@prisma/orm-toolchain 8.0.0-rc.11-dev.50 → 8.0.0-rc.11-dev.52
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 +1475 -268
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +17 -2
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +2 -2
- package/dist/cli__init-output.d.mts +11 -1
- package/dist/cli__init-output.d.mts.map +1 -1
- package/dist/cli__init-output.mjs +1 -1
- package/dist/cli__migration-cli.mjs +1 -1
- package/dist/config-loader.d.mts +2 -2
- package/dist/config-loader.mjs +2 -2
- package/dist/{exports-uepvbfMs.mjs → exports-BiGALu6k.mjs} +2 -2
- package/dist/{exports-uepvbfMs.mjs.map → exports-BiGALu6k.mjs.map} +1 -1
- package/dist/{exports-DJ4RhlW4.mjs → exports-ClG6amXs.mjs} +49 -13
- package/dist/exports-ClG6amXs.mjs.map +1 -0
- package/dist/{index-u5RdrumF.d.mts → index-CjMp0WzN.d.mts} +27 -2
- package/dist/index-CjMp0WzN.d.mts.map +1 -0
- package/dist/output-BcC8eB0h-C5bRd-aC.mjs +129 -0
- package/dist/output-BcC8eB0h-C5bRd-aC.mjs.map +1 -0
- package/dist/quick-reference-prisma7.md +80 -0
- package/dist/{ref-g7LrevBG-DgO9ywms.mjs → ref-DL4C2p9T-BVsb1HWR.mjs} +82 -34
- package/dist/{ref-g7LrevBG-DgO9ywms.mjs.map → ref-DL4C2p9T-BVsb1HWR.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +2 -2
- package/package.json +12 -12
- package/dist/exports-DJ4RhlW4.mjs.map +0 -1
- package/dist/index-u5RdrumF.d.mts.map +0 -1
- package/dist/output-D83nTTpC-XlvN30yS.mjs +0 -77
- package/dist/output-D83nTTpC-XlvN30yS.mjs.map +0 -1
|
@@ -92,6 +92,11 @@ function collectArtifactCollisionDiagnostics(contract) {
|
|
|
92
92
|
})];
|
|
93
93
|
return [];
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Validates a raw `orm` section and resolves its paths against `configDir`, the way a loaded config
|
|
97
|
+
* file is. A caller that builds the section in memory gets the same diagnostics as one that wrote
|
|
98
|
+
* it to `prisma.config.ts`.
|
|
99
|
+
*/
|
|
95
100
|
function buildLoadedConfig(rawConfig, configDir) {
|
|
96
101
|
const issues = collectConfigIssues(rawConfig);
|
|
97
102
|
const diagnostics = issues.map((issue) => errorConfigValidation(issue.field, {
|
|
@@ -134,15 +139,6 @@ function toConfigLoadFailure(error, configPath) {
|
|
|
134
139
|
return errorConfigEvaluationFailed(resolvedPath, { why: String(error) });
|
|
135
140
|
}
|
|
136
141
|
/**
|
|
137
|
-
* Loads and finalizes the Prisma 8 config.
|
|
138
|
-
*
|
|
139
|
-
* Failures that prevent evaluation entirely — missing file, module that does
|
|
140
|
-
* not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the
|
|
141
|
-
* `Result` failure. Structural problems inside an evaluated config do not
|
|
142
|
-
* fail the load: they are returned as section-tagged diagnostics so commands
|
|
143
|
-
* fail only on the sections they read (via {@link requireConfigSections}).
|
|
144
|
-
*/
|
|
145
|
-
/**
|
|
146
142
|
* c12 is resolved to its real on-disk entry before importing: jiti (inside
|
|
147
143
|
* c12) resolves its own transitive imports from the importing file's location,
|
|
148
144
|
* and a symlinked install (pnpm) would otherwise anchor them somewhere the
|
|
@@ -152,8 +148,13 @@ function toConfigLoadFailure(error, configPath) {
|
|
|
152
148
|
async function importC12() {
|
|
153
149
|
return await import(pathToFileURL(realpathSync(createRequire(import.meta.url).resolve("c12"))).href);
|
|
154
150
|
}
|
|
155
|
-
|
|
156
|
-
|
|
151
|
+
/**
|
|
152
|
+
* Runs c12 against one config path. Every throw out of evaluation becomes a
|
|
153
|
+
* `CONFIG.EVALUATION_FAILED` and a requested path c12 did not resolve to becomes
|
|
154
|
+
* `CONFIG.FILE_NOT_FOUND`, so both loaders report the same failures for the
|
|
155
|
+
* same file.
|
|
156
|
+
*/
|
|
157
|
+
async function evaluateWithC12(configPath, cwd) {
|
|
157
158
|
const resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;
|
|
158
159
|
const configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;
|
|
159
160
|
let result;
|
|
@@ -167,6 +168,41 @@ async function loadConfig(configPath, options) {
|
|
|
167
168
|
return notOk(toConfigLoadFailure(error, configPath));
|
|
168
169
|
}
|
|
169
170
|
if (resolvedConfigPath && result.configFile !== resolvedConfigPath) return notOk(errorConfigFileNotFound(resolvedConfigPath));
|
|
171
|
+
return ok(result);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* The raw default export of the module at `configPath`, evaluated exactly as
|
|
175
|
+
* {@link loadConfig} evaluates it and returned without validation, finalization,
|
|
176
|
+
* or the version-marker check. The caller decides what the export means — a
|
|
177
|
+
* default export without the `$prismaConfig` marker is what an earlier Prisma
|
|
178
|
+
* CLI's config looks like.
|
|
179
|
+
*/
|
|
180
|
+
async function evaluateConfigModule(configPath, options) {
|
|
181
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
182
|
+
const resolvedConfigPath = resolve(cwd, configPath);
|
|
183
|
+
if (!await fileExists(resolvedConfigPath)) return notOk(errorConfigFileNotFound(resolvedConfigPath));
|
|
184
|
+
const evaluated = await evaluateWithC12(resolvedConfigPath, cwd);
|
|
185
|
+
if (!evaluated.ok) return evaluated;
|
|
186
|
+
/* v8 ignore next -- c12 always returns layers for a config it evaluated */
|
|
187
|
+
const [requestedLayer] = evaluated.value.layers ?? [];
|
|
188
|
+
return ok(requestedLayer?.config);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Loads and finalizes the Prisma 8 config.
|
|
192
|
+
*
|
|
193
|
+
* Failures that prevent evaluation entirely — missing file, module that does
|
|
194
|
+
* not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the
|
|
195
|
+
* `Result` failure. Structural problems inside an evaluated config do not
|
|
196
|
+
* fail the load: they are returned as section-tagged diagnostics so commands
|
|
197
|
+
* fail only on the sections they read (via {@link requireConfigSections}).
|
|
198
|
+
*/
|
|
199
|
+
async function loadConfig(configPath, options) {
|
|
200
|
+
const cwd = options?.cwd ?? process.cwd();
|
|
201
|
+
const resolvedConfigPath = configPath ? resolve(cwd, configPath) : void 0;
|
|
202
|
+
const configCwd = resolvedConfigPath ? dirname(resolvedConfigPath) : cwd;
|
|
203
|
+
const evaluated = await evaluateWithC12(configPath, cwd);
|
|
204
|
+
if (!evaluated.ok) return evaluated;
|
|
205
|
+
const result = evaluated.value;
|
|
170
206
|
if (!result.config || Object.keys(result.config).length === 0) return notOk(errorConfigFileNotFound(result.configFile || resolvedConfigPath || configPath));
|
|
171
207
|
/* v8 ignore next -- @preserve */
|
|
172
208
|
const loadedConfigDir = result.configFile ? dirname(result.configFile) : configCwd;
|
|
@@ -216,6 +252,6 @@ async function loadConfigForFile(filePath) {
|
|
|
216
252
|
return loadConfig(configPath);
|
|
217
253
|
}
|
|
218
254
|
//#endregion
|
|
219
|
-
export {
|
|
255
|
+
export { loadConfig as a, requireConfigSections as c, findNearestConfigPathForFile as i, evaluateConfigModule as n, loadConfigForFile as o, finalizeConfig as r, loadConfigForSections as s, buildLoadedConfig as t };
|
|
220
256
|
|
|
221
|
-
//# sourceMappingURL=exports-
|
|
257
|
+
//# sourceMappingURL=exports-ClG6amXs.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exports-ClG6amXs.mjs","names":[],"sources":["../../../../1-framework/3-tooling/config-loader/dist/exports/index.mjs"],"sourcesContent":["import { createRequire } from \"node:module\";\nimport { normalizeContractConfig } from \"@internal/config/config-types\";\nimport { dirname, join, resolve } from \"pathe\";\nimport { realpathSync } from \"node:fs\";\nimport { access } from \"node:fs/promises\";\nimport { pathToFileURL } from \"node:url\";\nimport { collectConfigIssues } from \"@internal/config/config-validation\";\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\";\n//#region src/finalize-config.ts\nfunction finalizeContractSource(source, configDir) {\n\tconst resolvedInputs = source.inputs?.map((input) => resolve(configDir, input));\n\tif (resolvedInputs === void 0) return source;\n\treturn {\n\t\t...source,\n\t\tinputs: resolvedInputs\n\t};\n}\n/** Normalizes a contract section and resolves its paths against `configDir`. */\nfunction finalizeContractConfig(contract, configDir) {\n\tconst normalized = normalizeContractConfig(contract);\n\treturn {\n\t\t...normalized,\n\t\tsource: finalizeContractSource(normalized.source, configDir),\n\t\toutput: resolve(configDir, normalized.output)\n\t};\n}\nconst DEFAULT_MIGRATIONS_DIR = \"migrations\";\n/**\n* Resolves the migrations directory against `configDir`, which is what `migrations.dir` is\n* documented to be relative to. The default is applied here too, so no caller re-derives it\n* against a different base — a command run from one directory with `--config` naming a project in\n* another would otherwise read the wrong `migrations/`.\n*/\nfunction finalizeMigrationsConfig(migrations, configDir) {\n\treturn {\n\t\t...migrations,\n\t\tdir: resolve(configDir, migrations?.dir ?? DEFAULT_MIGRATIONS_DIR)\n\t};\n}\nfunction finalizeConfig(config, configDir) {\n\treturn {\n\t\t...config,\n\t\t...config.contract ? { contract: finalizeContractConfig(config.contract, configDir) } : void 0,\n\t\tmigrations: finalizeMigrationsConfig(config.migrations, configDir)\n\t};\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}\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 issues = collectConfigIssues(rawConfig);\n\tconst diagnostics = issues.map((issue) => errorConfigValidation(issue.field, {\n\t\twhy: issue.message,\n\t\tsection: issue.section\n\t}));\n\tconst raw = blindCast(rawConfig);\n\tconst config = issues.some((issue) => issue.section === \"migrations\") ? raw : {\n\t\t...raw,\n\t\tmigrations: finalizeMigrationsConfig(raw.migrations, configDir)\n\t};\n\tif (config.contract === void 0 || issues.some((issue) => issue.section === \"contract\")) return {\n\t\tconfig,\n\t\tdiagnostics\n\t};\n\tconst contract = finalizeContractConfig(config.contract, configDir);\n\tdiagnostics.push(...collectArtifactCollisionDiagnostics(contract));\n\treturn {\n\t\tconfig: {\n\t\t\t...config,\n\t\t\tcontract\n\t\t},\n\t\tdiagnostics\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}\n/**\n* The raw default export of the module at `configPath`, evaluated exactly as\n* {@link loadConfig} evaluates it and returned without validation, finalization,\n* or the 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/**\n* Loads and finalizes the Prisma 8 config.\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 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 -- @preserve */\n\tconst loadedConfigDir = result.configFile ? dirname(result.configFile) : configCwd;\n\t/* v8 ignore next -- c12 always returns layers for a config it evaluated */\n\tconst [requestedLayer] = result.layers ?? [];\n\tconst layerConfig = requestedLayer?.config;\n\tconst engineMarker = isRecord(layerConfig) ? layerConfig[\"$prismaConfig\"] : void 0;\n\tif (engineMarker !== void 0) {\n\t\tif (engineMarker !== 1)\n /* v8 ignore next -- a config that evaluated always carries its resolved path */\n\t\treturn notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));\n\t\tconst orm = result.config[\"orm\"];\n\t\tif (orm !== void 0 && !isRecord(orm)) return ok({\n\t\t\tconfig: buildLoadedConfig({}, loadedConfigDir).config,\n\t\t\tdiagnostics: [errorConfigValidation(\"orm\", { why: `The orm section of ${CONFIG_FILENAME} must be an object` })]\n\t\t});\n\t\treturn ok(buildLoadedConfig(orm ?? {}, loadedConfigDir));\n\t}\n\t/* v8 ignore next -- a config that evaluated always carries its resolved path */\n\treturn notOk(errorConfigVersionMarkerMissing(result.configFile ?? resolvedConfigPath));\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 { buildLoadedConfig, evaluateConfigModule, finalizeConfig, findNearestConfigPathForFile,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AAO,GAAG,kBAAkB,OAAO,CAAC,GAAG,eAAe,CAAC;CACxD;;CAEA,OAAO,MAAM,gCAAgC,OAAO,cAAc,kBAAkB,CAAC;AACtF;;;;;;AAMA,SAAS,sBAAsB,QAAQ,UAAU;CAChD,MAAM,WAAW,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"}
|
|
@@ -19,6 +19,31 @@ interface LoadedConfig {
|
|
|
19
19
|
readonly diagnostics: readonly CliStructuredError[];
|
|
20
20
|
}
|
|
21
21
|
declare function findNearestConfigPathForFile(filePath: string): Promise<string | undefined>;
|
|
22
|
+
/**
|
|
23
|
+
* Validates a raw `orm` section and resolves its paths against `configDir`, the way a loaded config
|
|
24
|
+
* file is. A caller that builds the section in memory gets the same diagnostics as one that wrote
|
|
25
|
+
* it to `prisma.config.ts`.
|
|
26
|
+
*/
|
|
27
|
+
declare function buildLoadedConfig(rawConfig: Record<string, unknown>, configDir: string): LoadedConfig;
|
|
28
|
+
/**
|
|
29
|
+
* The raw default export of the module at `configPath`, evaluated exactly as
|
|
30
|
+
* {@link loadConfig} evaluates it and returned without validation, finalization,
|
|
31
|
+
* or the version-marker check. The caller decides what the export means — a
|
|
32
|
+
* default export without the `$prismaConfig` marker is what an earlier Prisma
|
|
33
|
+
* CLI's config looks like.
|
|
34
|
+
*/
|
|
35
|
+
declare function evaluateConfigModule(configPath: string, options?: {
|
|
36
|
+
readonly cwd?: string;
|
|
37
|
+
}): Promise<Result<unknown, CliStructuredError>>;
|
|
38
|
+
/**
|
|
39
|
+
* Loads and finalizes the Prisma 8 config.
|
|
40
|
+
*
|
|
41
|
+
* Failures that prevent evaluation entirely — missing file, module that does
|
|
42
|
+
* not evaluate (`CONFIG.FILE_NOT_FOUND`, `CONFIG.EVALUATION_FAILED`) — are the
|
|
43
|
+
* `Result` failure. Structural problems inside an evaluated config do not
|
|
44
|
+
* fail the load: they are returned as section-tagged diagnostics so commands
|
|
45
|
+
* fail only on the sections they read (via {@link requireConfigSections}).
|
|
46
|
+
*/
|
|
22
47
|
declare function loadConfig(configPath?: string, options?: {
|
|
23
48
|
readonly cwd?: string;
|
|
24
49
|
}): Promise<Result<LoadedConfig, CliStructuredError>>;
|
|
@@ -36,5 +61,5 @@ declare function requireConfigSections(loaded: LoadedConfig, sections: readonly
|
|
|
36
61
|
declare function loadConfigForSections(configPath: string | undefined, sections: readonly ConfigSection[]): Promise<Result<PrismaNextConfig, CliStructuredError>>;
|
|
37
62
|
declare function loadConfigForFile(filePath: string): Promise<Result<LoadedConfig, CliStructuredError>>;
|
|
38
63
|
//#endregion
|
|
39
|
-
export {
|
|
40
|
-
//# sourceMappingURL=index-
|
|
64
|
+
export { evaluateConfigModule as a, loadConfig as c, requireConfigSections as d, buildLoadedConfig as i, loadConfigForFile as l, LoadedConfig as n, finalizeConfig as o, PrismaNextConfig$1 as r, findNearestConfigPathForFile as s, ConfigSection as t, loadConfigForSections as u };
|
|
65
|
+
//# sourceMappingURL=index-CjMp0WzN.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-CjMp0WzN.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/config-loader/dist/exports/index.d.mts"],"mappings":";;;;;;iBAKiB,eAAe,QAAQ,kBAAoB,oBAAoB;;;;;;;;;;UAUtE;WACC,QAAQ;WACR,sBAAsB;;iBAEhB,6BAA6B,mBAAmB;;;;;;iBAMhD,kBAAkB,WAAW,yBAAyB,oBAAoB;;;;;;;;iBAQ1E,qBAAqB,oBAAoB;WAC/C;IACP,QAAQ,gBAAgB;;;;;;;;;;iBAUX,WAAW,qBAAqB;WACtC;IACP,QAAQ,OAAO,cAAc;;;;;;iBAMhB,sBAAsB,QAAQ,cAAc,mBAAmB,kBAAkB,OAAO,kBAAoB;;;;;;iBAM5G,sBAAsB,gCAAgC,mBAAmB,kBAAkB,QAAQ,OAAO,kBAAoB;iBAC9H,kBAAkB,mBAAmB,QAAQ,OAAO,cAAc"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { type } from "arktype";
|
|
2
|
+
//#region ../../../1-framework/3-tooling/cli/dist/output-BcC8eB0h.mjs
|
|
3
|
+
/**
|
|
4
|
+
* arktype schema for the structured success document `init --json` writes
|
|
5
|
+
* to stdout (FR1.5). The same shape backs the human-readable outro
|
|
6
|
+
* renderer (FR10), so the two output modes carry identical information.
|
|
7
|
+
*
|
|
8
|
+
* `target` is normalised to the user-facing flag value (`mongodb` rather
|
|
9
|
+
* than the internal `mongo`) so consumers can round-trip the document
|
|
10
|
+
* straight into a follow-up `--target` invocation.
|
|
11
|
+
*
|
|
12
|
+
* The `ok: true` literal is the documented success/error discriminator —
|
|
13
|
+
* see [Style Guide § JSON Semantics](../../../../../../../docs/CLI%20Style%20Guide.md#json-semantics).
|
|
14
|
+
* Error envelopes (`CliErrorEnvelope`) carry `ok: false` so consumers can
|
|
15
|
+
* branch with `if (doc.ok)` without inspecting the rest of the structure.
|
|
16
|
+
*/
|
|
17
|
+
const InitOutputSchema = type({
|
|
18
|
+
ok: "true",
|
|
19
|
+
target: "'postgres'|'mongodb'",
|
|
20
|
+
/** `prisma7` when an existing Prisma 7 schema is the contract source. */
|
|
21
|
+
authoring: "'psl'|'typescript'|'prisma7'",
|
|
22
|
+
/** The starter schema init wrote, or the Prisma 7 schema it points the config at. */
|
|
23
|
+
schemaPath: "string",
|
|
24
|
+
filesWritten: "string[]",
|
|
25
|
+
/**
|
|
26
|
+
* FR9.1 — paths removed from disk during this run: contract artifacts
|
|
27
|
+
* (`contract.json`, `contract.d.ts`, `ops.json`, `migration.json`) an
|
|
28
|
+
* earlier run left behind, which only a re-init has, and the retired
|
|
29
|
+
* agent-skill directories, which every run removes when it finds them.
|
|
30
|
+
*/
|
|
31
|
+
filesDeleted: "string[]",
|
|
32
|
+
/** The Prisma 7 config moved out of Prisma 8's way; empty on a normal run. */
|
|
33
|
+
filesRenamed: type({
|
|
34
|
+
from: "string",
|
|
35
|
+
to: "string"
|
|
36
|
+
}).array(),
|
|
37
|
+
/**
|
|
38
|
+
* What became of the dependency install. `skipped` is the deliberate
|
|
39
|
+
* `--skip-install`; `failed` is an install that ran and did not succeed,
|
|
40
|
+
* which leaves a scaffolded project that cannot run yet. `deps` and
|
|
41
|
+
* `devDeps` list what was installed, so both non-`installed` states
|
|
42
|
+
* carry them empty.
|
|
43
|
+
*/
|
|
44
|
+
packagesInstalled: {
|
|
45
|
+
status: "'installed'|'skipped'|'failed'",
|
|
46
|
+
deps: "string[]",
|
|
47
|
+
devDeps: "string[]"
|
|
48
|
+
},
|
|
49
|
+
contractEmitted: "boolean",
|
|
50
|
+
/**
|
|
51
|
+
* What the Prisma 7 path did beyond a normal run: the schema adopted, the
|
|
52
|
+
* config renamed (or `null` when it was already `prisma7.config.*`), the
|
|
53
|
+
* `package.json` scripts now invoking `prisma7`, and the Prisma 7 package
|
|
54
|
+
* specs installed or listed to install. `null` on a normal run.
|
|
55
|
+
*/
|
|
56
|
+
prisma7: type({
|
|
57
|
+
schemaPath: "string",
|
|
58
|
+
configRenamedTo: "string | null",
|
|
59
|
+
scriptsRewritten: "string[]",
|
|
60
|
+
packagesMoved: "string[]"
|
|
61
|
+
}).or("null"),
|
|
62
|
+
nextSteps: "string[]",
|
|
63
|
+
warnings: "string[]"
|
|
64
|
+
});
|
|
65
|
+
/**
|
|
66
|
+
* Builds the `nextSteps` array from the resolved scaffold state. Steps are
|
|
67
|
+
* ordered by the workflow a user needs to follow: install what is missing →
|
|
68
|
+
* configure connection → (emit if not yet done) → run a starter query →
|
|
69
|
+
* docs / agent skill.
|
|
70
|
+
*
|
|
71
|
+
* The strings are stable and human-readable; agents wanting to act on them
|
|
72
|
+
* should match on substrings (e.g. "DATABASE_URL") rather than exact text,
|
|
73
|
+
* since copy may evolve.
|
|
74
|
+
*/
|
|
75
|
+
function buildNextSteps(options) {
|
|
76
|
+
const steps = [];
|
|
77
|
+
let stepNumber = 1;
|
|
78
|
+
const push = (text) => {
|
|
79
|
+
steps.push(`${stepNumber}. ${text}`);
|
|
80
|
+
stepNumber += 1;
|
|
81
|
+
};
|
|
82
|
+
if (options.prisma7 !== null) {
|
|
83
|
+
pushPrisma7Steps(push, {
|
|
84
|
+
...options,
|
|
85
|
+
prisma7: options.prisma7
|
|
86
|
+
});
|
|
87
|
+
return steps;
|
|
88
|
+
}
|
|
89
|
+
if (options.packagesInstalled === "failed") push("Install the project dependencies with your package manager — the install this run attempted failed, so nothing else here will work yet.");
|
|
90
|
+
if (options.packagesInstalled === "skipped") push("Install the project dependencies with your package manager (this run skipped them).");
|
|
91
|
+
push("Set DATABASE_URL in your environment (export it or add it to .env).");
|
|
92
|
+
if (!options.contractEmitted) {
|
|
93
|
+
push(`Emit the contract: \`${options.emitCommand}\``);
|
|
94
|
+
push(`Edit your schema at ${options.schemaPath}, then re-run the emit command.`);
|
|
95
|
+
} else push(`Edit your schema at ${options.schemaPath}, then re-run \`${options.emitCommand}\`.`);
|
|
96
|
+
push("Open prisma-8.md for a quick reference on how to write your first typed query.");
|
|
97
|
+
push("Working with a coding agent? Run `prisma init` in this project to set up the Prisma agent skills.");
|
|
98
|
+
return steps;
|
|
99
|
+
}
|
|
100
|
+
/** The install that precedes the Prisma 7 check failed, so nothing was written. */
|
|
101
|
+
const NEXT_STEPS_BEFORE_SCAFFOLD = ["1. Install the project dependencies with your package manager. The install this run attempted failed before anything was written.", "2. Run `prisma orm init` again."];
|
|
102
|
+
const DB_SIGN_STEP = "Adopt your existing database: `prisma db sign` verifies it against the contract and records the signing marker and the `db` ref. It makes no change to the database schema.";
|
|
103
|
+
const PRISMA7_ROUTES_STEP = "Move your routes one at a time to the Prisma 8 client in src/prisma/db.ts.";
|
|
104
|
+
const PRISMA7_LOOP_STEP = "After each `prisma7 migrate dev`, run `prisma contract emit` and then `prisma db sign`.";
|
|
105
|
+
const PRISMA7_GENERATE_STEP = "Run `prisma7 generate` so the Prisma 7 client matches the Prisma 7 CLI.";
|
|
106
|
+
const PRISMA7_QUICK_REFERENCE_STEP = "Open prisma-8.md for a quick reference on the transition loop and your first typed query.";
|
|
107
|
+
const AGENT_SKILLS_STEP = "Working with a coding agent? Run `prisma init` in this project to set up the Prisma agent skills.";
|
|
108
|
+
/**
|
|
109
|
+
* The transition routine, project requirement 7: init set Prisma 8 up beside
|
|
110
|
+
* Prisma 7 and stopped, so every database action here is one the user runs.
|
|
111
|
+
*/
|
|
112
|
+
function pushPrisma7Steps(push, options) {
|
|
113
|
+
const moved = options.prisma7.packagesMoved;
|
|
114
|
+
const including = moved.length === 0 ? "" : ` That includes ${moved.join(", ")}.`;
|
|
115
|
+
push("Set DATABASE_URL in your environment (export it or add it to .env).");
|
|
116
|
+
if (options.packagesInstalled === "failed") push(`Install the project dependencies with your package manager — the install this run attempted failed, so nothing else here will work yet.${including}`);
|
|
117
|
+
if (options.packagesInstalled === "skipped") push(`Install the project dependencies with your package manager (this run skipped them)${moved.length === 0 ? "" : `, including ${moved.join(", ")}`}.`);
|
|
118
|
+
if (!options.contractEmitted) push(`Emit the contract: \`${options.emitCommand}\``);
|
|
119
|
+
push(DB_SIGN_STEP);
|
|
120
|
+
push(PRISMA7_ROUTES_STEP);
|
|
121
|
+
push(PRISMA7_LOOP_STEP);
|
|
122
|
+
if (options.prisma7.clientMoved) push(PRISMA7_GENERATE_STEP);
|
|
123
|
+
push(PRISMA7_QUICK_REFERENCE_STEP);
|
|
124
|
+
push(AGENT_SKILLS_STEP);
|
|
125
|
+
}
|
|
126
|
+
//#endregion
|
|
127
|
+
export { PRISMA7_QUICK_REFERENCE_STEP as a, PRISMA7_LOOP_STEP as i, InitOutputSchema as n, buildNextSteps as o, NEXT_STEPS_BEFORE_SCAFFOLD as r, DB_SIGN_STEP as t };
|
|
128
|
+
|
|
129
|
+
//# sourceMappingURL=output-BcC8eB0h-C5bRd-aC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output-BcC8eB0h-C5bRd-aC.mjs","names":[],"sources":["../../../../1-framework/3-tooling/cli/dist/output-BcC8eB0h.mjs"],"sourcesContent":["import { type } from \"arktype\";\n//#region src/commands/init/output.ts\n/**\n* arktype schema for the structured success document `init --json` writes\n* to stdout (FR1.5). The same shape backs the human-readable outro\n* renderer (FR10), so the two output modes carry identical information.\n*\n* `target` is normalised to the user-facing flag value (`mongodb` rather\n* than the internal `mongo`) so consumers can round-trip the document\n* straight into a follow-up `--target` invocation.\n*\n* The `ok: true` literal is the documented success/error discriminator —\n* see [Style Guide § JSON Semantics](../../../../../../../docs/CLI%20Style%20Guide.md#json-semantics).\n* Error envelopes (`CliErrorEnvelope`) carry `ok: false` so consumers can\n* branch with `if (doc.ok)` without inspecting the rest of the structure.\n*/\nconst InitOutputSchema = type({\n\tok: \"true\",\n\ttarget: \"'postgres'|'mongodb'\",\n\t/** `prisma7` when an existing Prisma 7 schema is the contract source. */\n\tauthoring: \"'psl'|'typescript'|'prisma7'\",\n\t/** The starter schema init wrote, or the Prisma 7 schema it points the config at. */\n\tschemaPath: \"string\",\n\tfilesWritten: \"string[]\",\n\t/**\n\t* FR9.1 — paths removed from disk during this run: contract artifacts\n\t* (`contract.json`, `contract.d.ts`, `ops.json`, `migration.json`) an\n\t* earlier run left behind, which only a re-init has, and the retired\n\t* agent-skill directories, which every run removes when it finds them.\n\t*/\n\tfilesDeleted: \"string[]\",\n\t/** The Prisma 7 config moved out of Prisma 8's way; empty on a normal run. */\n\tfilesRenamed: type({\n\t\tfrom: \"string\",\n\t\tto: \"string\"\n\t}).array(),\n\t/**\n\t* What became of the dependency install. `skipped` is the deliberate\n\t* `--skip-install`; `failed` is an install that ran and did not succeed,\n\t* which leaves a scaffolded project that cannot run yet. `deps` and\n\t* `devDeps` list what was installed, so both non-`installed` states\n\t* carry them empty.\n\t*/\n\tpackagesInstalled: {\n\t\tstatus: \"'installed'|'skipped'|'failed'\",\n\t\tdeps: \"string[]\",\n\t\tdevDeps: \"string[]\"\n\t},\n\tcontractEmitted: \"boolean\",\n\t/**\n\t* What the Prisma 7 path did beyond a normal run: the schema adopted, the\n\t* config renamed (or `null` when it was already `prisma7.config.*`), the\n\t* `package.json` scripts now invoking `prisma7`, and the Prisma 7 package\n\t* specs installed or listed to install. `null` on a normal run.\n\t*/\n\tprisma7: type({\n\t\tschemaPath: \"string\",\n\t\tconfigRenamedTo: \"string | null\",\n\t\tscriptsRewritten: \"string[]\",\n\t\tpackagesMoved: \"string[]\"\n\t}).or(\"null\"),\n\tnextSteps: \"string[]\",\n\twarnings: \"string[]\"\n});\n/**\n* Builds the `nextSteps` array from the resolved scaffold state. Steps are\n* ordered by the workflow a user needs to follow: install what is missing →\n* configure connection → (emit if not yet done) → run a starter query →\n* docs / agent skill.\n*\n* The strings are stable and human-readable; agents wanting to act on them\n* should match on substrings (e.g. \"DATABASE_URL\") rather than exact text,\n* since copy may evolve.\n*/\nfunction buildNextSteps(options) {\n\tconst steps = [];\n\tlet stepNumber = 1;\n\tconst push = (text) => {\n\t\tsteps.push(`${stepNumber}. ${text}`);\n\t\tstepNumber += 1;\n\t};\n\tif (options.prisma7 !== null) {\n\t\tpushPrisma7Steps(push, {\n\t\t\t...options,\n\t\t\tprisma7: options.prisma7\n\t\t});\n\t\treturn steps;\n\t}\n\tif (options.packagesInstalled === \"failed\") push(\"Install the project dependencies with your package manager — the install this run attempted failed, so nothing else here will work yet.\");\n\tif (options.packagesInstalled === \"skipped\") push(\"Install the project dependencies with your package manager (this run skipped them).\");\n\tpush(\"Set DATABASE_URL in your environment (export it or add it to .env).\");\n\tif (!options.contractEmitted) {\n\t\tpush(`Emit the contract: \\`${options.emitCommand}\\``);\n\t\tpush(`Edit your schema at ${options.schemaPath}, then re-run the emit command.`);\n\t} else push(`Edit your schema at ${options.schemaPath}, then re-run \\`${options.emitCommand}\\`.`);\n\tpush(\"Open prisma-8.md for a quick reference on how to write your first typed query.\");\n\tpush(\"Working with a coding agent? Run `prisma init` in this project to set up the Prisma agent skills.\");\n\treturn steps;\n}\n/** The install that precedes the Prisma 7 check failed, so nothing was written. */\nconst NEXT_STEPS_BEFORE_SCAFFOLD = [\"1. Install the project dependencies with your package manager. The install this run attempted failed before anything was written.\", \"2. Run `prisma orm init` again.\"];\nconst DB_SIGN_STEP = \"Adopt your existing database: `prisma db sign` verifies it against the contract and records the signing marker and the `db` ref. It makes no change to the database schema.\";\nconst PRISMA7_ROUTES_STEP = \"Move your routes one at a time to the Prisma 8 client in src/prisma/db.ts.\";\nconst PRISMA7_LOOP_STEP = \"After each `prisma7 migrate dev`, run `prisma contract emit` and then `prisma db sign`.\";\nconst PRISMA7_GENERATE_STEP = \"Run `prisma7 generate` so the Prisma 7 client matches the Prisma 7 CLI.\";\nconst PRISMA7_QUICK_REFERENCE_STEP = \"Open prisma-8.md for a quick reference on the transition loop and your first typed query.\";\nconst AGENT_SKILLS_STEP = \"Working with a coding agent? Run `prisma init` in this project to set up the Prisma agent skills.\";\n/**\n* The transition routine, project requirement 7: init set Prisma 8 up beside\n* Prisma 7 and stopped, so every database action here is one the user runs.\n*/\nfunction pushPrisma7Steps(push, options) {\n\tconst moved = options.prisma7.packagesMoved;\n\tconst including = moved.length === 0 ? \"\" : ` That includes ${moved.join(\", \")}.`;\n\tpush(\"Set DATABASE_URL in your environment (export it or add it to .env).\");\n\tif (options.packagesInstalled === \"failed\") push(`Install the project dependencies with your package manager — the install this run attempted failed, so nothing else here will work yet.${including}`);\n\tif (options.packagesInstalled === \"skipped\") push(`Install the project dependencies with your package manager (this run skipped them)${moved.length === 0 ? \"\" : `, including ${moved.join(\", \")}`}.`);\n\tif (!options.contractEmitted) push(`Emit the contract: \\`${options.emitCommand}\\``);\n\tpush(DB_SIGN_STEP);\n\tpush(PRISMA7_ROUTES_STEP);\n\tpush(PRISMA7_LOOP_STEP);\n\tif (options.prisma7.clientMoved) push(PRISMA7_GENERATE_STEP);\n\tpush(PRISMA7_QUICK_REFERENCE_STEP);\n\tpush(AGENT_SKILLS_STEP);\n}\n//#endregion\nexport { PRISMA7_QUICK_REFERENCE_STEP as a, PRISMA7_LOOP_STEP as i, InitOutputSchema as n, buildNextSteps as o, NEXT_STEPS_BEFORE_SCAFFOLD as r, DB_SIGN_STEP as t };\n\n//# sourceMappingURL=output-BcC8eB0h.mjs.map"],"mappings":";;;;;;;;;;;;;;;;AAgBA,MAAM,mBAAmB,KAAK;CAC7B,IAAI;CACJ,QAAQ;;CAER,WAAW;;CAEX,YAAY;CACZ,cAAc;;;;;;;CAOd,cAAc;;CAEd,cAAc,KAAK;EAClB,MAAM;EACN,IAAI;CACL,CAAC,CAAC,CAAC,MAAM;;;;;;;;CAQT,mBAAmB;EAClB,QAAQ;EACR,MAAM;EACN,SAAS;CACV;CACA,iBAAiB;;;;;;;CAOjB,SAAS,KAAK;EACb,YAAY;EACZ,iBAAiB;EACjB,kBAAkB;EAClB,eAAe;CAChB,CAAC,CAAC,CAAC,GAAG,MAAM;CACZ,WAAW;CACX,UAAU;AACX,CAAC;;;;;;;;;;;AAWD,SAAS,eAAe,SAAS;CAChC,MAAM,QAAQ,CAAC;CACf,IAAI,aAAa;CACjB,MAAM,QAAQ,SAAS;EACtB,MAAM,KAAK,GAAG,WAAW,IAAI,MAAM;EACnC,cAAc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
1
|
+
# Welcome to Prisma ORM 8!
|
|
2
|
+
|
|
3
|
+
Prisma ORM lets you query your database in simple, easy-to-read TypeScript. This project keeps its Prisma 7 schema and migrations, and Prisma 8 reads that schema as its contract source, so both run side by side while you move your code over.
|
|
4
|
+
|
|
5
|
+
{{requirements}}
|
|
6
|
+
|
|
7
|
+
## Your contract source
|
|
8
|
+
|
|
9
|
+
Your contract source is your Prisma 7 schema at [`{{schemaPath}}`]({{schemaPath}}). Prisma 7 keeps owning it: edit it as before and migrate with `prisma7 migrate dev`. Prisma 8 compiles it into two companion files under `{{outputDir}}/`:
|
|
10
|
+
|
|
11
|
+
- **`contract.json`** — this tells your application what models exist, just like `package-lock.json` tells your package manager what dependencies your project has
|
|
12
|
+
- **`contract.d.ts`** — this powers autocomplete and type checking in your editor
|
|
13
|
+
|
|
14
|
+
Commit both files to git. When the schema changes, run `{{pkgRun}} contract emit` to update them.
|
|
15
|
+
|
|
16
|
+
Every model in your schema can be queried from your app through the Prisma 8 client:
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { db } from '{{dbImportPath}}';
|
|
20
|
+
|
|
21
|
+
const user = await db.orm.public.User
|
|
22
|
+
.where({ email: 'alice@example.com' })
|
|
23
|
+
.first();
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Configuration
|
|
27
|
+
|
|
28
|
+
[`prisma.config.ts`](prisma.config.ts) tells the Prisma 8 CLI where your contract source lives and how to connect to your database.{{prisma7ConfigSentence}}
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
import 'dotenv/config';
|
|
32
|
+
import { definePrismaConfig } from '@prisma/cli-engine';
|
|
33
|
+
import { defineConfig as ormConfig, prisma7Schema } from '{{configEntrypoint}}';
|
|
34
|
+
|
|
35
|
+
export default definePrismaConfig({
|
|
36
|
+
orm: ormConfig({
|
|
37
|
+
contract: prisma7Schema('{{schemaPath}}'),
|
|
38
|
+
output: '{{outputDir}}',
|
|
39
|
+
db: {
|
|
40
|
+
connection: process.env['DATABASE_URL']!,
|
|
41
|
+
},
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
`DATABASE_URL` is read from your [`.env`](./.env) file:
|
|
47
|
+
|
|
48
|
+
```env
|
|
49
|
+
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## The transition loop
|
|
53
|
+
|
|
54
|
+
1. Run `{{pkgRun}} db sign` once so Prisma 8 knows the database matches the contract.
|
|
55
|
+
2. Move your routes to the Prisma 8 client in [`{{outputDir}}/db.ts`]({{outputDir}}/db.ts) one at a time.
|
|
56
|
+
3. After each `prisma7 migrate dev`, run `{{pkgRun}} contract emit` and then `{{pkgRun}} db sign`.
|
|
57
|
+
|
|
58
|
+
## Quick reference
|
|
59
|
+
|
|
60
|
+
### Commands
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
{{pkgRun}} contract emit # Update contract.json and contract.d.ts from the schema
|
|
64
|
+
{{pkgRun}} db sign # Record that the database matches the contract
|
|
65
|
+
prisma7 migrate dev # Migrate with Prisma 7, as before
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Files
|
|
69
|
+
|
|
70
|
+
| File | Purpose |
|
|
71
|
+
|---|---|
|
|
72
|
+
| [`{{schemaPath}}`]({{schemaPath}}) | Your Prisma 7 schema — the contract source |
|
|
73
|
+
| [`prisma.config.ts`](prisma.config.ts) | Prisma 8 CLI configuration |{{prisma7ConfigRow}}
|
|
74
|
+
| [`{{outputDir}}/db.ts`]({{outputDir}}/db.ts) | Database client — `import { db } from '{{dbImportPath}}'` |
|
|
75
|
+
| `{{outputDir}}/contract.json` | Compiled contract (generated) |
|
|
76
|
+
| `{{outputDir}}/contract.d.ts` | Contract types (generated) |
|
|
77
|
+
|
|
78
|
+
## Monorepo notes (pnpm workspaces)
|
|
79
|
+
|
|
80
|
+
If this project lives inside a pnpm workspace, `pnpm-workspace.yaml` catalogs for `prisma` or `{{pkg}}` take precedence over `latest`; update or remove the catalog entry and re-run `pnpm install` if you wanted the published version.
|
|
@@ -33,7 +33,7 @@ import { canonicalizeJson } from "@prisma/orm-framework/components/utils";
|
|
|
33
33
|
import { mkdir, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
34
34
|
import { abortable } from "@prisma/orm-framework/utils/abortable";
|
|
35
35
|
import { resolve as resolve$1 } from "node:path";
|
|
36
|
-
//#region ../../../1-framework/3-tooling/cli/dist/ref-
|
|
36
|
+
//#region ../../../1-framework/3-tooling/cli/dist/ref-DL4C2p9T.mjs
|
|
37
37
|
/**
|
|
38
38
|
* The typed remediation the CLI attaches to its own errors and findings.
|
|
39
39
|
* Constructors live here rather than in any library the CLI calls: naming a
|
|
@@ -2910,6 +2910,17 @@ function formatLocation({ sourceId, line, character }) {
|
|
|
2910
2910
|
if (sourceId === void 0) return void 0;
|
|
2911
2911
|
return line !== void 0 && character !== void 0 ? `${sourceId}:${line}:${character}` : sourceId;
|
|
2912
2912
|
}
|
|
2913
|
+
/** One source diagnostic as a line of text: `<sourceId>:<line>:<column> <code> <message>`. */
|
|
2914
|
+
function formatSourceDiagnostic(raw) {
|
|
2915
|
+
if (!isRecord(raw)) return String(raw);
|
|
2916
|
+
const code = typeof raw["code"] === "string" ? raw["code"] : "diagnostic";
|
|
2917
|
+
const message = typeof raw["message"] === "string" ? raw["message"] : "";
|
|
2918
|
+
return [
|
|
2919
|
+
formatLocation(diagnosticLocation(raw)),
|
|
2920
|
+
code,
|
|
2921
|
+
message
|
|
2922
|
+
].filter((part) => part !== void 0 && part !== "").join(" ");
|
|
2923
|
+
}
|
|
2913
2924
|
/**
|
|
2914
2925
|
* The finding the CLI prints under the error, one per source diagnostic. The
|
|
2915
2926
|
* terminal renderer prints a finding's code and summary and nothing of its
|
|
@@ -2969,36 +2980,86 @@ function mapDiagnosticsToIssues(diagnostics) {
|
|
|
2969
2980
|
}
|
|
2970
2981
|
function validateProviderResult(providerResult) {
|
|
2971
2982
|
if (!isRecord(providerResult) || typeof providerResult["ok"] !== "boolean") return {
|
|
2972
|
-
|
|
2983
|
+
kind: "malformed",
|
|
2973
2984
|
error: failedToResolveContractSource("Contract source provider returned malformed result shape.", "Ensure contract.source.load resolves to ok(Contract) or notOk({ summary, diagnostics }).")
|
|
2974
2985
|
};
|
|
2975
2986
|
if (providerResult["ok"]) {
|
|
2976
2987
|
if (!("value" in providerResult)) return {
|
|
2977
|
-
|
|
2988
|
+
kind: "malformed",
|
|
2978
2989
|
error: failedToResolveContractSource("Contract source provider returned malformed success result: missing value.", "Ensure contract.source.load success payload is ok(Contract).")
|
|
2979
2990
|
};
|
|
2980
2991
|
return {
|
|
2981
|
-
|
|
2992
|
+
kind: "ok",
|
|
2982
2993
|
value: providerResult["value"]
|
|
2983
2994
|
};
|
|
2984
2995
|
}
|
|
2985
2996
|
const failure = providerResult["failure"];
|
|
2986
2997
|
if (!isRecord(failure) || typeof failure["summary"] !== "string" || !Array.isArray(failure["diagnostics"])) return {
|
|
2987
|
-
|
|
2998
|
+
kind: "malformed",
|
|
2988
2999
|
error: failedToResolveContractSource("Contract source provider returned malformed failure result: expected summary and diagnostics.", "Ensure contract.source.load failure payload is notOk({ summary, diagnostics, meta? }).")
|
|
2989
3000
|
};
|
|
2990
3001
|
if (failure["diagnostics"].some((diagnostic) => !isRecord(diagnostic) || typeof diagnostic["sourceId"] !== "string")) return {
|
|
2991
|
-
|
|
3002
|
+
kind: "malformed",
|
|
2992
3003
|
error: failedToResolveContractSource("Contract source provider returned malformed failure result: each diagnostic must include a string sourceId.", "Include the source filename in each diagnostic returned by contract.source.load.")
|
|
2993
3004
|
};
|
|
2994
3005
|
return {
|
|
2995
|
-
|
|
2996
|
-
|
|
3006
|
+
kind: "failed",
|
|
3007
|
+
failure: {
|
|
3008
|
+
summary: failure["summary"],
|
|
2997
3009
|
diagnostics: failure["diagnostics"],
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3010
|
+
meta: failure["meta"]
|
|
3011
|
+
}
|
|
3012
|
+
};
|
|
3013
|
+
}
|
|
3014
|
+
function sourceFailureError(failure) {
|
|
3015
|
+
return failedToResolveContractSource(failure.summary, "Edit the schema where each finding points, then run contract emit again.", {
|
|
3016
|
+
diagnostics: failure.diagnostics,
|
|
3017
|
+
issues: mapDiagnosticsToIssues(failure.diagnostics),
|
|
3018
|
+
...ifDefined("providerMeta", failure.meta)
|
|
3019
|
+
}, void 0, sourceDiagnosticsToFindings(failure.diagnostics));
|
|
3020
|
+
}
|
|
3021
|
+
function requireContractConfig(config) {
|
|
3022
|
+
if (!config.contract) throw errorContractConfigMissing({ why: "Config.contract is required for emit. Define it in your config: contract: { source: ..., output: ... }" });
|
|
3023
|
+
return config.contract;
|
|
3024
|
+
}
|
|
3025
|
+
function requireSourceProvider(contractConfig) {
|
|
3026
|
+
if (typeof contractConfig.source?.load !== "function") throw errorContractConfigMissing({ why: "Contract config must include a valid source provider object" });
|
|
3027
|
+
}
|
|
3028
|
+
async function resolveContractSource(contractConfig, stack, signal) {
|
|
3029
|
+
const sourceContext = {
|
|
3030
|
+
composedExtensions: stack.extensions.map((p) => p.id),
|
|
3031
|
+
composedExtensionContracts: stack.extensionContracts,
|
|
3032
|
+
authoringContributions: stack.authoringContributions,
|
|
3033
|
+
codecLookup: stack.codecLookup,
|
|
3034
|
+
controlMutationDefaults: stack.controlMutationDefaults,
|
|
3035
|
+
dataTypeLookup: stack.dataTypeLookup,
|
|
3036
|
+
resolvedInputs: contractConfig.source.inputs ?? [],
|
|
3037
|
+
capabilities: stack.capabilities
|
|
3001
3038
|
};
|
|
3039
|
+
let providerResult;
|
|
3040
|
+
try {
|
|
3041
|
+
providerResult = await abortable(signal)(contractConfig.source.load(sourceContext));
|
|
3042
|
+
} catch (error) {
|
|
3043
|
+
if (signal.aborted || isRecord(error) && error["name"] === "AbortError") throw error;
|
|
3044
|
+
throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error);
|
|
3045
|
+
}
|
|
3046
|
+
const validated = validateProviderResult(providerResult);
|
|
3047
|
+
switch (validated.kind) {
|
|
3048
|
+
case "malformed": throw validated.error;
|
|
3049
|
+
case "failed": return notOk(validated.failure);
|
|
3050
|
+
case "ok": return ok(validated.value);
|
|
3051
|
+
}
|
|
3052
|
+
}
|
|
3053
|
+
/**
|
|
3054
|
+
* Runs the config's contract source the way `executeContractEmit` does and
|
|
3055
|
+
* stops there: nothing is emitted or written. A source that reports
|
|
3056
|
+
* diagnostics is a `notOk`; a malformed or throwing source raises the same
|
|
3057
|
+
* error emit raises.
|
|
3058
|
+
*/
|
|
3059
|
+
async function loadContractSource(config, options = {}) {
|
|
3060
|
+
const contractConfig = requireContractConfig(config);
|
|
3061
|
+
requireSourceProvider(contractConfig);
|
|
3062
|
+
return resolveContractSource(contractConfig, createControlStack(config), options.signal ?? new AbortController().signal);
|
|
3002
3063
|
}
|
|
3003
3064
|
/**
|
|
3004
3065
|
* Canonical contract emit operation.
|
|
@@ -3023,11 +3084,10 @@ function validateProviderResult(providerResult) {
|
|
|
3023
3084
|
async function executeContractEmit(options, dependencies = defaultContractEmitDependencies) {
|
|
3024
3085
|
const { config, configPath, outputPath, signal = new AbortController().signal, onProgress } = options;
|
|
3025
3086
|
const unlessAborted = abortable(signal);
|
|
3026
|
-
|
|
3027
|
-
const contractConfig = config.contract;
|
|
3087
|
+
const contractConfig = requireContractConfig(config);
|
|
3028
3088
|
const effectiveOutput = outputPath !== void 0 ? join(outputPath, "contract.json") : contractConfig.output;
|
|
3029
3089
|
if (!effectiveOutput) throw errorContractConfigMissing({ why: "Contract config must have output path. This should not happen if defineConfig() was used." });
|
|
3030
|
-
|
|
3090
|
+
requireSourceProvider(contractConfig);
|
|
3031
3091
|
let outputPaths;
|
|
3032
3092
|
try {
|
|
3033
3093
|
outputPaths = getEmittedArtifactPaths(effectiveOutput);
|
|
@@ -3037,29 +3097,17 @@ async function executeContractEmit(options, dependencies = defaultContractEmitDe
|
|
|
3037
3097
|
const { jsonPath: outputJsonPath, dtsPath: outputDtsPath } = outputPaths;
|
|
3038
3098
|
return queueEmitByOutput(outputJsonPath, async () => {
|
|
3039
3099
|
const stack = createControlStack(config);
|
|
3040
|
-
const sourceContext = {
|
|
3041
|
-
composedExtensions: stack.extensions.map((p) => p.id),
|
|
3042
|
-
composedExtensionContracts: stack.extensionContracts,
|
|
3043
|
-
authoringContributions: stack.authoringContributions,
|
|
3044
|
-
codecLookup: stack.codecLookup,
|
|
3045
|
-
controlMutationDefaults: stack.controlMutationDefaults,
|
|
3046
|
-
dataTypeLookup: stack.dataTypeLookup,
|
|
3047
|
-
resolvedInputs: contractConfig.source.inputs ?? [],
|
|
3048
|
-
capabilities: stack.capabilities
|
|
3049
|
-
};
|
|
3050
3100
|
startSpan(onProgress, "resolveSource", "Resolving contract source...");
|
|
3051
|
-
let
|
|
3101
|
+
let resolved;
|
|
3052
3102
|
try {
|
|
3053
|
-
|
|
3103
|
+
resolved = await resolveContractSource(contractConfig, stack, signal);
|
|
3054
3104
|
} catch (error) {
|
|
3055
3105
|
endSpan(onProgress, "resolveSource", "error");
|
|
3056
|
-
|
|
3057
|
-
throw failedToResolveContractSource(error instanceof Error ? error.message : String(error), "Ensure contract.source.load resolves to ok(Contract) or returns structured diagnostics.", void 0, error);
|
|
3106
|
+
throw error;
|
|
3058
3107
|
}
|
|
3059
|
-
|
|
3060
|
-
if (!validatedContract.ok) {
|
|
3108
|
+
if (!resolved.ok) {
|
|
3061
3109
|
endSpan(onProgress, "resolveSource", "error");
|
|
3062
|
-
throw
|
|
3110
|
+
throw sourceFailureError(resolved.failure);
|
|
3063
3111
|
}
|
|
3064
3112
|
endSpan(onProgress, "resolveSource", "ok");
|
|
3065
3113
|
startSpan(onProgress, "emit", "Emitting contract...");
|
|
@@ -3072,7 +3120,7 @@ async function executeContractEmit(options, dependencies = defaultContractEmitDe
|
|
|
3072
3120
|
...config.extensions ?? []
|
|
3073
3121
|
];
|
|
3074
3122
|
const frameworkComponents = assertFrameworkComponentsCompatible(config.family.familyId, config.target.targetId, rawComponents);
|
|
3075
|
-
const enrichedIR = enrichContract(blindCast(
|
|
3123
|
+
const enrichedIR = enrichContract(blindCast(resolved.value), frameworkComponents);
|
|
3076
3124
|
const rawContractJson = config.target.contractSerializer.serializeContract(enrichedIR);
|
|
3077
3125
|
const deserializedContract = familyInstance.deserializeContract(rawContractJson);
|
|
3078
3126
|
const { contractSerializer } = config.target;
|
|
@@ -5023,6 +5071,6 @@ async function executeRefListCommand(options) {
|
|
|
5023
5071
|
}
|
|
5024
5072
|
}
|
|
5025
5073
|
//#endregion
|
|
5026
|
-
export {
|
|
5074
|
+
export { formatSourceDiagnostic as $, errorLegendHumanOnly as A, runContractSpaceSeedPhase as At, errorUnexpected as B, errorContractArgConflict as C, resolveAppTargetPath as Ct, errorDriverRequired as D, resolveMigrationRef as Dt, errorDestructiveChanges as E, resolveFromForPlan as Et, errorPathUnreachable as F, statusForMigrationHash as Ft, executeMigrateShowPlan as G, executeDbInit as H, errorRunnerFailed as I, targetSupportsMigrations as It, executeRefAdvancement as J, executeMigrationNewCommand as K, errorRuntime as L, toDeclaredExtensionsFromRaw as Lt, errorMigrationPackageNotFound as M, runMigrationList as Mt, errorMigrationPlanningFailed as N, sanitizeErrorMessage as Nt, errorFileNotFound as O, resolveToForPlan as Ot, errorNoMigrations as P, snapshotVerifierFor as Pt, findPackageByDirPath as Q, errorTargetMigrationNotSupported as R, errorConsentPlanMismatch as S, requireLiveDatabase as St, errorDatabaseConnectionRequired as T, resolveContractRefToSnapshot as Tt, executeDbUpdate as U, executeContractEmit as V, executeDbVerify as W, executeRefListCommand as X, executeRefDeleteCommand as Y, executeRefSetCommand as Z, disposeEmitQueue as _, refuseDeclaredExtensionTargetMismatch as _t, appContractStandInFromIdentity as a, loadContractSpaceAggregateForCli as at, errorAdvanceRefArgConflict as b, refusePackageCorruptionOnAggregate as bt, buildMigrationSpaceGraphEntries as c, mapContractAtError as ct, checkSingleTarget as d, migrationSpaceListEntriesFromAggregate as dt, hasMigrationPath as et, chooseAction as f, originHashForStatus as ft, deriveStatusEdgeAnnotations as g, refuseContractSpaceIntegrity as gt, createControlClient as h, readMigrationRefs as ht, advanceRefSafely as i, loadContractSource as it, errorMarkerMissing as j, runMigrationCheck as jt, errorHashMismatch as k, runCommandAction as kt, buildReadAggregate as l, mapIntegrityViolations as lt, computeRefAdvancementName as m, readContractEnvelope as mt, ERROR_CODE_DESTRUCTIVE_CHANGES as n, loadAggregateIntegrityViolations as nt, appliedHashesFromLedger as o, looksLikePath as ot, closeQuietly as p, preflightRefAdvancement as pt, executeMigrationPlanCommand as q, NO_REF_ADVANCEMENT as r, loadContractRawSafely as rt, buildContractSpaceAggregate as s, mapCaughtMigrationError as st, CliStructuredError$1 as t, listRefsByContractHash as tt, buildRefAdvancementFields as u, maskConnectionUrl as ut, enrichContract as v, refuseMarkerOutsideGraph as vt, errorContractValidationFailed as w, resolveContractRef$1 as wt, errorConfigValidation$1 as x, refuseUnknownInvariants as xt, enumerateCheckSpaces as y, refuseMissingInvariantPath as yt, errorTargetMismatch as z };
|
|
5027
5075
|
|
|
5028
|
-
//# sourceMappingURL=ref-
|
|
5076
|
+
//# sourceMappingURL=ref-DL4C2p9T-BVsb1HWR.mjs.map
|