@prisma/orm-toolchain 8.0.0-rc.18-dev.22 → 8.0.0-rc.18-dev.24

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.
package/dist/cli.mjs CHANGED
@@ -11,7 +11,7 @@ import { d as writeRef, r as readRef } from "./refs-BIzM-guE-qMvITMOL.mjs";
11
11
  import { a as contractHashAtMarker } from "./aggregate-C0qscKli.mjs";
12
12
  import { i as createScaffoldSpecifierResolver } from "./import-roots-DXD7fung.mjs";
13
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-C4HTKAnF-4Opkr4ZP.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-CMuiuRq8-DQRCjbrc.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";
@@ -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-BvLuytQm.mjs
43
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-DVbHe84W.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
@@ -805,50 +805,6 @@ function migrateFailedPrecheckFix(report, invocation) {
805
805
  function dbInitFailedPrecheckFix(invocation) {
806
806
  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.`;
807
807
  }
808
- const OUTCOME_LABEL = {
809
- "not-found": "missing",
810
- "not-expected": "extra",
811
- "not-equal": "mismatch"
812
- };
813
- const MISMATCH_CAUSES = {
814
- differs: true,
815
- "possibly-equivalent": true
816
- };
817
- /** What a diff issue says, in the words the commander shell used. */
818
- function issueLabel(issue) {
819
- const label = `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join("/")}`;
820
- return issue.explanation === void 0 ? label : `${label}. ${issue.explanation.text}`;
821
- }
822
- /** The issues of a failed schema check, as one sentence for a diagnostic's why, after `opening`. */
823
- function schemaIssuesWhy(opening, issues) {
824
- return `${opening}: ${issues.map((issue) => issueLabel(issue).replace(/\.$/, "")).join("; ")}.`;
825
- }
826
- /**
827
- * The issues a runner failure of its schema check after apply carries in its meta, or `undefined`
828
- * for another failure, or when the meta holds no issue the CLI can read.
829
- */
830
- function runnerSchemaIssues(meta) {
831
- if (meta?.["runnerErrorCode"] !== "MIGRATION.SCHEMA_VERIFY_FAILED") return void 0;
832
- const issues = meta["issues"];
833
- return Array.isArray(issues) && issues.length > 0 && issues.every(isSchemaDiffIssue) ? issues : void 0;
834
- }
835
- /** The why of a runner failure of its schema check after apply, listing the issues as `db verify` does. */
836
- function runnerSchemaCheckWhy(meta) {
837
- const issues = runnerSchemaIssues(meta);
838
- return issues === void 0 ? void 0 : schemaIssuesWhy("The schema check after apply found", issues);
839
- }
840
- function isSchemaDiffIssue(value) {
841
- if (typeof value !== "object" || value === null) return false;
842
- if (!("path" in value) || !Array.isArray(value.path)) return false;
843
- if (!value.path.every((step) => typeof step === "string")) return false;
844
- const expected = "expected" in value ? value.expected : void 0;
845
- const actual = "actual" in value ? value.actual : void 0;
846
- if (expected === void 0 && actual === void 0) return false;
847
- return !("explanation" in value) || isMismatchExplanation(value.explanation);
848
- }
849
- function isMismatchExplanation(value) {
850
- return typeof value === "object" && value !== null && "text" in value && typeof value.text === "string" && "cause" in value && typeof value.cause === "string" && Object.hasOwn(MISMATCH_CAUSES, value.cause);
851
- }
852
808
  /** What a runner failure says of a type change that failed: who converted the values, and how it failed. */
853
809
  function failedTypeChangeText(change) {
854
810
  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.`;
@@ -987,10 +943,28 @@ function migrateFix(failure, invocation) {
987
943
  const failedMigration = failure.failedMigration === void 0 ? void 0 : failedMigrationText(failure.failedMigration, invocation);
988
944
  if (failure.failedTypeChange !== void 0) return migrateFailedTypeChangeFix(failure.failedTypeChange, failedMigration, invocation);
989
945
  if (failure.rowsWithoutValue !== void 0) return migrateRowsWithoutValueFix(failure.rowsWithoutValue, failedMigration, invocation);
990
- if (runnerSchemaIssues(failure.meta) !== void 0) return migrateSchemaCheckFix(failedMigration, invocation);
946
+ if (failure.schemaIssues !== void 0) return migrateSchemaCheckFix(failedMigration, invocation);
991
947
  if (failure.failedPrecheck !== void 0) return migrateFailedPrecheckFix(failure.failedPrecheck, invocation);
992
948
  return `Fix the issue and re-run \`${cliCommand(invocation, "db migrate", ["--to", "<contract>"])}\` — previously applied migrations are preserved.`;
993
949
  }
950
+ const OUTCOME_LABEL = {
951
+ "not-found": "missing",
952
+ "not-expected": "extra",
953
+ "not-equal": "mismatch"
954
+ };
955
+ /** What a diff issue says, in the words the commander shell used. */
956
+ function issueLabel(issue) {
957
+ const label = `${OUTCOME_LABEL[issueOutcome(issue)]}: ${issue.path.join("/")}`;
958
+ return issue.explanation === void 0 ? label : `${label}. ${issue.explanation.text}`;
959
+ }
960
+ /** The issues of a failed schema check, as one sentence for a diagnostic's why, after `opening`. */
961
+ function schemaIssuesWhy(opening, issues) {
962
+ return `${opening}: ${issues.map((issue) => issueLabel(issue).replace(/\.$/, "")).join("; ")}.`;
963
+ }
964
+ /** The why of a failed schema check after apply, listing its issues as `db verify` does; `undefined` when the failure is another. */
965
+ function schemaCheckWhy(issues) {
966
+ return issues === void 0 ? void 0 : schemaIssuesWhy("The schema check after apply found", issues);
967
+ }
994
968
  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`.";
995
969
  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`.";
996
970
  /**
@@ -1045,10 +1019,9 @@ function mapDbInitFailure(failure, invocation) {
1045
1019
  }
1046
1020
  });
1047
1021
  if (failure.code === "RUNNER_FAILED") {
1048
- const runnerCode = typeof failure.meta?.["runnerErrorCode"] === "string" ? failure.meta["runnerErrorCode"] : void 0;
1049
- const fix = failure.rowsWithoutValue !== void 0 ? dbInitRowsWithoutValueFix(failure.rowsWithoutValue, invocation) : runnerSchemaIssues(failure.meta) !== 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) : runnerCode === "MIGRATION.LEGACY_MARKER_SHAPE" ? "Legacy marker-table shape detected. Drop `prisma_contract.marker` (Postgres) or `_prisma_marker` (SQLite) and re-run `{bin} db init` to recreate it with the current per-space schema." : "Fix the schema mismatch (db init is additive-only), or drop/reset the database and re-run `{bin} db init`";
1022
+ 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`";
1050
1023
  return errorRunnerFailed(failure.summary, {
1051
- why: runnerSchemaCheckWhy(failure.meta) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
1024
+ why: schemaCheckWhy(failure.schemaIssues) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
1052
1025
  fix,
1053
1026
  ...ifDefined("meta", failure.meta),
1054
1027
  ...ifDefined("cause", failure.cause)
@@ -2361,10 +2334,9 @@ const dbSignCommand = createDbSignCommand();
2361
2334
  function mapDbUpdateFailure(failure, invocation) {
2362
2335
  if (failure.code === "PLANNING_FAILED") return errorMigrationPlanningFailed({ conflicts: failure.conflicts ?? [] });
2363
2336
  if (failure.code === "RUNNER_FAILED") {
2364
- const runnerCode = typeof failure.meta?.["runnerErrorCode"] === "string" ? failure.meta["runnerErrorCode"] : void 0;
2365
- const fix = failure.failedTypeChange !== void 0 ? dbUpdateFailedTypeChangeFix(failure.failedTypeChange, failure.databaseStorageHash, invocation) : failure.rowsWithoutValue !== void 0 ? dbUpdateRowsWithoutValueFix(failure.rowsWithoutValue, failure.databaseStorageHash, invocation) : runnerSchemaIssues(failure.meta) !== void 0 ? `Change the contract source to resolve the issues listed, re-run \`${cliCommand(invocation, "contract emit")}\`, then re-run \`${cliCommand(invocation, "db update")}\`.` : runnerCode === "MIGRATION.LEGACY_MARKER_SHAPE" ? `Legacy marker-table shape detected. Drop \`prisma_contract.marker\` (Postgres) or \`_prisma_marker\` (SQLite) and re-run \`${cliCommand(invocation, "db init")}\` to recreate it with the current per-space schema.` : `Inspect the reported conflict, reconcile schema drift if needed, then re-run \`${cliCommand(invocation, "db update")}\``;
2337
+ 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")}\``;
2366
2338
  return errorRunnerFailed(failure.summary, {
2367
- why: runnerSchemaCheckWhy(failure.meta) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
2339
+ why: schemaCheckWhy(failure.schemaIssues) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
2368
2340
  fix,
2369
2341
  meta: {
2370
2342
  ...failure.meta,
@@ -9490,7 +9462,7 @@ function migrateShowRunListRows(migrations, rendering, options) {
9490
9462
  function mapMigrateFailure(failure, invocation) {
9491
9463
  if (failure.code === "MIGRATION_PATH_NOT_FOUND") return errorPathUnreachable(failure);
9492
9464
  return errorRunnerFailed(failure.summary, {
9493
- why: runnerSchemaCheckWhy(failure.meta) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
9465
+ why: schemaCheckWhy(failure.schemaIssues) ?? failure.why ?? (failure.failedPrecheck === void 0 ? "Migration runner failed" : failedPrecheckWhy(failure.failedPrecheck)),
9494
9466
  fix: migrateFix(failure, invocation),
9495
9467
  meta: failure.meta ?? {},
9496
9468
  ...ifDefined("cause", failure.cause)