@prisma/orm-toolchain 8.0.0-rc.11-dev.56 → 8.0.0-rc.12

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.
Files changed (32) hide show
  1. package/dist/cli-telemetry.d.mts +1 -1
  2. package/dist/cli-telemetry.mjs +9 -4
  3. package/dist/cli-telemetry.mjs.map +1 -1
  4. package/dist/cli.d.mts +8 -11
  5. package/dist/cli.d.mts.map +1 -1
  6. package/dist/cli.mjs +62 -229
  7. package/dist/cli.mjs.map +1 -1
  8. package/dist/cli__control-api.d.mts +8 -12
  9. package/dist/cli__control-api.d.mts.map +1 -1
  10. package/dist/cli__control-api.mjs +1 -1
  11. package/dist/cli__control-api__testing.d.mts +1 -1
  12. package/dist/cli__migration-cli.mjs +1 -1
  13. package/dist/config-loader.d.mts +2 -2
  14. package/dist/config-loader.mjs +2 -2
  15. package/dist/{db-verify-BkwsVjIf-BQHjqQoO.d.mts → db-verify-DyjbIXfH-Bk68qPoB.d.mts} +8 -8
  16. package/dist/{db-verify-BkwsVjIf-BQHjqQoO.d.mts.map → db-verify-DyjbIXfH-Bk68qPoB.d.mts.map} +1 -1
  17. package/dist/exports-BOv2LgXz.mjs +518 -0
  18. package/dist/exports-BOv2LgXz.mjs.map +1 -0
  19. package/dist/{exports-DVWNaJUr.mjs → exports-DpFO5X4j.mjs} +2 -2
  20. package/dist/{exports-DVWNaJUr.mjs.map → exports-DpFO5X4j.mjs.map} +1 -1
  21. package/dist/index-D_KaEMoL.d.mts +195 -0
  22. package/dist/index-D_KaEMoL.d.mts.map +1 -0
  23. package/dist/{ref-CTp4Kvp--3Dgd8LXq.mjs → ref-BK7yr-IT-Dk0sxEcL.mjs} +25 -26
  24. package/dist/ref-BK7yr-IT-Dk0sxEcL.mjs.map +1 -0
  25. package/dist/vite-plugin-contract-emit.mjs +4 -4
  26. package/dist/vite-plugin-contract-emit.mjs.map +1 -1
  27. package/package.json +13 -13
  28. package/dist/exports-8-S4PGn0.mjs +0 -286
  29. package/dist/exports-8-S4PGn0.mjs.map +0 -1
  30. package/dist/index-DFX8XFLx.d.mts +0 -83
  31. package/dist/index-DFX8XFLx.d.mts.map +0 -1
  32. package/dist/ref-CTp4Kvp--3Dgd8LXq.mjs.map +0 -1
package/dist/cli.mjs CHANGED
@@ -1,165 +1,40 @@
1
- import { r as getEmittedArtifactPaths } from "./exports-DI1kMms6--e9LdT9A.mjs";
2
- import { i as finalizeConfig, l as requireConfigSections, n as evaluateConfigModule, o as loadConfig, r as expandContractInputs, t as buildLoadedConfig } from "./exports-8-S4PGn0.mjs";
1
+ import { i as expandContractInputs, l as loadConfigFiles, m as requireConfigSections, n as buildLoadedConfig, p as ormConfigSection, r as evaluateConfigModule } from "./exports-BOv2LgXz.mjs";
3
2
  import { t as MigrationToolsError } from "./errors-DD6iLGXk-B4Q4tIha.mjs";
4
3
  import { t as contractSnapshotDir } from "./contract-snapshot-store-1S_6vaGt-mzFobPtq.mjs";
5
4
  import { t as EMPTY_CONTRACT_HASH } from "./constants-CM-w38DQ-Cz_EXbOc.mjs";
6
5
  import { r as readRef } from "./refs-qwvw4_dV-Bk9tl756.mjs";
7
6
  import { c as spaceMigrationDirectory } from "./verify-contract-spaces-CYjc343k-9_2GpPRg.mjs";
8
7
  import { i as createScaffoldSpecifierResolver } from "./import-roots-CYpOz1XZ.mjs";
