feat: enhance AEM service and content type utilities to support UID r…#979
Merged
umeshmore45 merged 2 commits intodevfrom Feb 25, 2026
Merged
feat: enhance AEM service and content type utilities to support UID r…#979umeshmore45 merged 2 commits intodevfrom
umeshmore45 merged 2 commits intodevfrom
Conversation
…emapping and improve schema handling resolved bugs - CMG-816, CMG-812
vikrantraut
approved these changes
Feb 25, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR enhances the AEM migration service and content type utilities to support UID remapping when content types are mapped to different UIDs in the destination stack. The changes introduce a remapReferenceUids utility function that handles remapping of content type references across various field types (json, html, global_field, reference), and updates the UI to fix issues with nested field deletion and schema resolution.
Changes:
- Introduced
remapReferenceUidsutility to remap content type UIDs in reference fields using keyMapper - Fixed recursive deletion of nested/descendant fields in ContentMapper when parent fields are changed
- Fixed schema resolution issues by using local
resolvedSchemavariable to avoid stale state
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| ui/src/components/ContentMapper/index.tsx | Refactored field deletion logic to recursively collect all descendants and use functional state updates; introduced resolvedSchema local variable to fix stale closure issues with schema state |
| api/src/utils/content-type-creator.utils.ts | Added remapReferenceUids function and threaded keyMapper parameter through buildFieldSchema recursion; applied UID remapping to all reference_to fields in schema generation |
| api/src/services/aem.service.ts | Enhanced entry creation to remap content type UIDs in reference fields using keyMapper before looking up entry mappings |
Comments suppressed due to low confidence (1)
ui/src/components/ContentMapper/index.tsx:1484
- After collecting all descendants and updating state on lines 1467-1475, the code immediately updates
existingFieldagain on lines 1481-1484. This second update adds the newly selected value. However, since React batches state updates, both updates should work correctly. Still, it would be clearer to combine these into a single state update that both removes descendants and adds the new value, to avoid potential issues if React's batching behavior changes.
setExistingField((prev) => {
const next = { ...prev };
allDescendants.forEach((item) => delete next[item?.backupFieldUid]);
return next;
});
setIsFieldDeleted(true); // once, outside loop
setSelectedOptions((prev) => prev.filter((opt) => !labelsToRemove.has(opt)));
}
else {
setIsFieldDeleted(false);
}
setExistingField((prevOptions: ExistingFieldType) => ({
...prevOptions,
[backupFieldUid]: { label: selectedValue?.label, value: selectedValue?.value }
}));
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…duplicate processing of descendants
umeshmore45
approved these changes
Feb 25, 2026
sayalijoshi27
approved these changes
Feb 25, 2026
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.
…emapping and improve schema handling resolved bugs - CMG-816, CMG-812