prisma-next 0.12.0-dev.5 → 0.12.0-dev.51

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 (127) hide show
  1. package/dist/cli.mjs +180 -163
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/{client-KgJorIvG.mjs → client-DC-UlBLy.mjs} +83 -58
  4. package/dist/client-DC-UlBLy.mjs.map +1 -0
  5. package/dist/{command-helpers-Bbw1GbwL.mjs → command-helpers-esJGBD4W.mjs} +317 -23
  6. package/dist/command-helpers-esJGBD4W.mjs.map +1 -0
  7. package/dist/commands/contract-emit.mjs +1 -1
  8. package/dist/commands/contract-infer.mjs +1 -1
  9. package/dist/commands/db-init.mjs +4 -5
  10. package/dist/commands/db-init.mjs.map +1 -1
  11. package/dist/commands/db-schema.mjs +3 -3
  12. package/dist/commands/db-sign.mjs +4 -4
  13. package/dist/commands/db-update.d.mts.map +1 -1
  14. package/dist/commands/db-update.mjs +10 -7
  15. package/dist/commands/db-update.mjs.map +1 -1
  16. package/dist/commands/db-verify.mjs +1 -1
  17. package/dist/commands/migrate.d.mts +2 -2
  18. package/dist/commands/migrate.d.mts.map +1 -1
  19. package/dist/commands/migrate.mjs +6 -8
  20. package/dist/commands/migrate.mjs.map +1 -1
  21. package/dist/commands/migration-check.d.mts +55 -13
  22. package/dist/commands/migration-check.d.mts.map +1 -1
  23. package/dist/commands/migration-check.mjs +3 -2
  24. package/dist/commands/migration-graph.d.mts +17 -8
  25. package/dist/commands/migration-graph.d.mts.map +1 -1
  26. package/dist/commands/migration-graph.mjs +183 -2
  27. package/dist/commands/migration-graph.mjs.map +1 -0
  28. package/dist/commands/migration-list.d.mts +25 -27
  29. package/dist/commands/migration-list.d.mts.map +1 -1
  30. package/dist/commands/migration-list.mjs +2 -190
  31. package/dist/commands/migration-log.d.mts +9 -19
  32. package/dist/commands/migration-log.d.mts.map +1 -1
  33. package/dist/commands/migration-log.mjs +1 -137
  34. package/dist/commands/migration-new.mjs +3 -3
  35. package/dist/commands/migration-plan.d.mts +1 -1
  36. package/dist/commands/migration-plan.mjs +1 -1
  37. package/dist/commands/migration-show.d.mts +17 -21
  38. package/dist/commands/migration-show.d.mts.map +1 -1
  39. package/dist/commands/migration-show.mjs +23 -35
  40. package/dist/commands/migration-show.mjs.map +1 -1
  41. package/dist/commands/migration-status.d.mts +42 -144
  42. package/dist/commands/migration-status.d.mts.map +1 -1
  43. package/dist/commands/migration-status.mjs +3 -759
  44. package/dist/commands/ref.d.mts +1 -1
  45. package/dist/commands/ref.mjs +3 -3
  46. package/dist/commands/telemetry/index.d.mts +7 -0
  47. package/dist/commands/telemetry/index.d.mts.map +1 -0
  48. package/dist/commands/telemetry/index.mjs +2 -0
  49. package/dist/{contract-at-errors-BxP-TOMl.mjs → contract-at-errors-COZAemUl.mjs} +2 -2
  50. package/dist/{contract-at-errors-BxP-TOMl.mjs.map → contract-at-errors-COZAemUl.mjs.map} +1 -1
  51. package/dist/{contract-emit-DxcGl4Uq.mjs → contract-emit-Bv46RAIO.mjs} +3 -3
  52. package/dist/{contract-emit-DxcGl4Uq.mjs.map → contract-emit-Bv46RAIO.mjs.map} +1 -1
  53. package/dist/{contract-emit-D-4jrNve.mjs → contract-emit-DIWImLqS.mjs} +5 -5
  54. package/dist/{contract-emit-D-4jrNve.mjs.map → contract-emit-DIWImLqS.mjs.map} +1 -1
  55. package/dist/{contract-infer-D8uEbJuu.mjs → contract-infer-DpGN9SAj.mjs} +3 -3
  56. package/dist/{contract-infer-D8uEbJuu.mjs.map → contract-infer-DpGN9SAj.mjs.map} +1 -1
  57. package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs → contract-space-aggregate-loader-CpNVrBqW.mjs} +63 -5
  58. package/dist/{contract-space-aggregate-loader-DvZwdkrr.mjs.map → contract-space-aggregate-loader-CpNVrBqW.mjs.map} +1 -1
  59. package/dist/{db-verify-v_vUKXTU.mjs → db-verify-Cq16Obsw.mjs} +4 -4
  60. package/dist/{db-verify-v_vUKXTU.mjs.map → db-verify-Cq16Obsw.mjs.map} +1 -1
  61. package/dist/exports/control-api.d.mts +2 -2
  62. package/dist/exports/control-api.d.mts.map +1 -1
  63. package/dist/exports/control-api.mjs +2 -2
  64. package/dist/exports/index.mjs +1 -1
  65. package/dist/exports/init-output.mjs +1 -1
  66. package/dist/{framework-components-fYXjz_in.mjs → framework-components-BO9VO43s.mjs} +2 -2
  67. package/dist/{framework-components-fYXjz_in.mjs.map → framework-components-BO9VO43s.mjs.map} +1 -1
  68. package/dist/{global-flags-DEHjV8_s.d.mts → global-flags-CV5LhrFg.d.mts} +1 -1
  69. package/dist/{global-flags-DEHjV8_s.d.mts.map → global-flags-CV5LhrFg.d.mts.map} +1 -1
  70. package/dist/{init-Cv9UzWL5.mjs → init-C0rjiQ9I.mjs} +5 -58
  71. package/dist/init-C0rjiQ9I.mjs.map +1 -0
  72. package/dist/{inspect-live-schema-C6ohV_oQ.mjs → inspect-live-schema-CRDKTNcf.mjs} +3 -3
  73. package/dist/{inspect-live-schema-C6ohV_oQ.mjs.map → inspect-live-schema-CRDKTNcf.mjs.map} +1 -1
  74. package/dist/migration-check-BxWlQBOs.mjs +573 -0
  75. package/dist/migration-check-BxWlQBOs.mjs.map +1 -0
  76. package/dist/{migration-command-scaffold-CjvwO6at.mjs → migration-command-scaffold-BDd9abqW.mjs} +3 -3
  77. package/dist/{migration-command-scaffold-CjvwO6at.mjs.map → migration-command-scaffold-BDd9abqW.mjs.map} +1 -1
  78. package/dist/migration-graph-space-render-CeNXh_Wy.mjs +1966 -0
  79. package/dist/migration-graph-space-render-CeNXh_Wy.mjs.map +1 -0
  80. package/dist/migration-list-vJWFuXca.mjs +228 -0
  81. package/dist/migration-list-vJWFuXca.mjs.map +1 -0
  82. package/dist/migration-log-6rcHQSI4.mjs +222 -0
  83. package/dist/migration-log-6rcHQSI4.mjs.map +1 -0
  84. package/dist/migration-path-target-UkxkgXnv.mjs +38 -0
  85. package/dist/migration-path-target-UkxkgXnv.mjs.map +1 -0
  86. package/dist/{migration-plan-9DJ7q7_z.mjs → migration-plan-CHu_erQ5.mjs} +5 -6
  87. package/dist/{migration-plan-9DJ7q7_z.mjs.map → migration-plan-CHu_erQ5.mjs.map} +1 -1
  88. package/dist/migration-status-Bjv91dE7.mjs +444 -0
  89. package/dist/migration-status-Bjv91dE7.mjs.map +1 -0
  90. package/dist/{output-B60Gw5fu.mjs → output-BD61elic.mjs} +1 -1
  91. package/dist/{output-B60Gw5fu.mjs.map → output-BD61elic.mjs.map} +1 -1
  92. package/dist/{ref-advancement-DUZqsue6.mjs → ref-advancement-CJY9zOv7.mjs} +1 -1
  93. package/dist/{ref-advancement-DUZqsue6.mjs.map → ref-advancement-CJY9zOv7.mjs.map} +1 -1
  94. package/dist/schemas-BL33A3i-.d.mts +193 -0
  95. package/dist/schemas-BL33A3i-.d.mts.map +1 -0
  96. package/dist/schemas-DJY2O09F.mjs +112 -0
  97. package/dist/schemas-DJY2O09F.mjs.map +1 -0
  98. package/dist/telemetry-CZkgkR_O.mjs +122 -0
  99. package/dist/telemetry-CZkgkR_O.mjs.map +1 -0
  100. package/dist/{terminal-ui-5Y6mrg93.d.mts → terminal-ui-BgLiAOYi.d.mts} +1 -1
  101. package/dist/{terminal-ui-5Y6mrg93.d.mts.map → terminal-ui-BgLiAOYi.d.mts.map} +1 -1
  102. package/dist/{types-Dt_SfqFm.d.mts → types-qV41eEXH.d.mts} +44 -31
  103. package/dist/types-qV41eEXH.d.mts.map +1 -0
  104. package/dist/{verify-DCA9Sldu.mjs → verify-IilvIk_E.mjs} +2 -2
  105. package/dist/{verify-DCA9Sldu.mjs.map → verify-IilvIk_E.mjs.map} +1 -1
  106. package/package.json +11 -12
  107. package/dist/client-KgJorIvG.mjs.map +0 -1
  108. package/dist/command-helpers-Bbw1GbwL.mjs.map +0 -1
  109. package/dist/commands/migration-list.mjs.map +0 -1
  110. package/dist/commands/migration-log.mjs.map +0 -1
  111. package/dist/commands/migration-status.mjs.map +0 -1
  112. package/dist/extension-pack-inputs-IDvjRCi3.mjs +0 -62
  113. package/dist/extension-pack-inputs-IDvjRCi3.mjs.map +0 -1
  114. package/dist/graph-render-rFAqZujX.mjs +0 -1081
  115. package/dist/graph-render-rFAqZujX.mjs.map +0 -1
  116. package/dist/init-Cv9UzWL5.mjs.map +0 -1
  117. package/dist/migration-check-BiBJoYYW.mjs +0 -341
  118. package/dist/migration-check-BiBJoYYW.mjs.map +0 -1
  119. package/dist/migration-graph-D7DVUElV.mjs +0 -1232
  120. package/dist/migration-graph-D7DVUElV.mjs.map +0 -1
  121. package/dist/migration-list-styler-BRwF4-gy.mjs +0 -399
  122. package/dist/migration-list-styler-BRwF4-gy.mjs.map +0 -1
  123. package/dist/migration-types-D2FW63pr.d.mts +0 -15
  124. package/dist/migration-types-D2FW63pr.d.mts.map +0 -1
  125. package/dist/migrations-Cv2jxNNK.mjs +0 -228
  126. package/dist/migrations-Cv2jxNNK.mjs.map +0 -1
  127. package/dist/types-Dt_SfqFm.d.mts.map +0 -1
