@prisma/orm-toolchain 8.0.0-rc.11-dev.55 → 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
@@ -0,0 +1,518 @@
1
+ import { r as getEmittedArtifactPaths } from "./exports-DI1kMms6--e9LdT9A.mjs";
2
+ import { createRequire } from "node:module";
3
+ import { realpathSync } from "node:fs";
4
+ import { ifDefined } from "@prisma/orm-framework/utils/defined";
5
+ import { dirname, join, resolve } from "pathe";
6
+ import { glob, isDynamicPattern } from "tinyglobby";
7
+ import { access } from "node:fs/promises";
8
+ import { pathToFileURL } from "node:url";
9
+ import { isStructuredError } from "@prisma/orm-framework/utils/structured-error";
10
+ import { blindCast } from "@prisma/orm-framework/utils/casts";
11
+ import { CliStructuredError, errorConfigEvaluationFailed, errorConfigFileNotFound, errorConfigValidation, errorConfigVersionMarkerMissing } from "@prisma/orm-framework/errors/control";
12
+ import { notOk, ok } from "@prisma/orm-framework/utils/result";
13
+ import { configSchema, defineConfigSection, reference, validateSectionWithSchema } from "@prisma/cli-engine";
14
+ //#region \0rolldown/runtime.js
15
+ var __defProp = Object.defineProperty;
16
+ var __exportAll = (all, no_symbols) => {
17
+ let target = {};
18
+ for (var name in all) __defProp(target, name, {
19
+ get: all[name],
20
+ enumerable: true
21
+ });
22
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
23
+ return target;
24
+ };
25
+ //#endregion
26
+ //#region ../../../1-framework/3-tooling/config-loader/dist/exports/index.mjs
27
+ var exports_exports = /* @__PURE__ */ __exportAll({
28
+ ORM_CONFIG_SECTION_NAME: () => "orm",
29
+ buildLoadedConfig: () => buildLoadedConfig,
30
+ evaluateConfigModule: () => evaluateConfigModule,
31
+ expandContractInputs: () => expandContractInputs,
32
+ findNearestConfigPathForFile: () => findNearestConfigPathForFile,
33
+ isConfigSection: () => isConfigSection,
34
+ loadConfig: () => loadConfig,
35
+ loadConfigFiles: () => loadConfigFiles,
36
+ loadConfigForFile: () => loadConfigForFile,
37
+ loadConfigForSections: () => loadConfigForSections,
38
+ ormConfigSchema: () => ormConfigSchema,
39
+ ormConfigSection: () => ormConfigSection,
40
+ requireConfigSections: () => requireConfigSections,
41
+ validateOrmSection: () => validateOrmSection
42
+ });
43
+ /**
44
+ * Expands a finalized contract source input list into its member file set:
45
+ * absolute, deduped by canonical path, sorted. `patterns` must already be
46
+ * absolute (the `orm` config schema resolves each entry against the config
47
+ * file that wrote it but does not expand it).
48
+ *
49
+ * A wildcard-free entry (per tinyglobby's own magic-character check) passes
50
+ * through verbatim — no globbing, no existence check, no directory
51
+ * expansion — so a literal file, a nonexistent path (its read error
52
+ * surfaces downstream), and a directory (`contract-prisma7`'s adoption
53
+ * surface) all reach the result unchanged. Only entries containing glob
54
+ * magic run through `tinyglobby`, directories-not-auto-expanded and
55
+ * files-only; a glob matching nothing contributes nothing — no diagnostic
56
+ * here.
57
+ */
58
+ async function expandContractInputs(patterns) {
59
+ if (patterns === void 0 || patterns.length === 0) return [];
60
+ const literals = [];
61
+ const globPatterns = [];
62
+ for (const pattern of patterns) (isDynamicPattern(pattern) ? globPatterns : literals).push(pattern);
63
+ const globMatches = globPatterns.length === 0 ? [] : await glob(globPatterns, {
64
+ absolute: true,
65
+ onlyFiles: true,
66
+ expandDirectories: false
67
+ });
68
+ const canonical = new Set([...literals, ...globMatches].map((entry) => resolve(entry)));
69
+ return Array.from(canonical).sort();
70
+ }
71
+ /** The single config section the `orm` command family owns. */
72
+ const ORM_CONFIG_SECTION_NAME = "orm";
73
+ const CONFIG_SECTIONS = [
74
+ "family",
75
+ "target",
76
+ "adapter",
77
+ "driver",
78
+ "extensions",
79
+ "db",
80
+ "contract",
81
+ "migrations",
82
+ "formatter"
83
+ ];
84
+ function isConfigSection(value) {
85
+ return CONFIG_SECTIONS.some((section) => section === value);
86
+ }
87
+ /**
88
+ * The fields that identify a control descriptor. Only these are declared: a
89
+ * descriptor is a runtime object the family builds, and its other members
90
+ * (codec tables, the contract serializer, migration hooks) pass through. Each
91
+ * descriptor is declared a reference, so the command receives the object the
92
+ * config file built.
93
+ */
94
+ const descriptorFields = {
95
+ id: "string",
96
+ familyId: "string",
97
+ version: "string",
98
+ create: "Function"
99
+ };
100
+ const targetLikeFields = {
101
+ ...descriptorFields,
102
+ targetId: "string"
103
+ };
104
+ /**
105
+ * The contract source provider: `load` closes over the authored contract,
106
+ * and `inputs` are paths the schema resolves against the config file. Other
107
+ * keys a provider carries pass through.
108
+ */
109
+ const contractSource = {
110
+ load: "Function",
111
+ "inputs?": "path[]",
112
+ "format?": "string"
113
+ };
114
+ /** Each subsection's own shape, without the rules that relate subsections to one another. */
115
+ const ormSubsectionsSchema = configSchema({
116
+ family: reference(configSchema({
117
+ kind: "'family'",
118
+ ...descriptorFields,
119
+ emission: "object"
120
+ })),
121
+ target: reference(configSchema({
122
+ kind: "'target'",
123
+ ...targetLikeFields
124
+ })),
125
+ adapter: reference(configSchema({
126
+ kind: "'adapter'",
127
+ ...targetLikeFields
128
+ })),
129
+ "driver?": reference(configSchema({
130
+ kind: "'driver'",
131
+ ...targetLikeFields
132
+ })),
133
+ "extensions?": [reference(configSchema({
134
+ kind: "'extension'",
135
+ ...targetLikeFields
136
+ })), "[]"],
137
+ "db?": { "connection?": reference(configSchema("unknown")) },
138
+ "contract?": {
139
+ source: contractSource,
140
+ output: [
141
+ "path",
142
+ "=",
143
+ () => "src/prisma/contract.json"
144
+ ]
145
+ },
146
+ migrations: [
147
+ { dir: [
148
+ "path",
149
+ "=",
150
+ () => "./migrations"
151
+ ] },
152
+ "=",
153
+ () => ({})
154
+ ],
155
+ "formatter?": {
156
+ "indent?": "number.integer >= 1 | 'tab'",
157
+ "newline?": "'LF' | 'CRLF'"
158
+ }
159
+ });
160
+ /**
161
+ * Every broken rule relating the descriptor subsections: each descriptor
162
+ * shares the family's `familyId`, and each target-bound descriptor shares
163
+ * the target's `targetId`. A rule is checked only when `checked` accepts
164
+ * both subsections it relates, so a loader can check the subsections that
165
+ * validated while others have diagnostics.
166
+ */
167
+ function descriptorRelationshipProblems(config, checked) {
168
+ const family = checked("family") ? config.family : void 0;
169
+ const target = checked("target") ? config.target : void 0;
170
+ const bound = [
171
+ [["target"], target],
172
+ [["adapter"], checked("adapter") ? config.adapter : void 0],
173
+ [["driver"], checked("driver") ? config.driver : void 0],
174
+ ...(checked("extensions") ? config.extensions ?? [] : []).map((extension, index) => [["extensions", index], extension])
175
+ ];
176
+ const problems = [];
177
+ for (const [path, descriptor] of bound) {
178
+ if (descriptor === void 0) continue;
179
+ if (family !== void 0 && descriptor.familyId !== family.familyId) problems.push({
180
+ path: [...path, "familyId"],
181
+ expected: `Config.family.familyId (${family.familyId})`,
182
+ actual: descriptor.familyId
183
+ });
184
+ if (target !== void 0 && path[0] !== "target" && descriptor.targetId !== target.targetId) problems.push({
185
+ path: [...path, "targetId"],
186
+ expected: `Config.target.targetId (${target.targetId})`,
187
+ actual: descriptor.targetId
188
+ });
189
+ }
190
+ return problems;
191
+ }
192
+ /**
193
+ * The shape of the `orm` section of `prisma.config.ts`, declared once. The
194
+ * CLI engine derives validation, the diagnostics naming a bad field and the
195
+ * file to fix, and the resolution of every `path` field against the config
196
+ * file that wrote it (prisma-cli ADR 0005). Relative paths are resolved
197
+ * before any command sees the value, and the value carries `baseDir`.
198
+ */
199
+ const ormConfigSchema = ormSubsectionsSchema.narrow((config, ctx) => {
200
+ if ("extensionPacks" in config) return ctx.reject({
201
+ path: ["extensionPacks"],
202
+ message: "Config.extensionPacks is no longer supported; rename it to Config.extensions"
203
+ });
204
+ const problems = descriptorRelationshipProblems(config, () => true);
205
+ for (const problem of problems) ctx.error({
206
+ path: [...problem.path],
207
+ expected: problem.expected,
208
+ actual: problem.actual
209
+ });
210
+ return problems.length === 0;
211
+ });
212
+ /**
213
+ * The section token the ORM's commands declare in `needs.config`. The
214
+ * engine validates the merged section with its provenance and hands the
215
+ * handler the value: absolute paths, `migrations.dir` defaulted, `baseDir`
216
+ * recorded.
217
+ */
218
+ const ormConfigSection = blindCast(defineConfigSection({
219
+ name: "orm",
220
+ schema: ormConfigSchema
221
+ }));
222
+ /**
223
+ * Validates a raw `orm` section the way the engine does for a command,
224
+ * for the loaders and tools that read the config outside a command run.
225
+ */
226
+ function validateOrmSection(raw, provenance) {
227
+ return blindCast(validateSectionWithSchema("orm", ormConfigSchema, raw, provenance));
228
+ }
229
+ /**
230
+ * Validates the shape of every subsection except `failing`, which comes back
231
+ * as authored. A loader uses it when some subsections have diagnostics, so a
232
+ * caller that reads only the others still gets their paths resolved and
233
+ * defaults applied. The rules relating subsections are not applied here; see
234
+ * {@link descriptorRelationshipProblems}.
235
+ */
236
+ function validateOrmSectionExcept(raw, provenance, failing) {
237
+ const healthy = CONFIG_SECTIONS.filter((section) => !failing.has(section));
238
+ return validateSectionWithSchema("orm", ormSubsectionsSchema.pick(...healthy), raw, provenance);
239
+ }
240
+ const CONFIG_FILENAME = "prisma.config.ts";
241
+ async function findNearestConfigPathForFile(filePath) {
242
+ let current = dirname(resolve(process.cwd(), filePath));
243
+ while (true) {
244
+ const candidate = join(current, CONFIG_FILENAME);
245
+ if (await fileExists(candidate)) return candidate;
246
+ const parent = dirname(current);
247
+ if (parent === current) return;
248
+ current = parent;
249
+ }
250
+ }
251
+ async function fileExists(path) {
252
+ try {
253
+ await access(path);
254
+ return true;
255
+ } catch {
256
+ return false;
257
+ }
258
+ }
259
+ function isRecord(value) {
260
+ return typeof value === "object" && value !== null && !Array.isArray(value);
261
+ }
262
+ function collectArtifactCollisionDiagnostics(contract) {
263
+ const inputs = contract.source.inputs;
264
+ const output = contract.output;
265
+ if (inputs === void 0 || output === void 0) return [];
266
+ let emittedArtifactPaths;
267
+ try {
268
+ emittedArtifactPaths = getEmittedArtifactPaths(output);
269
+ } catch (error) {
270
+ return [errorConfigValidation("contract.output", {
271
+ /* v8 ignore next -- getEmittedArtifactPaths only ever throws an Error */
272
+ why: error instanceof Error ? error.message : String(error),
273
+ section: "contract"
274
+ })];
275
+ }
276
+ const emittedPaths = /* @__PURE__ */ new Set([emittedArtifactPaths.jsonPath, emittedArtifactPaths.dtsPath]);
277
+ if (inputs.some((input) => emittedPaths.has(input))) return [errorConfigValidation("contract.source.inputs[]", {
278
+ why: "Config.contract.source.inputs must not include emitted artifact paths derived from contract.output",
279
+ section: "contract"
280
+ })];
281
+ return [];
282
+ }
283
+ function validateLoadedSection(rawConfig, provenance) {
284
+ const validation = validateOrmSection(rawConfig, provenance);
285
+ if (!validation.ok) {
286
+ const diagnostics = validation.diagnostics.map((diagnostic) => {
287
+ const field = typeof diagnostic.meta?.["field"] === "string" ? diagnostic.meta["field"] : "";
288
+ const section = field.split(".")[0] ?? "";
289
+ return errorConfigValidation(field, {
290
+ why: diagnostic.summary,
291
+ ...isConfigSection(section) ? { section } : {}
292
+ });
293
+ });
294
+ const failing = new Set(diagnostics.map((diagnostic) => String(diagnostic.meta?.["section"] ?? "")));
295
+ const partial = validateOrmSectionExcept(rawConfig, provenance, failing);
296
+ const config = blindCast(partial.ok ? partial.value : rawConfig);
297
+ if (!partial.ok) return {
298
+ config,
299
+ diagnostics
300
+ };
301
+ const related = descriptorRelationshipProblems(config, (section) => !failing.has(section)).map((problem) => errorConfigValidation(problem.path.join("."), {
302
+ why: `${problem.path.join(".")} must be ${problem.expected} (was ${problem.actual})`,
303
+ section: String(problem.path[0])
304
+ }));
305
+ const collisions = failing.has("contract") || config.contract === void 0 ? [] : collectArtifactCollisionDiagnostics(config.contract);
306
+ return {
307
+ config,
308
+ diagnostics: [
309
+ ...diagnostics,
310
+ ...related,
311
+ ...collisions
312
+ ]
313
+ };
314
+ }
315
+ const config = validation.value;
316
+ if (config.contract === void 0) return {
317
+ config,
318
+ diagnostics: []
319
+ };
320
+ return {
321
+ config,
322
+ diagnostics: collectArtifactCollisionDiagnostics(config.contract)
323
+ };
324
+ }
325
+ /**
326
+ * Validates a raw `orm` section and resolves its paths against `configDir`, the way a loaded config
327
+ * file is. A caller that builds the section in memory gets the same diagnostics as one that wrote
328
+ * it to `prisma.config.ts`.
329
+ */
330
+ function buildLoadedConfig(rawConfig, configDir) {
331
+ const file = join(configDir, CONFIG_FILENAME);
332
+ return validateLoadedSection(rawConfig, {
333
+ files: [file],
334
+ keys: Object.fromEntries(Object.keys(rawConfig).map((key) => [key, file]))
335
+ });
336
+ }
337
+ function toConfigLoadFailure(error, configPath) {
338
+ if (CliStructuredError.is(error)) return error;
339
+ const resolvedPath = configPath ? resolve(process.cwd(), configPath) : void 0;
340
+ if (isStructuredError(error)) return new CliStructuredError(error.code, error.message, {
341
+ ...ifDefined("why", error.why),
342
+ ...ifDefined("fix", error.fix),
343
+ ...ifDefined("where", error.where),
344
+ ...ifDefined("meta", error.meta),
345
+ cause: error
346
+ });
347
+ if (error instanceof Error) return errorConfigEvaluationFailed(resolvedPath, {
348
+ why: error.message,
349
+ cause: error
350
+ });
351
+ return errorConfigEvaluationFailed(resolvedPath, { why: String(error) });
352
+ }
353
+ /**
354
+ * c12 is resolved to its real on-disk entry before importing: jiti (inside
355
+ * c12) resolves its own transitive imports from the importing file's location,
356
+ * and a symlinked install (pnpm) would otherwise anchor them somewhere the
357
+ * packages are not. Importing at the real location keeps every transitive
358
+ * resolution working.
359
+ */
360
+ async function importC12() {
361
+ return await import(pathToFileURL(realpathSync(createRequire(import.meta.url).resolve("c12"))).href);
362
+ }
363
+ /**
364
+ * Runs c12 against one config path. Every throw out of evaluation becomes a
365
+ * `CONFIG.EVALUATION_FAILED` and a requested path c12 did not resolve to becomes
366
+ * `CONFIG.FILE_NOT_FOUND`, so both loaders report the same failures for the
367
+ * same file.
368
+ */
369
+ async function evaluateWithC12(configPath, cwd) {
370
+ const resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;
371
+ const configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;
372
+ let result;
373
+ try {
374
+ result = await (await importC12()).loadConfig({
375
+ name: "prisma",
376
+ ...ifDefined("configFile", resolvedConfigPath),
377
+ cwd: configCwd
378
+ });
379
+ } catch (error) {
380
+ return notOk(toConfigLoadFailure(error, configPath));
381
+ }
382
+ if (resolvedConfigPath && result.configFile !== resolvedConfigPath) return notOk(errorConfigFileNotFound(resolvedConfigPath));
383
+ return ok(result);
384
+ }
385
+ const FILE_FORMAT_KEYS = /* @__PURE__ */ new Set(["$prismaConfig", "extends"]);
386
+ function sectionsOf(exported) {
387
+ return Object.fromEntries(Object.entries(exported).filter(([key]) => !FILE_FORMAT_KEYS.has(key)));
388
+ }
389
+ /**
390
+ * Evaluates `prisma.config.ts` and hands back each file on the chain with its
391
+ * sections as written, plus c12's merge. Failures that prevent evaluation are
392
+ * the Result failure. Nothing is validated or resolved here: the CLI engine
393
+ * validates each section against its schema with the files' provenance, and
394
+ * {@link loadConfig} does the same for the `orm` section outside a command run.
395
+ */
396
+ async function loadConfigFiles(configPath, options) {
397
+ const cwd = options?.cwd ?? process.cwd();
398
+ const resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;
399
+ const configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;
400
+ const evaluated = await evaluateWithC12(configPath, cwd);
401
+ if (!evaluated.ok) return evaluated;
402
+ const result = evaluated.value;
403
+ if (!result.config || Object.keys(result.config).length === 0) return notOk(errorConfigFileNotFound(result.configFile || resolvedConfigPath || configPath));
404
+ /* v8 ignore next -- c12 always returns layers for a config it evaluated */
405
+ const layers = result.layers ?? [];
406
+ const layerConfig = layers[0]?.config;
407
+ const engineMarker = isRecord(layerConfig) ? layerConfig["$prismaConfig"] : void 0;
408
+ if (engineMarker === void 0)
409
+ /* v8 ignore next -- a config that evaluated always carries its resolved path */
410
+ return notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));
411
+ if (engineMarker !== 1)
412
+ /* v8 ignore next -- a config that evaluated always carries its resolved path */
413
+ return notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));
414
+ /* v8 ignore next -- @preserve */
415
+ const requested = result.configFile ?? join(configCwd, CONFIG_FILENAME);
416
+ const files = layers.flatMap((layer, index) => isRecord(layer.config) && Object.keys(layer.config).length > 0 ? [{
417
+ path: index === 0 ? requested : resolve(configCwd, layer.configFile ?? requested),
418
+ sections: sectionsOf(layer.config)
419
+ }] : []);
420
+ return ok({
421
+ files: files.length === 0 ? [{
422
+ path: requested,
423
+ sections: sectionsOf(result.config)
424
+ }] : files,
425
+ merged: result.config
426
+ });
427
+ }
428
+ /**
429
+ * The raw default export of the module at `configPath`, evaluated exactly as
430
+ * {@link loadConfig} evaluates it and returned without validation or the
431
+ * version-marker check. The caller decides what the export means — a
432
+ * default export without the `$prismaConfig` marker is what an earlier Prisma
433
+ * CLI's config looks like.
434
+ */
435
+ async function evaluateConfigModule(configPath, options) {
436
+ const cwd = options?.cwd ?? process.cwd();
437
+ const resolvedConfigPath = resolve(cwd, configPath);
438
+ if (!await fileExists(resolvedConfigPath)) return notOk(errorConfigFileNotFound(resolvedConfigPath));
439
+ const evaluated = await evaluateWithC12(resolvedConfigPath, cwd);
440
+ if (!evaluated.ok) return evaluated;
441
+ /* v8 ignore next -- c12 always returns layers for a config it evaluated */
442
+ const [requestedLayer] = evaluated.value.layers ?? [];
443
+ return ok(requestedLayer?.config);
444
+ }
445
+ /** Which file wrote each top-level key of the `orm` section, nearest file first. */
446
+ function ormProvenance(files, merged) {
447
+ const contributors = files.filter((file) => isRecord(file.sections["orm"]));
448
+ const paths = contributors.map((file) => file.path);
449
+ return {
450
+ files: paths,
451
+ keys: Object.fromEntries(Object.keys(merged).flatMap((key) => {
452
+ const file = contributors.find((contributor) => {
453
+ const orm = contributor.sections["orm"];
454
+ return isRecord(orm) && Object.hasOwn(orm, key);
455
+ })?.path ?? paths[0];
456
+ return file === void 0 ? [] : [[key, file]];
457
+ }))
458
+ };
459
+ }
460
+ /**
461
+ * Loads the Prisma 8 config and validates its `orm` section.
462
+ *
463
+ * Failures that prevent evaluation entirely — missing file, module that does
464
+ * not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the
465
+ * `Result` failure. Structural problems inside an evaluated config do not
466
+ * fail the load: they are returned as section-tagged diagnostics so commands
467
+ * fail only on the sections they read (via {@link requireConfigSections}).
468
+ */
469
+ async function loadConfig(configPath, options) {
470
+ const loaded = await loadConfigFiles(configPath, options);
471
+ if (!loaded.ok) return loaded;
472
+ const orm = loaded.value.merged["orm"];
473
+ if (orm !== void 0 && !isRecord(orm)) return ok({
474
+ config: validateLoadedSection({}, {
475
+ files: [],
476
+ keys: {}
477
+ }).config,
478
+ diagnostics: [errorConfigValidation("orm", { why: `The orm section of ${CONFIG_FILENAME} must be an object` })]
479
+ });
480
+ const section = orm ?? {};
481
+ const provenance = ormProvenance(loaded.value.files, section);
482
+ const requested = loaded.value.files[0]?.path;
483
+ return ok(validateLoadedSection(section, provenance.files.length === 0 && requested !== void 0 ? {
484
+ files: [requested],
485
+ keys: Object.fromEntries(Object.keys(section).map((key) => [key, requested]))
486
+ } : provenance));
487
+ }
488
+ /**
489
+ * Narrows a {@link LoadedConfig} to the sections a command reads. Fails with
490
+ * the first diagnostic concerning a required section; diagnostics on other
491
+ * sections are ignored so unrelated commands keep working.
492
+ */
493
+ function requireConfigSections(loaded, sections) {
494
+ const blocking = loaded.diagnostics.find((diagnostic) => {
495
+ const section = diagnostic.meta?.["section"];
496
+ return typeof section !== "string" || sections.some((required) => required === section);
497
+ });
498
+ return blocking ? notOk(blocking) : ok(loaded.config);
499
+ }
500
+ /**
501
+ * Convenience composition of {@link loadConfig} and
502
+ * {@link requireConfigSections} for commands that read a fixed set of
503
+ * sections and have no use for diagnostics outside them.
504
+ */
505
+ async function loadConfigForSections(configPath, sections) {
506
+ const loaded = await loadConfig(configPath);
507
+ if (!loaded.ok) return loaded;
508
+ return requireConfigSections(loaded.value, sections);
509
+ }
510
+ async function loadConfigForFile(filePath) {
511
+ const configPath = await findNearestConfigPathForFile(filePath);
512
+ if (configPath === void 0) return notOk(errorConfigFileNotFound(join(dirname(resolve(process.cwd(), filePath)), CONFIG_FILENAME)));
513
+ return loadConfig(configPath);
514
+ }
515
+ //#endregion
516
+ export { exports_exports as a, loadConfig as c, loadConfigForSections as d, ormConfigSchema as f, validateOrmSection as h, expandContractInputs as i, loadConfigFiles as l, requireConfigSections as m, buildLoadedConfig as n, findNearestConfigPathForFile as o, ormConfigSection as p, evaluateConfigModule as r, isConfigSection as s, ORM_CONFIG_SECTION_NAME as t, loadConfigForFile as u };
517
+
518
+ //# sourceMappingURL=exports-BOv2LgXz.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exports-BOv2LgXz.mjs","names":[],"sources":["../../../../1-framework/3-tooling/config-loader/dist/exports/index.mjs"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { dirname, join, resolve } from \"pathe\";\nimport { glob, isDynamicPattern } from \"tinyglobby\";\nimport { realpathSync } from \"node:fs\";\nimport { access } from \"node:fs/promises\";\nimport { pathToFileURL } from \"node:url\";\nimport { getEmittedArtifactPaths } from \"@internal/emitter\";\nimport { CliStructuredError, errorConfigEvaluationFailed, errorConfigFileNotFound, errorConfigValidation, errorConfigVersionMarkerMissing } from \"@internal/errors/control\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { notOk, ok } from \"@internal/utils/result\";\nimport { isStructuredError } from \"@internal/utils/structured-error\";\nimport { configSchema, defineConfigSection, reference, validateSectionWithSchema } from \"@prisma/cli-engine\";\n//#region src/expand-contract-inputs.ts\n/**\n* Expands a finalized contract source input list into its member file set:\n* absolute, deduped by canonical path, sorted. `patterns` must already be\n* absolute (the `orm` config schema resolves each entry against the config\n* file that wrote it but does not expand it).\n*\n* A wildcard-free entry (per tinyglobby's own magic-character check) passes\n* through verbatim — no globbing, no existence check, no directory\n* expansion — so a literal file, a nonexistent path (its read error\n* surfaces downstream), and a directory (`contract-prisma7`'s adoption\n* surface) all reach the result unchanged. Only entries containing glob\n* magic run through `tinyglobby`, directories-not-auto-expanded and\n* files-only; a glob matching nothing contributes nothing — no diagnostic\n* here.\n*/\nasync function expandContractInputs(patterns) {\n\tif (patterns === void 0 || patterns.length === 0) return [];\n\tconst literals = [];\n\tconst globPatterns = [];\n\tfor (const pattern of patterns) (isDynamicPattern(pattern) ? globPatterns : literals).push(pattern);\n\tconst globMatches = globPatterns.length === 0 ? [] : await glob(globPatterns, {\n\t\tabsolute: true,\n\t\tonlyFiles: true,\n\t\texpandDirectories: false\n\t});\n\tconst canonical = new Set([...literals, ...globMatches].map((entry) => resolve(entry)));\n\treturn Array.from(canonical).sort();\n}\n//#endregion\n//#region src/orm-section.ts\n/** The single config section the `orm` command family owns. */\nconst ORM_CONFIG_SECTION_NAME = \"orm\";\nconst CONFIG_SECTIONS = [\n\t\"family\",\n\t\"target\",\n\t\"adapter\",\n\t\"driver\",\n\t\"extensions\",\n\t\"db\",\n\t\"contract\",\n\t\"migrations\",\n\t\"formatter\"\n];\nfunction isConfigSection(value) {\n\treturn CONFIG_SECTIONS.some((section) => section === value);\n}\n/**\n* The fields that identify a control descriptor. Only these are declared: a\n* descriptor is a runtime object the family builds, and its other members\n* (codec tables, the contract serializer, migration hooks) pass through. Each\n* descriptor is declared a reference, so the command receives the object the\n* config file built.\n*/\nconst descriptorFields = {\n\tid: \"string\",\n\tfamilyId: \"string\",\n\tversion: \"string\",\n\tcreate: \"Function\"\n};\nconst targetLikeFields = {\n\t...descriptorFields,\n\ttargetId: \"string\"\n};\n/**\n* The contract source provider: `load` closes over the authored contract,\n* and `inputs` are paths the schema resolves against the config file. Other\n* keys a provider carries pass through.\n*/\nconst contractSource = {\n\tload: \"Function\",\n\t\"inputs?\": \"path[]\",\n\t\"format?\": \"string\"\n};\n/** Each subsection's own shape, without the rules that relate subsections to one another. */\nconst ormSubsectionsSchema = configSchema({\n\tfamily: reference(configSchema({\n\t\tkind: \"'family'\",\n\t\t...descriptorFields,\n\t\temission: \"object\"\n\t})),\n\ttarget: reference(configSchema({\n\t\tkind: \"'target'\",\n\t\t...targetLikeFields\n\t})),\n\tadapter: reference(configSchema({\n\t\tkind: \"'adapter'\",\n\t\t...targetLikeFields\n\t})),\n\t\"driver?\": reference(configSchema({\n\t\tkind: \"'driver'\",\n\t\t...targetLikeFields\n\t})),\n\t\"extensions?\": [reference(configSchema({\n\t\tkind: \"'extension'\",\n\t\t...targetLikeFields\n\t})), \"[]\"],\n\t\"db?\": { \"connection?\": reference(configSchema(\"unknown\")) },\n\t\"contract?\": {\n\t\tsource: contractSource,\n\t\toutput: [\n\t\t\t\"path\",\n\t\t\t\"=\",\n\t\t\t() => \"src/prisma/contract.json\"\n\t\t]\n\t},\n\tmigrations: [\n\t\t{ dir: [\n\t\t\t\"path\",\n\t\t\t\"=\",\n\t\t\t() => \"./migrations\"\n\t\t] },\n\t\t\"=\",\n\t\t() => ({})\n\t],\n\t\"formatter?\": {\n\t\t\"indent?\": \"number.integer >= 1 | 'tab'\",\n\t\t\"newline?\": \"'LF' | 'CRLF'\"\n\t}\n});\n/**\n* Every broken rule relating the descriptor subsections: each descriptor\n* shares the family's `familyId`, and each target-bound descriptor shares\n* the target's `targetId`. A rule is checked only when `checked` accepts\n* both subsections it relates, so a loader can check the subsections that\n* validated while others have diagnostics.\n*/\nfunction descriptorRelationshipProblems(config, checked) {\n\tconst family = checked(\"family\") ? config.family : void 0;\n\tconst target = checked(\"target\") ? config.target : void 0;\n\tconst bound = [\n\t\t[[\"target\"], target],\n\t\t[[\"adapter\"], checked(\"adapter\") ? config.adapter : void 0],\n\t\t[[\"driver\"], checked(\"driver\") ? config.driver : void 0],\n\t\t...(checked(\"extensions\") ? config.extensions ?? [] : []).map((extension, index) => [[\"extensions\", index], extension])\n\t];\n\tconst problems = [];\n\tfor (const [path, descriptor] of bound) {\n\t\tif (descriptor === void 0) continue;\n\t\tif (family !== void 0 && descriptor.familyId !== family.familyId) problems.push({\n\t\t\tpath: [...path, \"familyId\"],\n\t\t\texpected: `Config.family.familyId (${family.familyId})`,\n\t\t\tactual: descriptor.familyId\n\t\t});\n\t\tif (target !== void 0 && path[0] !== \"target\" && descriptor.targetId !== target.targetId) problems.push({\n\t\t\tpath: [...path, \"targetId\"],\n\t\t\texpected: `Config.target.targetId (${target.targetId})`,\n\t\t\tactual: descriptor.targetId\n\t\t});\n\t}\n\treturn problems;\n}\n/**\n* The shape of the `orm` section of `prisma.config.ts`, declared once. The\n* CLI engine derives validation, the diagnostics naming a bad field and the\n* file to fix, and the resolution of every `path` field against the config\n* file that wrote it (prisma-cli ADR 0005). Relative paths are resolved\n* before any command sees the value, and the value carries `baseDir`.\n*/\nconst ormConfigSchema = ormSubsectionsSchema.narrow((config, ctx) => {\n\tif (\"extensionPacks\" in config) return ctx.reject({\n\t\tpath: [\"extensionPacks\"],\n\t\tmessage: \"Config.extensionPacks is no longer supported; rename it to Config.extensions\"\n\t});\n\tconst problems = descriptorRelationshipProblems(config, () => true);\n\tfor (const problem of problems) ctx.error({\n\t\tpath: [...problem.path],\n\t\texpected: problem.expected,\n\t\tactual: problem.actual\n\t});\n\treturn problems.length === 0;\n});\n/**\n* The section token the ORM's commands declare in `needs.config`. The\n* engine validates the merged section with its provenance and hands the\n* handler the value: absolute paths, `migrations.dir` defaulted, `baseDir`\n* recorded.\n*/\nconst ormConfigSection = blindCast(defineConfigSection({\n\tname: \"orm\",\n\tschema: ormConfigSchema\n}));\n/**\n* Validates a raw `orm` section the way the engine does for a command,\n* for the loaders and tools that read the config outside a command run.\n*/\nfunction validateOrmSection(raw, provenance) {\n\treturn blindCast(validateSectionWithSchema(\"orm\", ormConfigSchema, raw, provenance));\n}\n/**\n* Validates the shape of every subsection except `failing`, which comes back\n* as authored. A loader uses it when some subsections have diagnostics, so a\n* caller that reads only the others still gets their paths resolved and\n* defaults applied. The rules relating subsections are not applied here; see\n* {@link descriptorRelationshipProblems}.\n*/\nfunction validateOrmSectionExcept(raw, provenance, failing) {\n\tconst healthy = CONFIG_SECTIONS.filter((section) => !failing.has(section));\n\treturn validateSectionWithSchema(\"orm\", ormSubsectionsSchema.pick(...healthy), raw, provenance);\n}\n//#endregion\n//#region src/load.ts\nconst CONFIG_FILENAME = \"prisma.config.ts\";\nasync function findNearestConfigPathForFile(filePath) {\n\tlet current = dirname(resolve(process.cwd(), filePath));\n\twhile (true) {\n\t\tconst candidate = join(current, CONFIG_FILENAME);\n\t\tif (await fileExists(candidate)) return candidate;\n\t\tconst parent = dirname(current);\n\t\tif (parent === current) return;\n\t\tcurrent = parent;\n\t}\n}\nasync function fileExists(path) {\n\ttry {\n\t\tawait access(path);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n}\nfunction isRecord(value) {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\nfunction collectArtifactCollisionDiagnostics(contract) {\n\tconst inputs = contract.source.inputs;\n\tconst output = contract.output;\n\tif (inputs === void 0 || output === void 0) return [];\n\tlet emittedArtifactPaths;\n\ttry {\n\t\temittedArtifactPaths = getEmittedArtifactPaths(output);\n\t} catch (error) {\n\t\treturn [errorConfigValidation(\"contract.output\", {\n\t\t\t/* v8 ignore next -- getEmittedArtifactPaths only ever throws an Error */\n\t\t\twhy: error instanceof Error ? error.message : String(error),\n\t\t\tsection: \"contract\"\n\t\t})];\n\t}\n\tconst emittedPaths = /* @__PURE__ */ new Set([emittedArtifactPaths.jsonPath, emittedArtifactPaths.dtsPath]);\n\tif (inputs.some((input) => emittedPaths.has(input))) return [errorConfigValidation(\"contract.source.inputs[]\", {\n\t\twhy: \"Config.contract.source.inputs must not include emitted artifact paths derived from contract.output\",\n\t\tsection: \"contract\"\n\t})];\n\treturn [];\n}\nfunction validateLoadedSection(rawConfig, provenance) {\n\tconst validation = validateOrmSection(rawConfig, provenance);\n\tif (!validation.ok) {\n\t\tconst diagnostics = validation.diagnostics.map((diagnostic) => {\n\t\t\tconst field = typeof diagnostic.meta?.[\"field\"] === \"string\" ? diagnostic.meta[\"field\"] : \"\";\n\t\t\tconst section = field.split(\".\")[0] ?? \"\";\n\t\t\treturn errorConfigValidation(field, {\n\t\t\t\twhy: diagnostic.summary,\n\t\t\t\t...isConfigSection(section) ? { section } : {}\n\t\t\t});\n\t\t});\n\t\tconst failing = new Set(diagnostics.map((diagnostic) => String(diagnostic.meta?.[\"section\"] ?? \"\")));\n\t\tconst partial = validateOrmSectionExcept(rawConfig, provenance, failing);\n\t\tconst config = blindCast(partial.ok ? partial.value : rawConfig);\n\t\tif (!partial.ok) return {\n\t\t\tconfig,\n\t\t\tdiagnostics\n\t\t};\n\t\tconst related = descriptorRelationshipProblems(config, (section) => !failing.has(section)).map((problem) => errorConfigValidation(problem.path.join(\".\"), {\n\t\t\twhy: `${problem.path.join(\".\")} must be ${problem.expected} (was ${problem.actual})`,\n\t\t\tsection: String(problem.path[0])\n\t\t}));\n\t\tconst collisions = failing.has(\"contract\") || config.contract === void 0 ? [] : collectArtifactCollisionDiagnostics(config.contract);\n\t\treturn {\n\t\t\tconfig,\n\t\t\tdiagnostics: [\n\t\t\t\t...diagnostics,\n\t\t\t\t...related,\n\t\t\t\t...collisions\n\t\t\t]\n\t\t};\n\t}\n\tconst config = validation.value;\n\tif (config.contract === void 0) return {\n\t\tconfig,\n\t\tdiagnostics: []\n\t};\n\treturn {\n\t\tconfig,\n\t\tdiagnostics: collectArtifactCollisionDiagnostics(config.contract)\n\t};\n}\n/**\n* Validates a raw `orm` section and resolves its paths against `configDir`, the way a loaded config\n* file is. A caller that builds the section in memory gets the same diagnostics as one that wrote\n* it to `prisma.config.ts`.\n*/\nfunction buildLoadedConfig(rawConfig, configDir) {\n\tconst file = join(configDir, CONFIG_FILENAME);\n\treturn validateLoadedSection(rawConfig, {\n\t\tfiles: [file],\n\t\tkeys: Object.fromEntries(Object.keys(rawConfig).map((key) => [key, file]))\n\t});\n}\nfunction toConfigLoadFailure(error, configPath) {\n\tif (CliStructuredError.is(error)) return error;\n\tconst resolvedPath = configPath ? resolve(process.cwd(), configPath) : void 0;\n\tif (isStructuredError(error)) return new CliStructuredError(error.code, error.message, {\n\t\t...ifDefined(\"why\", error.why),\n\t\t...ifDefined(\"fix\", error.fix),\n\t\t...ifDefined(\"where\", error.where),\n\t\t...ifDefined(\"meta\", error.meta),\n\t\tcause: error\n\t});\n\tif (error instanceof Error) return errorConfigEvaluationFailed(resolvedPath, {\n\t\twhy: error.message,\n\t\tcause: error\n\t});\n\treturn errorConfigEvaluationFailed(resolvedPath, { why: String(error) });\n}\n/**\n* c12 is resolved to its real on-disk entry before importing: jiti (inside\n* c12) resolves its own transitive imports from the importing file's location,\n* and a symlinked install (pnpm) would otherwise anchor them somewhere the\n* packages are not. Importing at the real location keeps every transitive\n* resolution working.\n*/\nasync function importC12() {\n\treturn await import(pathToFileURL(realpathSync(createRequire(import.meta.url).resolve(\"c12\"))).href);\n}\n/**\n* Runs c12 against one config path. Every throw out of evaluation becomes a\n* `CONFIG.EVALUATION_FAILED` and a requested path c12 did not resolve to becomes\n* `CONFIG.FILE_NOT_FOUND`, so both loaders report the same failures for the\n* same file.\n*/\nasync function evaluateWithC12(configPath, cwd) {\n\tconst resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;\n\tconst configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;\n\tlet result;\n\ttry {\n\t\tresult = await (await importC12()).loadConfig({\n\t\t\tname: \"prisma\",\n\t\t\t...ifDefined(\"configFile\", resolvedConfigPath),\n\t\t\tcwd: configCwd\n\t\t});\n\t} catch (error) {\n\t\treturn notOk(toConfigLoadFailure(error, configPath));\n\t}\n\tif (resolvedConfigPath && result.configFile !== resolvedConfigPath) return notOk(errorConfigFileNotFound(resolvedConfigPath));\n\treturn ok(result);\n}\nconst FILE_FORMAT_KEYS = /* @__PURE__ */ new Set([\"$prismaConfig\", \"extends\"]);\nfunction sectionsOf(exported) {\n\treturn Object.fromEntries(Object.entries(exported).filter(([key]) => !FILE_FORMAT_KEYS.has(key)));\n}\n/**\n* Evaluates `prisma.config.ts` and hands back each file on the chain with its\n* sections as written, plus c12's merge. Failures that prevent evaluation are\n* the Result failure. Nothing is validated or resolved here: the CLI engine\n* validates each section against its schema with the files' provenance, and\n* {@link loadConfig} does the same for the `orm` section outside a command run.\n*/\nasync function loadConfigFiles(configPath, options) {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;\n\tconst configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;\n\tconst evaluated = await evaluateWithC12(configPath, cwd);\n\tif (!evaluated.ok) return evaluated;\n\tconst result = evaluated.value;\n\tif (!result.config || Object.keys(result.config).length === 0) return notOk(errorConfigFileNotFound(result.configFile || resolvedConfigPath || configPath));\n\t/* v8 ignore next -- c12 always returns layers for a config it evaluated */\n\tconst layers = result.layers ?? [];\n\tconst layerConfig = layers[0]?.config;\n\tconst engineMarker = isRecord(layerConfig) ? layerConfig[\"$prismaConfig\"] : void 0;\n\tif (engineMarker === void 0)\n /* v8 ignore next -- a config that evaluated always carries its resolved path */\n\treturn notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));\n\tif (engineMarker !== 1)\n /* v8 ignore next -- a config that evaluated always carries its resolved path */\n\treturn notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));\n\t/* v8 ignore next -- @preserve */\n\tconst requested = result.configFile ?? join(configCwd, CONFIG_FILENAME);\n\tconst files = layers.flatMap((layer, index) => isRecord(layer.config) && Object.keys(layer.config).length > 0 ? [{\n\t\tpath: index === 0 ? requested : resolve(configCwd, layer.configFile ?? requested),\n\t\tsections: sectionsOf(layer.config)\n\t}] : []);\n\treturn ok({\n\t\tfiles: files.length === 0 ? [{\n\t\t\tpath: requested,\n\t\t\tsections: sectionsOf(result.config)\n\t\t}] : files,\n\t\tmerged: result.config\n\t});\n}\n/**\n* The raw default export of the module at `configPath`, evaluated exactly as\n* {@link loadConfig} evaluates it and returned without validation or the\n* version-marker check. The caller decides what the export means — a\n* default export without the `$prismaConfig` marker is what an earlier Prisma\n* CLI's config looks like.\n*/\nasync function evaluateConfigModule(configPath, options) {\n\tconst cwd = options?.cwd ?? process.cwd();\n\tconst resolvedConfigPath = resolve(cwd, configPath);\n\tif (!await fileExists(resolvedConfigPath)) return notOk(errorConfigFileNotFound(resolvedConfigPath));\n\tconst evaluated = await evaluateWithC12(resolvedConfigPath, cwd);\n\tif (!evaluated.ok) return evaluated;\n\t/* v8 ignore next -- c12 always returns layers for a config it evaluated */\n\tconst [requestedLayer] = evaluated.value.layers ?? [];\n\treturn ok(requestedLayer?.config);\n}\n/** Which file wrote each top-level key of the `orm` section, nearest file first. */\nfunction ormProvenance(files, merged) {\n\tconst contributors = files.filter((file) => isRecord(file.sections[\"orm\"]));\n\tconst paths = contributors.map((file) => file.path);\n\treturn {\n\t\tfiles: paths,\n\t\tkeys: Object.fromEntries(Object.keys(merged).flatMap((key) => {\n\t\t\tconst file = contributors.find((contributor) => {\n\t\t\t\tconst orm = contributor.sections[\"orm\"];\n\t\t\t\treturn isRecord(orm) && Object.hasOwn(orm, key);\n\t\t\t})?.path ?? paths[0];\n\t\t\treturn file === void 0 ? [] : [[key, file]];\n\t\t}))\n\t};\n}\n/**\n* Loads the Prisma 8 config and validates its `orm` section.\n*\n* Failures that prevent evaluation entirely — missing file, module that does\n* not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the\n* `Result` failure. Structural problems inside an evaluated config do not\n* fail the load: they are returned as section-tagged diagnostics so commands\n* fail only on the sections they read (via {@link requireConfigSections}).\n*/\nasync function loadConfig(configPath, options) {\n\tconst loaded = await loadConfigFiles(configPath, options);\n\tif (!loaded.ok) return loaded;\n\tconst orm = loaded.value.merged[\"orm\"];\n\tif (orm !== void 0 && !isRecord(orm)) return ok({\n\t\tconfig: validateLoadedSection({}, {\n\t\t\tfiles: [],\n\t\t\tkeys: {}\n\t\t}).config,\n\t\tdiagnostics: [errorConfigValidation(\"orm\", { why: `The orm section of ${CONFIG_FILENAME} must be an object` })]\n\t});\n\tconst section = orm ?? {};\n\tconst provenance = ormProvenance(loaded.value.files, section);\n\tconst requested = loaded.value.files[0]?.path;\n\treturn ok(validateLoadedSection(section, provenance.files.length === 0 && requested !== void 0 ? {\n\t\tfiles: [requested],\n\t\tkeys: Object.fromEntries(Object.keys(section).map((key) => [key, requested]))\n\t} : provenance));\n}\n/**\n* Narrows a {@link LoadedConfig} to the sections a command reads. Fails with\n* the first diagnostic concerning a required section; diagnostics on other\n* sections are ignored so unrelated commands keep working.\n*/\nfunction requireConfigSections(loaded, sections) {\n\tconst blocking = loaded.diagnostics.find((diagnostic) => {\n\t\tconst section = diagnostic.meta?.[\"section\"];\n\t\treturn typeof section !== \"string\" || sections.some((required) => required === section);\n\t});\n\treturn blocking ? notOk(blocking) : ok(loaded.config);\n}\n/**\n* Convenience composition of {@link loadConfig} and\n* {@link requireConfigSections} for commands that read a fixed set of\n* sections and have no use for diagnostics outside them.\n*/\nasync function loadConfigForSections(configPath, sections) {\n\tconst loaded = await loadConfig(configPath);\n\tif (!loaded.ok) return loaded;\n\treturn requireConfigSections(loaded.value, sections);\n}\nasync function loadConfigForFile(filePath) {\n\tconst configPath = await findNearestConfigPathForFile(filePath);\n\tif (configPath === void 0) return notOk(errorConfigFileNotFound(join(dirname(resolve(process.cwd(), filePath)), CONFIG_FILENAME)));\n\treturn loadConfig(configPath);\n}\n//#endregion\nexport { ORM_CONFIG_SECTION_NAME, buildLoadedConfig, evaluateConfigModule, expandContractInputs, findNearestConfigPathForFile, isConfigSection, loadConfig, loadConfigFiles, loadConfigForFile, loadConfigForSections, ormConfigSchema, ormConfigSection, requireConfigSections, validateOrmSection };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BA,eAAe,qBAAqB,UAAU;CAC7C,IAAI,aAAa,KAAK,KAAK,SAAS,WAAW,GAAG,OAAO,CAAC;CAC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W,OAAO,YAAY,MAAM,eAAe;EACxD,MAAM,UAAU,WAAW,OAAO;EAClC,OAAO,OAAO,YAAY,YAAY,SAAS,MAAM,aAAa,aAAa,OAAO;CACvF,CAAC;CACD,OAAO,WAAW,MAAM,QAAQ,IAAI,GAAG,OAAO,MAAM;AACrD;;;;;;AAMA,eAAe,sBAAsB,YAAY,UAAU;CAC1D,MAAM,SAAS,MAAM,WAAW,UAAU;CAC1C,IAAI,CAAC,OAAO,IAAI,OAAO;CACvB,OAAO,sBAAsB,OAAO,OAAO,QAAQ;AACpD;AACA,eAAe,kBAAkB,UAAU;CAC1C,MAAM,aAAa,MAAM,6BAA6B,QAAQ;CAC9D,IAAI,eAAe,KAAK,GAAG,OAAO,MAAM,wBAAwB,KAAK,QAAQ,QAAQ,QAAQ,IAAI,GAAG,QAAQ,CAAC,GAAG,eAAe,CAAC,CAAC;CACjI,OAAO,WAAW,UAAU;AAC7B"}
@@ -1,4 +1,4 @@
1
- import { a as findNearestConfigPathForFile, l as requireConfigSections, o as loadConfig } from "./exports-8-S4PGn0.mjs";
1
+ import { c as loadConfig, m as requireConfigSections, o as findNearestConfigPathForFile } from "./exports-BOv2LgXz.mjs";
2
2
  import { join } from "pathe";
3
3
  import { fileURLToPath, pathToFileURL } from "node:url";
4
4
  import { blindCast } from "@prisma/orm-framework/utils/casts";
@@ -2793,4 +2793,4 @@ function startServer(streams) {
2793
2793
  //#endregion
2794
2794
  export { startServer };
2795
2795
 
2796
- //# sourceMappingURL=exports-DVWNaJUr.mjs.map
2796
+ //# sourceMappingURL=exports-DpFO5X4j.mjs.map