@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,41 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __defProp = Object.defineProperty;
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
6
|
+
var __export = (target, all) => {
|
7
|
+
for (var name in all)
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
9
|
+
};
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
12
|
+
for (let key of __getOwnPropNames(from))
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
15
|
+
}
|
16
|
+
return to;
|
17
|
+
};
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
19
|
+
var chunk_Q6ZVYPDB_exports = {};
|
20
|
+
__export(chunk_Q6ZVYPDB_exports, {
|
21
|
+
loadEnvFile: () => loadEnvFile
|
22
|
+
});
|
23
|
+
module.exports = __toCommonJS(chunk_Q6ZVYPDB_exports);
|
24
|
+
var import_chunk_WCPUXXL2 = require("./chunk-WCPUXXL2.js");
|
25
|
+
var import_chunk_2IP7H3BQ = require("./chunk-2IP7H3BQ.js");
|
26
|
+
async function loadEnvFile({
|
27
|
+
schemaPath,
|
28
|
+
config,
|
29
|
+
printMessage = false
|
30
|
+
}) {
|
31
|
+
if (config.loadedFromFile) {
|
32
|
+
process.stdout.write(`Prisma config detected, skipping environment variable loading.
|
33
|
+
`);
|
34
|
+
return;
|
35
|
+
}
|
36
|
+
const envPaths = await (0, import_chunk_WCPUXXL2.getEnvPaths)(schemaPath);
|
37
|
+
const envData = (0, import_chunk_2IP7H3BQ.tryLoadEnvs)(envPaths, { conflictCheck: "error" });
|
38
|
+
if (printMessage && envData && envData.message) {
|
39
|
+
process.stdout.write(envData.message + "\n");
|
40
|
+
}
|
41
|
+
}
|
@@ -26,35 +26,25 @@ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
|
|
26
26
|
mod
|
27
27
|
));
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
29
|
-
var
|
30
|
-
__export(
|
29
|
+
var chunk_QOMMMKJO_exports = {};
|
30
|
+
__export(chunk_QOMMMKJO_exports, {
|
31
31
|
checkUnsupportedDataProxy: () => checkUnsupportedDataProxy,
|
32
32
|
checkUnsupportedSchemaEngineWasm: () => checkUnsupportedSchemaEngineWasm,
|
33
33
|
forbiddenCmdFlagWithSchemaEngineWasm: () => forbiddenCmdFlagWithSchemaEngineWasm,
|
34
34
|
forbiddenCmdWithDataProxyFlagMessage: () => forbiddenCmdWithDataProxyFlagMessage,
|
35
35
|
formatSchema: () => formatSchema,
|
36
36
|
getBinaryTargetForCurrentPlatform: () => import_get_platform2.getBinaryTargetForCurrentPlatform,
|
37
|
-
getCLIPathHash: () => getCLIPathHash,
|
38
|
-
getEnvPaths: () => getEnvPaths,
|
39
37
|
getGenerator: () => getGenerator,
|
40
38
|
getGenerators: () => getGenerators,
|
41
39
|
getNodeAPIName: () => import_get_platform2.getNodeAPIName,
|
42
|
-
getPrismaConfigFromPackageJson: () => getPrismaConfigFromPackageJson,
|
43
|
-
getProjectHash: () => getProjectHash,
|
44
|
-
getSchemaFromPackageJson: () => getSchemaFromPackageJson,
|
45
|
-
getSchemaWithPath: () => getSchemaWithPath,
|
46
|
-
getSchemaWithPathOptional: () => getSchemaWithPathOptional,
|
47
40
|
knownBinaryTargets: () => knownBinaryTargets,
|
48
|
-
loadEnvFile: () => loadEnvFile,
|
49
41
|
loadSchemaContext: () => loadSchemaContext,
|
50
|
-
printSchemaLoadedMessage: () => printSchemaLoadedMessage,
|
51
42
|
processSchemaResult: () => processSchemaResult,
|
52
43
|
skipIndex: () => skipIndex
|
53
44
|
});
|
54
|
-
module.exports = __toCommonJS(
|
45
|
+
module.exports = __toCommonJS(chunk_QOMMMKJO_exports);
|
55
46
|
var import_chunk_X3P4J7WW = require("./chunk-X3P4J7WW.js");
|
56
47
|
var import_chunk_LRU47BGE = require("./chunk-LRU47BGE.js");
|
57
|
-
var import_chunk_2IP7H3BQ = require("./chunk-2IP7H3BQ.js");
|
58
48
|
var import_chunk_X77CS5RK = require("./chunk-X77CS5RK.js");
|
59
49
|
var import_chunk_EPXBOIA5 = require("./chunk-EPXBOIA5.js");
|
60
50
|
var import_chunk_RS2R7COT = require("./chunk-RS2R7COT.js");
|
@@ -62,13 +52,15 @@ var import_chunk_5V36RLCO = require("./chunk-5V36RLCO.js");
|
|
62
52
|
var import_chunk_5FJ3MENK = require("./chunk-5FJ3MENK.js");
|
63
53
|
var import_chunk_7QC5VORA = require("./chunk-7QC5VORA.js");
|
64
54
|
var import_chunk_AX5N26KG = require("./chunk-AX5N26KG.js");
|
55
|
+
var import_chunk_WCPUXXL2 = require("./chunk-WCPUXXL2.js");
|
65
56
|
var import_chunk_I6WLABB2 = require("./chunk-I6WLABB2.js");
|
66
57
|
var import_chunk_CRVLHWC5 = require("./chunk-CRVLHWC5.js");
|
67
|
-
var
|
68
|
-
var
|
69
|
-
var
|
70
|
-
var
|
71
|
-
var
|
58
|
+
var import_chunk_PD4UCNF3 = require("./chunk-PD4UCNF3.js");
|
59
|
+
var import_chunk_37VFNYDN = require("./chunk-37VFNYDN.js");
|
60
|
+
var import_chunk_R37TYWYY = require("./chunk-R37TYWYY.js");
|
61
|
+
var import_chunk_OBDAVBAO = require("./chunk-OBDAVBAO.js");
|
62
|
+
var import_chunk_ZCBEMBHR = require("./chunk-ZCBEMBHR.js");
|
63
|
+
var import_chunk_DUZ7VTLL = require("./chunk-DUZ7VTLL.js");
|
72
64
|
var import_chunk_ZJWZK45Z = require("./chunk-ZJWZK45Z.js");
|
73
65
|
var import_chunk_2B26F5N3 = require("./chunk-2B26F5N3.js");
|
74
66
|
var import_chunk_M3GBKLGE = require("./chunk-M3GBKLGE.js");
|
@@ -77,30 +69,15 @@ var import_chunk_LMVSIVKQ = require("./chunk-LMVSIVKQ.js");
|
|
77
69
|
var import_chunk_BPDMLM32 = require("./chunk-BPDMLM32.js");
|
78
70
|
var import_chunk_IOIAK7V7 = require("./chunk-IOIAK7V7.js");
|
79
71
|
var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
|
80
|
-
var
|
72
|
+
var import_chunk_ZIFBTC6Y = require("./chunk-ZIFBTC6Y.js");
|
81
73
|
var import_chunk_4VNS5WPM = require("./chunk-4VNS5WPM.js");
|
82
|
-
var import_debug = require("@prisma/debug");
|
83
|
-
var import_schema_files_loader = require("@prisma/schema-files-loader");
|
84
|
-
var import_fs = __toESM2(require("fs"));
|
85
74
|
var import_path = __toESM2(require("path"));
|
86
|
-
var
|
75
|
+
var import_debug = __toESM2(require("@prisma/debug"));
|
87
76
|
var import_debug2 = __toESM2(require("@prisma/debug"));
|
88
|
-
var import_crypto = __toESM2(require("crypto"));
|
89
|
-
var import_path2 = __toESM2(require("path"));
|
90
|
-
var import_debug3 = __toESM2(require("@prisma/debug"));
|
91
77
|
var import_engines = require("@prisma/engines");
|
92
78
|
var import_fetch_engine = require("@prisma/fetch-engine");
|
93
79
|
var import_get_platform = require("@prisma/get-platform");
|
94
|
-
var
|
95
|
-
var import_debug4 = __toESM2(require("@prisma/debug"));
|
96
|
-
var import_node_path = __toESM2(require("node:path"));
|
97
|
-
var import_node_process = __toESM2(require("node:process"));
|
98
|
-
var import_node_path2 = __toESM2(require("node:path"));
|
99
|
-
var import_node_fs = __toESM2(require("node:fs"));
|
100
|
-
var import_node_url = require("node:url");
|
101
|
-
var import_node_fs2 = __toESM2(require("node:fs"));
|
102
|
-
var import_fs2 = __toESM2(require("fs"));
|
103
|
-
var import_path4 = __toESM2(require("path"));
|
80
|
+
var import_path2 = __toESM2(require("path"));
|
104
81
|
var import_get_platform2 = require("@prisma/get-platform");
|
105
82
|
var forbiddenCmdFlagWithSchemaEngineWasm = ({ cmd, flag }) => `
|
106
83
|
Passing the ${(0, import_chunk_PG5FDKSF.green)(`${flag}`)} flag to the ${(0, import_chunk_PG5FDKSF.green)(`prisma ${cmd}`)} command is not supported when
|
@@ -123,11 +100,11 @@ function checkUnsupportedSchemaEngineWasm({
|
|
123
100
|
}
|
124
101
|
}
|
125
102
|
}
|
126
|
-
var debug = (0,
|
103
|
+
var debug = (0, import_debug.default)("prisma:format");
|
127
104
|
async function formatSchema({ schemas }, inputFormattingOptions) {
|
128
105
|
if (process.env.FORCE_PANIC_PRISMA_SCHEMA) {
|
129
106
|
handleFormatPanic(() => {
|
130
|
-
|
107
|
+
import_chunk_DUZ7VTLL.prismaSchemaWasm.debug_panic();
|
131
108
|
});
|
132
109
|
}
|
133
110
|
const defaultFormattingOptions = {
|
@@ -144,10 +121,10 @@ async function formatSchema({ schemas }, inputFormattingOptions) {
|
|
144
121
|
const { formattedMultipleSchemas, lintDiagnostics } = handleFormatPanic(() => {
|
145
122
|
const formattedMultipleSchemasRaw = formatWasm(JSON.stringify(schemas), documentFormattingParams);
|
146
123
|
const formattedMultipleSchemas2 = JSON.parse(formattedMultipleSchemasRaw);
|
147
|
-
const lintDiagnostics2 = (0,
|
124
|
+
const lintDiagnostics2 = (0, import_chunk_R37TYWYY.lintSchema)({ schemas: formattedMultipleSchemas2 });
|
148
125
|
return { formattedMultipleSchemas: formattedMultipleSchemas2, lintDiagnostics: lintDiagnostics2 };
|
149
126
|
});
|
150
|
-
const lintWarnings = (0,
|
127
|
+
const lintWarnings = (0, import_chunk_R37TYWYY.getLintWarningsAsText)(lintDiagnostics);
|
151
128
|
if (lintWarnings && import_chunk_ZJWZK45Z.logger_exports.should.warn()) {
|
152
129
|
console.warn(lintWarnings);
|
153
130
|
}
|
@@ -174,226 +151,9 @@ function handleFormatPanic(tryCb) {
|
|
174
151
|
}
|
175
152
|
}
|
176
153
|
function formatWasm(schema, documentFormattingParams) {
|
177
|
-
const formattedSchema =
|
154
|
+
const formattedSchema = import_chunk_DUZ7VTLL.prismaSchemaWasm.format(schema, JSON.stringify(documentFormattingParams));
|
178
155
|
return formattedSchema;
|
179
156
|
}
|
180
|
-
var readFile = (0, import_util.promisify)(import_fs.default.readFile);
|
181
|
-
var stat = (0, import_util.promisify)(import_fs.default.stat);
|
182
|
-
var debug2 = (0, import_debug.Debug)("prisma:getSchema");
|
183
|
-
async function getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
|
184
|
-
const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
|
185
|
-
if (result.ok) {
|
186
|
-
return result.schema;
|
187
|
-
}
|
188
|
-
throw new Error(renderDefaultLookupError(result.error, cwd));
|
189
|
-
}
|
190
|
-
async function getSchemaWithPathOptional(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
|
191
|
-
const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
|
192
|
-
if (result.ok) {
|
193
|
-
return result.schema;
|
194
|
-
}
|
195
|
-
return null;
|
196
|
-
}
|
197
|
-
function printSchemaLoadedMessage(schemaPath2) {
|
198
|
-
process.stdout.write((0, import_chunk_PG5FDKSF.dim)(`Prisma schema loaded from ${import_path.default.relative(process.cwd(), schemaPath2)}`) + "\n");
|
199
|
-
}
|
200
|
-
async function readSchemaFromSingleFile(schemaPath2) {
|
201
|
-
debug2("Reading schema from single file", schemaPath2);
|
202
|
-
const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath2, "file");
|
203
|
-
if (typeError) {
|
204
|
-
return { ok: false, error: typeError };
|
205
|
-
}
|
206
|
-
const file = await readFile(schemaPath2, { encoding: "utf-8" });
|
207
|
-
const schemaTuple = [schemaPath2, file];
|
208
|
-
return {
|
209
|
-
ok: true,
|
210
|
-
schema: { schemaPath: schemaPath2, schemaRootDir: import_path.default.dirname(schemaPath2), schemas: [schemaTuple] }
|
211
|
-
};
|
212
|
-
}
|
213
|
-
async function readSchemaFromDirectory(schemaPath2) {
|
214
|
-
debug2("Reading schema from multiple files", schemaPath2);
|
215
|
-
const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath2, "directory");
|
216
|
-
if (typeError) {
|
217
|
-
return { ok: false, error: typeError };
|
218
|
-
}
|
219
|
-
const files = await (0, import_schema_files_loader.loadSchemaFiles)(schemaPath2);
|
220
|
-
debug2("Loading config");
|
221
|
-
const config = await (0, import_chunk_XO424ERB.getConfig)({
|
222
|
-
datamodel: files,
|
223
|
-
ignoreEnvVarErrors: true
|
224
|
-
});
|
225
|
-
debug2("Ok");
|
226
|
-
if (!(0, import_schema_files_loader.usesPrismaSchemaFolder)(config)) {
|
227
|
-
return { ok: false, error: { kind: "FolderPreviewNotEnabled", path: schemaPath2 } };
|
228
|
-
}
|
229
|
-
return { ok: true, schema: { schemaPath: schemaPath2, schemaRootDir: schemaPath2, schemas: files } };
|
230
|
-
}
|
231
|
-
async function readSchemaFromFileOrDirectory(schemaPath2) {
|
232
|
-
let stats;
|
233
|
-
try {
|
234
|
-
stats = await stat(schemaPath2);
|
235
|
-
} catch (e) {
|
236
|
-
if (e.code === "ENOENT") {
|
237
|
-
return { ok: false, error: { kind: "NotFound", path: schemaPath2 } };
|
238
|
-
}
|
239
|
-
throw e;
|
240
|
-
}
|
241
|
-
if (stats.isFile()) {
|
242
|
-
return readSchemaFromSingleFile(schemaPath2);
|
243
|
-
}
|
244
|
-
if (stats.isDirectory()) {
|
245
|
-
return readSchemaFromDirectory(schemaPath2);
|
246
|
-
}
|
247
|
-
return { ok: false, error: { kind: "WrongType", path: schemaPath2, expectedTypes: ["file", "directory"] } };
|
248
|
-
}
|
249
|
-
async function getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName }) {
|
250
|
-
if (schemaPathFromArgs) {
|
251
|
-
const absPath = import_path.default.resolve(cwd, schemaPathFromArgs);
|
252
|
-
const customSchemaResult = await readSchemaFromFileOrDirectory(absPath);
|
253
|
-
if (!customSchemaResult.ok) {
|
254
|
-
const relPath = import_path.default.relative(cwd, absPath);
|
255
|
-
throw new Error(
|
256
|
-
`Could not load \`${argumentName}\` from provided path \`${relPath}\`: ${renderLookupError(
|
257
|
-
customSchemaResult.error
|
258
|
-
)}`
|
259
|
-
);
|
260
|
-
}
|
261
|
-
return customSchemaResult;
|
262
|
-
}
|
263
|
-
const prismaConfigResult = await readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig);
|
264
|
-
if (prismaConfigResult.ok) {
|
265
|
-
return prismaConfigResult;
|
266
|
-
}
|
267
|
-
const pkgJsonResult = await getSchemaFromPackageJson(cwd);
|
268
|
-
if (pkgJsonResult.ok) {
|
269
|
-
return pkgJsonResult;
|
270
|
-
}
|
271
|
-
const defaultResult = await getDefaultSchema(cwd);
|
272
|
-
if (defaultResult.ok) {
|
273
|
-
return defaultResult;
|
274
|
-
}
|
275
|
-
return {
|
276
|
-
ok: false,
|
277
|
-
error: defaultResult.error
|
278
|
-
};
|
279
|
-
}
|
280
|
-
function renderLookupError(error) {
|
281
|
-
switch (error.kind) {
|
282
|
-
case "NotFound": {
|
283
|
-
const expected = error.expectedType ?? "file or directory";
|
284
|
-
return `${expected} not found`;
|
285
|
-
}
|
286
|
-
case "FolderPreviewNotEnabled":
|
287
|
-
return `"prismaSchemaFolder" preview feature must be enabled`;
|
288
|
-
case "WrongType":
|
289
|
-
return `expected ${error.expectedTypes.join(" or ")}`;
|
290
|
-
}
|
291
|
-
}
|
292
|
-
function renderDefaultLookupError(error, cwd) {
|
293
|
-
const parts = [
|
294
|
-
`Could not find Prisma Schema that is required for this command.`,
|
295
|
-
`You can either provide it with ${(0, import_chunk_PG5FDKSF.green)("`--schema`")} argument,`,
|
296
|
-
`set it in your ${(0, import_chunk_PG5FDKSF.green)("`prisma.config.ts`")},`,
|
297
|
-
`set it as ${(0, import_chunk_PG5FDKSF.green)("`prisma.schema`")} in your ${(0, import_chunk_PG5FDKSF.green)("package.json")},`,
|
298
|
-
`or put it into the default location (${(0, import_chunk_PG5FDKSF.green)("`./prisma/schema.prisma`")}, or ${(0, import_chunk_PG5FDKSF.green)("`./schema.prisma`")}.`,
|
299
|
-
"Checked following paths:\n"
|
300
|
-
];
|
301
|
-
const printedPaths = /* @__PURE__ */ new Set();
|
302
|
-
for (const failure of error.failures) {
|
303
|
-
const filePath = failure.path;
|
304
|
-
if (!printedPaths.has(failure.path)) {
|
305
|
-
parts.push(`${import_path.default.relative(cwd, filePath)}: ${renderLookupError(failure.error)}`);
|
306
|
-
printedPaths.add(filePath);
|
307
|
-
}
|
308
|
-
}
|
309
|
-
parts.push("\nSee also https://pris.ly/d/prisma-schema-location");
|
310
|
-
return parts.join("\n");
|
311
|
-
}
|
312
|
-
async function getPrismaConfigFromPackageJson(cwd) {
|
313
|
-
const pkgJson = await (0, import_chunk_MJIP3FY5.readPackageUp)({ cwd, normalize: false });
|
314
|
-
const prismaPropertyFromPkgJson = pkgJson?.packageJson?.prisma;
|
315
|
-
if (!pkgJson) {
|
316
|
-
return null;
|
317
|
-
}
|
318
|
-
return {
|
319
|
-
data: prismaPropertyFromPkgJson,
|
320
|
-
packagePath: pkgJson.path
|
321
|
-
};
|
322
|
-
}
|
323
|
-
async function readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig) {
|
324
|
-
if (!schemaPathFromConfig) {
|
325
|
-
return {
|
326
|
-
ok: false,
|
327
|
-
error: { kind: "PrismaConfigNotConfigured" }
|
328
|
-
};
|
329
|
-
}
|
330
|
-
const schemaResult = await readSchemaFromFileOrDirectory(schemaPathFromConfig);
|
331
|
-
if (!schemaResult.ok) {
|
332
|
-
throw new Error(
|
333
|
-
`Could not load schema from \`${schemaPathFromConfig}\` provided by "prisma.config.ts"\`: ${renderLookupError(
|
334
|
-
schemaResult.error
|
335
|
-
)}`
|
336
|
-
);
|
337
|
-
}
|
338
|
-
return schemaResult;
|
339
|
-
}
|
340
|
-
async function getSchemaFromPackageJson(cwd) {
|
341
|
-
const prismaConfig = await getPrismaConfigFromPackageJson(cwd);
|
342
|
-
debug2("prismaConfig", prismaConfig);
|
343
|
-
if (!prismaConfig || !prismaConfig.data?.schema) {
|
344
|
-
return { ok: false, error: { kind: "PackageJsonNotConfigured" } };
|
345
|
-
}
|
346
|
-
const schemaPathFromPkgJson = prismaConfig.data.schema;
|
347
|
-
if (typeof schemaPathFromPkgJson !== "string") {
|
348
|
-
throw new Error(
|
349
|
-
`Provided schema path \`${schemaPathFromPkgJson}\` from \`${import_path.default.relative(
|
350
|
-
cwd,
|
351
|
-
prismaConfig.packagePath
|
352
|
-
)}\` must be of type string`
|
353
|
-
);
|
354
|
-
}
|
355
|
-
const absoluteSchemaPath = import_path.default.isAbsolute(schemaPathFromPkgJson) ? schemaPathFromPkgJson : import_path.default.resolve(import_path.default.dirname(prismaConfig.packagePath), schemaPathFromPkgJson);
|
356
|
-
const lookupResult = await readSchemaFromFileOrDirectory(absoluteSchemaPath);
|
357
|
-
if (!lookupResult.ok) {
|
358
|
-
throw new Error(
|
359
|
-
`Could not load schema from \`${import_path.default.relative(
|
360
|
-
cwd,
|
361
|
-
absoluteSchemaPath
|
362
|
-
)}\` provided by "prisma.schema" config of \`${import_path.default.relative(
|
363
|
-
cwd,
|
364
|
-
prismaConfig.packagePath
|
365
|
-
)}\`: ${renderLookupError(lookupResult.error)}`
|
366
|
-
);
|
367
|
-
}
|
368
|
-
return lookupResult;
|
369
|
-
}
|
370
|
-
async function getDefaultSchema(cwd, failures = []) {
|
371
|
-
const lookupPaths = [import_path.default.join(cwd, "schema.prisma"), import_path.default.join(cwd, "prisma", "schema.prisma")];
|
372
|
-
for (const path7 of lookupPaths) {
|
373
|
-
debug2(`Checking existence of ${path7}`);
|
374
|
-
const schema = await readSchemaFromSingleFile(path7);
|
375
|
-
if (!schema.ok) {
|
376
|
-
failures.push({ path: path7, error: schema.error });
|
377
|
-
continue;
|
378
|
-
}
|
379
|
-
return schema;
|
380
|
-
}
|
381
|
-
return {
|
382
|
-
ok: false,
|
383
|
-
error: {
|
384
|
-
kind: "NotFoundMultipleLocations",
|
385
|
-
failures
|
386
|
-
}
|
387
|
-
};
|
388
|
-
}
|
389
|
-
async function getProjectHash(schemaPathFromArgs, schemaPathFromConfig) {
|
390
|
-
const projectPath = (await getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig))?.schemaPath ?? process.cwd();
|
391
|
-
return import_crypto.default.createHash("sha256").update(projectPath).digest("hex").substring(0, 8);
|
392
|
-
}
|
393
|
-
function getCLIPathHash() {
|
394
|
-
const cliPath = process.argv[1];
|
395
|
-
return import_crypto.default.createHash("sha256").update(cliPath).digest("hex").substring(0, 8);
|
396
|
-
}
|
397
157
|
async function loadSchemaContext({
|
398
158
|
schemaPathFromArg,
|
399
159
|
schemaPathFromConfig,
|
@@ -405,13 +165,13 @@ async function loadSchemaContext({
|
|
405
165
|
} = {}) {
|
406
166
|
let schemaResult = null;
|
407
167
|
if (allowNull) {
|
408
|
-
schemaResult = await getSchemaWithPathOptional(schemaPathFromArg, schemaPathFromConfig, {
|
168
|
+
schemaResult = await (0, import_chunk_ZCBEMBHR.getSchemaWithPathOptional)(schemaPathFromArg, schemaPathFromConfig, {
|
409
169
|
argumentName: schemaPathArgumentName,
|
410
170
|
cwd
|
411
171
|
});
|
412
172
|
if (!schemaResult) return null;
|
413
173
|
} else {
|
414
|
-
schemaResult = await getSchemaWithPath(schemaPathFromArg, schemaPathFromConfig, {
|
174
|
+
schemaResult = await (0, import_chunk_ZCBEMBHR.getSchemaWithPath)(schemaPathFromArg, schemaPathFromConfig, {
|
415
175
|
argumentName: schemaPathArgumentName,
|
416
176
|
cwd
|
417
177
|
});
|
@@ -424,11 +184,11 @@ async function processSchemaResult({
|
|
424
184
|
ignoreEnvVarErrors = false,
|
425
185
|
cwd = process.cwd()
|
426
186
|
}) {
|
427
|
-
const loadedFromPathForLogMessages =
|
187
|
+
const loadedFromPathForLogMessages = import_path.default.relative(cwd, schemaResult.schemaPath);
|
428
188
|
if (printLoadMessage) {
|
429
|
-
printSchemaLoadedMessage(loadedFromPathForLogMessages);
|
189
|
+
(0, import_chunk_ZCBEMBHR.printSchemaLoadedMessage)(loadedFromPathForLogMessages);
|
430
190
|
}
|
431
|
-
const configFromPsl = await (0,
|
191
|
+
const configFromPsl = await (0, import_chunk_PD4UCNF3.getConfig)({ datamodel: schemaResult.schemas, ignoreEnvVarErrors });
|
432
192
|
const primaryDatasource = configFromPsl.datasources.at(0);
|
433
193
|
const schemaRootDir = schemaResult.schemaRootDir || cwd;
|
434
194
|
return {
|
@@ -446,12 +206,12 @@ async function processSchemaResult({
|
|
446
206
|
function primaryDatasourceDirectory(primaryDatasource) {
|
447
207
|
const datasourcePath = primaryDatasource?.sourceFilePath;
|
448
208
|
if (datasourcePath) {
|
449
|
-
return
|
209
|
+
return import_path.default.dirname(datasourcePath);
|
450
210
|
}
|
451
211
|
return null;
|
452
212
|
}
|
453
|
-
var import_p_map = (0, import_chunk_4VNS5WPM.__toESM)((0,
|
454
|
-
var
|
213
|
+
var import_p_map = (0, import_chunk_4VNS5WPM.__toESM)((0, import_chunk_ZIFBTC6Y.require_p_map)());
|
214
|
+
var debug2 = (0, import_debug2.default)("prisma:getGenerators");
|
455
215
|
async function getGenerators(options) {
|
456
216
|
if (options.registry === void 0 && options.providerAliases !== void 0) {
|
457
217
|
options.registry = Object.fromEntries(
|
@@ -506,7 +266,7 @@ async function getGenerators(options) {
|
|
506
266
|
}
|
507
267
|
(0, import_chunk_5FJ3MENK.printConfigWarnings)(schemaContext.warnings);
|
508
268
|
const previewFeatures = (0, import_chunk_CRVLHWC5.extractPreviewFeatures)(schemaContext.generators);
|
509
|
-
const dmmf = await (0,
|
269
|
+
const dmmf = await (0, import_chunk_37VFNYDN.getDMMF)({
|
510
270
|
datamodel: schemaContext.schemaFiles,
|
511
271
|
previewFeatures
|
512
272
|
});
|
@@ -523,7 +283,7 @@ async function getGenerators(options) {
|
|
523
283
|
const generators = await (0, import_p_map.default)(
|
524
284
|
generatorConfigs,
|
525
285
|
async (generatorConfig, index) => {
|
526
|
-
const baseDir =
|
286
|
+
const baseDir = import_path2.default.dirname(generatorConfig.sourceFilePath ?? schemaContext.schemaRootDir);
|
527
287
|
const providerValue = (0, import_chunk_IOIAK7V7.parseEnvValue)(generatorConfig.provider);
|
528
288
|
const generatorDefinition = registry[providerValue] ?? {
|
529
289
|
type: "rpc",
|
@@ -536,7 +296,7 @@ async function getGenerators(options) {
|
|
536
296
|
await generatorInstance.init();
|
537
297
|
if (generatorConfig.output) {
|
538
298
|
generatorConfig.output = {
|
539
|
-
value:
|
299
|
+
value: import_path2.default.resolve(baseDir, (0, import_chunk_IOIAK7V7.parseEnvValue)(generatorConfig.output)),
|
540
300
|
fromEnvVar: null
|
541
301
|
};
|
542
302
|
generatorConfig.isCustomOutput = true;
|
@@ -557,8 +317,8 @@ You need to define \`output\` in the generator block in the schema file.`
|
|
557
317
|
fromEnvVar: null
|
558
318
|
};
|
559
319
|
}
|
560
|
-
const datamodel = (0,
|
561
|
-
const envPaths = await getEnvPaths(schemaContext.schemaPath, { cwd: generatorConfig.output.value });
|
320
|
+
const datamodel = (0, import_chunk_OBDAVBAO.mergeSchemas)({ schemas: schemaContext.schemaFiles });
|
321
|
+
const envPaths = await (0, import_chunk_WCPUXXL2.getEnvPaths)(schemaContext.schemaPath, { cwd: generatorConfig.output.value });
|
562
322
|
const options2 = {
|
563
323
|
datamodel,
|
564
324
|
datasources: schemaContext.datasources,
|
@@ -624,7 +384,7 @@ generator gen {
|
|
624
384
|
}
|
625
385
|
}
|
626
386
|
}
|
627
|
-
|
387
|
+
debug2("neededVersions", JSON.stringify(neededVersions, null, 2));
|
628
388
|
const binaryPathsByVersion = await (0, import_chunk_EPXBOIA5.getBinaryPathsByVersion)({
|
629
389
|
neededVersions,
|
630
390
|
binaryTarget,
|
@@ -638,17 +398,17 @@ generator gen {
|
|
638
398
|
const engineVersion = (0, import_chunk_X3P4J7WW.getEngineVersionForGenerator)(generator.manifest, version);
|
639
399
|
const binaryPaths = binaryPathsByVersion[engineVersion];
|
640
400
|
const generatorBinaryPaths = (0, import_chunk_5V36RLCO.pick)(binaryPaths ?? {}, generator.manifest.requiresEngines);
|
641
|
-
|
401
|
+
debug2({ generatorBinaryPaths });
|
642
402
|
generator.setBinaryPaths(generatorBinaryPaths);
|
643
403
|
if (engineVersion !== version && generator.options && generator.manifest.requiresEngines.includes(queryEngineType) && generatorBinaryPaths[queryEngineType] && generatorBinaryPaths[queryEngineType]?.[binaryTarget]) {
|
644
|
-
const customDmmf = await (0,
|
404
|
+
const customDmmf = await (0, import_chunk_37VFNYDN.getDMMF)({
|
645
405
|
datamodel: schemaContext.schemaFiles,
|
646
406
|
previewFeatures
|
647
407
|
});
|
648
408
|
const options2 = { ...generator.options, dmmf: customDmmf };
|
649
|
-
|
650
|
-
|
651
|
-
|
409
|
+
debug2("generator.manifest.prettyName", generator.manifest.prettyName);
|
410
|
+
debug2("options", options2);
|
411
|
+
debug2("options.generator.binaryTargets", options2.generator.binaryTargets);
|
652
412
|
generator.setOptions(options2);
|
653
413
|
}
|
654
414
|
}
|
@@ -745,160 +505,6 @@ function filterGenerators(generators, generatorNames2) {
|
|
745
505
|
}
|
746
506
|
return filtered;
|
747
507
|
}
|
748
|
-
var typeMappings = {
|
749
|
-
directory: "isDirectory",
|
750
|
-
file: "isFile"
|
751
|
-
};
|
752
|
-
function checkType(type) {
|
753
|
-
if (Object.hasOwnProperty.call(typeMappings, type)) {
|
754
|
-
return;
|
755
|
-
}
|
756
|
-
throw new Error(`Invalid type specified: ${type}`);
|
757
|
-
}
|
758
|
-
var matchType = (type, stat2) => stat2[typeMappings[type]]();
|
759
|
-
var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
|
760
|
-
function locatePathSync(paths, {
|
761
|
-
cwd = import_node_process.default.cwd(),
|
762
|
-
type = "file",
|
763
|
-
allowSymlinks = true
|
764
|
-
} = {}) {
|
765
|
-
checkType(type);
|
766
|
-
cwd = toPath2(cwd);
|
767
|
-
const statFunction = allowSymlinks ? import_node_fs.default.statSync : import_node_fs.default.lstatSync;
|
768
|
-
for (const path_ of paths) {
|
769
|
-
try {
|
770
|
-
const stat2 = statFunction(import_node_path2.default.resolve(cwd, path_), {
|
771
|
-
throwIfNoEntry: false
|
772
|
-
});
|
773
|
-
if (!stat2) {
|
774
|
-
continue;
|
775
|
-
}
|
776
|
-
if (matchType(type, stat2)) {
|
777
|
-
return path_;
|
778
|
-
}
|
779
|
-
} catch {
|
780
|
-
}
|
781
|
-
}
|
782
|
-
}
|
783
|
-
function pathExistsSync(path7) {
|
784
|
-
try {
|
785
|
-
import_node_fs2.default.accessSync(path7);
|
786
|
-
return true;
|
787
|
-
} catch {
|
788
|
-
return false;
|
789
|
-
}
|
790
|
-
}
|
791
|
-
var findUpStop = Symbol("findUpStop");
|
792
|
-
function findUpMultipleSync(name, options2 = {}) {
|
793
|
-
let directory = import_node_path.default.resolve((0, import_chunk_MJIP3FY5.toPath)(options2.cwd) ?? "");
|
794
|
-
const { root } = import_node_path.default.parse(directory);
|
795
|
-
const stopAt = import_node_path.default.resolve(directory, (0, import_chunk_MJIP3FY5.toPath)(options2.stopAt) ?? root);
|
796
|
-
const limit = options2.limit ?? Number.POSITIVE_INFINITY;
|
797
|
-
const paths = [name].flat();
|
798
|
-
const runMatcher = (locateOptions) => {
|
799
|
-
if (typeof name !== "function") {
|
800
|
-
return locatePathSync(paths, locateOptions);
|
801
|
-
}
|
802
|
-
const foundPath = name(locateOptions.cwd);
|
803
|
-
if (typeof foundPath === "string") {
|
804
|
-
return locatePathSync([foundPath], locateOptions);
|
805
|
-
}
|
806
|
-
return foundPath;
|
807
|
-
};
|
808
|
-
const matches = [];
|
809
|
-
while (true) {
|
810
|
-
const foundPath = runMatcher({ ...options2, cwd: directory });
|
811
|
-
if (foundPath === findUpStop) {
|
812
|
-
break;
|
813
|
-
}
|
814
|
-
if (foundPath) {
|
815
|
-
matches.push(import_node_path.default.resolve(directory, foundPath));
|
816
|
-
}
|
817
|
-
if (directory === stopAt || matches.length >= limit) {
|
818
|
-
break;
|
819
|
-
}
|
820
|
-
directory = import_node_path.default.dirname(directory);
|
821
|
-
}
|
822
|
-
return matches;
|
823
|
-
}
|
824
|
-
function findUpSync(name, options2 = {}) {
|
825
|
-
const matches = findUpMultipleSync(name, { ...options2, limit: 1 });
|
826
|
-
return matches[0];
|
827
|
-
}
|
828
|
-
var debug4 = (0, import_debug4.default)("prisma:loadEnv");
|
829
|
-
async function getEnvPaths(schemaPath2, opts = { cwd: process.cwd() }) {
|
830
|
-
const rootEnvPath = getProjectRootEnvPath({ cwd: opts.cwd }) ?? null;
|
831
|
-
const schemaEnvPathFromArgs = schemaPathToEnvPath(schemaPath2);
|
832
|
-
const schemaEnvPathFromPkgJson = schemaPathToEnvPath(await readSchemaPathFromPkgJson());
|
833
|
-
const schemaEnvPaths = [
|
834
|
-
schemaEnvPathFromArgs,
|
835
|
-
// 1 - Check --schema directory for .env
|
836
|
-
schemaEnvPathFromPkgJson,
|
837
|
-
// 2 - Check package.json schema directory for .env
|
838
|
-
"./prisma/.env",
|
839
|
-
// 3 - Check ./prisma directory for .env
|
840
|
-
"./.env"
|
841
|
-
// 4 - Check cwd for .env
|
842
|
-
];
|
843
|
-
const schemaEnvPath = schemaEnvPaths.find(import_chunk_2IP7H3BQ.exists);
|
844
|
-
return { rootEnvPath, schemaEnvPath };
|
845
|
-
}
|
846
|
-
async function readSchemaPathFromPkgJson() {
|
847
|
-
try {
|
848
|
-
const pkgJsonSchema = await getSchemaFromPackageJson(process.cwd());
|
849
|
-
if (pkgJsonSchema.ok) {
|
850
|
-
pkgJsonSchema.schema.schemaPath;
|
851
|
-
}
|
852
|
-
return null;
|
853
|
-
} catch {
|
854
|
-
return null;
|
855
|
-
}
|
856
|
-
}
|
857
|
-
function getProjectRootEnvPath(opts) {
|
858
|
-
const pkgJsonPath = findUpSync((dir) => {
|
859
|
-
const pkgPath = import_path4.default.join(dir, "package.json");
|
860
|
-
if (pathExistsSync(pkgPath)) {
|
861
|
-
try {
|
862
|
-
const pkg = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf8"));
|
863
|
-
if (pkg["name"] !== ".prisma/client") {
|
864
|
-
debug4(`project root found at ${pkgPath}`);
|
865
|
-
return pkgPath;
|
866
|
-
}
|
867
|
-
} catch (e) {
|
868
|
-
debug4(`skipping package.json at ${pkgPath}`);
|
869
|
-
}
|
870
|
-
}
|
871
|
-
return void 0;
|
872
|
-
}, opts);
|
873
|
-
if (!pkgJsonPath) {
|
874
|
-
return null;
|
875
|
-
}
|
876
|
-
const candidate = import_path4.default.join(import_path4.default.dirname(pkgJsonPath), ".env");
|
877
|
-
if (!import_fs2.default.existsSync(candidate)) {
|
878
|
-
return null;
|
879
|
-
}
|
880
|
-
return candidate;
|
881
|
-
}
|
882
|
-
function schemaPathToEnvPath(schemaPath2) {
|
883
|
-
if (!schemaPath2) return null;
|
884
|
-
return import_path4.default.join(import_path4.default.dirname(schemaPath2), ".env");
|
885
|
-
}
|
886
|
-
async function loadEnvFile({
|
887
|
-
schemaPath: schemaPath2,
|
888
|
-
config,
|
889
|
-
printMessage = false
|
890
|
-
}) {
|
891
|
-
if (config.loadedFromFile) {
|
892
|
-
process.stdout.write(`Prisma config detected, skipping environment variable loading.
|
893
|
-
`);
|
894
|
-
return;
|
895
|
-
}
|
896
|
-
const envPaths = await getEnvPaths(schemaPath2);
|
897
|
-
const envData = (0, import_chunk_2IP7H3BQ.tryLoadEnvs)(envPaths, { conflictCheck: "error" });
|
898
|
-
if (printMessage && envData && envData.message) {
|
899
|
-
process.stdout.write(envData.message + "\n");
|
900
|
-
}
|
901
|
-
}
|
902
508
|
var forbiddenCmdWithDataProxyFlagMessage = (command) => `
|
903
509
|
Using an Accelerate URL is not supported for this CLI command ${(0, import_chunk_PG5FDKSF.green)(`prisma ${command}`)} yet.
|
904
510
|
Please use a direct connection to your database via the datasource \`directUrl\` setting.
|
@@ -916,7 +522,7 @@ function checkUnsupportedDataProxy({
|
|
916
522
|
}
|
917
523
|
}
|
918
524
|
if (!schemaContext2?.primaryDatasource) return;
|
919
|
-
const url = (0,
|
525
|
+
const url = (0, import_chunk_PD4UCNF3.resolveUrl)((0, import_chunk_PD4UCNF3.getEffectiveUrl)(schemaContext2.primaryDatasource));
|
920
526
|
if (url?.startsWith("prisma://")) {
|
921
527
|
throw new Error(forbiddenCmdWithDataProxyFlagMessage(cmd));
|
922
528
|
}
|