@@ -1,15 +1,15 @@
1
- import { A as CliStructuredError } from "./command-helpers-Bbw1GbwL.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-fYXjz_in.mjs";
1
+ import { F as CliStructuredError } from "./command-helpers-esJGBD4W.mjs";
2
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-BO9VO43s.mjs";
3
3
  import { t as enrichContract } from "./contract-enrichment-a0V5Y_mL.mjs";
4
- import { n as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-DvZwdkrr.mjs";
4
+ import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-CpNVrBqW.mjs";
5
5
  import { emit } from "@prisma-next/emitter";
6
6
  import { ifDefined } from "@prisma-next/utils/defined";
7
7
  import { notOk, ok } from "@prisma-next/utils/result";
8
8
  import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaView } from "@prisma-next/framework-components/control";
9
- import { graphWalkStrategy, planMigration, requireHeadRef, verifyMigration } from "@prisma-next/migration-tools/aggregate";
9
+ import { castAs } from "@prisma-next/utils/casts";
10
+ import { buildSynthMigrationEdge, graphWalkStrategy, planMigration, requireHeadRef, verifyMigration } from "@prisma-next/migration-tools/aggregate";
10
11
  import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
11
12
  import { errorNoInvariantPath } from "@prisma-next/migration-tools/errors";
12
- import { castAs } from "@prisma-next/utils/casts";
13
13
  import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
