@prisma/orm-toolchain 8.0.0-rc.11-dev.51 → 8.0.0-rc.11-dev.53
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 +1476 -269
- 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/{import-roots-CYGb9VeC.mjs → import-roots-CYpOz1XZ.mjs} +2 -2
- package/dist/{import-roots-CYGb9VeC.mjs.map → import-roots-CYpOz1XZ.mjs.map} +1 -1
- 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/publish-surface.mjs +2 -2
- package/dist/publish-surface__import-roots.mjs +1 -1
- package/dist/publish-surface__shells.mjs +1 -1
- package/dist/quick-reference-prisma7.md +80 -0
- package/dist/{ref-g7LrevBG-DgO9ywms.mjs → ref-DL4C2p9T-B6EVNIhl.mjs} +83 -35
- package/dist/{ref-g7LrevBG-DgO9ywms.mjs.map → ref-DL4C2p9T-B6EVNIhl.mjs.map} +1 -1
- package/dist/{shells-C_vvtity.mjs → shells-DQaV4Fdt.mjs} +2 -1
- package/dist/{shells-C_vvtity.mjs.map → shells-DQaV4Fdt.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, loadConfig, loadConfigForFile, loadConfigForSections, requireConfigSections };\n\n//# sourceMappingURL=index.mjs.map"],"mappings":";;;;;;;;;;;;;;AAcA,SAAS,uBAAuB,QAAQ,WAAW;CAClD,MAAM,iBAAiB,OAAO,QAAQ,KAAK,UAAU,QAAQ,WAAW,KAAK,CAAC;CAC9E,IAAI,mBAAmB,KAAK,GAAG,OAAO;CACtC,OAAO;EACN,GAAG;EACH,QAAQ;CACT;AACD;;AAEA,SAAS,uBAAuB,UAAU,WAAW;CACpD,MAAM,aAAa,wBAAwB,QAAQ;CACnD,OAAO;EACN,GAAG;EACH,QAAQ,uBAAuB,WAAW,QAAQ,SAAS;EAC3D,QAAQ,QAAQ,WAAW,WAAW,MAAM;CAC7C;AACD;AACA,MAAM,yBAAyB;;;;;;;AAO/B,SAAS,yBAAyB,YAAY,WAAW;CACxD,OAAO;EACN,GAAG;EACH,KAAK,QAAQ,WAAW,YAAY,OAAO,sBAAsB;CAClE;AACD;AACA,SAAS,eAAe,QAAQ,WAAW;CAC1C,OAAO;EACN,GAAG;EACH,GAAG,OAAO,WAAW,EAAE,UAAU,uBAAuB,OAAO,UAAU,SAAS,EAAE,IAAI,KAAK;EAC7F,YAAY,yBAAyB,OAAO,YAAY,SAAS;CAClE;AACD;AAGA,MAAM,kBAAkB;AACxB,eAAe,6BAA6B,UAAU;CACrD,IAAI,UAAU,QAAQ,QAAQ,QAAQ,IAAI,GAAG,QAAQ,CAAC;CACtD,OAAO,MAA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|
/**
|
|
4
4
|
* Import-root resolution: the one place that turns an internal workspace
|
|
@@ -221,4 +221,4 @@ const EXTERNAL_DIRECT_DEPENDENCIES = /* @__PURE__ */ new Set(["@prisma/cli-engin
|
|
|
221
221
|
//#endregion
|
|
222
222
|
export { directDependencyShells as a, internalImportRoot as c, transitiveImports as d, createScaffoldSpecifierResolver as i, platformEntrypointOf as l, buildOwnerIndex as n, importRootForDependencies as o, createImportSpecifierResolver as r, importedSpecifiers as s, ImportRootError as t, resolveImportSpecifier as u };
|
|
223
223
|
|
|
224
|
-
//# sourceMappingURL=import-roots-
|
|
224
|
+
//# sourceMappingURL=import-roots-CYpOz1XZ.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"import-roots-CYGb9VeC.mjs","names":[],"sources":["../../../../0-shared/publish-surface/dist/import-roots.mjs"],"sourcesContent":["import { publicShells } from \"./shells.mjs\";\n//#region src/import-roots.ts\n/**\n* Import-root resolution: the one place that turns an internal workspace\n* specifier into the name generated code should carry.\n*\n* Emission writes package names into files the user keeps — generated\n* contract types, scaffolded migrations, `prisma orm init` output. Which\n* name is correct depends on how the application installed Prisma 8, so\n* every emitter resolves through an {@link ImportRoot} rather than hardcoding\n* a specifier. The mapping itself is `./shells`; nothing here duplicates it.\n*/\nconst INTERNAL_SCOPE = \"@internal/\";\nconst PUBLISHED_SCOPE = \"@prisma/\";\n/** An import root that emitted code cannot express. */\nvar ImportRootError = class extends Error {};\nconst internalImportRoot = { mode: \"internal\" };\n/**\n* The import root an application's own dependency list expresses.\n*\n* Emission has to name packages the application can actually resolve, and the\n* application already states which those are. Reading its manifest keeps the\n* two from drifting and lets consumers move to published names one project at\n* a time instead of behind a repository-wide switch.\n*\n* A project that names exactly one facade is on the facade root; one that\n* names platform shells without a facade is a decomposed install; anything\n* else — including a project with no `@prisma/orm-*` dependency at all — is on\n* the internal root, which emits workspace names unchanged.\n*\n* @throws {ImportRootError} when the project depends on two facades, which no\n* single generated file can be emitted for.\n*/\nfunction importRootForDependencies(dependencies) {\n\tconst named = new Set(dependencies);\n\tconst facades = [];\n\tlet hasPlatform = false;\n\tfor (const [shell, definition] of publicShells) {\n\t\tif (!named.has(shell)) continue;\n\t\tif (definition.kind === \"facade\") facades.push(shell);\n\t\tif (definition.kind === \"platform\") hasPlatform = true;\n\t}\n\tif (facades.length > 1) throw new ImportRootError(`an application may depend on only one database facade, but this one depends on ${facades.join(\" and \")}`);\n\tconst [facade] = facades;\n\tif (facade !== void 0) return {\n\t\tmode: \"facade\",\n\t\tfacade\n\t};\n\treturn hasPlatform ? { mode: \"platform\" } : internalImportRoot;\n}\nconst owners = buildOwnerIndex(publicShells);\n/**\n* Takes the shell map as an argument rather than closing over `publicShells`\n* so the duplicate-owner guard is reachable from a test: the real map is\n* valid by construction, and a guard nothing can exercise is a guard nobody\n* knows still works.\n*/\nfunction buildOwnerIndex(shells) {\n\tconst index = /* @__PURE__ */ new Map();\n\tfor (const [shell, definition] of shells) for (const pkg of definition.packages) {\n\t\tconst existing = index.get(pkg.name);\n\t\tif (existing !== void 0) throw new ImportRootError(`${pkg.name} is mapped to both ${existing.shell} and ${shell}; one module may live in only one published package (ADR 242)`);\n\t\tindex.set(pkg.name, {\n\t\t\tshell,\n\t\t\tentry: pkg.entry\n\t\t});\n\t}\n\treturn index;\n}\nfunction splitSpecifier(specifier) {\n\tconst [scope, pkg, ...rest] = specifier.split(\"/\");\n\treturn {\n\t\tname: `${scope}/${pkg}`,\n\t\tsubpath: rest.join(\"/\")\n\t};\n}\nfunction joinEntrypoint(shell, entry, subpath) {\n\tconst tail = [entry, subpath].filter(Boolean).join(\"/\");\n\treturn tail === \"\" ? shell : `${shell}/${tail}`;\n}\n/**\n* The shells an application installs directly under this root. Emitted code\n* may name only these: a package manager puts a package's own dependencies in\n* its own `node_modules`, so importing a transitively installed package fails\n* to resolve at run time even though the files are on disk.\n*/\nfunction directDependencyShells(root) {\n\tconst direct = /* @__PURE__ */ new Set();\n\tif (root.mode === \"internal\") return direct;\n\tfor (const [shell, definition] of publicShells) {\n\t\tif (definition.kind === \"extension\") direct.add(shell);\n\t\tif (root.mode === \"platform\" && definition.kind === \"platform\") direct.add(shell);\n\t}\n\tif (root.mode === \"facade\") direct.add(root.facade);\n\treturn direct;\n}\nfunction owningShell(specifier, name) {\n\tconst owner = owners.get(name);\n\tif (owner === void 0) throw new ImportRootError(`${specifier} is not mapped to any published shell`);\n\treturn owner;\n}\n/**\n* The platform-install name for an internal specifier, with the shell that\n* owns it. The shell build needs both: an import that stays inside the shell\n* being built is bundled rather than externalized.\n*/\nfunction platformEntrypointOf(specifier) {\n\tconst { name, subpath } = splitSpecifier(specifier);\n\tconst owner = owningShell(specifier, name);\n\treturn {\n\t\tshell: owner.shell,\n\t\tid: joinEntrypoint(owner.shell, owner.entry, subpath)\n\t};\n}\n/**\n* The facade's own name for an internal specifier it republishes, or\n* `undefined` when the facade does not carry that surface.\n*/\nfunction facadeEntrypoint(facade, name, subpath) {\n\tconst definition = publicShells.get(facade);\n\t/* v8 ignore next -- @preserve: every ShellName is a key of publicShells */\n\tif (definition === void 0) throw new ImportRootError(`unknown shell ${facade}`);\n\tif (definition.kind !== \"facade\") throw new ImportRootError(`${facade} is a ${definition.kind} shell, not a facade`);\n\tfor (const reexport of definition.reexports ?? []) {\n\t\tif (reexport.package !== name) continue;\n\t\tif (subpath === \"\" && reexport.root === false) return void 0;\n\t\tif (reexport.subpaths !== void 0 && !reexport.subpaths.includes(subpath)) return void 0;\n\t\treturn joinEntrypoint(facade, reexport.entry, subpath);\n\t}\n}\nfunction describe(root) {\n\treturn root.mode === \"facade\" ? `${root.mode} (${root.facade})` : root.mode;\n}\nfunction resolveImportSpecifier(specifier, root) {\n\tif (root.mode === \"internal\") return specifier;\n\tif (!specifier.startsWith(INTERNAL_SCOPE)) return specifier;\n\tconst { name, subpath } = splitSpecifier(specifier);\n\tif (root.mode === \"facade\") {\n\t\tconst republished = facadeEntrypoint(root.facade, name, subpath);\n\t\tif (republished !== void 0) return republished;\n\t}\n\tconst owner = owningShell(specifier, name);\n\tconst published = joinEntrypoint(owner.shell, owner.entry, subpath);\n\tif (!directDependencyShells(root).has(owner.shell)) throw new ImportRootError(unreachableUnder(specifier, published, root));\n\treturn published;\n}\n/**\n* Why a specifier has no name under `root`.\n*\n* The facade wording deliberately does not say \"not a direct dependency\":\n* under ADR 242 the answer to that is never \"install the platform package\n* too\", it is that the facade has to republish the surface.\n*/\nfunction unreachableUnder(specifier, published, root) {\n\tif (root.mode === \"facade\") return `${specifier} has no name under ${root.facade}: the facade does not republish ${published}. An application installs one facade and nothing else, so every surface it reaches has to be one of that facade’s own entrypoints (ADR 242).`;\n\treturn `${specifier} resolves to ${published}, which an application on the ${describe(root)} import root does not depend on directly. Emitted code may name only direct dependencies (ADR 242).`;\n}\nfunction createImportSpecifierResolver(root) {\n\tif (root.mode === \"internal\") return (specifier) => specifier;\n\treturn (specifier) => resolveImportSpecifier(specifier, root);\n}\n/**\n* Builds the resolver `prisma orm init` scaffolds with. Identical to\n* {@link createImportSpecifierResolver} except that it will not accept a root\n* a scaffold cannot express, so the impossible case is rejected where the\n* resolver is made rather than when a template happens to hit a name.\n*/\nfunction createScaffoldSpecifierResolver(root) {\n\treturn createImportSpecifierResolver(root);\n}\nconst MODULE_SPECIFIER = /\\b(?:from|import)\\s*\\(?\\s*(['\"])([^'\"\\n]+)\\1/g;\n/**\n* True when `source` contains module syntax that must carry a quoted\n* specifier: `import '<s>'`, `import('<s>')`, or an import/export clause\n* followed by `from '<s>'`.\n*\n* Deliberately independent of {@link MODULE_SPECIFIER} — it exists to notice\n* when that scanner has stopped matching, so it accepts any quote character,\n* including the backtick a renderer must never emit. It does still require a\n* quote: the word \"import\" on its own appears in prose and comments all the\n* time, and treating that as module syntax made the check below fire on files\n* that have no imports at all.\n*/\nconst HAS_IMPORT_SYNTAX = /(?:^|[\\s(;}])import\\s*[('\"`]|(?:^|[\\s;}])(?:import|export)\\b[\\w$*,{}\\s]*?\\bfrom\\s*['\"`]/;\n/** The module specifiers a generated source file names. */\nfunction importedSpecifiers(source) {\n\treturn [...source.matchAll(MODULE_SPECIFIER)].map(([, , specifier]) => specifier ?? \"\");\n}\n/**\n* The specifiers in a generated file that the application would not have as a\n* direct dependency under `root` — the thing no emitted file may contain.\n*\n* Under the `internal` root nothing is reported: those names are the\n* repository's own, and every in-repo consumer resolves them through the\n* workspace.\n*\n* Throws rather than returning `[]` when the source plainly has imports but\n* the scan found none. An audit whose scanner has stopped matching would\n* otherwise report every file as clean, which is the one failure mode that\n* makes the audit worse than not having it.\n*/\nfunction transitiveImports(source, root) {\n\tconst specifiers = importedSpecifiers(source);\n\tif (specifiers.length === 0 && HAS_IMPORT_SYNTAX.test(source)) throw new ImportRootError(\"source contains import syntax but no specifier was recognised; the audit would pass vacuously\");\n\tif (root.mode === \"internal\") return [];\n\tconst direct = new Set(directDependencyShells(root));\n\treturn specifiers.filter((specifier) => {\n\t\tif (specifier.startsWith(INTERNAL_SCOPE)) return true;\n\t\tif (!specifier.startsWith(PUBLISHED_SCOPE)) return false;\n\t\tconst [scope, shell] = specifier.split(\"/\");\n\t\tconst name = `${scope}/${shell}`;\n\t\treturn !direct.has(name) && !EXTERNAL_DIRECT_DEPENDENCIES.has(name);\n\t});\n}\n/**\n* Published packages this workspace does not own but `init` installs into a\n* scaffolded application directly, so its files may import them:\n* `@prisma/cli-engine` is the config file's `definePrismaConfig` import.\n*/\nconst EXTERNAL_DIRECT_DEPENDENCIES = /* @__PURE__ */ new Set([\"@prisma/cli-engine\"]);\n//#endregion\nexport { ImportRootError, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, resolveImportSpecifier, transitiveImports };\n\n//# sourceMappingURL=import-roots.mjs.map"],"mappings":";;;;;;;;;;;;AAYA,MAAM,iBAAiB;AACvB,MAAM,kBAAkB;;AAExB,IAAI,kBAAkB,cAAc,MAAM,CAAC;AAC3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AE;AACvF;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB,QAAQ,MAAM;CACxC,MAAM,aAAa,mBAAmB,MAAM;CAC5C,IAAI,WAAW,WAAW,KAAK,kBAAkB,KAAK,MAAM,GAAG,MAAM,IAAI,gBAAgB,+FAA+F;CACxL,IAAI,KAAK,SAAS,YAAY,OAAO,CAAC;CACtC,MAAM,SAAS,IAAI,IAAI,uBAAuB,IAAI,CAAC;CACnD,OAAO,WAAW,QAAQ,cAAc;EACvC,IAAI,UAAU,WAAW,cAAc,GAAG,OAAO;EACjD,IAAI,CAAC,UAAU,WAAW,eAAe,GAAG,OAAO;EACnD,MAAM,CAAC,OAAO,SAAS,UAAU,MAAM,GAAG;EAC1C,MAAM,OAAO,GAAG,MAAM,GAAG;EACzB,OAAO,CAAC,OAAO,IAAI,IAAI,KAAK,CAAC,6BAA6B,IAAI,IAAI;CACnE,CAAC;AACF;;;;;;AAMA,MAAM,+CAA+C,IAAI,IAAI,CAAC,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"import-roots-CYpOz1XZ.mjs","names":[],"sources":["../../../../0-shared/publish-surface/dist/import-roots.mjs"],"sourcesContent":["import { publicShells } from \"./shells.mjs\";\n//#region src/import-roots.ts\n/**\n* Import-root resolution: the one place that turns an internal workspace\n* specifier into the name generated code should carry.\n*\n* Emission writes package names into files the user keeps — generated\n* contract types, scaffolded migrations, `prisma orm init` output. Which\n* name is correct depends on how the application installed Prisma 8, so\n* every emitter resolves through an {@link ImportRoot} rather than hardcoding\n* a specifier. The mapping itself is `./shells`; nothing here duplicates it.\n*/\nconst INTERNAL_SCOPE = \"@internal/\";\nconst PUBLISHED_SCOPE = \"@prisma/\";\n/** An import root that emitted code cannot express. */\nvar ImportRootError = class extends Error {};\nconst internalImportRoot = { mode: \"internal\" };\n/**\n* The import root an application's own dependency list expresses.\n*\n* Emission has to name packages the application can actually resolve, and the\n* application already states which those are. Reading its manifest keeps the\n* two from drifting and lets consumers move to published names one project at\n* a time instead of behind a repository-wide switch.\n*\n* A project that names exactly one facade is on the facade root; one that\n* names platform shells without a facade is a decomposed install; anything\n* else — including a project with no `@prisma/orm-*` dependency at all — is on\n* the internal root, which emits workspace names unchanged.\n*\n* @throws {ImportRootError} when the project depends on two facades, which no\n* single generated file can be emitted for.\n*/\nfunction importRootForDependencies(dependencies) {\n\tconst named = new Set(dependencies);\n\tconst facades = [];\n\tlet hasPlatform = false;\n\tfor (const [shell, definition] of publicShells) {\n\t\tif (!named.has(shell)) continue;\n\t\tif (definition.kind === \"facade\") facades.push(shell);\n\t\tif (definition.kind === \"platform\") hasPlatform = true;\n\t}\n\tif (facades.length > 1) throw new ImportRootError(`an application may depend on only one database facade, but this one depends on ${facades.join(\" and \")}`);\n\tconst [facade] = facades;\n\tif (facade !== void 0) return {\n\t\tmode: \"facade\",\n\t\tfacade\n\t};\n\treturn hasPlatform ? { mode: \"platform\" } : internalImportRoot;\n}\nconst owners = buildOwnerIndex(publicShells);\n/**\n* Takes the shell map as an argument rather than closing over `publicShells`\n* so the duplicate-owner guard is reachable from a test: the real map is\n* valid by construction, and a guard nothing can exercise is a guard nobody\n* knows still works.\n*/\nfunction buildOwnerIndex(shells) {\n\tconst index = /* @__PURE__ */ new Map();\n\tfor (const [shell, definition] of shells) for (const pkg of definition.packages) {\n\t\tconst existing = index.get(pkg.name);\n\t\tif (existing !== void 0) throw new ImportRootError(`${pkg.name} is mapped to both ${existing.shell} and ${shell}; one module may live in only one published package (ADR 242)`);\n\t\tindex.set(pkg.name, {\n\t\t\tshell,\n\t\t\tentry: pkg.entry\n\t\t});\n\t}\n\treturn index;\n}\nfunction splitSpecifier(specifier) {\n\tconst [scope, pkg, ...rest] = specifier.split(\"/\");\n\treturn {\n\t\tname: `${scope}/${pkg}`,\n\t\tsubpath: rest.join(\"/\")\n\t};\n}\nfunction joinEntrypoint(shell, entry, subpath) {\n\tconst tail = [entry, subpath].filter(Boolean).join(\"/\");\n\treturn tail === \"\" ? shell : `${shell}/${tail}`;\n}\n/**\n* The shells an application installs directly under this root. Emitted code\n* may name only these: a package manager puts a package's own dependencies in\n* its own `node_modules`, so importing a transitively installed package fails\n* to resolve at run time even though the files are on disk.\n*/\nfunction directDependencyShells(root) {\n\tconst direct = /* @__PURE__ */ new Set();\n\tif (root.mode === \"internal\") return direct;\n\tfor (const [shell, definition] of publicShells) {\n\t\tif (definition.kind === \"extension\") direct.add(shell);\n\t\tif (root.mode === \"platform\" && definition.kind === \"platform\") direct.add(shell);\n\t}\n\tif (root.mode === \"facade\") direct.add(root.facade);\n\treturn direct;\n}\nfunction owningShell(specifier, name) {\n\tconst owner = owners.get(name);\n\tif (owner === void 0) throw new ImportRootError(`${specifier} is not mapped to any published shell`);\n\treturn owner;\n}\n/**\n* The platform-install name for an internal specifier, with the shell that\n* owns it. The shell build needs both: an import that stays inside the shell\n* being built is bundled rather than externalized.\n*/\nfunction platformEntrypointOf(specifier) {\n\tconst { name, subpath } = splitSpecifier(specifier);\n\tconst owner = owningShell(specifier, name);\n\treturn {\n\t\tshell: owner.shell,\n\t\tid: joinEntrypoint(owner.shell, owner.entry, subpath)\n\t};\n}\n/**\n* The facade's own name for an internal specifier it republishes, or\n* `undefined` when the facade does not carry that surface.\n*/\nfunction facadeEntrypoint(facade, name, subpath) {\n\tconst definition = publicShells.get(facade);\n\t/* v8 ignore next -- @preserve: every ShellName is a key of publicShells */\n\tif (definition === void 0) throw new ImportRootError(`unknown shell ${facade}`);\n\tif (definition.kind !== \"facade\") throw new ImportRootError(`${facade} is a ${definition.kind} shell, not a facade`);\n\tfor (const reexport of definition.reexports ?? []) {\n\t\tif (reexport.package !== name) continue;\n\t\tif (subpath === \"\" && reexport.root === false) return void 0;\n\t\tif (reexport.subpaths !== void 0 && !reexport.subpaths.includes(subpath)) return void 0;\n\t\treturn joinEntrypoint(facade, reexport.entry, subpath);\n\t}\n}\nfunction describe(root) {\n\treturn root.mode === \"facade\" ? `${root.mode} (${root.facade})` : root.mode;\n}\nfunction resolveImportSpecifier(specifier, root) {\n\tif (root.mode === \"internal\") return specifier;\n\tif (!specifier.startsWith(INTERNAL_SCOPE)) return specifier;\n\tconst { name, subpath } = splitSpecifier(specifier);\n\tif (root.mode === \"facade\") {\n\t\tconst republished = facadeEntrypoint(root.facade, name, subpath);\n\t\tif (republished !== void 0) return republished;\n\t}\n\tconst owner = owningShell(specifier, name);\n\tconst published = joinEntrypoint(owner.shell, owner.entry, subpath);\n\tif (!directDependencyShells(root).has(owner.shell)) throw new ImportRootError(unreachableUnder(specifier, published, root));\n\treturn published;\n}\n/**\n* Why a specifier has no name under `root`.\n*\n* The facade wording deliberately does not say \"not a direct dependency\":\n* under ADR 242 the answer to that is never \"install the platform package\n* too\", it is that the facade has to republish the surface.\n*/\nfunction unreachableUnder(specifier, published, root) {\n\tif (root.mode === \"facade\") return `${specifier} has no name under ${root.facade}: the facade does not republish ${published}. An application installs one facade and nothing else, so every surface it reaches has to be one of that facade’s own entrypoints (ADR 242).`;\n\treturn `${specifier} resolves to ${published}, which an application on the ${describe(root)} import root does not depend on directly. Emitted code may name only direct dependencies (ADR 242).`;\n}\nfunction createImportSpecifierResolver(root) {\n\tif (root.mode === \"internal\") return (specifier) => specifier;\n\treturn (specifier) => resolveImportSpecifier(specifier, root);\n}\n/**\n* Builds the resolver `prisma orm init` scaffolds with. Identical to\n* {@link createImportSpecifierResolver} except that it will not accept a root\n* a scaffold cannot express, so the impossible case is rejected where the\n* resolver is made rather than when a template happens to hit a name.\n*/\nfunction createScaffoldSpecifierResolver(root) {\n\treturn createImportSpecifierResolver(root);\n}\nconst MODULE_SPECIFIER = /\\b(?:from|import)\\s*\\(?\\s*(['\"])([^'\"\\n]+)\\1/g;\n/**\n* True when `source` contains module syntax that must carry a quoted\n* specifier: `import '<s>'`, `import('<s>')`, or an import/export clause\n* followed by `from '<s>'`.\n*\n* Deliberately independent of {@link MODULE_SPECIFIER} — it exists to notice\n* when that scanner has stopped matching, so it accepts any quote character,\n* including the backtick a renderer must never emit. It does still require a\n* quote: the word \"import\" on its own appears in prose and comments all the\n* time, and treating that as module syntax made the check below fire on files\n* that have no imports at all.\n*/\nconst HAS_IMPORT_SYNTAX = /(?:^|[\\s(;}])import\\s*[('\"`]|(?:^|[\\s;}])(?:import|export)\\b[\\w$*,{}\\s]*?\\bfrom\\s*['\"`]/;\n/** The module specifiers a generated source file names. */\nfunction importedSpecifiers(source) {\n\treturn [...source.matchAll(MODULE_SPECIFIER)].map(([, , specifier]) => specifier ?? \"\");\n}\n/**\n* The specifiers in a generated file that the application would not have as a\n* direct dependency under `root` — the thing no emitted file may contain.\n*\n* Under the `internal` root nothing is reported: those names are the\n* repository's own, and every in-repo consumer resolves them through the\n* workspace.\n*\n* Throws rather than returning `[]` when the source plainly has imports but\n* the scan found none. An audit whose scanner has stopped matching would\n* otherwise report every file as clean, which is the one failure mode that\n* makes the audit worse than not having it.\n*/\nfunction transitiveImports(source, root) {\n\tconst specifiers = importedSpecifiers(source);\n\tif (specifiers.length === 0 && HAS_IMPORT_SYNTAX.test(source)) throw new ImportRootError(\"source contains import syntax but no specifier was recognised; the audit would pass vacuously\");\n\tif (root.mode === \"internal\") return [];\n\tconst direct = new Set(directDependencyShells(root));\n\treturn specifiers.filter((specifier) => {\n\t\tif (specifier.startsWith(INTERNAL_SCOPE)) return true;\n\t\tif (!specifier.startsWith(PUBLISHED_SCOPE)) return false;\n\t\tconst [scope, shell] = specifier.split(\"/\");\n\t\tconst name = `${scope}/${shell}`;\n\t\treturn !direct.has(name) && !EXTERNAL_DIRECT_DEPENDENCIES.has(name);\n\t});\n}\n/**\n* Published packages this workspace does not own but `init` installs into a\n* scaffolded application directly, so its files may import them:\n* `@prisma/cli-engine` is the config file's `definePrismaConfig` import.\n*/\nconst EXTERNAL_DIRECT_DEPENDENCIES = /* @__PURE__ */ new Set([\"@prisma/cli-engine\"]);\n//#endregion\nexport { ImportRootError, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, importRootForDependencies, importedSpec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IAAI;AAC1C;AACA,MAAM,mBAAmB;;;;;;;;;;;;;AAazB,MAAM,oBAAoB;;AAE1B,SAAS,mBAAmB,QAAQ;CACnC,OAAO,CAAC,GAAG,OAAO,SAAS,gBAAgB,CAAC,CAAC,CAAC,KAAK,KAAK,eAAe,aAAa,EAAE;AACvF;;;;;;;;;;;;;;AAcA,SAAS,kBAAkB,QAAQ,MAAM;CACxC,MAAM,aAAa,mBAAmB,MAAM;CAC5C,IAAI,WAAW,WAAW,KAAK,kBAAkB,KAAK,MAAM,GAAG,MAAM,IAAI,gBAAgB,+FAA+F;CACxL,IAAI,KAAK,SAAS,YAAY,OAAO,CAAC;CACtC,MAAM,SAAS,IAAI,IAAI,uBAAuB,IAAI,CAAC;CACnD,OAAO,WAAW,QAAQ,cAAc;EACvC,IAAI,UAAU,WAAW,cAAc,GAAG,OAAO;EACjD,IAAI,CAAC,UAAU,WAAW,eAAe,GAAG,OAAO;EACnD,MAAM,CAAC,OAAO,SAAS,UAAU,MAAM,GAAG;EAC1C,MAAM,OAAO,GAAG,MAAM,GAAG;EACzB,OAAO,CAAC,OAAO,IAAI,IAAI,KAAK,CAAC,6BAA6B,IAAI,IAAI;CACnE,CAAC;AACF;;;;;;AAMA,MAAM,+CAA+C,IAAI,IAAI,CAAC,oBAAoB,CAAC"}
|
|
@@ -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,QA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A4B;CACjC,KAAK,iBAAiB;AACvB"}
|
package/dist/publish-surface.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as publicShells, t as excludedSubpaths } from "./shells-
|
|
2
|
-
import { a as directDependencyShells, c as internalImportRoot, d as transitiveImports, i as createScaffoldSpecifierResolver, l as platformEntrypointOf, n as buildOwnerIndex, o as importRootForDependencies, r as createImportSpecifierResolver, s as importedSpecifiers, t as ImportRootError, u as resolveImportSpecifier } from "./import-roots-
|
|
1
|
+
import { n as publicShells, t as excludedSubpaths } from "./shells-DQaV4Fdt.mjs";
|
|
2
|
+
import { a as directDependencyShells, c as internalImportRoot, d as transitiveImports, i as createScaffoldSpecifierResolver, l as platformEntrypointOf, n as buildOwnerIndex, o as importRootForDependencies, r as createImportSpecifierResolver, s as importedSpecifiers, t as ImportRootError, u as resolveImportSpecifier } from "./import-roots-CYpOz1XZ.mjs";
|
|
3
3
|
export { ImportRootError, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, excludedSubpaths, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, publicShells, resolveImportSpecifier, transitiveImports };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as directDependencyShells, c as internalImportRoot, d as transitiveImports, i as createScaffoldSpecifierResolver, l as platformEntrypointOf, n as buildOwnerIndex, o as importRootForDependencies, r as createImportSpecifierResolver, s as importedSpecifiers, t as ImportRootError, u as resolveImportSpecifier } from "./import-roots-
|
|
1
|
+
import { a as directDependencyShells, c as internalImportRoot, d as transitiveImports, i as createScaffoldSpecifierResolver, l as platformEntrypointOf, n as buildOwnerIndex, o as importRootForDependencies, r as createImportSpecifierResolver, s as importedSpecifiers, t as ImportRootError, u as resolveImportSpecifier } from "./import-roots-CYpOz1XZ.mjs";
|
|
2
2
|
export { ImportRootError, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, resolveImportSpecifier, transitiveImports };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as publicShells, t as excludedSubpaths } from "./shells-
|
|
1
|
+
import { n as publicShells, t as excludedSubpaths } from "./shells-DQaV4Fdt.mjs";
|
|
2
2
|
export { excludedSubpaths, publicShells };
|
|
@@ -0,0 +1,80 @@
|
|
|
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.
|