@prisma/orm-toolchain 8.0.0-rc.18-dev.32 → 8.0.0-rc.18-dev.34

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 (79) hide show
  1. package/dist/{aggregate-C0qscKli.mjs → aggregate-B9HIfbq6.mjs} +7 -7
  2. package/dist/{aggregate-C0qscKli.mjs.map → aggregate-B9HIfbq6.mjs.map} +1 -1
  3. package/dist/{caught-errors-BJYT1ZZW-CJZWDvwc.mjs → caught-errors-VVhfmaAC-B-4FGHb0.mjs} +20 -25
  4. package/dist/caught-errors-VVhfmaAC-B-4FGHb0.mjs.map +1 -0
  5. package/dist/cli-telemetry.mjs +1 -1
  6. package/dist/cli.mjs +58 -334
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/cli__control-api.d.mts +9 -5
  9. package/dist/cli__control-api.d.mts.map +1 -1
  10. package/dist/cli__control-api.mjs +2 -2
  11. package/dist/cli__control-api__testing.d.mts +1 -1
  12. package/dist/cli__migration-cli.mjs +4 -4
  13. package/dist/cli__migration-cli.mjs.map +1 -1
  14. package/dist/config-loader.mjs +1 -1
  15. package/dist/{contract-snapshot-store-DwEs5EOp-3qAvnEf3.mjs → contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs} +3 -3
  16. package/dist/{contract-snapshot-store-DwEs5EOp-3qAvnEf3.mjs.map → contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs.map} +1 -1
  17. package/dist/{db-sign-WZXfmxmZ-BVlM-YTL.d.mts → db-sign-DyugidHS-DGvMQ558.d.mts} +34 -140
  18. package/dist/db-sign-DyugidHS-DGvMQ558.d.mts.map +1 -0
  19. package/dist/{domain-type-generation-DpXuDGLd-CuADX8tA.mjs → domain-type-generation-B4m774CV-WAjyhZHw.mjs} +14 -8
  20. package/dist/domain-type-generation-B4m774CV-WAjyhZHw.mjs.map +1 -0
  21. package/dist/{domain-type-generation-BdSOXF3O-DGGiAaNs.d.mts → domain-type-generation-DZjtzrbE-BpOOD3YV.d.mts} +9 -6
  22. package/dist/domain-type-generation-DZjtzrbE-BpOOD3YV.d.mts.map +1 -0
  23. package/dist/emitter.d.mts +2 -2
  24. package/dist/emitter.mjs +2 -2
  25. package/dist/emitter__domain-type-generation.d.mts +2 -2
  26. package/dist/emitter__domain-type-generation.mjs +2 -2
  27. package/dist/{errors-GnmirXRU.d.mts → errors-CLwhWJiz.d.mts} +10 -2
  28. package/dist/errors-CLwhWJiz.d.mts.map +1 -0
  29. package/dist/{errors-nnIQQvmN-oeANP4Yi.mjs → errors-DXha_4l--relAaiI4.mjs} +9 -6
  30. package/dist/errors-DXha_4l--relAaiI4.mjs.map +1 -0
  31. package/dist/{exports-BLyT8ULG-C_kH8_9c.mjs → exports-BCIlMjIW-DkUBVDzl.mjs} +5 -16
  32. package/dist/exports-BCIlMjIW-DkUBVDzl.mjs.map +1 -0
  33. package/dist/{exports-DfSHy5Id.mjs → exports-BlYTE3-J.mjs} +2 -2
  34. package/dist/{exports-DfSHy5Id.mjs.map → exports-BlYTE3-J.mjs.map} +1 -1
  35. package/dist/{exports-CiTltjML.mjs → exports-CfQzEu2x.mjs} +2 -2
  36. package/dist/{exports-CiTltjML.mjs.map → exports-CfQzEu2x.mjs.map} +1 -1
  37. package/dist/{graph-membership-ul46Kb0W-B8HahKEu.mjs → graph-membership-DxpNgxfZ-BfqA-H7V.mjs} +3 -3
  38. package/dist/{graph-membership-ul46Kb0W-B8HahKEu.mjs.map → graph-membership-DxpNgxfZ-BfqA-H7V.mjs.map} +1 -1
  39. package/dist/{index-wUUMOC5E.d.mts → index-tAySVPvZ.d.mts} +4 -4
  40. package/dist/{index-wUUMOC5E.d.mts.map → index-tAySVPvZ.d.mts.map} +1 -1
  41. package/dist/{invariants-Jgsl_-rJ-0ieZ1n7L.mjs → invariants-DrF9p5Gd-BF70vGl1.mjs} +3 -3
  42. package/dist/{invariants-Jgsl_-rJ-0ieZ1n7L.mjs.map → invariants-DrF9p5Gd-BF70vGl1.mjs.map} +1 -1
  43. package/dist/{io-QeCr3NPS-Bk-Rfef2.mjs → io-BJ-LXfIc-BDm7pWEw.mjs} +5 -5
  44. package/dist/{io-QeCr3NPS-Bk-Rfef2.mjs.map → io-BJ-LXfIc-BDm7pWEw.mjs.map} +1 -1
  45. package/dist/migration-tools.d.mts +2 -2
  46. package/dist/migration-tools.mjs +12 -12
  47. package/dist/migration-tools__aggregate.mjs +1 -1
  48. package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
  49. package/dist/migration-tools__errors.d.mts +2 -2
  50. package/dist/migration-tools__errors.mjs +1 -1
  51. package/dist/migration-tools__invariants.mjs +1 -1
  52. package/dist/migration-tools__io.mjs +1 -1
  53. package/dist/migration-tools__migration-graph.mjs +1 -1
  54. package/dist/migration-tools__migration.mjs +1 -1
  55. package/dist/migration-tools__ref-resolution.mjs +1 -1
  56. package/dist/migration-tools__refs.mjs +1 -1
  57. package/dist/migration-tools__spaces.mjs +2 -2
  58. package/dist/{migration-Cp6vkFMP.mjs → migration-wBxEFdXP.mjs} +3 -3
  59. package/dist/{migration-Cp6vkFMP.mjs.map → migration-wBxEFdXP.mjs.map} +1 -1
  60. package/dist/{ref-Bn3SzQ9Z-Cy3ftpv6.mjs → ref-DLqjHXyn-CsLViutC.mjs} +405 -156
  61. package/dist/ref-DLqjHXyn-CsLViutC.mjs.map +1 -0
  62. package/dist/{ref-resolution-CCIgrFwK.mjs → ref-resolution-Eo0QHp4f.mjs} +2 -2
  63. package/dist/{ref-resolution-CCIgrFwK.mjs.map → ref-resolution-Eo0QHp4f.mjs.map} +1 -1
  64. package/dist/{refs-BIzM-guE-qMvITMOL.mjs → refs-DM3q3IZC-BC6H6P0X.mjs} +3 -3
  65. package/dist/{refs-BIzM-guE-qMvITMOL.mjs.map → refs-DM3q3IZC-BC6H6P0X.mjs.map} +1 -1
  66. package/dist/{spaces-BoFEHLeH.mjs → spaces-COXaiv-z.mjs} +5 -5
  67. package/dist/{spaces-BoFEHLeH.mjs.map → spaces-COXaiv-z.mjs.map} +1 -1
  68. package/dist/{verify-contract-spaces-BFH2o5RL-CI6uhB5B.mjs → verify-contract-spaces-DkXWDLa0-R1nU6Hq1.mjs} +4 -4
  69. package/dist/{verify-contract-spaces-BFH2o5RL-CI6uhB5B.mjs.map → verify-contract-spaces-DkXWDLa0-R1nU6Hq1.mjs.map} +1 -1
  70. package/dist/vite-plugin-contract-emit.mjs +3 -3
  71. package/package.json +12 -12
  72. package/dist/caught-errors-BJYT1ZZW-CJZWDvwc.mjs.map +0 -1
  73. package/dist/db-sign-WZXfmxmZ-BVlM-YTL.d.mts.map +0 -1
  74. package/dist/domain-type-generation-BdSOXF3O-DGGiAaNs.d.mts.map +0 -1
  75. package/dist/domain-type-generation-DpXuDGLd-CuADX8tA.mjs.map +0 -1
  76. package/dist/errors-GnmirXRU.d.mts.map +0 -1
  77. package/dist/errors-nnIQQvmN-oeANP4Yi.mjs.map +0 -1
  78. package/dist/exports-BLyT8ULG-C_kH8_9c.mjs.map +0 -1
  79. package/dist/ref-Bn3SzQ9Z-Cy3ftpv6.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -1,23 +1,23 @@
