prisma-next 0.11.0 → 0.12.0-dev.10

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 (147) hide show
  1. package/dist/cli.mjs +259 -12
  2. package/dist/cli.mjs.map +1 -1
  3. package/dist/{client-oXO2WCPD.mjs → client-CDr4o07S.mjs} +88 -63
  4. package/dist/client-CDr4o07S.mjs.map +1 -0
  5. package/dist/{command-helpers-BSb0tRC8.mjs → command-helpers-Bbw1GbwL.mjs} +646 -46
  6. package/dist/command-helpers-Bbw1GbwL.mjs.map +1 -0
  7. package/dist/commands/contract-emit.d.mts.map +1 -1
  8. package/dist/commands/contract-emit.mjs +1 -1
  9. package/dist/commands/contract-infer.d.mts.map +1 -1
  10. package/dist/commands/contract-infer.mjs +1 -1
  11. package/dist/commands/db-init.d.mts.map +1 -1
  12. package/dist/commands/db-init.mjs +32 -7
  13. package/dist/commands/db-init.mjs.map +1 -1
  14. package/dist/commands/db-schema.d.mts.map +1 -1
  15. package/dist/commands/db-schema.mjs +3 -4
  16. package/dist/commands/db-schema.mjs.map +1 -1
  17. package/dist/commands/db-sign.d.mts.map +1 -1
  18. package/dist/commands/db-sign.mjs +12 -10
  19. package/dist/commands/db-sign.mjs.map +1 -1
  20. package/dist/commands/db-update.d.mts.map +1 -1
  21. package/dist/commands/db-update.mjs +41 -11
  22. package/dist/commands/db-update.mjs.map +1 -1
  23. package/dist/commands/db-verify.d.mts.map +1 -1
  24. package/dist/commands/db-verify.mjs +1 -1
  25. package/dist/commands/migrate.d.mts +6 -2
  26. package/dist/commands/migrate.d.mts.map +1 -1
  27. package/dist/commands/migrate.mjs +75 -40
  28. package/dist/commands/migrate.mjs.map +1 -1
  29. package/dist/commands/migration-check.d.mts +4 -3
  30. package/dist/commands/migration-check.d.mts.map +1 -1
  31. package/dist/commands/migration-check.mjs +1 -280
  32. package/dist/commands/migration-graph.d.mts +31 -2
  33. package/dist/commands/migration-graph.d.mts.map +1 -1
  34. package/dist/commands/migration-graph.mjs +2 -137
  35. package/dist/commands/migration-list.d.mts +64 -4
  36. package/dist/commands/migration-list.d.mts.map +1 -1
  37. package/dist/commands/migration-list.mjs +143 -56
  38. package/dist/commands/migration-list.mjs.map +1 -1
  39. package/dist/commands/migration-log.d.mts +10 -1
  40. package/dist/commands/migration-log.d.mts.map +1 -1
  41. package/dist/commands/migration-log.mjs +10 -15
  42. package/dist/commands/migration-log.mjs.map +1 -1
  43. package/dist/commands/migration-new.d.mts.map +1 -1
  44. package/dist/commands/migration-new.mjs +32 -38
  45. package/dist/commands/migration-new.mjs.map +1 -1
  46. package/dist/commands/migration-plan.d.mts +3 -2
  47. package/dist/commands/migration-plan.d.mts.map +1 -1
  48. package/dist/commands/migration-plan.mjs +1 -1
  49. package/dist/commands/migration-show.d.mts +4 -55
  50. package/dist/commands/migration-show.d.mts.map +1 -1
  51. package/dist/commands/migration-show.mjs +61 -153
  52. package/dist/commands/migration-show.mjs.map +1 -1
  53. package/dist/commands/migration-status.d.mts +12 -49
  54. package/dist/commands/migration-status.d.mts.map +1 -1
  55. package/dist/commands/migration-status.mjs +86 -82
  56. package/dist/commands/migration-status.mjs.map +1 -1
  57. package/dist/commands/ref.d.mts +1 -1
  58. package/dist/commands/ref.d.mts.map +1 -1
  59. package/dist/commands/ref.mjs +38 -10
  60. package/dist/commands/ref.mjs.map +1 -1
  61. package/dist/config-loader-B6sJjXTv.mjs.map +1 -1
  62. package/dist/config-loader.d.mts.map +1 -1
  63. package/dist/contract-at-errors-BxP-TOMl.mjs +42 -0
  64. package/dist/contract-at-errors-BxP-TOMl.mjs.map +1 -0
  65. package/dist/{contract-emit-bcrpT-wD.mjs → contract-emit-D-4jrNve.mjs} +25 -10
  66. package/dist/contract-emit-D-4jrNve.mjs.map +1 -0
  67. package/dist/{contract-emit-r4y8Zhf1.mjs → contract-emit-DxcGl4Uq.mjs} +19 -14
  68. package/dist/contract-emit-DxcGl4Uq.mjs.map +1 -0
  69. package/dist/{contract-enrichment-Dani0mMW.mjs → contract-enrichment-a0V5Y_mL.mjs} +4 -25
  70. package/dist/contract-enrichment-a0V5Y_mL.mjs.map +1 -0
  71. package/dist/{contract-infer-BmySmqVT.mjs → contract-infer-C8J1WMvO.mjs} +4 -5
  72. package/dist/{contract-infer-BmySmqVT.mjs.map → contract-infer-C8J1WMvO.mjs.map} +1 -1
  73. package/dist/contract-space-aggregate-loader-DvZwdkrr.mjs +247 -0
  74. package/dist/contract-space-aggregate-loader-DvZwdkrr.mjs.map +1 -0
  75. package/dist/{db-verify-BClPs3ph.mjs → db-verify-BeRHwN8M.mjs} +5 -7
  76. package/dist/{db-verify-BClPs3ph.mjs.map → db-verify-BeRHwN8M.mjs.map} +1 -1
  77. package/dist/exports/control-api.d.mts +3 -3
  78. package/dist/exports/control-api.d.mts.map +1 -1
  79. package/dist/exports/control-api.mjs +3 -3
  80. package/dist/exports/index.d.mts.map +1 -1
  81. package/dist/exports/index.mjs +1 -1
  82. package/dist/exports/index.mjs.map +1 -1
  83. package/dist/exports/init-output.d.mts.map +1 -1
  84. package/dist/exports/init-output.mjs +1 -1
  85. package/dist/extension-pack-inputs-IDvjRCi3.mjs +62 -0
  86. package/dist/extension-pack-inputs-IDvjRCi3.mjs.map +1 -0
  87. package/dist/{framework-components-65gOHkHB.mjs → framework-components-fYXjz_in.mjs} +2 -2
  88. package/dist/{framework-components-65gOHkHB.mjs.map → framework-components-fYXjz_in.mjs.map} +1 -1
  89. package/dist/global-flags-DEHjV8_s.d.mts +34 -0
  90. package/dist/global-flags-DEHjV8_s.d.mts.map +1 -0
  91. package/dist/{graph-render-DJVv0_uf.mjs → graph-render-rFAqZujX.mjs} +2 -2
  92. package/dist/{graph-render-DJVv0_uf.mjs.map → graph-render-rFAqZujX.mjs.map} +1 -1
  93. package/dist/{init-BCJZPWE1.mjs → init-Cv9UzWL5.mjs} +20 -269
  94. package/dist/init-Cv9UzWL5.mjs.map +1 -0
  95. package/dist/{inspect-live-schema-DSRbFoOL.mjs → inspect-live-schema-BlKR2Zln.mjs} +4 -5
  96. package/dist/{inspect-live-schema-DSRbFoOL.mjs.map → inspect-live-schema-BlKR2Zln.mjs.map} +1 -1
  97. package/dist/migration-check-BiBJoYYW.mjs +341 -0
  98. package/dist/migration-check-BiBJoYYW.mjs.map +1 -0
  99. package/dist/migration-cli.d.mts.map +1 -1
  100. package/dist/migration-cli.mjs +4 -4
  101. package/dist/migration-cli.mjs.map +1 -1
  102. package/dist/{migration-command-scaffold-Bzd9La5c.mjs → migration-command-scaffold-BAGUiGOK.mjs} +4 -5
  103. package/dist/{migration-command-scaffold-Bzd9La5c.mjs.map → migration-command-scaffold-BAGUiGOK.mjs.map} +1 -1
  104. package/dist/migration-graph-C9WC-7eO.mjs +1478 -0
  105. package/dist/migration-graph-C9WC-7eO.mjs.map +1 -0
  106. package/dist/migration-list-styler-BRwF4-gy.mjs +399 -0
  107. package/dist/migration-list-styler-BRwF4-gy.mjs.map +1 -0
  108. package/dist/{migration-plan-CFwqw3Gk.mjs → migration-plan-9DJ7q7_z.mjs} +372 -133
  109. package/dist/migration-plan-9DJ7q7_z.mjs.map +1 -0
  110. package/dist/{migration-types-BXWvz12q.d.mts → migration-types-D2FW63pr.d.mts} +1 -1
  111. package/dist/{migration-types-BXWvz12q.d.mts.map → migration-types-D2FW63pr.d.mts.map} +1 -1
  112. package/dist/{migrations-CwZMa1Ck.mjs → migrations-Cv2jxNNK.mjs} +12 -13
  113. package/dist/migrations-Cv2jxNNK.mjs.map +1 -0
  114. package/dist/{output-BlsrGMEF.mjs → output-B60Gw5fu.mjs} +1 -1
  115. package/dist/{output-BlsrGMEF.mjs.map → output-B60Gw5fu.mjs.map} +1 -1
  116. package/dist/{progress-adapter-DFfvZcYL.mjs → progress-adapter-C644QK8l.mjs} +1 -1
  117. package/dist/{progress-adapter-DFfvZcYL.mjs.map → progress-adapter-C644QK8l.mjs.map} +1 -1
  118. package/dist/ref-advancement-DUZqsue6.mjs +50 -0
  119. package/dist/ref-advancement-DUZqsue6.mjs.map +1 -0
  120. package/dist/terminal-ui-5Y6mrg93.d.mts +133 -0
  121. package/dist/terminal-ui-5Y6mrg93.d.mts.map +1 -0
  122. package/dist/{types--CqjMdk0.d.mts → types-CeC5ec2Y.d.mts} +35 -29
  123. package/dist/types-CeC5ec2Y.d.mts.map +1 -0
  124. package/dist/{verify-Bom75OYI.mjs → verify-DCA9Sldu.mjs} +2 -2
  125. package/dist/{verify-Bom75OYI.mjs.map → verify-DCA9Sldu.mjs.map} +1 -1
  126. package/package.json +28 -17
  127. package/dist/cli-errors-Czmx92Zy.d.mts +0 -3
  128. package/dist/cli-errors-Djtz98Vm.mjs +0 -71
  129. package/dist/cli-errors-Djtz98Vm.mjs.map +0 -1
  130. package/dist/client-oXO2WCPD.mjs.map +0 -1
  131. package/dist/command-helpers-BSb0tRC8.mjs.map +0 -1
  132. package/dist/commands/migration-check.mjs.map +0 -1
  133. package/dist/commands/migration-graph.mjs.map +0 -1
  134. package/dist/contract-emit-bcrpT-wD.mjs.map +0 -1
  135. package/dist/contract-emit-r4y8Zhf1.mjs.map +0 -1
  136. package/dist/contract-enrichment-Dani0mMW.mjs.map +0 -1
  137. package/dist/contract-space-aggregate-loader-BmNQwlws.mjs +0 -160
  138. package/dist/contract-space-aggregate-loader-BmNQwlws.mjs.map +0 -1
  139. package/dist/global-flags-CdE7M0d9.d.mts +0 -15
  140. package/dist/global-flags-CdE7M0d9.d.mts.map +0 -1
  141. package/dist/init-BCJZPWE1.mjs.map +0 -1
  142. package/dist/migration-plan-CFwqw3Gk.mjs.map +0 -1
  143. package/dist/migrations-CwZMa1Ck.mjs.map +0 -1
  144. package/dist/rolldown-runtime-twds-ZHy.mjs +0 -14
  145. package/dist/terminal-ui-BiB_8KNo.mjs +0 -379
  146. package/dist/terminal-ui-BiB_8KNo.mjs.map +0 -1
  147. package/dist/types--CqjMdk0.d.mts.map +0 -1
