@prisma/orm-toolchain 8.0.0-rc.13-dev.12 → 8.0.0-rc.14
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 +45 -16
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +1 -0
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +1 -1
- package/dist/{ref-Qev9k5zj-BMvIT-te.mjs → ref-EXO_pTtx-DOX1lJKh.mjs} +37 -12
- package/dist/ref-EXO_pTtx-DOX1lJKh.mjs.map +1 -0
- package/dist/vite-plugin-contract-emit.mjs +1 -1
- package/package.json +12 -12
- package/dist/ref-Qev9k5zj-BMvIT-te.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
|
|
|
6
6
|
import { r as readRef } from "./refs-qwvw4_dV-DNg_7WTD.mjs";
|
|
7
7
|
import { c as spaceMigrationDirectory } from "./verify-contract-spaces-CYjc343k-DHy5xtKR.mjs";
|
|
8
8
|
import { i as createScaffoldSpecifierResolver } from "./import-roots-BB3GzIi-.mjs";
|
|
9
|
-
import { $ as
|
|
9
|
+
import { $ as executeRefListCommand, A as errorDriverRequired, At as resolveContractRefToSnapshot, B as errorRuntime, Bt as sourceWarningDiagnostic, C as errorConfigValidation$1, Ct as refuseMarkerOutsideGraph, D as errorContractValidationFailed, Dt as requireLiveDatabase, E as errorContractConfigMissing, Et as refuseUnknownInvariants, F as errorMigrationPackageNotFound, H as errorTargetMismatch, Ht as targetSupportsMigrations, I as errorMigrationPlanningFailed, It as runMigrationCheck, J as executeMigrateShowPlan, L as errorNoMigrations, Lt as runMigrationList, M as errorHashMismatch, Mt as resolveMigrationRef, N as errorLegendHumanOnly, O as errorDatabaseConnectionRequired, Ot as resolveAppTargetPath, P as errorMarkerMissing, Pt as runCommandAction, Q as executeRefDeleteCommand, R as errorPathUnreachable, Rt as sanitizeErrorMessage, S as errorAdvanceRefArgConflict, T as errorContractArgConflict, Tt as refusePackageCorruptionOnAggregate, U as errorUnexpected, Ut as toDeclaredExtensionsFromRaw, V as errorTargetMigrationNotSupported, Vt as statusForMigrationHash, W as executeContractEmit, Wt as validateLoadedContract, X as executeMigrationPlanCommand, Y as executeMigrationNewCommand, _ as createControlClient, _t as preflightRefAdvancement, a as NO_REF_ADVANCEMENT, at as loadAggregateIntegrityViolations, bt as redactUrlCredentials, c as appliedHashesFromLedger, ct as loadContractSourceWithStack, d as buildReadAggregate, dt as mapCaughtMigrationError, et as executeRefSetCommand, f as buildRefAdvancementFields, ft as mapContractAtError, g as computeRefAdvancementName, gt as originHashForStatus, h as closeQuietly, ht as migrationSpaceListEntriesFromAggregate, i as ERROR_CODE_DESTRUCTIVE_CHANGES, it as listRefsByContractHash, j as errorFileNotFound, k as errorDestructiveChanges, kt as resolveContractRef$1, lt as loadContractSpaceAggregateForCli, m as chooseAction, mt as maskConnectionUrl, n as CliStructuredError$1$1, nt as formatSourceDiagnostic, o as advanceRefSafely, ot as loadContractRawSafely, p as checkSingleTarget, r as DB_UPDATE_POLICY, rt as hasMigrationPath, st as loadContractSource, t as ActionableCliError, tt as findPackageByDirPath, u as buildMigrationSpaceGraphEntries, ut as looksLikePath, v as deriveStatusEdgeAnnotations, vt as readContractEnvelope, w as errorConsentPlanMismatch, wt as refuseMissingInvariantPath, x as enumerateCheckSpaces, xt as refuseContractSpaceIntegrity, yt as readMigrationRefs, z as errorRunnerFailed, zt as snapshotVerifierFor } from "./ref-EXO_pTtx-DOX1lJKh.mjs";
|
|
10
10
|
import { a as PRISMA7_QUICK_REFERENCE_STEP, i as PRISMA7_LOOP_STEP, n as InitOutputSchema, o as buildNextSteps, r as NEXT_STEPS_BEFORE_SCAFFOLD, t as DB_SIGN_STEP } from "./output-BcC8eB0h-C5bRd-aC.mjs";
|
|
11
11
|
import { createRequire } from "node:module";
|
|
12
12
|
import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
@@ -35,7 +35,7 @@ import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
|
|
|
35
35
|
import stringWidth from "string-width";
|
|
36
36
|
import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
|
|
37
37
|
import { build } from "esbuild";
|
|
38
|
-
//#region ../../../1-framework/3-tooling/cli/dist/load-config-
|
|
38
|
+
//#region ../../../1-framework/3-tooling/cli/dist/load-config-dx-AKQyD.mjs
|
|
39
39
|
/**
|
|
40
40
|
* `isStructuredError` is the repo's own check, and it is the one that matters here: it holds the
|
|
41
41
|
* regular expression for a dotted `NAMESPACE.SUBCODE`, so only a code the protocol accepts
|
|
@@ -262,11 +262,7 @@ function createContractEmitCommand({ executeContractEmit }) {
|
|
|
262
262
|
signal: ctx.signal,
|
|
263
263
|
...ifDefined("outputPath", outputPath)
|
|
264
264
|
});
|
|
265
|
-
|
|
266
|
-
kind: "message",
|
|
267
|
-
severity: "warn",
|
|
268
|
-
text: `warning ${formatSourceDiagnostic(warning)}`
|
|
269
|
-
});
|
|
265
|
+
const diagnostics = (result.sourceWarnings ?? []).flatMap((warning) => sourceWarningDiagnostic(warning, ctx.cwd) ?? []);
|
|
270
266
|
if (result.validationWarning !== void 0) ctx.report({
|
|
271
267
|
kind: "message",
|
|
272
268
|
severity: "warn",
|
|
@@ -286,7 +282,10 @@ function createContractEmitCommand({ executeContractEmit }) {
|
|
|
286
282
|
severity: "verbose",
|
|
287
283
|
text: `Total time: ${document.timings.total}ms`
|
|
288
284
|
});
|
|
289
|
-
return ok$1(ctx.present({
|
|
285
|
+
return ok$1(ctx.present({
|
|
286
|
+
data: document,
|
|
287
|
+
diagnostics
|
|
288
|
+
}, emitPresentations({
|
|
290
289
|
document,
|
|
291
290
|
cwd: ctx.cwd
|
|
292
291
|
})));
|
|
@@ -515,12 +514,13 @@ const defaultContractPrintDependencies = { printPsl };
|
|
|
515
514
|
* @throws {DOMException} `AbortError` if cancelled via `signal`
|
|
516
515
|
*/
|
|
517
516
|
async function executeContractPrint(options, dependencies = defaultContractPrintDependencies) {
|
|
518
|
-
const { config, contractConfig, description, signal } = options;
|
|
517
|
+
const { config, contractConfig, description, cwd, signal } = options;
|
|
519
518
|
const stack = createControlStack(config);
|
|
520
519
|
const sourceWarnings = [];
|
|
521
520
|
const loaded = await loadContractSourceWithStack({
|
|
522
521
|
stack,
|
|
523
522
|
source: contractConfig.source,
|
|
523
|
+
cwd,
|
|
524
524
|
...ifDefined("signal", signal),
|
|
525
525
|
reportWarning: (diagnostic) => {
|
|
526
526
|
sourceWarnings.push(diagnostic);
|
|
@@ -752,17 +752,14 @@ function createContractPrintCommand({ printPsl }) {
|
|
|
752
752
|
config: ctx.config,
|
|
753
753
|
contractConfig,
|
|
754
754
|
description: printDescription(sourcePaths),
|
|
755
|
+
cwd: ctx.cwd,
|
|
755
756
|
signal: ctx.signal
|
|
756
757
|
}, { printPsl });
|
|
757
758
|
} catch (error) {
|
|
758
759
|
return notOk$1(normalizeError(error));
|
|
759
760
|
}
|
|
760
761
|
ctx.signal.throwIfAborted();
|
|
761
|
-
|
|
762
|
-
kind: "message",
|
|
763
|
-
severity: "warn",
|
|
764
|
-
text: `warning ${formatSourceDiagnostic(warning)}`
|
|
765
|
-
});
|
|
762
|
+
const diagnostics = printed.sourceWarnings.flatMap((warning) => sourceWarningDiagnostic(warning, ctx.cwd) ?? []);
|
|
766
763
|
if (outputPath !== void 0) {
|
|
767
764
|
if (existsSync(outputPath)) ctx.report({
|
|
768
765
|
kind: "message",
|
|
@@ -793,7 +790,10 @@ function createContractPrintCommand({ printPsl }) {
|
|
|
793
790
|
sourceSettings: printed.sourceSettings,
|
|
794
791
|
timings: { total: Date.now() - startedAt }
|
|
795
792
|
};
|
|
796
|
-
return ok$1(ctx.present({
|
|
793
|
+
return ok$1(ctx.present({
|
|
794
|
+
data: document,
|
|
795
|
+
diagnostics
|
|
796
|
+
}, printPresentations(document, outputPath === void 0 ? void 0 : {
|
|
797
797
|
contractPath: relative(configDir, outputPath),
|
|
798
798
|
emittedFilesMove: emittedFilesMoveFor({
|
|
799
799
|
configDir,
|
|
@@ -805,6 +805,22 @@ function createContractPrintCommand({ printPsl }) {
|
|
|
805
805
|
});
|
|
806
806
|
}
|
|
807
807
|
const contractPrintCommand = createContractPrintCommand({ printPsl });
|
|
808
|
+
const DB_INIT_ADDITIVE_ONLY_FIX = "`db init` applies only additive changes. Run `{bin} db update`, which also applies widening and destructive ones after you confirm them by typing the database name, or pass `--no-interactive --confirm <database>` where there is nobody to ask.";
|
|
809
|
+
const DB_INIT_NEEDS_MIGRATION_FIX = "`db init` applies only additive changes, and `db update` does not apply data operations. Plan a migration with `{bin} migration plan`, which can include them, and apply it with `{bin} db migrate`.";
|
|
810
|
+
/**
|
|
811
|
+
* What to do instead of `db init` when its additive-only policy refused operations of the given classes: `db update` when its policy allows all of them, otherwise a planned migration.
|
|
812
|
+
*/
|
|
813
|
+
function adviceForRefusedClasses(refused) {
|
|
814
|
+
const allowedByDbUpdate = new Set(DB_UPDATE_POLICY.allowedOperationClasses);
|
|
815
|
+
if (![...refused].every((operationClass) => allowedByDbUpdate.has(operationClass))) return {
|
|
816
|
+
fix: DB_INIT_NEEDS_MIGRATION_FIX,
|
|
817
|
+
nextAction: runCommandAction("Plan a migration, since db update does not apply data operations", "{bin} migration plan")
|
|
818
|
+
};
|
|
819
|
+
return {
|
|
820
|
+
fix: DB_INIT_ADDITIVE_ONLY_FIX,
|
|
821
|
+
nextAction: runCommandAction(refused.has("destructive") ? "Apply the change with db update, which lists the destructive operations and asks you to confirm them" : "Apply the change with db update", "{bin} db update")
|
|
822
|
+
};
|
|
823
|
+
}
|
|
808
824
|
function markerMismatchDetail(failure) {
|
|
809
825
|
const parts = [];
|
|
810
826
|
if (failure.marker?.storageHash !== failure.destination?.storageHash && failure.marker?.storageHash && failure.destination?.storageHash) parts.push(`storageHash (marker: ${failure.marker.storageHash}, destination: ${failure.destination.storageHash})`);
|
|
@@ -818,7 +834,20 @@ function markerMismatchDetail(failure) {
|
|
|
818
834
|
* handle must stop the command rather than degrade into a generic message.
|
|
819
835
|
*/
|
|
820
836
|
function mapDbInitFailure(failure) {
|
|
821
|
-
if (failure.code === "PLANNING_FAILED")
|
|
837
|
+
if (failure.code === "PLANNING_FAILED") {
|
|
838
|
+
const conflicts = failure.conflicts ?? [];
|
|
839
|
+
const planningFailed = errorMigrationPlanningFailed({ conflicts });
|
|
840
|
+
const refused = new Set(conflicts.flatMap((conflict) => conflict.refusedOperationClass === void 0 ? [] : [conflict.refusedOperationClass]));
|
|
841
|
+
if (refused.size === 0) return planningFailed;
|
|
842
|
+
const { fix, nextAction } = adviceForRefusedClasses(refused);
|
|
843
|
+
return new ActionableCliError(planningFailed.code, planningFailed.message, {
|
|
844
|
+
why: planningFailed.why ?? "",
|
|
845
|
+
fix,
|
|
846
|
+
nextActions: [nextAction],
|
|
847
|
+
...ifDefined("meta", planningFailed.meta),
|
|
848
|
+
...ifDefined("docsUrl", planningFailed.docsUrl)
|
|
849
|
+
});
|
|
850
|
+
}
|
|
822
851
|
if (failure.code === "MIGRATION.MARKER_ORIGIN_MISMATCH") return errorRuntime("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing database signature does not match plan destination.${markerMismatchDetail(failure)}`, {
|
|
823
852
|
why: "Database has an existing signature (marker) that does not match the target contract",
|
|
824
853
|
fix: "If bootstrapping, drop/reset the database then re-run `{bin} db init`; otherwise reconcile schema/marker using your migration workflow",
|