@prisma-next/cli 0.16.0-dev.3 → 0.16.0-dev.31

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 (173) hide show
  1. package/README.md +44 -45
  2. package/dist/cli.mjs +13 -13
  3. package/dist/{client-KuBQftxz.mjs → client-B1UjQc_x.mjs} +50 -58
  4. package/dist/client-B1UjQc_x.mjs.map +1 -0
  5. package/dist/{command-helpers-Cpq44aVa.mjs → command-helpers-D-jBl0Qt.mjs} +16 -8
  6. package/dist/command-helpers-D-jBl0Qt.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.d.mts.map +1 -1
  10. package/dist/commands/db-init.mjs +8 -6
  11. package/dist/commands/db-init.mjs.map +1 -1
  12. package/dist/commands/db-schema.mjs +3 -3
  13. package/dist/commands/db-sign.d.mts.map +1 -1
  14. package/dist/commands/db-sign.mjs +11 -12
  15. package/dist/commands/db-sign.mjs.map +1 -1
  16. package/dist/commands/db-update.d.mts.map +1 -1
  17. package/dist/commands/db-update.mjs +14 -15
  18. package/dist/commands/db-update.mjs.map +1 -1
  19. package/dist/commands/db-verify.mjs +1 -1
  20. package/dist/commands/migrate.d.mts +1 -1
  21. package/dist/commands/migrate.d.mts.map +1 -1
  22. package/dist/commands/migrate.mjs +13 -13
  23. package/dist/commands/migrate.mjs.map +1 -1
  24. package/dist/commands/migration-check.d.mts +4 -2
  25. package/dist/commands/migration-check.d.mts.map +1 -1
  26. package/dist/commands/migration-check.mjs +1 -1
  27. package/dist/commands/migration-graph.d.mts +1 -1
  28. package/dist/commands/migration-graph.mjs +4 -4
  29. package/dist/commands/migration-list.d.mts +1 -1
  30. package/dist/commands/migration-list.d.mts.map +1 -1
  31. package/dist/commands/migration-list.mjs +1 -1
  32. package/dist/commands/migration-log.d.mts +1 -1
  33. package/dist/commands/migration-log.mjs +1 -1
  34. package/dist/commands/migration-new.d.mts.map +1 -1
  35. package/dist/commands/migration-new.mjs +16 -40
  36. package/dist/commands/migration-new.mjs.map +1 -1
  37. package/dist/commands/migration-plan.d.mts +3 -4
  38. package/dist/commands/migration-plan.d.mts.map +1 -1
  39. package/dist/commands/migration-plan.mjs +1 -1
  40. package/dist/commands/migration-show.mjs +5 -5
  41. package/dist/commands/migration-show.mjs.map +1 -1
  42. package/dist/commands/migration-status.d.mts +1 -1
  43. package/dist/commands/migration-status.d.mts.map +1 -1
  44. package/dist/commands/migration-status.mjs +1 -1
  45. package/dist/commands/ref.d.mts +1 -1
  46. package/dist/commands/ref.d.mts.map +1 -1
  47. package/dist/commands/ref.mjs +13 -18
  48. package/dist/commands/ref.mjs.map +1 -1
  49. package/dist/commands/telemetry/index.mjs +1 -1
  50. package/dist/contract-at-errors-DvZ_DzJK.mjs +36 -0
  51. package/dist/contract-at-errors-DvZ_DzJK.mjs.map +1 -0
  52. package/dist/{contract-emit-CgnXSANN.mjs → contract-emit-BT46Mu8Q.mjs} +3 -3
  53. package/dist/{contract-emit-CgnXSANN.mjs.map → contract-emit-BT46Mu8Q.mjs.map} +1 -1
  54. package/dist/{contract-emit-cJQBlvGb.mjs → contract-emit-hVdlaF2U.mjs} +6 -7
  55. package/dist/{contract-emit-cJQBlvGb.mjs.map → contract-emit-hVdlaF2U.mjs.map} +1 -1
  56. package/dist/{contract-enrichment-gn9sWbPw.mjs → contract-enrichment-JUhLv-BX.mjs} +8 -8
  57. package/dist/{contract-enrichment-gn9sWbPw.mjs.map → contract-enrichment-JUhLv-BX.mjs.map} +1 -1
  58. package/dist/{contract-infer-Cg8evbeg.mjs → contract-infer-DpqTQECL.mjs} +3 -3
  59. package/dist/{contract-infer-Cg8evbeg.mjs.map → contract-infer-DpqTQECL.mjs.map} +1 -1
  60. package/dist/{contract-space-aggregate-loader-D_3VeHVb.mjs → contract-space-aggregate-loader-CNd-ZB6C.mjs} +14 -14
  61. package/dist/contract-space-aggregate-loader-CNd-ZB6C.mjs.map +1 -0
  62. package/dist/{db-verify-BEclUzki.mjs → db-verify-FEN6k1m7.mjs} +10 -8
  63. package/dist/db-verify-FEN6k1m7.mjs.map +1 -0
  64. package/dist/exports/control-api.d.mts +4 -4
  65. package/dist/exports/control-api.d.mts.map +1 -1
  66. package/dist/exports/control-api.mjs +3 -3
  67. package/dist/exports/index.d.mts +2 -1
  68. package/dist/exports/index.d.mts.map +1 -1
  69. package/dist/exports/index.mjs +61 -21
  70. package/dist/exports/index.mjs.map +1 -1
  71. package/dist/exports/init-output.d.mts.map +1 -1
  72. package/dist/exports/init-output.mjs +1 -1
  73. package/dist/{format-DAUAZqPt.mjs → format-DI5qVr22.mjs} +8 -7
  74. package/dist/format-DI5qVr22.mjs.map +1 -0
  75. package/dist/{framework-components-CnbUbiJw.mjs → framework-components-C4XACYNB.mjs} +3 -3
  76. package/dist/framework-components-C4XACYNB.mjs.map +1 -0
  77. package/dist/{init-C3JhkHg-.mjs → init-ClrRkbwd.mjs} +77 -67
  78. package/dist/init-ClrRkbwd.mjs.map +1 -0
  79. package/dist/{inspect-live-schema-CX7EA5C3.mjs → inspect-live-schema-C0Rgdtw_.mjs} +4 -4
  80. package/dist/{inspect-live-schema-CX7EA5C3.mjs.map → inspect-live-schema-C0Rgdtw_.mjs.map} +1 -1
  81. package/dist/{migration-check-MHT3w7_v.mjs → migration-check-zEkHpPDT.mjs} +58 -30
  82. package/dist/migration-check-zEkHpPDT.mjs.map +1 -0
  83. package/dist/{migration-command-scaffold-CRyYrHZ9.mjs → migration-command-scaffold-CkNsp9g1.mjs} +4 -4
  84. package/dist/{migration-command-scaffold-CRyYrHZ9.mjs.map → migration-command-scaffold-CkNsp9g1.mjs.map} +1 -1
  85. package/dist/{migration-graph-command-render-B83xrnNy.mjs → migration-graph-command-render-DEwFpx-w.mjs} +5 -4
  86. package/dist/migration-graph-command-render-DEwFpx-w.mjs.map +1 -0
  87. package/dist/{migration-list-BAKujUjh.mjs → migration-list-BkafFVXS.mjs} +6 -6
  88. package/dist/migration-list-BkafFVXS.mjs.map +1 -0
  89. package/dist/{migration-log-C_xam2HZ.mjs → migration-log-BxhAtbhA.mjs} +5 -5
  90. package/dist/{migration-log-C_xam2HZ.mjs.map → migration-log-BxhAtbhA.mjs.map} +1 -1
  91. package/dist/{migration-path-target-DpPTsRCg.mjs → migration-path-target-B5HkjSTO.mjs} +2 -2
  92. package/dist/{migration-path-target-DpPTsRCg.mjs.map → migration-path-target-B5HkjSTO.mjs.map} +1 -1
  93. package/dist/{migration-plan-CreSVtWZ.mjs → migration-plan-Bk2pbPQH.mjs} +64 -74
  94. package/dist/migration-plan-Bk2pbPQH.mjs.map +1 -0
  95. package/dist/{migration-status-YgEvXf-u.mjs → migration-status-BzlARseq.mjs} +13 -12
  96. package/dist/migration-status-BzlARseq.mjs.map +1 -0
  97. package/dist/{output-mEQ74_nd.mjs → output-DWNYqZGc.mjs} +5 -6
  98. package/dist/output-DWNYqZGc.mjs.map +1 -0
  99. package/dist/{ref-advancement-BkXlikCA.mjs → ref-advancement-BCz7X7qJ.mjs} +13 -6
  100. package/dist/ref-advancement-BCz7X7qJ.mjs.map +1 -0
  101. package/dist/{telemetry-DVr6RFnq.mjs → telemetry-BbniBUbP.mjs} +2 -2
  102. package/dist/{telemetry-DVr6RFnq.mjs.map → telemetry-BbniBUbP.mjs.map} +1 -1
  103. package/dist/{types-D4r_HI9-.d.mts → types-DgXprE3w.d.mts} +3 -3
  104. package/dist/types-DgXprE3w.d.mts.map +1 -0
  105. package/dist/{verify-CgDVZjhc.mjs → verify-BSaNeaSL.mjs} +2 -2
  106. package/dist/{verify-CgDVZjhc.mjs.map → verify-BSaNeaSL.mjs.map} +1 -1
  107. package/package.json +21 -21
  108. package/src/commands/db-init.ts +5 -3
  109. package/src/commands/db-sign.ts +9 -7
  110. package/src/commands/db-update.ts +18 -9
  111. package/src/commands/db-verify.ts +4 -4
  112. package/src/commands/format.ts +1 -1
  113. package/src/commands/init/hygiene-gitattributes.ts +37 -21
  114. package/src/commands/init/init.ts +6 -6
  115. package/src/commands/init/output.ts +4 -5
  116. package/src/commands/init/probe-db.ts +9 -2
  117. package/src/commands/init/reinit-cleanup.ts +16 -17
  118. package/src/commands/init/templates/render.ts +2 -1
  119. package/src/commands/inspect-live-schema.ts +1 -1
  120. package/src/commands/migrate.ts +6 -5
  121. package/src/commands/migration-check.ts +72 -34
  122. package/src/commands/migration-list.ts +1 -5
  123. package/src/commands/migration-log.ts +1 -1
  124. package/src/commands/migration-new.ts +17 -41
  125. package/src/commands/migration-plan.ts +64 -88
  126. package/src/commands/migration-show.ts +2 -2
  127. package/src/commands/migration-status.ts +6 -7
  128. package/src/commands/ref.ts +19 -14
  129. package/src/control-api/client.ts +43 -25
  130. package/src/control-api/contract-enrichment.ts +7 -7
  131. package/src/control-api/operations/contract-emit.ts +2 -3
  132. package/src/control-api/operations/db-init.ts +3 -3
  133. package/src/control-api/operations/db-run.ts +8 -7
  134. package/src/control-api/operations/db-update.ts +2 -2
  135. package/src/control-api/operations/db-verify.ts +4 -4
  136. package/src/control-api/operations/format.ts +5 -4
  137. package/src/control-api/operations/migrate.ts +6 -5
  138. package/src/control-api/operations/run-migration.ts +2 -1
  139. package/src/control-api/types.ts +1 -1
  140. package/src/load-ts-contract.ts +81 -16
  141. package/src/utils/cli-errors.ts +15 -7
  142. package/src/utils/combine-verify-results.ts +2 -1
  143. package/src/utils/command-helpers.ts +15 -5
  144. package/src/utils/contract-at-errors.ts +13 -22
  145. package/src/utils/contract-space-aggregate-loader.ts +8 -8
  146. package/src/utils/contract-space-seed-phase.ts +11 -9
  147. package/src/utils/extension-pack-inputs.ts +8 -8
  148. package/src/utils/formatters/migration-graph-grid-layout.ts +2 -1
  149. package/src/utils/formatters/migration-graph-labels.ts +1 -2
  150. package/src/utils/formatters/migration-list-data-column.ts +1 -2
  151. package/src/utils/framework-components.ts +9 -9
  152. package/src/utils/integrity-violation-to-check-failure.ts +3 -3
  153. package/src/utils/migration-command-scaffold.ts +1 -1
  154. package/src/utils/plan-resolution.ts +7 -10
  155. package/src/utils/ref-advancement.ts +22 -3
  156. package/dist/client-KuBQftxz.mjs.map +0 -1
  157. package/dist/command-helpers-Cpq44aVa.mjs.map +0 -1
  158. package/dist/contract-at-errors-D9gEjYtg.mjs +0 -42
  159. package/dist/contract-at-errors-D9gEjYtg.mjs.map +0 -1
  160. package/dist/contract-space-aggregate-loader-D_3VeHVb.mjs.map +0 -1
  161. package/dist/db-verify-BEclUzki.mjs.map +0 -1
  162. package/dist/format-DAUAZqPt.mjs.map +0 -1
  163. package/dist/framework-components-CnbUbiJw.mjs.map +0 -1
  164. package/dist/init-C3JhkHg-.mjs.map +0 -1
  165. package/dist/migration-check-MHT3w7_v.mjs.map +0 -1
  166. package/dist/migration-graph-command-render-B83xrnNy.mjs.map +0 -1
  167. package/dist/migration-list-BAKujUjh.mjs.map +0 -1
  168. package/dist/migration-plan-CreSVtWZ.mjs.map +0 -1
  169. package/dist/migration-status-YgEvXf-u.mjs.map +0 -1
  170. package/dist/output-mEQ74_nd.mjs.map +0 -1
  171. package/dist/ref-advancement-BkXlikCA.mjs.map +0 -1
  172. package/dist/types-D4r_HI9-.d.mts.map +0 -1
  173. package/src/control-api/errors.ts +0 -9