1
- import { a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, r as buildLoadedConfig } from "./exports-DfSHy5Id.mjs";
2
- import { t as MigrationToolsError } from "./errors-nnIQQvmN-oeANP4Yi.mjs";
3
- import { t as contractSnapshotDir } from "./contract-snapshot-store-DwEs5EOp-3qAvnEf3.mjs";
4
- import { s as readMigrationsDir } from "./io-QeCr3NPS-Bk-Rfef2.mjs";
1
+ import { a as expandContractInputs, c as globContractInputMatching, d as loadConfigFiles, g as requireConfigSections, h as ormConfigSection, i as evaluateConfigModule, r as buildLoadedConfig } from "./exports-BlYTE3-J.mjs";
5
2
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
6
- import { c as spaceMigrationDirectory, l as spaceRefsDirectory } from "./verify-contract-spaces-BFH2o5RL-CI6uhB5B.mjs";
7
- import { $ as errorTargetMismatch, A as errorMarkerMissing, C as errorDriverRequired, E as errorHashMismatch, H as errorRuntime, M as errorMigrationPlanningFailed, N as errorNoMigrations, O as errorLegendHumanOnly, P as errorPathUnreachable, Q as errorTargetMigrationNotSupported, S as errorDatabaseConnectionRequired, T as errorFromCaught, U as errorSignRefsNotWritten, V as errorRunnerFailed, Y as errorStatementNeedsMigrationFile, _ as errorConfigValidation$1, a as appRefsDirFor, at as printedPath, b as errorContractValidationFailed, c as cliCommand, ct as redactUrlCredentials, d as closeQuietly, ft as runCommandAction, gt as targetSupportsMigrations, h as errorAdvanceRefArgConflict, ht as statementFlag, i as appMigrationsDirFor, it as migrationsDirFor, j as errorMigrationPackageNotFound, lt as requireLiveDatabase, m as displayPath, mt as shellQuoted, n as CliStructuredError$1$1, o as baseDirFor, ot as printedPlanCommand, p as contractPathFor, pt as selfEmitCommand, rt as maskConnectionUrl, s as chooseAction, st as readContractEnvelope, t as ActionableCliError, u as cliInvocation, v as errorContractArgConflict, w as errorFileNotFound, x as errorConvertAndDelete, y as errorContractConfigMissing } from "./caught-errors-BJYT1ZZW-CJZWDvwc.mjs";
8
- import { r as getEmittedArtifactPaths } from "./exports-BLyT8ULG-C_kH8_9c.mjs";
9
- import { r as isInSpaceHistory } from "./graph-membership-ul46Kb0W-B8HahKEu.mjs";
10
- import { d as writeRef, r as readRef } from "./refs-BIzM-guE-qMvITMOL.mjs";
11
- import { a as contractHashAtMarker } from "./aggregate-C0qscKli.mjs";
3
+ import { t as MigrationToolsError } from "./errors-DXha_4l--relAaiI4.mjs";
4
+ import { t as contractSnapshotDir } from "./contract-snapshot-store-6gIBcUeb-DJK3OM0j.mjs";
5
+ import { s as readMigrationsDir } from "./io-BJ-LXfIc-BDm7pWEw.mjs";
6
+ import { c as spaceMigrationDirectory, l as spaceRefsDirectory } from "./verify-contract-spaces-DkXWDLa0-R1nU6Hq1.mjs";
7
+ import { A as errorMarkerMissing, C as errorDriverRequired, E as errorHashMismatch, H as errorSignRefsNotWritten, J as errorStatementNeedsMigrationFile, N as errorNoMigrations, O as errorLegendHumanOnly, Q as errorTargetMismatch, S as errorDatabaseConnectionRequired, T as errorFromCaught, V as errorRuntime, Z as errorTargetMigrationNotSupported, _ as errorConfigValidation$1, a as appRefsDirFor, at as printedPlanCommand, b as errorContractValidationFailed, c as cliCommand, ct as requireLiveDatabase, d as closeQuietly, dt as runCommandAction, ft as selfEmitCommand, h as errorAdvanceRefArgConflict, ht as targetSupportsMigrations, i as appMigrationsDirFor, j as errorMigrationPackageNotFound, m as displayPath, mt as statementFlag, n as CliStructuredError$1$1, nt as maskConnectionUrl, o as baseDirFor, ot as readContractEnvelope, p as contractPathFor, pt as shellQuoted, rt as migrationsDirFor, s as chooseAction, st as redactUrlCredentials, u as cliInvocation, v as errorContractArgConflict, w as errorFileNotFound, x as errorConvertAndDelete, y as errorContractConfigMissing } from "./caught-errors-VVhfmaAC-B-4FGHb0.mjs";
8
+ import { r as getEmittedArtifactPaths } from "./exports-BCIlMjIW-DkUBVDzl.mjs";
9
+ import { r as isInSpaceHistory } from "./graph-membership-DxpNgxfZ-BfqA-H7V.mjs";
10
+ import { d as writeRef, r as readRef } from "./refs-DM3q3IZC-BC6H6P0X.mjs";
11
+ import { a as contractHashAtMarker } from "./aggregate-B9HIfbq6.mjs";
12
12
  import { i as createScaffoldSpecifierResolver } from "./import-roots-DXD7fung.mjs";
