@prisma/internals 6.6.0 → 6.7.0-dev.10
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/{chunk-2JBXOLXL.js → chunk-37VFNYDN.js} +8 -8
- package/dist/{chunk-RMLLA4MJ.js → chunk-3YTH3LTS.js} +5 -5
- package/dist/{chunk-R2TLNOWM.js → chunk-6BENCJWK.js} +5 -5
- package/dist/{chunk-C6CLGEHZ.js → chunk-6TCOHSIQ.js} +8 -8
- package/dist/{chunk-TZ7QN7B5.js → chunk-ANRRALG6.js} +5 -5
- package/dist/chunk-CHOXBASF.js +44 -0
- package/dist/{chunk-RKUASVCY.js → chunk-CI74URJJ.js} +7 -7
- package/dist/{chunk-7LPMJRUK.js → chunk-CKGYGP5K.js} +8 -8
- package/dist/{chunk-EVK7A7GF.js → chunk-DMAV353H.js} +5 -5
- package/dist/{chunk-37SOLWL3.js → chunk-DUZ7VTLL.js} +5 -5
- package/dist/{chunk-HG3YOAAE.js → chunk-FYZCPL2Z.js} +7 -8
- package/dist/{chunk-M3NEJQPR.js → chunk-IAPYMRWB.js} +5 -5
- package/dist/{chunk-I7NBPZBO.js → chunk-K4VD7DL5.js} +5 -5
- package/dist/{chunk-S7FWTZ4D.js → chunk-KQ6L53YO.js} +8 -8
- package/dist/{chunk-CFIXRANP.js → chunk-KSEX3ZQS.js} +6 -6
- package/dist/{chunk-67I7CEQJ.js → chunk-MY5KA4VU.js} +12 -329
- package/dist/{chunk-A4GRMJJI.js → chunk-NFMKETO5.js} +38 -432
- package/dist/{chunk-DSO2BAJY.js → chunk-OBDAVBAO.js} +7 -7
- package/dist/{chunk-DKSUHQGA.js → chunk-ONPT5QRX.js} +5 -5
- package/dist/{chunk-UZFWYQZJ.js → chunk-P3Y54DBD.js} +5 -5
- package/dist/{chunk-B4AYGGZW.js → chunk-PD4UCNF3.js} +8 -8
- package/dist/{chunk-3DQANJMY.js → chunk-PRGTOMXU.js} +5 -5
- package/dist/chunk-PSFQKG2Q.js +6291 -0
- package/dist/chunk-Q6ZVYPDB.js +41 -0
- package/dist/{chunk-DCWEKWHT.js → chunk-QOMMMKJO.js} +38 -432
- package/dist/chunk-QS3WUGE3.js +341 -0
- package/dist/{chunk-XRNBEUVE.js → chunk-R37TYWYY.js} +5 -5
- package/dist/{chunk-XO424ERB.js → chunk-UZARHCFS.js} +8 -8
- package/dist/{chunk-KB5DKCI4.js → chunk-W67YF34Y.js} +7 -7
- package/dist/chunk-WCPUXXL2.js +183 -0
- package/dist/chunk-ZCBEMBHR.js +242 -0
- package/dist/chunk-ZIFBTC6Y.js +6440 -0
- package/dist/cli/checkUnsupportedDataProxy.js +26 -20
- package/dist/cli/checkUnsupportedSchemaEngineWasm.js +26 -20
- package/dist/cli/getSchema.js +8 -112
- package/dist/cli/hashes.js +6 -109
- package/dist/cli/schemaContext.js +26 -20
- package/dist/engine-commands/errorHelpers.js +4 -4
- package/dist/engine-commands/formatSchema.js +25 -19
- package/dist/engine-commands/getConfig.js +10 -10
- package/dist/engine-commands/getDmmf.js +7 -7
- package/dist/engine-commands/getEngineVersion.js +4 -4
- package/dist/engine-commands/getEnginesMetaInfo.js +6 -6
- package/dist/engine-commands/index.js +36 -30
- package/dist/engine-commands/lintSchema.js +8 -8
- package/dist/engine-commands/mergeSchemas.js +7 -7
- package/dist/engine-commands/validate.js +7 -7
- package/dist/get-generators/getGenerators.js +28 -22
- package/dist/getPackedPackage.js +6 -4
- package/dist/index.js +64 -58
- package/dist/resolveBinary.js +6 -6
- package/dist/resolvePkg.js +3 -2
- package/dist/schemaEngineCommands.js +7 -7
- package/dist/utils/getEnvPaths.js +5 -106
- package/dist/utils/getVersionFromPackageJson.js +3 -3
- package/dist/utils/loadEnvFile.js +6 -106
- package/dist/wasm.js +5 -5
- package/package.json +13 -13
- package/dist/chunk-MJIP3FY5.js +0 -12695
@@ -0,0 +1,242 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __create = Object.create;
|
3
|
+
var __defProp = Object.defineProperty;
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
8
|
+
var __export = (target, all) => {
|
9
|
+
for (var name in all)
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
11
|
+
};
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
14
|
+
for (let key of __getOwnPropNames(from))
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
17
|
+
}
|
18
|
+
return to;
|
19
|
+
};
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
26
|
+
mod
|
27
|
+
));
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
+
var chunk_ZCBEMBHR_exports = {};
|
30
|
+
__export(chunk_ZCBEMBHR_exports, {
|
31
|
+
getPrismaConfigFromPackageJson: () => getPrismaConfigFromPackageJson,
|
32
|
+
getSchemaFromPackageJson: () => getSchemaFromPackageJson,
|
33
|
+
getSchemaWithPath: () => getSchemaWithPath,
|
34
|
+
getSchemaWithPathOptional: () => getSchemaWithPathOptional,
|
35
|
+
printSchemaLoadedMessage: () => printSchemaLoadedMessage
|
36
|
+
});
|
37
|
+
module.exports = __toCommonJS(chunk_ZCBEMBHR_exports);
|
38
|
+
var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
|
39
|
+
var import_chunk_PSFQKG2Q = require("./chunk-PSFQKG2Q.js");
|
40
|
+
var import_debug = require("@prisma/debug");
|
41
|
+
var import_schema_files_loader = require("@prisma/schema-files-loader");
|
42
|
+
var import_fs = __toESM(require("fs"));
|
43
|
+
var import_path = __toESM(require("path"));
|
44
|
+
var import_util = require("util");
|
45
|
+
var readFile = (0, import_util.promisify)(import_fs.default.readFile);
|
46
|
+
var stat = (0, import_util.promisify)(import_fs.default.stat);
|
47
|
+
var debug = (0, import_debug.Debug)("prisma:getSchema");
|
48
|
+
async function getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
|
49
|
+
const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
|
50
|
+
if (result.ok) {
|
51
|
+
return result.schema;
|
52
|
+
}
|
53
|
+
throw new Error(renderDefaultLookupError(result.error, cwd));
|
54
|
+
}
|
55
|
+
async function getSchemaWithPathOptional(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
|
56
|
+
const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
|
57
|
+
if (result.ok) {
|
58
|
+
return result.schema;
|
59
|
+
}
|
60
|
+
return null;
|
61
|
+
}
|
62
|
+
function printSchemaLoadedMessage(schemaPath) {
|
63
|
+
process.stdout.write((0, import_chunk_PG5FDKSF.dim)(`Prisma schema loaded from ${import_path.default.relative(process.cwd(), schemaPath)}`) + "\n");
|
64
|
+
}
|
65
|
+
async function readSchemaFromSingleFile(schemaPath) {
|
66
|
+
debug("Reading schema from single file", schemaPath);
|
67
|
+
const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath, "file");
|
68
|
+
if (typeError) {
|
69
|
+
return { ok: false, error: typeError };
|
70
|
+
}
|
71
|
+
const file = await readFile(schemaPath, { encoding: "utf-8" });
|
72
|
+
const schemaTuple = [schemaPath, file];
|
73
|
+
return {
|
74
|
+
ok: true,
|
75
|
+
schema: { schemaPath, schemaRootDir: import_path.default.dirname(schemaPath), schemas: [schemaTuple] }
|
76
|
+
};
|
77
|
+
}
|
78
|
+
async function readSchemaFromDirectory(schemaPath) {
|
79
|
+
debug("Reading schema from multiple files", schemaPath);
|
80
|
+
const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath, "directory");
|
81
|
+
if (typeError) {
|
82
|
+
return { ok: false, error: typeError };
|
83
|
+
}
|
84
|
+
const files = await (0, import_schema_files_loader.loadSchemaFiles)(schemaPath);
|
85
|
+
return { ok: true, schema: { schemaPath, schemaRootDir: schemaPath, schemas: files } };
|
86
|
+
}
|
87
|
+
async function readSchemaFromFileOrDirectory(schemaPath) {
|
88
|
+
let stats;
|
89
|
+
try {
|
90
|
+
stats = await stat(schemaPath);
|
91
|
+
} catch (e) {
|
92
|
+
if (e.code === "ENOENT") {
|
93
|
+
return { ok: false, error: { kind: "NotFound", path: schemaPath } };
|
94
|
+
}
|
95
|
+
throw e;
|
96
|
+
}
|
97
|
+
if (stats.isFile()) {
|
98
|
+
return readSchemaFromSingleFile(schemaPath);
|
99
|
+
}
|
100
|
+
if (stats.isDirectory()) {
|
101
|
+
return readSchemaFromDirectory(schemaPath);
|
102
|
+
}
|
103
|
+
return { ok: false, error: { kind: "WrongType", path: schemaPath, expectedTypes: ["file", "directory"] } };
|
104
|
+
}
|
105
|
+
async function getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName }) {
|
106
|
+
if (schemaPathFromArgs) {
|
107
|
+
const absPath = import_path.default.resolve(cwd, schemaPathFromArgs);
|
108
|
+
const customSchemaResult = await readSchemaFromFileOrDirectory(absPath);
|
109
|
+
if (!customSchemaResult.ok) {
|
110
|
+
const relPath = import_path.default.relative(cwd, absPath);
|
111
|
+
throw new Error(
|
112
|
+
`Could not load \`${argumentName}\` from provided path \`${relPath}\`: ${renderLookupError(
|
113
|
+
customSchemaResult.error
|
114
|
+
)}`
|
115
|
+
);
|
116
|
+
}
|
117
|
+
return customSchemaResult;
|
118
|
+
}
|
119
|
+
const prismaConfigResult = await readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig);
|
120
|
+
if (prismaConfigResult.ok) {
|
121
|
+
return prismaConfigResult;
|
122
|
+
}
|
123
|
+
const pkgJsonResult = await getSchemaFromPackageJson(cwd);
|
124
|
+
if (pkgJsonResult.ok) {
|
125
|
+
return pkgJsonResult;
|
126
|
+
}
|
127
|
+
const defaultResult = await getDefaultSchema(cwd);
|
128
|
+
if (defaultResult.ok) {
|
129
|
+
return defaultResult;
|
130
|
+
}
|
131
|
+
return {
|
132
|
+
ok: false,
|
133
|
+
error: defaultResult.error
|
134
|
+
};
|
135
|
+
}
|
136
|
+
function renderLookupError(error) {
|
137
|
+
switch (error.kind) {
|
138
|
+
case "NotFound": {
|
139
|
+
const expected = error.expectedType ?? "file or directory";
|
140
|
+
return `${expected} not found`;
|
141
|
+
}
|
142
|
+
case "WrongType":
|
143
|
+
return `expected ${error.expectedTypes.join(" or ")}`;
|
144
|
+
}
|
145
|
+
}
|
146
|
+
function renderDefaultLookupError(error, cwd) {
|
147
|
+
const parts = [
|
148
|
+
`Could not find Prisma Schema that is required for this command.`,
|
149
|
+
`You can either provide it with ${(0, import_chunk_PG5FDKSF.green)("`--schema`")} argument,`,
|
150
|
+
`set it in your ${(0, import_chunk_PG5FDKSF.green)("`prisma.config.ts`")},`,
|
151
|
+
`set it as ${(0, import_chunk_PG5FDKSF.green)("`prisma.schema`")} in your ${(0, import_chunk_PG5FDKSF.green)("package.json")},`,
|
152
|
+
`or put it into the default location (${(0, import_chunk_PG5FDKSF.green)("`./prisma/schema.prisma`")}, or ${(0, import_chunk_PG5FDKSF.green)("`./schema.prisma`")}.`,
|
153
|
+
"Checked following paths:\n"
|
154
|
+
];
|
155
|
+
const printedPaths = /* @__PURE__ */ new Set();
|
156
|
+
for (const failure of error.failures) {
|
157
|
+
const filePath = failure.path;
|
158
|
+
if (!printedPaths.has(failure.path)) {
|
159
|
+
parts.push(`${import_path.default.relative(cwd, filePath)}: ${renderLookupError(failure.error)}`);
|
160
|
+
printedPaths.add(filePath);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
parts.push("\nSee also https://pris.ly/d/prisma-schema-location");
|
164
|
+
return parts.join("\n");
|
165
|
+
}
|
166
|
+
async function getPrismaConfigFromPackageJson(cwd) {
|
167
|
+
const pkgJson = await (0, import_chunk_PSFQKG2Q.readPackageUp)({ cwd, normalize: false });
|
168
|
+
const prismaPropertyFromPkgJson = pkgJson?.packageJson?.prisma;
|
169
|
+
if (!pkgJson) {
|
170
|
+
return null;
|
171
|
+
}
|
172
|
+
return {
|
173
|
+
data: prismaPropertyFromPkgJson,
|
174
|
+
packagePath: pkgJson.path
|
175
|
+
};
|
176
|
+
}
|
177
|
+
async function readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig) {
|
178
|
+
if (!schemaPathFromConfig) {
|
179
|
+
return {
|
180
|
+
ok: false,
|
181
|
+
error: { kind: "PrismaConfigNotConfigured" }
|
182
|
+
};
|
183
|
+
}
|
184
|
+
const schemaResult = await readSchemaFromFileOrDirectory(schemaPathFromConfig);
|
185
|
+
if (!schemaResult.ok) {
|
186
|
+
throw new Error(
|
187
|
+
`Could not load schema from \`${schemaPathFromConfig}\` provided by "prisma.config.ts"\`: ${renderLookupError(
|
188
|
+
schemaResult.error
|
189
|
+
)}`
|
190
|
+
);
|
191
|
+
}
|
192
|
+
return schemaResult;
|
193
|
+
}
|
194
|
+
async function getSchemaFromPackageJson(cwd) {
|
195
|
+
const prismaConfig = await getPrismaConfigFromPackageJson(cwd);
|
196
|
+
debug("prismaConfig", prismaConfig);
|
197
|
+
if (!prismaConfig || !prismaConfig.data?.schema) {
|
198
|
+
return { ok: false, error: { kind: "PackageJsonNotConfigured" } };
|
199
|
+
}
|
200
|
+
const schemaPathFromPkgJson = prismaConfig.data.schema;
|
201
|
+
if (typeof schemaPathFromPkgJson !== "string") {
|
202
|
+
throw new Error(
|
203
|
+
`Provided schema path \`${schemaPathFromPkgJson}\` from \`${import_path.default.relative(
|
204
|
+
cwd,
|
205
|
+
prismaConfig.packagePath
|
206
|
+
)}\` must be of type string`
|
207
|
+
);
|
208
|
+
}
|
209
|
+
const absoluteSchemaPath = import_path.default.isAbsolute(schemaPathFromPkgJson) ? schemaPathFromPkgJson : import_path.default.resolve(import_path.default.dirname(prismaConfig.packagePath), schemaPathFromPkgJson);
|
210
|
+
const lookupResult = await readSchemaFromFileOrDirectory(absoluteSchemaPath);
|
211
|
+
if (!lookupResult.ok) {
|
212
|
+
throw new Error(
|
213
|
+
`Could not load schema from \`${import_path.default.relative(
|
214
|
+
cwd,
|
215
|
+
absoluteSchemaPath
|
216
|
+
)}\` provided by "prisma.schema" config of \`${import_path.default.relative(
|
217
|
+
cwd,
|
218
|
+
prismaConfig.packagePath
|
219
|
+
)}\`: ${renderLookupError(lookupResult.error)}`
|
220
|
+
);
|
221
|
+
}
|
222
|
+
return lookupResult;
|
223
|
+
}
|
224
|
+
async function getDefaultSchema(cwd, failures = []) {
|
225
|
+
const lookupPaths = [import_path.default.join(cwd, "schema.prisma"), import_path.default.join(cwd, "prisma", "schema.prisma")];
|
226
|
+
for (const path2 of lookupPaths) {
|
227
|
+
debug(`Checking existence of ${path2}`);
|
228
|
+
const schema = await readSchemaFromSingleFile(path2);
|
229
|
+
if (!schema.ok) {
|
230
|
+
failures.push({ path: path2, error: schema.error });
|
231
|
+
continue;
|
232
|
+
}
|
233
|
+
return schema;
|
234
|
+
}
|
235
|
+
return {
|
236
|
+
ok: false,
|
237
|
+
error: {
|
238
|
+
kind: "NotFoundMultipleLocations",
|
239
|
+
failures
|
240
|
+
}
|
241
|
+
};
|
242
|
+
}
|