@prisma/internals 6.19.0-integration-next.16 → 6.19.0-integration-engines-6-19-0-32-next-568b222d0ab829bbbe5f2fd48ed587836813346c.1

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.
Files changed (85) hide show
  1. package/dist/{chunk-SIMRXUXR.js → chunk-2MJTY4KQ.js} +5 -5
  2. package/dist/chunk-3FP46GUV.js +471 -0
  3. package/dist/chunk-46ABODUM.js +186 -0
  4. package/dist/{chunk-VRGMXDRD.js → chunk-4CGPN5SR.js} +6 -3
  5. package/dist/{chunk-INJO27TY.js → chunk-4HCWAIVZ.js} +15 -9
  6. package/dist/{chunk-GL7OANR6.js → chunk-4JCVHBYR.js} +5 -5
  7. package/dist/{chunk-2ONERNWE.js → chunk-DK5SCKNO.js} +5 -5
  8. package/dist/{chunk-FMYHDVAC.js → chunk-DSG2XXJJ.js} +7 -7
  9. package/dist/{chunk-R3RVIOOH.js → chunk-DX7WJ45H.js} +5 -5
  10. package/dist/{chunk-FUYRCYVL.js → chunk-ERSH2BQA.js} +8 -3
  11. package/dist/{chunk-OKVM3CW4.js → chunk-EYVG6XQS.js} +39 -3
  12. package/dist/{chunk-5XFNC2RY.js → chunk-F2OZV76L.js} +7 -7
  13. package/dist/{chunk-R3J2O23S.js → chunk-FCYHZHVW.js} +4 -4
  14. package/dist/{chunk-5NV3W7KM.js → chunk-FYZCPL2Z.js} +4 -4
  15. package/dist/{chunk-HL6M6I6N.js → chunk-GMW36QQF.js} +7 -7
  16. package/dist/{chunk-GSH4BXBI.js → chunk-HFFWZTVM.js} +6 -4
  17. package/dist/{chunk-5W3BSMTH.js → chunk-HO5HRHFZ.js} +6 -3
  18. package/dist/{chunk-25QIR2OA.js → chunk-IKIW52QS.js} +8 -8
  19. package/dist/{chunk-RXUFT5US.js → chunk-ISSTUMGH.js} +8 -8
  20. package/dist/{chunk-6OLUZD6G.js → chunk-JD36HS5L.js} +15 -9
  21. package/dist/{chunk-XQFPAFQE.js → chunk-LBEUT2S6.js} +5 -5
  22. package/dist/{chunk-A7LJSXBL.js → chunk-N3UPGHTD.js} +49 -31
  23. package/dist/{chunk-5FUXDJAN.js → chunk-OAT7ZJED.js} +9 -5
  24. package/dist/{chunk-XCUYCN3Z.js → chunk-PWLNUJDJ.js} +5 -5
  25. package/dist/{chunk-MH5DW7MH.js → chunk-PZEUONUZ.js} +7 -7
  26. package/dist/chunk-PZMRR772.js +41 -0
  27. package/dist/{chunk-6GH4RAXF.js → chunk-RIACS7RB.js} +5 -5
  28. package/dist/{chunk-HC7ALJJ2.js → chunk-RKDOMYIG.js} +49 -31
  29. package/dist/{chunk-B22EOFPW.js → chunk-RS2R7COT.js} +6 -3
  30. package/dist/{chunk-SVPXYUIM.js → chunk-SH2TNBI6.js} +8 -7
  31. package/dist/chunk-T2PM5TKT.js +55 -0
  32. package/dist/{chunk-3GU5WOTV.js → chunk-TGOAMULH.js} +9 -8
  33. package/dist/{chunk-63H7LVQK.js → chunk-U2GOPCRA.js} +5 -5
  34. package/dist/{chunk-SYOFVVNN.js → chunk-UHI6VYFX.js} +5 -5
  35. package/dist/{chunk-BLBFB7XV.js → chunk-UQUWZJVN.js} +7 -7
  36. package/dist/{chunk-NDSHLEAN.js → chunk-VDOBMNYY.js} +8 -8
  37. package/dist/{chunk-ARC7TW3L.js → chunk-WFNB7VRA.js} +14 -4
  38. package/dist/{chunk-CAACRLTC.js → chunk-YU52YNDP.js} +8 -8
  39. package/dist/{chunk-I6IIL2R7.js → chunk-ZKW5OHDA.js} +5 -5
  40. package/dist/cli/checkUnsupportedDataProxy.js +45 -41
  41. package/dist/cli/checkUnsupportedSchemaEngineWasm.js +45 -41
  42. package/dist/cli/getGeneratorSuccessMessage.js +3 -2
  43. package/dist/cli/getSchema.d.ts +15 -1
  44. package/dist/cli/getSchema.js +5 -4
  45. package/dist/cli/hashes.js +4 -4
  46. package/dist/cli/schemaContext.d.ts +3 -1
  47. package/dist/cli/schemaContext.js +45 -41
  48. package/dist/client/getClientEngineType.d.ts +1 -0
  49. package/dist/client/getClientEngineType.js +3 -3
  50. package/dist/dotenvExpand.d.ts +35 -0
  51. package/dist/dotenvExpand.js +25 -0
  52. package/dist/engine-commands/errorHelpers.js +4 -4
  53. package/dist/engine-commands/formatSchema.js +44 -40
  54. package/dist/engine-commands/getConfig.d.ts +1 -0
  55. package/dist/engine-commands/getConfig.js +11 -11
  56. package/dist/engine-commands/getDmmf.js +8 -8
  57. package/dist/engine-commands/getEngineVersion.js +6 -6
  58. package/dist/engine-commands/getEnginesInfo.d.ts +1 -0
  59. package/dist/engine-commands/getEnginesInfo.js +7 -7
  60. package/dist/engine-commands/index.js +56 -52
  61. package/dist/engine-commands/lintSchema.js +9 -9
  62. package/dist/engine-commands/mergeSchemas.js +8 -8
  63. package/dist/engine-commands/validate.js +8 -8
  64. package/dist/get-generators/getGenerators.d.ts +1 -0
  65. package/dist/get-generators/getGenerators.js +47 -43
  66. package/dist/get-generators/utils/binaryTypeToEngineType.js +2 -2
  67. package/dist/get-generators/utils/engineTypeToBinaryType.js +2 -2
  68. package/dist/get-generators/utils/getBinaryPathsByVersion.js +4 -4
  69. package/dist/index.d.ts +4 -0
  70. package/dist/index.js +89 -82
  71. package/dist/resolveBinary.js +7 -7
  72. package/dist/schemaEngineCommands.js +8 -8
  73. package/dist/sendPanic.js +2 -2
  74. package/dist/utils/canPrompt.js +3 -3
  75. package/dist/utils/getEnvPaths.d.ts +14 -0
  76. package/dist/utils/getEnvPaths.js +29 -0
  77. package/dist/utils/getVersionFromPackageJson.js +3 -3
  78. package/dist/utils/handlePanic.js +6 -6
  79. package/dist/utils/loadEnvFile.d.ts +10 -0
  80. package/dist/utils/loadEnvFile.js +30 -0
  81. package/dist/utils/serializeQueryEngineName.js +2 -2
  82. package/dist/utils/tryLoadEnvs.d.ts +25 -0
  83. package/dist/utils/tryLoadEnvs.js +30 -0
  84. package/dist/wasm.js +5 -5
  85. package/package.json +16 -15