13
- import { o as isLiveMarkerRef } from "./ref-resolution-CCIgrFwK.mjs";
14
- import { $ as refuseMarkerOutsideGraph, B as loadAggregateIntegrityViolations, D as executeMigrateShowPlan, F as formatSourceDiagnostic, G as looksLikePath, H as loadContractSource, I as hasMigrationPath, J as migrationSpaceListEntriesFromAggregate, K as mapContractAtError, L as isStatementVerb, M as executeRefListCommand, N as executeRefSetCommand, O as executeMigrationNewCommand, P as findPackageByDirPath, R as listRefsByContractHash, S as executeContractEmit, U as loadContractSourceWithStack, V as loadContractRawSafely, W as loadContractSpaceAggregateForCli, X as readMigrationRefs, Y as preflightRefAdvancement, Z as refuseContractSpaceIntegrity, _ as createControlClient, _t as statusForMigrationHash, a as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, at as resolveContractRef$1, c as appliedHashesFromLedger, ct as resolveMigrationRef, d as buildReadAggregate, dt as retryCommandFor, et as refuseMissingInvariantPath, f as buildRefAdvancementFields, g as convertAndDelete, gt as sourceWarningDiagnostic, h as contractValidationMeta, ht as snapshotVerifierFor, i as RECORDED_CONTRACT_REF_FORMS, it as resolveAppTargetPath, j as executeRefDeleteCommand, k as executeMigrationPlanCommand, m as computeRefAdvancementName, mt as runMigrationList, n as DB_UPDATE_POLICY, nt as refuseUnknownInvariants, o as advanceRefSafely, ot as resolveContractRefToSnapshot, p as checkSingleTarget, pt as runMigrationCheck, r as NO_REF_ADVANCEMENT, rt as requireDatabaseForLiveMarkerUse, t as ALL_CONTRACT_REF_FORMS, tt as refusePackageCorruptionOnAggregate, u as buildMigrationSpaceGraphEntries, v as deriveStatusEdgeAnnotations, vt as toDeclaredExtensionsFromRaw, x as enumerateCheckSpaces, yt as validateLoadedContract, z as liveMarkerUse } from "./ref-Bn3SzQ9Z-Cy3ftpv6.mjs";
13
+ import { o as isLiveMarkerRef } from "./ref-resolution-Eo0QHp4f.mjs";
14
+ import { $ as refuseMissingInvariantPath, A as executeRefDeleteCommand, B as loadContractRawSafely, D as executeMigrationNewCommand, E as executeMigrateShowPlan, F as hasMigrationPath, G as mapContractAtError, H as loadContractSourceWithStack, I as isStatementVerb, J as preflightRefAdvancement, L as listRefsByContractHash, M as executeRefSetCommand, N as findPackageByDirPath, O as executeMigrationPlanCommand, P as formatSourceDiagnostic, Q as refuseMarkerOutsideGraph, R as liveMarkerUse, U as loadContractSpaceAggregateForCli, V as loadContractSource, W as looksLikePath, X as refuseContractSpaceIntegrity, Y as readMigrationRefs, _ as deriveStatusEdgeAnnotations, _t as toDeclaredExtensionsFromRaw, a as advanceRefSafely, at as resolveContractRefToSnapshot, b as enumerateCheckSpaces, d as buildRefAdvancementFields, et as refusePackageCorruptionOnAggregate, f as checkSingleTarget, ft as runMigrationCheck, g as createControlClient, gt as statusForMigrationHash, h as convertAndDelete, ht as sourceWarningDiagnostic, i as RECORDED_OR_EMPTY_CONTRACT_REF_FORMS, it as resolveContractRef$1, j as executeRefListCommand, l as buildMigrationSpaceGraphEntries, m as contractValidationMeta, mt as snapshotVerifierFor, n as NO_REF_ADVANCEMENT, nt as requireDatabaseForLiveMarkerUse, p as computeRefAdvancementName, pt as runMigrationList, q as migrationSpaceListEntriesFromAggregate, r as RECORDED_CONTRACT_REF_FORMS, rt as resolveAppTargetPath, s as appliedHashesFromLedger, st as resolveMigrationRef, t as ALL_CONTRACT_REF_FORMS, tt as refuseUnknownInvariants, u as buildReadAggregate, ut as retryCommandFor, vt as validateLoadedContract, x as executeContractEmit, z as loadAggregateIntegrityViolations } from "./ref-DLqjHXyn-CsLViutC.mjs";
15
15
  import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BcC8eB0h-C5bRd-aC.mjs";
16
16
  import { createRequire } from "node:module";
17
17
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
18
18
  import { CliStructuredError } from "@prisma/orm-framework/errors/control";
19
- import { APP_SPACE_ID, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, createControlStack, hasPslContractBuild, issueOutcome, migrationSubjectJson } from "@prisma/orm-framework/components/control";
20
- import { InternalError, assertNever, isInternalError } from "@prisma/orm-framework/utils/internal-error";
19
+ import { APP_SPACE_ID, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_SCHEMA_FAILURE, VERIFY_CODE_TARGET_MISMATCH, createControlStack, hasPslContractBuild, issueLabel, migrationSubjectJson, schemaIssuesWhy } from "@prisma/orm-framework/components/control";
20
+ import { InternalError, isInternalError } from "@prisma/orm-framework/utils/internal-error";
21
21
  import { DOCS_BASE, docsUrlFor, isStructuredError, isStructuredErrorCode } from "@prisma/orm-framework/utils/structured-error";
