feat(search-index): add search-index export and import commands#105
Merged
Conversation
easen-amp
reviewed
Aug 17, 2021
PikinerLiliya
approved these changes
Aug 26, 2021
Contributor
Author
|
Depends on amplience/dc-management-sdk-js#95. After that's merged, package.json must be updated. |
… --webhooks argument on import
…ebhook mode and for replicas
8b40a45 to
5fafc0d
Compare
Merged
easen-amp
approved these changes
Dec 7, 2021
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR adds search index export and import commands.
The export command is rather straightforward - it scans all search indexes in the hub, enriches them with related info such as its settings, assigned content types, keys and replicas, and dumps them to a JSON file for each index. Replicas do not appear as individual files - they are contained within their parent search index's file.
Webhooks are also exported with each search index, into the
webhooks/subfolder of the target directory. These include their webhook id, which is referenced by the fields ofEnrichedAssignedContentTypeso that the webhook can be found from these files when importing.On import, search indexes are created or updated depending on if a match with the same name is found, and if its content does not match the search index being imported. Settings are synchronised afterwards, including a list of all replicas. The import uses a union of both the existing replicas and the replicas in the import file to determine what replicas to put in the settings, and update the settings of. Replicas are never deleted - as their names are unique and reserved, deleting them would cause issues.
Assigned content types are created automatically, and will try to sync with what you are importing - including deleting assignments that are not present on the file being imported. By default, each assigned content type uses the default webhooks created when the type was created - or the existing webhooks if the assignment already existed.
Optionally, the user can provide a
--webhooksflag, which allows importing webhooks relating to assigned content types within search indexes. When importing webhooks, the command attempts to rewrite occurrences of thewithDeliveryContentItemtag within the webhook body to point to the target hub's name and virtual staging environment. If different, this new body and any other related properties are copied to the target webhook.A clone step is also added for search indexes, which occurs immediately before content item import, so that step triggers any webhooks. Similar to extensions, the
revertversion of this step does not delete search indexes, as the names are unique and reserved on creation. Deleting them might make them impossible to recreate in the future, so we prefer to leave them alive to update in the future instead.