-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[App Arch] [Cleanup] Saved object migrations from kibana plugin to new platform #64289
Closed
Closed
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
ed3a959
[App Arch] [Cleanup] Saved object migrations from kibana plugin to ne…
alexwizp bef7546
Merge remote-tracking branch 'upstream/master'
alexwizp 43244f3
add two generics TInputDoc and TOutputDoc
alexwizp d547ab1
fix check_published_api_changes.js
alexwizp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 think we need to add two generics cause it allow us to avoid a lot of casting in future.
Like e.g. here:
src/plugins/dashboard/server/saved_objects/dashboard_migrations.ts
Also using this approach we can guarantee that all Doc's extended from
SavedObjectUnsanitizedDoc
orSavedObjectSanitizedDoc
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.
To follow our slack discussion:
This is an alternative of #63943
However on #63943 we choose to only generify the
attributes
property ofSavedObjectUnsanitizedDoc
, as we didn't see any (valid) reasons plugin migration functions should be able to superseed/override the root SO type. This could also be dangerous as it may cause developer errors trying to push changes/properties not defined in the schema.Do you have any usages where you would need to use type override on the whole
SavedObjectUnsanitizedDoc
type?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.
At least in version 7.0.0
references
were added. And we should somehow handle it.Also who knows what will be added in future?
From the other hand if someone wants to add something into doc we have at least 2 options: use JS without typings, just cast object to needed type =) So, validation should be implemented in a different way
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.
Currently there's an index signature so anything goes, but we should definitely remove that
kibana/src/core/server/saved_objects/serialization/types.ts
Line 63 in 97d1685
Root properties cannot be added by plugins, so if we ever add them in Core, we can update this type at the same time like we recently did for the new
namespaces
root property.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.
@alexwizp could I get your review on #63943? Any argument on why the PR wouldn't answer the need in a better/safer way is welcome.