@@ -16,20 +16,20 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_SIMRXUXR_exports = {};
20
- __export(chunk_SIMRXUXR_exports, {
19
+ var chunk_2MJTY4KQ_exports = {};
20
+ __export(chunk_2MJTY4KQ_exports, {
21
21
  getLintWarnings: () => getLintWarnings,
22
22
  getLintWarningsAsText: () => getLintWarningsAsText,
23
23
  handleLintPanic: () => handleLintPanic,
24
24
  lintSchema: () => lintSchema,
25
25
  warningToString: () => warningToString
26
26
  });
27
- module.exports = __toCommonJS(chunk_SIMRXUXR_exports);
28
- var import_chunk_I6IIL2R7 = require("./chunk-I6IIL2R7.js");
27
+ module.exports = __toCommonJS(chunk_2MJTY4KQ_exports);
28
+ var import_chunk_DX7WJ45H = require("./chunk-DX7WJ45H.js");
29
29
  var import_chunk_LMVSIVKQ = require("./chunk-LMVSIVKQ.js");
30
30
  var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
31
31
  function lintSchema({ schemas }) {
32
- const lintResult = import_chunk_I6IIL2R7.prismaSchemaWasm.lint(JSON.stringify(schemas));
32
+ const lintResult = import_chunk_DX7WJ45H.prismaSchemaWasm.lint(JSON.stringify(schemas));
33
33
  const lintDiagnostics = JSON.parse(lintResult);
34
34
  return lintDiagnostics;
35
35
  }
@@ -0,0 +1,471 @@
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_3FP46GUV_exports = {};
30
+ __export(chunk_3FP46GUV_exports, {
31
+ exists: () => exists,
32
+ loadEnv: () => loadEnv,
33
+ pathsEqual: () => pathsEqual,
34
+ tryLoadEnvs: () => tryLoadEnvs
35
+ });
36
+ module.exports = __toCommonJS(chunk_3FP46GUV_exports);
37
+ var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
38
+ var import_chunk_T2PM5TKT = require("./chunk-T2PM5TKT.js");
39
+ var import_chunk_4VNS5WPM = require("./chunk-4VNS5WPM.js");
40
+ var import_debug = __toESM(require("@prisma/debug"));
41
+ var import_fs = __toESM(require("fs"));
42
+ var import_path = __toESM(require("path"));
43
+ var require_package = (0, import_chunk_4VNS5WPM.__commonJS)({
44
+ "../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/package.json"(exports, module2) {
45
+ module2.exports = {
46
+ name: "dotenv",
47
+ version: "16.5.0",
48
+ description: "Loads environment variables from .env file",
49
+ main: "lib/main.js",
50
+ types: "lib/main.d.ts",
51
+ exports: {
52
+ ".": {
53
+ types: "./lib/main.d.ts",
54
+ require: "./lib/main.js",
55
+ default: "./lib/main.js"
56
+ },
57
+ "./config": "./config.js",
58
+ "./config.js": "./config.js",
59
+ "./lib/env-options": "./lib/env-options.js",
60
+ "./lib/env-options.js": "./lib/env-options.js",
61
+ "./lib/cli-options": "./lib/cli-options.js",
62
+ "./lib/cli-options.js": "./lib/cli-options.js",
63
+ "./package.json": "./package.json"
64
+ },
65
+ scripts: {
66
+ "dts-check": "tsc --project tests/types/tsconfig.json",
67
+ lint: "standard",
68
+ pretest: "npm run lint && npm run dts-check",
69
+ test: "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
70
+ "test:coverage": "tap run --show-full-coverage --timeout=60000 --coverage-report=lcov",
71
+ prerelease: "npm test",
72
+ release: "standard-version"
73
+ },
74
+ repository: {
75
+ type: "git",
76
+ url: "git://github.com/motdotla/dotenv.git"
77
+ },
78
+ homepage: "https://github.com/motdotla/dotenv#readme",
79
+ funding: "https://dotenvx.com",
80
+ keywords: [
81
+ "dotenv",
82
+ "env",
83
+ ".env",
84
+ "environment",
85
+ "variables",
86
+ "config",
87
+ "settings"
88
+ ],
89
+ readmeFilename: "README.md",
90
+ license: "BSD-2-Clause",
91
+ devDependencies: {
92
+ "@types/node": "^18.11.3",
93
+ decache: "^4.6.2",
94
+ sinon: "^14.0.1",
95
+ standard: "^17.0.0",
96
+ "standard-version": "^9.5.0",
97
+ tap: "^19.2.0",
98
+ typescript: "^4.8.4"
99
+ },
100
+ engines: {
101
+ node: ">=12"
102
+ },
103
+ browser: {
104
+ fs: false
105
+ }
106
+ };
107
+ }
108
+ });
109
+ var require_main = (0, import_chunk_4VNS5WPM.__commonJS)({
110
+ "../../node_modules/.pnpm/dotenv@16.5.0/node_modules/dotenv/lib/main.js"(exports, module2) {
111
+ "use strict";
112
+ var fs2 = (0, import_chunk_4VNS5WPM.__require)("fs");
113
+ var path2 = (0, import_chunk_4VNS5WPM.__require)("path");
114
+ var os = (0, import_chunk_4VNS5WPM.__require)("os");
115
+ var crypto = (0, import_chunk_4VNS5WPM.__require)("crypto");
116
+ var packageJson = require_package();
117
+ var version = packageJson.version;
118
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
119
+ function parse(src) {
120
+ const obj = {};
121
+ let lines = src.toString();
122
+ lines = lines.replace(/\r\n?/mg, "\n");
123
+ let match;
124
+ while ((match = LINE.exec(lines)) != null) {
125
+ const key = match[1];
126
+ let value = match[2] || "";
127
+ value = value.trim();
128
+ const maybeQuote = value[0];
129
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
130
+ if (maybeQuote === '"') {
131
+ value = value.replace(/\\n/g, "\n");
132
+ value = value.replace(/\\r/g, "\r");
133
+ }
134
+ obj[key] = value;
135
+ }
136
+ return obj;
137
+ }
138
+ function _parseVault(options) {
139
+ const vaultPath = _vaultPath(options);
140
+ const result = DotenvModule.configDotenv({ path: vaultPath });
141
+ if (!result.parsed) {
142
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
143
+ err.code = "MISSING_DATA";
144
+ throw err;
145
+ }
146
+ const keys = _dotenvKey(options).split(",");
147
+ const length = keys.length;
148
+ let decrypted;
149
+ for (let i = 0; i < length; i++) {
150
+ try {
151
+ const key = keys[i].trim();
152
+ const attrs = _instructions(result, key);
153
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
154
+ break;
155
+ } catch (error) {
156
+ if (i + 1 >= length) {
157
+ throw error;
158
+ }
159
+ }
160
+ }
161
+ return DotenvModule.parse(decrypted);
162
+ }
163
+ function _warn(message) {
164
+ console.log(`[dotenv@${version}][WARN] ${message}`);
165
+ }
166
+ function _debug(message) {
167
+ console.log(`[dotenv@${version}][DEBUG] ${message}`);
168
+ }
169
+ function _dotenvKey(options) {
170
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
171
+ return options.DOTENV_KEY;
172
+ }
173
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
174
+ return process.env.DOTENV_KEY;
175
+ }
176
+ return "";
177
+ }
178
+ function _instructions(result, dotenvKey) {
179
+ let uri;
180
+ try {
181
+ uri = new URL(dotenvKey);
182
+ } catch (error) {
183
+ if (error.code === "ERR_INVALID_URL") {
184
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
185
+ err.code = "INVALID_DOTENV_KEY";
186
+ throw err;
187
+ }
188
+ throw error;
189
+ }
190
+ const key = uri.password;
191
+ if (!key) {
192
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
193
+ err.code = "INVALID_DOTENV_KEY";
194
+ throw err;
195
+ }
196
+ const environment = uri.searchParams.get("environment");
197
+ if (!environment) {
198
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
199
+ err.code = "INVALID_DOTENV_KEY";
200
+ throw err;
201
+ }
202
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
203
+ const ciphertext = result.parsed[environmentKey];
204
+ if (!ciphertext) {
205
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
206
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
207
+ throw err;
208
+ }
209
+ return { ciphertext, key };
210
+ }
211
+ function _vaultPath(options) {
212
+ let possibleVaultPath = null;
213
+ if (options && options.path && options.path.length > 0) {
214
+ if (Array.isArray(options.path)) {
215
+ for (const filepath of options.path) {
216
+ if (fs2.existsSync(filepath)) {
217
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
218
+ }
219
+ }
220
+ } else {
221
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
222
+ }
223
+ } else {
224
+ possibleVaultPath = path2.resolve(process.cwd(), ".env.vault");
225
+ }
226
+ if (fs2.existsSync(possibleVaultPath)) {
227
+ return possibleVaultPath;
228
+ }
229
+ return null;
230
+ }
231
+ function _resolveHome(envPath) {
232
+ return envPath[0] === "~" ? path2.join(os.homedir(), envPath.slice(1)) : envPath;
233
+ }
234
+ function _configVault(options) {
235
+ const debug2 = Boolean(options && options.debug);
236
+ if (debug2) {
237
+ _debug("Loading env from encrypted .env.vault");
238
+ }
239
+ const parsed = DotenvModule._parseVault(options);
240
+ let processEnv = process.env;
241
+ if (options && options.processEnv != null) {
242
+ processEnv = options.processEnv;
243
+ }
244
+ DotenvModule.populate(processEnv, parsed, options);
245
+ return { parsed };
246
+ }
247
+ function configDotenv(options) {
248
+ const dotenvPath = path2.resolve(process.cwd(), ".env");
249
+ let encoding = "utf8";
250
+ const debug2 = Boolean(options && options.debug);
251
+ if (options && options.encoding) {
252
+ encoding = options.encoding;
253
+ } else {
254
+ if (debug2) {
255
+ _debug("No encoding is specified. UTF-8 is used by default");
256
+ }
257
+ }
258
+ let optionPaths = [dotenvPath];
259
+ if (options && options.path) {
260
+ if (!Array.isArray(options.path)) {
261
+ optionPaths = [_resolveHome(options.path)];
262
+ } else {
263
+ optionPaths = [];
264
+ for (const filepath of options.path) {
265
+ optionPaths.push(_resolveHome(filepath));
266
+ }
267
+ }
268
+ }
269
+ let lastError;
270
+ const parsedAll = {};
271
+ for (const path3 of optionPaths) {
272
+ try {
273
+ const parsed = DotenvModule.parse(fs2.readFileSync(path3, { encoding }));
274
+ DotenvModule.populate(parsedAll, parsed, options);
275
+ } catch (e) {
276
+ if (debug2) {
277
+ _debug(`Failed to load ${path3} ${e.message}`);
278
+ }
279
+ lastError = e;
280
+ }
281
+ }
282
+ let processEnv = process.env;
283
+ if (options && options.processEnv != null) {
284
+ processEnv = options.processEnv;
285
+ }
286
+ DotenvModule.populate(processEnv, parsedAll, options);
287
+ if (lastError) {
288
+ return { parsed: parsedAll, error: lastError };
289
+ } else {
290
+ return { parsed: parsedAll };
291
+ }
292
+ }
293
+ function config(options) {
294
+ if (_dotenvKey(options).length === 0) {
295
+ return DotenvModule.configDotenv(options);
296
+ }
297
+ const vaultPath = _vaultPath(options);
298
+ if (!vaultPath) {
299
+ _warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}. Did you forget to build it?`);
300
+ return DotenvModule.configDotenv(options);
301
+ }
302
+ return DotenvModule._configVault(options);
303
+ }
304
+ function decrypt(encrypted, keyStr) {
305
+ const key = Buffer.from(keyStr.slice(-64), "hex");
306
+ let ciphertext = Buffer.from(encrypted, "base64");
307
+ const nonce = ciphertext.subarray(0, 12);
308
+ const authTag = ciphertext.subarray(-16);
309
+ ciphertext = ciphertext.subarray(12, -16);
310
+ try {
311
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
312
+ aesgcm.setAuthTag(authTag);
313
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
314
+ } catch (error) {
315
+ const isRange = error instanceof RangeError;
316
+ const invalidKeyLength = error.message === "Invalid key length";
317
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
318
+ if (isRange || invalidKeyLength) {
319
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
320
+ err.code = "INVALID_DOTENV_KEY";
321
+ throw err;
322
+ } else if (decryptionFailed) {
323
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
324
+ err.code = "DECRYPTION_FAILED";
325
+ throw err;
326
+ } else {
327
+ throw error;
328
+ }
329
+ }
330
+ }
331
+ function populate(processEnv, parsed, options = {}) {
332
+ const debug2 = Boolean(options && options.debug);
333
+ const override = Boolean(options && options.override);
334
+ if (typeof parsed !== "object") {
335
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
336
+ err.code = "OBJECT_REQUIRED";
337
+ throw err;
338
+ }
339
+ for (const key of Object.keys(parsed)) {
340
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
341
+ if (override === true) {
342
+ processEnv[key] = parsed[key];
343
+ }
344
+ if (debug2) {
345
+ if (override === true) {
346
+ _debug(`"${key}" is already defined and WAS overwritten`);
347
+ } else {
348
+ _debug(`"${key}" is already defined and was NOT overwritten`);
349
+ }
350
+ }
351
+ } else {
352
+ processEnv[key] = parsed[key];
353
+ }
354
+ }
355
+ }
356
+ var DotenvModule = {
357
+ configDotenv,
358
+ _configVault,
359
+ _parseVault,
360
+ config,
361
+ decrypt,
362
+ parse,
363
+ populate
364
+ };
365
+ module2.exports.configDotenv = DotenvModule.configDotenv;
366
+ module2.exports._configVault = DotenvModule._configVault;
367
+ module2.exports._parseVault = DotenvModule._parseVault;
368
+ module2.exports.config = DotenvModule.config;
369
+ module2.exports.decrypt = DotenvModule.decrypt;
370
+ module2.exports.parse = DotenvModule.parse;
371
+ module2.exports.populate = DotenvModule.populate;
372
+ module2.exports = DotenvModule;
373
+ }
374
+ });
375
+ var import_dotenv = (0, import_chunk_4VNS5WPM.__toESM)(require_main());
376
+ var debug = (0, import_debug.default)("prisma:tryLoadEnv");
377
+ function tryLoadEnvs({
378
+ rootEnvPath,
379
+ schemaEnvPath
380
+ }, opts = {
381
+ conflictCheck: "none"
382
+ }) {
383
+ const rootEnvInfo = loadEnv(rootEnvPath);
384
+ if (opts.conflictCheck !== "none") {
385
+ checkForConflicts(rootEnvInfo, schemaEnvPath, opts.conflictCheck);
386
+ }
387
+ let schemaEnvInfo = null;
388
+ if (!pathsEqual(rootEnvInfo?.path, schemaEnvPath)) {
389
+ schemaEnvInfo = loadEnv(schemaEnvPath);
390
+ }
391
+ if (!rootEnvInfo && !schemaEnvInfo) {
392
+ debug("No Environment variables loaded");
393
+ }
394
+ if (schemaEnvInfo?.dotenvResult.error) {
395
+ return console.error((0, import_chunk_PG5FDKSF.red)((0, import_chunk_PG5FDKSF.bold)("Schema Env Error: ")) + schemaEnvInfo.dotenvResult.error);
396
+ }
397
+ const messages = [rootEnvInfo?.message, schemaEnvInfo?.message].filter(Boolean);
398
+ return {
399
+ message: messages.join("\n"),
400
+ parsed: {
401
+ ...rootEnvInfo?.dotenvResult?.parsed,
402
+ ...schemaEnvInfo?.dotenvResult?.parsed
403
+ }
404
+ };
405
+ }
406
+ function checkForConflicts(rootEnvInfo, envPath, type) {
407
+ const parsedRootEnv = rootEnvInfo?.dotenvResult.parsed;
408
+ const areNotTheSame = !pathsEqual(rootEnvInfo?.path, envPath);
409
+ if (parsedRootEnv && envPath && areNotTheSame && import_fs.default.existsSync(envPath)) {
410
+ const envConfig = import_dotenv.default.parse(import_fs.default.readFileSync(envPath));
411
+ const conflicts = [];
412
+ for (const k in envConfig) {
413
+ if (parsedRootEnv[k] === envConfig[k]) {
414
+ conflicts.push(k);
415
+ }
416
+ }
417
+ if (conflicts.length > 0) {
418
+ const relativeRootEnvPath = import_path.default.relative(process.cwd(), rootEnvInfo.path);
419
+ const relativeEnvPath = import_path.default.relative(process.cwd(), envPath);
420
+ if (type === "error") {
421
+ const message = `There is a conflict between env var${conflicts.length > 1 ? "s" : ""} in ${(0, import_chunk_PG5FDKSF.underline)(
422
+ relativeRootEnvPath
423
+ )} and ${(0, import_chunk_PG5FDKSF.underline)(relativeEnvPath)}
424
+ Conflicting env vars:
425
+ ${conflicts.map((conflict) => ` ${(0, import_chunk_PG5FDKSF.bold)(conflict)}`).join("\n")}
426
+
427
+ We suggest to move the contents of ${(0, import_chunk_PG5FDKSF.underline)(relativeEnvPath)} to ${(0, import_chunk_PG5FDKSF.underline)(
428
+ relativeRootEnvPath
429
+ )} to consolidate your env vars.
430
+ `;
431
+ throw new Error(message);
432
+ } else if (type === "warn") {
433
+ const message = `Conflict for env var${conflicts.length > 1 ? "s" : ""} ${conflicts.map((c) => (0, import_chunk_PG5FDKSF.bold)(c)).join(", ")} in ${(0, import_chunk_PG5FDKSF.underline)(relativeRootEnvPath)} and ${(0, import_chunk_PG5FDKSF.underline)(relativeEnvPath)}
434
+ Env vars from ${(0, import_chunk_PG5FDKSF.underline)(relativeEnvPath)} overwrite the ones from ${(0, import_chunk_PG5FDKSF.underline)(relativeRootEnvPath)}
435
+ `;
436
+ console.warn(`${(0, import_chunk_PG5FDKSF.yellow)("warn(prisma)")} ${message}`);
437
+ }
438
+ }
439
+ }
440
+ }
441
+ function loadEnv(envPath) {
442
+ if (exists(envPath)) {
443
+ debug(`Environment variables loaded from ${envPath}`);
444
+ const dotenvOutput = import_dotenv.default.config({
445
+ path: envPath,
446
+ // Useful to debug dotenv parsing, prints errors & warnings
447
+ // Set to any value to enable
448
+ // Example for empty .env file
449
+ // [dotenv][DEBUG] did not match key and value when parsing line 1:
450
+ //
451
+ // Value needs to be null or undefined, false is truthy
452
+ // https://github.com/motdotla/dotenv/blob/7301ac9be0b2c766f865bbe24280bf82586d25aa/lib/main.js#L89-L91
453
+ debug: process.env.DOTENV_CONFIG_DEBUG ? true : void 0
454
+ });
455
+ const dotenvExpandOutput = (0, import_chunk_T2PM5TKT.dotenvExpand)(dotenvOutput);
456
+ return {
457
+ dotenvResult: dotenvExpandOutput,
458
+ message: (0, import_chunk_PG5FDKSF.dim)(`Environment variables loaded from ${import_path.default.relative(process.cwd(), envPath)}`),
459
+ path: envPath
460
+ };
461
+ } else {
462
+ debug(`Environment variables not found at ${envPath}`);
463
+ }
464
+ return null;
465
+ }
466
+ function pathsEqual(path1, path2) {
467
+ return path1 && path2 && import_path.default.resolve(path1) === import_path.default.resolve(path2);
468
+ }
469
+ function exists(p) {
470
+ return Boolean(p && import_fs.default.existsSync(p));
471
+ }
@@ -0,0 +1,186 @@
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_46ABODUM_exports = {};
30
+ __export(chunk_46ABODUM_exports, {
31
+ getEnvPaths: () => getEnvPaths
32
+ });
33
+ module.exports = __toCommonJS(chunk_46ABODUM_exports);
34
+ var import_chunk_3FP46GUV = require("./chunk-3FP46GUV.js");
35
+ var import_chunk_EYVG6XQS = require("./chunk-EYVG6XQS.js");
36
+ var import_debug = __toESM(require("@prisma/debug"));
37
+ var import_node_path = __toESM(require("node:path"));
38
+ var import_node_process = __toESM(require("node:process"));
39
+ var import_node_path2 = __toESM(require("node:path"));
40
+ var import_node_fs = __toESM(require("node:fs"));
41
+ var import_node_url = require("node:url");
42
+ var import_node_url2 = require("node:url");
43
+ var import_node_fs2 = __toESM(require("node:fs"));
44
+ var import_fs = __toESM(require("fs"));
45
+ var import_path = __toESM(require("path"));
46
+ var typeMappings = {
47
+ directory: "isDirectory",
48
+ file: "isFile"
49
+ };
50
+ function checkType(type) {
51
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
52
+ return;
53
+ }
54
+ throw new Error(`Invalid type specified: ${type}`);
55
+ }
56
+ var matchType = (type, stat) => stat[typeMappings[type]]();
57
+ var toPath = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
58
+ function locatePathSync(paths, {
59
+ cwd = import_node_process.default.cwd(),
60
+ type = "file",
61
+ allowSymlinks = true
62
+ } = {}) {
63
+ checkType(type);
64
+ cwd = toPath(cwd);
65
+ const statFunction = allowSymlinks ? import_node_fs.default.statSync : import_node_fs.default.lstatSync;
66
+ for (const path_ of paths) {
67
+ try {
68
+ const stat = statFunction(import_node_path2.default.resolve(cwd, path_), {
69
+ throwIfNoEntry: false
70
+ });
71
+ if (!stat) {
72
+ continue;
73
+ }
74
+ if (matchType(type, stat)) {
75
+ return path_;
76
+ }
77
+ } catch {
78
+ }
79
+ }
80
+ }
81
+ function toPath2(urlOrPath) {
82
+ return urlOrPath instanceof URL ? (0, import_node_url2.fileURLToPath)(urlOrPath) : urlOrPath;
83
+ }
84
+ function pathExistsSync(path4) {
85
+ try {
86
+ import_node_fs2.default.accessSync(path4);
87
+ return true;
88
+ } catch {
89
+ return false;
90
+ }
91
+ }
92
+ var findUpStop = Symbol("findUpStop");
93
+ function findUpMultipleSync(name, options = {}) {
94
+ let directory = import_node_path.default.resolve(toPath2(options.cwd) ?? "");
95
+ const { root } = import_node_path.default.parse(directory);
96
+ const stopAt = import_node_path.default.resolve(directory, toPath2(options.stopAt) ?? root);
97
+ const limit = options.limit ?? Number.POSITIVE_INFINITY;
98
+ const paths = [name].flat();
99
+ const runMatcher = (locateOptions) => {
100
+ if (typeof name !== "function") {
101
+ return locatePathSync(paths, locateOptions);
102
+ }
103
+ const foundPath = name(locateOptions.cwd);
104
+ if (typeof foundPath === "string") {
105
+ return locatePathSync([foundPath], locateOptions);
106
+ }
107
+ return foundPath;
108
+ };
109
+ const matches = [];
110
+ while (true) {
111
+ const foundPath = runMatcher({ ...options, cwd: directory });
112
+ if (foundPath === findUpStop) {
113
+ break;
114
+ }
115
+ if (foundPath) {
116
+ matches.push(import_node_path.default.resolve(directory, foundPath));
117
+ }
118
+ if (directory === stopAt || matches.length >= limit) {
119
+ break;
120
+ }
121
+ directory = import_node_path.default.dirname(directory);
122
+ }
123
+ return matches;
124
+ }
125
+ function findUpSync(name, options = {}) {
126
+ const matches = findUpMultipleSync(name, { ...options, limit: 1 });
127
+ return matches[0];
128
+ }
129
+ var debug = (0, import_debug.default)("prisma:loadEnv");
130
+ async function getEnvPaths(schemaPath, opts = { cwd: process.cwd() }) {
131
+ const rootEnvPath = getProjectRootEnvPath({ cwd: opts.cwd }) ?? null;
132
+ const schemaEnvPathFromArgs = schemaPathToEnvPath(schemaPath);
133
+ const schemaEnvPathFromPkgJson = schemaPathToEnvPath(await readSchemaPathFromPkgJson());
134
+ const schemaEnvPaths = [
135
+ schemaEnvPathFromArgs,
136
+ // 1 - Check --schema directory for .env
137
+ schemaEnvPathFromPkgJson,
138
+ // 2 - Check package.json schema directory for .env
139
+ "./prisma/.env",
140
+ // 3 - Check ./prisma directory for .env
141
+ "./.env"
142
+ // 4 - Check cwd for .env
143
+ ];
144
+ const schemaEnvPath = schemaEnvPaths.find(import_chunk_3FP46GUV.exists);
145
+ return { rootEnvPath, schemaEnvPath };
146
+ }
147
+ async function readSchemaPathFromPkgJson() {
148
+ try {
149
+ const pkgJsonSchema = await (0, import_chunk_EYVG6XQS.getSchemaFromPackageJson)(process.cwd());
150
+ if (pkgJsonSchema.ok) {
151
+ pkgJsonSchema.schema.schemaPath;
152
+ }
153
+ return null;
154
+ } catch {
155
+ return null;
156
+ }
157
+ }
158
+ function getProjectRootEnvPath(opts) {
159
+ const pkgJsonPath = findUpSync((dir) => {
160
+ const pkgPath = import_path.default.join(dir, "package.json");
161
+ if (pathExistsSync(pkgPath)) {
162
+ try {
163
+ const pkg = JSON.parse(import_fs.default.readFileSync(pkgPath, "utf8"));
164
+ if (pkg["name"] !== ".prisma/client") {
165
+ debug(`project root found at ${pkgPath}`);
166
+ return pkgPath;
167
+ }
168
+ } catch (e) {
169
+ debug(`skipping package.json at ${pkgPath}`);
170
+ }
171
+ }
172
+ return void 0;
173
+ }, opts);
174
+ if (!pkgJsonPath) {
175
+ return null;
176
+ }
177
+ const candidate = import_path.default.join(import_path.default.dirname(pkgJsonPath), ".env");
178
+ if (!import_fs.default.existsSync(candidate)) {
179
+ return null;
180
+ }
181
+ return candidate;
182
+ }
183
+ function schemaPathToEnvPath(schemaPath) {
184
+ if (!schemaPath) return null;
185
+ return import_path.default.join(import_path.default.dirname(schemaPath), ".env");
186
+ }