@prisma/orm-toolchain 8.0.0-rc.14-dev.37 → 8.0.0-rc.14-dev.39
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-qXuJ6w_I.mjs → aggregate-C7IHVcsV.mjs} +7 -3
- package/dist/aggregate-C7IHVcsV.mjs.map +1 -0
- package/dist/{aggregate-5NMLDtcl.d.mts → aggregate-DLptsx8n.d.mts} +4 -2
- package/dist/aggregate-DLptsx8n.d.mts.map +1 -0
- package/dist/cli.mjs +170 -111
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +14 -21
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +2 -2
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/{db-sign-BxYV7wMQ-BB1hlVbH.d.mts → db-sign-BxYV7wMQ-CNy01Yj7.d.mts} +2 -2
- package/dist/{db-sign-BxYV7wMQ-BB1hlVbH.d.mts.map → db-sign-BxYV7wMQ-CNy01Yj7.d.mts.map} +1 -1
- package/dist/graph-membership-C_ZO26nT-B7C4CJsh.mjs +19 -0
- package/dist/graph-membership-C_ZO26nT-B7C4CJsh.mjs.map +1 -0
- package/dist/{migration-graph-De1gCcTL.d.mts → migration-graph-Dra4CcyN.d.mts} +7 -2
- package/dist/migration-graph-Dra4CcyN.d.mts.map +1 -0
- package/dist/migration-tools.d.mts +4 -4
- package/dist/migration-tools.mjs +4 -4
- package/dist/migration-tools__aggregate.d.mts +2 -2
- package/dist/migration-tools__aggregate.mjs +2 -2
- package/dist/migration-tools__migration-graph.d.mts +2 -2
- package/dist/migration-tools__migration-graph.mjs +2 -2
- package/dist/migration-tools__ref-resolution.d.mts +2 -2
- package/dist/migration-tools__ref-resolution.mjs +2 -2
- package/dist/{ref-Bcy3ShDD-S7NKefbN.mjs → ref-DQpde3VD-BW3Yc5ni.mjs} +145 -90
- package/dist/ref-DQpde3VD-BW3Yc5ni.mjs.map +1 -0
- package/dist/{ref-resolution-CaHQJXE0.d.mts → ref-resolution-BPhR-kta.d.mts} +20 -12
- package/dist/ref-resolution-BPhR-kta.d.mts.map +1 -0
- package/dist/{ref-resolution-CoHoeFT7.mjs → ref-resolution-d7rcmU6F.mjs} +22 -5
- package/dist/ref-resolution-d7rcmU6F.mjs.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/aggregate-5NMLDtcl.d.mts.map +0 -1
- package/dist/aggregate-qXuJ6w_I.mjs.map +0 -1
- package/dist/graph-membership-BQ43lP4A-i4Ov419-.mjs +0 -14
- package/dist/graph-membership-BQ43lP4A-i4Ov419-.mjs.map +0 -1
- package/dist/migration-graph-De1gCcTL.d.mts.map +0 -1
- package/dist/ref-Bcy3ShDD-S7NKefbN.mjs.map +0 -1
- package/dist/ref-resolution-CaHQJXE0.d.mts.map +0 -1
- package/dist/ref-resolution-CoHoeFT7.mjs.map +0 -1
|
@@ -8,13 +8,13 @@ import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
|
8
8
|
import { i as findPathWithDecision, r as findPath } from "./migration-graph-BoiiZAaU-DLht12k7.mjs";
|
|
9
9
|
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-FXABEJZE.mjs";
|
|
10
10
|
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-CzLQQYa9.mjs";
|
|
11
|
-
import { A as errorRefSetBundleNotFound, B as errorUnexpected, D as errorPathUnreachable, H as mapRefResolutionError, I as errorSnapshotMissing, J as resolveMigrationPaths, K as requireLiveDatabase, L as errorSpaceNotFound, M as errorRefSetHashNotInGraph, O as errorPlanForgotTheFlag, P as errorRuntime, R as errorTargetMigrationNotSupported, S as errorMarkerMismatch, T as errorMigrationPlanningFailed, V as getTargetMigrations, W as readContractEnvelope, Y as runCommandAction, Z as toStructuralEdge, _ as errorFileNotFound, a as closeQuietly, b as errorInvalidSpaceId, c as errorAmbiguousMigrationRef, f as errorContractConfigMissing, h as errorDestructiveChanges, i as chooseAction, j as errorRefSetEmptySentinel, k as errorPlanOriginUnknown, l as errorConfigValidation$1,
|
|
11
|
+
import { A as errorRefSetBundleNotFound, B as errorUnexpected, D as errorPathUnreachable, H as mapRefResolutionError, I as errorSnapshotMissing, J as resolveMigrationPaths, K as requireLiveDatabase, L as errorSpaceNotFound, M as errorRefSetHashNotInGraph, O as errorPlanForgotTheFlag, P as errorRuntime, R as errorTargetMigrationNotSupported, S as errorMarkerMismatch, T as errorMigrationPlanningFailed, V as getTargetMigrations, W as readContractEnvelope, Y as runCommandAction, Z as toStructuralEdge, _ as errorFileNotFound, a as closeQuietly, b as errorInvalidSpaceId, c as errorAmbiguousMigrationRef, f as errorContractConfigMissing, h as errorDestructiveChanges, i as chooseAction, j as errorRefSetEmptySentinel, k as errorPlanOriginUnknown, l as errorConfigValidation$1, n as CliStructuredError$1, o as collectDeclaredInvariants, p as errorContractValidationFailed, q as resolveContractPath, u as errorConsentPlanMismatch, v as errorFromCaught } from "./caught-errors-DUIDd-Vm-RNMiEz4x.mjs";
|
|
12
12
|
import { r as getEmittedArtifactPaths, t as emit } from "./exports-B41NJHCo-BaEu3TXy.mjs";
|
|
13
|
-
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-
|
|
13
|
+
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-C_ZO26nT-B7C4CJsh.mjs";
|
|
14
14
|
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-X8sR92eT.mjs";
|
|
15
|
-
import { d as
|
|
15
|
+
import { a as contractHashAtMarker, c as loadContractSpaceAggregate, d as requireHeadRef, f as resolveRecordedPath, m as verifyMigration, n as buildFabricatedMigrationEdge, p as spacesInApplyOrder, r as collectAggregateNamespaces, t as allStorageElementsExternal, u as planMigration } from "./aggregate-C7IHVcsV.mjs";
|
|
16
16
|
import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-BeAYfehL.mjs";
|
|
17
|
-
import {
|
|
17
|
+
import { c as parseContractRef, l as parseMigrationRef, o as isLiveMarkerRef, r as RESERVED_CONTRACT_REFS, s as isReservedContractRef, t as EMPTY_CONTRACT_REF } from "./ref-resolution-d7rcmU6F.mjs";
|
|
18
18
|
import { i as writeMigrationTs } from "./migration-ts-BQuIba9e.mjs";
|
|
19
19
|
import { createRequire } from "node:module";
|
|
20
20
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -33,7 +33,7 @@ import { notOk, ok } from "@prisma/orm-framework/utils/result";
|
|
|
33
33
|
import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/components";
|
|
34
34
|
import { abortable } from "@prisma/orm-framework/utils/abortable";
|
|
35
35
|
import { resolve as resolve$1 } from "node:path";
|
|
36
|
-
//#region ../../../1-framework/3-tooling/cli/dist/ref-
|
|
36
|
+
//#region ../../../1-framework/3-tooling/cli/dist/ref-DQpde3VD.mjs
|
|
37
37
|
/**
|
|
38
38
|
* Asserts that all framework components are compatible with the expected family and target.
|
|
39
39
|
*
|
|
@@ -1558,7 +1558,7 @@ async function executeMigrate(options) {
|
|
|
1558
1558
|
const markerRows = await familyInstance.readAllMarkers({ driver });
|
|
1559
1559
|
const allSpaces = [aggregate.app, ...aggregate.extensions];
|
|
1560
1560
|
const perSpacePlans = /* @__PURE__ */ new Map();
|
|
1561
|
-
const
|
|
1561
|
+
const plansKeptFromRunner = /* @__PURE__ */ new Map();
|
|
1562
1562
|
for (const space of allSpaces) {
|
|
1563
1563
|
const isAppSpace = space.spaceId === aggregate.app.spaceId;
|
|
1564
1564
|
const headRef = requireHeadRef(space);
|
|
@@ -1572,7 +1572,7 @@ async function executeMigrate(options) {
|
|
|
1572
1572
|
...isAppSpace ? { refName } : {}
|
|
1573
1573
|
});
|
|
1574
1574
|
if (outcome.kind === "at-head") {
|
|
1575
|
-
|
|
1575
|
+
plansKeptFromRunner.set(space.spaceId, outcome.plan);
|
|
1576
1576
|
continue;
|
|
1577
1577
|
}
|
|
1578
1578
|
if (outcome.kind === "never-planned") return notOk(buildNeverPlannedFailure(outcome.spaceId, outcome.targetHash, migrationsDir));
|
|
@@ -1593,7 +1593,8 @@ async function executeMigrate(options) {
|
|
|
1593
1593
|
structuralPath
|
|
1594
1594
|
});
|
|
1595
1595
|
}
|
|
1596
|
-
|
|
1596
|
+
if (leavesUnmarkedSpaceUntouched(outcome.plan)) plansKeptFromRunner.set(space.spaceId, outcome.plan);
|
|
1597
|
+
else perSpacePlans.set(space.spaceId, outcome.plan);
|
|
1597
1598
|
}
|
|
1598
1599
|
const canonicalOrder = spacesInApplyOrder(aggregate).map((space) => space.spaceId);
|
|
1599
1600
|
const applyOrder = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId));
|
|
@@ -1601,8 +1602,8 @@ async function executeMigrate(options) {
|
|
|
1601
1602
|
const entry = perSpacePlans.get(spaceId);
|
|
1602
1603
|
return entry !== void 0 && planRequiresExecution(entry);
|
|
1603
1604
|
})) {
|
|
1604
|
-
const ordered = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) ||
|
|
1605
|
-
const entry = perSpacePlans.get(spaceId) ??
|
|
1605
|
+
const ordered = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) || plansKeptFromRunner.has(spaceId)).map((spaceId) => {
|
|
1606
|
+
const entry = perSpacePlans.get(spaceId) ?? plansKeptFromRunner.get(spaceId);
|
|
1606
1607
|
if (entry === void 0) throw new InternalError(`Unreachable: missing per-space plan for "${spaceId}"`);
|
|
1607
1608
|
return {
|
|
1608
1609
|
spaceId,
|
|
@@ -1643,12 +1644,12 @@ async function executeMigrate(options) {
|
|
|
1643
1644
|
meta: applied.failure.meta,
|
|
1644
1645
|
...ifDefined("cause", applied.failure.cause)
|
|
1645
1646
|
});
|
|
1646
|
-
const orderedAll = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) ||
|
|
1647
|
+
const orderedAll = canonicalOrder.filter((spaceId) => perSpacePlans.has(spaceId) || plansKeptFromRunner.has(spaceId)).map((spaceId) => {
|
|
1647
1648
|
if (perSpacePlans.has(spaceId)) {
|
|
1648
1649
|
const fromRunner = applied.value.orderedResolutions.find((r) => r.spaceId === spaceId);
|
|
1649
1650
|
if (fromRunner !== void 0) return fromRunner;
|
|
1650
1651
|
}
|
|
1651
|
-
const entry =
|
|
1652
|
+
const entry = plansKeptFromRunner.get(spaceId);
|
|
1652
1653
|
if (entry === void 0) throw new InternalError(`Unreachable: missing per-space plan for "${spaceId}"`);
|
|
1653
1654
|
return {
|
|
1654
1655
|
spaceId,
|
|
@@ -1789,6 +1790,10 @@ function buildAtHeadResolution(args) {
|
|
|
1789
1790
|
})]
|
|
1790
1791
|
};
|
|
1791
1792
|
}
|
|
1793
|
+
/** Handing this plan to the runner would write a marker the database never had. */
|
|
1794
|
+
function leavesUnmarkedSpaceUntouched(entry) {
|
|
1795
|
+
return !entry.plan.origin && !planRequiresExecution(entry);
|
|
1796
|
+
}
|
|
1792
1797
|
/**
|
|
1793
1798
|
* A plan needs the runner when it executes operations or advances the
|
|
1794
1799
|
* space's marker (a declared-state resolution has zero operations but a
|
|
@@ -1796,7 +1801,7 @@ function buildAtHeadResolution(args) {
|
|
|
1796
1801
|
*/
|
|
1797
1802
|
function planRequiresExecution(entry) {
|
|
1798
1803
|
if (entry.plan.operations.length > 0) return true;
|
|
1799
|
-
return entry.plan.origin
|
|
1804
|
+
return contractHashAtMarker(entry.plan.origin) !== entry.plan.destination.storageHash;
|
|
1800
1805
|
}
|
|
1801
1806
|
function buildSuccess(args) {
|
|
1802
1807
|
const appResolution = args.orderedResolutions.find((r) => r.spaceId === args.aggregate.app.spaceId);
|
|
@@ -2882,13 +2887,41 @@ async function advanceRefSafely(args) {
|
|
|
2882
2887
|
throw error;
|
|
2883
2888
|
}
|
|
2884
2889
|
}
|
|
2890
|
+
const RECORDED_FORMS = [
|
|
2891
|
+
"hash",
|
|
2892
|
+
"prefix",
|
|
2893
|
+
"ref name",
|
|
2894
|
+
"migration dir name",
|
|
2895
|
+
"<dir>^"
|
|
2896
|
+
];
|
|
2897
|
+
function listForms(forms) {
|
|
2898
|
+
return `${forms.slice(0, -1).join(", ")}, or ${forms.at(-1)}`;
|
|
2899
|
+
}
|
|
2900
|
+
/** The forms that name a contract recorded in the migrations directory. */
|
|
2901
|
+
const RECORDED_CONTRACT_REF_FORMS = listForms(RECORDED_FORMS);
|
|
2902
|
+
/** The recorded forms plus `@empty`. */
|
|
2903
|
+
const RECORDED_OR_EMPTY_CONTRACT_REF_FORMS = listForms([...RECORDED_FORMS, EMPTY_CONTRACT_REF]);
|
|
2904
|
+
/** The recorded forms plus every reserved reference. */
|
|
2905
|
+
const ALL_CONTRACT_REF_FORMS = listForms([...RECORDED_FORMS, ...RESERVED_CONTRACT_REFS]);
|
|
2885
2906
|
/**
|
|
2886
2907
|
* Resolves a user-supplied contract reference to an on-disk contract JSON (snapshot store or emitted contract), shared by db sign and db update --to.
|
|
2887
2908
|
*/
|
|
2888
2909
|
function isEnoent$1(error) {
|
|
2889
2910
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
2890
2911
|
}
|
|
2912
|
+
function reservedRefRefusal(options) {
|
|
2913
|
+
const { refInput: input, argument } = options;
|
|
2914
|
+
const accepted = `${options.fallbackToEmitted ? "a contract" : "a migration destination"} recorded in the migrations directory`;
|
|
2915
|
+
return {
|
|
2916
|
+
kind: "wrong-grammar",
|
|
2917
|
+
input,
|
|
2918
|
+
expectedGrammar: "contract",
|
|
2919
|
+
message: `"${input}" is a reserved reference; ${argument} takes ${accepted} (${RECORDED_CONTRACT_REF_FORMS})`,
|
|
2920
|
+
fix: `Name ${accepted}, or omit ${argument} to use the emitted contract.`
|
|
2921
|
+
};
|
|
2922
|
+
}
|
|
2891
2923
|
async function resolveContractRefToSnapshot(options) {
|
|
2924
|
+
if (isReservedContractRef(options.refInput)) return notOk(mapRefResolutionError(reservedRefRefusal(options)));
|
|
2892
2925
|
try {
|
|
2893
2926
|
const loaded = await buildReadAggregate(options.config, { migrationsDir: options.migrationsDir });
|
|
2894
2927
|
if (!loaded.ok) return notOk(loaded.failure);
|
|
@@ -2907,7 +2940,7 @@ async function resolveContractRefToSnapshot(options) {
|
|
|
2907
2940
|
contractJsonPath: join(contractSnapshotDir(options.migrationsDir, targetHash), "contract.json"),
|
|
2908
2941
|
source: "snapshot"
|
|
2909
2942
|
});
|
|
2910
|
-
if (!options.fallbackToEmitted) return notOk(errorUnexpected(`No migration bundle found for ${options.
|
|
2943
|
+
if (!options.fallbackToEmitted) return notOk(errorUnexpected(`No migration bundle found for ${options.argument} "${options.refInput}" (resolved hash: ${targetHash})`, {
|
|
2911
2944
|
why: `The ref resolved successfully but no on-disk migration package has a destination (\`to\`) hash matching ${targetHash}.`,
|
|
2912
2945
|
fix: "Provide a ref or hash that corresponds to an existing migration package, or run `migration list` to see available migrations."
|
|
2913
2946
|
}));
|
|
@@ -2947,6 +2980,54 @@ async function resolveContractRefToSnapshot(options) {
|
|
|
2947
2980
|
throw error;
|
|
2948
2981
|
}
|
|
2949
2982
|
}
|
|
2983
|
+
function resolveContractRef$1(input, context) {
|
|
2984
|
+
const result = parseContractRef(input, context);
|
|
2985
|
+
return result.ok ? ok(result.value) : notOk(mapRefResolutionError(result.failure));
|
|
2986
|
+
}
|
|
2987
|
+
function resolveMigrationRef(input, context) {
|
|
2988
|
+
const result = parseMigrationRef(input, context);
|
|
2989
|
+
return result.ok ? ok(result.value) : notOk(mapRefResolutionError(result.failure));
|
|
2990
|
+
}
|
|
2991
|
+
/** Where `--from`/`--to` read the live marker: an omitted or `@db` origin, and an `@db` target. */
|
|
2992
|
+
function liveMarkerUse(flags) {
|
|
2993
|
+
const liveOrigin = flags.from === void 0 || isLiveMarkerRef(flags.from);
|
|
2994
|
+
const liveTarget = isLiveMarkerRef(flags.to);
|
|
2995
|
+
return {
|
|
2996
|
+
liveOrigin,
|
|
2997
|
+
liveTarget,
|
|
2998
|
+
needsDatabase: liveOrigin || liveTarget
|
|
2999
|
+
};
|
|
3000
|
+
}
|
|
3001
|
+
/** The command a missing-connection error suggests: the user's flags as given, plus what the retry needs to run. */
|
|
3002
|
+
function retryCommandFor(args) {
|
|
3003
|
+
const namesLiveMarker = isLiveMarkerRef(args.from) || isLiveMarkerRef(args.to);
|
|
3004
|
+
const suggestsOffline = args.canRunOffline && args.from === void 0 && !namesLiveMarker;
|
|
3005
|
+
const needsConnection = !args.canRunOffline || namesLiveMarker;
|
|
3006
|
+
return [
|
|
3007
|
+
`{bin} ${args.commandName}`,
|
|
3008
|
+
...args.from === void 0 ? [] : [`--from ${args.from}`],
|
|
3009
|
+
...suggestsOffline ? ["--from <contract>"] : [],
|
|
3010
|
+
...args.to === void 0 ? [] : [`--to ${args.to}`],
|
|
3011
|
+
...args.advanceRef === void 0 ? [] : [`--advance-ref ${args.advanceRef}`],
|
|
3012
|
+
...needsConnection ? ["--db $DATABASE_URL"] : []
|
|
3013
|
+
].join(" ");
|
|
3014
|
+
}
|
|
3015
|
+
/** The missing-connection error for a command whose `--from`/`--to` read the live marker, or `null`. */
|
|
3016
|
+
function requireDatabaseForLiveMarkerUse(args) {
|
|
3017
|
+
if (!liveMarkerUse(args).needsDatabase) return null;
|
|
3018
|
+
return requireLiveDatabase({
|
|
3019
|
+
dbConnection: args.dbConnection,
|
|
3020
|
+
hasDriver: args.hasDriver,
|
|
3021
|
+
why: isLiveMarkerRef(args.from) || isLiveMarkerRef(args.to) ? `@db resolves to the live database marker and requires a --db connection` : `${args.commandName} needs a database connection to read the live marker (or pass --from <contract> to run offline)`,
|
|
3022
|
+
commandName: args.commandName,
|
|
3023
|
+
retryCommand: retryCommandFor({
|
|
3024
|
+
commandName: args.commandName,
|
|
3025
|
+
from: args.from,
|
|
3026
|
+
to: args.to,
|
|
3027
|
+
canRunOffline: true
|
|
3028
|
+
})
|
|
3029
|
+
});
|
|
3030
|
+
}
|
|
2950
3031
|
function mapContractAtError(error, options) {
|
|
2951
3032
|
if (MigrationToolsError.is(error)) switch (error.code) {
|
|
2952
3033
|
case "MIGRATION.REF_NOT_RESOLVABLE": return notOk(errorSnapshotMissing(typeof error.meta?.["refName"] === "string" ? error.meta["refName"] : typeof error.meta?.["identifier"] === "string" ? error.meta["identifier"] : "unknown", { cause: error }));
|
|
@@ -3040,17 +3121,20 @@ async function executeMigrateShowPlan(options) {
|
|
|
3040
3121
|
const config = options.config;
|
|
3041
3122
|
const { configPath, migrationsDir, migrationsRelative, refsDir } = resolveMigrationPaths(config, options.cwd);
|
|
3042
3123
|
const dbConnection = options.db ?? config.db?.connection;
|
|
3043
|
-
const
|
|
3124
|
+
const driver = config.driver;
|
|
3044
3125
|
const hasExplicitFrom = options.from !== void 0;
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3126
|
+
const { liveOrigin, liveTarget, needsDatabase } = liveMarkerUse({
|
|
3127
|
+
from: options.from,
|
|
3128
|
+
to: options.to
|
|
3129
|
+
});
|
|
3130
|
+
const missingDb = requireDatabaseForLiveMarkerUse({
|
|
3131
|
+
from: options.from,
|
|
3132
|
+
to: options.to,
|
|
3133
|
+
dbConnection,
|
|
3134
|
+
hasDriver: driver !== void 0,
|
|
3135
|
+
commandName: "db migrate --show"
|
|
3136
|
+
});
|
|
3137
|
+
if (missingDb) return notOk(missingDb);
|
|
3054
3138
|
let allRefs = {};
|
|
3055
3139
|
try {
|
|
3056
3140
|
allRefs = await readRefs(refsDir);
|
|
@@ -3064,17 +3148,14 @@ async function executeMigrateShowPlan(options) {
|
|
|
3064
3148
|
const appGraph = aggregate.app.graph();
|
|
3065
3149
|
let targetHash = contractHash;
|
|
3066
3150
|
let refInvariants;
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
if (toResult.
|
|
3075
|
-
why: "@db is not valid as a --to target; it names the live database state, not a target contract.",
|
|
3076
|
-
commandName: "migrate --show"
|
|
3077
|
-
}));
|
|
3151
|
+
const refContext = {
|
|
3152
|
+
graph: appGraph,
|
|
3153
|
+
refs: allRefs,
|
|
3154
|
+
contractHash
|
|
3155
|
+
};
|
|
3156
|
+
if (options.to && !liveTarget) {
|
|
3157
|
+
const toResult = resolveContractRef$1(options.to, refContext);
|
|
3158
|
+
if (!toResult.ok) return notOk(toResult.failure);
|
|
3078
3159
|
targetHash = toResult.value.hash;
|
|
3079
3160
|
if (toResult.value.provenance.kind === "ref") {
|
|
3080
3161
|
const refEntry = allRefs[toResult.value.provenance.refName];
|
|
@@ -3088,58 +3169,43 @@ async function executeMigrateShowPlan(options) {
|
|
|
3088
3169
|
hasExplicitFrom
|
|
3089
3170
|
});
|
|
3090
3171
|
const markerBySpace = /* @__PURE__ */ new Map();
|
|
3172
|
+
let databaseMarkers;
|
|
3091
3173
|
const allSpaces = [aggregate.app, ...aggregate.extensions];
|
|
3092
|
-
if (
|
|
3093
|
-
const
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
const fromResult = parseContractRef(options.from, {
|
|
3102
|
-
graph: appGraph,
|
|
3103
|
-
refs: allRefs,
|
|
3104
|
-
contractHash
|
|
3105
|
-
});
|
|
3106
|
-
if (!fromResult.ok) return notOk(mapRefResolutionError(fromResult.failure));
|
|
3107
|
-
if (fromResult.value.provenance.kind === "reserved-db") {
|
|
3108
|
-
const missingDb = requireLiveDatabase({
|
|
3109
|
-
dbConnection,
|
|
3110
|
-
hasDriver,
|
|
3111
|
-
why: "@db resolves to the live database marker and requires a --db connection"
|
|
3112
|
-
});
|
|
3113
|
-
if (missingDb) return notOk(missingDb);
|
|
3114
|
-
} else {
|
|
3115
|
-
const fromHash = fromResult.value.hash;
|
|
3116
|
-
const offlineMarker = fromHash === "empty" ? null : {
|
|
3117
|
-
storageHash: fromHash,
|
|
3118
|
-
invariants: []
|
|
3119
|
-
};
|
|
3120
|
-
markerBySpace.set(aggregate.app.spaceId, offlineMarker);
|
|
3121
|
-
}
|
|
3174
|
+
if (options.from !== void 0 && !liveOrigin) {
|
|
3175
|
+
const fromResult = resolveContractRef$1(options.from, refContext);
|
|
3176
|
+
if (!fromResult.ok) return notOk(fromResult.failure);
|
|
3177
|
+
const fromHash = fromResult.value.hash;
|
|
3178
|
+
const offlineMarker = fromHash === "empty" ? null : {
|
|
3179
|
+
storageHash: fromHash,
|
|
3180
|
+
invariants: []
|
|
3181
|
+
};
|
|
3182
|
+
markerBySpace.set(aggregate.app.spaceId, offlineMarker);
|
|
3122
3183
|
}
|
|
3123
|
-
|
|
3124
|
-
if (needsLiveMarker) {
|
|
3125
|
-
if (!dbConnection || !hasDriver) return notOk(errorDatabaseConnectionRequired({
|
|
3126
|
-
why: "A database connection is required to read the live marker for migrate --show",
|
|
3127
|
-
commandName: "migrate --show"
|
|
3128
|
-
}));
|
|
3184
|
+
if (needsDatabase && driver !== void 0) {
|
|
3129
3185
|
const client = (options.createClient ?? createControlClient)({
|
|
3130
3186
|
family: config.family,
|
|
3131
3187
|
target: config.target,
|
|
3132
3188
|
adapter: config.adapter,
|
|
3133
|
-
driver
|
|
3189
|
+
driver,
|
|
3134
3190
|
extensions: config.extensions ?? []
|
|
3135
3191
|
});
|
|
3136
3192
|
try {
|
|
3137
3193
|
await client.connect(dbConnection);
|
|
3138
3194
|
const allMarkers = await client.readAllMarkers();
|
|
3139
|
-
|
|
3195
|
+
databaseMarkers = allMarkers;
|
|
3196
|
+
const appMarker = allMarkers.get(aggregate.app.spaceId);
|
|
3197
|
+
if (appMarker !== void 0) {
|
|
3198
|
+
const refusal = refuseMarkerOutsideGraph({
|
|
3199
|
+
markerHash: appMarker.storageHash,
|
|
3200
|
+
graph: appGraph
|
|
3201
|
+
});
|
|
3202
|
+
if (refusal) return notOk(refusal);
|
|
3203
|
+
}
|
|
3204
|
+
if (liveOrigin) for (const space of allSpaces) {
|
|
3140
3205
|
const marker = allMarkers.get(space.spaceId);
|
|
3141
3206
|
markerBySpace.set(space.spaceId, marker ?? null);
|
|
3142
3207
|
}
|
|
3208
|
+
if (liveTarget) targetHash = contractHashAtMarker(appMarker);
|
|
3143
3209
|
} catch (error) {
|
|
3144
3210
|
return notOk(errorFromCaught(error, (message) => `Failed to read live DB marker: ${message}`, { connection: typeof dbConnection === "string" ? dbConnection : void 0 }));
|
|
3145
3211
|
} finally {
|
|
@@ -3198,23 +3264,16 @@ async function executeMigrateShowPlan(options) {
|
|
|
3198
3264
|
});
|
|
3199
3265
|
}
|
|
3200
3266
|
const count = orderedMigrations.length;
|
|
3267
|
+
const summary = count === 0 ? "Already up to date — nothing to run" : `${count} migration${count === 1 ? "" : "s"} will run`;
|
|
3268
|
+
const spacesUsingMarker = liveOrigin ? allSpaces : [aggregate.app];
|
|
3201
3269
|
return ok({
|
|
3202
3270
|
aggregate,
|
|
3203
3271
|
contractHash,
|
|
3204
3272
|
migrations: orderedMigrations,
|
|
3205
|
-
summary
|
|
3206
|
-
|
|
3207
|
-
usedLiveMarker: needsLiveMarker
|
|
3273
|
+
summary,
|
|
3274
|
+
...ifDefined("databaseMarkerHashBySpace", databaseMarkers === void 0 ? void 0 : new Map(spacesUsingMarker.map((space) => [space.spaceId, contractHashAtMarker(databaseMarkers.get(space.spaceId))])))
|
|
3208
3275
|
});
|
|
3209
3276
|
}
|
|
3210
|
-
function resolveContractRef$1(input, context) {
|
|
3211
|
-
const result = parseContractRef(input, context);
|
|
3212
|
-
return result.ok ? ok(result.value) : notOk(mapRefResolutionError(result.failure));
|
|
3213
|
-
}
|
|
3214
|
-
function resolveMigrationRef(input, context) {
|
|
3215
|
-
const result = parseMigrationRef(input, context);
|
|
3216
|
-
return result.ok ? ok(result.value) : notOk(mapRefResolutionError(result.failure));
|
|
3217
|
-
}
|
|
3218
3277
|
function compareSpaceIds(a, b) {
|
|
3219
3278
|
if (a === APP_SPACE_ID$1) return b === APP_SPACE_ID$1 ? 0 : -1;
|
|
3220
3279
|
if (b === APP_SPACE_ID$1) return 1;
|
|
@@ -4561,10 +4620,6 @@ function buildAutoBaselinePlanSummary(baselineOpsCount, deltaOpsCount, emittedEx
|
|
|
4561
4620
|
if (emittedExtensionDirsCount === 0) return base;
|
|
4562
4621
|
return `${base}; materialised ${emittedExtensionDirsCount} ${emittedExtensionDirsCount === 1 ? "extension-space migration" : "extension-space migrations"}`;
|
|
4563
4622
|
}
|
|
4564
|
-
/** Origin hash for status path computation: the live/override marker, or the empty-contract sentinel. */
|
|
4565
|
-
function originHashForStatus(markerHash) {
|
|
4566
|
-
return markerHash ?? "empty";
|
|
4567
|
-
}
|
|
4568
4623
|
function deriveStatusEdgeAnnotations(input) {
|
|
4569
4624
|
const annotations = /* @__PURE__ */ new Map();
|
|
4570
4625
|
if (input.showAppliedOverlay) {
|
|
@@ -4676,6 +4731,6 @@ async function executeRefListCommand(options) {
|
|
|
4676
4731
|
}
|
|
4677
4732
|
}
|
|
4678
4733
|
//#endregion
|
|
4679
|
-
export {
|
|
4734
|
+
export { refuseUnknownInvariants as $, executeRefListCommand as A, loadContractSourceWithStack as B, executeDbUpdate as C, executeMigrationPlanCommand as D, executeMigrationNewCommand as E, listRefsByContractHash as F, migrationSpaceListEntriesFromAggregate as G, looksLikePath as H, liveMarkerUse as I, refuseContractSpaceIntegrity as J, preflightRefAdvancement as K, loadAggregateIntegrityViolations as L, findPackageByDirPath as M, formatSourceDiagnostic as N, executeRefAdvancement as O, hasMigrationPath as P, refusePackageCorruptionOnAggregate as Q, loadContractRawSafely as R, executeDbSign as S, executeMigrateShowPlan as T, mapContractAtError as U, loadContractSpaceAggregateForCli as V, mapIntegrityViolations as W, refuseMarkerOutsideGraph as X, refuseDeclaredExtensionTargetMismatch as Y, refuseMissingInvariantPath as Z, disposeEmitQueue as _, RECORDED_OR_EMPTY_CONTRACT_REF_FORMS as a, resolveMigrationRef as at, executeContractEmit as b, appliedHashesFromLedger as c, runContractSpaceSeedPhase as ct, buildReadAggregate as d, snapshotVerifierFor as dt, requireDatabaseForLiveMarkerUse as et, buildRefAdvancementFields as f, sourceWarningDiagnostic as ft, deriveStatusEdgeAnnotations as g, createControlClient as h, validateLoadedContract as ht, RECORDED_CONTRACT_REF_FORMS as i, resolveFromForPlan as it, executeRefSetCommand as j, executeRefDeleteCommand as k, buildContractSpaceAggregate as l, runMigrationCheck as lt, computeRefAdvancementName as m, toDeclaredExtensionsFromRaw as mt, DB_UPDATE_POLICY as n, resolveContractRef$1 as nt, advanceRefSafely as o, resolveToForPlan as ot, checkSingleTarget as p, statusForMigrationHash as pt, readMigrationRefs as q, NO_REF_ADVANCEMENT as r, resolveContractRefToSnapshot as rt, appContractStandInFromIdentity as s, retryCommandFor as st, ALL_CONTRACT_REF_FORMS as t, resolveAppTargetPath as tt, buildMigrationSpaceGraphEntries as u, runMigrationList as ut, enrichContract as v, executeDbVerify as w, executeDbInit as x, enumerateCheckSpaces as y, loadContractSource as z };
|
|
4680
4735
|
|
|
4681
|
-
//# sourceMappingURL=ref-
|
|
4736
|
+
//# sourceMappingURL=ref-DQpde3VD-BW3Yc5ni.mjs.map
|