-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Saved Object Management] Address v1 HTTP API TODOs
#150892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
e16a64b
f919661
2720745
bf1c2b8
f8a8fe6
9a876fd
3854b37
37beda9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ | |
| * Side Public License, v 1. | ||
| */ | ||
|
|
||
| import { schema } from '@kbn/config-schema'; | ||
| import { type Type, schema } from '@kbn/config-schema'; | ||
| import type { IRouter } from '@kbn/core/server'; | ||
|
|
||
| import type { v1 } from '../../common'; | ||
|
|
@@ -24,6 +24,11 @@ export const registerFindRoute = ( | |
| const searchOperatorSchema = schema.oneOf([schema.literal('OR'), schema.literal('AND')], { | ||
| defaultValue: 'OR', | ||
| }); | ||
| const sortFieldSchema: Type<keyof v1.SavedObjectWithMetadata> = schema.oneOf([ | ||
| schema.literal('created_at'), | ||
| schema.literal('updated_at'), | ||
| schema.literal('type'), | ||
| ]); | ||
|
Comment on lines
+27
to
+31
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is probably the riskiest change to introduce here. The sort columns we define for the front end are pretty much fixed to these values but it is possible for columns to be registered dynamically and attempt to sort by a nested
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems reasonable to me. In fact, I like the approach that we have pre-defined options for sorting. We do, however, have to consider the case where a type may not have these fields, since we don't have a default option to sort on here. What do you think about defaulting to |
||
|
|
||
| router.get( | ||
| { | ||
|
|
@@ -35,7 +40,7 @@ export const registerFindRoute = ( | |
| type: schema.oneOf([schema.string(), schema.arrayOf(schema.string())]), | ||
| search: schema.maybe(schema.string()), | ||
| defaultSearchOperator: searchOperatorSchema, | ||
| sortField: schema.maybe(schema.string()), | ||
| sortField: schema.maybe(sortFieldSchema), | ||
| sortOrder: schema.maybe(schema.oneOf([schema.literal('asc'), schema.literal('desc')])), | ||
| hasReference: schema.maybe( | ||
| schema.oneOf([referenceSchema, schema.arrayOf(referenceSchema)]) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.