@prisma/orm-toolchain 8.0.0-rc.17-dev.27 → 8.0.0-rc.17-dev.29
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-DlfOyErc.mjs → aggregate-C0Kci0iw.mjs} +7 -7
- package/dist/{aggregate-DlfOyErc.mjs.map → aggregate-C0Kci0iw.mjs.map} +1 -1
- package/dist/{caught-errors-HFQjjQVE-b_GDV-6J.mjs → caught-errors-DUV-u8yQ-DuPp394m.mjs} +45 -8
- package/dist/caught-errors-DUV-u8yQ-DuPp394m.mjs.map +1 -0
- package/dist/cli-telemetry.mjs +1 -1
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +22 -54
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +4 -2
- 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/cli__migration-cli.mjs +62 -18
- 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-1S_6vaGt-HJIMKsVd.mjs → contract-snapshot-store-CNu34KAd-D9xN1Sll.mjs} +3 -3
- package/dist/{contract-snapshot-store-1S_6vaGt-HJIMKsVd.mjs.map → contract-snapshot-store-CNu34KAd-D9xN1Sll.mjs.map} +1 -1
- package/dist/{db-sign-BPf9SzzX-CwOFPxoZ.d.mts → db-sign-DvCsMwUF-D5UIkRXD.d.mts} +2 -2
- package/dist/{db-sign-BPf9SzzX-CwOFPxoZ.d.mts.map → db-sign-DvCsMwUF-D5UIkRXD.d.mts.map} +1 -1
- package/dist/{errors-DD6iLGXk-6I9PqjpZ.mjs → errors-B1xJ5JTo-CrQL55Qf.mjs} +3 -3
- package/dist/{errors-DD6iLGXk-6I9PqjpZ.mjs.map → errors-B1xJ5JTo-CrQL55Qf.mjs.map} +1 -1
- package/dist/{exports-Cxv8mNRJ.mjs → exports-D997yN01.mjs} +2 -2
- package/dist/{exports-Cxv8mNRJ.mjs.map → exports-D997yN01.mjs.map} +1 -1
- package/dist/{exports-C7GzkPEc.mjs → exports-JFLSlPBW.mjs} +4 -3
- package/dist/{exports-C7GzkPEc.mjs.map → exports-JFLSlPBW.mjs.map} +1 -1
- package/dist/{graph-membership-C_ZO26nT-B7C4CJsh.mjs → graph-membership-C-5WMh1R-BUtW54H2.mjs} +3 -3
- package/dist/{graph-membership-C_ZO26nT-B7C4CJsh.mjs.map → graph-membership-C-5WMh1R-BUtW54H2.mjs.map} +1 -1
- package/dist/{index-DVcYlnHq.d.mts → index-CWPFeYyi.d.mts} +3 -2
- package/dist/{index-DVcYlnHq.d.mts.map → index-CWPFeYyi.d.mts.map} +1 -1
- package/dist/{invariants-C0lpc60l-CMUCvk4O.mjs → invariants-1xSrwDkH-BoUuNrf4.mjs} +3 -3
- package/dist/{invariants-C0lpc60l-CMUCvk4O.mjs.map → invariants-1xSrwDkH-BoUuNrf4.mjs.map} +1 -1
- package/dist/{io-xKnQrxIC-CEXpCgE_.mjs → io-CUFeeOVP-CEgOEVwW.mjs} +5 -5
- package/dist/{io-xKnQrxIC-CEXpCgE_.mjs.map → io-CUFeeOVP-CEgOEVwW.mjs.map} +1 -1
- package/dist/{migration-oIynqb-J.mjs → migration-CZrQ_3zY.mjs} +3 -3
- package/dist/{migration-oIynqb-J.mjs.map → migration-CZrQ_3zY.mjs.map} +1 -1
- package/dist/migration-tools.mjs +11 -11
- 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.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/{ref-Cc_CTagE-BYkEh32b.mjs → ref-BITTabCb-BMk154EL.mjs} +100 -69
- package/dist/ref-BITTabCb-BMk154EL.mjs.map +1 -0
- package/dist/{ref-resolution-Be_zewf7.mjs → ref-resolution-kNMjYJ26.mjs} +2 -2
- package/dist/{ref-resolution-Be_zewf7.mjs.map → ref-resolution-kNMjYJ26.mjs.map} +1 -1
- package/dist/{refs-qwvw4_dV-DNg_7WTD.mjs → refs-CS997f-J-BxkRLuCE.mjs} +3 -3
- package/dist/{refs-qwvw4_dV-DNg_7WTD.mjs.map → refs-CS997f-J-BxkRLuCE.mjs.map} +1 -1
- package/dist/{spaces-DGu96Hkk.mjs → spaces-CtxjvIS0.mjs} +5 -5
- package/dist/{spaces-DGu96Hkk.mjs.map → spaces-CtxjvIS0.mjs.map} +1 -1
- package/dist/{verify-contract-spaces-CYjc343k-ClHHEkJF.mjs → verify-contract-spaces-sL5mlmCX-K2P69KDp.mjs} +4 -4
- package/dist/{verify-contract-spaces-CYjc343k-ClHHEkJF.mjs.map → verify-contract-spaces-sL5mlmCX-K2P69KDp.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +2 -2
- package/package.json +12 -12
- package/dist/caught-errors-HFQjjQVE-b_GDV-6J.mjs.map +0 -1
- package/dist/ref-Cc_CTagE-BYkEh32b.mjs.map +0 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { D as errorNoInvariantPath, M as errorUnknownInvariant, b as errorInvalidRefName, r as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-
|
|
1
|
+
import { a as expandContractInputs } from "./exports-JFLSlPBW.mjs";
|
|
2
|
+
import { D as errorNoInvariantPath, M as errorUnknownInvariant, b as errorInvalidRefName, r as errorContractDeserializationFailed, t as MigrationToolsError } from "./errors-B1xJ5JTo-CrQL55Qf.mjs";
|
|
3
3
|
import { r as verifyMigrationHash, t as computeMigrationHash } from "./hash-BAZVWU4a-BQovI7hF.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-
|
|
4
|
+
import { a as snapshotsImportPathFrom, n as createSnapshotContentVerifier, o as writeContractSnapshot, r as readContractSnapshotJson, t as contractSnapshotDir } from "./contract-snapshot-store-CNu34KAd-D9xN1Sll.mjs";
|
|
5
|
+
import { t as deriveProvidedInvariants } from "./invariants-1xSrwDkH-BoUuNrf4.mjs";
|
|
6
|
+
import { i as materialiseExtensionMigrationPackageIfMissing, r as formatMigrationDirName, u as writeMigrationPackage } from "./io-CUFeeOVP-CEgOEVwW.mjs";
|
|
7
7
|
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
|
-
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-
|
|
10
|
-
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-
|
|
11
|
-
import {
|
|
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-sL5mlmCX-K2P69KDp.mjs";
|
|
10
|
+
import { i as emitContractSpaceArtifacts, o as planAllSpaces } from "./spaces-CtxjvIS0.mjs";
|
|
11
|
+
import { A as errorPathUnreachable, B as errorSnapshotMissing, C as errorInvalidSpaceId, F as errorRefSetEmptySentinel, G as errorStatementOriginUnknown, H as errorStatementAnswersNoQuestion, I as errorRefSetHashNotInGraph, K as errorStatementUnresolved, M as errorPlanOriginUnknown, N as errorPlanProducedNoOperations, O as errorMigrationPlanningFailed, P as errorRefSetBundleNotFound, R as errorRuntime, T as errorMarkerMismatch, U as errorStatementDidNotResolveLoss, V as errorSpaceNotFound, W as errorStatementInvalid, X as getTargetMigrations, Y as errorUnexpected, Z as mapRefResolutionError, _ as errorContractValidationFailed, at as runCommandAction, b as errorFileNotFound, c as closeQuietly, et as readContractEnvelope, g as errorContractConfigMissing, it as resolveMigrationPaths, j as errorPlanForgotTheFlag, l as collectDeclaredInvariants, m as errorConfigValidation$1, n as CliStructuredError$1, nt as requireLiveDatabase, p as errorAmbiguousMigrationRef, q as errorTargetMigrationNotSupported, r as STORE_ORIGIN_SNAPSHOT_STEPS, rt as resolveContractPath, s as chooseAction, st as toStructuralEdge, x as errorFromCaught } from "./caught-errors-DUV-u8yQ-DuPp394m.mjs";
|
|
12
12
|
import { r as getEmittedArtifactPaths, t as emit } from "./exports-DaDckULH-JNQeM6Nn.mjs";
|
|
13
|
-
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-
|
|
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-
|
|
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-
|
|
13
|
+
import { n as isGraphNode, t as assertHashIsGraphNode } from "./graph-membership-C-5WMh1R-BUtW54H2.mjs";
|
|
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-CS997f-J-BxkRLuCE.mjs";
|
|
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-C0Kci0iw.mjs";
|
|
16
16
|
import { c as internalImportRoot, o as importRootForDependencies, r as createImportSpecifierResolver, t as ImportRootError } from "./import-roots-B6vrm5bT.mjs";
|
|
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-
|
|
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-kNMjYJ26.mjs";
|
|
18
18
|
import { a as writeMigrationTs } from "./migration-ts-DDgjsR1O.mjs";
|
|
19
19
|
import { createRequire } from "node:module";
|
|
20
20
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
@@ -33,7 +33,7 @@ import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/compon
|
|
|
33
33
|
import { asNamespaceId } from "@prisma/orm-framework/contract/types";
|
|
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-BITTabCb.mjs
|
|
37
37
|
/**
|
|
38
38
|
* Asserts that all framework components are compatible with the expected family and target.
|
|
39
39
|
*
|
|
@@ -416,7 +416,16 @@ function readField(state, side, namespaceId, modelName, field) {
|
|
|
416
416
|
}
|
|
417
417
|
function readSide(state, side, segments) {
|
|
418
418
|
if (segments.length === 1) return readModel(state, side, void 0, segments[0]);
|
|
419
|
-
if (segments.length === 3)
|
|
419
|
+
if (segments.length === 3) {
|
|
420
|
+
const [first, second, third] = segments;
|
|
421
|
+
const qualified = readField(state, side, first, second, third);
|
|
422
|
+
const dotted = readField(state, side, void 0, first, `${second}.${third}`);
|
|
423
|
+
if (qualified.ok && dotted.ok) return notOk({
|
|
424
|
+
reason: `"${first}.${second}.${third}" resolves both as namespace "${first}" model "${second}" field "${third}" and as model "${first}" field "${second}.${third}"`,
|
|
425
|
+
fix: `Give the field a stored name without "." with @map, or rename namespace "${first}" or model "${first}", so that only one reading resolves.`
|
|
426
|
+
});
|
|
427
|
+
return qualified.ok || !dotted.ok ? qualified : dotted;
|
|
428
|
+
}
|
|
420
429
|
const [first, second] = segments;
|
|
421
430
|
const asModel = readModel(state, side, first, second);
|
|
422
431
|
const asField = readField(state, side, void 0, first, second);
|
|
@@ -637,16 +646,16 @@ function lossText(subject, text, originKnown) {
|
|
|
637
646
|
switch (subject.kind) {
|
|
638
647
|
case "model": return `would lose the data of model "${text}"`;
|
|
639
648
|
case "field": return `would lose the values of field "${text}"`;
|
|
640
|
-
case "storage": return originKnown ? `would lose the data in "${text}", which no model of the origin contract stores` : `would lose the data in "${text}", named by its storage name because the origin contract is unknown; --delete loses
|
|
649
|
+
case "storage": return originKnown ? `would lose the data in "${text}", which no model of the origin contract stores` : `would lose the data in "${text}", named by its storage name because the origin contract is unknown; --delete loses that data`;
|
|
641
650
|
}
|
|
642
651
|
}
|
|
643
652
|
/**
|
|
644
|
-
* How to keep the
|
|
653
|
+
* How to keep the data of a storage subject that was renamed, when the origin contract is unknown:
|
|
645
654
|
* store the snapshot of the contract the database is at, as `MIGRATION.STATEMENT_ORIGIN_UNKNOWN`
|
|
646
655
|
* advises, then answer with a rename. The refusal gives it once, on its first storage question. The
|
|
647
656
|
* engine does not put the CLI's name in a question's text, so the steps name `prisma`.
|
|
648
657
|
*/
|
|
649
|
-
const ORIGIN_SNAPSHOT_RECOVERY = ["If it was renamed, keep its data instead: store the snapshot of the contract the database is at, then run this command again and answer with --rename.", ...STORE_ORIGIN_SNAPSHOT_STEPS.map((step) => step.replaceAll("{bin}", "prisma"))].join("
|
|
658
|
+
const ORIGIN_SNAPSHOT_RECOVERY = ["If it was renamed, keep its data instead: store the snapshot of the contract the database is at, then run this command again and answer with --rename.", ...STORE_ORIGIN_SNAPSHOT_STEPS.map((step) => step.replaceAll("{bin}", "prisma"))].join("\n");
|
|
650
659
|
function sameCoordinate(statement, subject) {
|
|
651
660
|
if (subject.kind === "storage") return false;
|
|
652
661
|
const { from } = statement;
|
|
@@ -656,13 +665,9 @@ function sameCoordinate(statement, subject) {
|
|
|
656
665
|
function namesSubject(verb, subject) {
|
|
657
666
|
return (text) => text === subject ? void 0 : `${verb} names "${subject}": --${verb} ${subject}.`;
|
|
658
667
|
}
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
*/
|
|
663
|
-
function keepDataByHandFor(migrations, origin) {
|
|
664
|
-
const refused = migrations.renameStatements;
|
|
665
|
-
return refused === void 0 ? void 0 : (subject) => refused.keepDataByHand(subject, origin);
|
|
668
|
+
function modelRenameAdvice(model, contracts) {
|
|
669
|
+
const name = modelText(contracts.origin, model);
|
|
670
|
+
return `The destination contract has no model "${name}"; to keep the values instead, also pass --rename ${name}:<new model name>, naming the model that stores them now, and the question then offers to rename the field.`;
|
|
666
671
|
}
|
|
667
672
|
/** A rename as a statement is written: a field's new name keeps the model, `User.nickname:User.<new name>`. */
|
|
668
673
|
function renameForm(subject, text) {
|
|
@@ -690,19 +695,34 @@ function inDestination(subject, contracts) {
|
|
|
690
695
|
return subject.kind === "model" || Object.hasOwn(destinationModel.fields, subject.field);
|
|
691
696
|
}
|
|
692
697
|
/**
|
|
698
|
+
* The model of a field subject, under the name a rename of the plan gives it, when the destination
|
|
699
|
+
* has no model of that name: a rename of the field cannot be written until a statement renames the
|
|
700
|
+
* model.
|
|
701
|
+
*/
|
|
702
|
+
function missingFieldModel(subject, contracts) {
|
|
703
|
+
if (subject.kind !== "field") return void 0;
|
|
704
|
+
const model = renamedModel(subject, contracts) ?? subject;
|
|
705
|
+
return contracts.destination.domain.namespaces[model.namespaceId]?.models[model.model] === void 0 ? model : void 0;
|
|
706
|
+
}
|
|
707
|
+
/**
|
|
693
708
|
* The question for one operation that would lose data. A model or field the destination no longer
|
|
694
709
|
* has, and no rename of the plan renamed, may be renamed instead of deleted; a rename is resolved
|
|
695
710
|
* against the two contracts after the plan's other renames, and its old name must be the subject.
|
|
696
711
|
* A subject the destination keeps, such as a field whose type changes, and data no model stores,
|
|
697
|
-
* can only be deleted.
|
|
698
|
-
*
|
|
712
|
+
* can only be deleted. A field whose model the destination names differently can be renamed only
|
|
713
|
+
* after a statement renames the model, so the question says to pass one.
|
|
699
714
|
*/
|
|
700
715
|
function dataLossQuestion(loss, contracts) {
|
|
701
716
|
const subject = subjectText(loss.subject, contracts);
|
|
702
|
-
const
|
|
717
|
+
const missingModel = missingFieldModel(loss.subject, contracts);
|
|
718
|
+
const renamable = missingModel === void 0 && loss.subject.kind !== "storage" && !inDestination(loss.subject, contracts) && !renamedByPlan(loss.subject, contracts);
|
|
703
719
|
const deleteNames = namesSubject("delete", subject);
|
|
704
720
|
return {
|
|
705
|
-
question: [
|
|
721
|
+
question: [
|
|
722
|
+
`${loss.label} ${lossText(loss.subject, subject, contracts.originKnown)}.`,
|
|
723
|
+
...missingModel === void 0 ? [] : [modelRenameAdvice(missingModel, contracts)],
|
|
724
|
+
...loss.keepDataAdvice === void 0 ? [] : [loss.keepDataAdvice]
|
|
725
|
+
].join(" "),
|
|
706
726
|
subject,
|
|
707
727
|
verbs: renamable ? ["rename", "delete"] : ["delete"],
|
|
708
728
|
forms: renamable ? { rename: renameForm(loss.subject, subject) } : {},
|
|
@@ -783,7 +803,7 @@ function withRecoveryOnFirstStorageQuestion(asked, recoveryApplies) {
|
|
|
783
803
|
const first = recoveryApplies ? asked.findIndex(({ loss }) => loss.subject.kind === "storage") : -1;
|
|
784
804
|
return asked.map(({ question }, index) => index === first ? {
|
|
785
805
|
...question,
|
|
786
|
-
question: `${question.question}
|
|
806
|
+
question: `${question.question}\n${ORIGIN_SNAPSHOT_RECOVERY}`
|
|
787
807
|
} : question);
|
|
788
808
|
}
|
|
789
809
|
/**
|
|
@@ -804,7 +824,6 @@ async function askPlanQuestions(input) {
|
|
|
804
824
|
const contracts = {
|
|
805
825
|
origin: input.origin,
|
|
806
826
|
originKnown: input.originKnown,
|
|
807
|
-
keepDataByHand: input.keepDataByHand,
|
|
808
827
|
destination: input.destination,
|
|
809
828
|
renames
|
|
810
829
|
};
|
|
@@ -827,7 +846,7 @@ async function askPlanQuestions(input) {
|
|
|
827
846
|
const questions = [...withRecoveryOnFirstStorageQuestion(losses.map((loss) => ({
|
|
828
847
|
loss,
|
|
829
848
|
question: dataLossQuestion(loss, contracts)
|
|
830
|
-
})), !input.originKnown
|
|
849
|
+
})), !input.originKnown), ...widenings.map((widening) => accessWideningQuestion(widening, contracts))];
|
|
831
850
|
const answers = await input.answer(questions);
|
|
832
851
|
checkAnswers(questions, answers);
|
|
833
852
|
const typedRenames = [];
|
|
@@ -1517,7 +1536,6 @@ async function executeRun(options) {
|
|
|
1517
1536
|
},
|
|
1518
1537
|
origin: fromContract ?? EMPTY_ORIGIN$1,
|
|
1519
1538
|
originKnown: fromContract !== null,
|
|
1520
|
-
keepDataByHand: keepDataByHandFor(migrations, fromContract ?? EMPTY_ORIGIN$1),
|
|
1521
1539
|
destination: contract,
|
|
1522
1540
|
answer: options.answerQuestions,
|
|
1523
1541
|
replan: (renames) => plan(resolveRenames(renames))
|
|
@@ -4994,6 +5012,10 @@ async function executeMigrationNewCommand(options) {
|
|
|
4994
5012
|
return notOk(errorFromCaught(error, (message) => `Failed to scaffold migration: ${message}`));
|
|
4995
5013
|
}
|
|
4996
5014
|
}
|
|
5015
|
+
/** The command that runs a `migration.ts`, repeating the `--config` the CLI was given so it loads the same config. */
|
|
5016
|
+
function selfEmitCommand(migrationTs, configPath) {
|
|
5017
|
+
return configPath === void 0 ? `node "${migrationTs}"` : `node "${migrationTs}" --config "${configPath}"`;
|
|
5018
|
+
}
|
|
4997
5019
|
/**
|
|
4998
5020
|
* Phase-1 of the two-phase `migration plan` pipeline (sub-spec § 4).
|
|
4999
5021
|
*
|
|
@@ -5090,6 +5112,9 @@ function buildPlaceholderContractDts(spaceId) {
|
|
|
5090
5112
|
function isEnoent(error) {
|
|
5091
5113
|
return error instanceof Error && "code" in error && error.code === "ENOENT";
|
|
5092
5114
|
}
|
|
5115
|
+
function placeholderSummary(planned, dirs, configPath) {
|
|
5116
|
+
return `Planned ${planned} with placeholder(s) — edit migration.ts, then run ${dirs.map((dir) => `\`${selfEmitCommand(join(dir, "migration.ts"), configPath)}\``).join(" and ")} to self-emit`;
|
|
5117
|
+
}
|
|
5093
5118
|
/** The origin of a plan from an empty database: no models, so no statement resolves. */
|
|
5094
5119
|
const EMPTY_ORIGIN = { domain: { namespaces: {} } };
|
|
5095
5120
|
async function runPlannerLeg(planner, migrations, frameworkComponents, contract, origin, destination, statements, noOperationsExpected, spaceId, ownership, snapshotsImportPath, resolveImportSpecifier) {
|
|
@@ -5140,9 +5165,10 @@ async function runPlannerLeg(planner, migrations, frameworkComponents, contract,
|
|
|
5140
5165
|
plannedOps,
|
|
5141
5166
|
migrationTsContent: plannerResult.plan.renderTypeScript(resolveImportSpecifier),
|
|
5142
5167
|
hasPlaceholders,
|
|
5143
|
-
dataLoss: plannerResult.dataLoss.map(({ operationIndex, subject }) => ({
|
|
5168
|
+
dataLoss: plannerResult.dataLoss.map(({ operationIndex, subject, keepDataAdvice }) => ({
|
|
5144
5169
|
operationIndex: position(operationIndex),
|
|
5145
5170
|
subject,
|
|
5171
|
+
...ifDefined("keepDataAdvice", keepDataAdvice),
|
|
5146
5172
|
label: resolved[operationIndex]?.label ?? subjectText(subject, {
|
|
5147
5173
|
origin: fromContract ?? EMPTY_ORIGIN,
|
|
5148
5174
|
renames: []
|
|
@@ -5218,7 +5244,6 @@ async function answerPlannedDataLoss(input) {
|
|
|
5218
5244
|
},
|
|
5219
5245
|
origin: input.origin,
|
|
5220
5246
|
originKnown: input.originKnown,
|
|
5221
|
-
keepDataByHand: input.keepDataByHand,
|
|
5222
5247
|
destination: input.destination,
|
|
5223
5248
|
answer: input.answer,
|
|
5224
5249
|
replan: async (renames) => {
|
|
@@ -5420,7 +5445,6 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
|
|
|
5420
5445
|
consents: statementTexts.filter((statement) => statement.verb !== "rename"),
|
|
5421
5446
|
origin: fromContract ?? EMPTY_ORIGIN,
|
|
5422
5447
|
originKnown: true,
|
|
5423
|
-
keepDataByHand: keepDataByHandFor(migrations, fromContract ?? EMPTY_ORIGIN),
|
|
5424
5448
|
destination: toContract,
|
|
5425
5449
|
answer: options.answerQuestions,
|
|
5426
5450
|
planDelta: async (renames) => {
|
|
@@ -5481,7 +5505,7 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
|
|
|
5481
5505
|
...warnings.length > 0 ? { warnings } : {},
|
|
5482
5506
|
pendingPlaceholders: true,
|
|
5483
5507
|
appliedStatements: [...statementsWithoutOperations, ...deletes],
|
|
5484
|
-
summary: "
|
|
5508
|
+
summary: placeholderSummary("baseline", [baselineDir], options.configPath),
|
|
5485
5509
|
timings: { total: Date.now() - startTime }
|
|
5486
5510
|
});
|
|
5487
5511
|
}
|
|
@@ -5509,22 +5533,26 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
|
|
|
5509
5533
|
await writeDestinationSnapshot(toStorageHash);
|
|
5510
5534
|
const baselineOps = baselineLeg.value.hasPlaceholders ? [] : baselineLeg.value.plannedOps;
|
|
5511
5535
|
const deltaOps = deltaLeg.value.hasPlaceholders ? [] : deltaLeg.value.plannedOps;
|
|
5512
|
-
if (baselineLeg.value.hasPlaceholders || deltaLeg.value.hasPlaceholders)
|
|
5513
|
-
|
|
5514
|
-
|
|
5515
|
-
|
|
5516
|
-
|
|
5517
|
-
|
|
5518
|
-
|
|
5519
|
-
|
|
5520
|
-
|
|
5521
|
-
|
|
5522
|
-
|
|
5523
|
-
|
|
5524
|
-
|
|
5525
|
-
|
|
5526
|
-
|
|
5527
|
-
|
|
5536
|
+
if (baselineLeg.value.hasPlaceholders || deltaLeg.value.hasPlaceholders) {
|
|
5537
|
+
const baselineDir = relative(cwd, baselinePackageDir);
|
|
5538
|
+
const deltaDir = relative(cwd, deltaPackageDir);
|
|
5539
|
+
return ok({
|
|
5540
|
+
ok: true,
|
|
5541
|
+
noOp: false,
|
|
5542
|
+
from: fromHash,
|
|
5543
|
+
to: toStorageHash,
|
|
5544
|
+
dir: deltaDir,
|
|
5545
|
+
baselineDir,
|
|
5546
|
+
operations: operationSummaries(deltaLeg.value.plannedOps),
|
|
5547
|
+
baselineOperations: operationSummaries(baselineLeg.value.plannedOps),
|
|
5548
|
+
emittedExtensionDirs,
|
|
5549
|
+
...warnings.length > 0 ? { warnings } : {},
|
|
5550
|
+
pendingPlaceholders: true,
|
|
5551
|
+
appliedStatements: [...deltaLeg.value.appliedStatements, ...deletes],
|
|
5552
|
+
summary: placeholderSummary("baseline + migration", [baselineDir, deltaDir], options.configPath),
|
|
5553
|
+
timings: { total: Date.now() - startTime }
|
|
5554
|
+
});
|
|
5555
|
+
}
|
|
5528
5556
|
const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview([...baselineOps, ...deltaOps]) : void 0;
|
|
5529
5557
|
return ok({
|
|
5530
5558
|
ok: true,
|
|
@@ -5574,21 +5602,24 @@ async function executeMigrationPlanCommandInner(options, startTime, callbacks) {
|
|
|
5574
5602
|
});
|
|
5575
5603
|
await writePlannedMigrationPackage(packageDir, fromHash, toStorageHash, timestamp, deltaLeg.value);
|
|
5576
5604
|
await writeDestinationSnapshot(toStorageHash);
|
|
5577
|
-
if (deltaLeg.value.hasPlaceholders)
|
|
5578
|
-
|
|
5579
|
-
|
|
5580
|
-
|
|
5581
|
-
|
|
5582
|
-
|
|
5583
|
-
|
|
5584
|
-
|
|
5585
|
-
|
|
5586
|
-
|
|
5587
|
-
|
|
5588
|
-
|
|
5589
|
-
|
|
5590
|
-
|
|
5591
|
-
|
|
5605
|
+
if (deltaLeg.value.hasPlaceholders) {
|
|
5606
|
+
const dir = relative(cwd, packageDir);
|
|
5607
|
+
return ok({
|
|
5608
|
+
ok: true,
|
|
5609
|
+
noOp: false,
|
|
5610
|
+
from: fromHash,
|
|
5611
|
+
to: toStorageHash,
|
|
5612
|
+
dir,
|
|
5613
|
+
operations: operationSummaries(deltaLeg.value.plannedOps),
|
|
5614
|
+
emittedExtensionDirs,
|
|
5615
|
+
...warnings.length > 0 ? { warnings } : {},
|
|
5616
|
+
pendingPlaceholders: true,
|
|
5617
|
+
...fromDefaulted ? { fromDefaulted } : {},
|
|
5618
|
+
appliedStatements: [...deltaLeg.value.appliedStatements, ...deletes],
|
|
5619
|
+
summary: placeholderSummary("migration", [dir], options.configPath),
|
|
5620
|
+
timings: { total: Date.now() - startTime }
|
|
5621
|
+
});
|
|
5622
|
+
}
|
|
5592
5623
|
const plannedOps = deltaLeg.value.plannedOps;
|
|
5593
5624
|
const preview = hasOperationPreview(familyInstance) ? familyInstance.toOperationPreview(plannedOps) : void 0;
|
|
5594
5625
|
return ok({
|
|
@@ -5749,6 +5780,6 @@ async function executeRefListCommand(options) {
|
|
|
5749
5780
|
}
|
|
5750
5781
|
}
|
|
5751
5782
|
//#endregion
|
|
5752
|
-
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 _,
|
|
5783
|
+
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 _, statusForMigrationHash as _t, RECORDED_OR_EMPTY_CONTRACT_REF_FORMS as a, resolveMigrationRef as at, executeContractEmit as b, appliedHashesFromLedger as c, retryCommandFor as ct, buildReadAggregate as d, runMigrationList as dt, requireDatabaseForLiveMarkerUse as et, buildRefAdvancementFields as f, selfEmitCommand as ft, deriveStatusEdgeAnnotations as g, statementFlag as gt, createControlClient as h, sourceWarningDiagnostic as ht, RECORDED_CONTRACT_REF_FORMS as i, resolveFromForPlan as it, executeRefSetCommand as j, executeRefDeleteCommand as k, buildContractSpaceAggregate as l, runContractSpaceSeedPhase as lt, computeRefAdvancementName as m, snapshotVerifierFor as mt, DB_UPDATE_POLICY as n, resolveContractRef$1 as nt, advanceRefSafely as o, resolveStatements as ot, checkSingleTarget as p, shellQuoted as pt, readMigrationRefs as q, NO_REF_ADVANCEMENT as r, resolveContractRefToSnapshot as rt, appContractStandInFromIdentity as s, resolveToForPlan as st, ALL_CONTRACT_REF_FORMS as t, resolveAppTargetPath as tt, buildMigrationSpaceGraphEntries as u, runMigrationCheck as ut, enrichContract as v, toDeclaredExtensionsFromRaw as vt, executeDbVerify as w, executeDbInit as x, enumerateCheckSpaces as y, validateLoadedContract as yt, loadContractSource as z };
|
|
5753
5784
|
|
|
5754
|
-
//# sourceMappingURL=ref-
|
|
5785
|
+
//# sourceMappingURL=ref-BITTabCb-BMk154EL.mjs.map
|