@@ -1,15 +1,16 @@
1
- import { h as errorRunnerFailed, t as CliStructuredError } from "./cli-errors-Djtz98Vm.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-65gOHkHB.mjs";
3
- import { t as enrichContract } from "./contract-enrichment-Dani0mMW.mjs";
4
- import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-BmNQwlws.mjs";
1
+ import { A as CliStructuredError } from "./command-helpers-Bbw1GbwL.mjs";
2
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-fYXjz_in.mjs";
3
+ import { t as enrichContract } from "./contract-enrichment-a0V5Y_mL.mjs";
4
+ import { n as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-DvZwdkrr.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
- import { APP_SPACE_ID, createControlStack, hasMigrations, hasMultiSpaceRunner, hasOperationPreview, hasPslContractInfer, hasSchemaView } from "@prisma-next/framework-components/control";
9
- import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
10
- import { graphWalkStrategy, planAggregate, verifyAggregate } from "@prisma-next/migration-tools/aggregate";
8
+ import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaView } from "@prisma-next/framework-components/control";
9
+ import { buildSynthMigrationEdge, graphWalkStrategy, planMigration, requireHeadRef, verifyMigration } from "@prisma-next/migration-tools/aggregate";
11
10
  import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
12
11
  import { errorNoInvariantPath } from "@prisma-next/migration-tools/errors";
