@contentful/experience-design-system-cli 2.41.1-dev-build-3a724687.0 → 2.41.1-dev-build-699ca2d9.0

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/app.js CHANGED
@@ -22282,14 +22282,42 @@ function parseCDFComponents(obj, prefix = "") {
22282
22282
  }
22283
22283
  return { components, tokens };
22284
22284
  }
22285
+ function entryValidator(name) {
22286
+ const check = ajv2.getSchema(`${CDF_SCHEMA_URL2}#/definitions/${name}`);
22287
+ if (!check)
22288
+ throw new Error(`the CDF schema has no "${name}" definition`);
22289
+ return check;
22290
+ }
22291
+ var validateComponentEntry = entryValidator("component");
22292
+ var validateTokenEntry = entryValidator("token");
22293
+ function toValidationErrors(errors, prefix = "") {
22294
+ return (errors ?? []).filter((err) => err.keyword !== "if").map((err) => ({
22295
+ path: `${prefix}${err.instancePath}` || "/",
22296
+ message: err.message ?? "Unknown validation error",
22297
+ expected: err.params ? JSON.stringify(err.params) : void 0
22298
+ }));
22299
+ }
22300
+ function entryErrors(node, prefix) {
22301
+ const errors = [];
22302
+ for (const [key, value] of Object.entries(node)) {
22303
+ if (key.startsWith("$") || typeof value !== "object" || value === null)
22304
+ continue;
22305
+ const path5 = `${prefix}/${key}`;
22306
+ const type = value["$type"];
22307
+ const check = type === "component" ? validateComponentEntry : TOKEN_TYPE_SET3.has(type) ? validateTokenEntry : void 0;
22308
+ if (!check) {
22309
+ errors.push(...entryErrors(value, path5));
22310
+ } else if (!check(value)) {
22311
+ errors.push(...toValidationErrors(check.errors, path5));
22312
+ }
22313
+ }
22314
+ return errors;
22315
+ }
22285
22316
  function validateCDF2(input) {
22286
22317
  const valid = validate2(input);
22287
22318
  if (!valid) {
22288
- const errors = (validate2.errors ?? []).map((err) => ({
22289
- path: err.instancePath || "/",
22290
- message: err.message ?? "Unknown validation error",
22291
- expected: err.params ? JSON.stringify(err.params) : void 0
22292
- }));
22319
+ const focused = typeof input === "object" && input !== null ? entryErrors(input, "") : [];
22320
+ const errors = focused.length > 0 ? focused : toValidationErrors(validate2.errors);
22293
22321
  return { valid: false, errors, components: [], tokens: [] };
22294
22322
  }
22295
22323
  const file = input;
@@ -22341,6 +22369,45 @@ var CDFTokenSchema2 = z3.strictObject({
22341
22369
  $description: z3.optional(z3.string())
22342
22370
  });
22343
22371
 
22372
+ // packages/experience-design-system-types/dist/src/cdf/repair-token-kinds.js
22373
+ var UNRESOLVED_WARNING = /\s*WARNING: token_kind unknown[^\n]*/;
22374
+ function inferTokenKind(propName, prop, tokens) {
22375
+ const bound = typeof prop.$default === "string" ? tokens.find(({ path: path5 }) => path5 === prop.$default) : void 0;
22376
+ if (bound)
22377
+ return bound.entry.$type;
22378
+ const name = propName.toLowerCase();
22379
+ const kinds = new Set(tokens.filter(({ path: path5 }) => path5.toLowerCase().split(".").includes(name)).map(({ entry }) => entry.$type));
22380
+ return kinds.size === 1 ? [...kinds][0] : void 0;
22381
+ }
22382
+ function withoutWarning(prop) {
22383
+ if (prop.$description === void 0)
22384
+ return prop;
22385
+ const description = prop.$description.replace(UNRESOLVED_WARNING, "").trim();
22386
+ const { $description: _stale, ...rest } = prop;
22387
+ return description ? { ...rest, $description: description } : rest;
22388
+ }
22389
+ function repairTokenKinds(entry, componentKey, tokens, note) {
22390
+ const properties = { ...entry.$properties };
22391
+ let repaired = false;
22392
+ for (const [name, prop] of Object.entries(entry.$properties)) {
22393
+ if (prop.$type !== "token" || prop["$token.kind"])
22394
+ continue;
22395
+ repaired = true;
22396
+ const kind = inferTokenKind(name, prop, tokens);
22397
+ if (kind) {
22398
+ properties[name] = { ...withoutWarning(prop), "$token.kind": kind };
22399
+ note?.(`${componentKey}.${name} had no token kind, so "${kind}" was taken from the token file`);
22400
+ } else {
22401
+ const plain = { ...withoutWarning(prop), $type: "string" };
22402
+ delete plain["$token.allowed"];
22403
+ delete plain.$default;
22404
+ properties[name] = plain;
22405
+ note?.(`${componentKey}.${name} had no token kind and none could be told, so it was saved as a string property`);
22406
+ }
22407
+ }
22408
+ return repaired ? { ...entry, $properties: properties } : entry;
22409
+ }
22410
+
22344
22411
  // packages/experience-design-system-types/dist/src/cdf/build.js
22345
22412
  function stripUnsupportedSlotFields(entry) {
22346
22413
  if (!entry.$slots)
@@ -22377,7 +22444,7 @@ function buildCDF2(components, tokens, opts = {}) {
22377
22444
  return void 0;
22378
22445
  const doc = { $schema: CDF_SCHEMA_URL2 };
22379
22446
  for (const { key, entry } of components) {
22380
- setAtPath(doc, key, stripUnsupportedSlotFields(entry));
22447
+ setAtPath(doc, key, stripUnsupportedSlotFields(repairTokenKinds(entry, key, tokens, opts.onRepair)));
22381
22448
  }
22382
22449
  for (const { path: path5, entry } of resolveTokenPathCollisions(tokens)) {
22383
22450
  setAtPath(doc, path5, entry);
@@ -29207,8 +29274,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
29207
29274
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
29208
29275
  const validation = validateCDF2(cdf);
29209
29276
  if (!validation.valid) {
29210
- const errors = validation.errors.filter((error) => error.message !== 'must match "then" schema');
29211
- throw new Error(`generated CDF failed validation: ${errors.map(describeCdfError).join("; ")}`);
29277
+ throw new Error(`generated CDF failed validation: ${validation.errors.map(describeCdfError).join("; ")}`);
29212
29278
  }
29213
29279
  return cdf;
29214
29280
  }
@@ -29235,7 +29301,11 @@ async function runPrintFiles(input, deps, onPatch) {
29235
29301
  db.close();
29236
29302
  }
29237
29303
  if (!input.tokenSessionId && input.tokensPath) tokens = await deps.readTokens(input.tokensPath);
29238
- const cdf = buildSavedCDF(components, tokens, { deleteAll: input.allowEmpty });
29304
+ const cdf = buildSavedCDF(components, tokens, {
29305
+ deleteAll: input.allowEmpty,
29306
+ onRepair: (message) => deps.warn(`${message}
29307
+ `)
29308
+ });
29239
29309
  await deps.writeFile(componentsPath, `${JSON.stringify(cdf, null, 2)}
29240
29310
  `);
29241
29311
  deps.warn(
@@ -30433,7 +30503,7 @@ function AgentsScreen({ onDone }) {
30433
30503
  hints: [
30434
30504
  { keys: "\u2191/\u2193", label: "move" },
30435
30505
  { keys: "\u23CE", label: "make default" },
30436
- { keys: "\u2192", label: "settings and test" },
30506
+ { keys: "\u2192", label: "settings" },
30437
30507
  { keys: "Esc/q", label: "back" }
30438
30508
  ]
30439
30509
  }
package/dist/index.js CHANGED
@@ -14474,19 +14474,11 @@ var init_src = __esm({
14474
14474
  }
14475
14475
  });
14476
14476
 
14477
- // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/token-kinds/repair-token-kinds.js
14478
- var init_repair_token_kinds = __esm({
14479
- "packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/helpers/token-kinds/repair-token-kinds.js"() {
14480
- "use strict";
14481
- }
14482
- });
14483
-
14484
14477
  // packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/services/run-cdf-generation-service.js
14485
14478
  var init_run_cdf_generation_service = __esm({
14486
14479
  "packages/experience-design-system-backend-pipeline/dist/src/steps/generation/src/services/run-cdf-generation-service.js"() {
14487
14480
  "use strict";
14488
14481
  init_agents();
14489
- init_repair_token_kinds();
14490
14482
  }
14491
14483
  });
14492
14484
 
@@ -25468,14 +25460,40 @@ function parseCDFComponents(obj, prefix = "") {
25468
25460
  }
25469
25461
  return { components, tokens };
25470
25462
  }
25463
+ function entryValidator(name) {
25464
+ const check = ajv2.getSchema(`${CDF_SCHEMA_URL2}#/definitions/${name}`);
25465
+ if (!check)
25466
+ throw new Error(`the CDF schema has no "${name}" definition`);
25467
+ return check;
25468
+ }
25469
+ function toValidationErrors(errors, prefix = "") {
25470
+ return (errors ?? []).filter((err) => err.keyword !== "if").map((err) => ({
25471
+ path: `${prefix}${err.instancePath}` || "/",
25472
+ message: err.message ?? "Unknown validation error",
25473
+ expected: err.params ? JSON.stringify(err.params) : void 0
25474
+ }));
25475
+ }
25476
+ function entryErrors(node, prefix) {
25477
+ const errors = [];
25478
+ for (const [key, value] of Object.entries(node)) {
25479
+ if (key.startsWith("$") || typeof value !== "object" || value === null)
25480
+ continue;
25481
+ const path5 = `${prefix}/${key}`;
25482
+ const type = value["$type"];
25483
+ const check = type === "component" ? validateComponentEntry : TOKEN_TYPE_SET3.has(type) ? validateTokenEntry : void 0;
25484
+ if (!check) {
25485
+ errors.push(...entryErrors(value, path5));
25486
+ } else if (!check(value)) {
25487
+ errors.push(...toValidationErrors(check.errors, path5));
25488
+ }
25489
+ }
25490
+ return errors;
25491
+ }
25471
25492
  function validateCDF2(input) {
25472
25493
  const valid = validate2(input);
25473
25494
  if (!valid) {
25474
- const errors = (validate2.errors ?? []).map((err) => ({
25475
- path: err.instancePath || "/",
25476
- message: err.message ?? "Unknown validation error",
25477
- expected: err.params ? JSON.stringify(err.params) : void 0
25478
- }));
25495
+ const focused = typeof input === "object" && input !== null ? entryErrors(input, "") : [];
25496
+ const errors = focused.length > 0 ? focused : toValidationErrors(validate2.errors);
25479
25497
  return { valid: false, errors, components: [], tokens: [] };
25480
25498
  }
25481
25499
  const file = input;
@@ -25497,7 +25515,7 @@ function validateCDF2(input) {
25497
25515
  const { components, tokens } = parseCDFComponents(file);
25498
25516
  return { valid: true, errors: [], components, tokens };
25499
25517
  }
25500
- var ajv2, validate2, TOKEN_TYPE_SET3;
25518
+ var ajv2, validate2, TOKEN_TYPE_SET3, validateComponentEntry, validateTokenEntry;
25501
25519
  var init_validate5 = __esm({
25502
25520
  "packages/experience-design-system-types/dist/src/cdf/validate.js"() {
25503
25521
  "use strict";
@@ -25506,6 +25524,8 @@ var init_validate5 = __esm({
25506
25524
  ajv2 = new Ajv2({ allErrors: true });
25507
25525
  validate2 = ajv2.compile(cdfJsonSchema2);
25508
25526
  TOKEN_TYPE_SET3 = new Set(DESIGN_TOKEN_TYPES2);
25527
+ validateComponentEntry = entryValidator("component");
25528
+ validateTokenEntry = entryValidator("token");
25509
25529
  }
25510
25530
  });
25511
25531
 
@@ -25546,6 +25566,51 @@ var init_types7 = __esm({
25546
25566
  }
25547
25567
  });
25548
25568
 
25569
+ // packages/experience-design-system-types/dist/src/cdf/repair-token-kinds.js
25570
+ function inferTokenKind(propName, prop, tokens) {
25571
+ const bound = typeof prop.$default === "string" ? tokens.find(({ path: path5 }) => path5 === prop.$default) : void 0;
25572
+ if (bound)
25573
+ return bound.entry.$type;
25574
+ const name = propName.toLowerCase();
25575
+ const kinds = new Set(tokens.filter(({ path: path5 }) => path5.toLowerCase().split(".").includes(name)).map(({ entry }) => entry.$type));
25576
+ return kinds.size === 1 ? [...kinds][0] : void 0;
25577
+ }
25578
+ function withoutWarning(prop) {
25579
+ if (prop.$description === void 0)
25580
+ return prop;
25581
+ const description = prop.$description.replace(UNRESOLVED_WARNING, "").trim();
25582
+ const { $description: _stale, ...rest } = prop;
25583
+ return description ? { ...rest, $description: description } : rest;
25584
+ }
25585
+ function repairTokenKinds(entry, componentKey, tokens, note) {
25586
+ const properties = { ...entry.$properties };
25587
+ let repaired = false;
25588
+ for (const [name, prop] of Object.entries(entry.$properties)) {
25589
+ if (prop.$type !== "token" || prop["$token.kind"])
25590
+ continue;
25591
+ repaired = true;
25592
+ const kind = inferTokenKind(name, prop, tokens);
25593
+ if (kind) {
25594
+ properties[name] = { ...withoutWarning(prop), "$token.kind": kind };
25595
+ note?.(`${componentKey}.${name} had no token kind, so "${kind}" was taken from the token file`);
25596
+ } else {
25597
+ const plain = { ...withoutWarning(prop), $type: "string" };
25598
+ delete plain["$token.allowed"];
25599
+ delete plain.$default;
25600
+ properties[name] = plain;
25601
+ note?.(`${componentKey}.${name} had no token kind and none could be told, so it was saved as a string property`);
25602
+ }
25603
+ }
25604
+ return repaired ? { ...entry, $properties: properties } : entry;
25605
+ }
25606
+ var UNRESOLVED_WARNING;
25607
+ var init_repair_token_kinds = __esm({
25608
+ "packages/experience-design-system-types/dist/src/cdf/repair-token-kinds.js"() {
25609
+ "use strict";
25610
+ UNRESOLVED_WARNING = /\s*WARNING: token_kind unknown[^\n]*/;
25611
+ }
25612
+ });
25613
+
25549
25614
  // packages/experience-design-system-types/dist/src/cdf/build.js
25550
25615
  function stripUnsupportedSlotFields(entry) {
25551
25616
  if (!entry.$slots)
@@ -25581,7 +25646,7 @@ function buildCDF2(components, tokens, opts = {}) {
25581
25646
  return void 0;
25582
25647
  const doc = { $schema: CDF_SCHEMA_URL2 };
25583
25648
  for (const { key, entry } of components) {
25584
- setAtPath(doc, key, stripUnsupportedSlotFields(entry));
25649
+ setAtPath(doc, key, stripUnsupportedSlotFields(repairTokenKinds(entry, key, tokens, opts.onRepair)));
25585
25650
  }
25586
25651
  for (const { path: path5, entry } of resolveTokenPathCollisions(tokens)) {
25587
25652
  setAtPath(doc, path5, entry);
@@ -25623,6 +25688,7 @@ var COLLISION_LEAF_KEY;
25623
25688
  var init_build2 = __esm({
25624
25689
  "packages/experience-design-system-types/dist/src/cdf/build.js"() {
25625
25690
  "use strict";
25691
+ init_repair_token_kinds();
25626
25692
  init_schema2();
25627
25693
  COLLISION_LEAF_KEY = "default";
25628
25694
  }
@@ -32965,8 +33031,7 @@ function buildSavedCDF(components, tokens, opts = {}) {
32965
33031
  if (!cdf) throw new Error("nothing to save \u2014 no components or tokens resolved");
32966
33032
  const validation = validateCDF2(cdf);
32967
33033
  if (!validation.valid) {
32968
- const errors = validation.errors.filter((error) => error.message !== 'must match "then" schema');
32969
- throw new Error(`generated CDF failed validation: ${errors.map(describeCdfError).join("; ")}`);
33034
+ throw new Error(`generated CDF failed validation: ${validation.errors.map(describeCdfError).join("; ")}`);
32970
33035
  }
32971
33036
  return cdf;
32972
33037
  }
@@ -32984,7 +33049,11 @@ async function runPrintFiles(input, deps, onPatch) {
32984
33049
  db.close();
32985
33050
  }
32986
33051
  if (!input.tokenSessionId && input.tokensPath) tokens = await deps.readTokens(input.tokensPath);
32987
- const cdf = buildSavedCDF(components, tokens, { deleteAll: input.allowEmpty });
33052
+ const cdf = buildSavedCDF(components, tokens, {
33053
+ deleteAll: input.allowEmpty,
33054
+ onRepair: (message) => deps.warn(`${message}
33055
+ `)
33056
+ });
32988
33057
  await deps.writeFile(componentsPath, `${JSON.stringify(cdf, null, 2)}
32989
33058
  `);
32990
33059
  deps.warn(
@@ -34210,7 +34279,7 @@ function AgentsScreen({ onDone }) {
34210
34279
  hints: [
34211
34280
  { keys: "\u2191/\u2193", label: "move" },
34212
34281
  { keys: "\u23CE", label: "make default" },
34213
- { keys: "\u2192", label: "settings and test" },
34282
+ { keys: "\u2192", label: "settings" },
34214
34283
  { keys: "Esc/q", label: "back" }
34215
34284
  ]
34216
34285
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.41.1-dev-build-3a724687.0",
3
+ "version": "2.41.1-dev-build-699ca2d9.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.41.1-dev-build-3a724687.0",
3
+ "version": "2.41.1-dev-build-699ca2d9.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -45,7 +45,7 @@
45
45
  "ts-morph": "^27.0.2",
46
46
  "typescript": "^5.9.3",
47
47
  "zod": "^4.6.5",
48
- "@contentful/experience-design-system-types": "2.41.1-dev-build-3a724687.0"
48
+ "@contentful/experience-design-system-types": "2.41.1-dev-build-699ca2d9.0"
49
49
  },
50
50
  "devDependencies": {
51
51
  "@tsconfig/node24": "^24.0.4",
@@ -59,7 +59,7 @@
59
59
  "ink-testing-library": "^4.0.0",
60
60
  "typescript-eslint": "^8.67.0",
61
61
  "vitest": "^4.0.16",
62
- "@contentful/experience-design-system-backend-pipeline": "2.41.1-dev-build-3a724687.0"
62
+ "@contentful/experience-design-system-backend-pipeline": "2.41.1-dev-build-699ca2d9.0"
63
63
  },
64
64
  "repository": {
65
65
  "type": "git",