9
- import { $ as formatSourceDiagnostic, A as errorLegendHumanOnly, B as errorUnexpected, C as errorContractArgConflict, Ct as resolveAppTargetPath, D as errorDriverRequired, Dt as resolveMigrationRef, E as errorDestructiveChanges, F as errorPathUnreachable, Ft as statusForMigrationHash, G as executeMigrateShowPlan, I as errorRunnerFailed, It as targetSupportsMigrations, K as executeMigrationNewCommand, L as errorRuntime, Lt as toDeclaredExtensionsFromRaw, M as errorMigrationPackageNotFound, Mt as runMigrationList, N as errorMigrationPlanningFailed, Nt as sanitizeErrorMessage, O as errorFileNotFound, P as errorNoMigrations, Pt as snapshotVerifierFor, Q as findPackageByDirPath, R as errorTargetMigrationNotSupported, S as errorConsentPlanMismatch, St as requireLiveDatabase, T as errorDatabaseConnectionRequired, Tt as resolveContractRefToSnapshot, V as executeContractEmit, X as executeRefListCommand, Y as executeRefDeleteCommand, Z as executeRefSetCommand, at as loadContractSpaceAggregateForCli, b as errorAdvanceRefArgConflict, bt as refusePackageCorruptionOnAggregate, c as buildMigrationSpaceGraphEntries, ct as mapContractAtError, d as checkSingleTarget, dt as migrationSpaceListEntriesFromAggregate, et as hasMigrationPath, f as chooseAction, ft as originHashForStatus, g as deriveStatusEdgeAnnotations, gt as refuseContractSpaceIntegrity, h as createControlClient, ht as readMigrationRefs, i as advanceRefSafely, it as loadContractSource, j as errorMarkerMissing, jt as runMigrationCheck, k as errorHashMismatch, kt as runCommandAction, l as buildReadAggregate, m as computeRefAdvancementName, mt as readContractEnvelope, n as ERROR_CODE_DESTRUCTIVE_CHANGES, nt as loadAggregateIntegrityViolations, o as appliedHashesFromLedger, ot as looksLikePath, p as closeQuietly, pt as preflightRefAdvancement, q as executeMigrationPlanCommand, r as NO_REF_ADVANCEMENT, rt as loadContractRawSafely, st as mapCaughtMigrationError, t as CliStructuredError$1$1, tt as listRefsByContractHash, u as buildRefAdvancementFields, ut as maskConnectionUrl, vt as refuseMarkerOutsideGraph, w as errorContractValidationFailed, wt as resolveContractRef$1, x as errorConfigValidation$1, xt as refuseUnknownInvariants, y as enumerateCheckSpaces, yt as refuseMissingInvariantPath, z as errorTargetMismatch } from "./ref-CTp4Kvp--3Dgd8LXq.mjs";
8
+ import { $ as formatSourceDiagnostic, A as errorLegendHumanOnly, B as errorUnexpected, C as errorContractArgConflict, Ct as resolveAppTargetPath, D as errorDriverRequired, Dt as resolveMigrationRef, E as errorDestructiveChanges, F as errorPathUnreachable, Ft as statusForMigrationHash, G as executeMigrateShowPlan, I as errorRunnerFailed, It as targetSupportsMigrations, K as executeMigrationNewCommand, L as errorRuntime, Lt as toDeclaredExtensionsFromRaw, M as errorMigrationPackageNotFound, Mt as runMigrationList, N as errorMigrationPlanningFailed, Nt as sanitizeErrorMessage, O as errorFileNotFound, P as errorNoMigrations, Pt as snapshotVerifierFor, Q as findPackageByDirPath, R as errorTargetMigrationNotSupported, S as errorConsentPlanMismatch, St as requireLiveDatabase, T as errorDatabaseConnectionRequired, Tt as resolveContractRefToSnapshot, V as executeContractEmit, X as executeRefListCommand, Y as executeRefDeleteCommand, Z as executeRefSetCommand, at as loadContractSpaceAggregateForCli, b as errorAdvanceRefArgConflict, bt as refusePackageCorruptionOnAggregate, c as buildMigrationSpaceGraphEntries, ct as mapContractAtError, d as checkSingleTarget, dt as migrationSpaceListEntriesFromAggregate, et as hasMigrationPath, f as chooseAction, ft as originHashForStatus, g as deriveStatusEdgeAnnotations, gt as refuseContractSpaceIntegrity, h as createControlClient, ht as readMigrationRefs, i as advanceRefSafely, it as loadContractSource, j as errorMarkerMissing, jt as runMigrationCheck, k as errorHashMismatch, kt as runCommandAction, l as buildReadAggregate, m as computeRefAdvancementName, mt as readContractEnvelope, n as ERROR_CODE_DESTRUCTIVE_CHANGES, nt as loadAggregateIntegrityViolations, o as appliedHashesFromLedger, ot as looksLikePath, p as closeQuietly, pt as preflightRefAdvancement, q as executeMigrationPlanCommand, r as NO_REF_ADVANCEMENT, rt as loadContractRawSafely, st as mapCaughtMigrationError, t as CliStructuredError$1$1, tt as listRefsByContractHash, u as buildRefAdvancementFields, ut as maskConnectionUrl, vt as refuseMarkerOutsideGraph, w as errorContractValidationFailed, wt as resolveContractRef$1, x as errorConfigValidation$1, xt as refuseUnknownInvariants, y as enumerateCheckSpaces, yt as refuseMissingInvariantPath, z as errorTargetMismatch } from "./ref-BK7yr-IT-Dk0sxEcL.mjs";
10
9
  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