@@ -1,26 +1,19 @@
1
- import { F as CliStructuredError } from "./command-helpers-Cpq44aVa.mjs";
2
- import { t as assertFrameworkComponentsCompatible } from "./framework-components-CnbUbiJw.mjs";
3
- import { t as enrichContract } from "./contract-enrichment-gn9sWbPw.mjs";
4
- import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-D_3VeHVb.mjs";
1
+ import { F as CliStructuredError$1 } from "./command-helpers-D-jBl0Qt.mjs";
2
+ import { t as assertFrameworkComponentsCompatible } from "./framework-components-C4XACYNB.mjs";
3
+ import { t as enrichContract } from "./contract-enrichment-JUhLv-BX.mjs";
4
+ import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-CNd-ZB6C.mjs";
5
5
  import { emit } from "@prisma-next/emitter";
6
+ import { CliStructuredError } from "@prisma-next/errors/control";
6
7
  import { ifDefined } from "@prisma-next/utils/defined";
7
8
  import { notOk, ok } from "@prisma-next/utils/result";
8
9
  import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma-next/framework-components/control";
9
10
  import { blindCast, castAs } from "@prisma-next/utils/casts";
11
+ import { InternalError } from "@prisma-next/utils/internal-error";
12
+ import { structuredError } from "@prisma-next/utils/structured-error";
10
13
  import { allStorageElementsExternal, buildFabricatedMigrationEdge, collectAggregateNamespaces, planMigration, requireHeadRef, resolveRecordedPath, verifyMigration } from "@prisma-next/migration-tools/aggregate";