14
14
  //#region src/control-api/errors.ts
15
15
  var ContractValidationError = class extends Error {
@@ -21,14 +21,27 @@ var ContractValidationError = class extends Error {
21
21
  }
22
22
  };
23
23
  //#endregion
24
- //#region src/control-api/operations/apply.ts
24
+ //#region src/control-api/operations/migration-helpers.ts
25
25
  /**
26
- * Span id emitted via `onProgress` for the apply phase. Stable
26
+ * Strips operation objects to their public shape (id, label, operationClass).
27
+ * Used at the API boundary to avoid leaking internal fields (precheck, execute, postcheck, etc.).
28
+ */
29
+ function stripOperations(operations) {
30
+ return operations.map((op) => ({
31
+ id: op.id,
32
+ label: op.label,
33
+ operationClass: op.operationClass
34
+ }));
35
+ }
36
+ //#endregion
37
+ //#region src/control-api/operations/run-migration.ts
38
+ /**
39
+ * Span id emitted via `onProgress` for the run phase. Stable
27
40
  * identifier consumed by the structured-output renderer and by tests.
28
41
  */
29
- const APPLY_SPAN_ID = "apply";
42
+ const RUN_SPAN_ID = "apply";
30
43
  /**
31
- * Runner-driving tail shared by every apply caller — `db init`,
44
+ * Runner-driving tail shared by every run caller — `db init`,
32
45
  * `db update`, and `migrate`. Consumes already-resolved per-space
33
46
  * plans (the planner-vs-replay distinction is owned by the caller) and
34
47
  * dispatches them to the runner in canonical order.
@@ -43,14 +56,14 @@ const APPLY_SPAN_ID = "apply";
43
56
  * so callers don't have to duplicate it; the `action` field on each
44
57
  * progress event is taken from the caller's `action` argument.
45
58
  */
