@prisma/orm-toolchain 8.0.0-rc.24-dev.30 → 8.0.0-rc.24-dev.32

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.
@@ -1,3 +1,3 @@
1
1
  import { j as errorFromCaught } from "./caught-errors-D_pbHqmS-B-4jRN6g.mjs";
2
- import { A as executeMigrationNewCommand, Ct as statusForMigrationHash, D as executeDbUpdate, E as executeDbSign, F as executeRefSetCommand, G as loadContractSource, M as executeRefAdvancement, N as executeRefDeleteCommand, O as executeDbVerify, P as executeRefListCommand, Q as migrationSpaceListEntriesFromAggregate, R as hasMigrationPath, S as enumerateCheckSpaces, T as executeDbInit, U as loadAggregateIntegrityViolations, V as listRefsByContractHash, W as loadContractRawSafely, X as mapIntegrityViolations, Y as mapContractAtError, _t as runContractSpaceSeedPhase, a as advanceRefSafely, at as refusePackageCorruptionOnAggregate, b as disposeEmitQueue, c as buildContractSpaceAggregate, d as buildRefAdvancementFields, dt as resolveContractRefToSnapshot, et as preflightRefAdvancement, f as checkSingleTarget, ft as resolveFromForPlan, g as createControlClient, ht as resolveToForPlan, it as refuseMissingInvariantPath, j as executeMigrationPlanCommand, k as executeMigrateShowPlan, l as buildMigrationSpaceGraphEntries, mt as resolveStatements, n as NO_REF_ADVANCEMENT, nt as refuseContractSpaceIntegrity, o as appContractStandInFromIdentity, ot as refuseUnknownInvariants, p as computeRefAdvancementName, pt as resolveMigrationRef, q as loadContractSpaceAggregateForCli, rt as refuseDeclaredExtensionTargetMismatch, s as appliedHashesFromLedger, tt as readMigrationRefs, u as buildReadAggregate, ut as resolveContractRef$1, vt as runMigrationCheck, w as executeContractEmit, x as enrichContract, y as deriveStatusEdgeAnnotations, yt as runMigrationList } from "./ref-PQOM_LTC-lyfzb0MO.mjs";
2
+ import { A as executeMigrationNewCommand, Ct as statusForMigrationHash, D as executeDbUpdate, E as executeDbSign, F as executeRefSetCommand, G as loadContractSource, M as executeRefAdvancement, N as executeRefDeleteCommand, O as executeDbVerify, P as executeRefListCommand, Q as migrationSpaceListEntriesFromAggregate, R as hasMigrationPath, S as enumerateCheckSpaces, T as executeDbInit, U as loadAggregateIntegrityViolations, V as listRefsByContractHash, W as loadContractRawSafely, X as mapIntegrityViolations, Y as mapContractAtError, _t as runContractSpaceSeedPhase, a as advanceRefSafely, at as refusePackageCorruptionOnAggregate, b as disposeEmitQueue, c as buildContractSpaceAggregate, d as buildRefAdvancementFields, dt as resolveContractRefToSnapshot, et as preflightRefAdvancement, f as checkSingleTarget, ft as resolveFromForPlan, g as createControlClient, ht as resolveToForPlan, it as refuseMissingInvariantPath, j as executeMigrationPlanCommand, k as executeMigrateShowPlan, l as buildMigrationSpaceGraphEntries, mt as resolveStatements, n as NO_REF_ADVANCEMENT, nt as refuseContractSpaceIntegrity, o as appContractStandInFromIdentity, ot as refuseUnknownInvariants, p as computeRefAdvancementName, pt as resolveMigrationRef, q as loadContractSpaceAggregateForCli, rt as refuseDeclaredExtensionTargetMismatch, s as appliedHashesFromLedger, tt as readMigrationRefs, u as buildReadAggregate, ut as resolveContractRef$1, vt as runMigrationCheck, w as executeContractEmit, x as enrichContract, y as deriveStatusEdgeAnnotations, yt as runMigrationList } from "./ref-Cdgyujqe-KrdBPcA7.mjs";
3
3
  export { NO_REF_ADVANCEMENT, advanceRefSafely, appContractStandInFromIdentity, appliedHashesFromLedger, buildContractSpaceAggregate, buildMigrationSpaceGraphEntries, buildReadAggregate, buildRefAdvancementFields, checkSingleTarget, computeRefAdvancementName, createControlClient, deriveStatusEdgeAnnotations, disposeEmitQueue, enrichContract, enumerateCheckSpaces, errorFromCaught, executeContractEmit, executeDbInit, executeDbSign, executeDbUpdate, executeDbVerify, executeMigrateShowPlan, executeMigrationNewCommand, executeMigrationPlanCommand, executeRefAdvancement, executeRefDeleteCommand, executeRefListCommand, executeRefSetCommand, hasMigrationPath, listRefsByContractHash, loadAggregateIntegrityViolations, loadContractRawSafely, loadContractSource, loadContractSpaceAggregateForCli, mapContractAtError, mapIntegrityViolations, migrationSpaceListEntriesFromAggregate, preflightRefAdvancement, readMigrationRefs, refuseContractSpaceIntegrity, refuseDeclaredExtensionTargetMismatch, refuseMissingInvariantPath, refusePackageCorruptionOnAggregate, refuseUnknownInvariants, resolveContractRef$1 as resolveContractRef, resolveContractRefToSnapshot, resolveFromForPlan, resolveMigrationRef, resolveStatements, resolveToForPlan, runContractSpaceSeedPhase, runMigrationCheck, runMigrationList, statusForMigrationHash };