12
+ import { castAs } from "@prisma-next/utils/casts";
13
+ import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
13
14
  //#region src/control-api/errors.ts
14
15
  var ContractValidationError = class extends Error {
15
16
  cause;
@@ -20,33 +21,32 @@ var ContractValidationError = class extends Error {
20
21
  }
21
22
  };
22
23
  //#endregion
23
- //#region src/control-api/operations/apply-aggregate.ts
24
+ //#region src/control-api/operations/apply.ts
24
25
  /**
25
26
  * Span id emitted via `onProgress` for the apply phase. Stable
26
27
  * identifier consumed by the structured-output renderer and by tests.
27
28
  */
28
29
  const APPLY_SPAN_ID = "apply";
29
30
  /**
30
- * Runner-driving tail shared by every aggregate apply caller — `db init`,
31
+ * Runner-driving tail shared by every apply caller — `db init`,
31
32
  * `db update`, and `migrate`. Consumes already-resolved per-space
32
33
  * plans (the planner-vs-replay distinction is owned by the caller) and
33
- * dispatches them to the multi-space runner in canonical order.
34
+ * dispatches them to the runner in canonical order.
34
35
  *
35
36
  * Marker advancement is part of the runner's per-space transaction
36
37
  * (the SQL family runner writes the marker as the last step of each
37
38
  * space's transaction), so this primitive does not advance markers
38
- * separately — by the time `executeAcrossSpaces` returns ok, every
39
+ * separately — by the time `execute` returns ok, every
39
40
  * space's marker has been advanced to its plan's destination.
40
41
  *
41
42
  * Span emission (`spanStart 'apply'` / `spanEnd 'apply'`) is owned here
42
43
  * so callers don't have to duplicate it; the `action` field on each
43
44
  * progress event is taken from the caller's `action` argument.
44
45
  */
