@contentful/experience-design-system-cli 2.32.1-dev-build-661f431.0 → 2.32.1-dev-build-26a2030.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.32.1-dev-build-661f431.0",
3
+ "version": "2.32.1-dev-build-26a2030.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/dist/src/index.js CHANGED
@@ -8942,6 +8942,76 @@ var init_session_resolver = __esm({
8942
8942
  }
8943
8943
  });
8944
8944
 
8945
+ // packages/experience-design-system-cli/src/session/core/tokens/build-dtcg-groups.ts
8946
+ function buildDtcgGroups(groupRows, tokenRows) {
8947
+ return groupRows.map((r) => {
8948
+ const prefix = `${r.path}.`;
8949
+ const tokenIds = tokenRows.filter((t) => t.path.startsWith(prefix) && !t.path.slice(prefix.length).includes(".")).map((t) => t.path);
8950
+ const g = { path: r.path, tokenIds };
8951
+ if (r.description !== null) g.$description = r.description;
8952
+ return g;
8953
+ });
8954
+ }
8955
+ var init_build_dtcg_groups = __esm({
8956
+ "packages/experience-design-system-cli/src/session/core/tokens/build-dtcg-groups.ts"() {
8957
+ "use strict";
8958
+ }
8959
+ });
8960
+
8961
+ // packages/experience-design-system-cli/src/session/core/tokens/build-dtcg-tokens.ts
8962
+ function buildDtcgTokens(tokenRows) {
8963
+ return tokenRows.map((r) => {
8964
+ const t = {
8965
+ path: r.path,
8966
+ $type: r.type,
8967
+ $value: JSON.parse(r.value)
8968
+ };
8969
+ if (r.description !== null) t.$description = r.description;
8970
+ return t;
8971
+ });
8972
+ }
8973
+ var init_build_dtcg_tokens = __esm({
8974
+ "packages/experience-design-system-cli/src/session/core/tokens/build-dtcg-tokens.ts"() {
8975
+ "use strict";
8976
+ }
8977
+ });
8978
+
8979
+ // packages/experience-design-system-cli/src/session/repositories/tokens/read.ts
8980
+ function getDtcgTokensForSession(db, sessionId2) {
8981
+ const groupRows = db.prepare("SELECT path, description FROM raw_token_groups WHERE session_id = ? ORDER BY path").all(sessionId2).map((row) => ({
8982
+ path: String(row.path),
8983
+ description: row.description === null ? null : String(row.description)
8984
+ }));
8985
+ const tokenRows = db.prepare("SELECT path, type, value, description FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId2).map((row) => ({
8986
+ path: String(row.path),
8987
+ type: String(row.type),
8988
+ value: String(row.value),
8989
+ description: row.description === null ? null : String(row.description)
8990
+ }));
8991
+ return {
8992
+ groups: buildDtcgGroups(groupRows, tokenRows),
8993
+ tokens: buildDtcgTokens(tokenRows)
8994
+ };
8995
+ }
8996
+ function getRawTokenNamePaths(db, sessionId2) {
8997
+ const rows = db.prepare("SELECT raw_name, path FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
8998
+ return Object.fromEntries(rows.map((row) => [String(row.raw_name), String(row.path)]));
8999
+ }
9000
+ function getRawTokenNamePathRows(db, sessionId2) {
9001
+ return db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2).map((row) => ({
9002
+ rawName: String(row.raw_name),
9003
+ path: String(row.path),
9004
+ source: String(row.source)
9005
+ }));
9006
+ }
9007
+ var init_read3 = __esm({
9008
+ "packages/experience-design-system-cli/src/session/repositories/tokens/read.ts"() {
9009
+ "use strict";
9010
+ init_build_dtcg_groups();
9011
+ init_build_dtcg_tokens();
9012
+ }
9013
+ });
9014
+
8945
9015
  // packages/experience-design-system-cli/src/session/core/components/hash-component-shape.ts
8946
9016
  import { createHash as createHash2 } from "node:crypto";
8947
9017
  function hashComponentShape(component) {
@@ -8978,6 +9048,169 @@ var init_hash_token_content = __esm({
8978
9048
  }
8979
9049
  });
8980
9050
 