46
- async function applyMigration(inputs) {
59
+ async function runMigration(inputs) {
47
60
  const { aggregate, perSpacePlans, applyOrder, driver, familyInstance, migrations, frameworkComponents, policy, action, onProgress } = inputs;
48
61
  const orderedResolutions = collectOrdered(applyOrder, perSpacePlans);
49
62
  const runner = migrations.createRunner(familyInstance);
50
63
  onProgress?.({
51
64
  action,
52
65
  kind: "spanStart",
53
- spanId: APPLY_SPAN_ID,
66
+ spanId: RUN_SPAN_ID,
54
67
  label: progressLabelForAction(action)
55
68
  });
56
69
  const perSpaceOptions = orderedResolutions.map((r) => ({
@@ -60,6 +73,7 @@ async function applyMigration(inputs) {
60
73
  destinationContract: r.entry.destinationContract,
61
74
  policy,
62
75
  frameworkComponents,
76
+ migrationEdges: r.entry.migrationEdges,
63
77
  strictVerification: false
64
78
  }));
65
79
  const runnerResult = await runner.execute({
@@ -70,7 +84,7 @@ async function applyMigration(inputs) {
70
84
  onProgress?.({
71
85
  action,
72
86
  kind: "spanEnd",
73
- spanId: APPLY_SPAN_ID,
87
+ spanId: RUN_SPAN_ID,
74
88
  outcome: "error"
75
89
  });
76
90
  return notOk({
@@ -86,7 +100,7 @@ async function applyMigration(inputs) {
86
100
  onProgress?.({
87
101
  action,
88
102
  kind: "spanEnd",
89
- spanId: APPLY_SPAN_ID,
103
+ spanId: RUN_SPAN_ID,
90
104
  outcome: "ok"
91
105
  });
92
106
  return ok({
@@ -105,7 +119,7 @@ async function applyMigration(inputs) {
105
119
  * advances as the last step of each space's transaction) and `false`
106
120
  * for plan-mode (no marker has been written yet).
107
121
  *
108
- * Exported alongside {@link applyMigration} so plan-mode callers can
122
+ * Exported alongside {@link runMigration} so plan-mode callers can
109
123
  * assemble the same per-space block without going through the runner.
110
124
  */
111
125
  function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
@@ -146,8 +160,8 @@ function collectOrdered(applyOrder, perSpace) {
146
160
  });
147
161
  }
148
162
  /**
149
- * Action-appropriate label for the `spanStart` event the apply
150
- * primitive emits. `applyMigration` is shared by `db init`, `db update`,
163
+ * Action-appropriate label for the `spanStart` event the run
164
+ * primitive emits. `runMigration` is shared by `db init`, `db update`,
151
165
  * and `migrate`; the span label tracks the user-visible action
152
166
  * so structured-progress output reads naturally for each surface.
153
167
  */
@@ -155,29 +169,16 @@ function progressLabelForAction(action) {
155
169
  switch (action) {
156
170
  case "dbInit": return "Initialising database across spaces";
157
171
  case "dbUpdate": return "Updating database across spaces";
158
- case "migrationApply": return "Applying migration plan across spaces";
172
+ case "migrate": return "Running migration plan across spaces";
159
173
  }
160
174
  }
161
175
  //#endregion
162
- //#region src/control-api/operations/migration-helpers.ts
163
- /**
164
- * Strips operation objects to their public shape (id, label, operationClass).
165
- * Used at the API boundary to avoid leaking internal fields (precheck, execute, postcheck, etc.).
166
- */
167
- function stripOperations(operations) {
168
- return operations.map((op) => ({
169
- id: op.id,
170
- label: op.label,
171
- operationClass: op.operationClass
172
- }));
173
- }
174
- //#endregion
175
- //#region src/control-api/operations/db-apply.ts
176
+ //#region src/control-api/operations/db-run.ts
176
177
  /**
177
- * Span IDs emitted via `onProgress` during the apply flow.
178
+ * Span IDs emitted via `onProgress` during the run flow.
178
179
  * Stable identifiers consumed by the structured-output renderer and by
179
180
  * tests asserting on span ids. The `apply` span itself is owned by
180
- * the {@link applyMigration} primitive — only the introspect / plan
181
+ * the {@link runMigration} primitive — only the introspect / plan
181
182
  * spans are emitted directly here.
182
183
  */
183
184
  const SPAN_IDS$1 = {
@@ -203,7 +204,7 @@ const SPAN_IDS$1 = {
203
204
  * transaction across every space; failure on any space rolls back
204
205
  * every space's writes.
205
206
  */
206
- async function executeApply(options) {
207
+ async function executeRun(options) {
207
208
  const { driver, familyInstance, contract, mode, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, policy, action, onProgress } = options;
208
209
  const loaded = await buildContractSpaceAggregate({
209
210
  targetId,
@@ -266,6 +267,7 @@ async function executeApply(options) {
266
267
  outcome: "ok"
267
268
  });
268
269
  const orderedResolutions = collectOrdered(planResult.value.applyOrder, planResult.value.perSpace);
270
+ const plannerWarnings = aggregatePlannerWarnings(orderedResolutions);
269
271
  const appResolution = orderedResolutions.find((r) => r.spaceId === aggregate.app.spaceId);
270
272
  if (!appResolution) throw new Error("Aggregate planner returned no plan for the app member — the planner is supposed to always emit one.");
271
273
  const appPlan = appResolution.entry.plan;
@@ -279,10 +281,11 @@ async function executeApply(options) {
279
281
  destination: appPlan.destination,
280
282
  preview,
281
283
  perSpace,
282
- summary
284
+ summary,
285
+ ...ifDefined("warnings", plannerWarnings)
283
286
  });
284
287
  }
285
- const applied = await applyMigration({
288
+ const applied = await runMigration({
286
289
  aggregate,
287
290
  perSpacePlans: planResult.value.perSpace,
288
291
  applyOrder: planResult.value.applyOrder,
@@ -297,7 +300,8 @@ async function executeApply(options) {
297
300
  if (!applied.ok) return buildRunnerFailure({
298
301
  summary: applied.failure.summary,
299
302
  ...ifDefined("why", applied.failure.why),
300
- meta: applied.failure.meta
303
+ meta: applied.failure.meta,
304
+ ...ifDefined("warnings", plannerWarnings)
301
305
  });
302
306
  const aggregateOps = applied.value.orderedResolutions.flatMap((r) => r.entry.displayOps);
303
307
  const summary = action === "dbInit" ? `Applied ${applied.value.totalOpsExecuted} operation(s) across ${applied.value.orderedResolutions.length} space(s), database signed` : applied.value.totalOpsExecuted === 0 ? `Database already matches contract across ${applied.value.orderedResolutions.length} space(s), signature updated` : `Applied ${applied.value.totalOpsExecuted} operation(s) across ${applied.value.orderedResolutions.length} space(s), signature updated`;
@@ -307,9 +311,14 @@ async function executeApply(options) {
307
311
  operationsPlanned: applied.value.totalOpsPlanned,
308
312
  operationsExecuted: applied.value.totalOpsExecuted,
309
313
  perSpace: applied.value.perSpace,
310
- summary
314
+ summary,
315
+ ...ifDefined("warnings", plannerWarnings)
311
316
  });
312
317
  }
318
+ function aggregatePlannerWarnings(orderedResolutions) {
319
+ const warnings = orderedResolutions.flatMap((r) => r.entry.warnings ?? []);
320
+ return warnings.length > 0 ? warnings : void 0;
321
+ }
313
322
  /**
314
323
  * Compare the live `_prisma_marker` rows against the aggregate's
315
324
  * declared members. Any marker row whose `space` is not a member of
@@ -383,7 +392,8 @@ function wrapPlanResult(args) {
383
392
  ...ifDefined("profileHash", args.destination.profileHash)
384
393
  },
385
394
  perSpace: args.perSpace,
386
- summary: args.summary
395
+ summary: args.summary,
396
+ ...ifDefined("warnings", args.warnings)
387
397
  });
388
398
  }
389
399
  function wrapApplyResult(args) {
@@ -403,7 +413,8 @@ function wrapApplyResult(args) {
403
413
  profileHash: args.destination.profileHash
404
414
  } : { storageHash: args.destination.storageHash },
405
415
  perSpace: args.perSpace,
406
- summary: args.summary
416
+ summary: args.summary,
417
+ ...ifDefined("warnings", args.warnings)
407
418
  });
408
419
  }
409
420
  function buildRunnerFailure(args) {
@@ -412,7 +423,8 @@ function buildRunnerFailure(args) {
412
423
  summary: args.summary,
413
424
  why: args.why,
414
425
  meta: args.meta,
415
- conflicts: void 0
426
+ conflicts: void 0,
427
+ ...ifDefined("warnings", args.warnings)
416
428
  });
417
429
  }
418
430
  //#endregion
@@ -425,7 +437,7 @@ function buildRunnerFailure(args) {
425
437
  * changes belong to `db update`.
426
438
  */
427
439
  async function executeDbInit(options) {
428
- return await executeApply({
440
+ return await executeRun({
429
441
  driver: options.driver,
430
442
  familyInstance: options.familyInstance,
431
443
  contract: options.contract,
@@ -474,7 +486,7 @@ async function executeDbUpdate(options) {
474
486
  const gate = await guardDestructiveChanges(sharedInputs);
475
487
  if (gate !== null) return gate;
476
488
  }
477
- return await executeApply({
489
+ return await executeRun({
478
490
  ...sharedInputs,
479
491
  mode: options.mode
480
492
  });
@@ -487,7 +499,7 @@ async function executeDbUpdate(options) {
487
499
  * run.
488
500
  */
489
501
  async function guardDestructiveChanges(sharedInputs) {
490
- const planResult = await executeApply({
502
+ const planResult = await executeRun({
491
503
  ...sharedInputs,
492
504
  mode: "plan"
493
505
  });
@@ -730,7 +742,7 @@ function mapMarkerCheckFailures(appSpaceId, section) {
730
742
  });
731
743
  }
732
744
  //#endregion
733
- //#region src/control-api/operations/migration-apply.ts
745
+ //#region src/control-api/operations/migrate.ts
734
746
  /**
735
747
  * Apply pending migrations across every contract space (app +
736
748
  * extensions). Replay-only: graph-walk against the on-disk graph for
@@ -745,14 +757,14 @@ function mapMarkerCheckFailures(appSpaceId, section) {
745
757
  * marker to `member.headRef.hash` (or `refHash` for the app
746
758
  * member when provided). Empty-graph members fail loudly — a
747
759
  * "never planned" space is a user-error condition for replay.
748
- * 4. Hand off to {@link applyMigration} (the runner-driving tail
760
+ * 4. Hand off to {@link runMigration} (the runner-driving tail
749
761
  * shared with `db init` / `db update`). Marker advancement is
750
762
  * inside the per-space transaction.
751
763
  *
752
764
  * Encodes the replay-only contract: every contract space must have an
753
765
  * authored migration graph on disk before this operation can advance it.
754
766
  */
755
- async function executeMigrationApply(options) {
767
+ async function executeMigrate(options) {
756
768
  const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, refHash, refInvariants, refName, onProgress } = options;
757
769
  const loaded = await buildContractSpaceAggregate({
758
770
  targetId,
@@ -840,7 +852,7 @@ async function executeMigrationApply(options) {
840
852
  summary: totalSpaces === 0 ? "Already up to date — no contract spaces are loaded" : totalSpaces === 1 ? "Already up to date" : `Already up to date across ${totalSpaces} space(s)`
841
853
  }));
842
854
  }
843
- const applied = await applyMigration({
855
+ const applied = await runMigration({
844
856
  aggregate,
845
857
  perSpacePlans,
846
858
  applyOrder,
@@ -854,7 +866,7 @@ async function executeMigrationApply(options) {
854
866
  "destructive",
855
867
  "data"
856
868
  ] },
857
- action: "migrationApply",
869
+ action: "migrate",
858
870
  ...ifDefined("onProgress", onProgress)
859
871
  });
860
872
  if (!applied.ok) return notOk({
@@ -876,7 +888,7 @@ async function executeMigrationApply(options) {
876
888
  };
877
889
  });
878
890
  const perSpaceAll = buildPerSpaceBreakdown(orderedAll, aggregate.app.spaceId, { includeMarkers: true });
879
- const summary = `Applied ${applied.value.orderedResolutions.reduce((sum, r) => sum + (r.entry.migrationEdges?.length ?? 0), 0)} migration(s) (${applied.value.totalOpsExecuted} operation(s)) across ${orderedAll.length} contract space(s)`;
891
+ const summary = `Applied ${applied.value.orderedResolutions.reduce((sum, r) => sum + r.entry.migrationEdges.length, 0)} migration(s) (${applied.value.totalOpsExecuted} operation(s)) across ${orderedAll.length} contract space(s)`;
880
892
  return ok(buildSuccess({
881
893
  aggregate,
882
894
  orderedResolutions: orderedAll,
@@ -906,7 +918,11 @@ function buildAtHeadResolution(args) {
906
918
  displayOps: [],
907
919
  destinationContract: member.contract(),
908
920
  strategy: "graph-walk",
909
- migrationEdges: []
921
+ migrationEdges: [buildSynthMigrationEdge({
922
+ currentMarkerStorageHash: liveMarker?.storageHash,
923
+ destinationStorageHash: targetHash,
924
+ operationCount: 0
925
+ })]
910
926
  };
911
927
  }
912
928
  function sumPlannedOps(applyOrder, perSpacePlans) {
@@ -922,7 +938,7 @@ function buildSuccess(args) {
922
938
  const appResolution = args.orderedResolutions.find((r) => r.spaceId === args.aggregate.app.spaceId);
923
939
  const appMarkerHash = appResolution?.entry.plan.destination.storageHash ?? requireHeadRef(args.aggregate.app).hash;
924
940
  const applied = args.orderedResolutions.flatMap((r) => {
925
- return (r.entry.migrationEdges ?? []).map((edge) => ({
941
+ return r.entry.migrationEdges.map((edge) => ({
926
942
  spaceId: r.spaceId,
927
943
  dirName: edge.dirName,
928
944
  migrationHash: edge.migrationHash,
@@ -1302,9 +1318,17 @@ var ControlClientImpl = class {
1302
1318
  const { driver, familyInstance } = await this.ensureConnected();
1303
1319
  return familyInstance.readAllMarkers({ driver });
1304
1320
  }
1305
- async migrationApply(options) {
1321
+ /** Reads the per-migration journal; omit `space` to return every space. */
1322
+ async readLedger(space) {
1323
+ const { driver, familyInstance } = await this.ensureConnected();
1324
+ return familyInstance.readLedger({
1325
+ driver,
1326
+ ...ifDefined("space", space)
1327
+ });
1328
+ }
1329
+ async migrate(options) {
1306
1330
  const { onProgress } = options;
1307
- await this.connectWithProgress(options.connection, "migrationApply", onProgress);
1331
+ await this.connectWithProgress(options.connection, "migrate", onProgress);
1308
1332
  const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1309
1333
  if (!hasMigrations(this.options.target)) throw new Error(`Target "${this.options.target.targetId}" does not support migrations`);
1310
1334
  let contract;
@@ -1313,7 +1337,7 @@ var ControlClientImpl = class {
1313
1337
  } catch (error) {
1314
1338
  throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1315
1339
  }
1316
- return executeMigrationApply({
1340
+ return executeMigrate({
1317
1341
  driver,
1318
1342
  familyInstance,
1319
1343
  contract,
@@ -1444,8 +1468,9 @@ var ControlClientImpl = class {
1444
1468
  });
1445
1469
  try {
1446
1470
  const enrichedIR = enrichContract(contractRaw, this.frameworkComponents ?? []);
1471
+ let deserializedContract;
1447
1472
  try {
1448
- this.familyInstance.deserializeContract(enrichedIR);
1473
+ deserializedContract = this.familyInstance.deserializeContract(enrichedIR);
1449
1474
  } catch (error) {
1450
1475
  onProgress?.({
1451
1476
  action: "emit",
@@ -1460,7 +1485,7 @@ var ControlClientImpl = class {
1460
1485
  meta: void 0
1461
1486
  });
1462
1487
  }
1463
- const result = await emit(enrichedIR, this.stack, this.options.family.emission, { serializeContract: (contract) => this.options.target.contractSerializer.serializeContract(contract) });
1488
+ const result = await emit(deserializedContract, this.stack, this.options.family.emission, { serializeContract: (contract) => this.options.target.contractSerializer.serializeContract(contract) });
1464
1489
  onProgress?.({
1465
1490
  action: "emit",
1466
1491
  kind: "spanEnd",
@@ -1493,4 +1518,4 @@ var ControlClientImpl = class {
1493
1518
  //#endregion
1494
1519
  export { ContractValidationError as a, executeDbInit as i, executeDbVerify as n, executeDbUpdate as r, createControlClient as t };
1495
1520
 
1496
- //# sourceMappingURL=client-KgJorIvG.mjs.map
1521
+ //# sourceMappingURL=client-DC-UlBLy.mjs.map