@uniformdev/transformer 1.1.45 → 1.1.47

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 CHANGED
@@ -6173,7 +6173,7 @@ function createFlattenBlockFieldCommand() {
6173
6173
  const command = new Command15("flatten-block-field");
6174
6174
  command.description(
6175
6175
  "Dissolves a $block parameter by lifting the block content type fields onto the component and extracting block item values into composition instances directly."
6176
- ).option("--componentId <id>", "The ID of the component that owns the block parameter").option("--parameterId <id>", "The ID of the $block parameter to flatten").option("--excludeFields <ids>", "Comma-separated list of block content type field IDs to skip when flattening").hook("preAction", (thisCommand) => {
6176
+ ).option("--componentId <id>", "The ID (or ,;|-separated list of IDs) of the component(s) that own the block parameter").option("--parameterId <id>", "The ID of the $block parameter to flatten").option("--excludeFields <ids>", "Comma-separated list of block content type field IDs to skip when flattening").hook("preAction", (thisCommand) => {
6177
6177
  const opts = thisCommand.opts();
6178
6178
  const requiredOptions = [
6179
6179
  { name: "componentId", flag: "--componentId" },
@@ -6193,31 +6193,49 @@ function createFlattenBlockFieldCommand() {
6193
6193
  excludeFields: opts.excludeFields
6194
6194
  };
6195
6195
  const logger = new Logger();
6196
+ logger.info(`componentId: ${options.componentId}`);
6197
+ logger.info(`parameterId: ${options.parameterId}`);
6198
+ logger.info(`excludeFields: ${options.excludeFields ?? ""}`);
6196
6199
  const fileSystem = new FileSystemService();
6197
6200
  const componentService = new ComponentService(fileSystem);
6198
6201
  const flattener = new BlockFieldFlattenerService(fileSystem, componentService, logger);
6202
+ const componentIds = splitList(options.componentId);
6203
+ const aggregate = {
6204
+ compositionsModified: 0,
6205
+ compositionPatternsModified: 0,
6206
+ componentPatternsModified: 0
6207
+ };
6199
6208
  try {
6200
- const result = await flattener.flatten({
6201
- rootDir: options.rootDir,
6202
- componentsDir: options.componentsDir,
6203
- compositionsDir: options.compositionsDir,
6204
- compositionPatternsDir: options.compositionPatternsDir,
6205
- componentPatternsDir: options.componentPatternsDir,
6206
- contentTypesDir: options.contentTypesDir,
6207
- componentId: options.componentId,
6208
- parameterId: options.parameterId,
6209
- whatIf: options.whatIf ?? false,
6210
- strict: options.strict ?? false,
6211
- excludeFields: options.excludeFields ? options.excludeFields.split(",").map((s) => s.trim()) : []
6212
- });
6209
+ for (const componentId of componentIds) {
6210
+ try {
6211
+ const result = await flattener.flatten({
6212
+ rootDir: options.rootDir,
6213
+ componentsDir: options.componentsDir,
6214
+ compositionsDir: options.compositionsDir,
6215
+ compositionPatternsDir: options.compositionPatternsDir,
6216
+ componentPatternsDir: options.componentPatternsDir,
6217
+ contentTypesDir: options.contentTypesDir,
6218
+ componentId,
6219
+ parameterId: options.parameterId,
6220
+ whatIf: options.whatIf ?? false,
6221
+ strict: options.strict ?? false,
6222
+ excludeFields: options.excludeFields ? options.excludeFields.split(",").map((s) => s.trim()) : []
6223
+ });
6224
+ aggregate.compositionsModified += result.compositionsModified;
6225
+ aggregate.compositionPatternsModified += result.compositionPatternsModified;
6226
+ aggregate.componentPatternsModified += result.componentPatternsModified;
6227
+ } catch (error) {
6228
+ if (error instanceof ComponentNotFoundError || error instanceof PropertyNotFoundError) {
6229
+ logger.warn(error.message);
6230
+ continue;
6231
+ }
6232
+ throw error;
6233
+ }
6234
+ }
6213
6235
  logger.success(
6214
- `Flattened parameter "${options.parameterId}" on component "${options.componentId}": ${result.compositionsModified} composition(s), ${result.compositionPatternsModified} composition pattern(s), ${result.componentPatternsModified} component pattern(s) updated`
6236
+ `Flattened parameter "${options.parameterId}" on component "${options.componentId}": ${aggregate.compositionsModified} composition(s), ${aggregate.compositionPatternsModified} composition pattern(s), ${aggregate.componentPatternsModified} component pattern(s) updated`
6215
6237
  );
6216
6238
  } catch (error) {
6217
- if (error instanceof ComponentNotFoundError || error instanceof PropertyNotFoundError) {
6218
- logger.warn(error.message);
6219
- return;
6220
- }
6221
6239
  if (error instanceof TransformError) {
6222
6240
  logger.error(error.message);
6223
6241
  process.exit(1);
@@ -7200,6 +7218,15 @@ var RootSlotPropagatorService = class {
7200
7218
  this.logger.debug(
7201
7219
  `Found ${compositions.length} composition(s) matching types [${compositionTypes.join(", ")}]`
7202
7220
  );
7221
+ const allowedFromSource = /* @__PURE__ */ new Set();
7222
+ for (const { sourceComponent } of sourceComponents) {
7223
+ for (const slotName of slotNames) {
7224
+ const slotDef = this.componentService.findSlot(sourceComponent, slotName, findOptions);
7225
+ for (const allowed of slotDef?.allowedComponents ?? []) {
7226
+ allowedFromSource.add(allowed);
7227
+ }
7228
+ }
7229
+ }
7203
7230
  const componentTypesInSlot = /* @__PURE__ */ new Set();
7204
7231
  for (const { composition } of compositions) {
7205
7232
  const rootSlots = composition.composition.slots ?? {};
@@ -7212,9 +7239,9 @@ var RootSlotPropagatorService = class {
7212
7239
  }
7213
7240
  }
7214
7241
  }
7215
- const collectedTypes = Array.from(componentTypesInSlot).sort();
7242
+ const collectedTypes = [.../* @__PURE__ */ new Set([...allowedFromSource, ...componentTypesInSlot])].sort();
7216
7243
  this.logger.info(
7217
- `Collected component types from slot contents: [${collectedTypes.join(", ")}]`
7244
+ `Collected allowedComponents: [${collectedTypes.join(", ")}] (from source definitions: [${[...allowedFromSource].sort().join(", ")}], from slot contents: [${[...componentTypesInSlot].sort().join(", ")}])`
7218
7245
  );
7219
7246
  let modifiedComponent = { ...targetComponent };
7220
7247
  let componentModified = false;
@@ -7429,7 +7456,7 @@ function createPropagateRootSlotCommand() {
7429
7456
  // package.json
7430
7457
  var package_default = {
7431
7458
  name: "@uniformdev/transformer",
7432
- version: "1.1.45",
7459
+ version: "1.1.47",
7433
7460
  description: "CLI tool for transforming Uniform.dev serialization files offline",
7434
7461
  type: "module",
7435
7462
  bin: {