11
14
  import { EMPTY_CONTRACT_HASH } from "@prisma-next/migration-tools/constants";
12
15
  import { errorNoInvariantPath } from "@prisma-next/migration-tools/errors";
13
16
  import { findPathWithDecision } from "@prisma-next/migration-tools/migration-graph";
14
- //#region src/control-api/errors.ts
15
- var ContractValidationError = class extends Error {
16
- cause;
17
- constructor(message, cause) {
18
- super(message);
19
- this.name = "ContractValidationError";
20
- this.cause = cause;
21
- }
22
- };
23
- //#endregion
24
17
  //#region src/control-api/operations/migration-helpers.ts
25
18
  /**
26
19
  * Strips operation objects to their public shape (id, label, operationClass).
@@ -152,7 +145,7 @@ function buildPerSpaceBreakdown(orderedResolutions, appSpaceId, options) {
152
145
  function collectOrdered(applyOrder, perSpace) {
153
146
  return applyOrder.map((spaceId) => {
154
147
  const entry = perSpace.get(spaceId);
155
- if (!entry) throw new Error(`planner output missing per-space plan for "${spaceId}"`);
148
+ if (!entry) throw new InternalError(`planner output missing per-space plan for "${spaceId}"`);
156
149
  return {
157
150
  spaceId,
158
151
  entry
@@ -206,12 +199,12 @@ const SPAN_IDS$1 = {
206
199
  * every space's writes.
207
200
  */
