prisma-next 0.11.0-dev.6 → 0.11.0-dev.8
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-errors-Bw2GlweY.mjs +175 -0
- package/dist/cli-errors-Bw2GlweY.mjs.map +1 -0
- package/dist/cli.mjs +7 -7
- package/dist/{client-oXO2WCPD.mjs → client-UnIveZxZ.mjs} +4 -4
- package/dist/{client-oXO2WCPD.mjs.map → client-UnIveZxZ.mjs.map} +1 -1
- package/dist/{command-helpers-DtavI0wJ.mjs → command-helpers-CRfjbZRz.mjs} +2 -2
- package/dist/{command-helpers-DtavI0wJ.mjs.map → command-helpers-CRfjbZRz.mjs.map} +1 -1
- package/dist/commands/contract-emit.mjs +1 -1
- package/dist/commands/contract-infer.mjs +1 -1
- package/dist/commands/db-init.d.mts.map +1 -1
- package/dist/commands/db-init.mjs +33 -6
- package/dist/commands/db-init.mjs.map +1 -1
- package/dist/commands/db-schema.mjs +3 -3
- package/dist/commands/db-sign.mjs +5 -5
- package/dist/commands/db-update.d.mts.map +1 -1
- package/dist/commands/db-update.mjs +36 -7
- package/dist/commands/db-update.mjs.map +1 -1
- package/dist/commands/db-verify.mjs +1 -1
- package/dist/commands/migrate.d.mts +5 -1
- package/dist/commands/migrate.d.mts.map +1 -1
- package/dist/commands/migrate.mjs +44 -8
- package/dist/commands/migrate.mjs.map +1 -1
- package/dist/commands/migration-check.mjs +2 -2
- package/dist/commands/migration-graph.mjs +3 -3
- package/dist/commands/migration-list.mjs +2 -2
- package/dist/commands/migration-log.mjs +3 -3
- package/dist/commands/migration-new.mjs +3 -3
- package/dist/commands/migration-plan.d.mts +1 -0
- package/dist/commands/migration-plan.d.mts.map +1 -1
- package/dist/commands/migration-plan.mjs +1 -1
- package/dist/commands/migration-show.d.mts +1 -1
- package/dist/commands/migration-show.mjs +6 -6
- package/dist/commands/migration-status.mjs +7 -7
- package/dist/commands/ref.d.mts +1 -1
- package/dist/commands/ref.d.mts.map +1 -1
- package/dist/commands/ref.mjs +34 -8
- package/dist/commands/ref.mjs.map +1 -1
- package/dist/{contract-emit-o-8VmdQX.mjs → contract-emit-C6rlsljO.mjs} +3 -3
- package/dist/{contract-emit-o-8VmdQX.mjs.map → contract-emit-C6rlsljO.mjs.map} +1 -1
- package/dist/{contract-emit-CmsklifJ.mjs → contract-emit-mqXmapxB.mjs} +4 -4
- package/dist/{contract-emit-CmsklifJ.mjs.map → contract-emit-mqXmapxB.mjs.map} +1 -1
- package/dist/{contract-infer-pKkiCt7C.mjs → contract-infer-C4jxc1aZ.mjs} +3 -3
- package/dist/{contract-infer-pKkiCt7C.mjs.map → contract-infer-C4jxc1aZ.mjs.map} +1 -1
- package/dist/{contract-space-aggregate-loader-BmNQwlws.mjs → contract-space-aggregate-loader-CGakRlKM.mjs} +2 -2
- package/dist/{contract-space-aggregate-loader-BmNQwlws.mjs.map → contract-space-aggregate-loader-CGakRlKM.mjs.map} +1 -1
- package/dist/{db-verify-AoIUriL4.mjs → db-verify-1d8tDoFN.mjs} +5 -5
- package/dist/{db-verify-AoIUriL4.mjs.map → db-verify-1d8tDoFN.mjs.map} +1 -1
- package/dist/exports/control-api.d.mts +1 -1
- package/dist/exports/control-api.mjs +2 -2
- package/dist/exports/index.mjs +1 -1
- package/dist/exports/init-output.mjs +1 -1
- package/dist/{framework-components-65gOHkHB.mjs → framework-components-Bexd0f4E.mjs} +2 -2
- package/dist/{framework-components-65gOHkHB.mjs.map → framework-components-Bexd0f4E.mjs.map} +1 -1
- package/dist/{graph-render-DJVv0_uf.mjs → graph-render-BE8vmJ_7.mjs} +1 -1
- package/dist/{graph-render-DJVv0_uf.mjs.map → graph-render-BE8vmJ_7.mjs.map} +1 -1
- package/dist/{init-Db5Itt5r.mjs → init-ByoeQphC.mjs} +4 -4
- package/dist/{init-Db5Itt5r.mjs.map → init-ByoeQphC.mjs.map} +1 -1
- package/dist/{inspect-live-schema-LeWvkZVz.mjs → inspect-live-schema-B1Q49RF0.mjs} +4 -4
- package/dist/{inspect-live-schema-LeWvkZVz.mjs.map → inspect-live-schema-B1Q49RF0.mjs.map} +1 -1
- package/dist/{migration-command-scaffold-BtkunvFQ.mjs → migration-command-scaffold-oY4P1Qto.mjs} +4 -4
- package/dist/{migration-command-scaffold-BtkunvFQ.mjs.map → migration-command-scaffold-oY4P1Qto.mjs.map} +1 -1
- package/dist/{migration-plan-C2jeH1J5.mjs → migration-plan-jdAHg_gK.mjs} +346 -87
- package/dist/migration-plan-jdAHg_gK.mjs.map +1 -0
- package/dist/{migrations-CwZMa1Ck.mjs → migrations-B7n518mT.mjs} +10 -1
- package/dist/migrations-B7n518mT.mjs.map +1 -0
- package/dist/{output-BlsrGMEF.mjs → output-CUIdfYo5.mjs} +1 -1
- package/dist/{output-BlsrGMEF.mjs.map → output-CUIdfYo5.mjs.map} +1 -1
- package/dist/ref-advancement-DRh5Nquq.mjs +50 -0
- package/dist/ref-advancement-DRh5Nquq.mjs.map +1 -0
- package/dist/{types-C9FfXb1l.d.mts → types-UWB2-rrw.d.mts} +5 -4
- package/dist/types-UWB2-rrw.d.mts.map +1 -0
- package/dist/{verify-Bom75OYI.mjs → verify-C5UvbrF1.mjs} +1 -1
- package/dist/{verify-Bom75OYI.mjs.map → verify-C5UvbrF1.mjs.map} +1 -1
- package/package.json +11 -11
- package/dist/cli-errors-Czmx92Zy.d.mts +0 -3
- package/dist/cli-errors-Djtz98Vm.mjs +0 -71
- package/dist/cli-errors-Djtz98Vm.mjs.map +0 -1
- package/dist/migration-plan-C2jeH1J5.mjs.map +0 -1
- package/dist/migrations-CwZMa1Ck.mjs.map +0 -1
- package/dist/types-C9FfXb1l.d.mts.map +0 -1
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { CliStructuredError as CliStructuredError$1, errorConfigValidation as errorConfigValidation$1, errorContractConfigMissing as errorContractConfigMissing$1, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorInvalidOutputFormat, errorMigrationPlanningFailed, errorOutputFormatMutex, errorTargetMigrationNotSupported, errorUnexpected as errorUnexpected$1 } from "@prisma-next/errors/control";
|
|
2
|
+
import { ERROR_CODE_DESTRUCTIVE_CHANGES, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorRunnerFailed, errorRuntime, errorRuntime as errorRuntime$1, errorTargetMismatch } from "@prisma-next/errors/execution";
|
|
3
|
+
import "@prisma-next/errors/migration";
|
|
4
|
+
//#region src/utils/cli-errors.ts
|
|
5
|
+
function errorRefSetHashNotInGraph(resolvedHash, reachableHashes, graphTipHash) {
|
|
6
|
+
const reachableList = reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)";
|
|
7
|
+
const fix = reachableHashes.length > 0 ? graphTipHash !== null ? `Set the ref to a graph-node hash such as ${graphTipHash}, or run \`prisma-next migration plan\` to extend the graph.` : "Set the ref to a hash that appears in the migration graph." : "Run `prisma-next migration plan` first.";
|
|
8
|
+
return errorRuntime(`Resolved contract hash is not in the migration graph: ${resolvedHash}`, {
|
|
9
|
+
why: reachableHashes.length > 0 ? `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.` : "The migration graph is empty — no hashes reachable.",
|
|
10
|
+
fix,
|
|
11
|
+
meta: {
|
|
12
|
+
code: "MIGRATION.HASH_NOT_IN_GRAPH",
|
|
13
|
+
resolvedHash,
|
|
14
|
+
reachableHashes: [...reachableHashes],
|
|
15
|
+
...graphTipHash !== null ? { graphTipHash } : {}
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
function errorRefSetEmptySentinel(hash) {
|
|
20
|
+
return errorRuntime(`Cannot set ref to the empty-database sentinel: ${hash}`, {
|
|
21
|
+
why: "The empty-database sentinel is a planner internal; it is not a valid ref target.",
|
|
22
|
+
fix: "Set the ref to a contract hash from the migration graph, or use another ref name.",
|
|
23
|
+
meta: {
|
|
24
|
+
code: "MIGRATION.REF_SET_EMPTY_SENTINEL",
|
|
25
|
+
hash
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
function errorRefSetBundleNotFound(hash) {
|
|
30
|
+
return errorRuntime(`No migration bundle matches graph-node hash ${hash}`, {
|
|
31
|
+
why: `The hash is a graph node but no on-disk bundle has metadata.to = ${hash}.`,
|
|
32
|
+
fix: "Run `pnpm fixtures:check`, or re-emit the migration that produces this hash so its bundle is restored.",
|
|
33
|
+
meta: {
|
|
34
|
+
code: "MIGRATION.REF_SET_BUNDLE_NOT_FOUND",
|
|
35
|
+
hash
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
function errorPlanForgotTheFlag(resolvedHash, reachableRefs, graphTipHash) {
|
|
40
|
+
const reachableList = reachableRefs.length > 0 ? reachableRefs.map((r) => `${r.name} (${r.hash})`).join(", ") : "(none)";
|
|
41
|
+
const refFix = reachableRefs.length > 0 ? `Run migration plan with ${reachableRefs.map((r) => `--from ${r.name}`).join(" or ")}.` : graphTipHash !== null ? `Run migration plan --from ${graphTipHash}.` : "Commit pending migrations first, then run migration plan.";
|
|
42
|
+
return errorRuntime(`Resolved from-hash is not in the migration graph: ${resolvedHash}`, {
|
|
43
|
+
why: `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.`,
|
|
44
|
+
fix: refFix,
|
|
45
|
+
meta: {
|
|
46
|
+
code: "MIGRATION.HASH_NOT_IN_GRAPH",
|
|
47
|
+
resolvedHash,
|
|
48
|
+
reachableRefs: reachableRefs.map((r) => r.name),
|
|
49
|
+
...graphTipHash !== null ? { graphTipHash } : {}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
function errorSnapshotMissing(identifier, options) {
|
|
54
|
+
const viaRef = options?.viaRef !== false;
|
|
55
|
+
const fix = viaRef ? `Run "prisma-next db update --advance-ref ${identifier}" to repopulate the snapshot, or "prisma-next ref delete ${identifier}" to clear the orphan pointer.` : `No contract source exists for hash "${identifier}" on an empty migration graph. Use --from with a ref name that has a paired snapshot, or run db update first.`;
|
|
56
|
+
return errorRuntime(viaRef ? `Ref "${identifier}" has no paired contract snapshot` : `No contract source for from-hash "${identifier}"`, {
|
|
57
|
+
why: viaRef ? `Ref "${identifier}" exists but its paired snapshot files are missing.` : `Hash "${identifier}" is not a graph node and no paired ref snapshot supplies a contract.`,
|
|
58
|
+
fix,
|
|
59
|
+
meta: {
|
|
60
|
+
code: "MIGRATION.SNAPSHOT_MISSING",
|
|
61
|
+
identifier,
|
|
62
|
+
viaRef
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function errorMarkerMismatch(markerHash, reachableHashes, graphTip) {
|
|
67
|
+
const reachableList = reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)";
|
|
68
|
+
const planFromFix = graphTip !== null ? `Run \`prisma-next migration plan --from ${graphTip}\` if the live marker is canonical and the on-disk graph needs catching up.` : "Run `prisma-next migration plan` if the live marker is canonical and the on-disk graph needs catching up.";
|
|
69
|
+
return errorRuntime("Database marker is not reachable in the on-disk migration graph", {
|
|
70
|
+
why: `DB marker is ${markerHash}, but the on-disk migration graph reaches: ${reachableList}.`,
|
|
71
|
+
fix: [
|
|
72
|
+
planFromFix,
|
|
73
|
+
`Run \`prisma-next ref set db ${markerHash}\` if the on-disk graph is canonical and the local \`db\` ref drifted.`,
|
|
74
|
+
"Investigate whether the database was migrated by an out-of-band process."
|
|
75
|
+
].join("\n"),
|
|
76
|
+
meta: {
|
|
77
|
+
code: "MIGRATION.MARKER_MISMATCH",
|
|
78
|
+
markerHash,
|
|
79
|
+
reachableHashes: [...reachableHashes],
|
|
80
|
+
...graphTip !== null ? { graphTip } : {}
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function errorPathUnreachable(failure) {
|
|
85
|
+
const meta = failure.meta ?? {};
|
|
86
|
+
const fromHash = typeof meta["fromHash"] === "string" ? meta["fromHash"] : null;
|
|
87
|
+
const targetHash = typeof meta["targetHash"] === "string" ? meta["targetHash"] : typeof meta["target"] === "string" ? meta["target"] : null;
|
|
88
|
+
const deadEnds = meta["deadEnds"];
|
|
89
|
+
const deadEndsSuffix = Array.isArray(deadEnds) && deadEnds.length > 0 ? ` Dead-ends: ${deadEnds.map(String).join(", ")}.` : "";
|
|
90
|
+
const planFix = (() => {
|
|
91
|
+
if (fromHash !== null && targetHash !== null) return `Run \`prisma-next migration plan --from ${fromHash} --to ${targetHash}\` to introduce the missing path.`;
|
|
92
|
+
if (targetHash !== null) return `Run \`prisma-next migration plan --to ${targetHash}\` to introduce the missing path.`;
|
|
93
|
+
if (fromHash !== null) return `Run \`prisma-next migration plan --from ${fromHash}\` to introduce the missing path.`;
|
|
94
|
+
return "Run `prisma-next migration plan` to introduce the missing path.";
|
|
95
|
+
})();
|
|
96
|
+
return errorRuntime(failure.summary, {
|
|
97
|
+
why: failure.why ?? `Cannot reach target "${targetHash ?? "<unknown>"}" from current marker "${fromHash ?? "<unknown>"}".${deadEndsSuffix}`,
|
|
98
|
+
fix: [
|
|
99
|
+
"Run `prisma-next migration list` to see the on-disk graph.",
|
|
100
|
+
planFix,
|
|
101
|
+
"Run `prisma-next migration show <bundle>` for any bundle in the path you expected."
|
|
102
|
+
].join("\n"),
|
|
103
|
+
meta: {
|
|
104
|
+
...meta,
|
|
105
|
+
code: "MIGRATION.PATH_UNREACHABLE"
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Maps a `MigrationToolsError` raised by the migration-tools loader/graph
|
|
111
|
+
* surface (`readMigrationPackage`, `readMigrationsDir`, `readRefs`,
|
|
112
|
+
* `resolveRef`, `reconstructGraph`, ...) into a CLI `errorRuntime` envelope.
|
|
113
|
+
*
|
|
114
|
+
* The full `error.details` payload is forwarded into `meta` so machine
|
|
115
|
+
* consumers (`--json`) see structural fields like `dir`, `storedHash`,
|
|
116
|
+
* `computedHash` (for `MIGRATION.HASH_MISMATCH`) alongside the stable
|
|
117
|
+
* `code`. The user-visible `summary`/`why`/`fix` text is unchanged.
|
|
118
|
+
*
|
|
119
|
+
* Callers are expected to gate on `MigrationToolsError.is(error)` first
|
|
120
|
+
* (mirroring the original inline pattern); non-`MigrationToolsError`
|
|
121
|
+
* values are caller-classified (rethrow, wrap with command-specific
|
|
122
|
+
* `errorUnexpected`, etc.).
|
|
123
|
+
*/
|
|
124
|
+
function mapMigrationToolsError(error) {
|
|
125
|
+
return errorRuntime(error.message, {
|
|
126
|
+
why: error.why,
|
|
127
|
+
fix: error.fix,
|
|
128
|
+
meta: {
|
|
129
|
+
code: error.code,
|
|
130
|
+
...error.details ?? {}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Maps a `RefResolutionError` from the contract/migration reference
|
|
136
|
+
* resolver into a CLI structured error envelope.
|
|
137
|
+
*/
|
|
138
|
+
function mapRefResolutionError(error) {
|
|
139
|
+
switch (error.kind) {
|
|
140
|
+
case "not-found": return errorRuntime(`Not a known ${error.grammar} reference: "${error.input}"`, {
|
|
141
|
+
why: `No ${error.grammar} matching "${error.input}" exists in the migration graph or refs index.`,
|
|
142
|
+
fix: error.grammar === "contract" ? "Provide a valid contract hash, ref name, or migration directory name." : "Provide a valid migration directory name or migration hash.",
|
|
143
|
+
meta: {
|
|
144
|
+
input: error.input,
|
|
145
|
+
grammar: error.grammar
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
case "ambiguous": return errorRuntime(`Ambiguous ${error.grammar} reference: "${error.input}"`, {
|
|
149
|
+
why: `"${error.input}" matches multiple ${error.grammar}s: ${error.candidates.join(", ")}`,
|
|
150
|
+
fix: "Provide a longer prefix or use the full hash to disambiguate.",
|
|
151
|
+
meta: {
|
|
152
|
+
input: error.input,
|
|
153
|
+
candidates: error.candidates,
|
|
154
|
+
grammar: error.grammar
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
case "wrong-grammar": return errorRuntime(error.message, {
|
|
158
|
+
why: error.message,
|
|
159
|
+
fix: error.fix,
|
|
160
|
+
meta: {
|
|
161
|
+
input: error.input,
|
|
162
|
+
expectedGrammar: error.expectedGrammar
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
case "invalid-format": return errorRuntime(`Invalid reference format: "${error.input}"`, {
|
|
166
|
+
why: error.reason,
|
|
167
|
+
fix: "Provide a valid contract hash, ref name, or migration directory name.",
|
|
168
|
+
meta: { input: error.input }
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
//#endregion
|
|
173
|
+
export { errorSnapshotMissing as C, mapMigrationToolsError as D, errorUnexpected$1 as E, mapRefResolutionError as O, errorRuntime$1 as S, errorTargetMismatch as T, errorPlanForgotTheFlag as _, errorContractValidationFailed as a, errorRefSetHashNotInGraph as b, errorDriverRequired as c, errorInvalidOutputFormat as d, errorMarkerMismatch as f, errorPathUnreachable as g, errorOutputFormatMutex as h, errorContractConfigMissing$1 as i, errorFileNotFound as l, errorMigrationPlanningFailed as m, ERROR_CODE_DESTRUCTIVE_CHANGES as n, errorDatabaseConnectionRequired as o, errorMarkerMissing as p, errorConfigValidation$1 as r, errorDestructiveChanges as s, CliStructuredError$1 as t, errorHashMismatch as u, errorRefSetBundleNotFound as v, errorTargetMigrationNotSupported as w, errorRunnerFailed as x, errorRefSetEmptySentinel as y };
|
|
174
|
+
|
|
175
|
+
//# sourceMappingURL=cli-errors-Bw2GlweY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-errors-Bw2GlweY.mjs","names":[],"sources":["../src/utils/cli-errors.ts"],"sourcesContent":["/**\n * Re-export all domain error factories from @prisma-next/errors for convenience.\n * CLI-specific errors (e.g., Commander argument validation in the main CLI, or\n * clipanion parse errors in the migration-file CLI) can be added here if needed.\n */\nexport type { CliErrorConflict, CliErrorEnvelope } from '@prisma-next/errors/control';\n\nimport {\n CliStructuredError,\n errorConfigFileNotFound,\n errorConfigValidation,\n errorContractConfigMissing,\n errorContractMissingExtensionPacks,\n errorContractValidationFailed,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorFamilyReadMarkerSqlRequired,\n errorFileNotFound,\n errorInvalidOutputFormat,\n errorMigrationCliInvalidConfigArg,\n errorMigrationCliUnknownFlag,\n errorMigrationPlanningFailed,\n errorOutputFormatMutex,\n errorQueryRunnerFactoryRequired,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n} from '@prisma-next/errors/control';\nimport { errorRuntime } from '@prisma-next/errors/execution';\nimport type { MigrationToolsError } from '@prisma-next/migration-tools/errors';\nimport type { RefResolutionError } from '@prisma-next/migration-tools/ref-resolution';\nimport type { MigrationApplyFailure } from '../control-api/types';\n\nexport {\n ERROR_CODE_DESTRUCTIVE_CHANGES,\n errorDestructiveChanges,\n errorHashMismatch,\n errorMarkerMissing,\n errorMarkerRequired,\n errorRunnerFailed,\n errorRuntime,\n errorSchemaVerificationFailed,\n errorTargetMismatch,\n} from '@prisma-next/errors/execution';\nexport {\n errorMigrationFileMissing,\n errorMigrationInvalidDefaultExport,\n errorMigrationPlanNotArray,\n errorUnfilledPlaceholder,\n placeholder,\n} from '@prisma-next/errors/migration';\nexport {\n CliStructuredError,\n errorConfigFileNotFound,\n errorConfigValidation,\n errorContractConfigMissing,\n errorContractMissingExtensionPacks,\n errorContractValidationFailed,\n errorDatabaseConnectionRequired,\n errorDriverRequired,\n errorFamilyReadMarkerSqlRequired,\n errorFileNotFound,\n errorInvalidOutputFormat,\n errorMigrationCliInvalidConfigArg,\n errorMigrationCliUnknownFlag,\n errorMigrationPlanningFailed,\n errorOutputFormatMutex,\n errorQueryRunnerFactoryRequired,\n errorTargetMigrationNotSupported,\n errorUnexpected,\n};\n\nexport function errorRefSetHashNotInGraph(\n resolvedHash: string,\n reachableHashes: readonly string[],\n graphTipHash: string | null,\n): CliStructuredError {\n const reachableList =\n reachableHashes.length > 0 ? reachableHashes.join(', ') : '(none — migration graph is empty)';\n const fix =\n reachableHashes.length > 0\n ? graphTipHash !== null\n ? `Set the ref to a graph-node hash such as ${graphTipHash}, or run \\`prisma-next migration plan\\` to extend the graph.`\n : 'Set the ref to a hash that appears in the migration graph.'\n : 'Run `prisma-next migration plan` first.';\n return errorRuntime(`Resolved contract hash is not in the migration graph: ${resolvedHash}`, {\n why:\n reachableHashes.length > 0\n ? `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.`\n : 'The migration graph is empty — no hashes reachable.',\n fix,\n meta: {\n code: 'MIGRATION.HASH_NOT_IN_GRAPH',\n resolvedHash,\n reachableHashes: [...reachableHashes],\n ...(graphTipHash !== null ? { graphTipHash } : {}),\n },\n });\n}\n\nexport function errorRefSetEmptySentinel(hash: string): CliStructuredError {\n return errorRuntime(`Cannot set ref to the empty-database sentinel: ${hash}`, {\n why: 'The empty-database sentinel is a planner internal; it is not a valid ref target.',\n fix: 'Set the ref to a contract hash from the migration graph, or use another ref name.',\n meta: {\n code: 'MIGRATION.REF_SET_EMPTY_SENTINEL',\n hash,\n },\n });\n}\n\nexport function errorRefSetBundleNotFound(hash: string): CliStructuredError {\n return errorRuntime(`No migration bundle matches graph-node hash ${hash}`, {\n why: `The hash is a graph node but no on-disk bundle has metadata.to = ${hash}.`,\n fix: 'Run `pnpm fixtures:check`, or re-emit the migration that produces this hash so its bundle is restored.',\n meta: {\n code: 'MIGRATION.REF_SET_BUNDLE_NOT_FOUND',\n hash,\n },\n });\n}\n\nexport function errorPlanForgotTheFlag(\n resolvedHash: string,\n reachableRefs: ReadonlyArray<{ readonly name: string; readonly hash: string }>,\n graphTipHash: string | null,\n): CliStructuredError {\n const reachableList =\n reachableRefs.length > 0\n ? reachableRefs.map((r) => `${r.name} (${r.hash})`).join(', ')\n : '(none)';\n const refFix =\n reachableRefs.length > 0\n ? `Run migration plan with ${reachableRefs.map((r) => `--from ${r.name}`).join(' or ')}.`\n : graphTipHash !== null\n ? `Run migration plan --from ${graphTipHash}.`\n : 'Commit pending migrations first, then run migration plan.';\n return errorRuntime(`Resolved from-hash is not in the migration graph: ${resolvedHash}`, {\n why: `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.`,\n fix: refFix,\n meta: {\n code: 'MIGRATION.HASH_NOT_IN_GRAPH',\n resolvedHash,\n reachableRefs: reachableRefs.map((r) => r.name),\n ...(graphTipHash !== null ? { graphTipHash } : {}),\n },\n });\n}\n\nexport function errorSnapshotMissing(\n identifier: string,\n options?: { readonly viaRef?: boolean },\n): CliStructuredError {\n const viaRef = options?.viaRef !== false;\n const fix = viaRef\n ? `Run \"prisma-next db update --advance-ref ${identifier}\" to repopulate the snapshot, or \"prisma-next ref delete ${identifier}\" to clear the orphan pointer.`\n : `No contract source exists for hash \"${identifier}\" on an empty migration graph. Use --from with a ref name that has a paired snapshot, or run db update first.`;\n return errorRuntime(\n viaRef\n ? `Ref \"${identifier}\" has no paired contract snapshot`\n : `No contract source for from-hash \"${identifier}\"`,\n {\n why: viaRef\n ? `Ref \"${identifier}\" exists but its paired snapshot files are missing.`\n : `Hash \"${identifier}\" is not a graph node and no paired ref snapshot supplies a contract.`,\n fix,\n meta: {\n code: 'MIGRATION.SNAPSHOT_MISSING',\n identifier,\n viaRef,\n },\n },\n );\n}\n\nexport function errorMarkerMismatch(\n markerHash: string,\n reachableHashes: readonly string[],\n graphTip: string | null,\n): CliStructuredError {\n const reachableList =\n reachableHashes.length > 0 ? reachableHashes.join(', ') : '(none — migration graph is empty)';\n const planFromFix =\n graphTip !== null\n ? `Run \\`prisma-next migration plan --from ${graphTip}\\` if the live marker is canonical and the on-disk graph needs catching up.`\n : 'Run `prisma-next migration plan` if the live marker is canonical and the on-disk graph needs catching up.';\n return errorRuntime('Database marker is not reachable in the on-disk migration graph', {\n why: `DB marker is ${markerHash}, but the on-disk migration graph reaches: ${reachableList}.`,\n fix: [\n planFromFix,\n `Run \\`prisma-next ref set db ${markerHash}\\` if the on-disk graph is canonical and the local \\`db\\` ref drifted.`,\n 'Investigate whether the database was migrated by an out-of-band process.',\n ].join('\\n'),\n meta: {\n code: 'MIGRATION.MARKER_MISMATCH',\n markerHash,\n reachableHashes: [...reachableHashes],\n ...(graphTip !== null ? { graphTip } : {}),\n },\n });\n}\n\nexport function errorPathUnreachable(failure: MigrationApplyFailure): CliStructuredError {\n const meta = failure.meta ?? {};\n const fromHash = typeof meta['fromHash'] === 'string' ? meta['fromHash'] : null;\n const targetHash =\n typeof meta['targetHash'] === 'string'\n ? meta['targetHash']\n : typeof meta['target'] === 'string'\n ? meta['target']\n : null;\n const deadEnds = meta['deadEnds'];\n const deadEndsSuffix =\n Array.isArray(deadEnds) && deadEnds.length > 0\n ? ` Dead-ends: ${deadEnds.map(String).join(', ')}.`\n : '';\n const planFix = (() => {\n if (fromHash !== null && targetHash !== null) {\n return `Run \\`prisma-next migration plan --from ${fromHash} --to ${targetHash}\\` to introduce the missing path.`;\n }\n if (targetHash !== null) {\n return `Run \\`prisma-next migration plan --to ${targetHash}\\` to introduce the missing path.`;\n }\n if (fromHash !== null) {\n return `Run \\`prisma-next migration plan --from ${fromHash}\\` to introduce the missing path.`;\n }\n return 'Run `prisma-next migration plan` to introduce the missing path.';\n })();\n return errorRuntime(failure.summary, {\n why:\n failure.why ??\n `Cannot reach target \"${targetHash ?? '<unknown>'}\" from current marker \"${fromHash ?? '<unknown>'}\".${deadEndsSuffix}`,\n fix: [\n 'Run `prisma-next migration list` to see the on-disk graph.',\n planFix,\n 'Run `prisma-next migration show <bundle>` for any bundle in the path you expected.',\n ].join('\\n'),\n meta: {\n ...meta,\n code: 'MIGRATION.PATH_UNREACHABLE',\n },\n });\n}\n\n/**\n * Maps a `MigrationToolsError` raised by the migration-tools loader/graph\n * surface (`readMigrationPackage`, `readMigrationsDir`, `readRefs`,\n * `resolveRef`, `reconstructGraph`, ...) into a CLI `errorRuntime` envelope.\n *\n * The full `error.details` payload is forwarded into `meta` so machine\n * consumers (`--json`) see structural fields like `dir`, `storedHash`,\n * `computedHash` (for `MIGRATION.HASH_MISMATCH`) alongside the stable\n * `code`. The user-visible `summary`/`why`/`fix` text is unchanged.\n *\n * Callers are expected to gate on `MigrationToolsError.is(error)` first\n * (mirroring the original inline pattern); non-`MigrationToolsError`\n * values are caller-classified (rethrow, wrap with command-specific\n * `errorUnexpected`, etc.).\n */\nexport function mapMigrationToolsError(error: MigrationToolsError): CliStructuredError {\n return errorRuntime(error.message, {\n why: error.why,\n fix: error.fix,\n meta: { code: error.code, ...(error.details ?? {}) },\n });\n}\n\n/**\n * Maps a `RefResolutionError` from the contract/migration reference\n * resolver into a CLI structured error envelope.\n */\nexport function mapRefResolutionError(error: RefResolutionError): CliStructuredError {\n switch (error.kind) {\n case 'not-found':\n return errorRuntime(`Not a known ${error.grammar} reference: \"${error.input}\"`, {\n why: `No ${error.grammar} matching \"${error.input}\" exists in the migration graph or refs index.`,\n fix:\n error.grammar === 'contract'\n ? 'Provide a valid contract hash, ref name, or migration directory name.'\n : 'Provide a valid migration directory name or migration hash.',\n meta: { input: error.input, grammar: error.grammar },\n });\n case 'ambiguous':\n return errorRuntime(`Ambiguous ${error.grammar} reference: \"${error.input}\"`, {\n why: `\"${error.input}\" matches multiple ${error.grammar}s: ${error.candidates.join(', ')}`,\n fix: 'Provide a longer prefix or use the full hash to disambiguate.',\n meta: { input: error.input, candidates: error.candidates, grammar: error.grammar },\n });\n case 'wrong-grammar':\n return errorRuntime(error.message, {\n why: error.message,\n fix: error.fix,\n meta: { input: error.input, expectedGrammar: error.expectedGrammar },\n });\n case 'invalid-format':\n return errorRuntime(`Invalid reference format: \"${error.input}\"`, {\n why: error.reason,\n fix: 'Provide a valid contract hash, ref name, or migration directory name.',\n meta: { input: error.input },\n });\n }\n}\n"],"mappings":";;;;AAuEA,SAAgB,0BACd,cACA,iBACA,cACoB;CACpB,MAAM,gBACJ,gBAAgB,SAAS,IAAI,gBAAgB,KAAK,KAAK,GAAG;CAC5D,MAAM,MACJ,gBAAgB,SAAS,IACrB,iBAAiB,OACf,4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|
3
|
-
import { _ as parseGlobalFlags, b as formatCommandHelp, d as setCommandDescriptions, f as setCommandExamples, t as addGlobalOptions, v as parseGlobalFlagsOrExit, x as formatRootHelp } from "./command-helpers-
|
|
4
|
-
import { t as createContractEmitCommand } from "./contract-emit-
|
|
5
|
-
import { t as createContractInferCommand } from "./contract-infer-
|
|
3
|
+
import { _ as parseGlobalFlags, b as formatCommandHelp, d as setCommandDescriptions, f as setCommandExamples, t as addGlobalOptions, v as parseGlobalFlagsOrExit, x as formatRootHelp } from "./command-helpers-CRfjbZRz.mjs";
|
|
4
|
+
import { t as createContractEmitCommand } from "./contract-emit-mqXmapxB.mjs";
|
|
5
|
+
import { t as createContractInferCommand } from "./contract-infer-C4jxc1aZ.mjs";
|
|
6
6
|
import { createDbInitCommand } from "./commands/db-init.mjs";
|
|
7
7
|
import { createDbSchemaCommand } from "./commands/db-schema.mjs";
|
|
8
8
|
import { createDbSignCommand } from "./commands/db-sign.mjs";
|
|
9
9
|
import { createDbUpdateCommand } from "./commands/db-update.mjs";
|
|
10
|
-
import { t as createDbVerifyCommand } from "./db-verify-
|
|
10
|
+
import { t as createDbVerifyCommand } from "./db-verify-1d8tDoFN.mjs";
|
|
11
11
|
import { createMigrateCommand } from "./commands/migrate.mjs";
|
|
12
12
|
import { createMigrationCheckCommand } from "./commands/migration-check.mjs";
|
|
13
13
|
import { createMigrationGraphCommand } from "./commands/migration-graph.mjs";
|
|
14
14
|
import { createMigrationListCommand } from "./commands/migration-list.mjs";
|
|
15
15
|
import { createMigrationLogCommand } from "./commands/migration-log.mjs";
|
|
16
16
|
import { createMigrationNewCommand } from "./commands/migration-new.mjs";
|
|
17
|
-
import { t as createMigrationPlanCommand } from "./migration-plan-
|
|
17
|
+
import { t as createMigrationPlanCommand } from "./migration-plan-jdAHg_gK.mjs";
|
|
18
18
|
import { createMigrationShowCommand } from "./commands/migration-show.mjs";
|
|
19
19
|
import { createMigrationStatusCommand } from "./commands/migration-status.mjs";
|
|
20
20
|
import { createRefCommand } from "./commands/ref.mjs";
|
|
@@ -25,7 +25,7 @@ import { fileURLToPath } from "node:url";
|
|
|
25
25
|
import { readUserConfig, resolveGating, runTelemetry } from "@prisma-next/cli-telemetry";
|
|
26
26
|
import { distance } from "closest-match";
|
|
27
27
|
//#region package.json
|
|
28
|
-
var version = "0.11.0-dev.
|
|
28
|
+
var version = "0.11.0-dev.8";
|
|
29
29
|
//#endregion
|
|
30
30
|
//#region src/utils/telemetry.ts
|
|
31
31
|
/**
|
|
@@ -413,7 +413,7 @@ Exit codes (see CLI Style Guide § Exit Codes):
|
|
|
413
413
|
"prisma-next init --no-skill # skip the skills install (air-gapped / restricted env)"
|
|
414
414
|
]);
|
|
415
415
|
return addGlobalOptions(command).option("--target <db>", "Database target: postgres or mongodb").option("--authoring <style>", "Schema authoring style: psl or typescript").option("--schema-path <path>", `Where to write the starter schema (default: ${defaultSchemaPath("psl")})`).option("--force", "Overwrite an existing scaffold without prompting").option("--write-env", "Write a .env file from .env.example (gitignored; default: only .env.example)").option("--probe-db", "Connect to DATABASE_URL once and check the server version against the target minimum (opt-in; off by default)").option("--strict-probe", "Treat a failed --probe-db as fatal (no-op without --probe-db; init is offline-by-default)").option("--no-install", "Skip dependency installation and contract emission").option("--no-skill", "Skip Prisma Next skills install (air-gapped CI, restricted registries, etc.)").action(async (options, actionCommand) => {
|
|
416
|
-
const { runInit } = await import("./init-
|
|
416
|
+
const { runInit } = await import("./init-ByoeQphC.mjs");
|
|
417
417
|
const flags = parseGlobalFlagsOrExit(options);
|
|
418
418
|
const canPrompt = deriveCanPrompt({
|
|
419
419
|
flagsInteractive: flags.interactive,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as assertFrameworkComponentsCompatible } from "./framework-components-
|
|
1
|
+
import { t as CliStructuredError, x as errorRunnerFailed } from "./cli-errors-Bw2GlweY.mjs";
|
|
2
|
+
import { t as assertFrameworkComponentsCompatible } from "./framework-components-Bexd0f4E.mjs";
|
|
3
3
|
import { t as enrichContract } from "./contract-enrichment-Dani0mMW.mjs";
|
|
4
|
-
import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-
|
|
4
|
+
import { t as buildContractSpaceAggregate } from "./contract-space-aggregate-loader-CGakRlKM.mjs";
|
|
5
5
|
import { emit } from "@prisma-next/emitter";
|
|
6
6
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
7
7
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
@@ -1481,4 +1481,4 @@ var ControlClientImpl = class {
|
|
|
1481
1481
|
//#endregion
|
|
1482
1482
|
export { ContractValidationError as a, executeDbInit as i, executeDbVerify as n, executeDbUpdate as r, createControlClient as t };
|
|
1483
1483
|
|
|
1484
|
-
//# sourceMappingURL=client-
|
|
1484
|
+
//# sourceMappingURL=client-UnIveZxZ.mjs.map
|