@uniformdev/transformer 1.1.39 → 1.1.41

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/index.d.ts CHANGED
@@ -182,6 +182,12 @@ interface RemoveOrphanEntriesOptions extends GlobalOptions {
182
182
  }
183
183
  interface RemoveUnusedContentTypesOptions extends GlobalOptions {
184
184
  }
185
+ interface RemoveUnusedComponentTypesOptions extends GlobalOptions {
186
+ excludeComponentTypes?: string;
187
+ }
188
+ interface GenerateMissingProjectMapNodesOptions extends GlobalOptions {
189
+ rootContentTypes: string;
190
+ }
185
191
 
186
192
  declare class TransformError extends Error {
187
193
  constructor(message: string);
@@ -622,4 +628,4 @@ declare class FieldRemoverService {
622
628
  private removeKeysFromMap;
623
629
  }
624
630
 
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 };
631
+ 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
@@ -1601,6 +1601,11 @@ function walkAndRegenerate(value, currentPath) {
1601
1601
  return value;
1602
1602
  }
1603
1603
 
1604
+ // src/core/utils.ts
1605
+ function splitList(value) {
1606
+ return value.split(/[,;|]/).map((s) => s.trim()).filter((s) => s.length > 0);
1607
+ }
1608
+
1604
1609
  // src/core/services/property-propagator.service.ts
1605
1610
  var PropertyPropagatorService = class {
1606
1611
  constructor(fileSystem, componentService, compositionService, logger) {
@@ -1644,7 +1649,7 @@ var PropertyPropagatorService = class {
1644
1649
  this.logger.info(`Loading component: ${targetComponentType}`);
1645
1650
  const { component: targetComponent, filePath: targetFilePath } = await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);
1646
1651
  this.logger.debug(`Loaded target component "${targetComponentType}" from ${targetFilePath}`);
1647
- const propertyNames = property.split("|").map((p) => p.trim()).filter((p) => p.length > 0);
1652
+ const propertyNames = splitList(property);
1648
1653
  const resolvedParams = [];
1649
1654
  const resolvedNames = [];
1650
1655
  for (const { sourceType, sourceComponent } of sourceComponents) {
@@ -1882,7 +1887,7 @@ var PropertyPropagatorService = class {
1882
1887
  };
1883
1888
  }
1884
1889
  parsePipeSeparatedValues(value, strict) {
1885
- const entries = value.split("|").map((entry) => entry.trim()).filter((entry) => entry.length > 0);
1890
+ const entries = splitList(value);
1886
1891
  const normalized = [];
1887
1892
  for (const entry of entries) {
1888
1893
  const exists = normalized.some(
@@ -2318,7 +2323,7 @@ var ComponentAdderService = class {
2318
2323
  return id1.toLowerCase() === id2.toLowerCase();
2319
2324
  }
2320
2325
  parseParentComponentTypes(parentComponentType) {
2321
- return parentComponentType.split("|").map((t) => t.trim()).filter((t) => t.length > 0);
2326
+ return splitList(parentComponentType);
2322
2327
  }
2323
2328
  matchesAnyParentType(instanceType, parentTypes, strict) {
2324
2329
  return parentTypes.some((pt) => this.compareIds(instanceType, pt, strict));
@@ -2591,8 +2596,7 @@ var ComponentAdderService = class {
2591
2596
  }
2592
2597
  const newInstance = {
2593
2598
  type: componentTypeInPattern,
2594
- _pattern: pattern.componentPatternId,
2595
- _id: randomUUID()
2599
+ _pattern: pattern.componentPatternId
2596
2600
  };
2597
2601
  const compositionsResult = await this.addComponentToDirectory(
2598
2602
  fullCompositionsDir,
@@ -2706,13 +2710,19 @@ var ComponentAdderService = class {
2706
2710
  continue;
2707
2711
  }
2708
2712
  const rootInstance = composition.composition;
2713
+ const rootPath = `${rootInstance._id ?? ""}${rootInstance.type}`;
2709
2714
  let modified = false;
2710
2715
  if (this.matchesAnyParentType(rootInstance.type, parentTypes, strict)) {
2711
2716
  if (!rootInstance.slots) {
2712
2717
  rootInstance.slots = {};
2713
2718
  }
2714
2719
  const instanceCopy = JSON.parse(JSON.stringify(newInstance));
2715
- this.regenerateInstanceIds(instanceCopy);
2720
+ if (instanceCopy._pattern !== void 0) {
2721
+ const slotIndex = rootInstance.slots[slot]?.length ?? 0;
2722
+ instanceCopy._id = computeGuidHash(`${rootPath}.${slot}[${slotIndex}]${instanceCopy.type}`);
2723
+ } else {
2724
+ this.regenerateInstanceIds(instanceCopy);
2725
+ }
2716
2726
  this.addComponentToSlot(rootInstance.slots, slot, instanceCopy);
2717
2727
  modified = true;
2718
2728
  }
@@ -2722,7 +2732,8 @@ var ComponentAdderService = class {
2722
2732
  parentTypes,
2723
2733
  slot,
2724
2734
  newInstance,
2725
- strict
2735
+ strict,
2736
+ rootPath
2726
2737
  );
2727
2738
  if (nestedModified) {
2728
2739
  modified = true;
@@ -2753,17 +2764,24 @@ var ComponentAdderService = class {
2753
2764
  }
2754
2765
  return filesModified;
2755
2766
  }
2756
- addComponentToNestedSlots(slots, parentTypes, slot, newInstance, strict) {
2767
+ addComponentToNestedSlots(slots, parentTypes, slot, newInstance, strict, pathPrefix) {
2757
2768
  let modified = false;
2758
- for (const slotInstances of Object.values(slots)) {
2769
+ for (const [slotName, slotInstances] of Object.entries(slots)) {
2759
2770
  if (!Array.isArray(slotInstances)) continue;
2760
- for (const instance of slotInstances) {
2771
+ for (let i = 0; i < slotInstances.length; i++) {
2772
+ const instance = slotInstances[i];
2773
+ const instancePath = `${pathPrefix}.${slotName}[${i}]${instance.type}`;
2761
2774
  if (this.matchesAnyParentType(instance.type, parentTypes, strict)) {
2762
2775
  if (!instance.slots) {
2763
2776
  instance.slots = {};
2764
2777
  }
2765
2778
  const instanceCopy = JSON.parse(JSON.stringify(newInstance));
2766
- this.regenerateInstanceIds(instanceCopy);
2779
+ if (instanceCopy._pattern !== void 0) {
2780
+ const slotIndex = instance.slots[slot]?.length ?? 0;
2781
+ instanceCopy._id = computeGuidHash(`${instancePath}.${slot}[${slotIndex}]${instanceCopy.type}`);
2782
+ } else {
2783
+ this.regenerateInstanceIds(instanceCopy);
2784
+ }
2767
2785
  this.addComponentToSlot(instance.slots, slot, instanceCopy);
2768
2786
  modified = true;
2769
2787
  }
@@ -2773,7 +2791,8 @@ var ComponentAdderService = class {
2773
2791
  parentTypes,
2774
2792
  slot,
2775
2793
  newInstance,
2776
- strict
2794
+ strict,
2795
+ instancePath
2777
2796
  );
2778
2797
  if (nestedModified) {
2779
2798
  modified = true;