Skip to content

feat: enhance AEM service and content type utilities to support UID r…#979

Merged
umeshmore45 merged 2 commits intodevfrom
bugfix/CMG-816
Feb 25, 2026
Merged

feat: enhance AEM service and content type utilities to support UID r…#979
umeshmore45 merged 2 commits intodevfrom
bugfix/CMG-816

Conversation

@shobhitupadhyayy
Copy link
Contributor

…emapping and improve schema handling resolved bugs - CMG-816, CMG-812

…emapping and improve schema handling resolved bugs - CMG-816, CMG-812
@shobhitupadhyayy shobhitupadhyayy requested a review from a team as a code owner February 25, 2026 09:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 remapReferenceUids utility 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 resolvedSchema variable 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 existingField again 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.

@umeshmore45 umeshmore45 merged commit b6ec338 into dev Feb 25, 2026
7 checks passed
@umeshmore45 umeshmore45 deleted the bugfix/CMG-816 branch February 25, 2026 12:07
@umeshmore45 umeshmore45 restored the bugfix/CMG-816 branch February 25, 2026 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants