@contentful/experience-design-system-cli 2.33.1-dev-build-d733cbf.0 → 2.33.1-dev-build-d7fc540.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.
Files changed (28) hide show
  1. package/dist/package.json +1 -1
  2. package/dist/src/index.js +245 -573
  3. package/dist/src/session/db.d.ts +8 -2
  4. package/package.json +6 -6
  5. package/dist/src/session/core/components/group-allowed-values-by-prop.d.ts +0 -2
  6. package/dist/src/session/core/components/plan-cdf-restore.d.ts +0 -3
  7. package/dist/src/session/core/components/snapshot-types.d.ts +0 -33
  8. package/dist/src/session/core/shared/memoize-by-key.d.ts +0 -1
  9. package/dist/src/session/repositories/components/raw/interfaces/raw-component-row.d.ts +0 -10
  10. package/dist/src/session/repositories/components/raw/interfaces/raw-prop-row.d.ts +0 -14
  11. package/dist/src/session/repositories/components/raw/interfaces/raw-slot-allowed-component-row.d.ts +0 -6
  12. package/dist/src/session/repositories/components/raw/interfaces/raw-slot-row.d.ts +0 -7
  13. package/dist/src/session/repositories/components/raw/read.d.ts +0 -18
  14. package/dist/src/session/repositories/components/raw/reads/get-classified-props.d.ts +0 -3
  15. package/dist/src/session/repositories/components/raw/reads/get-component-descriptions.d.ts +0 -3
  16. package/dist/src/session/repositories/components/raw/reads/get-raw-component-rows.d.ts +0 -3
  17. package/dist/src/session/repositories/components/raw/reads/get-raw-prop-allowed-value-rows.d.ts +0 -3
  18. package/dist/src/session/repositories/components/raw/reads/get-raw-prop-allowed-values.d.ts +0 -3
  19. package/dist/src/session/repositories/components/raw/reads/get-raw-prop-name-at-position.d.ts +0 -2
  20. package/dist/src/session/repositories/components/raw/reads/get-raw-prop-rows.d.ts +0 -3
  21. package/dist/src/session/repositories/components/raw/reads/get-raw-slot-allowed-component-rows.d.ts +0 -3
  22. package/dist/src/session/repositories/components/raw/reads/get-raw-slot-rows.d.ts +0 -3
  23. package/dist/src/session/repositories/components/raw/reads/has-raw-prop-named.d.ts +0 -2
  24. package/dist/src/session/repositories/components/raw/row-mappers.d.ts +0 -8
  25. package/dist/src/session/repositories/components/raw/rows.d.ts +0 -4
  26. package/dist/src/session/repositories/components/raw/write.d.ts +0 -12
  27. package/dist/src/session/services/components/apply-cdf-restore.d.ts +0 -3
  28. package/dist/src/session/services/components/store-raw-components.d.ts +0 -6
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.33.1-dev-build-d733cbf.0",
3
+ "version": "2.33.1-dev-build-d7fc540.0",
4
4
  "description": "Contentful Experiences design system import CLI",
5
5
  "license": "MIT",
6
6
  "type": "module",
package/dist/src/index.js CHANGED
@@ -9211,565 +9211,6 @@ var init_replace_raw_prop_token_paths = __esm({
9211
9211
  }
9212
9212
  });
9213
9213
 
9214
- // packages/experience-design-system-cli/src/session/repositories/components/raw/row-mappers.ts
9215
- function mapRawComponentRow(row) {
9216
- return {
9217
- component_id: String(row.component_id),
9218
- name: String(row.name),
9219
- source: String(row.source),
9220
- framework: String(row.framework),
9221
- extraction_confidence: row.extraction_confidence === null ? null : Number(row.extraction_confidence),
9222
- review_reasons: String(row.review_reasons ?? "[]"),
9223
- needs_review: Number(row.needs_review ?? 0),
9224
- source_path: row.source_path === null ? null : String(row.source_path)
9225
- };
9226
- }
9227
- function mapRawPropRow(row) {
9228
- return {
9229
- component_id: String(row.component_id),
9230
- name: String(row.name),
9231
- type: String(row.type),
9232
- required: Number(row.required),
9233
- category: row.category === null ? null : String(row.category),
9234
- default_value: row.default_value === null ? null : String(row.default_value),
9235
- description: row.description === null ? null : String(row.description),
9236
- token_reference: row.token_reference === null ? null : String(row.token_reference),
9237
- position: Number(row.position),
9238
- rationale: row.rationale === null ? null : String(row.rationale),
9239
- source_start_line: row.source_start_line === null ? null : Number(row.source_start_line),
9240
- source_end_line: row.source_end_line === null ? null : Number(row.source_end_line)
9241
- };
9242
- }
9243
- function mapAllowedValueSnapshotRow(row) {
9244
- return {
9245
- component_id: String(row.component_id),
9246
- prop_name: String(row.prop_name),
9247
- position: Number(row.position),
9248
- value: String(row.value)
9249
- };
9250
- }
9251
- function mapRawSlotRow(row) {
9252
- return {
9253
- component_id: String(row.component_id),
9254
- name: String(row.name),
9255
- is_default: Number(row.is_default),
9256
- description: row.description === null ? null : String(row.description),
9257
- position: Number(row.position)
9258
- };
9259
- }
9260
- function mapRawSlotAllowedComponentRow(row) {
9261
- return {
9262
- component_id: String(row.component_id),
9263
- slot_name: String(row.slot_name),
9264
- position: Number(row.position),
9265
- allowed_component: String(row.allowed_component)
9266
- };
9267
- }
9268
- function parseReviewReasons(raw) {
9269
- try {
9270
- const parsed = JSON.parse(raw);
9271
- return Array.isArray(parsed) ? parsed.filter((v) => typeof v === "string") : [];
9272
- } catch {
9273
- return [];
9274
- }
9275
- }
9276
- var init_row_mappers = __esm({
9277
- "packages/experience-design-system-cli/src/session/repositories/components/raw/row-mappers.ts"() {
9278
- "use strict";
9279
- }
9280
- });
9281
-
9282
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-component-rows.ts
9283
- function getRawComponentRows(db, sessionId2) {
9284
- return db.prepare(
9285
- "SELECT component_id, name, source, framework, extraction_confidence, review_reasons, needs_review, source_path FROM raw_components WHERE session_id = ? ORDER BY rowid"
9286
- ).all(sessionId2).map(mapRawComponentRow);
9287
- }
9288
- var init_get_raw_component_rows = __esm({
9289
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-component-rows.ts"() {
9290
- "use strict";
9291
- init_row_mappers();
9292
- }
9293
- });
9294
-
9295
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-rows.ts
9296
- function getRawPropRows(db, sessionId2) {
9297
- return db.prepare(
9298
- `SELECT component_id, name, type, required, category, default_value, description, token_reference, position,
9299
- rationale, source_start_line, source_end_line
9300
- FROM raw_props WHERE session_id = ? ORDER BY component_id, position`
9301
- ).all(sessionId2).map(mapRawPropRow);
9302
- }
9303
- var init_get_raw_prop_rows = __esm({
9304
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-rows.ts"() {
9305
- "use strict";
9306
- init_row_mappers();
9307
- }
9308
- });
9309
-
9310
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-allowed-value-rows.ts
9311
- function getRawPropAllowedValueRows(db, sessionId2) {
9312
- return db.prepare(
9313
- `SELECT component_id, prop_name, position, value
9314
- FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`
9315
- ).all(sessionId2).map(mapAllowedValueSnapshotRow);
9316
- }
9317
- var init_get_raw_prop_allowed_value_rows = __esm({
9318
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-allowed-value-rows.ts"() {
9319
- "use strict";
9320
- init_row_mappers();
9321
- }
9322
- });
9323
-
9324
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-slot-rows.ts
9325
- function getRawSlotRows(db, sessionId2) {
9326
- return db.prepare(
9327
- `SELECT component_id, name, is_default, description, position
9328
- FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`
9329
- ).all(sessionId2).map(mapRawSlotRow);
9330
- }
9331
- var init_get_raw_slot_rows = __esm({
9332
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-slot-rows.ts"() {
9333
- "use strict";
9334
- init_row_mappers();
9335
- }
9336
- });
9337
-
9338
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-slot-allowed-component-rows.ts
9339
- function getRawSlotAllowedComponentRows(db, sessionId2) {
9340
- return db.prepare(
9341
- `SELECT component_id, slot_name, position, allowed_component
9342
- FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`
9343
- ).all(sessionId2).map(mapRawSlotAllowedComponentRow);
9344
- }
9345
- var init_get_raw_slot_allowed_component_rows = __esm({
9346
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-slot-allowed-component-rows.ts"() {
9347
- "use strict";
9348
- init_row_mappers();
9349
- }
9350
- });
9351
-
9352
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-classified-props.ts
9353
- function getClassifiedProps(db, sessionId2) {
9354
- return db.prepare(
9355
- `SELECT component_id, name, position, cdf_type, cdf_category, cdf_token_kind
9356
- FROM raw_props WHERE session_id = ? AND cdf_type IS NOT NULL`
9357
- ).all(sessionId2).map((row) => ({
9358
- component_id: String(row.component_id),
9359
- name: String(row.name),
9360
- position: Number(row.position),
9361
- cdf_type: String(row.cdf_type),
9362
- cdf_category: String(row.cdf_category),
9363
- cdf_token_kind: row.cdf_token_kind === null ? null : String(row.cdf_token_kind)
9364
- }));
9365
- }
9366
- var init_get_classified_props = __esm({
9367
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-classified-props.ts"() {
9368
- "use strict";
9369
- }
9370
- });
9371
-
9372
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-component-descriptions.ts
9373
- function getComponentDescriptions(db, sessionId2) {
9374
- return db.prepare(
9375
- `SELECT component_id, description
9376
- FROM raw_components WHERE session_id = ? AND description IS NOT NULL`
9377
- ).all(sessionId2).map((row) => ({
9378
- component_id: String(row.component_id),
9379
- description: String(row.description)
9380
- }));
9381
- }
9382
- var init_get_component_descriptions = __esm({
9383
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-component-descriptions.ts"() {
9384
- "use strict";
9385
- }
9386
- });
9387
-
9388
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-allowed-values.ts
9389
- function getRawPropAllowedValues(db, sessionId2) {
9390
- return db.prepare(`SELECT component_id, prop_name, position, value FROM raw_prop_allowed_values WHERE session_id = ?`).all(sessionId2).map(mapAllowedValueSnapshotRow);
9391
- }
9392
- var init_get_raw_prop_allowed_values = __esm({
9393
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-allowed-values.ts"() {
9394
- "use strict";
9395
- init_row_mappers();
9396
- }
9397
- });
9398
-
9399
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-name-at-position.ts
9400
- function getRawPropNameAtPosition(db, sessionId2, componentId, position) {
9401
- const row = db.prepare(`SELECT name FROM raw_props WHERE session_id = ? AND component_id = ? AND position = ?`).get(sessionId2, componentId, position);
9402
- return row ? String(row.name) : null;
9403
- }
9404
- var init_get_raw_prop_name_at_position = __esm({
9405
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/get-raw-prop-name-at-position.ts"() {
9406
- "use strict";
9407
- }
9408
- });
9409
-
9410
- // packages/experience-design-system-cli/src/session/repositories/components/raw/reads/has-raw-prop-named.ts
9411
- function hasRawPropNamed(db, sessionId2, componentId, propName) {
9412
- const row = db.prepare("SELECT 1 as one FROM raw_props WHERE session_id = ? AND component_id = ? AND name = ?").get(sessionId2, componentId, propName);
9413
- return row !== void 0;
9414
- }
9415
- var init_has_raw_prop_named = __esm({
9416
- "packages/experience-design-system-cli/src/session/repositories/components/raw/reads/has-raw-prop-named.ts"() {
9417
- "use strict";
9418
- }
9419
- });
9420
-
9421
- // packages/experience-design-system-cli/src/session/repositories/components/raw/read.ts
9422
- function getRawComponents(db, sessionId2, allowedNames) {
9423
- const all = getRawComponentRows(db, sessionId2);
9424
- const components = allowedNames ? all.filter((c2) => allowedNames.has(c2.name)) : all;
9425
- if (components.length === 0) return [];
9426
- const props = getRawPropRows(db, sessionId2);
9427
- const allowedValues = getRawPropAllowedValueRows(db, sessionId2);
9428
- const slots = getRawSlotRows(db, sessionId2);
9429
- const allowedComponents = getRawSlotAllowedComponentRows(db, sessionId2);
9430
- const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
9431
- const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
9432
- const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
9433
- const allowedComponentsBySlot = indexRowsByKey(allowedComponents, (ac) => `${ac.component_id}::${ac.slot_name}`);
9434
- return components.map(
9435
- (c2) => ({
9436
- component_id: c2.component_id,
9437
- name: c2.name,
9438
- source: c2.source,
9439
- framework: c2.framework,
9440
- extractionConfidence: c2.extraction_confidence ?? null,
9441
- reviewReasons: parseReviewReasons(c2.review_reasons),
9442
- needsReview: Boolean(c2.needs_review),
9443
- sourcePath: c2.source_path ?? void 0,
9444
- props: (propsByComponent.get(c2.component_id) ?? []).map((p) => {
9445
- const av = allowedValuesByProp.get(`${c2.component_id}::${p.name}`);
9446
- const prop = {
9447
- name: p.name,
9448
- type: p.type,
9449
- required: Boolean(p.required)
9450
- };
9451
- if (p.category !== null) prop.category = p.category;
9452
- if (p.default_value !== null) prop.defaultValue = p.default_value;
9453
- if (p.description !== null) prop.description = p.description;
9454
- if (p.token_reference !== null) prop.tokenReference = p.token_reference;
9455
- if (av && av.length > 0) prop.allowedValues = av.map((v) => v.value);
9456
- if (p.source_start_line !== null) prop.sourceStartLine = p.source_start_line;
9457
- if (p.source_end_line !== null) prop.sourceEndLine = p.source_end_line;
9458
- return prop;
9459
- }),
9460
- slots: (slotsByComponent.get(c2.component_id) ?? []).map((s) => {
9461
- const ac = allowedComponentsBySlot.get(`${c2.component_id}::${s.name}`);
9462
- const slot = {
9463
- name: s.name,
9464
- isDefault: Boolean(s.is_default)
9465
- };
9466
- if (s.description !== null) slot.description = s.description;
9467
- if (ac && ac.length > 0) slot.allowedComponents = ac.map((v) => v.allowed_component);
9468
- return slot;
9469
- })
9470
- })
9471
- );
9472
- }
9473
- var init_read4 = __esm({
9474
- "packages/experience-design-system-cli/src/session/repositories/components/raw/read.ts"() {
9475
- "use strict";
9476
- init_index_rows_by_key();
9477
- init_row_mappers();
9478
- init_get_raw_component_rows();
9479
- init_get_raw_prop_rows();
9480
- init_get_raw_prop_allowed_value_rows();
9481
- init_get_raw_slot_rows();
9482
- init_get_raw_slot_allowed_component_rows();
9483
- init_row_mappers();
9484
- init_get_raw_component_rows();
9485
- init_get_raw_prop_rows();
9486
- init_get_raw_prop_allowed_value_rows();
9487
- init_get_raw_slot_rows();
9488
- init_get_raw_slot_allowed_component_rows();
9489
- init_get_classified_props();
9490
- init_get_component_descriptions();
9491
- init_get_raw_prop_allowed_values();
9492
- init_get_raw_prop_name_at_position();
9493
- init_has_raw_prop_named();
9494
- }
9495
- });
9496
-
9497
- // packages/experience-design-system-cli/src/session/repositories/components/raw/write.ts
9498
- function deleteRawComponentsForSession(db, sessionId2) {
9499
- db.prepare("DELETE FROM raw_components WHERE session_id = ?").run(sessionId2);
9500
- }
9501
- function createRawComponent(db, sessionId2, comp, extractedAt) {
9502
- const componentId = deriveComponentId(comp.name, comp.source);
9503
- db.prepare(
9504
- `INSERT INTO raw_components (session_id, component_id, name, source, framework, extracted_at, extraction_confidence, review_reasons, needs_review, source_path)
9505
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
9506
- ).run(
9507
- sessionId2,
9508
- componentId,
9509
- comp.name,
9510
- comp.source,
9511
- comp.framework,
9512
- extractedAt,
9513
- comp.extractionConfidence ?? null,
9514
- JSON.stringify(comp.reviewReasons ?? []),
9515
- comp.needsReview ? 1 : 0,
9516
- comp.sourcePath ?? null
9517
- );
9518
- return componentId;
9519
- }
9520
- function createRawProps(db, sessionId2, componentId, props) {
9521
- const insertProp = db.prepare(
9522
- `INSERT INTO raw_props
9523
- (session_id, component_id, name, type, required, category, default_value, description, token_reference, position, source_start_line, source_end_line)
9524
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
9525
- );
9526
- const insertAllowedValue = db.prepare(
9527
- `INSERT INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value)
9528
- VALUES (?, ?, ?, ?, ?)`
9529
- );
9530
- props.forEach((prop, position) => {
9531
- insertPropRow(insertProp, sessionId2, componentId, prop, position);
9532
- insertPropAllowedValues(insertAllowedValue, sessionId2, componentId, prop);
9533
- });
9534
- }
9535
- function insertPropRow(insertProp, sessionId2, componentId, prop, position) {
9536
- insertProp.run(
9537
- sessionId2,
9538
- componentId,
9539
- prop.name,
9540
- prop.type,
9541
- prop.required ? 1 : 0,
9542
- prop.category ?? null,
9543
- prop.defaultValue ?? null,
9544
- prop.description ?? null,
9545
- prop.tokenReference ?? null,
9546
- position,
9547
- prop.sourceStartLine ?? null,
9548
- prop.sourceEndLine ?? null
9549
- );
9550
- }
9551
- function insertPropAllowedValues(insertAllowedValue, sessionId2, componentId, prop) {
9552
- if (!prop.allowedValues) return;
9553
- prop.allowedValues.forEach((value, position) => {
9554
- insertAllowedValue.run(sessionId2, componentId, prop.name, position, value);
9555
- });
9556
- }
9557
- function createRawSlots(db, sessionId2, componentId, slots) {
9558
- const insertSlot = db.prepare(
9559
- `INSERT INTO raw_slots (session_id, component_id, name, is_default, description, position)
9560
- VALUES (?, ?, ?, ?, ?, ?)`
9561
- );
9562
- const insertAllowedComponent = db.prepare(
9563
- `INSERT INTO raw_slot_allowed_components (session_id, component_id, slot_name, position, allowed_component)
9564
- VALUES (?, ?, ?, ?, ?)`
9565
- );
9566
- slots.forEach((slot, position) => {
9567
- insertSlotRow(insertSlot, sessionId2, componentId, slot, position);
9568
- insertSlotAllowedComponents(insertAllowedComponent, sessionId2, componentId, slot);
9569
- });
9570
- }
9571
- function insertSlotRow(insertSlot, sessionId2, componentId, slot, position) {
9572
- insertSlot.run(sessionId2, componentId, slot.name, slot.isDefault ? 1 : 0, slot.description ?? null, position);
9573
- }
9574
- function insertSlotAllowedComponents(insertAllowedComponent, sessionId2, componentId, slot) {
9575
- if (!slot.allowedComponents) return;
9576
- slot.allowedComponents.forEach((allowedComponent, position) => {
9577
- insertAllowedComponent.run(sessionId2, componentId, slot.name, position, allowedComponent);
9578
- });
9579
- }
9580
- function updateRawComponentsStatus(db, sessionId2, status) {
9581
- db.prepare("UPDATE raw_components SET status = ? WHERE session_id = ?").run(status, sessionId2);
9582
- }
9583
- function updateRawPropCdfByName(db, sessionId2, componentId, propName, cdfType, cdfCategory, cdfTokenKind) {
9584
- const result = db.prepare(
9585
- `UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?
9586
- WHERE session_id = ? AND component_id = ? AND name = ?`
9587
- ).run(cdfType, cdfCategory, cdfTokenKind, sessionId2, componentId, propName);
9588
- return Number(result.changes);
9589
- }
9590
- function updateRawPropCdfByPosition(db, sessionId2, componentId, position, cdfType, cdfCategory, cdfTokenKind) {
9591
- const result = db.prepare(
9592
- `UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?
9593
- WHERE session_id = ? AND component_id = ? AND position = ? AND cdf_type IS NULL`
9594
- ).run(cdfType, cdfCategory, cdfTokenKind, sessionId2, componentId, position);
9595
- return Number(result.changes);
9596
- }
9597
- function updateRawComponentDescription(db, sessionId2, componentId, description) {
9598
- db.prepare("UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?").run(
9599
- description,
9600
- sessionId2,
9601
- componentId
9602
- );
9603
- }
9604
- function deleteRawPropAllowedValuesForProp(db, sessionId2, componentId, propName) {
9605
- db.prepare("DELETE FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ? AND prop_name = ?").run(
9606
- sessionId2,
9607
- componentId,
9608
- propName
9609
- );
9610
- }
9611
- function createRawPropAllowedValue(db, sessionId2, componentId, propName, position, value) {
9612
- db.prepare(
9613
- `INSERT OR IGNORE INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value)
9614
- VALUES (?, ?, ?, ?, ?)`
9615
- ).run(sessionId2, componentId, propName, position, value);
9616
- }
9617
- var init_write4 = __esm({
9618
- "packages/experience-design-system-cli/src/session/repositories/components/raw/write.ts"() {
9619
- "use strict";
9620
- init_derive_component_id();
9621
- }
9622
- });
9623
-
9624
- // packages/experience-design-system-cli/src/session/core/components/group-allowed-values-by-prop.ts
9625
- function groupAllowedValuesByProp(avSnapshot, nameMatchedKeys) {
9626
- const buckets = /* @__PURE__ */ new Map();
9627
- for (const av of avSnapshot) {
9628
- const key = `${av.component_id}::${av.prop_name}`;
9629
- if (!nameMatchedKeys.has(key)) continue;
9630
- const bucket = buckets.get(key) ?? { componentId: av.component_id, propName: av.prop_name, values: [] };
9631
- bucket.values.push(av);
9632
- buckets.set(key, bucket);
9633
- }
9634
- return [...buckets.values()];
9635
- }
9636
- var init_group_allowed_values_by_prop = __esm({
9637
- "packages/experience-design-system-cli/src/session/core/components/group-allowed-values-by-prop.ts"() {
9638
- "use strict";
9639
- }
9640
- });
9641
-
9642
- // packages/experience-design-system-cli/src/session/core/components/plan-cdf-restore.ts
9643
- function planCdfRestore(cdfSnapshot, descSnapshot, avSnapshot, currentProps) {
9644
- const byName = [];
9645
- const byPosition = [];
9646
- const nameMatchedKeys = /* @__PURE__ */ new Set();
9647
- for (const snap of cdfSnapshot) {
9648
- if (currentProps.hasPropNamed(snap.component_id, snap.name)) {
9649
- byName.push(snap);
9650
- nameMatchedKeys.add(propKey(snap.component_id, snap.name));
9651
- continue;
9652
- }
9653
- if (currentProps.propNameAtPosition(snap.component_id, snap.position) !== null) {
9654
- byPosition.push(snap);
9655
- }
9656
- }
9657
- return {
9658
- byName,
9659
- byPosition,
9660
- descriptions: descSnapshot,
9661
- allowedValues: groupAllowedValuesByProp(avSnapshot, nameMatchedKeys)
9662
- };
9663
- }
9664
- function propKey(componentId, propName) {
9665
- return `${componentId}::${propName}`;
9666
- }
9667
- var init_plan_cdf_restore = __esm({
9668
- "packages/experience-design-system-cli/src/session/core/components/plan-cdf-restore.ts"() {
9669
- "use strict";
9670
- init_group_allowed_values_by_prop();
9671
- }
9672
- });
9673
-
9674
- // packages/experience-design-system-cli/src/session/core/shared/memoize-by-key.ts
9675
- function memoizeByKey(lookup) {
9676
- const cache = /* @__PURE__ */ new Map();
9677
- return (a, b) => {
9678
- const key = `${a}::${b}`;
9679
- if (cache.has(key)) return cache.get(key);
9680
- const value = lookup(a, b);
9681
- cache.set(key, value);
9682
- return value;
9683
- };
9684
- }
9685
- var init_memoize_by_key = __esm({
9686
- "packages/experience-design-system-cli/src/session/core/shared/memoize-by-key.ts"() {
9687
- "use strict";
9688
- }
9689
- });
9690
-
9691
- // packages/experience-design-system-cli/src/session/services/components/apply-cdf-restore.ts
9692
- function applyCdfRestore(db, sessionId2, plan) {
9693
- for (const snap of plan.byName) {
9694
- updateRawPropCdfByName(
9695
- db,
9696
- sessionId2,
9697
- snap.component_id,
9698
- snap.name,
9699
- snap.cdf_type,
9700
- snap.cdf_category,
9701
- snap.cdf_token_kind
9702
- );
9703
- }
9704
- for (const snap of plan.byPosition) {
9705
- updateRawPropCdfByPosition(
9706
- db,
9707
- sessionId2,
9708
- snap.component_id,
9709
- snap.position,
9710
- snap.cdf_type,
9711
- snap.cdf_category,
9712
- snap.cdf_token_kind
9713
- );
9714
- }
9715
- for (const snap of plan.descriptions) {
9716
- updateRawComponentDescription(db, sessionId2, snap.component_id, snap.description);
9717
- }
9718
- for (const bucket of plan.allowedValues) {
9719
- deleteRawPropAllowedValuesForProp(db, sessionId2, bucket.componentId, bucket.propName);
9720
- for (const av of bucket.values) {
9721
- createRawPropAllowedValue(db, sessionId2, bucket.componentId, bucket.propName, av.position, av.value);
9722
- }
9723
- }
9724
- }
9725
- var init_apply_cdf_restore = __esm({
9726
- "packages/experience-design-system-cli/src/session/services/components/apply-cdf-restore.ts"() {
9727
- "use strict";
9728
- init_write4();
9729
- }
9730
- });
9731
-
9732
- // packages/experience-design-system-cli/src/session/services/components/store-raw-components.ts
9733
- function storeRawComponents(db, sessionId2, components, options) {
9734
- const now = (/* @__PURE__ */ new Date()).toISOString();
9735
- withTransaction(db, () => {
9736
- const cdfSnapshot = options?.preserveCDF ? getClassifiedProps(db, sessionId2) : [];
9737
- const descSnapshot = options?.preserveCDF ? getComponentDescriptions(db, sessionId2) : [];
9738
- const avSnapshot = options?.preserveCDF && cdfSnapshot.length > 0 ? getRawPropAllowedValues(db, sessionId2) : [];
9739
- deleteRawComponentsForSession(db, sessionId2);
9740
- for (const comp of components) {
9741
- const componentId = createRawComponent(db, sessionId2, comp, now);
9742
- createRawProps(db, sessionId2, componentId, comp.props);
9743
- createRawSlots(db, sessionId2, componentId, comp.slots);
9744
- }
9745
- if (options?.preserveCDF && cdfSnapshot.length > 0) {
9746
- const plan = planCdfRestore(cdfSnapshot, descSnapshot, avSnapshot, {
9747
- hasPropNamed: (componentId, propName) => hasRawPropNamed(db, sessionId2, componentId, propName),
9748
- propNameAtPosition: memoizeByKey(
9749
- (componentId, position) => getRawPropNameAtPosition(db, sessionId2, componentId, position)
9750
- )
9751
- });
9752
- applyCdfRestore(db, sessionId2, plan);
9753
- }
9754
- if (options?.status) {
9755
- updateRawComponentsStatus(db, sessionId2, options.status);
9756
- }
9757
- updateSessionTimestamp(db, sessionId2, now);
9758
- });
9759
- }
9760
- var init_store_raw_components = __esm({
9761
- "packages/experience-design-system-cli/src/session/services/components/store-raw-components.ts"() {
9762
- "use strict";
9763
- init_with_transaction();
9764
- init_write();
9765
- init_read4();
9766
- init_write4();
9767
- init_plan_cdf_restore();
9768
- init_memoize_by_key();
9769
- init_apply_cdf_restore();
9770
- }
9771
- });
9772
-
9773
9214
  // packages/experience-design-system-cli/src/session/cache-keys.ts
9774
9215
  var cache_keys_exports = {};
9775
9216
  __export(cache_keys_exports, {
@@ -10315,6 +9756,239 @@ function updateStep(db, stepId, status, outputs, error) {
10315
9756
  throw e;
10316
9757
  }
10317
9758
  }
9759
+ function storeRawComponents(db, sessionId2, components, options) {
9760
+ const now = (/* @__PURE__ */ new Date()).toISOString();
9761
+ const insertComp = db.prepare(
9762
+ `INSERT INTO raw_components (session_id, component_id, name, source, framework, extracted_at, extraction_confidence, review_reasons, needs_review, source_path)
9763
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
9764
+ );
9765
+ const insertProp = db.prepare(
9766
+ `INSERT INTO raw_props
9767
+ (session_id, component_id, name, type, required, category, default_value, description, token_reference, position, source_start_line, source_end_line)
9768
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`
9769
+ );
9770
+ const insertAllowedValue = db.prepare(
9771
+ `INSERT INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value)
9772
+ VALUES (?, ?, ?, ?, ?)`
9773
+ );
9774
+ const insertSlot = db.prepare(
9775
+ `INSERT INTO raw_slots (session_id, component_id, name, is_default, description, position)
9776
+ VALUES (?, ?, ?, ?, ?, ?)`
9777
+ );
9778
+ const insertAllowedComponent = db.prepare(
9779
+ `INSERT INTO raw_slot_allowed_components (session_id, component_id, slot_name, position, allowed_component)
9780
+ VALUES (?, ?, ?, ?, ?)`
9781
+ );
9782
+ db.exec("BEGIN");
9783
+ try {
9784
+ let cdfSnapshot = [];
9785
+ let descSnapshot = [];
9786
+ let avSnapshot = [];
9787
+ if (options?.preserveCDF) {
9788
+ cdfSnapshot = db.prepare(
9789
+ `SELECT component_id, name, position, cdf_type, cdf_category, cdf_token_kind
9790
+ FROM raw_props WHERE session_id = ? AND cdf_type IS NOT NULL`
9791
+ ).all(sessionId2);
9792
+ descSnapshot = db.prepare(
9793
+ `SELECT component_id, description
9794
+ FROM raw_components WHERE session_id = ? AND description IS NOT NULL`
9795
+ ).all(sessionId2);
9796
+ if (cdfSnapshot.length > 0) {
9797
+ avSnapshot = db.prepare(
9798
+ `SELECT component_id, prop_name, position, value
9799
+ FROM raw_prop_allowed_values WHERE session_id = ?`
9800
+ ).all(sessionId2);
9801
+ }
9802
+ }
9803
+ db.prepare("DELETE FROM raw_components WHERE session_id = ?").run(sessionId2);
9804
+ for (const comp of components) {
9805
+ const componentId = deriveComponentId(comp.name, comp.source);
9806
+ insertComp.run(
9807
+ sessionId2,
9808
+ componentId,
9809
+ comp.name,
9810
+ comp.source,
9811
+ comp.framework,
9812
+ now,
9813
+ comp.extractionConfidence ?? null,
9814
+ JSON.stringify(comp.reviewReasons ?? []),
9815
+ comp.needsReview ? 1 : 0,
9816
+ comp.sourcePath ?? null
9817
+ );
9818
+ for (let i = 0; i < comp.props.length; i++) {
9819
+ const prop = comp.props[i];
9820
+ insertProp.run(
9821
+ sessionId2,
9822
+ componentId,
9823
+ prop.name,
9824
+ prop.type,
9825
+ prop.required ? 1 : 0,
9826
+ prop.category ?? null,
9827
+ prop.defaultValue ?? null,
9828
+ prop.description ?? null,
9829
+ prop.tokenReference ?? null,
9830
+ i,
9831
+ prop.sourceStartLine ?? null,
9832
+ prop.sourceEndLine ?? null
9833
+ );
9834
+ if (prop.allowedValues) {
9835
+ prop.allowedValues.forEach((v, j) => insertAllowedValue.run(sessionId2, componentId, prop.name, j, v));
9836
+ }
9837
+ }
9838
+ for (let i = 0; i < comp.slots.length; i++) {
9839
+ const slot = comp.slots[i];
9840
+ insertSlot.run(sessionId2, componentId, slot.name, slot.isDefault ? 1 : 0, slot.description ?? null, i);
9841
+ if (slot.allowedComponents) {
9842
+ slot.allowedComponents.forEach(
9843
+ (ac, j) => insertAllowedComponent.run(sessionId2, componentId, slot.name, j, ac)
9844
+ );
9845
+ }
9846
+ }
9847
+ }
9848
+ if (options?.preserveCDF && cdfSnapshot.length > 0) {
9849
+ const updateCDFByName = db.prepare(
9850
+ `UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?
9851
+ WHERE session_id = ? AND component_id = ? AND name = ?`
9852
+ );
9853
+ const updateCDFByPosition = db.prepare(
9854
+ `UPDATE raw_props SET cdf_type = ?, cdf_category = ?, cdf_token_kind = ?
9855
+ WHERE session_id = ? AND component_id = ? AND position = ? AND cdf_type IS NULL`
9856
+ );
9857
+ const restoredPropKeys = /* @__PURE__ */ new Set();
9858
+ const unmatchedSnaps = [];
9859
+ for (const snap of cdfSnapshot) {
9860
+ const result = updateCDFByName.run(
9861
+ snap.cdf_type,
9862
+ snap.cdf_category,
9863
+ snap.cdf_token_kind,
9864
+ sessionId2,
9865
+ snap.component_id,
9866
+ snap.name
9867
+ );
9868
+ if (Number(result.changes) > 0) {
9869
+ restoredPropKeys.add(`${snap.component_id}::${snap.name}`);
9870
+ } else {
9871
+ unmatchedSnaps.push(snap);
9872
+ }
9873
+ }
9874
+ for (const snap of unmatchedSnaps) {
9875
+ const result = updateCDFByPosition.run(
9876
+ snap.cdf_type,
9877
+ snap.cdf_category,
9878
+ snap.cdf_token_kind,
9879
+ sessionId2,
9880
+ snap.component_id,
9881
+ snap.position
9882
+ );
9883
+ if (Number(result.changes) > 0) {
9884
+ const matched = db.prepare(`SELECT name FROM raw_props WHERE session_id = ? AND component_id = ? AND position = ?`).get(sessionId2, snap.component_id, snap.position);
9885
+ if (matched) {
9886
+ restoredPropKeys.add(`${snap.component_id}::${matched.name}`);
9887
+ }
9888
+ }
9889
+ }
9890
+ const updateDesc = db.prepare(
9891
+ `UPDATE raw_components SET description = ? WHERE session_id = ? AND component_id = ?`
9892
+ );
9893
+ for (const snap of descSnapshot) {
9894
+ updateDesc.run(snap.description, sessionId2, snap.component_id);
9895
+ }
9896
+ const relevantAV = avSnapshot.filter((av) => restoredPropKeys.has(`${av.component_id}::${av.prop_name}`));
9897
+ if (relevantAV.length > 0) {
9898
+ const deleteAV = db.prepare(
9899
+ `DELETE FROM raw_prop_allowed_values WHERE session_id = ? AND component_id = ? AND prop_name = ?`
9900
+ );
9901
+ const insertAV = db.prepare(
9902
+ `INSERT OR IGNORE INTO raw_prop_allowed_values (session_id, component_id, prop_name, position, value)
9903
+ VALUES (?, ?, ?, ?, ?)`
9904
+ );
9905
+ const deletedKeys = /* @__PURE__ */ new Set();
9906
+ for (const av of relevantAV) {
9907
+ const key = `${av.component_id}::${av.prop_name}`;
9908
+ if (!deletedKeys.has(key)) {
9909
+ deleteAV.run(sessionId2, av.component_id, av.prop_name);
9910
+ deletedKeys.add(key);
9911
+ }
9912
+ insertAV.run(sessionId2, av.component_id, av.prop_name, av.position, av.value);
9913
+ }
9914
+ }
9915
+ }
9916
+ if (options?.status) {
9917
+ db.prepare("UPDATE raw_components SET status = ? WHERE session_id = ?").run(options.status, sessionId2);
9918
+ }
9919
+ db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, sessionId2);
9920
+ db.exec("COMMIT");
9921
+ } catch (e) {
9922
+ db.exec("ROLLBACK");
9923
+ throw e;
9924
+ }
9925
+ }
9926
+ function loadRawComponents(db, sessionId2, allowedNames) {
9927
+ const all = db.prepare(
9928
+ "SELECT component_id, name, source, framework, extraction_confidence, review_reasons, needs_review, source_path FROM raw_components WHERE session_id = ? ORDER BY rowid"
9929
+ ).all(sessionId2);
9930
+ const components = allowedNames ? all.filter((c2) => allowedNames.has(c2.name)) : all;
9931
+ if (components.length === 0) return [];
9932
+ const props = db.prepare(
9933
+ `SELECT component_id, name, type, required, category, default_value, description, token_reference, position,
9934
+ rationale, source_start_line, source_end_line
9935
+ FROM raw_props WHERE session_id = ? ORDER BY component_id, position`
9936
+ ).all(sessionId2);
9937
+ const allowedValues = db.prepare(
9938
+ `SELECT component_id, prop_name, position, value
9939
+ FROM raw_prop_allowed_values WHERE session_id = ? ORDER BY component_id, prop_name, position`
9940
+ ).all(sessionId2);
9941
+ const slots = db.prepare(
9942
+ `SELECT component_id, name, is_default, description, position
9943
+ FROM raw_slots WHERE session_id = ? ORDER BY component_id, position`
9944
+ ).all(sessionId2);
9945
+ const allowedComponents = db.prepare(
9946
+ `SELECT component_id, slot_name, position, allowed_component
9947
+ FROM raw_slot_allowed_components WHERE session_id = ? ORDER BY component_id, slot_name, position`
9948
+ ).all(sessionId2);
9949
+ const propsByComponent = indexRowsByKey(props, (p) => p.component_id);
9950
+ const allowedValuesByProp = indexRowsByKey(allowedValues, (av) => `${av.component_id}::${av.prop_name}`);
9951
+ const slotsByComponent = indexRowsByKey(slots, (s) => s.component_id);
9952
+ const allowedComponentsBySlot = indexRowsByKey(allowedComponents, (ac) => `${ac.component_id}::${ac.slot_name}`);
9953
+ return components.map(
9954
+ (c2) => ({
9955
+ component_id: c2.component_id,
9956
+ name: c2.name,
9957
+ source: c2.source,
9958
+ framework: c2.framework,
9959
+ extractionConfidence: c2.extraction_confidence ?? null,
9960
+ reviewReasons: parseReviewReasons(c2.review_reasons),
9961
+ needsReview: Boolean(c2.needs_review),
9962
+ sourcePath: c2.source_path ?? void 0,
9963
+ props: (propsByComponent.get(c2.component_id) ?? []).map((p) => {
9964
+ const av = allowedValuesByProp.get(`${c2.component_id}::${p.name}`);
9965
+ const prop = {
9966
+ name: p.name,
9967
+ type: p.type,
9968
+ required: Boolean(p.required)
9969
+ };
9970
+ if (p.category !== null) prop.category = p.category;
9971
+ if (p.default_value !== null) prop.defaultValue = p.default_value;
9972
+ if (p.description !== null) prop.description = p.description;
9973
+ if (p.token_reference !== null) prop.tokenReference = p.token_reference;
9974
+ if (av && av.length > 0) prop.allowedValues = av.map((v) => v.value);
9975
+ if (p.source_start_line !== null) prop.sourceStartLine = p.source_start_line;
9976
+ if (p.source_end_line !== null) prop.sourceEndLine = p.source_end_line;
9977
+ return prop;
9978
+ }),
9979
+ slots: (slotsByComponent.get(c2.component_id) ?? []).map((s) => {
9980
+ const ac = allowedComponentsBySlot.get(`${c2.component_id}::${s.name}`);
9981
+ const slot = {
9982
+ name: s.name,
9983
+ isDefault: Boolean(s.is_default)
9984
+ };
9985
+ if (s.description !== null) slot.description = s.description;
9986
+ if (ac && ac.length > 0) slot.allowedComponents = ac.map((v) => v.allowed_component);
9987
+ return slot;
9988
+ })
9989
+ })
9990
+ );
9991
+ }
10318
9992
  function rewrittenSourcePaths(basePath) {
10319
9993
  for (const [emitted, sources] of TS_ESM_EXTENSION_REWRITES) {
10320
9994
  if (!basePath.endsWith(emitted)) continue;
@@ -10493,7 +10167,7 @@ function renameEmptySlots(db, sessionId2, componentId, componentName, slotCount)
10493
10167
  }
10494
10168
  return { renames, warnings };
10495
10169
  }
10496
- function parseReviewReasons2(raw) {
10170
+ function parseReviewReasons(raw) {
10497
10171
  try {
10498
10172
  const parsed = JSON.parse(raw ?? "[]");
10499
10173
  return Array.isArray(parsed) ? parsed.filter((reason) => typeof reason === "string") : [];
@@ -10747,7 +10421,7 @@ function loadScopeComponents(db, sessionId2) {
10747
10421
  const slotsByComponent = indexRowsByKey(slotRows, (s) => s.component_id);
10748
10422
  const allowedBySlot = indexRowsByKey(allowedRows, (a) => `${a.component_id}::${a.slot_name}`);
10749
10423
  return rows.map((r) => {
10750
- const reviewReasons = parseReviewReasons2(r.review_reasons);
10424
+ const reviewReasons = parseReviewReasons(r.review_reasons);
10751
10425
  const nonAuthorableReason = reviewReasons.find((reason) => reason.startsWith("non-authorable:"));
10752
10426
  return {
10753
10427
  name: r.name,
@@ -11105,9 +10779,9 @@ function copyMapTokensFromCache(db, sourceSessionId, targetSessionId) {
11105
10779
  const targetComponentId = targetIdByName.get(row.component_name);
11106
10780
  if (!targetComponentId) continue;
11107
10781
  if (!targetProps.has(`${targetComponentId}::${row.prop_name}`)) continue;
11108
- const propKey2 = `${targetComponentId}::${row.prop_name}`;
11109
- if (!clearedProps.has(propKey2)) {
11110
- clearedProps.add(propKey2);
10782
+ const propKey = `${targetComponentId}::${row.prop_name}`;
10783
+ if (!clearedProps.has(propKey)) {
10784
+ clearedProps.add(propKey);
11111
10785
  db.prepare(`DELETE FROM raw_prop_token_paths WHERE session_id = ? AND component_id = ? AND prop_name = ?`).run(
11112
10786
  targetSessionId,
11113
10787
  targetComponentId,
@@ -11115,7 +10789,7 @@ function copyMapTokensFromCache(db, sourceSessionId, targetSessionId) {
11115
10789
  );
11116
10790
  }
11117
10791
  insertPath.run(targetSessionId, targetComponentId, row.prop_name, row.source, row.position, row.path);
11118
- copiedProps.add(propKey2);
10792
+ copiedProps.add(propKey);
11119
10793
  }
11120
10794
  copiedCount = copiedProps.size;
11121
10795
  db.prepare("UPDATE sessions SET updated_at = ? WHERE id = ?").run(now, targetSessionId);
@@ -11213,8 +10887,6 @@ var init_db = __esm({
11213
10887
  init_apply_tool_calls();
11214
10888
  init_replace_raw_token_name_paths();
11215
10889
  init_replace_raw_prop_token_paths();
11216
- init_read4();
11217
- init_store_raw_components();
11218
10890
  SCHEMA = `
11219
10891
  PRAGMA journal_mode = WAL;
11220
10892
  PRAGMA foreign_keys = ON;
@@ -11456,7 +11128,7 @@ async function ensureRefineSession(sessionId2, artifactsRoot, initialSnapshot) {
11456
11128
  }
11457
11129
  async function writeScopeDecisionsSnapshot(db, sessionId2, decisions) {
11458
11130
  const acceptedSet = new Set(decisions.accepted);
11459
- const rawComponents = getRawComponents(db, sessionId2);
11131
+ const rawComponents = loadRawComponents(db, sessionId2);
11460
11132
  const records = rawComponents.map((c2) => {
11461
11133
  const status = acceptedSet.has(c2.name) ? "accepted" : "rejected";
11462
11134
  const proposal = {
@@ -12511,7 +12183,7 @@ function useSession({ sessionId: sessionId2, artifactsRoot, reviewRoot }) {
12511
12183
  const db = openPipelineDb();
12512
12184
  let rawComponents;
12513
12185
  try {
12514
- rawComponents = getRawComponents(db, sessionId2);
12186
+ rawComponents = loadRawComponents(db, sessionId2);
12515
12187
  } finally {
12516
12188
  db.close();
12517
12189
  }
@@ -16906,7 +16578,7 @@ async function loadAndValidateForReview(sessionId2, projectRoot) {
16906
16578
  const db = openPipelineDb();
16907
16579
  let rawComponents;
16908
16580
  try {
16909
- rawComponents = getRawComponents(db, sessionId2);
16581
+ rawComponents = loadRawComponents(db, sessionId2);
16910
16582
  } finally {
16911
16583
  db.close();
16912
16584
  }
@@ -17025,7 +16697,7 @@ function registerAnalyzeEditCommand(program) {
17025
16697
  const db = openPipelineDb();
17026
16698
  let rawComponentCount = 0;
17027
16699
  try {
17028
- rawComponentCount = getRawComponents(db, sessionId2).length;
16700
+ rawComponentCount = loadRawComponents(db, sessionId2).length;
17029
16701
  } finally {
17030
16702
  db.close();
17031
16703
  }
@@ -31446,7 +31118,7 @@ function registerAnalyzeSelectAgentCommand(program) {
31446
31118
  let rawComponents;
31447
31119
  let scannedFiles = [];
31448
31120
  try {
31449
- rawComponents = getRawComponents(db, sessionId2);
31121
+ rawComponents = loadRawComponents(db, sessionId2);
31450
31122
  scannedFiles = loadScannedFiles(db, sessionId2);
31451
31123
  } finally {
31452
31124
  db.close();
@@ -33588,7 +33260,7 @@ async function runGenerateSkill(skill, opts, verbose = false) {
33588
33260
  const acceptedNames = await loadAcceptedNames(sessionId2);
33589
33261
  const db = openPipelineDb();
33590
33262
  try {
33591
- allComponents = getRawComponents(db, sessionId2, acceptedNames ?? void 0);
33263
+ allComponents = loadRawComponents(db, sessionId2, acceptedNames ?? void 0);
33592
33264
  } finally {
33593
33265
  db.close();
33594
33266
  }
@@ -16,8 +16,6 @@ export { storeDtcgTokens as storeDTCGTokens } from './services/tokens/store-dtcg
16
16
  export { applyTokenToolCalls, type ApplyTokenToolCallsResult } from './services/tokens/apply-tool-calls.js';
17
17
  export { replaceRawTokenNamePaths } from './services/tokens/replace-raw-token-name-paths.js';
18
18
  export { replaceRawPropTokenPaths } from './services/tokens/replace-raw-prop-token-paths.js';
19
- export { getRawComponents as loadRawComponents, type RawComponentWithId } from './repositories/components/raw/read.js';
20
- export { storeRawComponents } from './services/components/store-raw-components.js';
21
19
  export type StepStatus = 'pending' | 'complete' | 'failed' | 'interrupted';
22
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';
23
21
  export interface SessionRow {
@@ -81,6 +79,14 @@ export type { SessionResolution };
81
79
  export declare function getOrCreateSession(db: DatabaseSync, sessionFlag: string | undefined, sessionName: string | undefined, hints: MatchHints): SessionResolution;
82
80
  export declare function createStep(db: DatabaseSync, sessionId: string, command: CommandName, inputs: Record<string, string>): number;
83
81
  export declare function updateStep(db: DatabaseSync, stepId: number, status: 'complete' | 'failed', outputs: Record<string, string>, error?: string): void;
82
+ export declare function storeRawComponents(db: DatabaseSync, sessionId: string, components: RawComponentDefinition[], options?: {
83
+ status?: string;
84
+ preserveCDF?: boolean;
85
+ }): void;
86
+ export type RawComponentWithId = RawComponentDefinition & {
87
+ component_id: string;
88
+ };
89
+ export declare function loadRawComponents(db: DatabaseSync, sessionId: string, allowedNames?: Set<string>): RawComponentWithId[];
84
90
  export declare function loadComponentSourceRef(name: string, sourcePath: string, propNames?: string[], propTypes?: string[]): Promise<ComponentSourceRef>;
85
91
  export declare function loadComponentSourceRefs(db: DatabaseSync, sessionId: string): Promise<ComponentSourceRef[]>;
86
92
  export declare function renameEmptySlots(db: DatabaseSync, sessionId: string, componentId: string, componentName: string, slotCount: number): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentful/experience-design-system-cli",
3
- "version": "2.33.1-dev-build-d733cbf.0",
3
+ "version": "2.33.1-dev-build-d7fc540.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-cli-v2": "2.33.1-dev-build-d733cbf.0",
44
- "@contentful/experience-design-system-types": "2.33.1-dev-build-d733cbf.0"
43
+ "@contentful/experience-design-system-cli-v2": "2.33.1-dev-build-d7fc540.0",
44
+ "@contentful/experience-design-system-types": "2.33.1-dev-build-d7fc540.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-client": "2.33.1-dev-build-d733cbf.0",
57
- "@contentful/experience-design-system-extraction": "2.33.1-dev-build-d733cbf.0",
58
- "@contentful/experience-design-system-generation": "2.33.1-dev-build-d733cbf.0"
56
+ "@contentful/experience-design-system-client": "2.33.1-dev-build-d7fc540.0",
57
+ "@contentful/experience-design-system-extraction": "2.33.1-dev-build-d7fc540.0",
58
+ "@contentful/experience-design-system-generation": "2.33.1-dev-build-d7fc540.0"
59
59
  },
60
60
  "repository": {
61
61
  "type": "git",
@@ -1,2 +0,0 @@
1
- import type { AllowedValueSnapshotEntry, RestoredAllowedValues } from './snapshot-types.js';
2
- export declare function groupAllowedValuesByProp(avSnapshot: AllowedValueSnapshotEntry[], nameMatchedKeys: ReadonlySet<string>): RestoredAllowedValues[];
@@ -1,3 +0,0 @@
1
- import type { AllowedValueSnapshotEntry, CdfRestorePlan, CdfSnapshotEntry, CurrentPropsQuery, DescriptionSnapshotEntry } from './snapshot-types.js';
2
- export type { AllowedValueSnapshotEntry, CdfRestorePlan, CdfSnapshotEntry, CurrentPropsQuery, DescriptionSnapshotEntry, RestoredAllowedValues, } from './snapshot-types.js';
3
- export declare function planCdfRestore(cdfSnapshot: CdfSnapshotEntry[], descSnapshot: DescriptionSnapshotEntry[], avSnapshot: AllowedValueSnapshotEntry[], currentProps: CurrentPropsQuery): CdfRestorePlan;
@@ -1,33 +0,0 @@
1
- export interface CdfSnapshotEntry {
2
- component_id: string;
3
- name: string;
4
- position: number;
5
- cdf_type: string;
6
- cdf_category: string;
7
- cdf_token_kind: string | null;
8
- }
9
- export interface DescriptionSnapshotEntry {
10
- component_id: string;
11
- description: string;
12
- }
13
- export interface AllowedValueSnapshotEntry {
14
- component_id: string;
15
- prop_name: string;
16
- position: number;
17
- value: string;
18
- }
19
- export interface RestoredAllowedValues {
20
- componentId: string;
21
- propName: string;
22
- values: AllowedValueSnapshotEntry[];
23
- }
24
- export interface CdfRestorePlan {
25
- byName: CdfSnapshotEntry[];
26
- byPosition: CdfSnapshotEntry[];
27
- descriptions: DescriptionSnapshotEntry[];
28
- allowedValues: RestoredAllowedValues[];
29
- }
30
- export interface CurrentPropsQuery {
31
- hasPropNamed: (componentId: string, propName: string) => boolean;
32
- propNameAtPosition: (componentId: string, position: number) => string | null;
33
- }
@@ -1 +0,0 @@
1
- export declare function memoizeByKey<A extends string | number, B extends string | number, R>(lookup: (a: A, b: B) => R): (a: A, b: B) => R;
@@ -1,10 +0,0 @@
1
- export interface RawComponentRow {
2
- component_id: string;
3
- name: string;
4
- source: string;
5
- framework: string;
6
- extraction_confidence: number | null;
7
- review_reasons: string;
8
- needs_review: number;
9
- source_path: string | null;
10
- }
@@ -1,14 +0,0 @@
1
- export interface RawPropRow {
2
- component_id: string;
3
- name: string;
4
- type: string;
5
- required: number;
6
- category: string | null;
7
- default_value: string | null;
8
- description: string | null;
9
- token_reference: string | null;
10
- position: number;
11
- rationale: string | null;
12
- source_start_line: number | null;
13
- source_end_line: number | null;
14
- }
@@ -1,6 +0,0 @@
1
- export interface RawSlotAllowedComponentRow {
2
- component_id: string;
3
- slot_name: string;
4
- position: number;
5
- allowed_component: string;
6
- }
@@ -1,7 +0,0 @@
1
- export interface RawSlotRow {
2
- component_id: string;
3
- name: string;
4
- is_default: number;
5
- description: string | null;
6
- position: number;
7
- }
@@ -1,18 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawComponentDefinition } from '../../../../types.js';
3
- export type { RawComponentRow, RawPropRow, RawSlotRow, RawSlotAllowedComponentRow } from './rows.js';
4
- export { mapRawComponentRow, mapRawPropRow, mapRawSlotRow, mapRawSlotAllowedComponentRow, mapAllowedValueSnapshotRow, parseReviewReasons, } from './row-mappers.js';
5
- export { getRawComponentRows } from './reads/get-raw-component-rows.js';
6
- export { getRawPropRows } from './reads/get-raw-prop-rows.js';
7
- export { getRawPropAllowedValueRows } from './reads/get-raw-prop-allowed-value-rows.js';
8
- export { getRawSlotRows } from './reads/get-raw-slot-rows.js';
9
- export { getRawSlotAllowedComponentRows } from './reads/get-raw-slot-allowed-component-rows.js';
10
- export { getClassifiedProps } from './reads/get-classified-props.js';
11
- export { getComponentDescriptions } from './reads/get-component-descriptions.js';
12
- export { getRawPropAllowedValues } from './reads/get-raw-prop-allowed-values.js';
13
- export { getRawPropNameAtPosition } from './reads/get-raw-prop-name-at-position.js';
14
- export { hasRawPropNamed } from './reads/has-raw-prop-named.js';
15
- export type RawComponentWithId = RawComponentDefinition & {
16
- component_id: string;
17
- };
18
- export declare function getRawComponents(db: DatabaseSync, sessionId: string, allowedNames?: Set<string>): RawComponentWithId[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { CdfSnapshotEntry } from '../../../../core/components/plan-cdf-restore.js';
3
- export declare function getClassifiedProps(db: DatabaseSync, sessionId: string): CdfSnapshotEntry[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { DescriptionSnapshotEntry } from '../../../../core/components/plan-cdf-restore.js';
3
- export declare function getComponentDescriptions(db: DatabaseSync, sessionId: string): DescriptionSnapshotEntry[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawComponentRow } from '../rows.js';
3
- export declare function getRawComponentRows(db: DatabaseSync, sessionId: string): RawComponentRow[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { AllowedValueSnapshotEntry } from '../../../../core/components/plan-cdf-restore.js';
3
- export declare function getRawPropAllowedValueRows(db: DatabaseSync, sessionId: string): AllowedValueSnapshotEntry[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { AllowedValueSnapshotEntry } from '../../../../core/components/plan-cdf-restore.js';
3
- export declare function getRawPropAllowedValues(db: DatabaseSync, sessionId: string): AllowedValueSnapshotEntry[];
@@ -1,2 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- export declare function getRawPropNameAtPosition(db: DatabaseSync, sessionId: string, componentId: string, position: number): string | null;
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawPropRow } from '../rows.js';
3
- export declare function getRawPropRows(db: DatabaseSync, sessionId: string): RawPropRow[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawSlotAllowedComponentRow } from '../rows.js';
3
- export declare function getRawSlotAllowedComponentRows(db: DatabaseSync, sessionId: string): RawSlotAllowedComponentRow[];
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawSlotRow } from '../rows.js';
3
- export declare function getRawSlotRows(db: DatabaseSync, sessionId: string): RawSlotRow[];
@@ -1,2 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- export declare function hasRawPropNamed(db: DatabaseSync, sessionId: string, componentId: string, propName: string): boolean;
@@ -1,8 +0,0 @@
1
- import type { AllowedValueSnapshotEntry } from '../../../core/components/plan-cdf-restore.js';
2
- import type { RawComponentRow, RawPropRow, RawSlotAllowedComponentRow, RawSlotRow } from './rows.js';
3
- export declare function mapRawComponentRow(row: Record<string, unknown>): RawComponentRow;
4
- export declare function mapRawPropRow(row: Record<string, unknown>): RawPropRow;
5
- export declare function mapAllowedValueSnapshotRow(row: Record<string, unknown>): AllowedValueSnapshotEntry;
6
- export declare function mapRawSlotRow(row: Record<string, unknown>): RawSlotRow;
7
- export declare function mapRawSlotAllowedComponentRow(row: Record<string, unknown>): RawSlotAllowedComponentRow;
8
- export declare function parseReviewReasons(raw: string): string[];
@@ -1,4 +0,0 @@
1
- export type { RawComponentRow } from './interfaces/raw-component-row.js';
2
- export type { RawPropRow } from './interfaces/raw-prop-row.js';
3
- export type { RawSlotRow } from './interfaces/raw-slot-row.js';
4
- export type { RawSlotAllowedComponentRow } from './interfaces/raw-slot-allowed-component-row.js';
@@ -1,12 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawComponentDefinition } from '../../../../types.js';
3
- export declare function deleteRawComponentsForSession(db: DatabaseSync, sessionId: string): void;
4
- export declare function createRawComponent(db: DatabaseSync, sessionId: string, comp: RawComponentDefinition, extractedAt: string): string;
5
- export declare function createRawProps(db: DatabaseSync, sessionId: string, componentId: string, props: RawComponentDefinition['props']): void;
6
- export declare function createRawSlots(db: DatabaseSync, sessionId: string, componentId: string, slots: RawComponentDefinition['slots']): void;
7
- export declare function updateRawComponentsStatus(db: DatabaseSync, sessionId: string, status: string): void;
8
- export declare function updateRawPropCdfByName(db: DatabaseSync, sessionId: string, componentId: string, propName: string, cdfType: string, cdfCategory: string, cdfTokenKind: string | null): number;
9
- export declare function updateRawPropCdfByPosition(db: DatabaseSync, sessionId: string, componentId: string, position: number, cdfType: string, cdfCategory: string, cdfTokenKind: string | null): number;
10
- export declare function updateRawComponentDescription(db: DatabaseSync, sessionId: string, componentId: string, description: string): void;
11
- export declare function deleteRawPropAllowedValuesForProp(db: DatabaseSync, sessionId: string, componentId: string, propName: string): void;
12
- export declare function createRawPropAllowedValue(db: DatabaseSync, sessionId: string, componentId: string, propName: string, position: number, value: string): void;
@@ -1,3 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { CdfRestorePlan } from '../../core/components/plan-cdf-restore.js';
3
- export declare function applyCdfRestore(db: DatabaseSync, sessionId: string, plan: CdfRestorePlan): void;
@@ -1,6 +0,0 @@
1
- import type { DatabaseSync } from 'node:sqlite';
2
- import type { RawComponentDefinition } from '../../../types.js';
3
- export declare function storeRawComponents(db: DatabaseSync, sessionId: string, components: RawComponentDefinition[], options?: {
4
- status?: string;
5
- preserveCDF?: boolean;
6
- }): void;