-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[EEM] Replace hashed ID with human readable ID #193652
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,11 @@ | |
* 2.0. | ||
*/ | ||
|
||
import { SavedObjectModelDataBackfillFn } from '@kbn/core-saved-objects-server'; | ||
import { | ||
SavedObjectModelDataBackfillFn, | ||
SavedObjectModelTransformationDoc, | ||
SavedObjectModelUnsafeTransformFn, | ||
} from '@kbn/core-saved-objects-server'; | ||
import { SavedObject, SavedObjectsType } from '@kbn/core/server'; | ||
import { EntityDefinition } from '@kbn/entities-schema'; | ||
import { | ||
|
@@ -35,6 +39,20 @@ export const backfillInstalledComponents: SavedObjectModelDataBackfillFn< | |
return savedObject; | ||
}; | ||
|
||
const removeOptionalIdentityFields: SavedObjectModelUnsafeTransformFn< | ||
EntityDefinition, | ||
EntityDefinition | ||
> = (savedObject) => { | ||
// Doing only this may break displayNameTemplates | ||
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. Which I think is okay since we're likely to remove this anyway in the future since it's hard to do any kind of template in ES|QL at runtime. So the displayNameTemplate might become similar to the identity field, where we just let users decide which fields to concat instead. |
||
savedObject.attributes.identityFields = savedObject.attributes.identityFields.filter( | ||
(identityField) => identityField.optional === false | ||
); | ||
|
||
return { | ||
document: savedObject as SavedObjectModelTransformationDoc<EntityDefinition>, | ||
}; | ||
}; | ||
|
||
export const entityDefinition: SavedObjectsType = { | ||
name: SO_ENTITY_DEFINITION_TYPE, | ||
hidden: false, | ||
|
@@ -97,5 +115,13 @@ export const entityDefinition: SavedObjectsType = { | |
}, | ||
], | ||
}, | ||
'4': { | ||
changes: [ | ||
{ | ||
type: 'unsafe_transform', | ||
transformFn: removeOptionalIdentityFields, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; |
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.
This blocks people from using optional fields even though technically this is still supported in the code, and we transform the existing saved objects to remove them.
This is mainly due to not being able to change the saved object mapping.