@prisma/orm-toolchain 8.0.0-rc.24-dev.15 → 8.0.0-rc.24-dev.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +3 -3
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/{ref-DH9J_oNY-DCRv3zP6.mjs → ref-D4GWEHQU-CV0reyKf.mjs} +271 -99
- package/dist/ref-D4GWEHQU-CV0reyKf.mjs.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/ref-DH9J_oNY-DCRv3zP6.mjs.map +0 -1
|
@@ -36,7 +36,7 @@ import { isDeepStrictEqual } from "node:util";
|
|
|
36
36
|
import { canonicalStringify } from "@prisma/orm-framework/utils/canonical-stringify";
|
|
37
37
|
import { abortable } from "@prisma/orm-framework/utils/abortable";
|
|
38
38
|
import { resolve as resolve$1 } from "node:path";
|
|
39
|
-
//#region ../../../1-framework/3-tooling/cli/dist/ref-
|
|
39
|
+
//#region ../../../1-framework/3-tooling/cli/dist/ref-D4GWEHQU.mjs
|
|
40
40
|
/**
|
|
41
41
|
* The meta of a contract that failed to load because the family refused it, such as the columns whose defaults it refused, for the command to report: the refusal's own meta, or the `refusedDefaults` a migration-tools error kept from it.
|
|
42
42
|
*/
|
|
@@ -275,12 +275,40 @@ function dbUpdateRowsWithoutValueAdvice(reports, databaseStorageHash, invocation
|
|
|
275
275
|
const flags = backfillFlags(reports);
|
|
276
276
|
const planned = flags.length === 0 ? [] : [chooseAction(`Plan it with ${quoted$1(printedPlanCommand(invocation, databaseStorageHash, flags))}, fill the backfill steps in the migration.ts it writes, ${RUN_PLANNED_FILE}, and apply it with ${dbMigrateCommand(invocation)}`)];
|
|
277
277
|
const [first] = reports;
|
|
278
|
-
if (first?.reason === "nullValues")
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
278
|
+
if (first?.reason === "nullValues") {
|
|
279
|
+
const keep = optionalFields([first], "the field");
|
|
280
|
+
return [
|
|
281
|
+
chooseAction(`Set a value in ${theRows(first.rows)}`),
|
|
282
|
+
...keep === void 0 ? [] : [editFileAction(`Keep ${keep.text} optional in the contract source`)],
|
|
283
|
+
...planned
|
|
284
|
+
];
|
|
285
|
+
}
|
|
286
|
+
const optional = optionalFields(reports, theFields(reports));
|
|
287
|
+
return [...planned, ...optional === void 0 ? [] : [editFileAction(`Make ${optional.text} optional in the contract source`)]];
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* The fields of the reports the contract can make optional, which leaves out discriminators: in the words the caller
|
|
291
|
+
* gives for all of them, or by name when a discriminator is left out. Undefined when every field is a discriminator.
|
|
292
|
+
*/
|
|
293
|
+
function optionalFields(reports, allOfThem) {
|
|
294
|
+
const optional = reports.filter(({ discriminator }) => !discriminator);
|
|
295
|
+
if (optional.length === 0) return;
|
|
296
|
+
const named = distinct(optional.flatMap(({ field }) => field === void 0 ? [] : [field]));
|
|
297
|
+
if (optional.length === reports.length || named.length === 0) return {
|
|
298
|
+
text: allOfThem,
|
|
299
|
+
one: reports.length === 1
|
|
300
|
+
};
|
|
301
|
+
const [only] = named;
|
|
302
|
+
return named.length === 1 && only !== void 0 ? {
|
|
303
|
+
text: `field "${only}"`,
|
|
304
|
+
one: true
|
|
305
|
+
} : {
|
|
306
|
+
text: `fields ${named.map((field) => `"${field}"`).join(", ")}`,
|
|
307
|
+
one: false
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
function theFields(reports) {
|
|
311
|
+
return new Set(reports.flatMap(({ field }) => field === void 0 ? [] : [field])).size > 1 ? "the fields" : "the field";
|
|
284
312
|
}
|
|
285
313
|
function distinct(values) {
|
|
286
314
|
return [...new Set(values)];
|
|
@@ -438,20 +466,29 @@ function migrateRowsWithoutValueAdvice(reports, failedMigration, invocation) {
|
|
|
438
466
|
if (reports.every(({ reason }) => reason === "nullValues")) {
|
|
439
467
|
const rerun = chooseAction(one ? `Set a value in ${theRows(first?.rows ?? 0)} and re-run ${dbMigrateCommand(invocation)}` : `Set a value in the rows that hold NULL in each of ${fieldList(reports)} and re-run ${dbMigrateCommand(invocation)}`);
|
|
440
468
|
const backfill = again("Delete");
|
|
441
|
-
const fields = one ? "the field" : "those fields";
|
|
442
|
-
const keep = failedMigration === void 0 ? editFileAction(`Keep ${fields} optional in the contract source, and plan the migration again`) : keepOptional(fields, one ? "it" : "them", failedMigration, invocation);
|
|
469
|
+
const fields = optionalFields(reports, one ? "the field" : "those fields");
|
|
470
|
+
const keep = fields === void 0 ? [] : [failedMigration === void 0 ? editFileAction(`Keep ${fields.text} optional in the contract source, and plan the migration again`) : keepOptional(fields.text, fields.one ? "it" : "them", failedMigration, invocation)];
|
|
443
471
|
return [
|
|
444
472
|
rerun,
|
|
445
473
|
...backfill === void 0 ? [] : [backfill],
|
|
446
|
-
keep
|
|
474
|
+
...keep
|
|
447
475
|
];
|
|
448
476
|
}
|
|
449
477
|
if (first?.reason === "nullValues") {
|
|
450
478
|
const notEnough = "The migration also adds a required field the existing rows have no value for, so setting values is not enough.";
|
|
451
|
-
|
|
479
|
+
const backfill = again(`${notEnough} Delete`);
|
|
480
|
+
if (backfill !== void 0) return [backfill];
|
|
481
|
+
const newFields = optionalFields(reports.filter(({ reason }) => reason === "newField"), "the new fields");
|
|
482
|
+
return newFields === void 0 ? [resolveTheCause(invocation)] : [editFileAction(`${notEnough} Make ${newFields.text} optional in the contract source, and plan the migration again`)];
|
|
452
483
|
}
|
|
453
|
-
const
|
|
454
|
-
|
|
484
|
+
const fields = theFields(reports);
|
|
485
|
+
const required = again(`To keep ${fields} required, delete`);
|
|
486
|
+
const optional = optionalFields(reports, fields);
|
|
487
|
+
if (required === void 0) return [optional === void 0 ? resolveTheCause(invocation) : editFileAction(`Make ${optional.text} optional in the contract source, and plan the migration again`)];
|
|
488
|
+
return [required, ...optional === void 0 ? [] : [editFileAction(`Make ${optional.text} optional in the contract source, and plan it again`)]];
|
|
489
|
+
}
|
|
490
|
+
function resolveTheCause(invocation) {
|
|
491
|
+
return chooseAction(`Resolve the cause the failure names, then re-run \`${cliCommand(invocation, "db migrate", invocation.rerunArgs ?? [])}\``);
|
|
455
492
|
}
|
|
456
493
|
function keepOptional(fields, pronoun, failedMigration, invocation) {
|
|
457
494
|
const plan = printedPlanCommand(invocation, failedMigration.from, ["--name", failedMigration.name]);
|
|
@@ -489,7 +526,7 @@ function migrateAdvice(failure, facts, failedOnDisk, invocation) {
|
|
|
489
526
|
if (facts.rowsFailingCheck !== void 0) return migrateRowsFailingCheckAdvice(facts.rowsFailingCheck, failedMigration, invocation);
|
|
490
527
|
if (schemaCheckIssues(failure) !== void 0) return migrateSchemaCheckAdvice(failedMigration, invocation);
|
|
491
528
|
if (facts.failedPrecheck !== void 0) return migrateFailedPrecheckAdvice(facts.failedPrecheck, invocation);
|
|
492
|
-
return [
|
|
529
|
+
return [resolveTheCause(invocation)];
|
|
493
530
|
}
|
|
494
531
|
/** The ways out as prose: each label as a sentence, every one after the first after "Or:". */
|
|
495
532
|
function adviceText(advice) {
|
|
@@ -621,68 +658,88 @@ function quoted(command) {
|
|
|
621
658
|
}
|
|
622
659
|
/** How `migration plan` says to keep the data of a subject: answer with a delete, then make the edits in the file it writes. */
|
|
623
660
|
function migrationPlanKeepDataEditAdvice(invocation) {
|
|
624
|
-
return (
|
|
661
|
+
return ({ text, edits }) => ({
|
|
625
662
|
lead: void 0,
|
|
626
|
-
ways: [`To keep that data, answer with ${statementFlag({
|
|
663
|
+
ways: edits.length === 0 ? [] : [`To keep that data, answer with ${statementFlag({
|
|
627
664
|
verb: "delete",
|
|
628
|
-
text
|
|
665
|
+
text
|
|
629
666
|
})}, then in the migration.ts this command writes ${editsText(edits)}, ${runWrittenFile(invocation)}.`]
|
|
630
667
|
});
|
|
631
668
|
}
|
|
632
|
-
/** The run's statements, without the
|
|
633
|
-
function otherStatements(invocation,
|
|
634
|
-
const
|
|
669
|
+
/** The run's statements, without the deletes that answer `subjects`. */
|
|
670
|
+
function otherStatements(invocation, subjects) {
|
|
671
|
+
const answers = subjects.map((text) => statementFlag({
|
|
635
672
|
verb: "delete",
|
|
636
|
-
text
|
|
637
|
-
});
|
|
638
|
-
return (invocation.statementArgs ?? []).filter((flag) => flag
|
|
673
|
+
text
|
|
674
|
+
}));
|
|
675
|
+
return (invocation.statementArgs ?? []).filter((flag) => !answers.includes(flag));
|
|
639
676
|
}
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
677
|
+
function listed$1(words) {
|
|
678
|
+
return words.length < 2 ? words.join("") : `${words.slice(0, -1).join(", ")} and ${words[words.length - 1]}`;
|
|
679
|
+
}
|
|
680
|
+
/** The members of `kept` in the enum of `subject`, compared by namespace and enum, in the order given. */
|
|
681
|
+
function sameEnum(subject, kept) {
|
|
682
|
+
return kept.flatMap(({ subject: each, text }) => each.kind === "enumValue" && each.namespaceId === subject.namespaceId && each.enum === subject.enum ? [{
|
|
683
|
+
member: each.member,
|
|
684
|
+
text
|
|
685
|
+
}] : []);
|
|
686
|
+
}
|
|
687
|
+
/**
|
|
688
|
+
* Two runs of `db update` that keep the data when members keep their names and only their stored values change, which no rename statement can name. The first run renames each member to a temporary member with a stored value the enum does not use, so its rename rewrites the stored values, and the second renames it back with its final stored value the same way. Passing through unused values means no rewrite writes a value another rewrite replaces, so members that swap values are kept too. `undefined` for a subject that is no enum value.
|
|
689
|
+
*/
|
|
690
|
+
function twoRuns(invocation, subject, kept) {
|
|
691
|
+
if (subject.subject.kind !== "enumValue") return void 0;
|
|
692
|
+
const enumName = subject.text.slice(0, -(subject.subject.member.length + 1));
|
|
693
|
+
const same = sameEnum(subject.subject, kept);
|
|
694
|
+
const members = same.map(({ member }) => member);
|
|
695
|
+
const subjects = same.map(({ text }) => text);
|
|
696
|
+
const one = members.length === 1;
|
|
697
|
+
const temporary = (member) => `${enumName}.<temporary member${one ? "" : ` for ${member}`}>`;
|
|
645
698
|
const emit = quoted(cliCommand(invocation, "contract emit"));
|
|
646
|
-
const
|
|
699
|
+
const first = cliCommand(invocation, "db update", [...otherStatements(invocation, subjects), ...members.map((member) => statementFlag({
|
|
647
700
|
verb: "rename",
|
|
648
|
-
text: `${
|
|
649
|
-
});
|
|
650
|
-
|
|
701
|
+
text: `${enumName}.${member}:${temporary(member)}`
|
|
702
|
+
}))]);
|
|
703
|
+
const second = cliCommand(invocation, "db update", members.map((member) => statementFlag({
|
|
704
|
+
verb: "rename",
|
|
705
|
+
text: `${temporary(member)}:${enumName}.${member}`
|
|
706
|
+
})));
|
|
707
|
+
const names = listed$1(members);
|
|
708
|
+
return one ? `To keep it with db update, change it in two runs. First rename member ${names} of enum ${enumName} in the contract source to a name the enum does not have and give it a stored value the enum does not use, run ${emit}, and run ${quoted(first)}. Then rename that member back to ${names} with its final stored value, run ${emit}, and run ${quoted(second)}.` : `To keep it with db update, change them in two runs. First rename members ${names} of enum ${enumName} in the contract source to names the enum does not have and give each a stored value the enum does not use, run ${emit}, and run ${quoted(first)}. Then rename those members back to ${names} with their final stored values, run ${emit}, and run ${quoted(second)}.`;
|
|
651
709
|
}
|
|
652
710
|
/**
|
|
653
|
-
* How `db update` says to keep the data of a subject: it cannot in one run. It plans the change
|
|
654
|
-
* with `migration plan` from the contract the database is at, when a migration ends there, or
|
|
655
|
-
* renames the member to a new member and back in two runs.
|
|
711
|
+
* How `db update` says to keep the data of a subject: it cannot in one run. It plans the change with `migration plan` from the contract the database is at, when a migration ends there and the target gives edits, answering with `--delete` each kept subject whose edits it gives, or changes the stored values in two runs through temporary members; members whose edits swap values do that only when no migration ends there.
|
|
656
712
|
*/
|
|
657
713
|
function dbUpdateKeepDataEditAdvice(invocation, databaseStorageHash) {
|
|
658
|
-
return (subject,
|
|
714
|
+
return (subject, kept) => {
|
|
659
715
|
const deleteFlag = statementFlag({
|
|
660
716
|
verb: "delete",
|
|
661
|
-
text: subject
|
|
717
|
+
text: subject.text
|
|
662
718
|
});
|
|
663
|
-
const swaps = edits.some(({ swapsValues }) => swapsValues === true);
|
|
664
|
-
const lead = swaps ? `db update cannot keep that data, because members of the enum swap stored values, and ${deleteFlag} removes it.` : `db update cannot keep that data in one run, and ${deleteFlag} removes it.`;
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
} : {
|
|
719
|
+
const swaps = subject.edits.some(({ swapsValues }) => swapsValues === true);
|
|
720
|
+
const lead = swaps ? `db update cannot keep that data in one run, because members of the enum swap stored values, and ${deleteFlag} removes it.` : `db update cannot keep that data in one run, and ${deleteFlag} removes it.`;
|
|
721
|
+
const runs = twoRuns(invocation, subject, kept);
|
|
722
|
+
const runWays = runs === void 0 ? [] : [runs];
|
|
723
|
+
if (databaseStorageHash === void 0 || subject.edits.length === 0) return {
|
|
669
724
|
lead,
|
|
670
|
-
ways:
|
|
725
|
+
ways: runWays
|
|
671
726
|
};
|
|
672
|
-
const
|
|
727
|
+
const edited = kept.filter(({ edits }) => edits.length > 0);
|
|
728
|
+
const deletes = edited.map(({ text }) => statementFlag({
|
|
673
729
|
verb: "delete",
|
|
674
730
|
text
|
|
675
731
|
}));
|
|
676
732
|
return {
|
|
677
733
|
lead,
|
|
678
|
-
ways: [`To keep it, plan the change with ${quoted(printedPlanCommand(invocation, databaseStorageHash, [...otherStatements(invocation, subject).filter((flag) => !deletes.includes(flag)), ...deletes]))}, in the migration.ts it writes ${editsText(edits)}, ${runWrittenFile(invocation)}.`, ...swaps ? [] :
|
|
734
|
+
ways: [`To keep it, plan the change with ${quoted(printedPlanCommand(invocation, databaseStorageHash, [...otherStatements(invocation, [subject.text]).filter((flag) => !deletes.includes(flag)), ...deletes]))}, in the migration.ts it writes ${editsText(edited.flatMap(({ edits }) => edits))}, ${runWrittenFile(invocation)}.`, ...swaps ? [] : runWays]
|
|
679
735
|
};
|
|
680
736
|
};
|
|
681
737
|
}
|
|
682
738
|
/**
|
|
683
739
|
* The planner's refusal as the CLI reports it. When a conflict can be written by hand, its next
|
|
684
|
-
*
|
|
685
|
-
* out, from the contract the database is
|
|
740
|
+
* actions are the conflicts' own advice, which says what to write, then the plan to write it in:
|
|
741
|
+
* the run's statements without the ones the conflict leaves out, from the contract the database is
|
|
742
|
+
* at when that is known.
|
|
686
743
|
*/
|
|
687
744
|
function planningRefusedError(conflicts, context) {
|
|
688
745
|
const refused = errorMigrationPlanningFailed({ conflicts });
|
|
@@ -695,10 +752,11 @@ function planningRefusedError(conflicts, context) {
|
|
|
695
752
|
const kept = context.statements.filter((statement) => !left.includes(statement));
|
|
696
753
|
const plan = printedPlanCommand(context.invocation, context.from, [...context.to === void 0 ? [] : ["--to", context.to], ...kept.map(statementFlag)]);
|
|
697
754
|
const action = chooseAction(`To write the rewrites by hand, plan the change without ${left.map(statementFlag).join(" and ")} with \`${plan}\`, add the rewrites the message describes to the migration.ts it writes, ${runWrittenFile(context.invocation)}`);
|
|
755
|
+
const reasons = conflicts.flatMap(({ why }) => why === void 0 ? [] : [why]);
|
|
698
756
|
return new ActionableCliError(refused.code, refused.message, {
|
|
699
757
|
why: refused.why,
|
|
700
758
|
fix: refused.fix ?? action.label,
|
|
701
|
-
nextActions: [action],
|
|
759
|
+
nextActions: [...reasons.length === 0 ? [] : [chooseAction(reasons.join("\n"))], action],
|
|
702
760
|
...ifDefined("meta", refused.meta),
|
|
703
761
|
...ifDefined("docsUrl", refused.docsUrl)
|
|
704
762
|
});
|
|
@@ -830,6 +888,10 @@ function modelOf(contract, coordinate) {
|
|
|
830
888
|
const namespace = Object.hasOwn(namespaces, coordinate.namespaceId) ? namespaces[coordinate.namespaceId] : void 0;
|
|
831
889
|
return namespace !== void 0 && Object.hasOwn(namespace.models, coordinate.model) ? namespace.models[coordinate.model] : void 0;
|
|
832
890
|
}
|
|
891
|
+
/** Whether a field is the discriminator of its model in the contract. */
|
|
892
|
+
function isDiscriminatorField(contract, coordinate) {
|
|
893
|
+
return modelOf(contract, coordinate)?.discriminator?.field === coordinate.field;
|
|
894
|
+
}
|
|
833
895
|
/** The discriminator value a variant has in its base model, or `undefined` when the model is no variant of the contract. */
|
|
834
896
|
function variantValue(contract, coordinate) {
|
|
835
897
|
const base = modelOf(contract, coordinate)?.base;
|
|
@@ -875,7 +937,7 @@ const MODEL_RENAMES = "model";
|
|
|
875
937
|
const FIELD_RENAMES = "field";
|
|
876
938
|
const LISTED_LIMIT = 20;
|
|
877
939
|
const CHECK_NAMES_FIX = "The old name must exist in the origin contract and not in the destination contract, and the new name the other way round. Names match exactly, including case.";
|
|
878
|
-
const STORED_NAME_ONLY = "If only the stored name changed (@map or @@map), a statement cannot state that in this release, and a plan without it drops and creates what the model or field is stored in, with its data. With migration plan, edit the planned migration.ts to rename the stored name instead of dropping and creating it. With db update, rename it in the database yourself first, then run db update
|
|
940
|
+
const STORED_NAME_ONLY = "If only the stored name changed (@map or @@map), a statement cannot state that in this release, and a plan without it drops and creates what the model or field is stored in, with its data. With migration plan, edit the planned migration.ts to rename the stored name instead of dropping and creating it. With db update, rename it in the database yourself first, then run db update.";
|
|
879
941
|
const REPEATED_NAME_FIX = "Give each model, field or enum value at most one statement, and each new name to one model, field or enum value only.";
|
|
880
942
|
function qualifiedModel(coordinate) {
|
|
881
943
|
return modelDisplayName(coordinate);
|
|
@@ -1360,8 +1422,8 @@ function resolveFieldRename(state, statement, from, to) {
|
|
|
1360
1422
|
if (state.renamedTo.has(toKey)) return notOk(errorStatementInvalid(statement, `An earlier statement already renames a field to "${qualifiedField(to.coordinate)}".`, REPEATED_NAME_FIX));
|
|
1361
1423
|
if (from.coordinate.field === to.coordinate.field) return notOk(errorStatementInvalid(statement, `The statement renames field "${toModel}.${to.coordinate.field}" to itself.`, `Leave out --${statement.verb} ${statement.text}. ${STORED_NAME_ONLY}`));
|
|
1362
1424
|
if (hasField(from.model, to.coordinate.field) && hasField(to.model, from.coordinate.field)) return notOk(swapRefusal(statement, "field", `${toModel}.${from.coordinate.field}`, `${toModel}.${to.coordinate.field}`));
|
|
1363
|
-
if (hasField(from.model, to.coordinate.field)) return notOk(errorStatementUnresolved(statement, `The field "${to.coordinate.field}" already exists on the origin model "${qualifiedModel(from.coordinate)}", so it cannot be the new name of a field.`,
|
|
1364
|
-
if (hasField(to.model, from.coordinate.field)) return notOk(errorStatementUnresolved(statement, `The field "${from.coordinate.field}" still exists on the destination model "${toModel}", so it was not renamed.`,
|
|
1425
|
+
if (hasField(from.model, to.coordinate.field)) return notOk(errorStatementUnresolved(statement, `The field "${to.coordinate.field}" already exists on the origin model "${qualifiedModel(from.coordinate)}", so it cannot be the new name of a field.`, newNameTakenFix(statement, from.coordinate.field, to.coordinate.field)));
|
|
1426
|
+
if (hasField(to.model, from.coordinate.field)) return notOk(errorStatementUnresolved(statement, `The field "${from.coordinate.field}" still exists on the destination model "${toModel}", so it was not renamed.`, oldNameReusedFix(statement, from.coordinate.field, to.coordinate.field)));
|
|
1365
1427
|
state.renamedFrom.add(fromKey);
|
|
1366
1428
|
state.renamedTo.add(toKey);
|
|
1367
1429
|
state.originOfRenamedField.set(qualifiedField(to.coordinate), from.coordinate);
|
|
@@ -1413,8 +1475,8 @@ function resolveValueObjectFieldRename(state, statement, from, to) {
|
|
|
1413
1475
|
const newInOrigin = from.fields.includes(newField);
|
|
1414
1476
|
const oldInDestination = to.fields.includes(oldField);
|
|
1415
1477
|
if (newInOrigin && oldInDestination) return notOk(swapRefusal(statement, "valueObjectField", `${newValueObject}.${oldField}`, `${newValueObject}.${newField}`));
|
|
1416
|
-
if (newInOrigin) return notOk(errorStatementUnresolved(statement, `The field "${newField}" already exists in the origin value object "${oldValueObject}", so it cannot be the new name of a field.`,
|
|
1417
|
-
if (oldInDestination) return notOk(errorStatementUnresolved(statement, `The field "${oldField}" still exists in the destination value object "${newValueObject}", so it was not renamed.`,
|
|
1478
|
+
if (newInOrigin) return notOk(errorStatementUnresolved(statement, `The field "${newField}" already exists in the origin value object "${oldValueObject}", so it cannot be the new name of a field.`, newNameTakenFix(statement, oldField, newField)));
|
|
1479
|
+
if (oldInDestination) return notOk(errorStatementUnresolved(statement, `The field "${oldField}" still exists in the destination value object "${newValueObject}", so it was not renamed.`, oldNameReusedFix(statement, oldField, newField)));
|
|
1418
1480
|
state.renamedFrom.add(fromKey);
|
|
1419
1481
|
state.renamedTo.add(toKey);
|
|
1420
1482
|
state.originOfRenamedValueObjectField.set(qualifiedValueObjectField(to.coordinate), from.coordinate);
|
|
@@ -1425,6 +1487,14 @@ function resolveValueObjectFieldRename(state, statement, from, to) {
|
|
|
1425
1487
|
to: to.coordinate
|
|
1426
1488
|
});
|
|
1427
1489
|
}
|
|
1490
|
+
/** How to rename a field onto a name another field of the origin holds: free the name in one migration, then rename. */
|
|
1491
|
+
function newNameTakenFix(statement, oldName, newName) {
|
|
1492
|
+
return `${CHECK_NAMES_FIX} If another field holds the name "${newName}" in the origin and this change renames or removes it, make the change in two migrations: first change the contract so that field has its new name or is gone, and plan only that; then give "${oldName}" the name "${newName}" and plan it with ${statementFlag(statement)}.`;
|
|
1493
|
+
}
|
|
1494
|
+
/** How to give a renamed field's old name to another field: rename in one migration, then add or rename the other. */
|
|
1495
|
+
function oldNameReusedFix(statement, oldName, newName) {
|
|
1496
|
+
return `${CHECK_NAMES_FIX} If "${oldName}" in the destination is another field that takes the name, make the change in two migrations: first change the contract so that "${oldName}" is renamed to "${newName}" and no field has the name "${oldName}", and plan it with ${statementFlag(statement)}; then add or rename the field that takes the name "${oldName}" and plan that.`;
|
|
1497
|
+
}
|
|
1428
1498
|
/**
|
|
1429
1499
|
* Two names that trade places: each is an old name and a new name, which one plan cannot do.
|
|
1430
1500
|
* Statements resolve against contracts, so the swap takes three plans through a temporary name.
|
|
@@ -2029,8 +2099,8 @@ function onlyNewValueObjectField(subject, contracts) {
|
|
|
2029
2099
|
const added = newValueObjectFields(subject, contracts);
|
|
2030
2100
|
return added.length === 1 ? added[0] : void 0;
|
|
2031
2101
|
}
|
|
2032
|
-
/** The
|
|
2033
|
-
function
|
|
2102
|
+
/** The plan's backfill statements, resolved; empty when they do not resolve. */
|
|
2103
|
+
function resolvedBackfills(contracts) {
|
|
2034
2104
|
if (!contracts.statements.some((statement) => statement.verb === "backfill")) return [];
|
|
2035
2105
|
const resolved = resolveStatements({
|
|
2036
2106
|
statements: contracts.statements,
|
|
@@ -2040,8 +2110,22 @@ function backfilledValueObjectFields(contracts) {
|
|
|
2040
2110
|
},
|
|
2041
2111
|
destination: contracts.destination
|
|
2042
2112
|
});
|
|
2043
|
-
|
|
2044
|
-
|
|
2113
|
+
return resolved.ok ? resolved.value.filter((statement) => statement.kind === "backfill") : [];
|
|
2114
|
+
}
|
|
2115
|
+
/** The fields of a model's field's destination model that the origin model does not have and no rename of the plan names. */
|
|
2116
|
+
function newModelFields(subject, contracts) {
|
|
2117
|
+
const model = renamedModel(subject, contracts) ?? subject;
|
|
2118
|
+
const originFields = Object.keys(contracts.origin.domain.namespaces[subject.namespaceId]?.models[subject.model]?.fields ?? {});
|
|
2119
|
+
const renamedTo = new Set(resolvedRenames(contracts).flatMap((statement) => statement.kind === "rename" && statement.entity === "field" && sameModel(statement.to, model) ? [statement.to.field] : []));
|
|
2120
|
+
return Object.keys(contracts.destination.domain.namespaces[model.namespaceId]?.models[model.model]?.fields ?? {}).filter((name) => !renamedTo.has(name) && !originFields.includes(name));
|
|
2121
|
+
}
|
|
2122
|
+
/**
|
|
2123
|
+
* The field a model's field can only have been renamed to: the one field of the destination model
|
|
2124
|
+
* that the origin model does not have and no rename of the plan names.
|
|
2125
|
+
*/
|
|
2126
|
+
function onlyNewModelField(subject, contracts) {
|
|
2127
|
+
const added = newModelFields(subject, contracts);
|
|
2128
|
+
return added.length === 1 ? added[0] : void 0;
|
|
2045
2129
|
}
|
|
2046
2130
|
function renameForm(subject, text, contracts) {
|
|
2047
2131
|
if (subject.kind === "storage") return `${text}:<new name>`;
|
|
@@ -2051,13 +2135,8 @@ function renameForm(subject, text, contracts) {
|
|
|
2051
2135
|
const [only] = added;
|
|
2052
2136
|
return `${text}:${only !== void 0 && added.length === 1 ? modelStatementText(contracts.destination, only) : "<new name>"}`;
|
|
2053
2137
|
}
|
|
2054
|
-
return `${text}:${text.slice(0, text.lastIndexOf("."))}.${(subject.kind === "enumValue" ? onlyNewMember(subject, contracts) : subject.kind === "valueObjectField" ? onlyNewValueObjectField(subject, contracts) :
|
|
2138
|
+
return `${text}:${text.slice(0, text.lastIndexOf("."))}.${(subject.kind === "enumValue" ? onlyNewMember(subject, contracts) : subject.kind === "valueObjectField" ? onlyNewValueObjectField(subject, contracts) : onlyNewModelField(subject, contracts)) ?? "<new name>"}`;
|
|
2055
2139
|
}
|
|
2056
|
-
const SUBJECTS_OF_SEVERAL_OPERATIONS = /* @__PURE__ */ new Set([
|
|
2057
|
-
"model",
|
|
2058
|
-
"enumValue",
|
|
2059
|
-
"valueObjectField"
|
|
2060
|
-
]);
|
|
2061
2140
|
/** The labels of the operations a question is about, as one phrase. */
|
|
2062
2141
|
function labelsText(labels) {
|
|
2063
2142
|
const [first, ...rest] = [...new Set(labels)];
|
|
@@ -2099,6 +2178,39 @@ function resolvesWith(statement, contracts) {
|
|
|
2099
2178
|
if (!resolved.ok) return notOk(`${resolved.failure.message}. ${resolved.failure.why ?? ""}`.trim());
|
|
2100
2179
|
return ok(resolved.value.at(-1));
|
|
2101
2180
|
}
|
|
2181
|
+
function enumMembers(contract, value) {
|
|
2182
|
+
return contract.domain.namespaces[value.namespaceId]?.enum?.[value.enum]?.members ?? [];
|
|
2183
|
+
}
|
|
2184
|
+
function booleanEnum(contract, value) {
|
|
2185
|
+
return enumMembers(contract, value).some((member) => typeof member.value === "boolean");
|
|
2186
|
+
}
|
|
2187
|
+
/**
|
|
2188
|
+
* Whether a command may say how to keep the subject's data: the target gives edits that keep it, or
|
|
2189
|
+
* it is an enum value whose member keeps its name with a new stored value, in an enum whose values
|
|
2190
|
+
* are not booleans, since a boolean enum has no unused value to pass through.
|
|
2191
|
+
*/
|
|
2192
|
+
function keepsDataByCommand(subject, edits, contracts) {
|
|
2193
|
+
return edits.length > 0 || subject.kind === "enumValue" && inDestination(subject, contracts) && !booleanEnum(contracts.origin, subject);
|
|
2194
|
+
}
|
|
2195
|
+
function sameStoredValue(left, right) {
|
|
2196
|
+
return left !== void 0 && JSON.stringify(left) === JSON.stringify(right);
|
|
2197
|
+
}
|
|
2198
|
+
/**
|
|
2199
|
+
* Whether an enum member takes the stored value of another member the destination still has, under
|
|
2200
|
+
* its name or the name a rename gives it, or gives its own stored value to one: the overlap for which
|
|
2201
|
+
* a target advises two migrations, since one rewrite writes a value another reads. A command's own
|
|
2202
|
+
* route for the members changes them all together.
|
|
2203
|
+
*/
|
|
2204
|
+
function sharesValueWithKeptMember(subject, contracts) {
|
|
2205
|
+
if (subject.kind !== "enumValue") return false;
|
|
2206
|
+
const destinationEnum = renamedEnumValue(subject, contracts) ?? subject;
|
|
2207
|
+
const renamedTo = new Map(resolvedRenames(contracts).flatMap((statement) => statement.kind === "rename" && statement.entity === "enumValue" && statement.from.namespaceId === subject.namespaceId && statement.from.enum === subject.enum ? [[statement.from.member, statement.to.member]] : []));
|
|
2208
|
+
const destinationMembers = enumMembers(contracts.destination, destinationEnum);
|
|
2209
|
+
const newValue = (member) => destinationMembers.find(({ name }) => name === (renamedTo.get(member) ?? member))?.value;
|
|
2210
|
+
const originMembers = enumMembers(contracts.origin, subject);
|
|
2211
|
+
const oldValue = originMembers.find(({ name }) => name === subject.member)?.value;
|
|
2212
|
+
return originMembers.some((other) => other.name !== subject.member && newValue(other.name) !== void 0 && (sameStoredValue(newValue(subject.member), other.value) || sameStoredValue(oldValue, newValue(other.name))));
|
|
2213
|
+
}
|
|
2102
2214
|
/**
|
|
2103
2215
|
* The model of a field subject, under the name a rename of the plan gives it, when the destination
|
|
2104
2216
|
* has no model of that name: a rename of the field cannot be written until a statement renames the
|
|
@@ -2109,6 +2221,18 @@ function missingFieldModel(subject, contracts) {
|
|
|
2109
2221
|
const model = renamedModel(subject, contracts) ?? subject;
|
|
2110
2222
|
return contracts.destination.domain.namespaces[model.namespaceId]?.models[model.model] === void 0 ? model : void 0;
|
|
2111
2223
|
}
|
|
2224
|
+
/** What changed for a variant whose discriminator value changed, and what `--convert` does about it. */
|
|
2225
|
+
function changedVariantNote(subject, contracts) {
|
|
2226
|
+
const variant = changedVariant(subject, contracts);
|
|
2227
|
+
if (variant === void 0 || subject.kind !== "model") return [];
|
|
2228
|
+
const from = variantValue(contracts.origin, subject);
|
|
2229
|
+
const to = variantValue(contracts.destination, variant);
|
|
2230
|
+
const convert = statementFlag({
|
|
2231
|
+
verb: "convert",
|
|
2232
|
+
text: modelStatementText(contracts.destination, variant)
|
|
2233
|
+
});
|
|
2234
|
+
return [`Its discriminator value changes from ${JSON.stringify(from)} to ${JSON.stringify(to)}: ${convert} rewrites the stored value to ${JSON.stringify(to)} and keeps the data.`];
|
|
2235
|
+
}
|
|
2112
2236
|
/**
|
|
2113
2237
|
* The variant a model subject is in the destination, under the name a rename of the plan gives it,
|
|
2114
2238
|
* when it is a variant in both contracts whose discriminator value changed: a convert rewrites its
|
|
@@ -2120,35 +2244,61 @@ function changedVariant(subject, contracts) {
|
|
|
2120
2244
|
return variantValueChanged(contracts.origin, subject, contracts.destination, model) ? model : void 0;
|
|
2121
2245
|
}
|
|
2122
2246
|
/**
|
|
2123
|
-
*
|
|
2124
|
-
*
|
|
2125
|
-
*
|
|
2247
|
+
* The new required fields beside a removed field of a value object or of a model another model
|
|
2248
|
+
* embeds, in the destination contract, without those the run backfills: the fields of its value object
|
|
2249
|
+
* or model that the origin does not have and no rename of the plan names.
|
|
2126
2250
|
*/
|
|
2127
|
-
function
|
|
2128
|
-
if (
|
|
2129
|
-
const
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
const
|
|
2251
|
+
function newRequiredFieldsBeside(subject, contracts) {
|
|
2252
|
+
if (inDestination(subject, contracts)) return [];
|
|
2253
|
+
const backfills = contracts.canConvert ? resolvedBackfills(contracts) : [];
|
|
2254
|
+
if (subject.kind === "valueObjectField") {
|
|
2255
|
+
const field = renamedValueObjectField(subject, contracts) ?? subject;
|
|
2256
|
+
const valueObject = valueObjectAt(contracts.destination.storage, {
|
|
2257
|
+
plane: "storage",
|
|
2258
|
+
namespaceId: field.namespaceId,
|
|
2259
|
+
entityKind: "valueObject",
|
|
2260
|
+
entityName: field.valueObject
|
|
2261
|
+
});
|
|
2262
|
+
return newValueObjectFields(subject, contracts).filter((name) => valueObject?.fields[name]?.nullable === false && !backfills.some((backfill) => backfill.kind === "backfill" && backfill.entity === "valueObjectField" && backfill.field.namespaceId === field.namespaceId && backfill.field.valueObject === field.valueObject && backfill.field.field === name)).map((name) => ({
|
|
2263
|
+
...field,
|
|
2264
|
+
kind: "valueObjectField",
|
|
2265
|
+
field: name
|
|
2266
|
+
}));
|
|
2267
|
+
}
|
|
2268
|
+
if (subject.kind !== "field") return [];
|
|
2269
|
+
if ((contracts.origin.domain.namespaces[subject.namespaceId]?.models[subject.model])?.owner === void 0) return [];
|
|
2270
|
+
const model = renamedModel(subject, contracts) ?? subject;
|
|
2271
|
+
const fields = contracts.destination.domain.namespaces[model.namespaceId]?.models[model.model]?.fields ?? {};
|
|
2272
|
+
return newModelFields(subject, contracts).filter((name) => fields[name]?.nullable === false && !backfills.some((backfill) => backfill.kind === "backfill" && backfill.entity === "field" && sameModel(backfill.field, model) && backfill.field.field === name)).map((name) => ({
|
|
2273
|
+
...model,
|
|
2274
|
+
kind: "field",
|
|
2275
|
+
field: name
|
|
2276
|
+
}));
|
|
2277
|
+
}
|
|
2278
|
+
function newFieldText(field, destination) {
|
|
2279
|
+
switch (field.kind) {
|
|
2280
|
+
case "field": return fieldStatementText(destination, field);
|
|
2281
|
+
case "valueObjectField": return valueObjectFieldStatementText(destination, field);
|
|
2282
|
+
default: throw new InternalError(`A new required field is a field or a value object field, not a ${field.kind}`);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
/**
|
|
2286
|
+
* What a delete leaves in the new required fields beside a removed field of a value object or an
|
|
2287
|
+
* embedded model: a temporary value the plan gives, or none, which a backfill writes.
|
|
2288
|
+
*/
|
|
2289
|
+
function newRequiredFieldNote(subject, contracts) {
|
|
2290
|
+
const added = newRequiredFieldsBeside(subject, contracts);
|
|
2291
|
+
if (added.length === 0) return [];
|
|
2292
|
+
const filledKeys = new Set(contracts.temporaryValues.map((value) => migrationSubjectKey(value.subject)));
|
|
2293
|
+
const filled = (each) => filledKeys.has(migrationSubjectKey(each));
|
|
2294
|
+
const temporary = added.filter(filled).map((each) => newFieldText(each, contracts.destination));
|
|
2295
|
+
const needed = added.filter((each) => !filled(each)).map((each) => newFieldText(each, contracts.destination));
|
|
2296
|
+
const named = (fields) => `${fields.length === 1 ? "field" : "fields"} ${quotedList(fields)}`;
|
|
2297
|
+
const backfills = needed.map((each) => statementFlag({
|
|
2148
2298
|
verb: "backfill",
|
|
2149
2299
|
text: each
|
|
2150
2300
|
})).join(" ");
|
|
2151
|
-
return [
|
|
2301
|
+
return [...temporary.length === 0 ? [] : [`If you answer delete, the existing objects get a temporary value in the new required ${named(temporary)}.`], ...needed.length === 0 ? [] : !contracts.canConvert ? [`If you answer delete, the new required ${named(needed)} ${needed.length === 1 ? "gets" : "get"} no temporary value: plan the change with migration plan ${backfills} to write ${needed.length === 1 ? "its value" : "their values"} in migration.ts.`] : needed.length === 1 ? [`If you answer delete, the new required ${named(needed)} still needs a value: add ${backfills} to write it in migration.ts.`] : [`If you answer delete, the new required ${named(needed)} still need a value: add ${backfills} to write them in migration.ts.`]];
|
|
2152
2302
|
}
|
|
2153
2303
|
function quotedList(items) {
|
|
2154
2304
|
const quoted = items.map((item) => `"${item}"`);
|
|
@@ -2163,22 +2313,33 @@ function quotedList(items) {
|
|
|
2163
2313
|
* other renames, and its old name must be the subject. Anything else, and data no model stores,
|
|
2164
2314
|
* can only be deleted. A field whose model the destination names differently can be renamed only
|
|
2165
2315
|
* after a statement renames the model, so the question says to pass one. The question ends with
|
|
2166
|
-
* the planner's advice on keeping the data, when it gives any
|
|
2316
|
+
* the planner's advice on keeping the data, when it gives any, except for enum members that share
|
|
2317
|
+
* stored values when the command gives its own route for them.
|
|
2167
2318
|
*/
|
|
2168
2319
|
function dataLossQuestion(loss, contracts, edits = [], labels = [loss.label]) {
|
|
2169
2320
|
const subject = subjectText(loss.subject, contracts);
|
|
2170
2321
|
const deleteNames = namesSubject("delete", subject);
|
|
2171
2322
|
const missingModel = missingFieldModel(loss.subject, contracts);
|
|
2172
|
-
const keepData =
|
|
2323
|
+
const keepData = contracts.keepDataEditAdvice === void 0 || !keepsDataByCommand(loss.subject, edits, contracts) ? void 0 : contracts.keepDataEditAdvice({
|
|
2324
|
+
subject: loss.subject,
|
|
2325
|
+
text: subject,
|
|
2326
|
+
edits
|
|
2327
|
+
}, contracts.keptSubjects ?? [{
|
|
2328
|
+
subject: loss.subject,
|
|
2329
|
+
text: subject,
|
|
2330
|
+
edits
|
|
2331
|
+
}]);
|
|
2332
|
+
const commandRoutesSharedValues = keepData !== void 0 && keepData.ways.length > 0 && sharesValueWithKeptMember(loss.subject, contracts);
|
|
2173
2333
|
const lost = lossText(loss.subject, subject, contracts.originKnown, loss.loss);
|
|
2174
2334
|
const operations = [...new Set(labels)];
|
|
2175
2335
|
const advice = [
|
|
2176
2336
|
...typeChangeNote(loss, contracts.canConvert),
|
|
2337
|
+
...changedVariantNote(loss.subject, contracts),
|
|
2177
2338
|
...missingModel === void 0 ? [] : [modelRenameAdvice(missingModel, contracts)],
|
|
2178
|
-
...loss.keepDataAdvice === void 0 ? [] : [loss.keepDataAdvice],
|
|
2339
|
+
...loss.keepDataAdvice === void 0 || commandRoutesSharedValues ? [] : [loss.keepDataAdvice],
|
|
2179
2340
|
...keepData?.lead === void 0 ? [] : [keepData.lead],
|
|
2180
2341
|
...keepData?.ways ?? [],
|
|
2181
|
-
...newRequiredFieldNote(loss.subject,
|
|
2342
|
+
...newRequiredFieldNote(loss.subject, contracts)
|
|
2182
2343
|
];
|
|
2183
2344
|
const question = operations.length > 1 ? [
|
|
2184
2345
|
`These operations ${lost}:`,
|
|
@@ -2248,6 +2409,7 @@ function dataLossQuestion(loss, contracts, edits = [], labels = [loss.label]) {
|
|
|
2248
2409
|
forms: renamable ? { rename: renameForm(loss.subject, subject, contracts) } : {},
|
|
2249
2410
|
validate: (verb, text) => {
|
|
2250
2411
|
if (verb !== "rename") return deleteNames(text);
|
|
2412
|
+
if (!text.includes(":")) return `rename needs the new name: type rename ${renameForm(loss.subject, subject, contracts)}.`;
|
|
2251
2413
|
const resolved = resolvesWith({
|
|
2252
2414
|
verb: "rename",
|
|
2253
2415
|
text
|
|
@@ -2394,7 +2556,8 @@ async function askPlanQuestions(input) {
|
|
|
2394
2556
|
destination: input.destination,
|
|
2395
2557
|
canConvert: input.canConvert,
|
|
2396
2558
|
statements,
|
|
2397
|
-
...ifDefined("keepDataEditAdvice", input.keepDataEditAdvice)
|
|
2559
|
+
...ifDefined("keepDataEditAdvice", input.keepDataEditAdvice),
|
|
2560
|
+
temporaryValues: plan.temporaryValues
|
|
2398
2561
|
};
|
|
2399
2562
|
const pending = (verb, planned) => [...new Map(planned.filter((entry) => !consented.has(questionKey(verb, entry))).map((entry) => [questionKey(verb, entry), entry])).values()];
|
|
2400
2563
|
const consent = (verb, entry, text) => consented.set(questionKey(verb, entry), {
|
|
@@ -2421,15 +2584,20 @@ async function askPlanQuestions(input) {
|
|
|
2421
2584
|
}
|
|
2422
2585
|
const losses = pending("delete", plan.dataLoss);
|
|
2423
2586
|
const sameSubject = (loss) => plan.dataLoss.filter((entry) => questionKey("delete", entry) === questionKey("delete", loss));
|
|
2587
|
+
const editsOf = (loss) => sameSubject(loss).flatMap((entry) => entry.keepDataEdit === void 0 ? [] : [entry.keepDataEdit]);
|
|
2424
2588
|
const roundContracts = {
|
|
2425
2589
|
...contracts,
|
|
2426
|
-
keptSubjects: losses.filter((loss) =>
|
|
2590
|
+
keptSubjects: losses.filter((loss) => keepsDataByCommand(loss.subject, editsOf(loss), contracts)).map((loss) => ({
|
|
2591
|
+
subject: loss.subject,
|
|
2592
|
+
text: subjectText(loss.subject, contracts),
|
|
2593
|
+
edits: editsOf(loss)
|
|
2594
|
+
}))
|
|
2427
2595
|
};
|
|
2428
2596
|
const accessChanges = input.askAccess ? pending("allow", plan.accessChanges) : [];
|
|
2429
2597
|
if (losses.length + accessChanges.length === 0 && round > 0) break;
|
|
2430
2598
|
const questions = [...withNamespaceDeleteOnFirstQuestion(withRecoveryOnFirstStorageQuestion(losses.map((loss) => ({
|
|
2431
2599
|
loss,
|
|
2432
|
-
question: acceptingNamespaceAnswers(dataLossQuestion(loss, roundContracts,
|
|
2600
|
+
question: acceptingNamespaceAnswers(dataLossQuestion(loss, roundContracts, editsOf(loss), sameSubject(loss).map(({ label }) => label)), removedNamespaceOf(loss.subject, plan.namespaces), contracts)
|
|
2433
2601
|
})), !input.originKnown), plan.namespaces?.added ?? []), ...accessChanges.map((change) => accessChangeQuestion(change, contracts))];
|
|
2434
2602
|
const answers = await input.answer(questions);
|
|
2435
2603
|
checkAnswers(questions, answers);
|
|
@@ -3045,7 +3213,8 @@ function failureReports(failure, resolutions) {
|
|
|
3045
3213
|
...ifDefined("rowsWithoutValue", rowsWithoutValue?.map(({ field, reason, rows }) => ({
|
|
3046
3214
|
field: field === void 0 ? void 0 : fieldText(field),
|
|
3047
3215
|
reason,
|
|
3048
|
-
rows
|
|
3216
|
+
rows,
|
|
3217
|
+
discriminator: field?.kind === "field" && isDiscriminatorField(resolution.entry.destinationContract, field)
|
|
3049
3218
|
}))),
|
|
3050
3219
|
...ifDefined("rowsHoldingValue", rowsHoldingValue?.map((fact) => rowsHoldingValueReport(fact, resolution.entry.destinationContract))),
|
|
3051
3220
|
...ifDefined("rowsFailingCheck", rowsFailingCheckReport(rowsFailingCheck)),
|
|
@@ -3352,6 +3521,7 @@ async function executeRun(options) {
|
|
|
3352
3521
|
loss: entry.loss
|
|
3353
3522
|
})),
|
|
3354
3523
|
accessChanges: labelled(subjects.accessChanges),
|
|
3524
|
+
temporaryValues: subjects.temporaryValues,
|
|
3355
3525
|
...ifDefined("namespaces", orderedResolutions.find(({ spaceId }) => spaceId === aggregate.app.spaceId)?.entry.namespaces)
|
|
3356
3526
|
});
|
|
3357
3527
|
};
|
|
@@ -7498,6 +7668,7 @@ async function runPlannerLeg(planner, migrations, frameworkComponents, contract,
|
|
|
7498
7668
|
})
|
|
7499
7669
|
})), fromContract, contract, 0),
|
|
7500
7670
|
temporaryValues: reportTemporaryValues(plannerResult.temporaryValues, contract),
|
|
7671
|
+
plannedTemporaryValues: plannerResult.temporaryValues,
|
|
7501
7672
|
...ifDefined("namespaces", plannerResult.namespaces),
|
|
7502
7673
|
plannerWarnings: plannerResult.warnings ?? []
|
|
7503
7674
|
});
|
|
@@ -7557,7 +7728,8 @@ async function answerPlannedDataLoss(input) {
|
|
|
7557
7728
|
delta,
|
|
7558
7729
|
dataLoss: [...input.baseline?.dataLoss ?? [], ...delta?.dataLoss ?? []],
|
|
7559
7730
|
accessChanges: [],
|
|
7560
|
-
...ifDefined("namespaces", delta?.namespaces)
|
|
7731
|
+
...ifDefined("namespaces", delta?.namespaces),
|
|
7732
|
+
temporaryValues: delta?.plannedTemporaryValues ?? []
|
|
7561
7733
|
});
|
|
7562
7734
|
const answered = await askPlanQuestions({
|
|
7563
7735
|
plan: legs(input.delta),
|
|
@@ -8163,4 +8335,4 @@ async function executeRefListCommand(options) {
|
|
|
8163
8335
|
//#endregion
|
|
8164
8336
|
export { refuseContractSpaceIntegrity as $, executeRefDeleteCommand as A, loadAggregateIntegrityViolations as B, executeDbSign as C, withWarningFindings as Ct, executeMigrationNewCommand as D, executeMigrateShowPlan as E, hasMigrationPath as F, looksLikePath as G, loadContractSource as H, isStatementVerb as I, matchConsents as J, mapContractAtError as K, labelsText as L, executeRefSetCommand as M, findPackageByDirPath as N, executeMigrationPlanCommand as O, formatSourceDiagnostic as P, readMigrationRefs as Q, listRefsByContractHash as R, executeDbInit as S, validateLoadedContract as St, executeDbVerify as T, loadContractSourceWithStack as U, loadContractRawSafely as V, loadContractSpaceAggregateForCli as W, planEverySpace as X, migrationSpaceListEntriesFromAggregate as Y, preflightRefAdvancement as Z, deriveStatusEdgeAnnotations as _, skippedOperationsText as _t, advanceRefSafely as a, requireDatabaseForLiveMarkerUse as at, enumerateCheckSpaces as b, statusForMigrationHash as bt, buildContractSpaceAggregate as c, resolveContractRefToSnapshot as ct, buildRefAdvancementFields as d, resolveStatements as dt, refuseDeclaredExtensionTargetMismatch as et, checkSingleTarget as f, resolveToForPlan as ft, createControlClient as g, runMigrationList as gt, convertAndDelete as h, runMigrationCheck as ht, RECORDED_OR_EMPTY_CONTRACT_REF_FORMS as i, renamedAndDeleted as it, executeRefListCommand as j, executeRefAdvancement as k, buildMigrationSpaceGraphEntries as l, resolveFromForPlan as lt, contractValidationMeta as m, runContractSpaceSeedPhase as mt, NO_REF_ADVANCEMENT as n, refusePackageCorruptionOnAggregate as nt, appContractStandInFromIdentity as o, resolveAppTargetPath as ot, computeRefAdvancementName as p, retryCommandFor as pt, mapIntegrityViolations as q, RECORDED_CONTRACT_REF_FORMS as r, refuseUnknownInvariants as rt, appliedHashesFromLedger as s, resolveContractRef$1 as st, ALL_CONTRACT_REF_FORMS as t, refuseMissingInvariantPath as tt, buildReadAggregate as u, resolveMigrationRef as ut, disposeEmitQueue as v, snapshotVerifierFor as vt, executeDbUpdate as w, executeContractEmit as x, toDeclaredExtensionsFromRaw as xt, enrichContract as y, sourceWarningDiagnostic as yt, liveMarkerUse as z };
|
|
8165
8337
|
|
|
8166
|
-
//# sourceMappingURL=ref-
|
|
8338
|
+
//# sourceMappingURL=ref-D4GWEHQU-CV0reyKf.mjs.map
|