9051
+ // packages/experience-design-system-cli/src/session/repositories/tokens/write.ts
9052
+ function deleteRawTokensForSession(db, sessionId2) {
9053
+ db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
9054
+ db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(sessionId2);
9055
+ }
9056
+ function createRawTokenGroups(db, sessionId2, groups) {
9057
+ const insertGroup = db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)`);
9058
+ for (const group of groups) {
9059
+ insertGroup.run(sessionId2, group.path, group.$description ?? null);
9060
+ }
9061
+ }
9062
+ function createRawTokens(db, sessionId2, tokens) {
9063
+ const insertToken = db.prepare(
9064
+ `INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)`
9065
+ );
9066
+ for (const token of tokens) {
9067
+ insertToken.run(sessionId2, token.path, token.$type, JSON.stringify(token.$value), token.$description ?? null);
9068
+ }
9069
+ }
9070
+ function upsertRawToken(db, sessionId2, call) {
9071
+ db.prepare(
9072
+ `INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)
9073
+ ON CONFLICT(session_id, path) DO UPDATE SET type = excluded.type, value = excluded.value, description = excluded.description`
9074
+ ).run(sessionId2, call.path, call.type, JSON.stringify(call.value), call.description ?? null);
9075
+ }
9076
+ function upsertRawTokenGroup(db, sessionId2, call) {
9077
+ db.prepare(
9078
+ `INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)
9079
+ ON CONFLICT(session_id, path) DO UPDATE SET description = excluded.description`
9080
+ ).run(sessionId2, call.path, call.description ?? null);
9081
+ }
9082
+ function updateRawTokenNamePaths(db, sessionId2, tokenNamePaths, source) {
9083
+ const entries = Object.entries(tokenNamePaths);
9084
+ const deletePaths = db.prepare("DELETE FROM raw_token_name_paths WHERE session_id = ? AND source = ?");
9085
+ const insertPath = db.prepare(
9086
+ "INSERT OR IGNORE INTO raw_token_name_paths (session_id, raw_name, path, source) VALUES (?, ?, ?, ?)"
9087
+ );
9088
+ const deleteAutomaticByName = db.prepare(
9089
+ "DELETE FROM raw_token_name_paths WHERE session_id = ? AND raw_name = ? AND source = 'automatic'"
9090
+ );
9091
+ deletePaths.run(sessionId2, source);
9092
+ for (const [rawName, path] of entries) {
9093
+ if (source === "manual") deleteAutomaticByName.run(sessionId2, rawName);
9094
+ insertPath.run(sessionId2, rawName, path, source);
9095
+ }
9096
+ }
9097
+ function updateRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source) {
9098
+ db.prepare(
9099
+ `DELETE FROM raw_prop_token_paths
9100
+ WHERE session_id = ? AND component_id = ? AND prop_name = ?`
9101
+ ).run(sessionId2, componentId, propName);
9102
+ const insertPath = db.prepare(
9103
+ `INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
9104
+ VALUES (?, ?, ?, ?, ?, ?)`
9105
+ );
9106
+ paths.forEach((path, position) => {
9107
+ insertPath.run(sessionId2, componentId, propName, source, position, path);
9108
+ });
9109
+ }
9110
+ var init_write3 = __esm({
9111
+ "packages/experience-design-system-cli/src/session/repositories/tokens/write.ts"() {
9112
+ "use strict";
9113
+ }
9114
+ });
9115
+
9116
+ // packages/experience-design-system-cli/src/session/repositories/shared/with-transaction.ts
9117
+ function withTransaction(db, fn) {
9118
+ db.exec("BEGIN");
9119
+ try {
9120
+ const result = fn();
9121
+ db.exec("COMMIT");
9122
+ return result;
9123
+ } catch (e) {
9124
+ db.exec("ROLLBACK");
9125
+ throw e;
9126
+ }
9127
+ }
9128
+ var init_with_transaction = __esm({
9129
+ "packages/experience-design-system-cli/src/session/repositories/shared/with-transaction.ts"() {
9130
+ "use strict";
9131
+ }
9132
+ });
9133
+
9134
+ // packages/experience-design-system-cli/src/session/services/tokens/store-dtcg-tokens.ts
9135
+ function storeDtcgTokens(db, sessionId2, groups, tokens) {
9136
+ const now = (/* @__PURE__ */ new Date()).toISOString();
9137
+ withTransaction(db, () => {
9138
+ deleteRawTokensForSession(db, sessionId2);
9139
+ createRawTokenGroups(db, sessionId2, groups);
9140
+ createRawTokens(db, sessionId2, tokens);
9141
+ updateSessionTimestamp(db, sessionId2, now);
9142
+ });
9143
+ }
9144
+ var init_store_dtcg_tokens = __esm({
9145
+ "packages/experience-design-system-cli/src/session/services/tokens/store-dtcg-tokens.ts"() {
9146
+ "use strict";
9147
+ init_write();
9148
+ init_write3();
9149
+ init_with_transaction();
9150
+ }
9151
+ });
9152
+
9153
+ // packages/experience-design-system-cli/src/session/services/tokens/apply-tool-calls.ts
9154
+ function applyTokenToolCalls(db, sessionId2, calls, incomingWarnings) {
9155
+ const now = (/* @__PURE__ */ new Date()).toISOString();
9156
+ const warnings = [...incomingWarnings];
9157
+ let tokens = 0;
9158
+ let groups = 0;
9159
+ withTransaction(db, () => {
9160
+ for (const call of calls) {
9161
+ if (call.tool === "set_token") {
9162
+ upsertRawToken(db, sessionId2, call);
9163
+ tokens++;
9164
+ } else if (call.tool === "set_group") {
9165
+ upsertRawTokenGroup(db, sessionId2, call);
9166
+ groups++;
9167
+ }
9168
+ }
9169
+ updateSessionTimestamp(db, sessionId2, now);
9170
+ });
9171
+ return { tokens, groups, warnings };
9172
+ }
9173
+ var init_apply_tool_calls = __esm({
9174
+ "packages/experience-design-system-cli/src/session/services/tokens/apply-tool-calls.ts"() {
9175
+ "use strict";
9176
+ init_write();
9177
+ init_write3();
9178
+ init_with_transaction();
9179
+ }
9180
+ });
9181
+
9182
+ // packages/experience-design-system-cli/src/session/services/tokens/replace-raw-token-name-paths.ts
9183
+ function replaceRawTokenNamePaths(db, sessionId2, tokenNamePaths, source = "automatic") {
9184
+ withTransaction(db, () => {
9185
+ updateRawTokenNamePaths(db, sessionId2, tokenNamePaths, source);
9186
+ updateSessionTimestamp(db, sessionId2, (/* @__PURE__ */ new Date()).toISOString());
9187
+ });
9188
+ }
9189
+ var init_replace_raw_token_name_paths = __esm({
9190
+ "packages/experience-design-system-cli/src/session/services/tokens/replace-raw-token-name-paths.ts"() {
9191
+ "use strict";
9192
+ init_write3();
9193
+ init_write();
9194
+ init_with_transaction();
9195
+ }
9196
+ });
9197
+
9198
+ // packages/experience-design-system-cli/src/session/services/tokens/replace-raw-prop-token-paths.ts
9199
+ function replaceRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source) {
9200
+ withTransaction(db, () => {
9201
+ updateRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source);
9202
+ updateSessionTimestamp(db, sessionId2, (/* @__PURE__ */ new Date()).toISOString());
9203
+ });
9204
+ }
9205
+ var init_replace_raw_prop_token_paths = __esm({
9206
+ "packages/experience-design-system-cli/src/session/services/tokens/replace-raw-prop-token-paths.ts"() {
9207
+ "use strict";
9208
+ init_write3();
9209
+ init_write();
9210
+ init_with_transaction();
9211
+ }
9212
+ });
9213
+
8981
9214
  // packages/experience-design-system-cli/src/session/cache-keys.ts
8982
9215
  var cache_keys_exports = {};
8983
9216
  __export(cache_keys_exports, {
@@ -9278,57 +9511,6 @@ function applyDbMigrations(db) {
9278
9511
  `);