45
- async function applyAggregate(inputs) {
46
+ async function applyMigration(inputs) {
46
47
  const { aggregate, perSpacePlans, applyOrder, driver, familyInstance, migrations, frameworkComponents, policy, action, onProgress } = inputs;
47
48
  const orderedResolutions = collectOrdered(applyOrder, perSpacePlans);
48
49
  const runner = migrations.createRunner(familyInstance);
49
- if (!hasMultiSpaceRunner(runner)) throw errorRunnerFailed(`Runner for target "${aggregate.targetId}" does not implement \`executeAcrossSpaces\``, { why: `${labelForAction(action)} requires multi-space-capable runners (today: every SQL family runner).` });
50
50
  onProgress?.({
51
51
  action,
52
52
  kind: "spanStart",
@@ -60,9 +60,10 @@ async function applyAggregate(inputs) {
60
60
  destinationContract: r.entry.destinationContract,
61
61
  policy,
62
62
  frameworkComponents,
63
+ migrationEdges: r.entry.migrationEdges,
63
64
  strictVerification: false
64
65
  }));
65
- const runnerResult = await runner.executeAcrossSpaces({
66
+ const runnerResult = await runner.execute({
66
67
  driver,
67
68
  perSpaceOptions
68
69
  });
@@ -98,14 +99,14 @@ async function applyAggregate(inputs) {
98
99
  }
99
100
  /**
100
101
  * Project the planner's per-space resolutions into the
101
- * `AggregatePerSpaceExecutionEntry[]` shape the CLI surfaces.
102
+ * `PerSpaceExecutionEntry[]` shape the CLI surfaces.
102
103
  *
103
104
  * `includeMarkers` is `true` for apply-mode (each space's marker is
104
105
  * the `destination.storageHash` of its plan, which the runner
105
106
  * advances as the last step of each space's transaction) and `false`
106
107
  * for plan-mode (no marker has been written yet).
107
108
  *
108
- * Exported alongside {@link applyAggregate} so plan-mode callers can
109
+ * Exported alongside {@link applyMigration} so plan-mode callers can
109
110
  * assemble the same per-space block without going through the runner.
110
111
  */
111
112
  function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
@@ -138,7 +139,7 @@ function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
138
139
  function collectOrdered(applyOrder, perSpace) {
139
140
  return applyOrder.map((spaceId) => {
140
141
  const entry = perSpace.get(spaceId);
141
- if (!entry) throw new Error(`Aggregate planner output missing per-space plan for "${spaceId}"`);
142
+ if (!entry) throw new Error(`planner output missing per-space plan for "${spaceId}"`);
142
143
  return {
143
144
  spaceId,
144
145
  entry
@@ -147,7 +148,7 @@ function collectOrdered(applyOrder, perSpace) {
147
148
  }
148
149
  /**
149
150
  * Action-appropriate label for the `spanStart` event the apply
150
- * primitive emits. `applyAggregate` is shared by `db init`, `db update`,
151
+ * primitive emits. `applyMigration` is shared by `db init`, `db update`,
151
152
  * and `migrate`; the span label tracks the user-visible action
152
153
  * so structured-progress output reads naturally for each surface.
153
154
  */
@@ -158,13 +159,6 @@ function progressLabelForAction(action) {
158
159
  case "migrationApply": return "Applying migration plan across spaces";
159
160
  }
160
161
  }
161
- function labelForAction(action) {
162
- switch (action) {
163
- case "dbInit": return "db init";
164
- case "dbUpdate": return "db update";
165
- case "migrationApply": return "migrate";
166
- }
167
- }
168
162
  //#endregion
169
163
  //#region src/control-api/operations/migration-helpers.ts
170
164
  /**
@@ -179,12 +173,12 @@ function stripOperations(operations) {
179
173
  }));
180
174
  }
181
175
  //#endregion
182
- //#region src/control-api/operations/db-apply-aggregate.ts
176
+ //#region src/control-api/operations/db-apply.ts
183
177
  /**
184
- * Span IDs emitted via `onProgress` during the aggregate apply flow.
178
+ * Span IDs emitted via `onProgress` during the apply flow.
185
179
  * Stable identifiers consumed by the structured-output renderer and by
186
180
  * tests asserting on span ids. The `apply` span itself is owned by
187
- * the {@link applyAggregate} primitive — only the introspect / plan
181
+ * the {@link applyMigration} primitive — only the introspect / plan
188
182
  * spans are emitted directly here.
189
183
  */
190
184
  const SPAN_IDS$1 = {
@@ -201,16 +195,16 @@ const SPAN_IDS$1 = {
201
195
  * integrity violation short-circuits with a structured error.
202
196
  * 2. **Read DB state**: marker rows (`familyInstance.readAllMarkers`)
203
197
  * + introspected schema (`familyInstance.introspect`).
204
- * 3. **Plan**: {@link planAggregate} chooses graph-walk vs synth per
198
+ * 3. **Plan**: {@link planMigration} chooses graph-walk vs synth per
205
199
  * member according to `callerPolicy.ignoreGraphFor`. The app member
206
200
  * is forced through synth (today's daily-driver behaviour); every
207
201
  * extension member walks its on-disk graph.
208
202
  * 4. **Apply** (when `mode === 'apply'`): every per-space `MigrationPlan`
209
- * feeds into the runner's `executeAcrossSpaces` — one outer
203
+ * feeds into the runner's `execute` — one outer
210
204
  * transaction across every space; failure on any space rolls back
211
205
  * every space's writes.
212
206
  */
213
- async function executeAggregateApply(options) {
207
+ async function executeApply(options) {
214
208
  const { driver, familyInstance, contract, mode, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, policy, action, onProgress } = options;
215
209
  const loaded = await buildContractSpaceAggregate({
216
210
  targetId,
@@ -245,7 +239,7 @@ async function executeAggregateApply(options) {
245
239
  spanId: SPAN_IDS$1.plan,
246
240
  label: "Planning migration"
247
241
  });
248
- const planResult = await planAggregate({
242
+ const planResult = await planMigration({
249
243
  aggregate,
250
244
  currentDBState: {
251
245
  markersBySpaceId: markerRows,
@@ -289,7 +283,7 @@ async function executeAggregateApply(options) {
289
283
  summary
290
284
  });
291
285
  }
292
- const applied = await applyAggregate({
286
+ const applied = await applyMigration({
293
287
  aggregate,
294
288
  perSpacePlans: planResult.value.perSpace,
295
289
  applyOrder: planResult.value.applyOrder,
@@ -432,7 +426,7 @@ function buildRunnerFailure(args) {
432
426
  * changes belong to `db update`.
433
427
  */
434
428
  async function executeDbInit(options) {
435
- return await executeAggregateApply({
429
+ return await executeApply({
436
430
  driver: options.driver,
437
431
  familyInstance: options.familyInstance,
438
432
  contract: options.contract,
@@ -481,7 +475,7 @@ async function executeDbUpdate(options) {
481
475
  const gate = await guardDestructiveChanges(sharedInputs);
482
476
  if (gate !== null) return gate;
483
477
  }
484
- return await executeAggregateApply({
478
+ return await executeApply({
485
479
  ...sharedInputs,
486
480
  mode: options.mode
487
481
  });
@@ -494,7 +488,7 @@ async function executeDbUpdate(options) {
494
488
  * run.
495
489
  */
496
490
  async function guardDestructiveChanges(sharedInputs) {
497
- const planResult = await executeAggregateApply({
491
+ const planResult = await executeApply({
498
492
  ...sharedInputs,
499
493
  mode: "plan"
500
494
  });
@@ -533,7 +527,7 @@ const SPAN_IDS = {
533
527
  * structured CLI error.
534
528
  * 2. **Read DB state**: marker rows + (when `skipSchema` is `false`)
535
529
  * schema introspection.
536
- * 3. **Verify**: {@link verifyAggregate} returns per-space
530
+ * 3. **Verify**: {@link verifyMigration} returns per-space
537
531
  * `markerCheck` + per-space pre-projected `schemaCheck` (closes F23).
538
532
  * Marker mismatches map to `CliStructuredError` (code `5002`) so
539
533
  * callers (CLI command) can render and exit. Schema results are
@@ -552,7 +546,7 @@ async function executeDbVerify(options) {
552
546
  });
553
547
  emitVerifySpan(onProgress, "spanStart");
554
548
  return finaliseVerifyResult({
555
- verifyResult: verifyAggregate({
549
+ verifyResult: verifyMigration({
556
550
  aggregate,
557
551
  markersBySpaceId,
558
552
  schemaIntrospection,
@@ -611,7 +605,7 @@ function createPerMemberVerifier(options) {
611
605
  return (projectedSchema, member, verifyMode) => {
612
606
  if (skipSchema) return buildSkippedSchemaResult(member);
613
607
  return familyInstance.verifySchema({
614
- contract: member.contract,
608
+ contract: member.contract(),
615
609
  schema: projectedSchema,
616
610
  strict: verifyMode === "strict",
617
611
  frameworkComponents
@@ -636,7 +630,7 @@ function emitVerifySpan(onProgress, kind) {
636
630
  });
637
631
  }
638
632
  /**
639
- * Map an {@link AggregateVerifierOutput} to the operation's
633
+ * Map an {@link VerifierOutput} to the operation's
640
634
  * {@link ExecuteDbVerifyResult}, applying the `skipMarker` policy used
641
635
  * by the CLI's `--schema-only` mode.
642
636
  */
@@ -664,15 +658,17 @@ function finaliseVerifyResult(args) {
664
658
  });
665
659
  }
666
660
  function buildSkippedSchemaResult(member) {
667
- const profileHash = member.contract.profileHash;
661
+ const contract = member.contract();
662
+ const headRef = requireHeadRef(member);
663
+ const profileHash = castAs(contract).profileHash;
668
664
  return {
669
665
  ok: true,
670
666
  summary: "Schema verification skipped",
671
667
  contract: {
672
- storageHash: member.headRef.hash,
668
+ storageHash: headRef.hash,
673
669
  ...profileHash ? { profileHash } : {}
674
670
  },
675
- target: { expected: member.contract.target },
671
+ target: { expected: contract.target },
676
672
  schema: {
677
673
  issues: [],
678
674
  root: {
@@ -750,7 +746,7 @@ function mapMarkerCheckFailures(appSpaceId, section) {
750
746
  * marker to `member.headRef.hash` (or `refHash` for the app
751
747
  * member when provided). Empty-graph members fail loudly — a
752
748
  * "never planned" space is a user-error condition for replay.
753
- * 4. Hand off to {@link applyAggregate} (the runner-driving tail
749
+ * 4. Hand off to {@link applyMigration} (the runner-driving tail
754
750
  * shared with `db init` / `db update`). Marker advancement is
755
751
  * inside the per-space transaction.
756
752
  *
@@ -758,14 +754,13 @@ function mapMarkerCheckFailures(appSpaceId, section) {
758
754
  * authored migration graph on disk before this operation can advance it.
759
755
  */
760
756
  async function executeMigrationApply(options) {
761
- const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, appMigrationPackages, refHash, refInvariants, refName, onProgress } = options;
757
+ const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, refHash, refInvariants, refName, onProgress } = options;
762
758
  const loaded = await buildContractSpaceAggregate({
763
759
  targetId,
764
760
  migrationsDir,
765
761
  appContract: contract,
766
762
  extensionPacks,
767
- deserializeContract: (json) => familyInstance.deserializeContract(json),
768
- appMigrationPackages
763
+ deserializeContract: (json) => familyInstance.deserializeContract(json)
769
764
  });
770
765
  if (!loaded.ok) throw loaded.failure;
771
766
  const aggregate = loaded.value;
@@ -775,9 +770,10 @@ async function executeMigrationApply(options) {
775
770
  const atHeadResolutions = /* @__PURE__ */ new Map();
776
771
  for (const member of allMembers) {
777
772
  const isAppMember = member.spaceId === aggregate.app.spaceId;
778
- const targetHash = isAppMember && refHash !== void 0 ? refHash : member.headRef.hash;
773
+ const headRef = requireHeadRef(member);
774
+ const targetHash = isAppMember && refHash !== void 0 ? refHash : headRef.hash;
779
775
  const liveMarker = markerRows.get(member.spaceId) ?? null;
780
- if (member.migrations.graph.nodes.size === 0) {
776
+ if (member.graph().nodes.size === 0) {
781
777
  const liveHash = liveMarker?.storageHash;
782
778
  if (targetHash === liveHash || liveHash === void 0 && targetHash === EMPTY_CONTRACT_HASH) {
783
779
  atHeadResolutions.set(member.spaceId, buildAtHeadResolution({
@@ -790,8 +786,8 @@ async function executeMigrationApply(options) {
790
786
  }
791
787
  return notOk(buildNeverPlannedFailure(member.spaceId, targetHash));
792
788
  }
793
- const targetInvariants = isAppMember && refHash !== void 0 && refInvariants !== void 0 ? refInvariants : member.headRef.invariants;
794
- const targetMember = targetHash === member.headRef.hash && targetInvariants === member.headRef.invariants ? member : {
789
+ const targetInvariants = isAppMember && refHash !== void 0 && refInvariants !== void 0 ? refInvariants : headRef.invariants;
790
+ const targetMember = targetHash === headRef.hash && targetInvariants === headRef.invariants ? member : {
795
791
  ...member,
796
792
  headRef: {
797
793
  hash: targetHash,
@@ -807,7 +803,7 @@ async function executeMigrationApply(options) {
807
803
  if (walked.kind === "unreachable") return notOk(buildPathNotFoundFailure(member.spaceId, liveMarker, targetHash));
808
804
  if (walked.kind === "unsatisfiable") {
809
805
  const fromHash = liveMarker?.storageHash ?? EMPTY_CONTRACT_HASH;
810
- const structural = findPathWithDecision(targetMember.migrations.graph, fromHash, targetHash, { required: /* @__PURE__ */ new Set() });
806
+ const structural = findPathWithDecision(targetMember.graph(), fromHash, targetHash, { required: /* @__PURE__ */ new Set() });
811
807
  const structuralPath = structural.kind === "ok" ? structural.decision.selectedPath.map((edge) => ({
812
808
  dirName: edge.dirName,
813
809
  migrationHash: edge.migrationHash,
@@ -845,7 +841,7 @@ async function executeMigrationApply(options) {
845
841
  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)`
846
842
  }));
847
843
  }
848
- const applied = await applyAggregate({
844
+ const applied = await applyMigration({
849
845
  aggregate,
850
846
  perSpacePlans,
851
847
  applyOrder,
@@ -881,7 +877,7 @@ async function executeMigrationApply(options) {
881
877
  };
882
878
  });
883
879
  const perSpaceAll = buildPerSpaceBreakdown(orderedAll, aggregate.app.spaceId, { includeMarkers: true });
884
- 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)`;
880
+ 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)`;
885
881
  return ok(buildSuccess({
886
882
  aggregate,
887
883
  orderedResolutions: orderedAll,
@@ -891,7 +887,7 @@ async function executeMigrationApply(options) {
891
887
  }));
892
888
  }
893
889
  /**
894
- * Build a zero-op {@link AggregatePerSpacePlan} for an empty-graph
890
+ * Build a zero-op {@link PerSpacePlan} for an empty-graph
895
891
  * member whose live marker already matches the target. Lets the apply
896
892
  * pipeline thread the member through `perSpacePlans` -> `applyOrder`
897
893
  * -> the success envelope's `perSpace[]` block so the result reflects
@@ -909,9 +905,13 @@ function buildAtHeadResolution(args) {
909
905
  providedInvariants: []
910
906
  },
911
907
  displayOps: [],
912
- destinationContract: member.contract,
908
+ destinationContract: member.contract(),
913
909
  strategy: "graph-walk",
914
- migrationEdges: []
910
+ migrationEdges: [buildSynthMigrationEdge({
911
+ currentMarkerStorageHash: liveMarker?.storageHash,
912
+ destinationStorageHash: targetHash,
913
+ operationCount: 0
914
+ })]
915
915
  };
916
916
  }
917
917
  function sumPlannedOps(applyOrder, perSpacePlans) {
@@ -925,9 +925,9 @@ function sumPlannedOps(applyOrder, perSpacePlans) {
925
925
  }
926
926
  function buildSuccess(args) {
927
927
  const appResolution = args.orderedResolutions.find((r) => r.spaceId === args.aggregate.app.spaceId);
928
- const appMarkerHash = appResolution?.entry.plan.destination.storageHash ?? args.aggregate.app.headRef.hash;
928
+ const appMarkerHash = appResolution?.entry.plan.destination.storageHash ?? requireHeadRef(args.aggregate.app).hash;
929
929
  const applied = args.orderedResolutions.flatMap((r) => {
930
- return (r.entry.migrationEdges ?? []).map((edge) => ({
930
+ return r.entry.migrationEdges.map((edge) => ({
931
931
  spaceId: r.spaceId,
932
932
  dirName: edge.dirName,
933
933
  migrationHash: edge.migrationHash,
@@ -962,11 +962,19 @@ function buildSuccess(args) {
962
962
  ...pathDecision !== void 0 ? { pathDecision } : {}
963
963
  };
964
964
  }
965
+ /**
966
+ * Build the `neverPlanned` failure raised when a contract space has no on-disk
967
+ * migration graph but migrate was asked to reach a target hash. The `why`
968
+ * states only the condition; the recovery sequence is composed by
969
+ * `errorPathUnreachable`'s `fix`.
970
+ *
971
+ * @internal Exported for testing only.
972
+ */
965
973
  function buildNeverPlannedFailure(spaceId, targetHash) {
966
974
  return {
967
975
  code: "MIGRATION_PATH_NOT_FOUND",
968
976
  summary: `No on-disk migrations for contract space "${spaceId}"`,
969
- why: `migrate is replay-only: every contract space must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`migrations/${spaceId}/\` but its head ref targets "${targetHash}". Run \`prisma-next migration plan\` first to materialise the path.`,
977
+ why: `migrate is replay-only: every contract space must have an authored migration graph on disk. Space "${spaceId}" has no migrations under \`migrations/${spaceId}/\` but its head ref targets "${targetHash}".`,
970
978
  meta: {
971
979
  spaceId,
972
980
  target: targetHash,
@@ -974,12 +982,22 @@ function buildNeverPlannedFailure(spaceId, targetHash) {
974
982
  }
975
983
  };
976
984
  }
985
+ /**
986
+ * Build the `pathUnreachable` failure raised when an emitted contract has no
987
+ * on-disk migration edge from the current marker to the target. The `why`
988
+ * states only the condition (no edge between the two named states, and migrate
989
+ * replays edges rather than inventing them); the recovery sequence — plan the
990
+ * edge, then re-apply — is composed by `errorPathUnreachable`'s `fix`, so the
991
+ * two read as one non-redundant plan-then-apply story.
992
+ *
993
+ * @internal Exported for testing only.
994
+ */
977
995
  function buildPathNotFoundFailure(spaceId, marker, targetHash) {
978
996
  const fromHash = marker?.storageHash ?? "<empty>";
979
997
  return {
980
998
  code: "MIGRATION_PATH_NOT_FOUND",
981
999
  summary: spaceId === "app" ? "Current contract has no planned migration path" : `Current contract has no planned migration path for contract space "${spaceId}"`,
982
- why: `Cannot reach target "${targetHash}" from current marker "${fromHash}" in space "${spaceId}". The on-disk migration graph for this space does not connect the two states. Run \`prisma-next migration plan\` to materialise the path.`,
1000
+ why: `No migration edge connects the current state "${fromHash}" to the target "${targetHash}" in contract space "${spaceId}". The on-disk migration graph does not join the two, and migrate replays existing edges it never invents one.`,
983
1001
  meta: {
984
1002
  spaceId,
985
1003
  fromHash,
@@ -1289,6 +1307,14 @@ var ControlClientImpl = class {
1289
1307
  const { driver, familyInstance } = await this.ensureConnected();
1290
1308
  return familyInstance.readAllMarkers({ driver });
1291
1309
  }
1310
+ /** Reads the per-migration journal for `space` (defaults to the app contract space). */
1311
+ async readLedger(space = APP_SPACE_ID) {
1312
+ const { driver, familyInstance } = await this.ensureConnected();
1313
+ return familyInstance.readLedger({
1314
+ driver,
1315
+ space
1316
+ });
1317
+ }
1292
1318
  async migrationApply(options) {
1293
1319
  const { onProgress } = options;
1294
1320
  await this.connectWithProgress(options.connection, "migrationApply", onProgress);
@@ -1309,7 +1335,6 @@ var ControlClientImpl = class {
1309
1335
  migrationsDir: options.migrationsDir,
1310
1336
  extensionPacks: this.options.extensionPacks ?? [],
1311
1337
  targetId: this.options.target.targetId,
1312
- appMigrationPackages: options.appMigrationPackages,
1313
1338
  ...ifDefined("refHash", options.refHash),
1314
1339
  ...ifDefined("refInvariants", options.refInvariants),
1315
1340
  ...ifDefined("refName", options.refName),
@@ -1481,4 +1506,4 @@ var ControlClientImpl = class {
1481
1506
  //#endregion
1482
1507
  export { ContractValidationError as a, executeDbInit as i, executeDbVerify as n, executeDbUpdate as r, createControlClient as t };
1483
1508
 
1484
- //# sourceMappingURL=client-oXO2WCPD.mjs.map
1509
+ //# sourceMappingURL=client-CDr4o07S.mjs.map