22
22
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "pathe";
23
23
  import { mkdir, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
@@ -40,7 +40,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
40
40
  import stringWidth from "string-width";
41
41
  import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
42
42
  import { build } from "esbuild";
43
- //#region ../../../1-framework/3-tooling/cli/dist/load-config-DAQI6U-B.mjs
43
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-BApVWBt0.mjs
44
44
  /**
45
45
  * `isStructuredError` is the repo's own check, and it is the one that matters here: it holds the
46
46
  * regular expression for a dotted `NAMESPACE.SUBCODE`, so only a code the protocol accepts
@@ -767,270 +767,6 @@ function createContractPrintCommand({ printPsl }) {
767
767
  });
768
768
  }
769
769
  const contractPrintCommand = createContractPrintCommand({ printPsl });
770
- const ABSENT = /^(?:ensure )?(.+?) (?:does not (?:already )?exist|is missing)( on .+)?$/;
771
- const ABSENT_FROM = /^(?:ensure )?(.+?) is absent from (.+)$/;
772
- const PRESENT = /^(?:ensure )?(.+?) exists( on .+)?$/;
773
- /**
774
- * Reads a check description, as the targets write it into an operation's precheck, for whether it expects an object absent or present, so the advice for a failed check can say what it means: `ensure index "x" does not exist`, `ensure column "y" does not exist on "item"`, `collection users does not exist`, `ensure column "x" is missing` and `ensure value "b" is absent from enum type "Mood"` expect it absent; `ensure table "x" exists` and `index exists on users` present. Any other description, `undefined`.
775
- */
776
- function readCheckDescription(description) {
777
- const absent = ABSENT.exec(description);
778
- if (absent?.[1] !== void 0) return {
779
- expects: "absent",
780
- object: `${absent[1]}${absent[2] ?? ""}`
781
- };
782
- const absentFrom = ABSENT_FROM.exec(description);
783
- if (absentFrom?.[1] !== void 0 && absentFrom[2] !== void 0) return {
784
- expects: "absent",
785
- object: `${absentFrom[1]} in ${absentFrom[2]}`
786
- };
787
- const present = PRESENT.exec(description);
788
- if (present?.[1] !== void 0) return {
789
- expects: "present",
790
- object: `${present[1]}${present[2] ?? ""}`
791
- };
792
- }
793
- /** What a failed check before an operation means, in words: which check failed, and what that says of the database. */
794
- function failedPrecheckWhy(report) {
795
- const checked = `Before operation ${report.operationId} runs, it checks: ${report.description}.`;
796
- const reading = readCheckDescription(report.description);
797
- if (reading === void 0) return `${checked} That check failed on this database.`;
798
- return reading.expects === "absent" ? `${checked} That check failed: the database already has ${reading.object}.` : `${checked} That check failed: the database has no ${reading.object}.`;
799
- }
800
- /** The way out of a failed check before an operation of `db migrate`. */
801
- function migrateFailedPrecheckFix(report, invocation) {
802
- const migrate = `\`${cliCommand(invocation, "db migrate")}\``;
803
- return report.planStartsFromMarker ? `The database has drifted from its migration history: it is not in the state the migrations before this one leave. See how it differs from the contract with \`${cliCommand(invocation, "db verify")}\`, change the database or the migration so they agree, and run ${migrate} again.` : `The database has no migration marker, so ${migrate} applies every migration from the first, and the database may already be ahead of this one. If its schema already matches the contract, adopt it with \`${cliCommand(invocation, "db sign")}\` instead.`;
804
- }
805
- /** The way out of a failed check before an operation of `db init`, which runs only on a database with no marker. */
806
- function dbInitFailedPrecheckFix(invocation) {
807
- return `The database already holds part of the schema \`${cliCommand(invocation, "db init")}\` would create. If its schema already matches the contract, adopt it with \`${cliCommand(invocation, "db sign")}\` instead.`;
808
- }
809
- /** What a runner failure says of a type change that failed: who converted the values, and how it failed. */
810
- function failedTypeChangeText(change) {
811
- if (change.by === "cast") return change.reason === "noCast" ? `The database has no cast from the old type of field "${change.field}" to its new type.` : `A value of field "${change.field}" cannot be converted to its new type by the database's cast.`;
812
- switch (change.reason) {
813
- case "value": return `The conversion of field "${change.field}" failed on a value its new type cannot hold.`;
814
- case "invalidResult": return `The conversion of field "${change.field}" left a value its new type cannot hold.`;
815
- case "expressionError": return `The conversion of field "${change.field}" failed with an error in its expression.`;
816
- }
817
- }
818
- function migrationPlanCommand$1(invocation, flags, from) {
819
- return `\`${printedPlanCommand(invocation, from, flags)}\``;
820
- }
821
- /** A `db migrate` command as advice prints it. */
822
- function dbMigrateCommand(invocation) {
823
- return `\`${cliCommand(invocation, "db migrate")}\``;
824
- }
825
- /** The step between filling a planned migration.ts and applying it, which writes its operations. */
826
- const RUN_PLANNED_FILE = "run that migration.ts with the `node` command `migration plan` prints";
827
- function backfillFlags(reports) {
828
- return [...new Set(reports.flatMap(({ field }) => field === void 0 ? [] : [statementFlag({
829
- verb: "backfill",
830
- text: field
831
- })]))];
832
- }
833
- /** The way out of a failed cast for `db update`, which plans and applies in one step. */
834
- function dbUpdateFailedTypeChangeFix(change, databaseStorageHash, invocation) {
835
- const plan = migrationPlanCommand$1(invocation, [statementFlag({
836
- verb: "convert",
837
- text: change.field
838
- })], databaseStorageHash);
839
- return `${failedTypeChangeText(change)} Plan the change with ${plan}, write the conversion in the migration.ts it writes, ${RUN_PLANNED_FILE}, and apply it with ${dbMigrateCommand(invocation)}.`;
840
- }
841
- /** The way out of rows without a value for `db update`, which plans and applies in one step. */
842
- function dbUpdateRowsWithoutValueFix(reports, databaseStorageHash, invocation) {
843
- const flags = backfillFlags(reports);
844
- const plan = flags.length === 0 ? void 0 : `${migrationPlanCommand$1(invocation, flags, databaseStorageHash)}, fill the backfill steps in the migration.ts it writes, ${RUN_PLANNED_FILE}, and apply it with ${dbMigrateCommand(invocation)}`;
845
- if (reports[0]?.reason === "nullValues") {
846
- const keep = "Set a value in those rows, or keep the field optional.";
847
- return plan === void 0 ? keep : `${keep} Or plan it with ${plan}.`;
848
- }
849
- return plan === void 0 ? "Make the field optional." : `Plan it with ${plan}. Or make the field optional.`;
850
- }
851
- /**
852
- * The way out of rows without a value for `db init`: a migration plan needs an origin contract,
853
- * which a database that `db init` never initialized does not have.
854
- */
855
- function dbInitRowsWithoutValueFix(reports, invocation) {
856
- const field = reports[0]?.field;
857
- const subject = field === void 0 ? "it" : `field "${field}"`;
858
- return `Run \`${cliCommand(invocation, "db init")}\` with ${subject} optional. Then make it required with \`${cliCommand(invocation, "db update")}\`, which says how to give the rows a value.`;
859
- }
860
- function failedMigrationText(failed, invocation) {
861
- const dirName = basename(failed.directory);
862
- return {
863
- directory: printedPath(invocation, failed.directory),
864
- name: dirName.slice(dirName.indexOf("_") + 1),
865
- from: failed.from === "empty" ? void 0 : failed.from,
866
- nodeCommand: selfEmitCommand(invocation, join(failed.directory, "migration.ts")),
867
- invocation
868
- };
869
- }
870
- function replan(flags, failed, except = void 0) {
871
- const others = except === void 0 ? "its other statements" : `its other statements except any ${except}`;
872
- const plan = migrationPlanCommand$1(failed.invocation, [
873
- "--name",
874
- failed.name,
875
- ...flags
876
- ], failed.from);
877
- return `delete \`${failed.directory}\` (copy any code you wrote in its migration.ts first), plan it again with ${plan} and ${others}, fill in the migration.ts it writes, ${RUN_PLANNED_FILE}, and run ${dbMigrateCommand(failed.invocation)}`;
878
- }
879
- /**
880
- * Where to fix code written in the failed migration's `migration.ts`, and the command that runs the
881
- * file again.
882
- */
883
- function failedMigrationFile(failedMigration) {
884
- if (failedMigration === void 0) return {
885
- file: "the migration.ts of the failed migration",
886
- run: "run that file with node"
887
- };
888
- return {
889
- file: `\`${failedMigration.directory}/migration.ts\``,
890
- run: `run \`${failedMigration.nodeCommand}\``
891
- };
892
- }
893
- function migrateFailedTypeChangeFix(change, failedMigration, invocation) {
894
- if (change.by === "conversion") {
895
- const { file, run } = failedMigrationFile(failedMigration);
896
- return `${failedTypeChangeText(change)} The failed apply changed nothing. Fix the conversion in ${file}, ${run}, and re-run ${dbMigrateCommand(invocation)}.`;
897
- }
898
- const convert = statementFlag({
899
- verb: "convert",
900
- text: change.field
901
- });
902
- if (failedMigration === void 0) return `${failedTypeChangeText(change)} Plan the type change again with ${migrationPlanCommand$1(invocation, [convert], void 0)}, write the conversion in the migration.ts it writes, ${RUN_PLANNED_FILE}, and apply it with ${dbMigrateCommand(invocation)}.`;
903
- const deleted = `\`${statementFlag({
904
- verb: "delete",
905
- text: change.field
906
- })}\``;
907
- const { file, run } = failedMigrationFile(failedMigration);
908
- return `${failedTypeChangeText(change)} The failed apply changed nothing. ${file} has no conversion for field "${change.field}": write one there, ${run}, and re-run ${dbMigrateCommand(invocation)}. Or ${replan([convert], failedMigration, deleted)}.`;
909
- }
910
- function migrateRowsWithoutValueFix(reports, failedMigration, invocation) {
911
- const [first] = reports;
912
- if (first?.reason === "backfillMissedRows") {
913
- const { file, run } = failedMigrationFile(failedMigration);
914
- return `${first.field === void 0 ? "The backfill step" : `The backfill step of field "${first.field}"`} left those rows without a value, and the failed apply changed nothing. Make its run fill every row in ${file}, ${run}, and re-run ${dbMigrateCommand(invocation)}.`;
915
- }
916
- const flags = backfillFlags(reports);
917
- const again = flags.length === 0 || failedMigration === void 0 ? void 0 : replan(flags, failedMigration);
918
- if (reports.every(({ reason }) => reason === "nullValues")) {
919
- const rerun = reports.length === 1 ? `Set a value in those rows and re-run ${dbMigrateCommand(invocation)}.` : `Set a value in the rows that hold NULL in each of ${fieldList(reports)} and re-run ${dbMigrateCommand(invocation)}.`;
920
- const keep = failedMigration === void 0 ? `Or keep ${reports.length === 1 ? "the field" : "those fields"} optional, and plan the migration again.` : `Or keep ${reports.length === 1 ? "the field" : "those fields"} optional: make ${reports.length === 1 ? "it" : "them"} optional in the contract again, delete \`${failedMigration.directory}\` (copy any code you wrote in its migration.ts first), and plan it again with ${migrationPlanCommand$1(invocation, ["--name", failedMigration.name], failedMigration.from)} and its other statements, put back any code you copied, ${RUN_PLANNED_FILE}, and apply it with ${dbMigrateCommand(invocation)}.`;
921
- return [
922
- rerun,
923
- ...again === void 0 ? [] : [`Or ${again}.`],
924
- keep
925
- ].join(" ");
926
- }
927
- if (reports[0]?.reason === "nullValues") return again === void 0 ? "The migration also adds a required field the existing rows have no value for, so setting values is not enough: make the new fields optional, and plan the migration again." : `The migration also adds a required field the existing rows have no value for, so setting values is not enough. The failed apply changed nothing: ${again}.`;
928
- return again === void 0 ? "Make the field optional, and plan the migration again." : `The failed apply changed nothing. To keep the field required, ${again}. Or make the field optional, and plan it again.`;
929
- }
930
- function fieldList(reports) {
931
- return reports.map(({ field }) => field === void 0 ? void 0 : `"${field}"`).filter((field) => field !== void 0).join(", ");
932
- }
933
- function migrateSchemaCheckFix(failedMigration, invocation) {
934
- const emit = `\`${cliCommand(invocation, "contract emit")}\``;
935
- if (failedMigration === void 0) return `The failed apply changed nothing. Change the contract source to resolve the issues listed, re-run ${emit}, delete the failed migration's directory (copy any code you wrote in its migration.ts first), plan it again with ${migrationPlanCommand$1(invocation, [], void 0)}, put any code you copied into the migration.ts it writes, ${RUN_PLANNED_FILE}, and run ${dbMigrateCommand(invocation)}.`;
936
- const plan = migrationPlanCommand$1(invocation, ["--name", failedMigration.name], failedMigration.from);
937
- return `The failed apply changed nothing. Change the contract source to resolve the issues listed, re-run ${emit}, delete \`${failedMigration.directory}\` (copy any code you wrote in its migration.ts first), plan it again with ${plan}, put any code you copied into the migration.ts it writes, ${RUN_PLANNED_FILE}, and run ${dbMigrateCommand(invocation)}.`;
938
- }
939
- /**
940
- * The way out of a failed `db migrate` apply: every path and command it prints works from where the
941
- * CLI ran, with the `--config` it was given.
942
- */
943
- function migrateFix(failure, invocation) {
944
- const failedMigration = failure.failedMigration === void 0 ? void 0 : failedMigrationText(failure.failedMigration, invocation);
945
- if (failure.failedTypeChange !== void 0) return migrateFailedTypeChangeFix(failure.failedTypeChange, failedMigration, invocation);
946
- if (failure.rowsWithoutValue !== void 0) return migrateRowsWithoutValueFix(failure.rowsWithoutValue, failedMigration, invocation);
947
- if (failure.schemaIssues !== void 0) return migrateSchemaCheckFix(failedMigration, invocation);
948
- if (failure.failedPrecheck !== void 0) return migrateFailedPrecheckFix(failure.failedPrecheck, invocation);
949
- return `Fix the issue and re-run \`${cliCommand(invocation, "db migrate", ["--to", "<contract>"])}\` — previously applied migrations are preserved.`;
950
- }
951
- const OUTCOME_LABEL = {
952
- "not-found": "missing",
953
- "not-expected": "extra",
954
- "not-equal": "mismatch"
955
- };
956
- /** What a diff issue says, in the words the commander shell used. */
957
- function issueLabel(issue) {
958
- const label = `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join("/")}`;
959
- return issue.explanation === void 0 ? label : `${label}. ${issue.explanation.text}`;
960
- }
961
- /** The issues of a failed schema check, as one sentence for a diagnostic's why, after `opening`. */
962
- function schemaIssuesWhy(opening, issues) {
963
- return `${opening}: ${issues.map((issue) => issueLabel(issue).replace(/\.$/, "")).join("; ")}.`;
964
- }
965
- /** The why of a failed schema check after apply, listing its issues as `db verify` does; `undefined` when the failure is another. */
966
- function schemaCheckWhy(issues) {
967
- return issues === void 0 ? void 0 : schemaIssuesWhy("The schema check after apply found", issues);
968
- }
969
- const DB_INIT_ADDITIVE_ONLY_FIX = "`db init` applies only additive changes. Run `{bin} db update`, which also applies widening and destructive ones once you answer what each operation that would lose data means, with `--delete` or `--rename`.";
970
- const DB_INIT_NEEDS_MIGRATION_FIX = "`db init` applies only additive changes, and `db update` does not apply data operations. Plan a migration with `{bin} migration plan`, which can include them, and apply it with `{bin} db migrate`.";
971
- /**
972
- * What to do instead of `db init` when its additive-only policy refused operations of the given classes: `db update` when its policy allows all of them, otherwise a planned migration.
973
- */
974
- function adviceForRefusedClasses(refused) {
975
- const allowedByDbUpdate = new Set(DB_UPDATE_POLICY.allowedOperationClasses);
976
- if (![...refused].every((operationClass) => allowedByDbUpdate.has(operationClass))) return {
977
- fix: DB_INIT_NEEDS_MIGRATION_FIX,
978
- nextAction: runCommandAction("Plan a migration, since db update does not apply data operations", "{bin} migration plan")
979
- };
980
- return {
981
- fix: DB_INIT_ADDITIVE_ONLY_FIX,
982
- nextAction: runCommandAction(refused.has("destructive") ? "Apply the change with db update, which asks what each operation that would lose data means" : "Apply the change with db update", "{bin} db update")
983
- };
984
- }
985
- function markerMismatchDetail(failure) {
986
- const parts = [];
987
- if (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) parts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);
988
- if (failure.marker?.profileHash !== failure.destination?.profileHash && failure.marker?.profileHash && failure.destination?.profileHash) parts.push(`profileHash (marker: ${failure.marker.profileHash}, destination: ${failure.destination.profileHash})`);
989
- return parts.length > 0 ? ` Mismatch in ${parts.join(" and ")}.` : "";
990
- }
991
- /**
992
- * A `db init` failure as the CLI's structured error.
993
- *
994
- * The `assertNever` is deliberate: a control-API failure code this does not
995
- * handle must stop the command rather than degrade into a generic message.
996
- */
997
- function mapDbInitFailure(failure, invocation) {
998
- if (failure.code === "PLANNING_FAILED") {
999
- const conflicts = failure.conflicts ?? [];
1000
- const planningFailed = errorMigrationPlanningFailed({ conflicts });
1001
- const refused = new Set(conflicts.flatMap((conflict) => conflict.refusedOperationClass === void 0 ? [] : [conflict.refusedOperationClass]));
1002
- if (refused.size === 0) return planningFailed;
1003
- const { fix, nextAction } = adviceForRefusedClasses(refused);
1004
- return new ActionableCliError(planningFailed.code, planningFailed.message, {
1005
- why: planningFailed.why ?? "",
1006
- fix,
1007
- nextActions: [nextAction],
1008
- ...ifDefined("meta", planningFailed.meta),
1009
- ...ifDefined("docsUrl", planningFailed.docsUrl)
1010
- });
1011
- }
1012
- if (failure.code === "MIGRATION.MARKER_ORIGIN_MISMATCH") return errorRuntime("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing database signature does not match plan destination.${markerMismatchDetail(failure)}`, {
1013
- why: "Database has an existing signature (marker) that does not match the target contract",
1014
- fix: "If bootstrapping, drop/reset the database then re-run `{bin} db init`; otherwise reconcile schema/marker using your migration workflow",
1015
- meta: {
1016
- ...ifDefined("markerStorageHash", failure.marker?.storageHash),
1017
- ...ifDefined("destinationStorageHash", failure.destination?.storageHash),
1018
- ...ifDefined("markerProfileHash", failure.marker?.profileHash),
1019
- ...ifDefined("destinationProfileHash", failure.destination?.profileHash)
1020
- }
1021
- });
1022
- if (failure.code === "RUNNER_FAILED") {
1023
- const fix = failure.rowsWithoutValue !== void 0 ? dbInitRowsWithoutValueFix(failure.rowsWithoutValue, invocation) : failure.schemaIssues !== void 0 ? "Change the contract source to resolve the issues listed, re-run `{bin} contract emit`, then re-run `{bin} db init`." : failure.failedPrecheck !== void 0 ? dbInitFailedPrecheckFix(invocation) : "Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `{bin} db init`";
1024
- return errorRunnerFailed(failure.summary, {
1025
- why: schemaCheckWhy(failure.schemaIssues) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
1026
- fix,
1027
- ...ifDefined("meta", failure.meta),
1028
- ...ifDefined("cause", failure.cause)
1029
- });
1030
- }
1031
- const exhaustive = failure.code;
1032
- return assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);
1033
- }
1034
770
  /**
1035
771
  * Render a single statement of an `OperationPreview` for the human-readable
1036
772
  * preview block. SQL statements get a trailing `;` if missing so the rendered
@@ -1163,10 +899,7 @@ function previewBlocks$2(preview) {
1163
899
  lines: statements
1164
900
  }];
1165
901
  }
1166
- /**
1167
- * What the planner flagged without refusing to plan it. Only `db update`
1168
- * produces these — the additive-only policies cannot reach the branch.
1169
- */
902
+ /** What the planner flagged without refusing to plan it. */
1170
903
  function plannerWarningBlocks(result) {
1171
904
  const warnings = result.warnings ?? [];
1172
905
  if (warnings.length === 0) return [];
@@ -1326,6 +1059,27 @@ function migrationResultBlocks(result, invocation, databaseStorageHash) {
1326
1059
  function migrationResultNextActions(result, invocation, applyCommand) {
1327
1060
  return result.mode === "plan" ? [runCommandAction("Apply the planned operations", applyCommand)] : [runCommandAction(result.perSpace !== void 0 && result.perSpace.length === 1 ? "Confirm the space is up to date" : "Confirm every space is up to date", cliCommand(invocation, "migration status"))];
1328
1061
  }
1062
+ /**
1063
+ * Collects the planner's warnings a run hands to `onPlannerWarnings`. A failed run reports them as
1064
+ * `warn` messages, which reach the human and the `--json` output; a successful one lists them in
1065
+ * its result.
1066
+ */
1067
+ function plannerWarningsCollector(report) {
1068
+ let collected = [];
1069
+ return {
1070
+ onPlannerWarnings: (warnings) => {
1071
+ collected = warnings;
1072
+ },
1073
+ collected: () => collected,
1074
+ reportCollected: () => {
1075
+ for (const warning of collected) report({
1076
+ kind: "message",
1077
+ severity: "warn",
1078
+ text: warning.summary
1079
+ });
1080
+ }
1081
+ };
1082
+ }
1329
1083
  /** Reads the emitted contract as the raw document the control API validates. */
1330
1084
  async function readContractDocument(contractPath) {
1331
1085
  let content;
@@ -1433,6 +1187,7 @@ function initDocument(inputs) {
1433
1187
  ...ifDefined("perSpace", value.perSpace),
1434
1188
  advancedRef: inputs.advancedRef,
1435
1189
  plannedAdvanceRef: inputs.plannedAdvanceRef,
1190
+ ...inputs.plannerWarnings.length > 0 ? { warnings: inputs.plannerWarnings } : {},
1436
1191
  summary: value.summary,
1437
1192
  timings: { total: Date.now() - inputs.startedAt }
1438
1193
  };
@@ -1491,13 +1246,19 @@ function createDbInitCommand(createClient) {
1491
1246
  let document;
1492
1247
  try {
1493
1248
  await client.connect(dbConnection);
1249
+ const plannerWarnings = plannerWarningsCollector(ctx.report);
1494
1250
  const result = await client.dbInit({
1495
1251
  contract: contractJson,
1496
1252
  mode: args.flags.dryRun ? "plan" : "apply",
1497
1253
  migrationsDir,
1254
+ invocation: cliInvocation(ctx, args.flags.db),
1255
+ onPlannerWarnings: plannerWarnings.onPlannerWarnings,
1498
1256
  onProgress: controlProgressReporter(ctx.report)
1499
1257
  });
1500
- if (!result.ok) return notOk$1(normalizeError(mapDbInitFailure(result.failure, cliInvocation(ctx, args.flags.db))));
1258
+ if (!result.ok) {
1259
+ plannerWarnings.reportCollected();
1260
+ return notOk$1(normalizeError(result.failure));
1261
+ }
1501
1262
  const advancementHash = result.value.mode === "apply" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;
1502
1263
  const advanced = advancement === null ? ok$1(NO_REF_ADVANCEMENT) : await buildRefAdvancementFields({
1503
1264
  name: advancement.name,
@@ -1513,7 +1274,8 @@ function createDbInitCommand(createClient) {
1513
1274
  targetId: ctx.config.target.targetId,
1514
1275
  advancedRef: advanced.value.advancedRef,
1515
1276
  plannedAdvanceRef: advanced.value.plannedAdvanceRef,
1516
- startedAt
1277
+ startedAt,
1278
+ plannerWarnings: plannerWarnings.collected()
1517
1279
  });
1518
1280
  } catch (error) {
1519
1281
  if (!CliStructuredError$1$1.is(error) && isStructuredError(error) && error.code === "CONTRACT.VALIDATION_FAILED") return notOk$1(normalizeError(errorContractValidationFailed(`Contract validation failed: ${error.message}`, {
@@ -2327,29 +2089,6 @@ function createDbSignCommand(createClient = createControlClient) {
2327
2089
  }
2328
2090
  const dbSignCommand = createDbSignCommand();
2329
2091
  /**
2330
- * A `db update` failure as the CLI's structured error.
2331
- *
2332
- * The `assertNever` is deliberate: a control-API failure code this does not
2333
- * handle must stop the command rather than degrade into a generic message.
2334
- */
2335
- function mapDbUpdateFailure(failure, invocation) {
2336
- if (failure.code === "PLANNING_FAILED") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });
2337
- if (failure.code === "RUNNER_FAILED") {
2338
- const fix = failure.failedTypeChange !== void 0 ? dbUpdateFailedTypeChangeFix(failure.failedTypeChange, failure.databaseStorageHash, invocation) : failure.rowsWithoutValue !== void 0 ? dbUpdateRowsWithoutValueFix(failure.rowsWithoutValue, failure.databaseStorageHash, invocation) : failure.schemaIssues !== void 0 ? `Change the contract source to resolve the issues listed, re-run \`${cliCommand(invocation, "contract emit")}\`, then re-run \`${cliCommand(invocation, "db update")}\`.` : `Inspect the reported conflict, reconcile schema drift if needed, then re-run \`${cliCommand(invocation, "db update")}\``;
2339
- return errorRunnerFailed(failure.summary, {
2340
- why: schemaCheckWhy(failure.schemaIssues) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
2341
- fix,
2342
- meta: {
2343
- ...failure.meta,
2344
- ...failure.warnings && failure.warnings.length > 0 ? { plannerWarnings: failure.warnings } : {}
2345
- },
2346
- ...ifDefined("cause", failure.cause)
2347
- });
2348
- }
2349
- const exhaustive = failure.code;
2350
- return assertNever(exhaustive, `Unhandled DbUpdateFailure code: ${String(exhaustive)}`);
2351
- }
2352
- /**
2353
2092
  * Asks a plan's questions through the engine's statement prompt, all in one batch that refuses a
2354
2093
  * statement nothing consumed before the command acts. Flags answer first; where nobody can answer,
2355
2094
  * the engine refuses and lists every question.
@@ -2515,7 +2254,7 @@ function updateDocument(inputs) {
2515
2254
  dataLoss: dataLossEntriesJson(value.dataLoss, inputs.statements),
2516
2255
  accessWidening: accessEntriesJson(value.accessWidening, inputs.statements)
2517
2256
  } : {},
2518
- ...ifDefined("warnings", value.warnings),
2257
+ ...inputs.plannerWarnings.length > 0 ? { warnings: inputs.plannerWarnings } : {},
2519
2258
  advancedRef: inputs.advancedRef,
2520
2259
  plannedAdvanceRef: inputs.plannedAdvanceRef,
2521
2260
  summary: value.summary,
@@ -2641,24 +2380,20 @@ function createDbUpdateCommand(createClient) {
2641
2380
  let databaseStorageHash;
2642
2381
  try {
2643
2382
  await client.connect(dbConnection);
2644
- const reportPlannerWarnings = (warnings) => {
2645
- for (const warning of warnings) ctx.report({
2646
- kind: "message",
2647
- severity: "warn",
2648
- text: warning.summary
2649
- });
2650
- };
2383
+ const plannerWarnings = plannerWarningsCollector(ctx.report);
2651
2384
  const result = await client.dbUpdate({
2652
2385
  contract: contractJson,
2653
2386
  mode,
2654
2387
  migrationsDir,
2655
2388
  statements: [...renames, ...previewConsents],
2656
2389
  answerQuestions: promptPlanQuestions(ctx.prompt),
2390
+ invocation: cliInvocation(ctx, args.flags.db),
2391
+ onPlannerWarnings: plannerWarnings.onPlannerWarnings,
2657
2392
  onProgress: controlProgressReporter(ctx.report)
2658
2393
  });
2659
2394
  if (!result.ok) {
2660
- reportPlannerWarnings(result.failure.warnings ?? []);
2661
- return notOk$1(normalizeError(mapDbUpdateFailure(result.failure, cliInvocation(ctx, args.flags.db))));
2395
+ plannerWarnings.reportCollected();
2396
+ return notOk$1(normalizeError(result.failure));
2662
2397
  }
2663
2398
  const advancementHash = result.value.mode === "apply" ? result.value.marker?.storageHash ?? result.value.destination.storageHash : result.value.destination.storageHash;
2664
2399
  const advanced = advancement === null ? ok$1(NO_REF_ADVANCEMENT) : await buildRefAdvancementFields({
@@ -2677,7 +2412,8 @@ function createDbUpdateCommand(createClient) {
2677
2412
  advancedRef: advanced.value.advancedRef,
2678
2413
  plannedAdvanceRef: advanced.value.plannedAdvanceRef,
2679
2414
  startedAt,
2680
- statements: previewConsents
2415
+ statements: previewConsents,
2416
+ plannerWarnings: plannerWarnings.collected()
2681
2417
  });
2682
2418
  } catch (error) {
2683
2419
  if (error instanceof CliStructuredError$1) throw error;
@@ -7224,7 +6960,7 @@ const lspCommand = defineServerCommand({
7224
6960
  } },
7225
6961
  handler: async (args, io) => {
7226
6962
  const exitCode = await withoutClientProcessIdInArgv(async () => {
7227
- const { startServer } = await import("./exports-CiTltjML.mjs");
6963
+ const { startServer } = await import("./exports-CfQzEu2x.mjs");
7228
6964
  return startServer({
7229
6965
  stdin: io.stdin,
7230
6966
  stdout: io.stdout,
@@ -9456,19 +9192,6 @@ function migrateShowRunListRows(migrations, rendering, options) {
9456
9192
  const listDirNameWidth = gutter + Math.max(rendering.runListDirNameWidth + LABEL_GAP, MIN_HASH_DATA_COLUMN - gutter) - (multiSpace ? LIST_INDENT : LIST_INDENT * 2);
9457
9193
  return migrations.map((migration) => ` ${formatOnPathMigrationRow(migration.dirName, migration.from, migration.to, listDirNameWidth, options.colorize, options.glyphMode, paintOverrides(options))}`);
9458
9194
  }
9459
- /**
9460
- * A `migrate` apply failure as the CLI's structured error; its advice prints paths and commands
9461
- * that work from where the CLI ran, with the `--config` it was given.
9462
- */
9463
- function mapMigrateFailure(failure, invocation) {
9464
- if (failure.code === "MIGRATION_PATH_NOT_FOUND") return errorPathUnreachable(failure);
9465
- return errorRunnerFailed(failure.summary, {
9466
- why: schemaCheckWhy(failure.schemaIssues) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
9467
- fix: migrateFix(failure, invocation),
9468
- meta: failure.meta ?? {},
9469
- ...ifDefined("cause", failure.cause)
9470
- });
9471
- }
9472
9195
  function statusAction(invocation) {
9473
9196
  return runCommandAction("Check every space against the database", cliCommand(invocation, "migration status"));
9474
9197
  }
@@ -9777,12 +9500,13 @@ function createMigrateCommand(createClient) {
9777
9500
  const applied = await client.migrate({
9778
9501
  contract: applyContract,
9779
9502
  migrationsDir,
9503
+ invocation: cliInvocation(ctx, args.flags.db),
9780
9504
  onProgress: controlProgressReporter(ctx.report),
9781
9505
  ...ifDefined("refHash", refEntry?.hash),
9782
9506
  ...refEntry?.invariants === void 0 ? {} : { refInvariants: refEntry.invariants },
9783
9507
  ...ifDefined("refName", target.refName)
9784
9508
  });
9785
- if (!applied.ok) return notOk$1(normalizeError(mapMigrateFailure(applied.failure, cliInvocation(ctx, args.flags.db))));
9509
+ if (!applied.ok) return notOk$1(normalizeError(applied.failure));
9786
9510
  const { value } = applied;
9787
9511
  let advancedRef = null;
9788
9512
  if (advancement !== null) {