@prisma/orm-toolchain 8.0.0-rc.24-dev.28 → 8.0.0-rc.24-dev.30
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/README.md +1 -3
- package/dist/{aggregate-CRIdmKmq.mjs → aggregate-7sB4u_aJ.mjs} +11 -5
- package/dist/aggregate-7sB4u_aJ.mjs.map +1 -0
- package/dist/{aggregate-C6PGBKyb.d.mts → aggregate-DgWdbWNs.d.mts} +12 -6
- package/dist/{aggregate-C6PGBKyb.d.mts.map → aggregate-DgWdbWNs.d.mts.map} +1 -1
- package/dist/{caught-errors-I1l50iPc-D_-F2M3t.mjs → caught-errors-D_pbHqmS-B-4jRN6g.mjs} +52 -11
- package/dist/caught-errors-D_pbHqmS-B-4jRN6g.mjs.map +1 -0
- package/dist/cli-telemetry.mjs +1 -1
- package/dist/cli.d.mts +2 -2
- package/dist/cli.mjs +1094 -1012
- package/dist/cli.mjs.map +1 -1
- package/dist/cli__control-api.d.mts +16 -14
- package/dist/cli__control-api.d.mts.map +1 -1
- package/dist/cli__control-api.mjs +2 -2
- package/dist/cli__control-api__testing.d.mts +1 -1
- package/dist/cli__init-contribution.d.mts +101 -0
- package/dist/cli__init-contribution.d.mts.map +1 -0
- package/dist/cli__init-contribution.mjs +1 -0
- package/dist/cli__init-output.d.mts +3 -3
- package/dist/cli__init-output.mjs +1 -1
- package/dist/cli__migration-cli.mjs +3 -3
- package/dist/cli__migration-cli.mjs.map +1 -1
- package/dist/config-loader.d.mts +1 -1
- package/dist/config-loader.mjs +1 -1
- package/dist/{db-sign-Bv-FZMAD-uQhMNCC7.d.mts → db-sign-DLIR5swa-DQ0aN1nU.d.mts} +25 -21
- package/dist/db-sign-DLIR5swa-DQ0aN1nU.d.mts.map +1 -0
- package/dist/{domain-type-generation-BlYB8GiS-k0HNTf4f.mjs → domain-type-generation-BGcbGgHJ-Cdw5RNaZ.mjs} +11 -12
- package/dist/domain-type-generation-BGcbGgHJ-Cdw5RNaZ.mjs.map +1 -0
- package/dist/{domain-type-generation-D5cG6TGd-DKLpO6ZA.d.mts → domain-type-generation-BP8J5hy8-CxSjSRCh.d.mts} +6 -5
- package/dist/domain-type-generation-BP8J5hy8-CxSjSRCh.d.mts.map +1 -0
- package/dist/emitter.d.mts +3 -3
- package/dist/emitter.mjs +3 -3
- package/dist/emitter__domain-type-generation.d.mts +2 -2
- package/dist/emitter__domain-type-generation.mjs +2 -2
- package/dist/{exports-RTLU0w9r.mjs → exports-BiXPktAF.mjs} +4 -4
- package/dist/{exports-RTLU0w9r.mjs.map → exports-BiXPktAF.mjs.map} +1 -1
- package/dist/{exports-CVgs3YWV-BF4rqnxF.mjs → exports-CCuYD8dO-yw1GizAT.mjs} +28 -18
- package/dist/exports-CCuYD8dO-yw1GizAT.mjs.map +1 -0
- package/dist/{exports-CSVHjfwG.mjs → exports-CZ6dPu-O.mjs} +35 -10
- package/dist/exports-CZ6dPu-O.mjs.map +1 -0
- package/dist/{index-BHYAWGxJ.d.mts → index-C09OeJjf.d.mts} +7 -12
- package/dist/index-C09OeJjf.d.mts.map +1 -0
- package/dist/{index-BhNbc269.d.mts → index-C3KtOcBP.d.mts} +3 -1
- package/dist/index-C3KtOcBP.d.mts.map +1 -0
- package/dist/migration-tools.d.mts +1 -1
- package/dist/migration-tools.mjs +3 -3
- package/dist/migration-tools__aggregate.d.mts +1 -1
- package/dist/migration-tools__aggregate.mjs +1 -1
- package/dist/migration-tools__ref-resolution.mjs +1 -1
- package/dist/migration-tools__refs.mjs +1 -1
- package/dist/{output-BcC8eB0h-C5bRd-aC.mjs → output-E6F4-EMc-CqlzGlv-.mjs} +50 -9
- package/dist/output-E6F4-EMc-CqlzGlv-.mjs.map +1 -0
- package/dist/{ref-DfuqRCA7-CPPoVHY9.mjs → ref-PQOM_LTC-lyfzb0MO.mjs} +535 -270
- package/dist/ref-PQOM_LTC-lyfzb0MO.mjs.map +1 -0
- package/dist/{ref-resolution-C9j2SSb6.mjs → ref-resolution-C0xsiRig.mjs} +2 -2
- package/dist/{ref-resolution-C9j2SSb6.mjs.map → ref-resolution-C0xsiRig.mjs.map} +1 -1
- package/dist/{refs-t_JbIjGo-CRpBRRkq.mjs → refs-t_JbIjGo-BVCqKpXd.mjs} +2 -2
- package/dist/{refs-t_JbIjGo-CRpBRRkq.mjs.map → refs-t_JbIjGo-BVCqKpXd.mjs.map} +1 -1
- package/dist/vite-plugin-contract-emit.mjs +4 -5
- package/dist/vite-plugin-contract-emit.mjs.map +1 -1
- package/package.json +19 -22
- package/dist/aggregate-CRIdmKmq.mjs.map +0 -1
- package/dist/caught-errors-I1l50iPc-D_-F2M3t.mjs.map +0 -1
- package/dist/db-sign-Bv-FZMAD-uQhMNCC7.d.mts.map +0 -1
- package/dist/domain-type-generation-BlYB8GiS-k0HNTf4f.mjs.map +0 -1
- package/dist/domain-type-generation-D5cG6TGd-DKLpO6ZA.d.mts.map +0 -1
- package/dist/exports-CSVHjfwG.mjs.map +0 -1
- package/dist/exports-CVgs3YWV-BF4rqnxF.mjs.map +0 -1
- package/dist/import-roots-DlSoi7oS.d.mts +0 -119
- package/dist/import-roots-DlSoi7oS.d.mts.map +0 -1
- package/dist/import-roots-Dqs1_cn4.mjs +0 -224
- package/dist/import-roots-Dqs1_cn4.mjs.map +0 -1
- package/dist/index-BHYAWGxJ.d.mts.map +0 -1
- package/dist/index-BhNbc269.d.mts.map +0 -1
- package/dist/output-BcC8eB0h-C5bRd-aC.mjs.map +0 -1
- package/dist/publish-surface.d.mts +0 -3
- package/dist/publish-surface.mjs +0 -3
- package/dist/publish-surface__import-roots.d.mts +0 -2
- package/dist/publish-surface__import-roots.mjs +0 -2
- package/dist/publish-surface__shells.d.mts +0 -2
- package/dist/publish-surface__shells.mjs +0 -2
- package/dist/quick-reference-mongo.md +0 -116
- package/dist/quick-reference-postgres.md +0 -95
- package/dist/quick-reference-prisma7.md +0 -80
- package/dist/readme-mongo.md +0 -35
- package/dist/readme-postgres.md +0 -34
- package/dist/ref-DfuqRCA7-CPPoVHY9.mjs.map +0 -1
- package/dist/shells-BA7YJyPT.mjs +0 -777
- package/dist/shells-BA7YJyPT.mjs.map +0 -1
- package/dist/shells-D7NNxMLT.d.mts +0 -129
- package/dist/shells-D7NNxMLT.d.mts.map +0 -1
|
@@ -1,224 +0,0 @@
|
|
|
1
|
-
import { n as publicShells } from "./shells-BA7YJyPT.mjs";
|
|
2
|
-
//#region ../../../0-shared/publish-surface/dist/import-roots.mjs
|
|
3
|
-
/**
|
|
4
|
-
* Import-root resolution: the one place that turns an internal workspace
|
|
5
|
-
* specifier into the name generated code should carry.
|
|
6
|
-
*
|
|
7
|
-
* Emission writes package names into files the user keeps — generated
|
|
8
|
-
* contract types, scaffolded migrations, `prisma orm init` output. Which
|
|
9
|
-
* name is correct depends on how the application installed Prisma 8, so
|
|
10
|
-
* every emitter resolves through an {@link ImportRoot} rather than hardcoding
|
|
11
|
-
* a specifier. The mapping itself is `./shells`; nothing here duplicates it.
|
|
12
|
-
*/
|
|
13
|
-
const INTERNAL_SCOPE = "@internal/";
|
|
14
|
-
const PUBLISHED_SCOPE = "@prisma/";
|
|
15
|
-
/** An import root that emitted code cannot express. */
|
|
16
|
-
var ImportRootError = class extends Error {};
|
|
17
|
-
const internalImportRoot = { mode: "internal" };
|
|
18
|
-
/**
|
|
19
|
-
* The import root an application's own dependency list expresses.
|
|
20
|
-
*
|
|
21
|
-
* Emission has to name packages the application can actually resolve, and the
|
|
22
|
-
* application already states which those are. Reading its manifest keeps the
|
|
23
|
-
* two from drifting and lets consumers move to published names one project at
|
|
24
|
-
* a time instead of behind a repository-wide switch.
|
|
25
|
-
*
|
|
26
|
-
* A project that names exactly one facade is on the facade root; one that
|
|
27
|
-
* names platform shells without a facade is a decomposed install; anything
|
|
28
|
-
* else — including a project with no `@prisma/orm-*` dependency at all — is on
|
|
29
|
-
* the internal root, which emits workspace names unchanged.
|
|
30
|
-
*
|
|
31
|
-
* @throws {ImportRootError} when the project depends on two facades, which no
|
|
32
|
-
* single generated file can be emitted for.
|
|
33
|
-
*/
|
|
34
|
-
function importRootForDependencies(dependencies) {
|
|
35
|
-
const named = new Set(dependencies);
|
|
36
|
-
const facades = [];
|
|
37
|
-
let hasPlatform = false;
|
|
38
|
-
for (const [shell, definition] of publicShells) {
|
|
39
|
-
if (!named.has(shell)) continue;
|
|
40
|
-
if (definition.kind === "facade") facades.push(shell);
|
|
41
|
-
if (definition.kind === "platform") hasPlatform = true;
|
|
42
|
-
}
|
|
43
|
-
if (facades.length > 1) throw new ImportRootError(`an application may depend on only one database facade, but this one depends on ${facades.join(" and ")}`);
|
|
44
|
-
const [facade] = facades;
|
|
45
|
-
if (facade !== void 0) return {
|
|
46
|
-
mode: "facade",
|
|
47
|
-
facade
|
|
48
|
-
};
|
|
49
|
-
return hasPlatform ? { mode: "platform" } : internalImportRoot;
|
|
50
|
-
}
|
|
51
|
-
const owners = buildOwnerIndex(publicShells);
|
|
52
|
-
/**
|
|
53
|
-
* Takes the shell map as an argument rather than closing over `publicShells`
|
|
54
|
-
* so the duplicate-owner guard is reachable from a test: the real map is
|
|
55
|
-
* valid by construction, and a guard nothing can exercise is a guard nobody
|
|
56
|
-
* knows still works.
|
|
57
|
-
*/
|
|
58
|
-
function buildOwnerIndex(shells) {
|
|
59
|
-
const index = /* @__PURE__ */ new Map();
|
|
60
|
-
for (const [shell, definition] of shells) for (const pkg of definition.packages) {
|
|
61
|
-
const existing = index.get(pkg.name);
|
|
62
|
-
if (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)`);
|
|
63
|
-
index.set(pkg.name, {
|
|
64
|
-
shell,
|
|
65
|
-
entry: pkg.entry
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
return index;
|
|
69
|
-
}
|
|
70
|
-
function splitSpecifier(specifier) {
|
|
71
|
-
const [scope, pkg, ...rest] = specifier.split("/");
|
|
72
|
-
return {
|
|
73
|
-
name: `${scope}/${pkg}`,
|
|
74
|
-
subpath: rest.join("/")
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
function joinEntrypoint(shell, entry, subpath) {
|
|
78
|
-
const tail = [entry, subpath].filter(Boolean).join("/");
|
|
79
|
-
return tail === "" ? shell : `${shell}/${tail}`;
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* The shells an application installs directly under this root. Emitted code
|
|
83
|
-
* may name only these: a package manager puts a package's own dependencies in
|
|
84
|
-
* its own `node_modules`, so importing a transitively installed package fails
|
|
85
|
-
* to resolve at run time even though the files are on disk.
|
|
86
|
-
*/
|
|
87
|
-
function directDependencyShells(root) {
|
|
88
|
-
const direct = /* @__PURE__ */ new Set();
|
|
89
|
-
if (root.mode === "internal") return direct;
|
|
90
|
-
for (const [shell, definition] of publicShells) {
|
|
91
|
-
if (definition.kind === "extension") direct.add(shell);
|
|
92
|
-
if (root.mode === "platform" && definition.kind === "platform") direct.add(shell);
|
|
93
|
-
}
|
|
94
|
-
if (root.mode === "facade") direct.add(root.facade);
|
|
95
|
-
return direct;
|
|
96
|
-
}
|
|
97
|
-
function owningShell(specifier, name) {
|
|
98
|
-
const owner = owners.get(name);
|
|
99
|
-
if (owner === void 0) throw new ImportRootError(`${specifier} is not mapped to any published shell`);
|
|
100
|
-
return owner;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* The platform-install name for an internal specifier, with the shell that
|
|
104
|
-
* owns it. The shell build needs both: an import that stays inside the shell
|
|
105
|
-
* being built is bundled rather than externalized.
|
|
106
|
-
*/
|
|
107
|
-
function platformEntrypointOf(specifier) {
|
|
108
|
-
const { name, subpath } = splitSpecifier(specifier);
|
|
109
|
-
const owner = owningShell(specifier, name);
|
|
110
|
-
return {
|
|
111
|
-
shell: owner.shell,
|
|
112
|
-
id: joinEntrypoint(owner.shell, owner.entry, subpath)
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* The facade's own name for an internal specifier it republishes, or
|
|
117
|
-
* `undefined` when the facade does not carry that surface.
|
|
118
|
-
*/
|
|
119
|
-
function facadeEntrypoint(facade, name, subpath) {
|
|
120
|
-
const definition = publicShells.get(facade);
|
|
121
|
-
/* v8 ignore next -- @preserve: every ShellName is a key of publicShells */
|
|
122
|
-
if (definition === void 0) throw new ImportRootError(`unknown shell ${facade}`);
|
|
123
|
-
if (definition.kind !== "facade") throw new ImportRootError(`${facade} is a ${definition.kind} shell, not a facade`);
|
|
124
|
-
for (const reexport of definition.reexports ?? []) {
|
|
125
|
-
if (reexport.package !== name) continue;
|
|
126
|
-
if (subpath === "" && reexport.root === false) return void 0;
|
|
127
|
-
if (reexport.subpaths !== void 0 && !reexport.subpaths.includes(subpath)) return void 0;
|
|
128
|
-
return joinEntrypoint(facade, reexport.entry, subpath);
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function describe(root) {
|
|
132
|
-
return root.mode === "facade" ? `${root.mode} (${root.facade})` : root.mode;
|
|
133
|
-
}
|
|
134
|
-
function resolveImportSpecifier(specifier, root) {
|
|
135
|
-
if (root.mode === "internal") return specifier;
|
|
136
|
-
if (!specifier.startsWith(INTERNAL_SCOPE)) return specifier;
|
|
137
|
-
const { name, subpath } = splitSpecifier(specifier);
|
|
138
|
-
if (root.mode === "facade") {
|
|
139
|
-
const republished = facadeEntrypoint(root.facade, name, subpath);
|
|
140
|
-
if (republished !== void 0) return republished;
|
|
141
|
-
}
|
|
142
|
-
const owner = owningShell(specifier, name);
|
|
143
|
-
const published = joinEntrypoint(owner.shell, owner.entry, subpath);
|
|
144
|
-
if (!directDependencyShells(root).has(owner.shell)) throw new ImportRootError(unreachableUnder(specifier, published, root));
|
|
145
|
-
return published;
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Why a specifier has no name under `root`.
|
|
149
|
-
*
|
|
150
|
-
* The facade wording deliberately does not say "not a direct dependency":
|
|
151
|
-
* under ADR 242 the answer to that is never "install the platform package
|
|
152
|
-
* too", it is that the facade has to republish the surface.
|
|
153
|
-
*/
|
|
154
|
-
function unreachableUnder(specifier, published, root) {
|
|
155
|
-
if (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).`;
|
|
156
|
-
return `${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).`;
|
|
157
|
-
}
|
|
158
|
-
function createImportSpecifierResolver(root) {
|
|
159
|
-
if (root.mode === "internal") return (specifier) => specifier;
|
|
160
|
-
return (specifier) => resolveImportSpecifier(specifier, root);
|
|
161
|
-
}
|
|
162
|
-
/**
|
|
163
|
-
* Builds the resolver `prisma orm init` scaffolds with. Identical to
|
|
164
|
-
* {@link createImportSpecifierResolver} except that it will not accept a root
|
|
165
|
-
* a scaffold cannot express, so the impossible case is rejected where the
|
|
166
|
-
* resolver is made rather than when a template happens to hit a name.
|
|
167
|
-
*/
|
|
168
|
-
function createScaffoldSpecifierResolver(root) {
|
|
169
|
-
return createImportSpecifierResolver(root);
|
|
170
|
-
}
|
|
171
|
-
const MODULE_SPECIFIER = /\b(?:from|import)\s*\(?\s*(['"])([^'"\n]+)\1/g;
|
|
172
|
-
/**
|
|
173
|
-
* True when `source` contains module syntax that must carry a quoted
|
|
174
|
-
* specifier: `import '<s>'`, `import('<s>')`, or an import/export clause
|
|
175
|
-
* followed by `from '<s>'`.
|
|
176
|
-
*
|
|
177
|
-
* Deliberately independent of {@link MODULE_SPECIFIER} — it exists to notice
|
|
178
|
-
* when that scanner has stopped matching, so it accepts any quote character,
|
|
179
|
-
* including the backtick a renderer must never emit. It does still require a
|
|
180
|
-
* quote: the word "import" on its own appears in prose and comments all the
|
|
181
|
-
* time, and treating that as module syntax made the check below fire on files
|
|
182
|
-
* that have no imports at all.
|
|
183
|
-
*/
|
|
184
|
-
const HAS_IMPORT_SYNTAX = /(?:^|[\s(;}])import\s*[('"`]|(?:^|[\s;}])(?:import|export)\b[\w$*,{}\s]*?\bfrom\s*['"`]/;
|
|
185
|
-
/** The module specifiers a generated source file names. */
|
|
186
|
-
function importedSpecifiers(source) {
|
|
187
|
-
return [...source.matchAll(MODULE_SPECIFIER)].map(([, , specifier]) => specifier ?? "");
|
|
188
|
-
}
|
|
189
|
-
/**
|
|
190
|
-
* The specifiers in a generated file that the application would not have as a
|
|
191
|
-
* direct dependency under `root` — the thing no emitted file may contain.
|
|
192
|
-
*
|
|
193
|
-
* Under the `internal` root nothing is reported: those names are the
|
|
194
|
-
* repository's own, and every in-repo consumer resolves them through the
|
|
195
|
-
* workspace.
|
|
196
|
-
*
|
|
197
|
-
* Throws rather than returning `[]` when the source plainly has imports but
|
|
198
|
-
* the scan found none. An audit whose scanner has stopped matching would
|
|
199
|
-
* otherwise report every file as clean, which is the one failure mode that
|
|
200
|
-
* makes the audit worse than not having it.
|
|
201
|
-
*/
|
|
202
|
-
function transitiveImports(source, root) {
|
|
203
|
-
const specifiers = importedSpecifiers(source);
|
|
204
|
-
if (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");
|
|
205
|
-
if (root.mode === "internal") return [];
|
|
206
|
-
const direct = new Set(directDependencyShells(root));
|
|
207
|
-
return specifiers.filter((specifier) => {
|
|
208
|
-
if (specifier.startsWith(INTERNAL_SCOPE)) return true;
|
|
209
|
-
if (!specifier.startsWith(PUBLISHED_SCOPE)) return false;
|
|
210
|
-
const [scope, shell] = specifier.split("/");
|
|
211
|
-
const name = `${scope}/${shell}`;
|
|
212
|
-
return !direct.has(name) && !EXTERNAL_DIRECT_DEPENDENCIES.has(name);
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
/**
|
|
216
|
-
* Published packages this workspace does not own but `init` installs into a
|
|
217
|
-
* scaffolded application directly, so its files may import them:
|
|
218
|
-
* `@prisma/cli-engine` is the config file's `definePrismaConfig` import.
|
|
219
|
-
*/
|
|
220
|
-
const EXTERNAL_DIRECT_DEPENDENCIES = /* @__PURE__ */ new Set(["@prisma/cli-engine"]);
|
|
221
|
-
//#endregion
|
|
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
|
-
|
|
224
|
-
//# sourceMappingURL=import-roots-Dqs1_cn4.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"import-roots-Dqs1_cn4.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;AAC3C,MAAM,qBAAqB,EAAE,MAAM,WAAW;;;;;;;;;;;;;;;;;AAiB9C,SAAS,0BAA0B,cAA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BAAyB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-BhNbc269.d.mts","names":[],"sources":["../../../../1-framework/3-tooling/config-loader/dist/exports/index.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;iBAoBiB,qBAAqB,0CAA0C;;;;;iBAK/D,0BAA0B,6BAA6B;;;;cAI1D;;;;;;KAMT;iBACY,gBAAgB,gBAAgB,SAAS;;;;;;;;cAQ5C,+DAA+D;EAC3E;IACE;IACA;IACA;IACA;IACA,QAAQ;IACR;;EAEF;IACE;IACA;IACA;IACA;IACA,QAAQ;IACR;;EAEF;IACE;IACA;IACA;IACA;IACA,QAAQ;IACR;;EAEF,qDAAqD;IACnD,MAAM,6CAA6C,8CAA8C;;EAEnG;IACE;IACA;IACA;IACA;IACA,QAAQ;IACR;;EAEF;IACE;IACA;IACA;IACA;IACA,QAAQ;IACR;;EAEF;IACE;;EAEF;IACE;MACE,MAAM;MACN;MACA,WAAW,iCAAiC;MAC5C;QACE;;;IAGJ,SAAS,6CAA6C,8CAA8C;;EAEtG;IACE;IACA;;;EAGF,OAAO,iCAAiC;;;;;;;;cAQ5B,kBAAkB,cAAgB;;;;;iBAK/B,mBAAmB,cAAc,YAAY,oBAAoB,kBAAkB,iBAAiB;;;cAGvG;;;;;;;;UAQJ;WACC,QAAQ;WACR,sBAAsB;;iBAEhB,6BAA6B,mBAAmB;;;;;;iBAMhD,kBAAkB,WAAW,yBAAyB,oBAAoB;;UAEjF;WACC;;WAEA,UAAU,SAAS;;;UAGpB;;WAEC,gBAAgB;;WAEhB,QAAQ,SAAS;;;;;;;;;iBASX,gBAAgB,qBAAqB;WAC3C;IACP,QAAQ,OAAO,aAAa;;;;;;;;iBAQf,qBAAqB,oBAAoB;WAC/C;IACP,QAAQ,gBAAgB;;;;;;;;;;iBAUX,WAAW,qBAAqB;WACtC;IACP,QAAQ,OAAO,gBAAc;;;;;;iBAMhB,sBAAsB,QAAQ,gBAAc,mBAAmB,oBAAkB,OAAO,cAAgB;;;;;;iBAMxG,sBAAsB,gCAAgC,mBAAmB,oBAAkB,QAAQ,OAAO,cAAgB;iBAC1H,kBAAkB,mBAAmB,QAAQ,OAAO,gBAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
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;CACf;CACA,IAAI,QAAQ,YAAY,MAAM;EAC7B,iBAAiB,MAAM;GACtB,GAAG;GACH,SAAS,QAAQ;EAClB,CAAC;EACD,OAAO;CACR;CACA,IAAI,QAAQ,sBAAsB,UAAU,KAAK,yIAAyI;CAC1L,IAAI,QAAQ,sBAAsB,WAAW,KAAK,qFAAqF;CACvI,KAAK,qEAAqE;CAC1E,IAAI,CAAC,QAAQ,iBAAiB;EAC7B,KAAK,wBAAwB,QAAQ,YAAY,GAAG;EACpD,KAAK,uBAAuB,QAAQ,WAAW,gCAAgC;CAChF,OAAO,KAAK,uBAAuB,QAAQ,WAAW,kBAAkB,QAAQ,YAAY,IAAI;CAChG,KAAK,gFAAgF;CACrF,KAAK,mGAAmG;CACxG,OAAO;AACR;;AAEA,MAAM,6BAA6B,CAAC,qIAAqI,iCAAiC;AAC1M,MAAM,eAAe;AACrB,MAAM,sBAAsB;AAC5B,MAAM,oBAAoB;AAC1B,MAAM,wBAAwB;AAC9B,MAAM,+BAA+B;AACrC,MAAM,oBAAoB;;;;;AAK1B,SAAS,iBAAiB,MAAM,SAAS;CACxC,MAAM,QAAQ,QAAQ,QAAQ;CAC9B,MAAM,YAAY,MAAM,WAAW,IAAI,KAAK,kBAAkB,MAAM,KAAK,IAAI,EAAE;CAC/E,KAAK,qEAAqE;CAC1E,IAAI,QAAQ,sBAAsB,UAAU,KAAK,0IAA0I,WAAW;CACtM,IAAI,QAAQ,sBAAsB,WAAW,KAAK,qFAAqF,MAAM,WAAW,IAAI,KAAK,eAAe,MAAM,KAAK,IAAI,IAAI,EAAE;CACrM,IAAI,CAAC,QAAQ,iBAAiB,KAAK,wBAAwB,QAAQ,YAAY,GAAG;CAClF,KAAK,YAAY;CACjB,KAAK,mBAAmB;CACxB,KAAK,iBAAiB;CACtB,IAAI,QAAQ,QAAQ,aAAa,KAAK,qBAAqB;CAC3D,KAAK,4BAA4B;CACjC,KAAK,iBAAiB;AACvB"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { a as ShellReexportMapping, i as ShellPackageMapping, n as ShellKind, o as excludedSubpaths, r as ShellName, s as publicShells, t as ShellDefinition } from "./shells-D7NNxMLT.mjs";
|
|
2
|
-
import { a as ScaffoldImportRoot, c as createScaffoldSpecifierResolver, d as importedSpecifiers, f as internalImportRoot, h as transitiveImports, i as ImportSpecifierResolver, l as directDependencyShells, m as resolveImportSpecifier, n as ImportRootError, o as buildOwnerIndex, p as platformEntrypointOf, r as ImportRootMode, s as createImportSpecifierResolver, t as ImportRoot, u as importRootForDependencies } from "./import-roots-DlSoi7oS.mjs";
|
|
3
|
-
export { ImportRoot, ImportRootError, ImportRootMode, ImportSpecifierResolver, ScaffoldImportRoot, ShellDefinition, ShellKind, ShellName, ShellPackageMapping, ShellReexportMapping, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, excludedSubpaths, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, publicShells, resolveImportSpecifier, transitiveImports };
|
package/dist/publish-surface.mjs
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { n as publicShells, t as excludedSubpaths } from "./shells-BA7YJyPT.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-Dqs1_cn4.mjs";
|
|
3
|
-
export { ImportRootError, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, excludedSubpaths, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, publicShells, resolveImportSpecifier, transitiveImports };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as ScaffoldImportRoot, c as createScaffoldSpecifierResolver, d as importedSpecifiers, f as internalImportRoot, h as transitiveImports, i as ImportSpecifierResolver, l as directDependencyShells, m as resolveImportSpecifier, n as ImportRootError, o as buildOwnerIndex, p as platformEntrypointOf, r as ImportRootMode, s as createImportSpecifierResolver, t as ImportRoot, u as importRootForDependencies } from "./import-roots-DlSoi7oS.mjs";
|
|
2
|
-
export { ImportRoot, ImportRootError, ImportRootMode, ImportSpecifierResolver, ScaffoldImportRoot, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, resolveImportSpecifier, transitiveImports };
|
|
@@ -1,2 +0,0 @@
|
|
|
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-Dqs1_cn4.mjs";
|
|
2
|
-
export { ImportRootError, buildOwnerIndex, createImportSpecifierResolver, createScaffoldSpecifierResolver, directDependencyShells, importRootForDependencies, importedSpecifiers, internalImportRoot, platformEntrypointOf, resolveImportSpecifier, transitiveImports };
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { a as ShellReexportMapping, i as ShellPackageMapping, n as ShellKind, o as excludedSubpaths, r as ShellName, s as publicShells, t as ShellDefinition } from "./shells-D7NNxMLT.mjs";
|
|
2
|
-
export { ShellDefinition, ShellKind, ShellName, ShellPackageMapping, ShellReexportMapping, excludedSubpaths, publicShells };
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
# Welcome to Prisma ORM!
|
|
2
|
-
|
|
3
|
-
Prisma ORM lets you query your database in simple, easy-to-read TypeScript. Define what your data looks like, and Prisma ORM gives you a fully typed client — with autocomplete for every collection, field, and relation.
|
|
4
|
-
|
|
5
|
-
This project is set up for MongoDB. Prisma ORM also supports other databases.
|
|
6
|
-
|
|
7
|
-
{{requirements}}
|
|
8
|
-
|
|
9
|
-
## Your data contract
|
|
10
|
-
|
|
11
|
-
Your data contract is the heart of your application. It lives at [`{{schemaPath}}`]({{schemaPath}}) and describes your models:
|
|
12
|
-
|
|
13
|
-
{{schemaSample}}
|
|
14
|
-
|
|
15
|
-
Every model you define in your contract can be queried from your app. Your editor will autocomplete the query methods and show you what type each field is:
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { db } from '{{dbImportPath}}';
|
|
19
|
-
|
|
20
|
-
const user = await db.orm.users
|
|
21
|
-
.where({ email: 'alice@example.com' })
|
|
22
|
-
.first();
|
|
23
|
-
|
|
24
|
-
// Your editor will show the type of user as
|
|
25
|
-
// { id: ObjectId; email: string; username: string | null; name: string | null; posts: Post[] } | null
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
`db` connects to MongoDB lazily on the first query, so there is no manual `connect(...)` step in your application code. Call `await db.close()` if you need to release the underlying connection (typically only in tests or short-lived scripts). After `close()` the client is single-shot — any further query, `connect()`, or `runtime()` call rejects with `"Mongo client is closed"`. Construct a new `mongo({...})` if you need to use it again.
|
|
29
|
-
|
|
30
|
-
Your contract has two companion files in the same directory:
|
|
31
|
-
|
|
32
|
-
- **`contract.json`** — this tells your application what models exist, just like `package-lock.json` tells your package manager what dependencies your project has
|
|
33
|
-
- **`contract.d.ts`** — this powers autocomplete and type checking in your editor
|
|
34
|
-
|
|
35
|
-
Commit both files to git. When you change your contract, run `{{pkgRun}} contract emit` to update them.
|
|
36
|
-
|
|
37
|
-
If you use a framework like Next.js or Vite, the Prisma ORM plugin will do this for you automatically.
|
|
38
|
-
|
|
39
|
-
## Configuration
|
|
40
|
-
|
|
41
|
-
[`prisma.config.ts`](prisma.config.ts) tells the CLI where your contract lives and how to connect to your database. It loads environment variables from `.env` automatically:
|
|
42
|
-
|
|
43
|
-
```typescript
|
|
44
|
-
import 'dotenv/config';
|
|
45
|
-
import { definePrismaConfig } from '@prisma/cli-engine';
|
|
46
|
-
import { defineConfig as ormConfig } from '{{configEntrypoint}}';
|
|
47
|
-
|
|
48
|
-
export default definePrismaConfig({
|
|
49
|
-
orm: ormConfig({
|
|
50
|
-
contract: './{{schemaPath}}',
|
|
51
|
-
db: {
|
|
52
|
-
connection: process.env['DATABASE_URL']!,
|
|
53
|
-
},
|
|
54
|
-
}),
|
|
55
|
-
});
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
Notice the `DATABASE_URL` above? It's defined in your [`.env`](./.env) file:
|
|
59
|
-
|
|
60
|
-
```env
|
|
61
|
-
DATABASE_URL="mongodb://localhost:27017/mydb"
|
|
62
|
-
```
|
|
63
|
-
|
|
64
|
-
You can customize how your environment variables are loaded by changing or removing the `import 'dotenv/config'` line.
|
|
65
|
-
|
|
66
|
-
## Quick reference
|
|
67
|
-
|
|
68
|
-
### Commands
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
{{pkgRun}} contract emit # Update contract.json and contract.d.ts
|
|
72
|
-
{{pkgRun}} db init # Create collections in the database
|
|
73
|
-
{{pkgRun}} migration status # Show migration status
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
### Files
|
|
77
|
-
|
|
78
|
-
| File | Purpose |
|
|
79
|
-
|---|---|
|
|
80
|
-
| [`{{schemaPath}}`]({{schemaPath}}) | Your data contract — define your models here |
|
|
81
|
-
| [`prisma.config.ts`](prisma.config.ts) | CLI configuration |
|
|
82
|
-
| [`{{schemaDir}}/db.ts`]({{schemaDir}}/db.ts) | Database client — `import { db } from '{{dbImportPath}}'` |
|
|
83
|
-
| `{{schemaDir}}/contract.json` | Compiled contract (generated) |
|
|
84
|
-
| `{{schemaDir}}/contract.d.ts` | Contract types (generated) |
|
|
85
|
-
|
|
86
|
-
### Workflow
|
|
87
|
-
|
|
88
|
-
1. Edit [`{{schemaPath}}`]({{schemaPath}}) to add or change models.
|
|
89
|
-
2. Run `{{pkgRun}} contract emit` to regenerate the contract.
|
|
90
|
-
3. Query your models — your IDE will autocomplete everything.
|
|
91
|
-
|
|
92
|
-
## Transactions and change streams (Mongo)
|
|
93
|
-
|
|
94
|
-
Multi-document transactions and change streams require MongoDB to run as a **replica set** — even single-node setups for development. A standalone `mongod` will reject `withTransaction()` at runtime. For local development you have a few options:
|
|
95
|
-
|
|
96
|
-
- **Docker Compose:** start `mongo` with `--replSet rs0` and run `rs.initiate()` once.
|
|
97
|
-
- **`mongodb-memory-server`:** use `MongoMemoryReplSet` instead of `MongoMemoryServer` in tests.
|
|
98
|
-
- **MongoDB Atlas:** every Atlas cluster is already a replica set.
|
|
99
|
-
|
|
100
|
-
The transaction API (`db.transaction(...)`) is on the roadmap and tracked under [TML-2313](https://linear.app/prisma-company/issue/TML-2313/mongo-dev-replica-set-story-is-missing-transactions-change-streams). Prisma ORM's Mongo facade does not expose it yet — until that ticket lands, drive transactions yourself with a raw `MongoClient` using the escape hatch in the next section.
|
|
101
|
-
|
|
102
|
-
## Escape hatches
|
|
103
|
-
|
|
104
|
-
The ORM covers the common cases. For the rest, two escape hatches are designed in:
|
|
105
|
-
|
|
106
|
-
- **Typed raw aggregations — `db.query`.** The facade exposes `db.query`, a typed builder for aggregation pipelines that runs through the same runtime + middleware + codec stack as `db.orm`. Reach for it when the ORM can't express a `$lookup`/`$facet`/`$graphLookup`/window-function pipeline.
|
|
107
|
-
- **Direct `mongodb` driver control — `mongoClient` binding.** Construct your own `MongoClient` and pass it to `mongo({ contract, mongoClient, dbName })`. Your code keeps the `MongoClient` reference and uses it directly (transactions, change streams, sessions, anything Prisma ORM doesn't surface yet); the same `db` object continues to give you the typed ORM.
|
|
108
|
-
|
|
109
|
-
`db.runtime()` is **not** the escape hatch — it returns the internal executor (`MongoRuntime`), not a `mongodb` `MongoClient` or `Db`. Use `db.query` for raw aggregations and the `mongoClient` binding for direct driver control.
|
|
110
|
-
|
|
111
|
-
## Monorepo notes (pnpm workspaces)
|
|
112
|
-
|
|
113
|
-
If this project lives inside a pnpm workspace, a few things are worth knowing:
|
|
114
|
-
|
|
115
|
-
- **Catalogs.** When the workspace's `pnpm-workspace.yaml` defines a `catalogs` entry for `prisma` or `{{pkg}}`, pnpm uses the catalog version everywhere — `init` does too. If you wanted the published `latest` instead, update or remove the catalog entry, then re-run `pnpm install`.
|
|
116
|
-
- **`pnpm dlx`.** `pnpm dlx prisma@latest orm init …` works in any directory. Inside a workspace, pnpm still resolves dependencies through the workspace's catalog/overrides rather than the registry; expect the installed Prisma ORM packages to reflect the workspace's catalog rather than `latest`.
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
# Welcome to Prisma ORM!
|
|
2
|
-
|
|
3
|
-
Prisma ORM lets you query your database in simple, easy-to-read TypeScript. Define what your data looks like, and Prisma ORM gives you a fully typed client — with autocomplete for every table, column, and relation.
|
|
4
|
-
|
|
5
|
-
This project is set up for PostgreSQL. Prisma ORM also supports other databases.
|
|
6
|
-
|
|
7
|
-
{{requirements}}
|
|
8
|
-
|
|
9
|
-
## Your data contract
|
|
10
|
-
|
|
11
|
-
Your data contract is the heart of your application. It lives at [`{{schemaPath}}`]({{schemaPath}}) and describes your models:
|
|
12
|
-
|
|
13
|
-
{{schemaSample}}
|
|
14
|
-
|
|
15
|
-
Every model you define in your contract can be queried from your app. Your editor will autocomplete the query methods and show you what type each model field is:
|
|
16
|
-
|
|
17
|
-
```typescript
|
|
18
|
-
import { db } from '{{dbImportPath}}';
|
|
19
|
-
|
|
20
|
-
const user = await db.orm.public.User
|
|
21
|
-
.where({ email: 'alice@example.com' })
|
|
22
|
-
.first();
|
|
23
|
-
|
|
24
|
-
// Your editor will show the type of user as
|
|
25
|
-
// { id: number; email: string; username: string | null; name: string | null; createdAt: Date; posts: Post[] } | null
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
Your contract has two companion files in the same directory:
|
|
29
|
-
|
|
30
|
-
- **`contract.json`** — this tells your application what models exist, just like `package-lock.json` tells your package manager what dependencies your project has
|
|
31
|
-
- **`contract.d.ts`** — this powers autocomplete and type checking in your editor
|
|
32
|
-
|
|
33
|
-
Commit both files to git. When you change your contract, run `{{pkgRun}} contract emit` to update them.
|
|
34
|
-
|
|
35
|
-
If you use a framework like Next.js or Vite, the Prisma ORM plugin will do this for you automatically.
|
|
36
|
-
|
|
37
|
-
## Configuration
|
|
38
|
-
|
|
39
|
-
[`prisma.config.ts`](prisma.config.ts) tells the CLI where your contract lives and how to connect to your database. It loads environment variables from `.env` automatically:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import 'dotenv/config';
|
|
43
|
-
import { definePrismaConfig } from '@prisma/cli-engine';
|
|
44
|
-
import { defineConfig as ormConfig } from '{{configEntrypoint}}';
|
|
45
|
-
|
|
46
|
-
export default definePrismaConfig({
|
|
47
|
-
orm: ormConfig({
|
|
48
|
-
contract: './{{schemaPath}}',
|
|
49
|
-
db: {
|
|
50
|
-
connection: process.env['DATABASE_URL']!,
|
|
51
|
-
},
|
|
52
|
-
}),
|
|
53
|
-
});
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Notice the `DATABASE_URL` above? It's defined in your [`.env`](./.env) file:
|
|
57
|
-
|
|
58
|
-
```env
|
|
59
|
-
DATABASE_URL="postgresql://user:password@localhost:5432/mydb"
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
You can customize how your environment variables are loaded by changing or removing the `import 'dotenv/config'` line.
|
|
63
|
-
|
|
64
|
-
## Quick reference
|
|
65
|
-
|
|
66
|
-
### Commands
|
|
67
|
-
|
|
68
|
-
```bash
|
|
69
|
-
{{pkgRun}} contract emit # Update contract.json and contract.d.ts
|
|
70
|
-
{{pkgRun}} db init # Create tables in the database
|
|
71
|
-
{{pkgRun}} migration status # Show migration status
|
|
72
|
-
```
|
|
73
|
-
|
|
74
|
-
### Files
|
|
75
|
-
|
|
76
|
-
| File | Purpose |
|
|
77
|
-
|---|---|
|
|
78
|
-
| [`{{schemaPath}}`]({{schemaPath}}) | Your data contract — define your models here |
|
|
79
|
-
| [`prisma.config.ts`](prisma.config.ts) | CLI configuration |
|
|
80
|
-
| [`{{schemaDir}}/db.ts`]({{schemaDir}}/db.ts) | Database client — `import { db } from '{{dbImportPath}}'` |
|
|
81
|
-
| `{{schemaDir}}/contract.json` | Compiled contract (generated) |
|
|
82
|
-
| `{{schemaDir}}/contract.d.ts` | Contract types (generated) |
|
|
83
|
-
|
|
84
|
-
### Workflow
|
|
85
|
-
|
|
86
|
-
1. Edit [`{{schemaPath}}`]({{schemaPath}}) to add or change models.
|
|
87
|
-
2. Run `{{pkgRun}} contract emit` to regenerate the contract.
|
|
88
|
-
3. Query your models — your IDE will autocomplete everything.
|
|
89
|
-
|
|
90
|
-
## Monorepo notes (pnpm workspaces)
|
|
91
|
-
|
|
92
|
-
If this project lives inside a pnpm workspace, a few things are worth knowing:
|
|
93
|
-
|
|
94
|
-
- **Catalogs.** When the workspace's `pnpm-workspace.yaml` defines a `catalogs` entry for `prisma` or `{{pkg}}`, pnpm uses the catalog version everywhere — `init` does too. If you wanted the published `latest` instead, update or remove the catalog entry, then re-run `pnpm install`.
|
|
95
|
-
- **`pnpm dlx`.** `pnpm dlx prisma@latest orm init …` works in any directory. Inside a workspace, pnpm still resolves dependencies through the workspace's catalog/overrides rather than the registry; expect the installed Prisma ORM packages to reflect the workspace's catalog rather than `latest`.
|
|
@@ -1,80 +0,0 @@
|
|
|
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.
|
package/dist/readme-mongo.md
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
# {{projectName}}
|
|
2
|
-
|
|
3
|
-
Generated by `prisma orm init` with the Minimal template.
|
|
4
|
-
|
|
5
|
-
## First run
|
|
6
|
-
|
|
7
|
-
1. `{{runDbUp}}` — start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
8
|
-
2. `{{runDev}}` — runs `src/index.ts`, which writes one row and reads it back.
|
|
9
|
-
|
|
10
|
-
## Available scripts
|
|
11
|
-
|
|
12
|
-
- `{{runDev}}` — run the Prisma ORM sample script
|
|
13
|
-
|
|
14
|
-
### Database and migrations
|
|
15
|
-
|
|
16
|
-
- `{{runContractEmit}}` — emit contract artifacts after contract changes
|
|
17
|
-
- `{{runDbUp}}` — start the local MongoDB replica set with `mongodb-memory-server`. Data persists in `.mongo-data/` across restarts.
|
|
18
|
-
- `{{runDbDown}}` — stop the local MongoDB process (data preserved)
|
|
19
|
-
- `{{runDbReset}}` — stop and wipe `.mongo-data/` for a clean slate
|
|
20
|
-
- `{{runMigrationPlan}}` — create a MongoDB migration plan
|
|
21
|
-
- `{{runMigrate}}` — apply the planned MongoDB migration
|
|
22
|
-
- `{{runDbSeed}}` — insert sample users manually
|
|
23
|
-
|
|
24
|
-
## Prisma ORM
|
|
25
|
-
|
|
26
|
-
Prisma ORM setup is scaffolded in:
|
|
27
|
-
|
|
28
|
-
- `{{contractPath}}`
|
|
29
|
-
- `prisma.config.ts`
|
|
30
|
-
- `prisma/db.ts`
|
|
31
|
-
- `src/lib/prisma.ts`
|
|
32
|
-
|
|
33
|
-
For provider-specific Prisma ORM reference docs, see `prisma-8.md`. Prisma ORM skills live in the upstream `skills/` directory: https://github.com/prisma/prisma/tree/main/skills.
|
|
34
|
-
|
|
35
|
-
Node-based Prisma ORM projects expect Node.js 24 LTS or newer.
|