@uniformdev/transformer 1.1.39 → 1.1.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +509 -13
- package/dist/cli/index.js.map +1 -1
- package/dist/index.d.ts +6 -1
- package/dist/index.js +23 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -182,6 +182,11 @@ interface RemoveOrphanEntriesOptions extends GlobalOptions {
|
|
|
182
182
|
}
|
|
183
183
|
interface RemoveUnusedContentTypesOptions extends GlobalOptions {
|
|
184
184
|
}
|
|
185
|
+
interface RemoveUnusedComponentTypesOptions extends GlobalOptions {
|
|
186
|
+
}
|
|
187
|
+
interface GenerateMissingProjectMapNodesOptions extends GlobalOptions {
|
|
188
|
+
rootContentTypes: string;
|
|
189
|
+
}
|
|
185
190
|
|
|
186
191
|
declare class TransformError extends Error {
|
|
187
192
|
constructor(message: string);
|
|
@@ -622,4 +627,4 @@ declare class FieldRemoverService {
|
|
|
622
627
|
private removeKeysFromMap;
|
|
623
628
|
}
|
|
624
629
|
|
|
625
|
-
export { type AddComponentOptions, type AddComponentParameterOptions, type AddComponentPatternOptions, type AddContentTypeFieldOptions, ComponentAdderService, ComponentAlreadyExistsError, type ComponentDefinition, type ComponentInstance, ComponentNotFoundError, ComponentRenamerService, ComponentService, type Composition, CompositionConverterService, type CompositionOverrides, type CompositionPatternCandidatesOptions, type CompositionRoot, CompositionService, type ContentTypeDefinition$1 as ContentTypeDefinition, type ContentTypeField$1 as ContentTypeField, type ConvertCompositionsToEntriesOptions, DuplicateIdError, FieldRemoverService, FileNotFoundError, FileSystemService, type FlattenBlockFieldOptions, type GlobalOptions, InvalidYamlError, Logger, type PackSerializationOptions, type Parameter, ParameterRemoverService, type ParameterValue, type PropagateRootComponentPropertyOptions, type PropagateRootComponentSlotOptions, PropertyNotFoundError, PropertyPropagatorService, type RemoveFieldOptions, type RemoveOrphanEntriesOptions, type RemoveParameterOptions, type RemoveUnusedContentTypesOptions, type RenameComponentOptions, type RenameSlotOptions, SlotAlreadyExistsError, type SlotDefinition, SlotNotFoundError, SlotRenamerService, TransformError, type UnpackSerializationOptions, computeGuidHash, regenerateIds };
|
|
630
|
+
export { type AddComponentOptions, type AddComponentParameterOptions, type AddComponentPatternOptions, type AddContentTypeFieldOptions, ComponentAdderService, ComponentAlreadyExistsError, type ComponentDefinition, type ComponentInstance, ComponentNotFoundError, ComponentRenamerService, ComponentService, type Composition, CompositionConverterService, type CompositionOverrides, type CompositionPatternCandidatesOptions, type CompositionRoot, CompositionService, type ContentTypeDefinition$1 as ContentTypeDefinition, type ContentTypeField$1 as ContentTypeField, type ConvertCompositionsToEntriesOptions, DuplicateIdError, FieldRemoverService, FileNotFoundError, FileSystemService, type FlattenBlockFieldOptions, type GenerateMissingProjectMapNodesOptions, type GlobalOptions, InvalidYamlError, Logger, type PackSerializationOptions, type Parameter, ParameterRemoverService, type ParameterValue, type PropagateRootComponentPropertyOptions, type PropagateRootComponentSlotOptions, PropertyNotFoundError, PropertyPropagatorService, type RemoveFieldOptions, type RemoveOrphanEntriesOptions, type RemoveParameterOptions, type RemoveUnusedComponentTypesOptions, type RemoveUnusedContentTypesOptions, type RenameComponentOptions, type RenameSlotOptions, SlotAlreadyExistsError, type SlotDefinition, SlotNotFoundError, SlotRenamerService, TransformError, type UnpackSerializationOptions, computeGuidHash, regenerateIds };
|
package/dist/index.js
CHANGED
|
@@ -2591,8 +2591,7 @@ var ComponentAdderService = class {
|
|
|
2591
2591
|
}
|
|
2592
2592
|
const newInstance = {
|
|
2593
2593
|
type: componentTypeInPattern,
|
|
2594
|
-
_pattern: pattern.componentPatternId
|
|
2595
|
-
_id: randomUUID()
|
|
2594
|
+
_pattern: pattern.componentPatternId
|
|
2596
2595
|
};
|
|
2597
2596
|
const compositionsResult = await this.addComponentToDirectory(
|
|
2598
2597
|
fullCompositionsDir,
|
|
@@ -2706,13 +2705,19 @@ var ComponentAdderService = class {
|
|
|
2706
2705
|
continue;
|
|
2707
2706
|
}
|
|
2708
2707
|
const rootInstance = composition.composition;
|
|
2708
|
+
const rootPath = `${rootInstance._id ?? ""}${rootInstance.type}`;
|
|
2709
2709
|
let modified = false;
|
|
2710
2710
|
if (this.matchesAnyParentType(rootInstance.type, parentTypes, strict)) {
|
|
2711
2711
|
if (!rootInstance.slots) {
|
|
2712
2712
|
rootInstance.slots = {};
|
|
2713
2713
|
}
|
|
2714
2714
|
const instanceCopy = JSON.parse(JSON.stringify(newInstance));
|
|
2715
|
-
|
|
2715
|
+
if (instanceCopy._pattern !== void 0) {
|
|
2716
|
+
const slotIndex = rootInstance.slots[slot]?.length ?? 0;
|
|
2717
|
+
instanceCopy._id = computeGuidHash(`${rootPath}.${slot}[${slotIndex}]${instanceCopy.type}`);
|
|
2718
|
+
} else {
|
|
2719
|
+
this.regenerateInstanceIds(instanceCopy);
|
|
2720
|
+
}
|
|
2716
2721
|
this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);
|
|
2717
2722
|
modified = true;
|
|
2718
2723
|
}
|
|
@@ -2722,7 +2727,8 @@ var ComponentAdderService = class {
|
|
|
2722
2727
|
parentTypes,
|
|
2723
2728
|
slot,
|
|
2724
2729
|
newInstance,
|
|
2725
|
-
strict
|
|
2730
|
+
strict,
|
|
2731
|
+
rootPath
|
|
2726
2732
|
);
|
|
2727
2733
|
if (nestedModified) {
|
|
2728
2734
|
modified = true;
|
|
@@ -2753,17 +2759,24 @@ var ComponentAdderService = class {
|
|
|
2753
2759
|
}
|
|
2754
2760
|
return filesModified;
|
|
2755
2761
|
}
|
|
2756
|
-
addComponentToNestedSlots(slots, parentTypes, slot, newInstance, strict) {
|
|
2762
|
+
addComponentToNestedSlots(slots, parentTypes, slot, newInstance, strict, pathPrefix) {
|
|
2757
2763
|
let modified = false;
|
|
2758
|
-
for (const slotInstances of Object.
|
|
2764
|
+
for (const [slotName, slotInstances] of Object.entries(slots)) {
|
|
2759
2765
|
if (!Array.isArray(slotInstances)) continue;
|
|
2760
|
-
for (
|
|
2766
|
+
for (let i = 0; i < slotInstances.length; i++) {
|
|
2767
|
+
const instance = slotInstances[i];
|
|
2768
|
+
const instancePath = `${pathPrefix}.${slotName}[${i}]${instance.type}`;
|
|
2761
2769
|
if (this.matchesAnyParentType(instance.type, parentTypes, strict)) {
|
|
2762
2770
|
if (!instance.slots) {
|
|
2763
2771
|
instance.slots = {};
|
|
2764
2772
|
}
|
|
2765
2773
|
const instanceCopy = JSON.parse(JSON.stringify(newInstance));
|
|
2766
|
-
|
|
2774
|
+
if (instanceCopy._pattern !== void 0) {
|
|
2775
|
+
const slotIndex = instance.slots[slot]?.length ?? 0;
|
|
2776
|
+
instanceCopy._id = computeGuidHash(`${instancePath}.${slot}[${slotIndex}]${instanceCopy.type}`);
|
|
2777
|
+
} else {
|
|
2778
|
+
this.regenerateInstanceIds(instanceCopy);
|
|
2779
|
+
}
|
|
2767
2780
|
this.addComponentToSlot(instance.slots, slot, instanceCopy);
|
|
2768
2781
|
modified = true;
|
|
2769
2782
|
}
|
|
@@ -2773,7 +2786,8 @@ var ComponentAdderService = class {
|
|
|
2773
2786
|
parentTypes,
|
|
2774
2787
|
slot,
|
|
2775
2788
|
newInstance,
|
|
2776
|
-
strict
|
|
2789
|
+
strict,
|
|
2790
|
+
instancePath
|
|
2777
2791
|
);
|
|
2778
2792
|
if (nestedModified) {
|
|
2779
2793
|
modified = true;
|