-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[data views] Content management api implementation #155803
[data views] Content management api implementation #155803
Conversation
…into data_views_content_mgmt
…om:mattkime/kibana into content_management_api_so_type_abstraction
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
…m:mattkime/kibana into data_views_content_mgmt_with_abstractions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kibana-gis changes LGTM
code review only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, code review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly looking good! I've added mostly questions rather than feedback.
const dataViewAttributesSchema = schema.object( | ||
{ | ||
title: schema.string(), | ||
type: schema.maybe(schema.string()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the type of the saved object (e.g. "index-pattern"
)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its rollup
or empty. I guess I should express that in the schema.
// We need it for BWC support between different versions of the content | ||
export const serviceDefinition: ServicesDefinition = { | ||
get: { | ||
out: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we not need in
here, or does it have a default of just the id
or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no reason since the in
portion is just the id of the doc we're getting. That said, if we needed it we could add it later, although I admit it would be nice to have more clarity and agreement around what it would take to introduce new transforms.
mSearch: { | ||
out: { | ||
result: { | ||
schema: dataViewSavedObjectSchema, | ||
}, | ||
}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this section necessary? I'm not seeing any usage of mSearch
in the plugin.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Saw the enableMSearch
code below... Is this something that external APIs will make use of?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its for multi type search - src/plugins/content_management/docs/content_onboarding.md:686
@@ -63,7 +74,10 @@ export class DataViewsPublicPlugin | |||
return new DataViewsServicePublic({ | |||
hasData: this.hasData.start(core), | |||
uiSettings: new UiSettingsPublicToCommon(uiSettings), | |||
savedObjectsClient: new SavedObjectsClientPublicToCommon(savedObjects.client), | |||
savedObjectsClient: new SavedObjectsClientPublicToCommon( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: When first going through this code I was a little confused by the name savedObjectsClient
. Since this client is no longer just a wrapper around the saved objects client, could we rename it something like dataViewsClient
to improve readability? savedObjectsClient
seems to be a bit of a misnomer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to factor out all the SavedObjectsClientPublicToCommon
entirely in a follow up. #158191
async get<T = unknown>(type: string, id: string) { | ||
const response = await this.savedObjectClient.resolve<T>(type, id); | ||
async getSavedSearch(id: string) { | ||
const response = await this.savedObjectClient.resolve('search', id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once saved search moves to the content management APIs, can the usage of savedObjectClient
here be removed entirely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, thats exactly the idea.
options, | ||
}); | ||
|
||
return response.item as SavedObject<DataViewAttributes>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm slightly concerned by the need to cast here: Is it necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added comment that addresses this - update may return a partial SO or a full SO. In this case its returning a full SO and thats why I'm casting it as such.
} | ||
|
||
delete(type: string, id: string) { | ||
return this.savedObjectClient.delete(type, id, { force: true }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything necessary to add to the new APIs that is analogous to force: true
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch! ...addressed
*/ | ||
export const LATEST_VERSION = 1; | ||
|
||
export const DataViewSOType = 'index-pattern'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Is there any reason you couldn't just re-export from ../../constants
instead of redefining this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good call
import { DataViewSOType } from '../../common/content_management'; | ||
import { cmServicesDefinition } from '../../common/content_management/cm_services'; | ||
|
||
export class DataViewsStorage extends SOContentStorage<DataViewCrudTypes> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this what takes care of up/down transforms for you since you're extending SOContentStorage
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, its the service definition. The service definition is passed in to SOContentStorage
so it can be applied in a consistent manner for different SO types. Since we only have v1, there's nothing to code for yet but there's an example here - src/plugins/content_management/docs/content_onboarding.md:587
Co-authored-by: Lukas Olson <olson.lukas@gmail.com>
…m:mattkime/kibana into data_views_content_mgmt_with_abstractions
this resolves #157069, right? |
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
References to deprecated APIs
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @mattkime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
@@ -21,7 +21,7 @@ import { serializedFieldFormatSchema, fieldSpecSchema } from '../../schemas'; | |||
const dataViewAttributesSchema = schema.object( | |||
{ | |||
title: schema.string(), | |||
type: schema.maybe(schema.string()), | |||
type: schema.maybe(schema.literal('rollup')), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to replace this with a constant (outside the scope of this PR), created a new issue here: #158410
Summary
Data views implements the content management api and associated minor changes. The bulk of the changes are in
(common|public|server)/content_management)
Closes #157069