@prisma/orm-toolchain 8.0.0-rc.11-dev.53 → 8.0.0-rc.11-dev.55
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/{aggregate-D1pUq5oA.mjs → aggregate-CZyUi3Gt.mjs} +10 -10
- package/dist/{aggregate-D1pUq5oA.mjs.map → aggregate-CZyUi3Gt.mjs.map} +1 -1
- package/dist/{aggregate-CnwOnxnJ.d.mts → aggregate-DwZNs0oH.d.mts} +3 -3
- package/dist/{aggregate-CnwOnxnJ.d.mts.map → aggregate-DwZNs0oH.d.mts.map} +1 -1
- package/dist/cli-telemetry.mjs +2 -2
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +57 -38
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +11 -11
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__control-api__testing.mjs +1 -1
- package/dist/cli__migration-cli.mjs +5 -5
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +2 -2
- package/dist/config-loader.mjs +2 -2
- package/dist/{contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs → contract-snapshot-store-1S_6vaGt-mzFobPtq.mjs} +5 -5
- package/dist/{contract-snapshot-store-CM9ubenX-o8kTVHxP.mjs.map → contract-snapshot-store-1S_6vaGt-mzFobPtq.mjs.map} +1 -1
- package/dist/{db-verify-BkwsVjIf-CDWnVSjr.d.mts → db-verify-BkwsVjIf-BQHjqQoO.d.mts} +3 -3
- package/dist/{db-verify-BkwsVjIf-CDWnVSjr.d.mts.map → db-verify-BkwsVjIf-BQHjqQoO.d.mts.map} +1 -1
- package/dist/{errors-BIroGS9E-Dg6CF-dm.mjs → errors-DD6iLGXk-B4Q4tIha.mjs} +4 -32
- package/dist/errors-DD6iLGXk-B4Q4tIha.mjs.map +1 -0
- package/dist/{exports-ClG6amXs.mjs → exports-8-S4PGn0.mjs} +36 -7
- package/dist/exports-8-S4PGn0.mjs.map +1 -0
- package/dist/{exports-BiGALu6k.mjs → exports-DVWNaJUr.mjs} +6 -15
- package/dist/exports-DVWNaJUr.mjs.map +1 -0
- package/dist/{graph-membership-CdU6royq-gP9Kb9Eh.mjs → graph-membership-BQ43lP4A-B8rZC7rC.mjs} +3 -3
- package/dist/{graph-membership-CdU6royq-gP9Kb9Eh.mjs.map → graph-membership-BQ43lP4A-B8rZC7rC.mjs.map} +1 -1
- package/dist/{index-CjMp0WzN.d.mts → index-DFX8XFLx.d.mts} +22 -4
- package/dist/index-DFX8XFLx.d.mts.map +1 -0
- package/dist/{invariants-CUbFGAse-DqgE4fhO.mjs → invariants-C0lpc60l-MH7CqDAw.mjs} +3 -3
- package/dist/{invariants-CUbFGAse-DqgE4fhO.mjs.map → invariants-C0lpc60l-MH7CqDAw.mjs.map} +1 -1
- package/dist/{io-CyV6U3am-CMJIi_UO.mjs → io-xKnQrxIC-D_C_lwGm.mjs} +5 -5
- package/dist/{io-CyV6U3am-CMJIi_UO.mjs.map → io-xKnQrxIC-D_C_lwGm.mjs.map} +1 -1
- package/dist/{migration-D95UJ0Dj.mjs → migration-CkACVhgz.mjs} +4 -4
- package/dist/{migration-D95UJ0Dj.mjs.map → migration-CkACVhgz.mjs.map} +1 -1
- package/dist/{migration-graph-B4xBv7B2-CQ8kM0NF.mjs → migration-graph-BoiiZAaU-DLht12k7.mjs} +3 -81
- package/dist/migration-graph-BoiiZAaU-DLht12k7.mjs.map +1 -0
- package/dist/{migration-graph-Dow0Gaw0-Dy6qj7aU.d.mts → migration-graph-D8IuOkZb-pSI7-k4_.d.mts} +4 -24
- package/dist/{migration-graph-Dow0Gaw0-Dy6qj7aU.d.mts.map → migration-graph-D8IuOkZb-pSI7-k4_.d.mts.map} +1 -1
- package/dist/{migration-graph-DhDB8qEP.d.mts → migration-graph-De1gCcTL.d.mts} +2 -2
- package/dist/{migration-graph-DhDB8qEP.d.mts.map → migration-graph-De1gCcTL.d.mts.map} +1 -1
- package/dist/migration-tools.d.mts +4 -4
- package/dist/migration-tools.mjs +14 -14
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__contract-snapshot-store.mjs +1 -1
- package/dist/migration-tools__errors.mjs +1 -1
- package/dist/migration-tools__invariants.mjs +1 -1
- package/dist/migration-tools__io.mjs +1 -1
- package/dist/migration-tools__migration-graph.d.mts +3 -3
- package/dist/migration-tools__migration-graph.mjs +3 -3
- package/dist/migration-tools__migration-ts.mjs +1 -1
- package/dist/migration-tools__migration.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/migration-tools__spaces.mjs +2 -2
- package/dist/{migration-ts-DdVm0rws.mjs → migration-ts-FyF55c4M.mjs} +2 -2
- package/dist/{migration-ts-DdVm0rws.mjs.map → migration-ts-FyF55c4M.mjs.map} +1 -1
- package/dist/{ref-DL4C2p9T-B6EVNIhl.mjs → ref-CTp4Kvp--3Dgd8LXq.mjs} +245 -226
- package/dist/ref-CTp4Kvp--3Dgd8LXq.mjs.map +1 -0
- package/dist/{ref-resolution-BwWLoU7C.mjs → ref-resolution-be3JMf5X.mjs} +2 -2
- package/dist/{ref-resolution-BwWLoU7C.mjs.map → ref-resolution-be3JMf5X.mjs.map} +1 -1
- package/dist/{refs-S0wu2JkI-BbFdehLe.mjs → refs-qwvw4_dV-Bk9tl756.mjs} +3 -3
- package/dist/{refs-S0wu2JkI-BbFdehLe.mjs.map → refs-qwvw4_dV-Bk9tl756.mjs.map} +1 -1
- package/dist/{spaces-Bk9Q5fMp.mjs → spaces-D1-7OKid.mjs} +8 -8
- package/dist/{spaces-Bk9Q5fMp.mjs.map → spaces-D1-7OKid.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs → verify-contract-spaces-CYjc343k-9_2GpPRg.mjs} +5 -5
- package/dist/{verify-contract-spaces-BLkC9r9l-CJIppNL8.mjs.map → verify-contract-spaces-CYjc343k-9_2GpPRg.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +3 -3
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +13 -12
- package/dist/errors-BIroGS9E-Dg6CF-dm.mjs.map +0 -1
- package/dist/exports-BiGALu6k.mjs.map +0 -1
- package/dist/exports-ClG6amXs.mjs.map +0 -1
- package/dist/index-CjMp0WzN.d.mts.map +0 -1
- package/dist/migration-graph-B4xBv7B2-CQ8kM0NF.mjs.map +0 -1
- package/dist/ref-DL4C2p9T-B6EVNIhl.mjs.map +0 -1
|
@@ -1,39 +1,40 @@
|
|
|
1
1
|
import { r as getEmittedArtifactPaths, t as emit } from "./exports-DI1kMms6--e9LdT9A.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { r as expandContractInputs } from "./exports-8-S4PGn0.mjs";
|
|
3
|
+
import { D as errorNoInvariantPath, M as errorUnknownInvariant, b as errorInvalidRefName, r as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-DD6iLGXk-B4Q4tIha.mjs";
|
|
3
4
|
import { r as verifyMigrationHash, t as computeMigrationHash } from "./hash-BAZVWU4a-BdynTmar.mjs";
|
|
4
|
-
import { a as snapshotsImportPathFrom, n as createSnapshotContentVerifier, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-
|
|
5
|
-
import { t as deriveProvidedInvariants } from "./invariants-
|
|
6
|
-
import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-
|
|
5
|
+
import { a as snapshotsImportPathFrom, n as createSnapshotContentVerifier, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-1S_6vaGt-mzFobPtq.mjs";
|
|
6
|
+
import { t as deriveProvidedInvariants } from "./invariants-C0lpc60l-MH7CqDAw.mjs";
|
|
7
|
+
import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-xKnQrxIC-D_C_lwGm.mjs";
|
|
7
8
|
import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
8
|
-
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-
|
|
9
|
-
import {
|
|
10
|
-
import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-
|
|
11
|
-
import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-
|
|
12
|
-
import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-
|
|
13
|
-
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-
|
|
9
|
+
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-BQ43lP4A-B8rZC7rC.mjs";
|
|
10
|
+
import { i as findPathWithDecision, r as findPath } from "./migration-graph-BoiiZAaU-DLht12k7.mjs";
|
|
11
|
+
import { d as writeRef, i as readRefs, l as validateRefName, n as deleteRef, o as refsByContractHash, t as HEAD_REF_NAME, u as validateRefValue } from "./refs-qwvw4_dV-Bk9tl756.mjs";
|
|
12
|
+
import { a as isValidSpaceId, c as spaceMigrationDirectory, l as spaceRefsDirectory, o as listContractSpaceDirectories, s as readContractSpaceHeadRef, t as APP_SPACE_ID$1 } from "./verify-contract-spaces-CYjc343k-9_2GpPRg.mjs";
|
|
13
|
+
import { d as resolveRecordedPath, f as verifyMigration, l as planMigration, n as buildFabricatedMigrationEdge, r as collectAggregateNamespaces, s as loadContractSpaceAggregate, t as allStorageElementsExternal, u as requireHeadRef } from "./aggregate-CZyUi3Gt.mjs";
|
|
14
|
+
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-D1-7OKid.mjs";
|
|
14
15
|
import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-CYpOz1XZ.mjs";
|
|
15
|
-
import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-
|
|
16
|
-
import { i as writeMigrationTs } from "./migration-ts-
|
|
16
|
+
import { n as parseContractRef, r as parseMigrationRef } from "./ref-resolution-be3JMf5X.mjs";
|
|
17
|
+
import { i as writeMigrationTs } from "./migration-ts-FyF55c4M.mjs";
|
|
17
18
|
import { createRequire } from "node:module";
|
|
18
19
|
import { existsSync, readFileSync, readdirSync, statSync } from "node:fs";
|
|
19
20
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
21
|
+
import { basename, dirname, isAbsolute, join, relative, resolve } from "pathe";
|
|
22
|
+
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
20
23
|
import { isStructuredErrorCode, structuredError } from "@prisma/orm-framework/utils/structured-error";
|
|
21
24
|
import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
|
|
22
25
|
import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
|
|
23
26
|
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
24
27
|
import { CliStructuredError, CliStructuredError as CliStructuredError$1, errorConfigValidation as errorConfigValidation$1, errorContractConfigMissing, errorContractValidationFailed, errorDatabaseConnectionRequired, errorDriverRequired, errorFileNotFound, errorMigrationPlanningFailed, errorTargetMigrationNotSupported, errorUnexpected } from "@prisma/orm-framework/errors/control";
|
|
25
|
-
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma/orm-framework/components/control";
|
|
26
28
|
import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
29
|
+
import { APP_SPACE_ID, createControlStack, hasMigrations, hasOperationPreview, hasPslContractInfer, hasSchemaSubjectClassifier, hasSchemaView } from "@prisma/orm-framework/components/control";
|
|
27
30
|
import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/components";
|
|
28
31
|
import { ERROR_CODE_DESTRUCTIVE_CHANGES, errorConsentPlanMismatch, errorDestructiveChanges, errorHashMismatch, errorMarkerMissing, errorRunnerFailed, errorRuntime, errorTargetMismatch } from "@prisma/orm-framework/errors/execution";
|
|
29
32
|
import "@prisma/orm-framework/errors/migration";
|
|
30
|
-
import { basename, dirname, isAbsolute, join, relative, resolve } from "pathe";
|
|
31
33
|
import { createHash } from "node:crypto";
|
|
32
34
|
import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
33
|
-
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
34
35
|
import { abortable } from "@prisma/orm-framework/utils/abortable";
|
|
35
36
|
import { resolve as resolve$1 } from "node:path";
|
|
36
|
-
//#region ../../../1-framework/3-tooling/cli/dist/ref-
|
|
37
|
+
//#region ../../../1-framework/3-tooling/cli/dist/ref-CTp4Kvp-.mjs
|
|
37
38
|
/**
|
|
38
39
|
* The typed remediation the CLI attaches to its own errors and findings.
|
|
39
40
|
* Constructors live here rather than in any library the CLI calls: naming a
|
|
@@ -101,18 +102,17 @@ function errorAdvanceRefArgConflict(options) {
|
|
|
101
102
|
meta: { advanceRef: options.advanceRef }
|
|
102
103
|
});
|
|
103
104
|
}
|
|
104
|
-
function errorRefSetHashNotInGraph(resolvedHash, reachableHashes
|
|
105
|
+
function errorRefSetHashNotInGraph(resolvedHash, reachableHashes) {
|
|
105
106
|
const reachableList = reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)";
|
|
106
|
-
const fix = reachableHashes.length > 0 ?
|
|
107
|
-
const nextActions = reachableHashes.length > 0 ?
|
|
107
|
+
const fix = reachableHashes.length > 0 ? "Set the ref to the `to` hash of an on-disk migration; `{bin} migration list` shows them." : "Run `{bin} migration plan` first.";
|
|
108
|
+
const nextActions = reachableHashes.length > 0 ? [runCommandAction("List the migrations and their destination hashes", "{bin} migration list"), chooseAction("Set the ref to the `to` hash of one of them")] : [runCommandAction("Plan the first migration", "{bin} migration plan")];
|
|
108
109
|
return new ActionableCliError("MIGRATION.HASH_NOT_IN_GRAPH", `Resolved contract hash is not in the migration graph: ${resolvedHash}`, {
|
|
109
110
|
why: reachableHashes.length > 0 ? `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.` : "The migration graph is empty — no hashes reachable.",
|
|
110
111
|
fix,
|
|
111
112
|
nextActions,
|
|
112
113
|
meta: {
|
|
113
114
|
resolvedHash,
|
|
114
|
-
reachableHashes: [...reachableHashes]
|
|
115
|
-
...graphTipHash !== null ? { graphTipHash } : {}
|
|
115
|
+
reachableHashes: [...reachableHashes]
|
|
116
116
|
}
|
|
117
117
|
});
|
|
118
118
|
}
|
|
@@ -202,18 +202,17 @@ function errorRefSetBundleNotFound(hash) {
|
|
|
202
202
|
meta: { hash }
|
|
203
203
|
});
|
|
204
204
|
}
|
|
205
|
-
function errorPlanForgotTheFlag(resolvedHash, reachableRefs,
|
|
205
|
+
function errorPlanForgotTheFlag(resolvedHash, reachableRefs, options) {
|
|
206
206
|
const reachableList = reachableRefs.length > 0 ? reachableRefs.map((r) => `${r.name} (${r.hash})`).join(", ") : "(none)";
|
|
207
|
-
const refFix = reachableRefs.length > 0 ? `Run migration plan with ${reachableRefs.map((r) => `--from ${r.name}`).join(" or ")}.` :
|
|
208
|
-
const nextActions = reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) :
|
|
207
|
+
const refFix = reachableRefs.length > 0 ? `Run migration plan with ${reachableRefs.map((r) => `--from ${r.name}`).join(" or ")}.` : "Pass --from <contract> naming the `to` hash of an on-disk migration (`{bin} migration list` shows them), or point the db ref at one with `{bin} migration ref set db <contract>`.";
|
|
208
|
+
const nextActions = reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) : [runCommandAction("Plan from an explicit origin", "{bin} migration plan --from <contract>"), runCommandAction("Point the db ref at a graph node", "{bin} migration ref set db <contract>")];
|
|
209
209
|
return new ActionableCliError("MIGRATION.HASH_NOT_IN_GRAPH", `Resolved from-hash is not in the migration graph: ${resolvedHash}`, {
|
|
210
210
|
why: `The migration graph reaches ${reachableList}; resolved ${resolvedHash} isn't a graph node.`,
|
|
211
211
|
fix: refFix,
|
|
212
212
|
nextActions,
|
|
213
213
|
meta: {
|
|
214
214
|
resolvedHash,
|
|
215
|
-
reachableRefs: reachableRefs.map((r) => r.name)
|
|
216
|
-
...graphTipHash !== null ? { graphTipHash } : {}
|
|
215
|
+
reachableRefs: reachableRefs.map((r) => r.name)
|
|
217
216
|
},
|
|
218
217
|
...ifDefined("cause", options?.cause)
|
|
219
218
|
});
|
|
@@ -251,9 +250,9 @@ function errorSnapshotMissing(identifier, options) {
|
|
|
251
250
|
* produce an empty-origin migration that ignores the existing history — almost
|
|
252
251
|
* always a mistake — so the command refuses and names the three exits.
|
|
253
252
|
*/
|
|
254
|
-
function errorPlanOriginUnknown(reachableRefs
|
|
255
|
-
const fromSuggestion = reachableRefs.length > 0 ? reachableRefs.map((r) => `--from ${r.name}`).join(" or ") :
|
|
256
|
-
const refSetCommand =
|
|
253
|
+
function errorPlanOriginUnknown(reachableRefs) {
|
|
254
|
+
const fromSuggestion = reachableRefs.length > 0 ? reachableRefs.map((r) => `--from ${r.name}`).join(" or ") : "--from <contract>";
|
|
255
|
+
const refSetCommand = "{bin} migration ref set db <contract>";
|
|
257
256
|
return new ActionableCliError("MIGRATION.PLAN_ORIGIN_UNKNOWN", "Cannot determine the plan origin: migrations exist but no origin is named", {
|
|
258
257
|
why: "Migrations exist on disk, but there is no `db` ref and no --from was given, so the plan origin would silently fall back to an empty database and the resulting migration would recreate everything the existing migrations already create.",
|
|
259
258
|
fix: [
|
|
@@ -266,32 +265,25 @@ function errorPlanOriginUnknown(reachableRefs, graphTipHash) {
|
|
|
266
265
|
...reachableRefs.length > 0 ? reachableRefs.map((ref) => runCommandAction(`Plan from ${ref.name}`, `{bin} migration plan --from ${ref.name}`)) : [runCommandAction("Plan from an explicit origin", `{bin} migration plan ${fromSuggestion}`)],
|
|
267
266
|
runCommandAction("Plan from an empty database deliberately", "{bin} migration plan --from @empty")
|
|
268
267
|
],
|
|
269
|
-
meta: {
|
|
270
|
-
reachableRefs: reachableRefs.map((r) => r.name),
|
|
271
|
-
...graphTipHash !== null ? { graphTipHash } : {}
|
|
272
|
-
}
|
|
268
|
+
meta: { reachableRefs: reachableRefs.map((r) => r.name) }
|
|
273
269
|
});
|
|
274
270
|
}
|
|
275
|
-
function errorMarkerMismatch(markerHash, reachableHashes
|
|
276
|
-
const reachableList = reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)";
|
|
277
|
-
const planFromFix = graphTip !== null ? `Run \`{bin} migration plan --from ${graphTip}\` if the live marker is canonical and the on-disk graph needs catching up.` : "Run `{bin} migration plan` if the live marker is canonical and the on-disk graph needs catching up.";
|
|
278
|
-
const planCommand = graphTip !== null ? `{bin} migration plan --from ${graphTip}` : "{bin} migration plan";
|
|
271
|
+
function errorMarkerMismatch(markerHash, reachableHashes) {
|
|
279
272
|
return new ActionableCliError("MIGRATION.MARKER_MISMATCH", "Database marker is not reachable in the on-disk migration graph", {
|
|
280
|
-
why: `DB marker is ${markerHash}, but the on-disk migration graph reaches: ${
|
|
273
|
+
why: `DB marker is ${markerHash}, but the on-disk migration graph reaches: ${reachableHashes.length > 0 ? reachableHashes.join(", ") : "(none — migration graph is empty)"}.`,
|
|
281
274
|
fix: [
|
|
282
|
-
|
|
275
|
+
"Run `{bin} migration plan --from <contract>`, naming the graph node the database was migrated from, if the live marker is canonical and the on-disk graph needs catching up.",
|
|
283
276
|
`Run \`{bin} migration ref set db ${markerHash}\` if the on-disk graph is canonical and the local \`db\` ref drifted.`,
|
|
284
277
|
"Investigate whether the database was migrated by an out-of-band process."
|
|
285
278
|
].join("\n"),
|
|
286
279
|
nextActions: [
|
|
287
|
-
runCommandAction("Catch the on-disk graph up to the live marker",
|
|
280
|
+
runCommandAction("Catch the on-disk graph up to the live marker", "{bin} migration plan --from <contract>"),
|
|
288
281
|
runCommandAction("Point the local db ref at the live marker", `{bin} migration ref set db ${markerHash}`),
|
|
289
282
|
chooseAction("Investigate whether the database was migrated by an out-of-band process")
|
|
290
283
|
],
|
|
291
284
|
meta: {
|
|
292
285
|
markerHash,
|
|
293
|
-
reachableHashes: [...reachableHashes]
|
|
294
|
-
...graphTip !== null ? { graphTip } : {}
|
|
286
|
+
reachableHashes: [...reachableHashes]
|
|
295
287
|
}
|
|
296
288
|
});
|
|
297
289
|
}
|
|
@@ -2501,7 +2493,7 @@ var ControlClientImpl = class {
|
|
|
2501
2493
|
codecLookup: stack.codecLookup,
|
|
2502
2494
|
controlMutationDefaults: stack.controlMutationDefaults,
|
|
2503
2495
|
dataTypeLookup: stack.dataTypeLookup,
|
|
2504
|
-
resolvedInputs: contractConfig.source.inputs
|
|
2496
|
+
resolvedInputs: await expandContractInputs(contractConfig.source.inputs),
|
|
2505
2497
|
capabilities: stack.capabilities
|
|
2506
2498
|
};
|
|
2507
2499
|
const providerResult = await contractConfig.source.load(sourceContext);
|
|
@@ -3033,7 +3025,7 @@ async function resolveContractSource(contractConfig, stack, signal) {
|
|
|
3033
3025
|
codecLookup: stack.codecLookup,
|
|
3034
3026
|
controlMutationDefaults: stack.controlMutationDefaults,
|
|
3035
3027
|
dataTypeLookup: stack.dataTypeLookup,
|
|
3036
|
-
resolvedInputs: contractConfig.source.inputs
|
|
3028
|
+
resolvedInputs: await abortable(signal)(expandContractInputs(contractConfig.source.inputs)),
|
|
3037
3029
|
capabilities: stack.capabilities
|
|
3038
3030
|
};
|
|
3039
3031
|
let providerResult;
|
|
@@ -3400,7 +3392,7 @@ function hasMigrationPath(graph, fromHash, toHash) {
|
|
|
3400
3392
|
*/
|
|
3401
3393
|
function refuseMarkerOutsideGraph(args) {
|
|
3402
3394
|
if (isGraphNode(args.markerHash, args.graph)) return null;
|
|
3403
|
-
return errorMarkerMismatch(args.markerHash, [...args.graph.nodes].sort()
|
|
3395
|
+
return errorMarkerMismatch(args.markerHash, [...args.graph.nodes].sort());
|
|
3404
3396
|
}
|
|
3405
3397
|
/**
|
|
3406
3398
|
* Invariant refusals shared by migrate and migration status: unknown ref invariants and unsatisfiable invariant paths.
|
|
@@ -4130,6 +4122,196 @@ function buildMigrationSpaceGraphEntries(args) {
|
|
|
4130
4122
|
}
|
|
4131
4123
|
return spaces;
|
|
4132
4124
|
}
|
|
4125
|
+
const FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;
|
|
4126
|
+
function looksLikeFullHash(input) {
|
|
4127
|
+
return FULL_HASH_PATTERN.test(input);
|
|
4128
|
+
}
|
|
4129
|
+
function graphIsEmpty(space) {
|
|
4130
|
+
return space.packages.length === 0;
|
|
4131
|
+
}
|
|
4132
|
+
function outgoingDestinations(graph, hash) {
|
|
4133
|
+
return [...new Set((graph.forwardChain.get(hash) ?? []).map((edge) => edge.to))].sort();
|
|
4134
|
+
}
|
|
4135
|
+
function getReachableRefs(refs, graph) {
|
|
4136
|
+
return Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{
|
|
4137
|
+
name,
|
|
4138
|
+
hash: entry.hash
|
|
4139
|
+
}] : []).sort((a, b) => a.name.localeCompare(b.name));
|
|
4140
|
+
}
|
|
4141
|
+
function assertFromIsGraphNode(fromHash, graph, refs) {
|
|
4142
|
+
try {
|
|
4143
|
+
assertHashIsGraphNode(fromHash, graph);
|
|
4144
|
+
} catch (error) {
|
|
4145
|
+
if (MigrationToolsError.is(error) && error.code === "MIGRATION.HASH_NOT_IN_GRAPH") throw errorPlanForgotTheFlag(fromHash, getReachableRefs(refs, graph), { cause: error });
|
|
4146
|
+
throw error;
|
|
4147
|
+
}
|
|
4148
|
+
}
|
|
4149
|
+
/**
|
|
4150
|
+
* The origin a command uses when `--from` is omitted, as a hash only. An empty
|
|
4151
|
+
* graph with no `db` ref plans from the empty database. An empty graph with a
|
|
4152
|
+
* `db` ref is `ref-needs-baseline`: the ref names a real contract that is not
|
|
4153
|
+
* a graph node yet (`migration plan` handles this by writing a baseline first).
|
|
4154
|
+
* Otherwise the `db` ref must exist and point at a graph node. `migration
|
|
4155
|
+
* plan` materialises the contract on top of this; `migration new` needs only
|
|
4156
|
+
* the hash.
|
|
4157
|
+
*/
|
|
4158
|
+
function resolveDefaultOriginHash(space) {
|
|
4159
|
+
const refs = space.refs;
|
|
4160
|
+
const dbRef = refs["db"];
|
|
4161
|
+
if (graphIsEmpty(space)) return ok(dbRef ? {
|
|
4162
|
+
kind: "ref-needs-baseline",
|
|
4163
|
+
refName: "db",
|
|
4164
|
+
fromHash: dbRef.hash
|
|
4165
|
+
} : {
|
|
4166
|
+
kind: "greenfield",
|
|
4167
|
+
fromHash: null
|
|
4168
|
+
});
|
|
4169
|
+
const graph = space.graph();
|
|
4170
|
+
if (!dbRef) return notOk(errorPlanOriginUnknown(getReachableRefs(refs, graph)));
|
|
4171
|
+
try {
|
|
4172
|
+
assertFromIsGraphNode(dbRef.hash, graph, refs);
|
|
4173
|
+
} catch (error) {
|
|
4174
|
+
if (CliStructuredError$1.is(error)) return notOk(error);
|
|
4175
|
+
throw error;
|
|
4176
|
+
}
|
|
4177
|
+
return ok({
|
|
4178
|
+
kind: "ref",
|
|
4179
|
+
refName: "db",
|
|
4180
|
+
fromHash: dbRef.hash
|
|
4181
|
+
});
|
|
4182
|
+
}
|
|
4183
|
+
async function resolveContractRef(parsed, space, options) {
|
|
4184
|
+
const { hash, provenance } = parsed;
|
|
4185
|
+
const refName = provenance.kind === "ref" ? provenance.refName : void 0;
|
|
4186
|
+
try {
|
|
4187
|
+
const at = await space.contractAt(hash, refName !== void 0 ? { refName } : void 0);
|
|
4188
|
+
if (at.provenance === "ref") return ok({
|
|
4189
|
+
kind: "ref",
|
|
4190
|
+
hash: at.hash,
|
|
4191
|
+
contract: at.contract
|
|
4192
|
+
});
|
|
4193
|
+
return ok({
|
|
4194
|
+
kind: "graph-node",
|
|
4195
|
+
hash: at.hash,
|
|
4196
|
+
contract: at.contract
|
|
4197
|
+
});
|
|
4198
|
+
} catch (error) {
|
|
4199
|
+
return mapContractAtError(error, options?.artifactRole !== void 0 ? { artifactRole: options.artifactRole } : void 0);
|
|
4200
|
+
}
|
|
4201
|
+
}
|
|
4202
|
+
async function resolveFromPolicy(parsed, input, refs, explicitFromLabel) {
|
|
4203
|
+
const resolution = await resolveContractRef(parsed, input.space, {
|
|
4204
|
+
...explicitFromLabel !== void 0 ? { explicitLabel: explicitFromLabel } : {},
|
|
4205
|
+
artifactRole: "from"
|
|
4206
|
+
});
|
|
4207
|
+
if (!resolution.ok) return resolution;
|
|
4208
|
+
if (resolution.value.kind === "graph-node") return ok({
|
|
4209
|
+
kind: "graph-node",
|
|
4210
|
+
fromHash: resolution.value.hash,
|
|
4211
|
+
fromContract: resolution.value.contract
|
|
4212
|
+
});
|
|
4213
|
+
const { hash, contract } = resolution.value;
|
|
4214
|
+
if (graphIsEmpty(input.space)) return ok({
|
|
4215
|
+
kind: "auto-baseline",
|
|
4216
|
+
fromHash: hash,
|
|
4217
|
+
fromContract: contract
|
|
4218
|
+
});
|
|
4219
|
+
const graph = input.space.graph();
|
|
4220
|
+
try {
|
|
4221
|
+
assertFromIsGraphNode(hash, graph, refs);
|
|
4222
|
+
} catch (error) {
|
|
4223
|
+
if (CliStructuredError$1.is(error)) return notOk(error);
|
|
4224
|
+
throw error;
|
|
4225
|
+
}
|
|
4226
|
+
return ok({
|
|
4227
|
+
kind: "ref",
|
|
4228
|
+
fromHash: hash,
|
|
4229
|
+
fromContract: contract
|
|
4230
|
+
});
|
|
4231
|
+
}
|
|
4232
|
+
async function resolveFromForPlan(input) {
|
|
4233
|
+
const { optionsFrom, space } = input;
|
|
4234
|
+
const graph = space.graph();
|
|
4235
|
+
const refs = space.refs;
|
|
4236
|
+
if (optionsFrom === void 0) {
|
|
4237
|
+
const dbRef = refs["db"];
|
|
4238
|
+
if (!dbRef) {
|
|
4239
|
+
if (graphIsEmpty(space)) return ok({
|
|
4240
|
+
kind: "greenfield",
|
|
4241
|
+
fromHash: null,
|
|
4242
|
+
fromContract: null,
|
|
4243
|
+
defaulted: true
|
|
4244
|
+
});
|
|
4245
|
+
return notOk(errorPlanOriginUnknown(getReachableRefs(refs, graph)));
|
|
4246
|
+
}
|
|
4247
|
+
const resolved = await resolveFromPolicy({
|
|
4248
|
+
hash: dbRef.hash,
|
|
4249
|
+
provenance: {
|
|
4250
|
+
kind: "ref",
|
|
4251
|
+
refName: "db"
|
|
4252
|
+
}
|
|
4253
|
+
}, input, refs);
|
|
4254
|
+
if (!resolved.ok) return resolved;
|
|
4255
|
+
const value = resolved.value;
|
|
4256
|
+
if (value.kind === "ref" || value.kind === "graph-node") {
|
|
4257
|
+
const outgoingTo = outgoingDestinations(graph, value.fromHash);
|
|
4258
|
+
if (outgoingTo.length > 0) return ok({
|
|
4259
|
+
...value,
|
|
4260
|
+
defaultOriginForks: {
|
|
4261
|
+
refName: "db",
|
|
4262
|
+
refHash: value.fromHash,
|
|
4263
|
+
outgoingTo
|
|
4264
|
+
}
|
|
4265
|
+
});
|
|
4266
|
+
}
|
|
4267
|
+
return resolved;
|
|
4268
|
+
}
|
|
4269
|
+
const refResult = parseContractRef(optionsFrom, {
|
|
4270
|
+
graph,
|
|
4271
|
+
refs
|
|
4272
|
+
});
|
|
4273
|
+
if (!refResult.ok) {
|
|
4274
|
+
if (looksLikeFullHash(optionsFrom)) {
|
|
4275
|
+
if (graphIsEmpty(space)) return notOk(errorSnapshotMissing(optionsFrom, { viaRef: false }));
|
|
4276
|
+
return notOk(errorPlanForgotTheFlag(optionsFrom, getReachableRefs(refs, graph)));
|
|
4277
|
+
}
|
|
4278
|
+
return notOk(mapRefResolutionError(refResult.failure));
|
|
4279
|
+
}
|
|
4280
|
+
if (refResult.value.provenance.kind === "reserved-empty") return ok({
|
|
4281
|
+
kind: "greenfield",
|
|
4282
|
+
fromHash: null,
|
|
4283
|
+
fromContract: null,
|
|
4284
|
+
defaulted: false
|
|
4285
|
+
});
|
|
4286
|
+
return resolveFromPolicy(refResult.value, input, refs, optionsFrom);
|
|
4287
|
+
}
|
|
4288
|
+
async function resolveToForPlan(optionsTo, input) {
|
|
4289
|
+
const { space } = input;
|
|
4290
|
+
const graph = space.graph();
|
|
4291
|
+
const refs = space.refs;
|
|
4292
|
+
const refResult = parseContractRef(optionsTo, {
|
|
4293
|
+
graph,
|
|
4294
|
+
refs
|
|
4295
|
+
});
|
|
4296
|
+
if (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));
|
|
4297
|
+
if (refResult.value.provenance.kind === "reserved-empty") return notOk(mapRefResolutionError({
|
|
4298
|
+
kind: "wrong-grammar",
|
|
4299
|
+
input: optionsTo,
|
|
4300
|
+
expectedGrammar: "contract",
|
|
4301
|
+
message: "`@empty` is only valid as an origin (`--from`); planning a migration to the empty contract is not supported through this shortcut",
|
|
4302
|
+
fix: "Pass `--to` a contract hash, ref name, or migration directory name. To plan starting from an empty database, use `--from @empty`."
|
|
4303
|
+
}));
|
|
4304
|
+
const resolution = await resolveContractRef(refResult.value, space, {
|
|
4305
|
+
explicitLabel: optionsTo,
|
|
4306
|
+
artifactRole: "to"
|
|
4307
|
+
});
|
|
4308
|
+
if (!resolution.ok) return resolution;
|
|
4309
|
+
const { hash, contract } = resolution.value;
|
|
4310
|
+
return ok({
|
|
4311
|
+
hash,
|
|
4312
|
+
contract
|
|
4313
|
+
});
|
|
4314
|
+
}
|
|
4133
4315
|
/**
|
|
4134
4316
|
* Policy core of `migration new`: scaffolds a migration package with a `migration.ts` stub for manual authoring.
|
|
4135
4317
|
*/
|
|
@@ -4178,7 +4360,6 @@ async function executeMigrationNewCommand(options) {
|
|
|
4178
4360
|
const packageCorruptionFailure = refusePackageCorruptionOnAggregate(aggregate, migrationsDir);
|
|
4179
4361
|
if (packageCorruptionFailure) return notOk(packageCorruptionFailure);
|
|
4180
4362
|
const packages = aggregate.app.packages;
|
|
4181
|
-
const graph = aggregate.app.graph();
|
|
4182
4363
|
let fromHash = null;
|
|
4183
4364
|
if (options.from !== void 0) {
|
|
4184
4365
|
if (packages.length === 0) return notOk(errorRuntime("MIGRATION.HASH_NOT_IN_GRAPH", "--from has no meaning on an empty graph", {
|
|
@@ -4199,9 +4380,18 @@ async function executeMigrationNewCommand(options) {
|
|
|
4199
4380
|
}
|
|
4200
4381
|
}));
|
|
4201
4382
|
fromHash = matchedHashes[0] ?? null;
|
|
4202
|
-
} else
|
|
4203
|
-
const
|
|
4204
|
-
if (
|
|
4383
|
+
} else {
|
|
4384
|
+
const origin = resolveDefaultOriginHash(aggregate.app);
|
|
4385
|
+
if (!origin.ok) return notOk(origin.failure);
|
|
4386
|
+
if (origin.value.kind === "ref-needs-baseline") return notOk(errorRuntime("MIGRATION.HASH_NOT_IN_GRAPH", "The db ref is not a graph node yet", {
|
|
4387
|
+
why: `The db ref points at ${origin.value.fromHash}, but ${appMigrationsRelative} contains no migrations, so that contract is not a graph node and nothing can chain from it.`,
|
|
4388
|
+
fix: "Run `{bin} migration plan` first: on an empty graph it writes the baseline migration for the db ref alongside the delta, after which `migration new` can chain from it.",
|
|
4389
|
+
meta: {
|
|
4390
|
+
refName: origin.value.refName,
|
|
4391
|
+
resolvedHash: origin.value.fromHash
|
|
4392
|
+
}
|
|
4393
|
+
}));
|
|
4394
|
+
fromHash = origin.value.fromHash;
|
|
4205
4395
|
}
|
|
4206
4396
|
if (fromHash === toStorageHash && !options.from) return notOk(errorRuntime("MIGRATION.NO_CHANGES", "No changes detected", {
|
|
4207
4397
|
why: "The from and to contract hashes are identical — there is nothing to migrate.",
|
|
@@ -4349,174 +4539,6 @@ function buildPlaceholderContractDts(spaceId) {
|
|
|
4349
4539
|
""
|
|
4350
4540
|
].join("\n");
|
|
4351
4541
|
}
|
|
4352
|
-
const FULL_HASH_PATTERN = /^([0-9a-f]{64}|empty)$/;
|
|
4353
|
-
function looksLikeFullHash(input) {
|
|
4354
|
-
return FULL_HASH_PATTERN.test(input);
|
|
4355
|
-
}
|
|
4356
|
-
function graphIsEmpty(space) {
|
|
4357
|
-
return space.packages.length === 0;
|
|
4358
|
-
}
|
|
4359
|
-
/**
|
|
4360
|
-
* The graph tip, or `null` when the graph is empty or already forked —
|
|
4361
|
-
* a forked graph has no single tip to compare the default ref against.
|
|
4362
|
-
*/
|
|
4363
|
-
function findUnambiguousTip(graph) {
|
|
4364
|
-
try {
|
|
4365
|
-
return findLatestMigration(graph)?.to ?? null;
|
|
4366
|
-
} catch (error) {
|
|
4367
|
-
if (MigrationToolsError.is(error)) return null;
|
|
4368
|
-
throw error;
|
|
4369
|
-
}
|
|
4370
|
-
}
|
|
4371
|
-
function getReachableRefs(refs, graph) {
|
|
4372
|
-
return Object.entries(refs).flatMap(([name, entry]) => entry && isGraphNode(entry.hash, graph) ? [{
|
|
4373
|
-
name,
|
|
4374
|
-
hash: entry.hash
|
|
4375
|
-
}] : []).sort((a, b) => a.name.localeCompare(b.name));
|
|
4376
|
-
}
|
|
4377
|
-
function assertFromIsGraphNode(fromHash, graph, refs, graphTipHash) {
|
|
4378
|
-
try {
|
|
4379
|
-
assertHashIsGraphNode(fromHash, graph);
|
|
4380
|
-
} catch (error) {
|
|
4381
|
-
if (MigrationToolsError.is(error) && error.code === "MIGRATION.HASH_NOT_IN_GRAPH") throw errorPlanForgotTheFlag(fromHash, getReachableRefs(refs, graph), graphTipHash, { cause: error });
|
|
4382
|
-
throw error;
|
|
4383
|
-
}
|
|
4384
|
-
}
|
|
4385
|
-
async function resolveContractRef(parsed, space, options) {
|
|
4386
|
-
const { hash, provenance } = parsed;
|
|
4387
|
-
const refName = provenance.kind === "ref" ? provenance.refName : void 0;
|
|
4388
|
-
try {
|
|
4389
|
-
const at = await space.contractAt(hash, refName !== void 0 ? { refName } : void 0);
|
|
4390
|
-
if (at.provenance === "ref") return ok({
|
|
4391
|
-
kind: "ref",
|
|
4392
|
-
hash: at.hash,
|
|
4393
|
-
contract: at.contract
|
|
4394
|
-
});
|
|
4395
|
-
return ok({
|
|
4396
|
-
kind: "graph-node",
|
|
4397
|
-
hash: at.hash,
|
|
4398
|
-
contract: at.contract
|
|
4399
|
-
});
|
|
4400
|
-
} catch (error) {
|
|
4401
|
-
return mapContractAtError(error, options?.artifactRole !== void 0 ? { artifactRole: options.artifactRole } : void 0);
|
|
4402
|
-
}
|
|
4403
|
-
}
|
|
4404
|
-
async function resolveFromPolicy(parsed, input, refs, explicitFromLabel) {
|
|
4405
|
-
const resolution = await resolveContractRef(parsed, input.space, {
|
|
4406
|
-
...explicitFromLabel !== void 0 ? { explicitLabel: explicitFromLabel } : {},
|
|
4407
|
-
artifactRole: "from"
|
|
4408
|
-
});
|
|
4409
|
-
if (!resolution.ok) return resolution;
|
|
4410
|
-
if (resolution.value.kind === "graph-node") return ok({
|
|
4411
|
-
kind: "graph-node",
|
|
4412
|
-
fromHash: resolution.value.hash,
|
|
4413
|
-
fromContract: resolution.value.contract
|
|
4414
|
-
});
|
|
4415
|
-
const { hash, contract } = resolution.value;
|
|
4416
|
-
if (graphIsEmpty(input.space)) return ok({
|
|
4417
|
-
kind: "auto-baseline",
|
|
4418
|
-
fromHash: hash,
|
|
4419
|
-
fromContract: contract
|
|
4420
|
-
});
|
|
4421
|
-
const graph = input.space.graph();
|
|
4422
|
-
const graphTip = findLatestMigration(graph)?.to ?? null;
|
|
4423
|
-
try {
|
|
4424
|
-
assertFromIsGraphNode(hash, graph, refs, graphTip);
|
|
4425
|
-
} catch (error) {
|
|
4426
|
-
if (CliStructuredError$1.is(error)) return notOk(error);
|
|
4427
|
-
throw error;
|
|
4428
|
-
}
|
|
4429
|
-
return ok({
|
|
4430
|
-
kind: "ref",
|
|
4431
|
-
fromHash: hash,
|
|
4432
|
-
fromContract: contract
|
|
4433
|
-
});
|
|
4434
|
-
}
|
|
4435
|
-
async function resolveFromForPlan(input) {
|
|
4436
|
-
const { optionsFrom, space } = input;
|
|
4437
|
-
const graph = space.graph();
|
|
4438
|
-
const refs = space.refs;
|
|
4439
|
-
if (optionsFrom === void 0) {
|
|
4440
|
-
const dbRef = refs["db"];
|
|
4441
|
-
if (!dbRef) {
|
|
4442
|
-
if (graphIsEmpty(space)) return ok({
|
|
4443
|
-
kind: "greenfield",
|
|
4444
|
-
fromHash: null,
|
|
4445
|
-
fromContract: null,
|
|
4446
|
-
defaulted: true
|
|
4447
|
-
});
|
|
4448
|
-
return notOk(errorPlanOriginUnknown(getReachableRefs(refs, graph), findLatestMigration(graph)?.to ?? null));
|
|
4449
|
-
}
|
|
4450
|
-
const resolved = await resolveFromPolicy({
|
|
4451
|
-
hash: dbRef.hash,
|
|
4452
|
-
provenance: {
|
|
4453
|
-
kind: "ref",
|
|
4454
|
-
refName: "db"
|
|
4455
|
-
}
|
|
4456
|
-
}, input, refs);
|
|
4457
|
-
if (!resolved.ok) return resolved;
|
|
4458
|
-
const value = resolved.value;
|
|
4459
|
-
if (value.kind === "ref" || value.kind === "graph-node") {
|
|
4460
|
-
const tipHash = findUnambiguousTip(graph);
|
|
4461
|
-
if (tipHash !== null && tipHash !== value.fromHash) return ok({
|
|
4462
|
-
...value,
|
|
4463
|
-
defaultOriginBehindTip: {
|
|
4464
|
-
refName: "db",
|
|
4465
|
-
refHash: value.fromHash,
|
|
4466
|
-
tipHash
|
|
4467
|
-
}
|
|
4468
|
-
});
|
|
4469
|
-
}
|
|
4470
|
-
return resolved;
|
|
4471
|
-
}
|
|
4472
|
-
const refResult = parseContractRef(optionsFrom, {
|
|
4473
|
-
graph,
|
|
4474
|
-
refs
|
|
4475
|
-
});
|
|
4476
|
-
if (!refResult.ok) {
|
|
4477
|
-
if (looksLikeFullHash(optionsFrom)) {
|
|
4478
|
-
const empty = graphIsEmpty(space);
|
|
4479
|
-
const graphTip = findLatestMigration(graph)?.to ?? null;
|
|
4480
|
-
if (empty) return notOk(errorSnapshotMissing(optionsFrom, { viaRef: false }));
|
|
4481
|
-
return notOk(errorPlanForgotTheFlag(optionsFrom, getReachableRefs(refs, graph), graphTip));
|
|
4482
|
-
}
|
|
4483
|
-
return notOk(mapRefResolutionError(refResult.failure));
|
|
4484
|
-
}
|
|
4485
|
-
if (refResult.value.provenance.kind === "reserved-empty") return ok({
|
|
4486
|
-
kind: "greenfield",
|
|
4487
|
-
fromHash: null,
|
|
4488
|
-
fromContract: null,
|
|
4489
|
-
defaulted: false
|
|
4490
|
-
});
|
|
4491
|
-
return resolveFromPolicy(refResult.value, input, refs, optionsFrom);
|
|
4492
|
-
}
|
|
4493
|
-
async function resolveToForPlan(optionsTo, input) {
|
|
4494
|
-
const { space } = input;
|
|
4495
|
-
const graph = space.graph();
|
|
4496
|
-
const refs = space.refs;
|
|
4497
|
-
const refResult = parseContractRef(optionsTo, {
|
|
4498
|
-
graph,
|
|
4499
|
-
refs
|
|
4500
|
-
});
|
|
4501
|
-
if (!refResult.ok) return notOk(mapRefResolutionError(refResult.failure));
|
|
4502
|
-
if (refResult.value.provenance.kind === "reserved-empty") return notOk(mapRefResolutionError({
|
|
4503
|
-
kind: "wrong-grammar",
|
|
4504
|
-
input: optionsTo,
|
|
4505
|
-
expectedGrammar: "contract",
|
|
4506
|
-
message: "`@empty` is only valid as an origin (`--from`); planning a migration to the empty contract is not supported through this shortcut",
|
|
4507
|
-
fix: "Pass `--to` a contract hash, ref name, or migration directory name. To plan starting from an empty database, use `--from @empty`."
|
|
4508
|
-
}));
|
|
4509
|
-
const resolution = await resolveContractRef(refResult.value, space, {
|
|
4510
|
-
explicitLabel: optionsTo,
|
|
4511
|
-
artifactRole: "to"
|
|
4512
|
-
});
|
|
4513
|
-
if (!resolution.ok) return resolution;
|
|
4514
|
-
const { hash, contract } = resolution.value;
|
|
4515
|
-
return ok({
|
|
4516
|
-
hash,
|
|
4517
|
-
contract
|
|
4518
|
-
});
|
|
4519
|
-
}
|
|
4520
4542
|
/**
|
|
4521
4543
|
* Policy core of `migration plan`: resolves from/to contracts, runs the planner legs, and writes the planned migration packages.
|
|
4522
4544
|
*/
|
|
@@ -4688,8 +4710,8 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
|
|
|
4688
4710
|
});
|
|
4689
4711
|
if (!resolutionResult.ok) return notOk(resolutionResult.failure);
|
|
4690
4712
|
const warnings = [];
|
|
4691
|
-
const
|
|
4692
|
-
warnings.push(`The default origin ref '${
|
|
4713
|
+
const warnForks = (forks) => {
|
|
4714
|
+
warnings.push(`The default origin ref '${forks.refName}' points at ${forks.refHash}, which already has a migration leading to ${forks.outgoingTo.join(", ")}. Planning from it forks the migration graph; pass --from to choose the origin explicitly.`);
|
|
4693
4715
|
};
|
|
4694
4716
|
switch (resolutionResult.value.kind) {
|
|
4695
4717
|
case "greenfield":
|
|
@@ -4698,13 +4720,13 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
|
|
|
4698
4720
|
case "graph-node":
|
|
4699
4721
|
fromHash = resolutionResult.value.fromHash;
|
|
4700
4722
|
fromContract = resolutionResult.value.fromContract;
|
|
4701
|
-
if (resolutionResult.value.
|
|
4723
|
+
if (resolutionResult.value.defaultOriginForks !== void 0) warnForks(resolutionResult.value.defaultOriginForks);
|
|
4702
4724
|
break;
|
|
4703
4725
|
case "ref":
|
|
4704
4726
|
fromHash = resolutionResult.value.fromHash;
|
|
4705
4727
|
fromContract = resolutionResult.value.fromContract;
|
|
4706
4728
|
fromContractInStore = true;
|
|
4707
|
-
if (resolutionResult.value.
|
|
4729
|
+
if (resolutionResult.value.defaultOriginForks !== void 0) warnForks(resolutionResult.value.defaultOriginForks);
|
|
4708
4730
|
break;
|
|
4709
4731
|
case "auto-baseline":
|
|
4710
4732
|
fromHash = resolutionResult.value.fromHash;
|
|
@@ -5014,10 +5036,7 @@ async function executeRefSetCommand(name, contractInput, options) {
|
|
|
5014
5036
|
resolvedHash = refResult.value.hash;
|
|
5015
5037
|
}
|
|
5016
5038
|
if (resolvedHash === "empty") return notOk(errorRefSetEmptySentinel(resolvedHash));
|
|
5017
|
-
if (!isGraphNode(resolvedHash, graph))
|
|
5018
|
-
const graphTip = findLatestMigration(graph)?.to ?? null;
|
|
5019
|
-
return notOk(errorRefSetHashNotInGraph(resolvedHash, [...graph.nodes].sort(), graphTip));
|
|
5020
|
-
}
|
|
5039
|
+
if (!isGraphNode(resolvedHash, graph)) return notOk(errorRefSetHashNotInGraph(resolvedHash, [...graph.nodes].sort()));
|
|
5021
5040
|
if (!bundles.find((bundle) => bundle.metadata.to === resolvedHash)) return notOk(errorRefSetBundleNotFound(resolvedHash));
|
|
5022
5041
|
const contractJsonPath = join(contractSnapshotDir(migrationsDir, resolvedHash), "contract.json");
|
|
5023
5042
|
try {
|
|
@@ -5073,4 +5092,4 @@ async function executeRefListCommand(options) {
|
|
|
5073
5092
|
//#endregion
|
|
5074
5093
|
export { formatSourceDiagnostic as $, errorLegendHumanOnly as A, runContractSpaceSeedPhase as At, errorUnexpected as B, errorContractArgConflict as C, resolveAppTargetPath as Ct, errorDriverRequired as D, resolveMigrationRef as Dt, errorDestructiveChanges as E, resolveFromForPlan as Et, errorPathUnreachable as F, statusForMigrationHash as Ft, executeMigrateShowPlan as G, executeDbInit as H, errorRunnerFailed as I, targetSupportsMigrations as It, executeRefAdvancement as J, executeMigrationNewCommand as K, errorRuntime as L, toDeclaredExtensionsFromRaw as Lt, errorMigrationPackageNotFound as M, runMigrationList as Mt, errorMigrationPlanningFailed as N, sanitizeErrorMessage as Nt, errorFileNotFound as O, resolveToForPlan as Ot, errorNoMigrations as P, snapshotVerifierFor as Pt, findPackageByDirPath as Q, errorTargetMigrationNotSupported as R, errorConsentPlanMismatch as S, requireLiveDatabase as St, errorDatabaseConnectionRequired as T, resolveContractRefToSnapshot as Tt, executeDbUpdate as U, executeContractEmit as V, executeDbVerify as W, executeRefListCommand as X, executeRefDeleteCommand as Y, executeRefSetCommand as Z, disposeEmitQueue as _, refuseDeclaredExtensionTargetMismatch as _t, appContractStandInFromIdentity as a, loadContractSpaceAggregateForCli as at, errorAdvanceRefArgConflict as b, refusePackageCorruptionOnAggregate as bt, buildMigrationSpaceGraphEntries as c, mapContractAtError as ct, checkSingleTarget as d, migrationSpaceListEntriesFromAggregate as dt, hasMigrationPath as et, chooseAction as f, originHashForStatus as ft, deriveStatusEdgeAnnotations as g, refuseContractSpaceIntegrity as gt, createControlClient as h, readMigrationRefs as ht, advanceRefSafely as i, loadContractSource as it, errorMarkerMissing as j, runMigrationCheck as jt, errorHashMismatch as k, runCommandAction as kt, buildReadAggregate as l, mapIntegrityViolations as lt, computeRefAdvancementName as m, readContractEnvelope as mt, ERROR_CODE_DESTRUCTIVE_CHANGES as n, loadAggregateIntegrityViolations as nt, appliedHashesFromLedger as o, looksLikePath as ot, closeQuietly as p, preflightRefAdvancement as pt, executeMigrationPlanCommand as q, NO_REF_ADVANCEMENT as r, loadContractRawSafely as rt, buildContractSpaceAggregate as s, mapCaughtMigrationError as st, CliStructuredError$1 as t, listRefsByContractHash as tt, buildRefAdvancementFields as u, maskConnectionUrl as ut, enrichContract as v, refuseMarkerOutsideGraph as vt, errorContractValidationFailed as w, resolveContractRef$1 as wt, errorConfigValidation$1 as x, refuseUnknownInvariants as xt, enumerateCheckSpaces as y, refuseMissingInvariantPath as yt, errorTargetMismatch as z };
|
|
5075
5094
|
|
|
5076
|
-
//# sourceMappingURL=ref-
|
|
5095
|
+
//# sourceMappingURL=ref-CTp4Kvp--3Dgd8LXq.mjs.map
|