10
  import { createRequire } from "node:module";
12
11
  import { existsSync, mkdirSync, readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
13
12
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
14
13
  import { basename, dirname, extname, isAbsolute, join, normalize, relative, resolve } from "pathe";
15
- import { DEFAULT_CONTRACT_SOURCE_DIR } from "@prisma/orm-framework/config/config-types";
16
14
  import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
17
15
  import { pathToFileURL } from "node:url";
18
- import { collectConfigIssues } from "@prisma/orm-framework/config/config-validation";
19
16
  import { DOCS_BASE, docsUrlFor, isStructuredError, isStructuredErrorCode } from "@prisma/orm-framework/utils/structured-error";
20
17
  import { keepInternalSpecifiers } from "@prisma/orm-framework/components/emission";
21
18
  import { blindCast, castAs } from "@prisma/orm-framework/utils/casts";
22
19
  import { InternalError, assertNever, isInternalError } from "@prisma/orm-framework/utils/internal-error";
23
20
  import { CliStructuredError } from "@prisma/orm-framework/errors/control";
24
21
  import { notOk, ok } from "@prisma/orm-framework/utils/result";
22
+ import { defineCommand, defineCommandFamily, defineServerCommand, flag, positional } from "@prisma/cli-engine";
25
23
  import { APP_SPACE_ID, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, createControlStack, issueOutcome } from "@prisma/orm-framework/components/control";
26
24
  import { type } from "arktype";
27
- import { defineCommand, defineCommandFamily, defineConfigSection, defineServerCommand, flag, positional } from "@prisma/cli-engine";
28
25
  import { CliStructuredError as CliStructuredError$1, notOk as notOk$1, ok as ok$1 } from "@prisma/cli-engine/protocol";
29
26
  import { printPsl } from "@prisma/orm-framework/psl-printer";
30
27
  import { EOL, tmpdir } from "node:os";
31
28
  import { format } from "@prisma/orm-framework/psl-parser/format";
32
29
  import { suppressIdleConnectionErrors } from "@prisma/orm-framework/utils/suppress-idle-connection-errors";
30
+ import { DEFAULT_CONTRACT_SOURCE_DIR } from "@prisma/orm-framework/config/config-types";
33
31
  import { spawn } from "node:child_process";
34
32
  import { detect } from "package-manager-detector/detect";
35
33
  import { applyEdits, modify, parse, printParseErrorCode } from "jsonc-parser";
36
34
  import stringWidth from "string-width";
37
35
  import { bold, createColors, cyan, cyanBright, dim, green, yellow } from "colorette";
38
36
  import { build } from "esbuild";
39
- //#region ../../../1-framework/3-tooling/cli/dist/load-config-BH9wEPj1.mjs
40
- const MISSING_CONFIG_ACTION = {
41
- kind: "run-command",
42
- label: "Create a config file",
43
- command: "{bin} orm init"
44
- };
45
- function editConfigAction(field) {
46
- return {
47
- kind: "edit-file",
48
- label: `Correct ${field} in prisma.config.ts`
49
- };
50
- }
51
- function issueDiagnostic(issue) {
52
- return {
53
- code: "CONFIG.VALIDATION_FAILED",
54
- severity: "error",
55
- summary: issue.message,
56
- why: issue.message,
57
- nextActions: [editConfigAction(issue.field)],
58
- meta: {
59
- field: issue.field,
60
- section: issue.section
61
- }
62
- };
63
- }
64
- function sectionAbsentDiagnostic() {
65
- return {
66
- code: "CONFIG.FILE_NOT_FOUND",
67
- severity: "error",
68
- summary: "No Prisma ORM configuration was loaded",
69
- why: `The orm config section is absent, so prisma.config.ts was never evaluated.`,
70
- nextActions: [MISSING_CONFIG_ACTION]
71
- };
72
- }
73
- function notAnObjectDiagnostic() {
74
- return {
75
- code: "CONFIG.VALIDATION_FAILED",
76
- severity: "error",
77
- summary: "Prisma ORM configuration must be an object",
78
- why: `The orm config section is not an object, so no section can be read from it.`,
79
- nextActions: [{
80
- kind: "edit-file",
81
- label: "Export a configuration object from prisma.config.ts"
82
- }]
83
- };
84
- }
85
- function unreadableDiagnostic(error) {
86
- return {
87
- code: "CONFIG.VALIDATION_FAILED",
88
- severity: "error",
89
- summary: "Prisma ORM configuration could not be inspected",
90
- why: error instanceof Error ? error.message : String(error),
91
- nextActions: [{
92
- kind: "edit-file",
93
- label: "Export a plain configuration object from prisma.config.ts"
94
- }]
95
- };
96
- }
97
- function isRecord$4(value) {
98
- return typeof value === "object" && value !== null && !Array.isArray(value);
99
- }
100
- /**
101
- * An emitted artifact listed as its own contract input makes every emit
102
- * consume its previous output. Structural, filesystem-free, and therefore the
103
- * section validator's business rather than the loader's.
104
- */
105
- function collectArtifactCollisionIssues(raw) {
106
- const contract = raw["contract"];
107
- if (!isRecord$4(contract)) return [];
108
- const source = contract["source"];
109
- const output = contract["output"];
110
- if (!isRecord$4(source) || typeof output !== "string") return [];
111
- const inputs = source["inputs"];
112
- if (!Array.isArray(inputs)) return [];
113
- let emitted;
114
- try {
115
- emitted = getEmittedArtifactPaths(output);
116
- } catch (error) {
117
- return [{
118
- section: "contract",
119
- field: "contract.output",
120
- message: error instanceof Error ? error.message : String(error)
121
- }];
122
- }
123
- const emittedPaths = /* @__PURE__ */ new Set([normalize(emitted.jsonPath), normalize(emitted.dtsPath)]);
124
- if (!inputs.some((input) => typeof input === "string" && emittedPaths.has(normalize(input)))) return [];
125
- return [{
126
- section: "contract",
127
- field: "contract.source.inputs[]",
128
- message: "Config.contract.source.inputs must not include emitted artifact paths derived from contract.output"
129
- }];
130
- }
131
- function validate(raw) {
132
- if (raw === void 0) return {
133
- ok: false,
134
- diagnostics: [sectionAbsentDiagnostic()]
135
- };
136
- if (!isRecord$4(raw)) return {
137
- ok: false,
138
- diagnostics: [notAnObjectDiagnostic()]
139
- };
140
- let issues;
141
- try {
142
- issues = [...collectConfigIssues(raw), ...collectArtifactCollisionIssues(raw)];
143
- } catch (error) {
144
- return {
145
- ok: false,
146
- diagnostics: [unreadableDiagnostic(error)]
147
- };
148
- }
149
- if (issues.length > 0) return {
150
- ok: false,
151
- diagnostics: issues.map(issueDiagnostic)
152
- };
153
- return {
154
- ok: true,
155
- value: blindCast(raw),
156
- diagnostics: []
157
- };
158
- }
159
- const ormConfigSection = defineConfigSection({
160
- name: "orm",
161
- validate
162
- });
37
+ //#region ../../../1-framework/3-tooling/cli/dist/load-config-BhBCeXvj.mjs
163
38
  /**
164
39
  * `isStructuredError` is the repo's own check, and it is the one that matters here: it holds the
165
40
  * regular expression for a dotted `NAMESPACE.SUBCODE`, so only a code the protocol accepts
@@ -253,39 +128,12 @@ function normalizeError(error) {
253
128
  * Prisma ORM rather than something the user did. Re-throwing lets the engine settle it as a bug
254
129
  * at exit 1, where converting it would report the same number as a bad connection string.
255
130
  */
256
- function isRecord$3(value) {
257
- return typeof value === "object" && value !== null && !Array.isArray(value);
258
- }
259
- /**
260
- * Hands the handler a config whose paths are absolute. The engine's own
261
- * loader evaluates `prisma.config.ts` without touching the paths inside it, so
262
- * a command mounted in the unified host receives `contract.output` and
263
- * `migrations.dir` exactly as authored — usually relative — while this repo's
264
- * bin finalizes them in its loader. Anchoring here, on the section every ORM
265
- * command reads, makes both hosts hand handlers the same absolute paths.
266
- *
267
- * The anchor is the working directory: the engine discovers the config in the
268
- * working directory only, so that is the file's own directory. (A `--config`
269
- * pointing into another directory is not visible from a command context; a
270
- * relative path inside such a file resolves against the invocation directory,
271
- * which is also what the file's author sees the command run from.)
272
- * Finalization is idempotent — an already-absolute path resolves to itself —
273
- * so a config that arrived finalized passes through unchanged.
274
- */
275
- function finalizedConfigContext(ctx) {
276
- if (!isRecord$3(ctx.config)) return ctx;
277
- const config = blindCast(ctx.config);
278
- return {
279
- ...ctx,
280
- config: finalizeConfig(config, ctx.cwd)
281
- };
282
- }
283
131
  function defineOrmCommand(def) {
284
132
  return defineCommand({
285
133
  ...def,
286
134
  handler: async (args, ctx) => {
287
135
  try {
288
- return await def.handler(args, finalizedConfigContext(ctx));
136
+ return await def.handler(args, ctx);
289
137
  } catch (error) {
290
138
  if (isInternalError(error)) throw error;
291
139
  return notOk$1(normalizeError(error));
@@ -626,42 +474,32 @@ function mapDbInitFailure(failure) {
626
474
  return assertNever(exhaustive, `Unhandled DbInitFailure code: ${String(exhaustive)}`);
627
475
  }
628
476
  /**
629
- * Where migrations live for this project. Resolved against the invocation
630
- * directory, which is also the config file's directory for every default
631
- * invocation.
477
+ * The directory of the config file that wrote the section, recorded when the
478
+ * engine validated it. Every command runs behind that validation, so its
479
+ * absence here is a bug.
632
480
  */
633
- function migrationsDirFor(config, cwd) {
634
- return resolve(cwd, config.migrations?.dir ?? "migrations");
481
+ function baseDirFor(config) {
482
+ if (config.baseDir === void 0) throw new InternalError("the orm config section reached a command without baseDir");
483
+ return config.baseDir;
635
484
  }
636
- /** The app subspace under {@link migrationsDirFor}. */
637
- function appMigrationsDirFor(config, cwd) {
638
- return spaceMigrationDirectory(migrationsDirFor(config, cwd), APP_SPACE_ID);
485
+ /** Where migrations live; the validated config carries it absolute and defaulted. */
486
+ function migrationsDirFor(config) {
487
+ return config.migrations?.dir ?? resolve(baseDirFor(config), "migrations");
639
488
  }
640
- /**
641
- * The config file an operation should anchor its project paths on. The engine
642
- * loads the config and hands a handler the value but not the path, and
643
- * `--config` is an engine flag the handler never sees, so a handler names the
644
- * invocation directory's file. That equals the loaded file for every
645
- * invocation whose config sits in the invocation directory.
646
- */
647
- function projectConfigPathFor(cwd) {
648
- return resolve(cwd, "prisma.config.ts");
489
+ /** The app subspace under {@link migrationsDirFor}. */
490
+ function appMigrationsDirFor(config) {
491
+ return spaceMigrationDirectory(migrationsDirFor(config), APP_SPACE_ID);
649
492
  }
650
493
  /**
651
494
  * Where refs live. The framework keeps them under the app subspace rather than
652
495
  * at the migrations root.
653
496
  */
654
- function appRefsDirFor(config, cwd) {
655
- return resolve(appMigrationsDirFor(config, cwd), "refs");
497
+ function appRefsDirFor(config) {
498
+ return resolve(appMigrationsDirFor(config), "refs");
656
499
  }
657
- /**
658
- * The emitted contract. The config loader has already resolved
659
- * `contract.output` against the config file's directory, so this only has an
660
- * effect for a config handed in raw, as tests do.
661
- */
662
- function contractPathFor(config, cwd) {
663
- const output = config.contract?.output;
664
- return output === void 0 ? void 0 : resolve(cwd, output);
500
+ /** The emitted contract; the validated config carries `contract.output` absolute. */
501
+ function contractPathFor(config) {
502
+ return config.contract?.output;
665
503
  }
666
504
  /**
667
505
  * The header's rendering of a path: relative to where the user invoked the
@@ -915,7 +753,7 @@ async function readContractDocument(contractPath) {
915
753
  }
916
754
  async function prepareMigrationRun(inputs) {
917
755
  const { config, cwd, commandName } = inputs;
918
- const contractPath = contractPathFor(config, cwd);
756
+ const contractPath = contractPathFor(config);
919
757
  if (contractPath === void 0) return notOk$1(normalizeError(errorConfigValidation$1("contract.output", {
920
758
  why: `${commandName} reads the emitted contract from config.contract.output; the config has no value to read.`,
921
759
  section: "contract"
@@ -943,8 +781,8 @@ async function prepareMigrationRun(inputs) {
943
781
  contractDisplayPath: displayPath(contractPath, cwd),
944
782
  dbConnection,
945
783
  database: typeof dbConnection === "string" ? maskConnectionUrl(dbConnection) : void 0,
946
- migrationsDir: migrationsDirFor(config, cwd),
947
- refsDir: appRefsDirFor(config, cwd)
784
+ migrationsDir: migrationsDirFor(config),
785
+ refsDir: appRefsDirFor(config)
948
786
  });
949
787
  }
950
788
  function initPresentations$1(inputs) {
@@ -1048,7 +886,7 @@ function createDbInitCommand(createClient) {
1048
886
  name: refName,
1049
887
  contractJson,
1050
888
  contractJsonPath: contractPath,
1051
- configPath: projectConfigPathFor(ctx.cwd),
889
+ projectDir: baseDirFor(ctx.config),
1052
890
  client
1053
891
  });
1054
892
  if (!preflight.ok) return notOk$1(normalizeError(preflight.failure));
@@ -1307,7 +1145,7 @@ const dbSchemaCommand = createDbSchemaCommand(createControlClient);
1307
1145
  * in this CLI crosses into family types.
1308
1146
  */
1309
1147
  async function readEmittedContract(inputs) {
1310
- const path = contractPathFor(inputs.config, inputs.cwd);
1148
+ const path = contractPathFor(inputs.config);
1311
1149
  if (path === void 0) return notOk$1(normalizeError(errorConfigValidation$1("contract.output", {
1312
1150
  why: `${inputs.commandName} reads the emitted contract from config.contract.output; the config has no value to read.`,
1313
1151
  section: "contract"
@@ -1660,7 +1498,7 @@ function createDbSignCommand(createClient = createControlClient) {
1660
1498
  commandName: "db sign"
1661
1499
  });
1662
1500
  if (!emitted.ok) return notOk$1(emitted.failure);
1663
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
1501
+ const migrationsDir = migrationsDirFor(ctx.config);
1664
1502
  let contractInput = emitted.value.contract;
1665
1503
  let signedSource;
1666
1504
  if (contractRef !== void 0) {
@@ -1695,7 +1533,7 @@ function createDbSignCommand(createClient = createControlClient) {
1695
1533
  name: refName,
1696
1534
  contractJson: signedSource.json,
1697
1535
  contractJsonPath: signedSource.jsonPath,
1698
- configPath: projectConfigPathFor(ctx.cwd),
1536
+ projectDir: baseDirFor(ctx.config),
1699
1537
  client
1700
1538
  });
1701
1539
  if (!preflight.ok) return notOk$1(normalizeError(preflight.failure));
@@ -1759,7 +1597,7 @@ function createDbSignCommand(createClient = createControlClient) {
1759
1597
  header
1760
1598
  })));
1761
1599
  }
1762
- const refsDir = appRefsDirFor(ctx.config, ctx.cwd);
1600
+ const refsDir = appRefsDirFor(ctx.config);
1763
1601
  const previousHash = await previousRefHash(refsDir, advancement.name);
1764
1602
  const advanced = await advanceRefSafely({
1765
1603
  refsDir,
@@ -1996,7 +1834,7 @@ function createDbUpdateCommand(createClient) {
1996
1834
  name: refName,
1997
1835
  contractJson,
1998
1836
  contractJsonPath: snapshotContractPath,
1999
- configPath: projectConfigPathFor(ctx.cwd),
1837
+ projectDir: baseDirFor(ctx.config),
2000
1838
  client
2001
1839
  });
2002
1840
  if (!preflight.ok) return notOk$1(normalizeError(preflight.failure));
@@ -2415,7 +2253,7 @@ function createDbVerifyCommand(createClient = createControlClient) {
2415
2253
  strict,
2416
2254
  database: maskConnectionUrl(dbConnection)
2417
2255
  });
2418
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
2256
+ const migrationsDir = migrationsDirFor(ctx.config);
2419
2257
  const client = createClient({
2420
2258
  family: ctx.config.family,
2421
2259
  target: ctx.config.target,
@@ -6373,7 +6211,7 @@ const lspCommand = defineServerCommand({
6373
6211
  } },
6374
6212
  handler: async (args, io) => {
6375
6213
  const exitCode = await withoutClientProcessIdInArgv(async () => {
6376
- const { startServer } = await import("./exports-DVWNaJUr.mjs");
6214
+ const { startServer } = await import("./exports-DpFO5X4j.mjs");
6377
6215
  return startServer({
6378
6216
  stdin: io.stdin,
6379
6217
  stdout: io.stdout,
@@ -8772,7 +8610,7 @@ function createMigrateCommand(createClient) {
8772
8610
  } },
8773
8611
  needs: { config: ormConfigSection },
8774
8612
  handler: async (args, ctx) => {
8775
- const migrationsRelative = displayPath(migrationsDirFor(ctx.config, ctx.cwd), ctx.cwd);
8613
+ const migrationsRelative = displayPath(migrationsDirFor(ctx.config), ctx.cwd);
8776
8614
  if (args.flags.show) {
8777
8615
  const planned = await executeMigrateShowPlan({
8778
8616
  config: ctx.config,
@@ -8884,7 +8722,7 @@ function createMigrateCommand(createClient) {
8884
8722
  name: args.flags.advanceRef,
8885
8723
  contractJson: snapshotContractJson,
8886
8724
  contractJsonPath: snapshotContractPath,
8887
- configPath: projectConfigPathFor(ctx.cwd),
8725
+ projectDir: baseDirFor(ctx.config),
8888
8726
  client
8889
8727
  });
8890
8728
  if (!preflight.ok) return notOk$1(normalizeError(preflight.failure));
@@ -9146,8 +8984,8 @@ const migrationCheckCommand = defineOrmCommand({
9146
8984
  handler: async (args, ctx) => {
9147
8985
  const { target } = args.positionals;
9148
8986
  const spaceFilter = args.flags.space;
9149
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
9150
- const appMigrationsDir = appMigrationsDirFor(ctx.config, ctx.cwd);
8987
+ const migrationsDir = migrationsDirFor(ctx.config);
8988
+ const appMigrationsDir = appMigrationsDirFor(ctx.config);
9151
8989
  const appMigrationsRelative = displayPath(appMigrationsDir, ctx.cwd);
9152
8990
  const verifySnapshotContent = snapshotVerifierFor(ctx.config);
9153
8991
  const loaded = await buildReadAggregate(ctx.config, {
@@ -9337,7 +9175,7 @@ const migrationGraphCommand = defineOrmCommand({
9337
9175
  needs: { config: ormConfigSection },
9338
9176
  handler: async (args, ctx) => {
9339
9177
  if (args.flags.legend && args.flags.dot) return notOk$1(normalizeError(errorLegendHumanOnly("--dot")));
9340
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
9178
+ const migrationsDir = migrationsDirFor(ctx.config);
9341
9179
  const loaded = await buildReadAggregate(ctx.config, { migrationsDir });
9342
9180
  if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
9343
9181
  const { aggregate, contractHash: liveContractHash } = loaded.value;
@@ -9440,7 +9278,7 @@ const migrationListCommand = defineOrmCommand({
9440
9278
  } },
9441
9279
  needs: { config: ormConfigSection },
9442
9280
  handler: async (args, ctx) => {
9443
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
9281
+ const migrationsDir = migrationsDirFor(ctx.config);
9444
9282
  const loaded = await buildReadAggregate(ctx.config, { migrationsDir });
9445
9283
  if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
9446
9284
  const { aggregate, contractHash: liveContractHash } = loaded.value;
@@ -9695,7 +9533,7 @@ function createMigrationNewCommand(createClient) {
9695
9533
  const scaffolded = await executeMigrationNewCommand({
9696
9534
  config: ctx.config,
9697
9535
  cwd: ctx.cwd,
9698
- configPath: projectConfigPathFor(ctx.cwd),
9536
+ projectDir: baseDirFor(ctx.config),
9699
9537
  ...ifDefined("name", args.flags.name),
9700
9538
  ...ifDefined("from", args.flags.from),
9701
9539
  client: createClient({
@@ -9707,11 +9545,11 @@ function createMigrationNewCommand(createClient) {
9707
9545
  })
9708
9546
  });
9709
9547
  if (!scaffolded.ok) return notOk$1(normalizeError(scaffolded.failure));
9710
- const contractPath = contractPathFor(ctx.config, ctx.cwd);
9548
+ const contractPath = contractPathFor(ctx.config);
9711
9549
  return ok$1(ctx.present({ data: scaffolded.value }, newPresentations({
9712
9550
  document: scaffolded.value,
9713
9551
  contractPath: contractPath === void 0 ? "(unset)" : displayPath(contractPath, ctx.cwd),
9714
- appMigrationsRelative: displayPath(appMigrationsDirFor(ctx.config, ctx.cwd), ctx.cwd)
9552
+ appMigrationsRelative: displayPath(appMigrationsDirFor(ctx.config), ctx.cwd)
9715
9553
  })));
9716
9554
  }
9717
9555
  });
@@ -9967,7 +9805,7 @@ function createMigrationPlanCommand(createClient) {
9967
9805
  const plan = (consent) => executeMigrationPlanCommand({
9968
9806
  config: ctx.config,
9969
9807
  cwd: ctx.cwd,
9970
- configPath: projectConfigPathFor(ctx.cwd),
9808
+ projectDir: baseDirFor(ctx.config),
9971
9809
  ...ifDefined("name", args.flags.name),
9972
9810
  ...ifDefined("from", args.flags.from),
9973
9811
  ...ifDefined("to", args.flags.to),
@@ -9995,12 +9833,12 @@ function createMigrationPlanCommand(createClient) {
9995
9833
  severity: "verbose",
9996
9834
  text: `Total time: ${planned.value.timings.total}ms`
9997
9835
  });
9998
- const contractPath = contractPathFor(ctx.config, ctx.cwd);
9836
+ const contractPath = contractPathFor(ctx.config);
9999
9837
  return ok$1(ctx.present({ data: planned.value }, planPresentations({
10000
9838
  document: planned.value,
10001
9839
  contractPath: contractPath === void 0 ? "(unset)" : displayPath(contractPath, ctx.cwd),
10002
- appMigrationsRelative: displayPath(appMigrationsDirFor(ctx.config, ctx.cwd), ctx.cwd),
10003
- migrationsRelative: displayPath(migrationsDirFor(ctx.config, ctx.cwd), ctx.cwd),
9840
+ appMigrationsRelative: displayPath(appMigrationsDirFor(ctx.config), ctx.cwd),
9841
+ migrationsRelative: displayPath(migrationsDirFor(ctx.config), ctx.cwd),
10004
9842
  from: args.flags.from,
10005
9843
  to: args.flags.to,
10006
9844
  name: args.flags.name
@@ -10165,13 +10003,13 @@ const migrationShowCommand = defineOrmCommand({
10165
10003
  needs: { config: ormConfigSection },
10166
10004
  handler: async (args, ctx) => {
10167
10005
  const { target } = args.positionals;
10168
- const contractPath = contractPathFor(ctx.config, ctx.cwd);
10006
+ const contractPath = contractPathFor(ctx.config);
10169
10007
  if (contractPath === void 0) return notOk$1(normalizeError(errorConfigValidation$1("contract.output", {
10170
10008
  why: "migration show reads the emitted contract from config.contract.output; the config has no value to read.",
10171
10009
  section: "contract"
10172
10010
  })));
10173
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
10174
- const appMigrationsDir = appMigrationsDirFor(ctx.config, ctx.cwd);
10011
+ const migrationsDir = migrationsDirFor(ctx.config);
10012
+ const appMigrationsDir = appMigrationsDirFor(ctx.config);
10175
10013
  const appMigrationsRelative = displayPath(appMigrationsDir, ctx.cwd);
10176
10014
  let contractJson;
10177
10015
  try {
@@ -10436,7 +10274,7 @@ const migrationStatusCommand = defineOrmCommand({
10436
10274
  } },
10437
10275
  needs: { config: ormConfigSection },
10438
10276
  handler: async (args, ctx) => {
10439
- const migrationsDir = migrationsDirFor(ctx.config, ctx.cwd);
10277
+ const migrationsDir = migrationsDirFor(ctx.config);
10440
10278
  const dbConnection = args.flags.db ?? ctx.config.db?.connection;
10441
10279
  const hasDriver = ctx.config.driver !== void 0;
10442
10280
  const usingFromOverride = args.flags.from !== void 0;
@@ -10449,14 +10287,14 @@ const migrationStatusCommand = defineOrmCommand({
10449
10287
  });
10450
10288
  if (missingDb !== null) return notOk$1(normalizeError(missingDb));
10451
10289
  }
10452
- const refsResult = await readMigrationRefs(appRefsDirFor(ctx.config, ctx.cwd));
10290
+ const refsResult = await readMigrationRefs(appRefsDirFor(ctx.config));
10453
10291
  if (!refsResult.ok) return notOk$1(normalizeError(refsResult.failure));
10454
10292
  const refs = refsResult.value;
10455
10293
  const findings = [];
10456
10294
  const loaded = await buildReadAggregate(ctx.config, { migrationsDir });
10457
10295
  if (!loaded.ok) return notOk$1(normalizeError(loaded.failure));
10458
10296
  const { aggregate, contractHash } = loaded.value;
10459
- const contractConfig = { contract: ifDefined("output", contractPathFor(ctx.config, ctx.cwd)) };
10297
+ const contractConfig = { contract: ifDefined("output", contractPathFor(ctx.config)) };
10460
10298
  try {
10461
10299
  await readContractEnvelope(contractConfig);
10462
10300
  } catch (error) {
@@ -10897,35 +10735,30 @@ const ormCommandFamily = defineCommandFamily({
10897
10735
  }
10898
10736
  ]
10899
10737
  });
10900
- /** The file the ORM's loader reads when `--config` names none. */
10901
- const ORM_CONFIG_FILENAME = "prisma.config.ts";
10902
10738
  /**
10903
10739
  * Builds the engine's `Runtime.config` from `prisma.config.ts`.
10904
10740
  *
10905
- * The engine ships its own synchronous loader, but the bin owns the load: the
10906
- * ORM's c12 loader evaluates the module asynchronously and finalizes paths
10907
- * against the config file's own directory. It reads the same shape the engine
10908
- * does — definePrismaConfig from `@prisma/cli-engine` with the whole Prisma ORM
10909
- * configuration nested as the single `orm` section.
10741
+ * The engine ships its own loader, but the bin owns the load: the ORM's c12
10742
+ * loader evaluates the module asynchronously and follows `extends`. It hands
10743
+ * the engine each file on the chain with its sections as written; the engine
10744
+ * validates the `orm` section against its schema with that provenance,
10745
+ * resolving every path against the file that declared it.
10910
10746
  *
10911
10747
  * Only failures that prevent evaluation entirely are diagnostics here, and
10912
10748
  * they carry `section: null` so they fail exactly the commands that read
10913
- * config. Structural verdicts belong to the section validator.
10749
+ * config. Structural verdicts belong to the section schema.
10914
10750
  */
10915
10751
  async function loadOrmConfig(options) {
10916
- const path = resolve(options.cwd, options.configPath ?? ORM_CONFIG_FILENAME);
10917
- const loaded = await loadConfig(options.configPath, { cwd: options.cwd });
10752
+ const loaded = await loadConfigFiles(options.configPath, { cwd: options.cwd });
10918
10753
  if (!loaded.ok) return {
10919
- path,
10920
- sections: {},
10754
+ files: [],
10921
10755
  diagnostics: [{
10922
10756
  section: null,
10923
10757
  diagnostic: toEngineDiagnostic(loaded.failure)
10924
10758
  }]
10925
10759
  };
10926
10760
  return {
10927
- path,
10928
- sections: { ["orm"]: loaded.value.config },
10761
+ files: loaded.value.files,
10929
10762
  diagnostics: []
10930
10763
  };
10931
10764
  }