@@ -35,7 +35,7 @@ import { mergeCapabilityMatrices } from "@prisma/orm-framework/components/compon
35
35
  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
- //#region ../../../1-framework/3-tooling/cli/dist/ref-PQOM_LTC.mjs
38
+ //#region ../../../1-framework/3-tooling/cli/dist/ref-Cdgyujqe.mjs
39
39
  /**
40
40
  * 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.
41
41
  */
@@ -858,29 +858,43 @@ const FORBIDDEN_CHANGE = {
858
858
  function refusingPolicy(source, forbids) {
859
859
  return source.kind === "ref" ? `${source.refName} declares a data protection policy that forbids ${forbids}, so these operations cannot run on the database it describes.` : `This database's data protection policy forbids ${forbids}, so these operations cannot run on it.`;
860
860
  }
861
- const KEEP_APPLIED_MIGRATION = "If another database has already applied this migration, keep it as it is: this database cannot run it until its data protection policy changes.";
861
+ const KEEP_APPLIED_MIGRATION = "If another database has already applied a migration listed here, keep it as it is.";
862
862
  function doItAnyway(source) {
863
863
  return source.kind === "ref" ? `To do it anyway, whoever owns that database must first change the data protection policy ${source.refName} declares.` : "To do it anyway, whoever owns the database must first change its data protection policy.";
864
864
  }
865
- /** What a user can do instead of a refused change, for the command that refused it. */
866
- function keepProtected(refusal, command, invocation) {
867
- const migrated = command === "db migrate";
868
- if (refusal.setting === "accessWidening") return [
869
- refusingPolicy(refusal.source, FORBIDDEN_CHANGE.accessWidening),
870
- ...migrated ? [KEEP_APPLIED_MIGRATION, "If none has, remove the operation from the migration."] : ["Keep the contract's access rules as they are."],
871
- doItAnyway(refusal.source)
872
- ].join(" ");
873
- const changesType = refusal.operations.some(({ loss }) => loss === "typeChange");
865
+ function quotedList$1(names) {
866
+ const quoted = names.map((name) => `"${name}"`);
867
+ return quoted.length === 1 ? quoted.join("") : `${quoted.slice(0, -1).join(", ")} and ${quoted[quoted.length - 1]}`;
868
+ }
869
+ /** The extensions' contract spaces own their migrations: only the extensions' authors can change them. */
870
+ function extensionsOwnMigrations(spaceIds) {
871
+ return spaceIds.length === 1 ? `Contract space ${quotedList$1(spaceIds)} belongs to an extension, so do not edit or delete its migrations; ask the extension's author for a version without the operation.` : `Contract spaces ${quotedList$1(spaceIds)} belong to extensions, so do not edit or delete their migrations; ask the extensions' authors for versions without the operations.`;
872
+ }
873
+ /** What a user can do about refused operations in the application's contract space, for the command that refused them. */
874
+ function keepAppProtected(setting, command, operations, alongsideExtensions, invocation) {
875
+ if (command === "db migrate") {
876
+ const unapplied = alongsideExtensions ? "For an application migration no database has applied" : "For a migration no database has applied";
877
+ return [KEEP_APPLIED_MIGRATION, setting === "accessWidening" ? `${unapplied}, delete the migration and any later ones no database has applied, put the contract's access rules back as they were, and plan again.` : `${unapplied}, delete the migration and any later ones no database has applied, and plan again: with --rename if a model or field was only renamed, with --convert if its type changed, or after putting back in the contract what the migration removes.`];
878
+ }
879
+ if (setting === "accessWidening") return [alongsideExtensions ? "For the application's operations, keep the contract's access rules as they are." : "Keep the contract's access rules as they are."];
880
+ const changesType = operations.some(({ loss }) => loss === "typeChange");
881
+ return [
882
+ alongsideExtensions ? "For the application's operations: if a model or field was only renamed, state the rename with --rename <old>:<new>." : "If a model or field was only renamed, state the rename with --rename <old>:<new>.",
883
+ ...changesType ? [`For a type change, write the conversion with ${cliCommand(invocation === void 0 ? void 0 : {
884
+ ...invocation,
885
+ dbGiven: false
886
+ }, "migration plan", ["--convert", "<field>"])}.`] : [],
887
+ "Otherwise keep it in the contract."
888
+ ];
889
+ }
890
+ /** What a user can do instead of a refused change, for the command that refused it and the contract spaces that hold it. */
891
+ function keepProtected(refusal, command, appSpaceId, invocation) {
892
+ const inApp = refusal.operations.filter(({ spaceId }) => spaceId === appSpaceId);
893
+ const extensionSpaces = [...new Set(refusal.operations.flatMap(({ spaceId }) => spaceId === appSpaceId ? [] : [spaceId]))];
874
894
  return [
875
- refusingPolicy(refusal.source, "losing data"),
876
- ...migrated ? [KEEP_APPLIED_MIGRATION, "If none has, and a model or field was only renamed or its type changed, delete it and plan it again with --rename or --convert; otherwise remove the operation from the migration."] : [
877
- "If a model or field was only renamed, state the rename with --rename <old>:<new>.",
878
- ...changesType ? [`For a type change, write the conversion with ${cliCommand(invocation === void 0 ? void 0 : {
879
- ...invocation,
880
- dbGiven: false
881
- }, "migration plan", ["--convert", "<field>"])}.`] : [],
882
- "Otherwise keep it in the contract."
883
- ],
895
+ refusingPolicy(refusal.source, refusal.setting === "accessWidening" ? FORBIDDEN_CHANGE.accessWidening : "losing data"),
896
+ ...inApp.length === 0 ? [] : keepAppProtected(refusal.setting, command, inApp, extensionSpaces.length > 0, invocation),
897
+ ...extensionSpaces.length === 0 ? [] : [extensionsOwnMigrations(extensionSpaces)],
884
898
  doItAnyway(refusal.source)
885
899
  ].join(" ");
886
900
  }
@@ -897,7 +911,7 @@ function errorDataProtectionForbids(args) {
897
911
  const policyHolder = refName === void 0 ? "This database's data protection policy" : `${refName} declares a data protection policy that`;
898
912
  const forbidden = refusals.map(({ setting }) => FORBIDDEN_CHANGE[setting]).join(" and ");
899
913
  const why = refusals.flatMap(({ setting, source, operations }) => [`${source.kind === "ref" ? `${source.refName} declares` : "The marker records"} ${setting}: ${FORBIDDEN_LEVEL[setting]}.`, ...operations.map(refusedOperationText)]).join(" ");
900
- const recoveries = refusals.map((refusal) => keepProtected(refusal, command, args.invocation));
914
+ const recoveries = refusals.map((refusal) => keepProtected(refusal, command, spaceId, args.invocation));
901
915
  return new ActionableCliError("MIGRATION.DATA_PROTECTION_FORBIDS", `${policyHolder} forbids ${forbidden}`, {
902
916
  why,
903
917
  fix: recoveries.join(" "),
@@ -8958,4 +8972,4 @@ async function executeRefListCommand(options) {
8958
8972
  //#endregion
8959
8973
  export { planEverySpace as $, executeMigrationNewCommand as A, labelsText as B, errorPermitPolicyChangeNeedsRef as C, statusForMigrationHash as Ct, executeDbUpdate as D, executeDbSign as E, withWarningFindings as Et, executeRefSetCommand as F, loadContractSource as G, liveMarkerUse as H, findPackageByDirPath as I, looksLikePath as J, loadContractSourceWithStack as K, formatSourceDiagnostic as L, executeRefAdvancement as M, executeRefDeleteCommand as N, executeDbVerify as O, executeRefListCommand as P, migrationSpaceListEntriesFromAggregate as Q, hasMigrationPath as R, enumerateCheckSpaces as S, sourceWarningDiagnostic as St, executeDbInit as T, validateLoadedContract as Tt, loadAggregateIntegrityViolations as U, listRefsByContractHash as V, loadContractRawSafely as W, mapIntegrityViolations as X, mapContractAtError as Y, matchConsents as Z, databasePoliciesInForce as _, runContractSpaceSeedPhase as _t, advanceRefSafely as a, refusePackageCorruptionOnAggregate as at, disposeEmitQueue as b, skippedOperationsText as bt, buildContractSpaceAggregate as c, requireDatabaseForLiveMarkerUse as ct, buildRefAdvancementFields as d, resolveContractRefToSnapshot as dt, preflightRefAdvancement as et, checkSingleTarget as f, resolveFromForPlan as ft, createControlClient as g, retryCommandFor as gt, convertAndDelete as h, resolveToForPlan as ht, RECORDED_OR_EMPTY_CONTRACT_REF_FORMS as i, refuseMissingInvariantPath as it, executeMigrationPlanCommand as j, executeMigrateShowPlan as k, buildMigrationSpaceGraphEntries as l, resolveAppTargetPath as lt, contractValidationMeta as m, resolveStatements as mt, NO_REF_ADVANCEMENT as n, refuseContractSpaceIntegrity as nt, appContractStandInFromIdentity as o, refuseUnknownInvariants as ot, computeRefAdvancementName as p, resolveMigrationRef as pt, loadContractSpaceAggregateForCli as q, RECORDED_CONTRACT_REF_FORMS as r, refuseDeclaredExtensionTargetMismatch as rt, appliedHashesFromLedger as s, renamedAndDeleted as st, ALL_CONTRACT_REF_FORMS as t, readMigrationRefs as tt, buildReadAggregate as u, resolveContractRef$1 as ut, declaredSettingsText as v, runMigrationCheck as vt, executeContractEmit as w, toDeclaredExtensionsFromRaw as wt, enrichContract as x, snapshotVerifierFor as xt, deriveStatusEdgeAnnotations as y, runMigrationList as yt, isStatementVerb as z };
8960
8974
 
8961
- //# sourceMappingURL=ref-PQOM_LTC-lyfzb0MO.mjs.map
8975
+ //# sourceMappingURL=ref-Cdgyujqe-KrdBPcA7.mjs.map