9279
9512
  }
9280
9513
  }
9281
- function replaceRawTokenNamePaths(db, sessionId2, tokenNamePaths, source = "automatic") {
9282
- const entries = Object.entries(tokenNamePaths);
9283
- const deletePaths = db.prepare("DELETE FROM raw_token_name_paths WHERE session_id = ? AND source = ?");
9284
- const insertPath = db.prepare(
9285
- "INSERT OR IGNORE INTO raw_token_name_paths (session_id, raw_name, path, source) VALUES (?, ?, ?, ?)"
9286
- );
9287
- const deleteAutomaticByName = db.prepare(
9288
- "DELETE FROM raw_token_name_paths WHERE session_id = ? AND raw_name = ? AND source = 'automatic'"
9289
- );
9290
- db.exec("BEGIN");
9291
- try {
9292
- deletePaths.run(sessionId2, source);
9293
- for (const [rawName, path] of entries) {
9294
- if (source === "manual") deleteAutomaticByName.run(sessionId2, rawName);
9295
- insertPath.run(sessionId2, rawName, path, source);
9296
- }
9297
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run((/* @__PURE__ */ new Date()).toISOString(), sessionId2);
9298
- db.exec("COMMIT");
9299
- } catch (e) {
9300
- db.exec("ROLLBACK");
9301
- throw e;
9302
- }
9303
- }
9304
- function loadRawTokenNamePaths(db, sessionId2) {
9305
- const rows = db.prepare("SELECT raw_name, path FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2);
9306
- return Object.fromEntries(rows.map((row) => [row.raw_name, row.path]));
9307
- }
9308
- function loadRawTokenNamePathRows(db, sessionId2) {
9309
- return db.prepare("SELECT raw_name, path, source FROM raw_token_name_paths WHERE session_id = ? ORDER BY raw_name").all(sessionId2).map((row) => ({ rawName: row.raw_name, path: row.path, source: row.source }));
9310
- }
9311
- function replaceRawPropTokenPaths(db, sessionId2, componentId, propName, paths, source) {
9312
- const deletePaths = db.prepare(
9313
- `DELETE FROM raw_prop_token_paths
9314
- WHERE session_id = ? AND component_id = ? AND prop_name = ?`
9315
- );
9316
- const insertPath = db.prepare(
9317
- `INSERT INTO raw_prop_token_paths (session_id, component_id, prop_name, source, position, path)
9318
- VALUES (?, ?, ?, ?, ?, ?)`
9319
- );
9320
- db.exec("BEGIN");
9321
- try {
9322
- deletePaths.run(sessionId2, componentId, propName);
9323
- paths.forEach((path, position) => {
9324
- insertPath.run(sessionId2, componentId, propName, source, position, path);
9325
- });
9326
- db.exec("COMMIT");
9327
- } catch (e) {
9328
- db.exec("ROLLBACK");
9329
- throw e;
9330
- }
9331
- }
9332
9514
  function loadComponentReviewMetadata(db, sessionId2, componentName) {
9333
9515
  const compRow = db.prepare(`SELECT component_id, source, source_path FROM raw_components WHERE session_id = ? AND name = ?`).get(sessionId2, componentName);
9334
9516
  if (!compRow) return null;
@@ -10163,7 +10345,7 @@ function loadCDFComponents(db, sessionId2) {
10163
10345
  `SELECT component_id, prop_name, position, path
10164
10346
  FROM raw_prop_token_paths WHERE session_id = ? ORDER BY component_id, prop_name, position`
10165
10347
  ).all(sessionId2);
10166
- const resolvedDefaultPaths = loadRawTokenNamePaths(db, sessionId2);
10348
+ const resolvedDefaultPaths = getRawTokenNamePaths(db, sessionId2);
10167
10349
  const tokenTypeByPath = new Map(
10168
10350
  db.prepare("SELECT path, type FROM raw_tokens WHERE session_id = ?").all(sessionId2).map((token) => [token.path, token.type])
10169
10351
  );
@@ -10275,82 +10457,6 @@ function applyScopeDecisions(db, sessionId2, decisions) {
10275
10457
  }
10276
10458
  db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
10277
10459
  }
10278
- function storeDTCGTokens(db, sessionId2, groups, tokens) {
10279
- const now = (/* @__PURE__ */ new Date()).toISOString();
10280
- db.exec("BEGIN");
10281
- try {
10282
- db.prepare("DELETE FROM raw_token_groups WHERE session_id = ?").run(sessionId2);
10283
- db.prepare("DELETE FROM raw_tokens WHERE session_id = ?").run(sessionId2);
10284
- const insertGroup = db.prepare(`INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)`);
10285
- for (const group of groups) {
10286
- insertGroup.run(sessionId2, group.path, group.$description ?? null);
10287
- }
10288
- const insertToken = db.prepare(
10289
- `INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)`
10290
- );
10291
- for (const token of tokens) {
10292
- insertToken.run(sessionId2, token.path, token.$type, JSON.stringify(token.$value), token.$description ?? null);
10293
- }
10294
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
10295
- db.exec("COMMIT");
10296
- } catch (e) {
10297
- db.exec("ROLLBACK");
10298
- throw e;
10299
- }
10300
- }
10301
- function applyTokenToolCalls(db, sessionId2, calls, incomingWarnings) {
10302
- const now = (/* @__PURE__ */ new Date()).toISOString();
10303
- const warnings = [...incomingWarnings];
10304
- let tokens = 0;
10305
- let groups = 0;
10306
- const upsertToken = db.prepare(
10307
- `INSERT INTO raw_tokens (session_id, path, type, value, description) VALUES (?, ?, ?, ?, ?)
10308
- ON CONFLICT(session_id, path) DO UPDATE SET type = excluded.type, value = excluded.value, description = excluded.description`
10309
- );
10310
- const upsertGroup = db.prepare(
10311
- `INSERT INTO raw_token_groups (session_id, path, description) VALUES (?, ?, ?)
10312
- ON CONFLICT(session_id, path) DO UPDATE SET description = excluded.description`
10313
- );
10314
- db.exec("BEGIN");
10315
- try {
10316
- for (const call of calls) {
10317
- if (call.tool === "set_token") {
10318
- upsertToken.run(sessionId2, call.path, call.type, JSON.stringify(call.value), call.description ?? null);
10319
- tokens++;
10320
- } else if (call.tool === "set_group") {
10321
- upsertGroup.run(sessionId2, call.path, call.description ?? null);
10322
- groups++;
10323
- }
10324
- }
10325
- db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
10326
- db.exec("COMMIT");
10327
- } catch (e) {
10328
- db.exec("ROLLBACK");
10329
- throw e;
10330
- }
10331
- return { tokens, groups, warnings };
10332
- }
10333
- function loadDTCGTokens(db, sessionId2) {
10334
- const groupRows = db.prepare("SELECT path, description FROM raw_token_groups WHERE session_id = ? ORDER BY path").all(sessionId2);
10335
- const tokenRows = db.prepare("SELECT path, type, value, description FROM raw_tokens WHERE session_id = ? ORDER BY path").all(sessionId2);
10336
- const groups = groupRows.map((r) => {
10337
- const prefix = `${r.path}.`;
10338
- const tokenIds = tokenRows.filter((t) => t.path.startsWith(prefix) && !t.path.slice(prefix.length).includes(".")).map((t) => t.path);
10339
- const g = { path: r.path, tokenIds };
10340
- if (r.description !== null) g.$description = r.description;
10341
- return g;
10342
- });
10343
- const tokens = tokenRows.map((r) => {
10344
- const t = {
10345
- path: r.path,
10346
- $type: r.type,
10347
- $value: JSON.parse(r.value)
10348
- };
10349
- if (r.description !== null) t.$description = r.description;
10350
- return t;
10351
- });
10352
- return { groups, tokens };
10353
- }
10354
10460
  function findLatestSessionForCommand(db, command) {
10355
10461
  return getLatestCompletedSessionForCommand(db, command);
10356
10462
  }
@@ -10771,10 +10877,16 @@ var init_db = __esm({
10771
10877
  init_read2();
10772
10878
  init_write2();
10773
10879
  init_session_resolver();
10880
+ init_read3();
10774
10881
  init_derive_component_id();
10775
10882
  init_hash_component_shape();
10776
10883
  init_hash_token_content();
10777
10884
  init_cdf_mappers();
10885
+ init_read3();
10886
+ init_store_dtcg_tokens();
10887
+ init_apply_tool_calls();
10888
+ init_replace_raw_token_name_paths();
10889
+ init_replace_raw_prop_token_paths();
10778
10890
  SCHEMA = `
10779
10891
  PRAGMA journal_mode = WAL;
10780
10892
  PRAGMA foreign_keys = ON;
@@ -24980,7 +25092,7 @@ function GenerateReviewStep({
24980
25092
  try {
24981
25093
  cdfComponents = loadCDFComponents(db, extractSessionId);
24982
25094
  cycles = loadSlotCycles(db, extractSessionId);
24983
- tokens = loadDTCGTokens(db, tokenSessionId ?? extractSessionId).tokens.map((token) => ({
25095
+ tokens = getDtcgTokensForSession(db, tokenSessionId ?? extractSessionId).tokens.map((token) => ({
24984
25096
  path: token.path,
24985
25097
  kind: token.$type
24986
25098
  }));
@@ -26868,7 +26980,7 @@ function AtomicGenerateReviewStep({
26868
26980
  let tokens = [];
26869
26981
  try {
26870
26982
  cdfComponents = loadCDFComponents(db, extractSessionId);
26871
- tokens = loadDTCGTokens(db, tokenSessionId ?? extractSessionId).tokens.map((token) => ({
26983
+ tokens = getDtcgTokensForSession(db, tokenSessionId ?? extractSessionId).tokens.map((token) => ({
26872
26984
  path: token.path,
26873
26985
  kind: token.$type
26874
26986
  }));
@@ -28217,7 +28329,7 @@ If you are using AWS Bedrock, run:
28217
28329
  copyTokensFromCache(db, state.tokenSessionId, sessionId2);
28218
28330
  } else if (!state.tokenSessionId && state.tokensPath) {
28219
28331
  const tokens = await readTokensFromPath("tokens", state.tokensPath);
28220
- storeDTCGTokens(db, sessionId2, [], tokens);
28332
+ storeDtcgTokens(db, sessionId2, [], tokens);
28221
28333
  }
28222
28334
  const cdfEntries = loadCDFComponents(db, sessionId2);
28223
28335
  mappablePropCount = cdfEntries.reduce(
@@ -28226,7 +28338,7 @@ If you are using AWS Bedrock, run:
28226
28338
  ).length,
28227
28339
  0
28228
28340
  );
28229
- rawTokenCount = loadDTCGTokens(db, sessionId2).tokens.length;
28341
+ rawTokenCount = getDtcgTokensForSession(db, sessionId2).tokens.length;
28230
28342
  } finally {
28231
28343
  db.close();
28232
28344
  }
@@ -34314,7 +34426,7 @@ function registerPrintCommand(program) {
34314
34426
  const db = openPipelineDb();
34315
34427
  let result;
34316
34428
  try {
34317
- result = loadDTCGTokens(db, sessionId2);
34429
+ result = getDtcgTokensForSession(db, sessionId2);
34318
34430
  } finally {
34319
34431
  db.close();
34320
34432
  }
@@ -34664,7 +34776,7 @@ async function runMapTokens(opts) {
34664
34776
  tokenLeaves
34665
34777
  );
34666
34778
  const manualMappings = new Map(
34667
- loadRawTokenNamePathRows(db, sessionId2).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path])
34779
+ getRawTokenNamePathRows(db, sessionId2).filter((row) => row.source === "manual").map((row) => [row.rawName, row.path])
34668
34780
  );
34669
34781
  const automaticMappings = {};
34670
34782
  const defaultDiagnostics = [
@@ -34699,7 +34811,7 @@ ${defaultDiagnostics.map((diagnostic) => ` ${diagnostic}`).join("\n")}
34699
34811
  (count, { entry }) => count + Object.values(entry.$properties ?? {}).filter((prop) => prop.$type === "token" && prop.$category === "design").length,
34700
34812
  0
34701
34813
  );
34702
- const { groups, tokens } = loadDTCGTokens(db, sessionId2);
34814
+ const { groups, tokens } = getDtcgTokensForSession(db, sessionId2);
34703
34815
  const tokenCount = tokens.length;
34704
34816
  if (mappablePropCount === 0 || tokenCount === 0) {
34705
34817
  process.stdout.write(
@@ -35184,7 +35296,7 @@ async function runPipeline(opts, progressWriter, cliPathOverride) {
35184
35296
  }
35185
35297
  if (extractSessionId && opts.tokens) {
35186
35298
  const tokens = await readTokensFromPath("--tokens", opts.tokens);
35187
- storeDTCGTokens(db, extractSessionId, [], tokens);
35299
+ storeDtcgTokens(db, extractSessionId, [], tokens);
35188
35300
  }
35189
35301
  const mapTokensLabel = stepLabel("Mapping design tokens");
35190
35302
  const hasGeneratedComponents = extractSessionId !== null && loadCDFComponents(db, extractSessionId).length > 0;
@@ -0,0 +1,12 @@
1
+ import type { DTCGTokenGroup } from '@contentful/experience-design-system-types';
2
+ export interface GroupRow {
3
+ path: string;
4
+ description: string | null;
5
+ }
6
+ export interface TokenRow {
7
+ path: string;
8
+ type: string;
9
+ value: string;
10
+ description: string | null;
11
+ }
12
+ export declare function buildDtcgGroups(groupRows: GroupRow[], tokenRows: TokenRow[]): DTCGTokenGroup[];
@@ -0,0 +1,3 @@
1
+ import type { DTCGTokenEntry } from '@contentful/experience-design-system-types';
2
+ import type { TokenRow } from './build-dtcg-groups.js';
3
+ export declare function buildDtcgTokens(tokenRows: TokenRow[]): DTCGTokenEntry[];
@@ -1,7 +1,7 @@
1
1
  import { DatabaseSync } from 'node:sqlite';
2
2
  import type { RawComponentDefinition } from '../types.js';
3
- import type { CDFComponentEntry, DTCGTokenEntry, DTCGTokenGroup } from '@contentful/experience-design-system-types';
4
- import type { ToolCall, TokenToolCall, ComponentSourceRef } from '@contentful/experience-design-system-generation';
3
+ import type { CDFComponentEntry } from '@contentful/experience-design-system-types';
4
+ import type { ToolCall, ComponentSourceRef } from '@contentful/experience-design-system-generation';
5
5
  import type { ComponentTypeSummary } from '@contentful/experience-design-system-types';
6
6
  import type { SlotCycle, SlotEdge } from '../analyze/cycle-detection.js';
7
7
  import { type MatchHints as SessionMatchHints } from './repositories/sessions/read.js';
@@ -10,6 +10,12 @@ export { deriveComponentId } from './core/components/derive-component-id.js';
10
10
  export { hashComponentShape as computeComponentInputHash } from './core/components/hash-component-shape.js';
11
11
  export { hashTokenContent as computeTokenInputHash } from './core/tokens/hash-token-content.js';
12
12
  export { mapContentfulTypeToCdfType, resolveCdfCategory } from './core/cdf/cdf-mappers.js';
13
+ export { getDtcgTokensForSession as loadDTCGTokens, getRawTokenNamePaths as loadRawTokenNamePaths, getRawTokenNamePathRows as loadRawTokenNamePathRows, type RawTokenNamePaths, type RawTokenNamePathSource, type RawTokenNamePath, } from './repositories/tokens/read.js';
14
+ export { type RawPropTokenPathSource } from './repositories/tokens/write.js';
15
+ export { storeDtcgTokens as storeDTCGTokens } from './services/tokens/store-dtcg-tokens.js';
16
+ export { applyTokenToolCalls, type ApplyTokenToolCallsResult } from './services/tokens/apply-tool-calls.js';
17
+ export { replaceRawTokenNamePaths } from './services/tokens/replace-raw-token-name-paths.js';
18
+ export { replaceRawPropTokenPaths } from './services/tokens/replace-raw-prop-token-paths.js';
13
19
  export type StepStatus = 'pending' | 'complete' | 'failed' | 'interrupted';
14
20
  export type CommandName = 'analyze extract' | 'analyze select' | 'generate components' | 'generate tokens' | 'generate edit' | 'apply preview' | 'apply select' | 'apply push' | 'print components' | 'print tokens' | 'map tokens' | 'fetch existing entities' | 'import';
15
21
  export interface SessionRow {
@@ -32,30 +38,6 @@ export interface StepRow {
32
38
  }
33
39
  export declare function getPipelineDbPath(): string;
34
40
  export declare function openPipelineDb(dbPath?: string): DatabaseSync;
35
- /** An exact source token reference paired with its canonical DTCG path. */
36
- export type RawTokenNamePaths = Record<string, string>;
37
- export type RawTokenNamePathSource = 'automatic' | 'manual';
38
- export interface RawTokenNamePath {
39
- rawName: string;
40
- path: string;
41
- source: RawTokenNamePathSource;
42
- }
43
- /**
44
- * Replaces the session's exact source-reference-to-DTCG-path sidecar.
45
- * Source references are retained verbatim; normalisation belongs to the
46
- * deterministic resolver, not to persistence or CDF emission.
47
- */
48
- export declare function replaceRawTokenNamePaths(db: DatabaseSync, sessionId: string, tokenNamePaths: RawTokenNamePaths, source?: RawTokenNamePathSource): void;
49
- /** Loads the exact source-reference-to-DTCG-path sidecar for a session. */
50
- export declare function loadRawTokenNamePaths(db: DatabaseSync, sessionId: string): RawTokenNamePaths;
51
- export declare function loadRawTokenNamePathRows(db: DatabaseSync, sessionId: string): RawTokenNamePath[];
52
- /**
53
- * Where a prop's token-path list came from. 'agent' is a map-tokens suggestion,
54
- * which a later run of that step may revise. 'review' is a person's decision in
55
- * the review editor, which a re-run must leave alone.
56
- */
57
- export type RawPropTokenPathSource = 'agent' | 'review';
58
- export declare function replaceRawPropTokenPaths(db: DatabaseSync, sessionId: string, componentId: string, propName: string, paths: string[], source: RawPropTokenPathSource): void;
59
41
  export interface ApplyToolCallsResult {
60
42
  classified: number;
61
43
  excluded: number;
@@ -138,17 +120,6 @@ export declare function applyScopeDecisions(db: DatabaseSync, sessionId: string,
138
120
  accepted: string[];
139
121
  rejected: string[];
140
122
  }): void;
141
- export declare function storeDTCGTokens(db: DatabaseSync, sessionId: string, groups: DTCGTokenGroup[], tokens: DTCGTokenEntry[]): void;
142
- export interface ApplyTokenToolCallsResult {
143
- tokens: number;
144
- groups: number;
145
- warnings: string[];
146
- }
147
- export declare function applyTokenToolCalls(db: DatabaseSync, sessionId: string, calls: TokenToolCall[], incomingWarnings: string[]): ApplyTokenToolCallsResult;
148
- export declare function loadDTCGTokens(db: DatabaseSync, sessionId: string): {
149
- groups: DTCGTokenGroup[];
150
- tokens: DTCGTokenEntry[];
151
- };
152
123
  export declare function findLatestSessionForCommand(db: DatabaseSync, command: CommandName): string | null;
153
124
  export declare function seedCDFFromPriorSession(db: DatabaseSync, targetSessionId: string): number;
154
125
  export declare function seedCDFFromPreviewResponse(db: DatabaseSync, sessionId: string, removedItems: ComponentTypeSummary[]): number;
@@ -0,0 +1,2 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ export declare function withTransaction<T>(db: DatabaseSync, fn: () => T): T;
@@ -0,0 +1,15 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { DTCGTokenEntry, DTCGTokenGroup } from '@contentful/experience-design-system-types';
3
+ export type RawTokenNamePaths = Record<string, string>;
4
+ export type RawTokenNamePathSource = 'automatic' | 'manual';
5
+ export interface RawTokenNamePath {
6
+ rawName: string;
7
+ path: string;
8
+ source: RawTokenNamePathSource;
9
+ }
10
+ export declare function getDtcgTokensForSession(db: DatabaseSync, sessionId: string): {
11
+ groups: DTCGTokenGroup[];
12
+ tokens: DTCGTokenEntry[];
13
+ };
14
+ export declare function getRawTokenNamePaths(db: DatabaseSync, sessionId: string): RawTokenNamePaths;
15
+ export declare function getRawTokenNamePathRows(db: DatabaseSync, sessionId: string): RawTokenNamePath[];
@@ -0,0 +1,16 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { DTCGTokenEntry, DTCGTokenGroup } from '@contentful/experience-design-system-types';
3
+ import type { TokenToolCall } from '@contentful/experience-design-system-generation';
4
+ import type { RawTokenNamePaths, RawTokenNamePathSource } from './read.js';
5
+ export type RawPropTokenPathSource = 'agent' | 'review';
6
+ export declare function deleteRawTokensForSession(db: DatabaseSync, sessionId: string): void;
7
+ export declare function createRawTokenGroups(db: DatabaseSync, sessionId: string, groups: DTCGTokenGroup[]): void;
8
+ export declare function createRawTokens(db: DatabaseSync, sessionId: string, tokens: DTCGTokenEntry[]): void;
9
+ export declare function upsertRawToken(db: DatabaseSync, sessionId: string, call: Extract<TokenToolCall, {
10
+ tool: 'set_token';
11
+ }>): void;
12
+ export declare function upsertRawTokenGroup(db: DatabaseSync, sessionId: string, call: Extract<TokenToolCall, {
13
+ tool: 'set_group';
14
+ }>): void;
15
+ export declare function updateRawTokenNamePaths(db: DatabaseSync, sessionId: string, tokenNamePaths: RawTokenNamePaths, source: RawTokenNamePathSource): void;
16
+ export declare function updateRawPropTokenPaths(db: DatabaseSync, sessionId: string, componentId: string, propName: string, paths: string[], source: RawPropTokenPathSource): void;
@@ -0,0 +1,8 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { TokenToolCall } from '@contentful/experience-design-system-generation';
3
+ export interface ApplyTokenToolCallsResult {
4
+ tokens: number;
5
+ groups: number;
6
+ warnings: string[];
7
+ }
8
+ export declare function applyTokenToolCalls(db: DatabaseSync, sessionId: string, calls: TokenToolCall[], incomingWarnings: string[]): ApplyTokenToolCallsResult;
@@ -0,0 +1,3 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import { type RawPropTokenPathSource } from '../../repositories/tokens/write.js';
3
+ export declare function replaceRawPropTokenPaths(db: DatabaseSync, sessionId: string, componentId: string, propName: string, paths: string[], source: RawPropTokenPathSource): void;
@@ -0,0 +1,3 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { RawTokenNamePaths, RawTokenNamePathSource } from '../../repositories/tokens/read.js';
3
+ export declare function replaceRawTokenNamePaths(db: DatabaseSync, sessionId: string, tokenNamePaths: RawTokenNamePaths, source?: RawTokenNamePathSource): void;
@@ -0,0 +1,3 @@
1
+ import type { DatabaseSync } from 'node:sqlite';
2
+ import type { DTCGTokenEntry, DTCGTokenGroup } from '@contentful/experience-design-system-types';
3
+ export declare function storeDtcgTokens(db: DatabaseSync, sessionId: string, groups: DTCGTokenGroup[], tokens: DTCGTokenEntry[]): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.32.1-dev-build-661f431.0",
3
+ "version": "2.32.1-dev-build-26a2030.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -40,8 +40,8 @@
40
40
  "svelte": "^5.56.4",
41
41
  "ts-morph": "^27.0.2",
42
42
  "typescript": "^5.9.3",
43
- "@contentful/experience-design-system-types": "2.32.1-dev-build-661f431.0",
44
- "@contentful/experience-design-system-cli-v2": "2.32.1-dev-build-661f431.0"
43
+ "@contentful/experience-design-system-types": "2.32.1-dev-build-26a2030.0",
44
+ "@contentful/experience-design-system-cli-v2": "2.32.1-dev-build-26a2030.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@tsconfig/node24": "^24.0.4",
@@ -53,9 +53,9 @@
53
53
  "ink-testing-library": "^4.0.0",
54
54
  "typescript-eslint": "^8.67.0",
55
55
  "vitest": "^4.0.16",
56
- "@contentful/experience-design-system-generation": "2.32.1-dev-build-661f431.0",
57
- "@contentful/experience-design-system-client": "2.32.1-dev-build-661f431.0",
58
- "@contentful/experience-design-system-extraction": "2.32.1-dev-build-661f431.0"
56
+ "@contentful/experience-design-system-client": "2.32.1-dev-build-26a2030.0",
57
+ "@contentful/experience-design-system-extraction": "2.32.1-dev-build-26a2030.0",
58
+ "@contentful/experience-design-system-generation": "2.32.1-dev-build-26a2030.0"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",