208
201
  async function executeRun(options) {
209
- const { driver, adapter, familyInstance, contract, mode, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, policy, action, onProgress } = options;
202
+ const { driver, adapter, familyInstance, contract, mode, migrations, frameworkComponents, migrationsDir, extensions, targetId, policy, action, onProgress } = options;
210
203
  const loaded = await buildContractSpaceAggregate({
211
204
  targetId,
212
205
  migrationsDir,
213
206
  appContract: contract,
214
- extensionPacks,
207
+ extensions,
215
208
  deserializeContract: (json) => familyInstance.deserializeContract(json)
216
209
  });
217
210
  if (!loaded.ok) throw loaded.failure;
@@ -273,7 +266,7 @@ async function executeRun(options) {
273
266
  const orderedResolutions = collectOrdered(planResult.value.applyOrder, planResult.value.perSpace);
274
267
  const plannerWarnings = aggregatePlannerWarnings(orderedResolutions);
275
268
  const appResolution = orderedResolutions.find((r) => r.spaceId === aggregate.app.spaceId);
276
- if (!appResolution) throw new Error("Aggregate planner returned no plan for the app space — the planner is supposed to always emit one.");
269
+ if (!appResolution) throw new InternalError("Aggregate planner returned no plan for the app space — the planner is supposed to always emit one.");
277
270
  const appPlan = appResolution.entry.plan;
278
271
  if (mode === "plan") {
279
272
  const aggregateOps = orderedResolutions.flatMap((r) => r.entry.displayOps);
@@ -327,7 +320,7 @@ function aggregatePlannerWarnings(orderedResolutions) {
327
320
  * Compare the live `_prisma_marker` rows against the aggregate's
328
321
  * declared contract spaces. Any marker row whose `space` is not a space of
329
322
  * the aggregate is an "orphan" — typically a marker left behind by
330
- * an extension that was removed from `extensionPacks` without first
323
+ * an extension that was removed from `extensions` without first
331
324
  * cleaning up its on-disk migrations / database tables.
332
325
  *
333
326
  * Returns a {@link CliStructuredError} envelope (code
@@ -344,9 +337,9 @@ function detectOrphanMarkers(aggregate, markerRows) {
344
337
  for (const [spaceId, row] of markerRows) if (row !== null && row !== void 0 && !aggregateSpaceIds.has(spaceId)) orphans.push(spaceId);
345
338
  if (orphans.length === 0) return null;
346
339
  orphans.sort((a, b) => a.localeCompare(b));
347
- return new CliStructuredError("MIGRATION.CONTRACT_SPACE_VIOLATION", orphans.length === 1 ? `Orphan contract-space marker detected for "${orphans[0]}"` : `Orphan contract-space markers detected for ${orphans.length} spaces`, {
348
- why: `The database has \`_prisma_marker\` rows for spaces (${orphans.map((s) => `"${s}"`).join(", ")}) that are not declared in the project's \`extensionPacks\`. The aggregate pipeline refuses to advance markers it cannot account for.`,
349
- fix: "Either re-declare the missing extension(s) in `extensionPacks` (so the aggregate owns them again), or remove the orphan marker row(s) from `_prisma_marker` once you have confirmed the corresponding tables can be safely retired.",
340
+ return new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", orphans.length === 1 ? `Orphan contract-space marker detected for "${orphans[0]}"` : `Orphan contract-space markers detected for ${orphans.length} spaces`, {
341
+ why: `The database has \`_prisma_marker\` rows for spaces (${orphans.map((s) => `"${s}"`).join(", ")}) that are not declared in the project's \`extensions\`. The aggregate pipeline refuses to advance markers it cannot account for.`,
342
+ fix: "Either re-declare the missing extension(s) in `extensions` (so the aggregate owns them again), or remove the orphan marker row(s) from `_prisma_marker` once you have confirmed the corresponding tables can be safely retired.",
350
343
  docsUrl: "https://pris.ly/contract-spaces",
351
344
  meta: { violations: orphans.map((spaceId) => ({
352
345
  kind: "orphanMarker",
@@ -451,7 +444,7 @@ async function executeDbInit(options) {
451
444
  frameworkComponents: options.frameworkComponents,
452
445
  migrationsDir: options.migrationsDir,
453
446
  targetId: options.targetId,
454
- extensionPacks: options.extensionPacks ?? [],
447
+ extensions: options.extensions ?? [],
455
448
  policy: { allowedOperationClasses: ["additive"] },
456
449
  action: "dbInit",
457
450
  ...ifDefined("onProgress", options.onProgress)
@@ -483,7 +476,7 @@ async function executeDbUpdate(options) {
483
476
  frameworkComponents: options.frameworkComponents,
484
477
  migrationsDir: options.migrationsDir,
485
478
  targetId: options.targetId,
486
- extensionPacks: options.extensionPacks ?? [],
479
+ extensions: options.extensions ?? [],
487
480
  policy: DB_UPDATE_POLICY,
488
481
  action: "dbUpdate",
489
482
  ...ifDefined("onProgress", options.onProgress)
@@ -585,7 +578,7 @@ function buildLoadInputs(options) {
585
578
  targetId: options.targetId,
586
579
  migrationsDir: options.migrationsDir,
587
580
  appContract: options.contract,
588
- extensionPacks: options.extensionPacks,
581
+ extensions: options.extensions,
589
582
  deserializeContract: (json) => options.familyInstance.deserializeContract(json)
590
583
  };
591
584
  }
@@ -663,7 +656,7 @@ function finaliseVerifyResult(args) {
663
656
  const { verifyResult, aggregate, skipMarker, onProgress } = args;
664
657
  if (!verifyResult.ok) {
665
658
  emitVerifySpan(onProgress, "spanEndError");
666
- return notOk(new CliStructuredError("MIGRATION.CONTRACT_SPACE_VIOLATION", "Aggregate verifier introspection failed", {
659
+ return notOk(new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", "Aggregate verifier introspection failed", {
667
660
  why: verifyResult.failure.detail,
668
661
  fix: "Check database connectivity and the introspection tooling.",
669
662
  docsUrl: "https://pris.ly/contract-spaces"
@@ -725,12 +718,12 @@ function mapMarkerCheckFailures(appSpaceId, section) {
725
718
  for (const orphan of section.orphanMarkers) violations.push({
726
719
  kind: "orphanMarker",
727
720
  spaceId: orphan.spaceId,
728
- remediation: `Add the corresponding extension to \`extensionPacks\` in \`prisma-next.config.ts\`, or delete the orphan marker row for "${orphan.spaceId}".`
721
+ remediation: `Add the corresponding extension to \`extensions\` in \`prisma-next.config.ts\`, or delete the orphan marker row for "${orphan.spaceId}".`
729
722
  });
730
723
  if (violations.length === 0) return null;
731
724
  const lines = violations.map((v) => `- [${v.kind}] ${v.spaceId}: ${v.remediation}`);
732
- return new CliStructuredError("MIGRATION.CONTRACT_SPACE_VIOLATION", violations.length === 1 ? "Contract-space verifier found a violation" : `Contract-space verifier found violations (${violations.length})`, {
733
- why: `The on-disk \`migrations/\` directory, the \`extensionPacks\` declaration, and the live database marker rows are not in agreement.\n${lines.join("\n")}`,
725
+ return new CliStructuredError$1("MIGRATION.CONTRACT_SPACE_VIOLATION", violations.length === 1 ? "Contract-space verifier found a violation" : `Contract-space verifier found violations (${violations.length})`, {
726
+ why: `The on-disk \`migrations/\` directory, the \`extensions\` declaration, and the live database marker rows are not in agreement.\n${lines.join("\n")}`,
734
727
  fix: violations[0]?.remediation ?? "Review and reconcile the violations listed above.",
735
728
  docsUrl: "https://pris.ly/contract-spaces",
736
729
  meta: { violations }
@@ -764,12 +757,12 @@ function mapMarkerCheckFailures(appSpaceId, section) {
764
757
  * authored migration graph on disk before this operation can advance it.
765
758
  */
766
759
  async function executeMigrate(options) {
767
- const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensionPacks, targetId, refHash, refInvariants, refName, onProgress } = options;
760
+ const { driver, familyInstance, contract, migrations, frameworkComponents, migrationsDir, extensions, targetId, refHash, refInvariants, refName, onProgress } = options;
768
761
  const loaded = await buildContractSpaceAggregate({
769
762
  targetId,
770
763
  migrationsDir,
771
764
  appContract: contract,
772
- extensionPacks,
765
+ extensions,
773
766
  deserializeContract: (json) => familyInstance.deserializeContract(json)
774
767
  });
775
768
  if (!loaded.ok) throw loaded.failure;
@@ -822,7 +815,7 @@ async function executeMigrate(options) {
822
815
  })) {
823
816
  const ordered = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) || atHeadResolutions.has(spaceId)).map((spaceId) => {
824
817
  const entry = perSpacePlans.get(spaceId) ?? atHeadResolutions.get(spaceId);
825
- if (entry === void 0) throw new Error(`Unreachable: missing per-space plan for "${spaceId}"`);
818
+ if (entry === void 0) throw new InternalError(`Unreachable: missing per-space plan for "${spaceId}"`);
826
819
  return {
827
820
  spaceId,
828
821
  entry
@@ -867,7 +860,7 @@ async function executeMigrate(options) {
867
860
  if (fromRunner !== void 0) return fromRunner;
868
861
  }
869
862
  const entry = atHeadResolutions.get(spaceId);
870
- if (entry === void 0) throw new Error(`Unreachable: missing per-space plan for "${spaceId}"`);
863
+ if (entry === void 0) throw new InternalError(`Unreachable: missing per-space plan for "${spaceId}"`);
871
864
  return {
872
865
  spaceId,
873
866
  entry
@@ -1139,23 +1132,23 @@ var ControlClientImpl = class {
1139
1132
  target: this.options.target,
1140
1133
  adapter: this.options.adapter,
1141
1134
  driver: this.options.driver,
1142
- extensionPacks: this.options.extensionPacks
1135
+ extensions: this.options.extensions
1143
1136
  });
1144
1137
  this.familyInstance = this.options.family.create(this.stack);
1145
1138
  const rawComponents = [
1146
1139
  this.options.target,
1147
1140
  this.options.adapter,
1148
- ...this.options.extensionPacks ?? []
1141
+ ...this.options.extensions ?? []
1149
1142
  ];
1150
1143
  this.frameworkComponents = assertFrameworkComponentsCompatible(this.options.family.familyId, this.options.target.targetId, rawComponents);
1151
1144
  this.initialized = true;
1152
1145
  }
1153
1146
  async connect(connection) {
1154
1147
  this.init();
1155
- if (this.driver) throw new Error("Already connected. Call close() before reconnecting.");
1148
+ if (this.driver) throw new CliStructuredError("DRIVER.ALREADY_CONNECTED", "Already connected. Call close() before reconnecting.");
1156
1149
  const resolvedConnection = connection ?? this.defaultConnection;
1157
- if (resolvedConnection === void 0) throw new Error("No connection provided. Pass a connection to connect() or provide a default connection when creating the client.");
1158
- if (!this.stack?.driver) throw new Error("Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations.");
1150
+ if (resolvedConnection === void 0) throw new CliStructuredError("CONFIG.DB_CONNECTION_REQUIRED", "No connection provided. Pass a connection to connect() or provide a default connection when creating the client.");
1151
+ if (!this.stack?.driver) throw new CliStructuredError("CONFIG.DRIVER_REQUIRED", "Driver is not configured. Pass a driver descriptor when creating the control client to enable database operations.");
1159
1152
  this.driver = await this.stack.driver.create(resolvedConnection);
1160
1153
  }
1161
1154
  async close() {
@@ -1173,13 +1166,13 @@ var ControlClientImpl = class {
1173
1166
  */
1174
1167
  buildControlAdapter() {
1175
1168
  this.init();
1176
- if (!this.stack?.adapter) throw new Error(`Target "${this.options.target.targetId}" requires an adapter for migrations`);
1169
+ if (!this.stack?.adapter) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" requires an adapter for migrations`);
1177
1170
  return this.stack.adapter.create(this.stack);
1178
1171
  }
1179
1172
  async ensureConnected() {
1180
1173
  this.init();
1181
1174
  if (!this.driver && this.defaultConnection !== void 0) await this.connect(this.defaultConnection);
1182
- if (!this.driver || !this.familyInstance || !this.frameworkComponents) throw new Error("Not connected. Call connect(connection) first.");
1175
+ if (!this.driver || !this.familyInstance || !this.frameworkComponents) throw new CliStructuredError("DRIVER.NOT_CONNECTED", "Not connected. Call connect(connection) first.");
1183
1176
  return {
1184
1177
  driver: this.driver,
1185
1178
  familyInstance: this.familyInstance,
@@ -1220,7 +1213,7 @@ var ControlClientImpl = class {
1220
1213
  try {
1221
1214
  contract = familyInstance.deserializeContract(options.contract);
1222
1215
  } catch (error) {
1223
- throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1216
+ throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1224
1217
  }
1225
1218
  onProgress?.({
1226
1219
  action: "verify",
@@ -1260,7 +1253,7 @@ var ControlClientImpl = class {
1260
1253
  try {
1261
1254
  contract = familyInstance.deserializeContract(options.contract);
1262
1255
  } catch (error) {
1263
- throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1256
+ throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1264
1257
  }
1265
1258
  onProgress?.({
1266
1259
  action: "schemaVerify",
@@ -1304,7 +1297,7 @@ var ControlClientImpl = class {
1304
1297
  try {
1305
1298
  contract = familyInstance.deserializeContract(options.contract);
1306
1299
  } catch (error) {
1307
- throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1300
+ throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1308
1301
  }
1309
1302
  onProgress?.({
1310
1303
  action: "sign",
@@ -1340,13 +1333,13 @@ var ControlClientImpl = class {
1340
1333
  const { onProgress } = options;
1341
1334
  await this.connectWithProgress(options.connection, "dbInit", onProgress);
1342
1335
  const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1343
- if (!hasMigrations(this.options.target)) throw new Error(`Target "${this.options.target.targetId}" does not support migrations`);
1336
+ if (!hasMigrations(this.options.target)) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" does not support migrations`);
1344
1337
  const adapter = this.buildControlAdapter();
1345
1338
  let contract;
1346
1339
  try {
1347
1340
  contract = familyInstance.deserializeContract(options.contract);
1348
1341
  } catch (error) {
1349
- throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1342
+ throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1350
1343
  }
1351
1344
  return executeDbInit({
1352
1345
  driver,
@@ -1358,7 +1351,7 @@ var ControlClientImpl = class {
1358
1351
  frameworkComponents,
1359
1352
  migrationsDir: options.migrationsDir,
1360
1353
  targetId: this.options.target.targetId,
1361
- extensionPacks: this.options.extensionPacks ?? [],
1354
+ extensions: this.options.extensions ?? [],
1362
1355
  ...ifDefined("onProgress", onProgress)
1363
1356
  });
1364
1357
  }
@@ -1366,13 +1359,13 @@ var ControlClientImpl = class {
1366
1359
  const { onProgress } = options;
1367
1360
  await this.connectWithProgress(options.connection, "dbUpdate", onProgress);
1368
1361
  const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1369
- if (!hasMigrations(this.options.target)) throw new Error(`Target "${this.options.target.targetId}" does not support migrations`);
1362
+ if (!hasMigrations(this.options.target)) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" does not support migrations`);
1370
1363
  const adapter = this.buildControlAdapter();
1371
1364
  let contract;
1372
1365
  try {
1373
1366
  contract = familyInstance.deserializeContract(options.contract);
1374
1367
  } catch (error) {
1375
- throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1368
+ throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1376
1369
  }
1377
1370
  return executeDbUpdate({
1378
1371
  driver,
@@ -1384,7 +1377,7 @@ var ControlClientImpl = class {
1384
1377
  frameworkComponents,
1385
1378
  migrationsDir: options.migrationsDir,
1386
1379
  targetId: this.options.target.targetId,
1387
- extensionPacks: this.options.extensionPacks ?? [],
1380
+ extensions: this.options.extensions ?? [],
1388
1381
  ...ifDefined("acceptDataLoss", options.acceptDataLoss),
1389
1382
  ...ifDefined("onProgress", onProgress)
1390
1383
  });
@@ -1399,7 +1392,7 @@ var ControlClientImpl = class {
1399
1392
  contract: options.contract,
1400
1393
  migrationsDir: options.migrationsDir,
1401
1394
  targetId: this.options.target.targetId,
1402
- extensionPacks: this.options.extensionPacks ?? [],
1395
+ extensions: this.options.extensions ?? [],
1403
1396
  frameworkComponents,
1404
1397
  mode: options.strict ? "strict" : "lenient",
1405
1398
  skipSchema: options.skipSchema,
@@ -1430,12 +1423,12 @@ var ControlClientImpl = class {
1430
1423
  const { onProgress } = options;
1431
1424
  await this.connectWithProgress(options.connection, "migrate", onProgress);
1432
1425
  const { driver, familyInstance, frameworkComponents } = await this.ensureConnected();
1433
- if (!hasMigrations(this.options.target)) throw new Error(`Target "${this.options.target.targetId}" does not support migrations`);
1426
+ if (!hasMigrations(this.options.target)) throw new CliStructuredError("MIGRATION.TARGET_UNSUPPORTED", `Target "${this.options.target.targetId}" does not support migrations`);
1434
1427
  let contract;
1435
1428
  try {
1436
1429
  contract = familyInstance.deserializeContract(options.contract);
1437
1430
  } catch (error) {
1438
- throw new ContractValidationError(error instanceof Error ? error.message : String(error), error);
1431
+ throw structuredError("CONTRACT.VALIDATION_FAILED", error instanceof Error ? error.message : String(error), { cause: error });
1439
1432
  }
1440
1433
  return executeMigrate({
1441
1434
  driver,
@@ -1444,7 +1437,7 @@ var ControlClientImpl = class {
1444
1437
  migrations: this.options.target.migrations,
1445
1438
  frameworkComponents,
1446
1439
  migrationsDir: options.migrationsDir,
1447
- extensionPacks: this.options.extensionPacks ?? [],
1440
+ extensions: this.options.extensions ?? [],
1448
1441
  targetId: this.options.target.targetId,
1449
1442
  ...ifDefined("refHash", options.refHash),
1450
1443
  ...ifDefined("refInvariants", options.refInvariants),
@@ -1501,7 +1494,7 @@ var ControlClientImpl = class {
1501
1494
  async emit(options) {
1502
1495
  const { onProgress, contractConfig } = options;
1503
1496
  this.init();
1504
- if (!this.familyInstance) throw new Error("Family instance was not initialized. This is a bug.");
1497
+ if (!this.familyInstance) throw new InternalError("Family instance was not initialized. This is a bug.");
1505
1498
  let contractRaw;
1506
1499
  onProgress?.({
1507
1500
  action: "emit",
@@ -1512,9 +1505,8 @@ var ControlClientImpl = class {
1512
1505
  try {
1513
1506
  const stack = this.stack;
1514
1507
  const sourceContext = {
1515
- composedExtensionPacks: stack.extensionPacks.map((p) => p.id),
1508
+ composedExtensions: stack.extensions.map((p) => p.id),
1516
1509
  composedExtensionContracts: stack.extensionContracts,
1517
- scalarTypeDescriptors: stack.scalarTypeDescriptors,
1518
1510
  authoringContributions: stack.authoringContributions,
1519
1511
  codecLookup: stack.codecLookup,
1520
1512
  controlMutationDefaults: stack.controlMutationDefaults,
@@ -1623,6 +1615,6 @@ var ControlClientImpl = class {
1623
1615
  }
1624
1616
  };
1625
1617
  //#endregion
1626
- export { executeDbInit as a, executeDbUpdate as i, planSpacePath as n, ContractValidationError as o, executeDbVerify as r, createControlClient as t };
1618
+ export { executeDbInit as a, executeDbUpdate as i, planSpacePath as n, executeDbVerify as r, createControlClient as t };
1627
1619
 
1628
- //# sourceMappingURL=client-KuBQftxz.mjs.map
1620
+ //# sourceMappingURL=client-B1UjQc_x.mjs.map