@uniformdev/transformer 1.1.35 → 1.1.36

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
@@ -307,7 +307,10 @@ declare class CompositionService {
307
307
  }
308
308
 
309
309
  declare class Logger {
310
+ private verbose;
311
+ constructor(verbose?: boolean);
310
312
  info(message: string): void;
313
+ debug(message: string): void;
311
314
  success(message: string): void;
312
315
  error(message: string): void;
313
316
  warn(message: string): void;
package/dist/index.js CHANGED
@@ -649,6 +649,7 @@ var CompositionConverterService = class {
649
649
  );
650
650
  const contentType = this.generateContentType(component);
651
651
  contentTypeMap.set(rootType, contentType);
652
+ this.logger.debug(`Generated content type "${rootType}" with ${contentType.fields.length} field(s): ${contentType.fields.map((f) => f.id).join(", ")}`);
652
653
  } catch (error) {
653
654
  if (error instanceof ComponentNotFoundError) {
654
655
  this.logger.warn(`Component not found: ${rootType} \u2014 skipping content type generation`);
@@ -684,6 +685,7 @@ var CompositionConverterService = class {
684
685
  if (isRefType) {
685
686
  const contentType = this.generateContentType(component);
686
687
  targetContentTypeMap.set(targetType, contentType);
688
+ this.logger.debug(`Generated reference content type "${targetType}" with ${contentType.fields.length} field(s): ${contentType.fields.map((f) => f.id).join(", ")}`);
687
689
  }
688
690
  if (isBlockType) {
689
691
  let blockId = targetType;
@@ -713,6 +715,7 @@ var CompositionConverterService = class {
713
715
  blockContentType.id = blockId;
714
716
  blockContentType.name = needsRename ? `${blockContentType.name} Block` : blockContentType.name;
715
717
  targetContentTypeMap.set(blockId, blockContentType);
718
+ this.logger.debug(`Generated block content type "${blockId}" with ${blockContentType.fields.length} field(s): ${blockContentType.fields.map((f) => f.id).join(", ")}`);
716
719
  }
717
720
  if (!isBlockType) {
718
721
  if (!isRefType) {
@@ -754,6 +757,7 @@ var CompositionConverterService = class {
754
757
  }
755
758
  } else {
756
759
  entry = this.generateEntryFromComposition(composition);
760
+ this.logger.debug(`Generated entry "${entry.entry._id}" from composition "${compositionName}" (${compositionType}) with fields: ${Object.keys(entry.entry.fields).join(", ") || "(none)"}`);
757
761
  }
758
762
  const refsByType = /* @__PURE__ */ new Map();
759
763
  if (componentsToReferences.length > 0 && comp.slots) {
@@ -771,6 +775,7 @@ var CompositionConverterService = class {
771
775
  compositionName,
772
776
  strict
773
777
  );
778
+ this.logger.debug(`Composition "${compositionName}": found ${instances.length} instance(s) of reference type "${refType}"`);
774
779
  if (instances.length > 0) {
775
780
  refsByType.set(refType, instances);
776
781
  if (missingTargetTypes.includes(refType)) {
@@ -784,6 +789,7 @@ var CompositionConverterService = class {
784
789
  const refIds = [];
785
790
  for (const inst of instances) {
786
791
  const existingId = this.findExistingEntryBySourceItem(inst, sourceItemMap);
792
+ this.logger.debug(`Reference instance "${inst.determinisiticId}" (${refType}): ${existingId ? `reusing existing entry "${existingId}"` : `assigned new ID "${inst.determinisiticId}"`}`);
787
793
  refIds.push(existingId ?? inst.determinisiticId);
788
794
  }
789
795
  resolvedRefIds.set(refType, refIds);
@@ -813,6 +819,7 @@ var CompositionConverterService = class {
813
819
  compositionName,
814
820
  strict
815
821
  );
822
+ this.logger.debug(`Composition "${compositionName}": found ${instances.length} instance(s) of block type "${blockType}"`);
816
823
  if (instances.length > 0) {
817
824
  blocksByType.set(blockType, instances);
818
825
  if (missingTargetTypes.includes(blockType)) {
@@ -869,6 +876,7 @@ var CompositionConverterService = class {
869
876
  "UPDATE",
870
877
  `${entriesDir}/${existingId}.json (${refType}, merged fields from "${this.truncate(compositionName, 50)}")`
871
878
  );
879
+ this.logger.debug(`Merging fields [${Object.keys(inst.instance.parameters ?? {}).join(", ") || "(none)"}] into existing reference entry "${existingId}"`);
872
880
  if (!whatIf) {
873
881
  const existingEntry = await this.fileSystem.readFile(existingEntryPath2);
874
882
  if (existingEntry?.entry) {
@@ -893,6 +901,7 @@ var CompositionConverterService = class {
893
901
  "WRITE",
894
902
  `${entriesDir}/${inst.determinisiticId}.json (${refType} from "${this.truncate(compositionName, 50)}")`
895
903
  );
904
+ this.logger.debug(`Writing reference entry "${inst.determinisiticId}" (${refType}) with fields: ${Object.keys(flatEntry.entry.fields).join(", ") || "(none)"}`);
896
905
  if (!whatIf) {
897
906
  await this.fileSystem.writeFile(flatEntryPath, flatEntry);
898
907
  }
@@ -919,6 +928,7 @@ var CompositionConverterService = class {
919
928
  },
920
929
  localizable: false
921
930
  });
931
+ this.logger.debug(`Field "${refType}" (contentReference) added to content type "${contentType.id}"`);
922
932
  }
923
933
  }
924
934
  }
@@ -941,6 +951,7 @@ var CompositionConverterService = class {
941
951
  },
942
952
  localizable: false
943
953
  });
954
+ this.logger.debug(`Field "${resolvedBlockId}" ($block) added to content type "${contentType.id}"`);
944
955
  }
945
956
  }
946
957
  }
@@ -965,6 +976,7 @@ var CompositionConverterService = class {
965
976
  "WRITE",
966
977
  `${contentTypesDir}/${typeName}.json (${baseFieldCount} fields${extrasInfo})`
967
978
  );
979
+ this.logger.debug(`Content type "${typeName}" fields: ${contentType.fields.map((f) => `${f.id}:${f.type}`).join(", ")}`);
968
980
  if (!whatIf) {
969
981
  await this.fileSystem.writeFile(filePath, contentType);
970
982
  }
@@ -977,6 +989,7 @@ var CompositionConverterService = class {
977
989
  "WRITE",
978
990
  `${contentTypesDir}/${typeName}.json (${contentType.fields.length} fields)`
979
991
  );
992
+ this.logger.debug(`Content type "${typeName}" fields: ${contentType.fields.map((f) => `${f.id}:${f.type}`).join(", ")}`);
980
993
  if (!whatIf) {
981
994
  await this.fileSystem.writeFile(filePath, contentType);
982
995
  }
@@ -1342,6 +1355,7 @@ var PropertyPropagatorService = class {
1342
1355
  try {
1343
1356
  const { component: sourceComponent, filePath: sourceFilePath } = await this.componentService.loadComponent(fullComponentsDir, sourceType, findOptions);
1344
1357
  sourceComponents.push({ sourceType, sourceFilePath, sourceComponent });
1358
+ this.logger.debug(`Loaded source component "${sourceType}" from ${sourceFilePath}`);
1345
1359
  } catch (error) {
1346
1360
  if (error instanceof ComponentNotFoundError) {
1347
1361
  this.logger.warn(`Component not found: ${sourceType} (searched: ${fullComponentsDir})`);
@@ -1352,6 +1366,7 @@ var PropertyPropagatorService = class {
1352
1366
  }
1353
1367
  this.logger.info(`Loading component: ${targetComponentType}`);
1354
1368
  const { component: targetComponent, filePath: targetFilePath } = await this.componentService.loadComponent(fullComponentsDir, targetComponentType, findOptions);
1369
+ this.logger.debug(`Loaded target component "${targetComponentType}" from ${targetFilePath}`);
1355
1370
  const propertyNames = property.split("|").map((p) => p.trim()).filter((p) => p.length > 0);
1356
1371
  const resolvedParams = [];
1357
1372
  const resolvedNames = [];
@@ -1372,6 +1387,8 @@ var PropertyPropagatorService = class {
1372
1387
  if (!exists) {
1373
1388
  resolvedParams.push(param);
1374
1389
  resolvedNames.push(param.id);
1390
+ } else {
1391
+ this.logger.debug(`Parameter "${param.id}" already collected from another source \u2014 skipping duplicate`);
1375
1392
  }
1376
1393
  }
1377
1394
  }
@@ -1410,7 +1427,10 @@ var PropertyPropagatorService = class {
1410
1427
  targetGroup,
1411
1428
  findOptions
1412
1429
  );
1430
+ this.logger.debug(`Group "${targetGroup}" (id: ${groupId}) created on component ${targetComponentType}`);
1413
1431
  componentModified = true;
1432
+ } else {
1433
+ this.logger.debug(`Group "${targetGroup}" (id: ${groupId}) already exists on ${targetComponentType}`);
1414
1434
  }
1415
1435
  for (const param of resolvedParams) {
1416
1436
  const existingParam = this.componentService.findParameter(
@@ -1435,6 +1455,7 @@ var PropertyPropagatorService = class {
1435
1455
  param.id,
1436
1456
  findOptions
1437
1457
  );
1458
+ this.logger.debug(`Parameter "${param.id}" (type: ${param.type}) added to component ${targetComponentType} in group "${targetGroup}"`);
1438
1459
  componentModified = true;
1439
1460
  } else {
1440
1461
  this.logger.info(`Parameter "${param.id}" already exists on ${targetComponentType}`);
@@ -1454,7 +1475,10 @@ var PropertyPropagatorService = class {
1454
1475
  param.id,
1455
1476
  findOptions
1456
1477
  );
1478
+ this.logger.debug(`Parameter "${param.id}" added to group "${targetGroup}" on ${targetComponentType} (was missing from group)`);
1457
1479
  componentModified = true;
1480
+ } else {
1481
+ this.logger.debug(`Parameter "${param.id}" already in group "${targetGroup}" on ${targetComponentType} \u2014 no change`);
1458
1482
  }
1459
1483
  }
1460
1484
  }
@@ -1467,6 +1491,7 @@ var PropertyPropagatorService = class {
1467
1491
  compositionTypes,
1468
1492
  findOptions
1469
1493
  );
1494
+ this.logger.debug(`Found ${compositions.length} composition(s) matching types [${compositionTypes.join(", ")}]`);
1470
1495
  let modifiedCompositions = 0;
1471
1496
  let propagatedInstances = 0;
1472
1497
  for (const { composition, filePath } of compositions) {
@@ -1477,6 +1502,7 @@ var PropertyPropagatorService = class {
1477
1502
  findOptions
1478
1503
  );
1479
1504
  if (instances.length === 0) {
1505
+ this.logger.debug(`Skipping "${filePath}": no instances of ${targetComponentType} found`);
1480
1506
  continue;
1481
1507
  }
1482
1508
  const valuesToPropagate = {};
@@ -1486,6 +1512,7 @@ var PropertyPropagatorService = class {
1486
1512
  }
1487
1513
  }
1488
1514
  if (Object.keys(valuesToPropagate).length === 0) {
1515
+ this.logger.debug(`Skipping "${filePath}": ${instances.length} instance(s) of ${targetComponentType} found but none of [${resolvedNames.join(", ")}] present in root overrides`);
1489
1516
  continue;
1490
1517
  }
1491
1518
  let compositionModified = false;
@@ -1497,9 +1524,11 @@ var PropertyPropagatorService = class {
1497
1524
  this.compositionService.setInstanceParameters(instance, clonedValues);
1498
1525
  compositionModified = true;
1499
1526
  propagatedInstances++;
1527
+ const updatedParamNames = Object.keys(valuesToPropagate).join(", ");
1500
1528
  instanceUpdates.push(
1501
- `${targetComponentType} "${instanceName}": ${Object.keys(valuesToPropagate).join(", ")}`
1529
+ `${targetComponentType} "${instanceName}": ${updatedParamNames}`
1502
1530
  );
1531
+ this.logger.debug(`Component ${targetComponentType} "${instanceName}": parameters ${updatedParamNames} updated`);
1503
1532
  }
1504
1533
  if (compositionModified) {
1505
1534
  this.logger.action(whatIf, "UPDATE", `composition/${relativePath}`);
@@ -1522,7 +1551,10 @@ var PropertyPropagatorService = class {
1522
1551
  if (exists) {
1523
1552
  this.logger.action(whatIf, "DELETE", `Parameter "${param.id}" from ${sourceType}`);
1524
1553
  modifiedSource = this.componentService.removeParameter(modifiedSource, param.id, findOptions);
1554
+ this.logger.debug(`Parameter "${param.id}" removed from component ${sourceType}`);
1525
1555
  sourceComponentModified = true;
1556
+ } else {
1557
+ this.logger.debug(`Parameter "${param.id}" not found on source component "${sourceType}" \u2014 nothing to delete`);
1526
1558
  }
1527
1559
  }
1528
1560
  const beforeGroupCount = modifiedSource.parameters?.filter(
@@ -1561,6 +1593,8 @@ var PropertyPropagatorService = class {
1561
1593
  if (!whatIf) {
1562
1594
  await this.compositionService.saveComposition(filePath, composition);
1563
1595
  }
1596
+ } else {
1597
+ this.logger.debug(`No root overrides matching [${resolvedNames.join(", ")}] in composition/${relativePath}`);
1564
1598
  }
1565
1599
  }
1566
1600
  }
@@ -2934,9 +2968,16 @@ var FieldRemoverService = class {
2934
2968
  // src/cli/logger.ts
2935
2969
  import chalk from "chalk";
2936
2970
  var Logger = class {
2971
+ constructor(verbose = false) {
2972
+ this.verbose = verbose;
2973
+ }
2937
2974
  info(message) {
2938
2975
  console.log(`${chalk.blue("[INFO]")} ${message}`);
2939
2976
  }
2977
+ debug(message) {
2978
+ if (!this.verbose) return;
2979
+ console.log(`${chalk.magenta("[DEBUG]")} ${message}`);
2980
+ }
2940
2981
  success(message) {
2941
2982
  console.log(`${chalk.green("[DONE]")} ${message}`);
2942
2983
  }