@prisma/internals 6.6.0-dev.39 → 6.6.0-dev.40

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 (193) hide show
  1. package/dist/Generator.js +1 -1
  2. package/dist/WasmPanicRegistry.js +1 -1
  3. package/dist/{chunk-T4QTTY5D.js → chunk-2CZNJDOD.js} +6 -6
  4. package/dist/chunk-2QTAK7KO.js +101 -0
  5. package/dist/{chunk-5TPBYAYG.js → chunk-3DQANJMY.js} +10 -10
  6. package/dist/{chunk-2ESYSVXG.js → chunk-4VNS5WPM.js} +3 -9
  7. package/dist/{chunk-NLYH6XB4.js → chunk-5AI4FIZ3.js} +10 -10
  8. package/dist/{chunk-QKPV6M3S.js → chunk-5SQV46LC.js} +5 -5
  9. package/dist/{chunk-6TVEFPKE.js → chunk-5VQNKCKW.js} +7 -7
  10. package/dist/chunk-6ATA6U3B.js +1076 -0
  11. package/dist/{chunk-DGLNFHJB.js → chunk-6EV2YAT6.js} +7 -7
  12. package/dist/{chunk-LSYWDURQ.js → chunk-6TTRTZXU.js} +5 -5
  13. package/dist/{chunk-ORR3O5RU.js → chunk-75BIJ5PX.js} +57 -57
  14. package/dist/{chunk-3GSMZHEZ.js → chunk-A4WCN34G.js} +21 -25
  15. package/dist/{chunk-QC7APOLV.js → chunk-AZV6HVKA.js} +5 -5
  16. package/dist/{chunk-XTF5F2RB.js → chunk-B6NQCD2C.js} +21 -25
  17. package/dist/{chunk-7CMXNYMQ.js → chunk-BUIBZ427.js} +11 -15
  18. package/dist/{chunk-WEATFJ6G.js → chunk-CR3XKUEA.js} +10 -10
  19. package/dist/{chunk-F46BPOEO.js → chunk-D4VDA2TZ.js} +7 -7
  20. package/dist/{chunk-PORKIX5G.js → chunk-D4VZUY3O.js} +6 -6
  21. package/dist/{chunk-YE7HS3KJ.js → chunk-DKSUHQGA.js} +8 -8
  22. package/dist/{chunk-SYCT2PLK.js → chunk-DTPFRZWV.js} +5 -5
  23. package/dist/{chunk-EIERU2IM.js → chunk-EPXBOIA5.js} +6 -6
  24. package/dist/{chunk-2WR3PY2L.js → chunk-ETYWYJBX.js} +60 -60
  25. package/dist/{chunk-DGZO4GAJ.js → chunk-EWWOTVR3.js} +6 -6
  26. package/dist/{chunk-2T4NJDHK.js → chunk-FXMGS3L5.js} +21 -40
  27. package/dist/{chunk-FNA4EAZ6.js → chunk-HAGJ64PM.js} +10 -10
  28. package/dist/{chunk-C3XVEHBX.js → chunk-HG3YOAAE.js} +8 -8
  29. package/dist/{chunk-LZNQTPCN.js → chunk-HNPYV6GE.js} +5 -5
  30. package/dist/{chunk-M6WKKED7.js → chunk-IBIHBHS4.js} +5 -5
  31. package/dist/{chunk-RAYPCPVU.js → chunk-IDINCQMN.js} +56 -57
  32. package/dist/chunk-JO6FUCDD.js +1076 -0
  33. package/dist/{chunk-V37JTUKZ.js → chunk-JOIIWB3U.js} +116 -116
  34. package/dist/{chunk-EWKNNPH2.js → chunk-JYMY3OAI.js} +6 -6
  35. package/dist/{chunk-KYMYLH7F.js → chunk-K5W6WZ6E.js} +162 -165
  36. package/dist/{chunk-F3AMC52Y.js → chunk-KB5DKCI4.js} +11 -11
  37. package/dist/{chunk-2R6DII47.js → chunk-KDP6C3CB.js} +5 -5
  38. package/dist/{chunk-CCQRDM7X.js → chunk-LMVSIVKQ.js} +4 -8
  39. package/dist/{chunk-UETN3RLH.js → chunk-LRJ4X43J.js} +5 -5
  40. package/dist/{chunk-IKQFIRRX.js → chunk-LRU47BGE.js} +6 -6
  41. package/dist/{chunk-KR25OQ6F.js → chunk-MM4ARWWY.js} +5 -5
  42. package/dist/{chunk-R7U45FIQ.js → chunk-N5S7K4Y6.js} +7 -7
  43. package/dist/{chunk-VLGS4WJI.js → chunk-NVNI2SRU.js} +13 -13
  44. package/dist/{chunk-PCD5SHSJ.js → chunk-OG6LFW2K.js} +11 -15
  45. package/dist/chunk-PFYALFCY.js +26 -0
  46. package/dist/{chunk-QY2WL356.js → chunk-Q33Z6IUP.js} +5 -5
  47. package/dist/{chunk-BTIX67Y6.js → chunk-Q6FDURCA.js} +21 -25
  48. package/dist/{chunk-PYCGBYLY.js → chunk-Q7XOR5W5.js} +20 -24
  49. package/dist/{chunk-ETNCBIDF.js → chunk-QGJH4P4N.js} +6 -6
  50. package/dist/{chunk-ZGAIRZ32.js → chunk-R6QH57HZ.js} +5 -5
  51. package/dist/{chunk-T4ZYOYTH.js → chunk-RAEXBZ6E.js} +22 -26
  52. package/dist/{chunk-T7EWI7A3.js → chunk-TQFONRJP.js} +7 -7
  53. package/dist/{chunk-G6YGTH5E.js → chunk-TZWVNLXX.js} +5 -5
  54. package/dist/{chunk-6LXUM3J5.js → chunk-U4GPK244.js} +22 -26
  55. package/dist/{chunk-ZCVVZ6U6.js → chunk-UTJGRVMG.js} +11 -11
  56. package/dist/{chunk-PKIVYJWI.js → chunk-UY6SQF5H.js} +20 -24
  57. package/dist/{chunk-H5XZKD22.js → chunk-UZTXEBTM.js} +7 -7
  58. package/dist/{chunk-23MPYLL6.js → chunk-VVPSLVOR.js} +27 -27
  59. package/dist/{chunk-MWUHUQI3.js → chunk-WSZXPLJQ.js} +7 -7
  60. package/dist/{chunk-7NELNWFH.js → chunk-XLTQGAI2.js} +6 -6
  61. package/dist/chunk-YR5KNFKN.js +1834 -0
  62. package/dist/{chunk-LLMEYK53.js → chunk-YRZY5EFW.js} +21 -25
  63. package/dist/{chunk-MBB2KJWX.js → chunk-ZJWZK45Z.js} +5 -5
  64. package/dist/chunk-ZSINRHD4.js +43 -0
  65. package/dist/cli/Help.js +1 -1
  66. package/dist/cli/checkUnsupportedDataProxy.js +56 -53
  67. package/dist/cli/directoryConfig.js +1 -1
  68. package/dist/cli/getGeneratorSuccessMessage.js +1 -1
  69. package/dist/cli/getSchema.js +60 -57
  70. package/dist/cli/getTypescriptVersion.js +1 -1
  71. package/dist/cli/hashes.js +56 -53
  72. package/dist/cli/schemaContext.js +56 -53
  73. package/dist/cli/utils.js +5 -5
  74. package/dist/client/getClientEngineType.js +1 -1
  75. package/dist/convertCredentials.js +1 -1
  76. package/dist/dotenvExpand.js +1 -1
  77. package/dist/engine-commands/errorHelpers.js +5 -5
  78. package/dist/engine-commands/formatSchema.js +55 -52
  79. package/dist/engine-commands/getConfig.js +15 -16
  80. package/dist/engine-commands/getDmmf.js +12 -13
  81. package/dist/engine-commands/getEngineVersion.js +11 -11
  82. package/dist/engine-commands/getEnginesMetaInfo.js +14 -14
  83. package/dist/engine-commands/index.js +66 -63
  84. package/dist/engine-commands/lintSchema.d.ts +1 -1
  85. package/dist/engine-commands/lintSchema.js +10 -11
  86. package/dist/engine-commands/mergeSchemas.js +12 -13
  87. package/dist/engine-commands/queryEngineCommons.js +8 -8
  88. package/dist/engine-commands/relativizePathInPSLError.js +1 -1
  89. package/dist/engine-commands/validate.js +12 -13
  90. package/dist/errorReporting.d.ts +0 -1
  91. package/dist/errorReporting.js +7 -7
  92. package/dist/get-generators/generatorResolvers/generatorResolvers.js +55 -52
  93. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.js +4 -4
  94. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.js +1 -1
  95. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.js +5 -5
  96. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.js +55 -52
  97. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.js +1 -1
  98. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.js +4 -4
  99. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.js +1 -1
  100. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.test.js +1 -1
  101. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.js +56 -53
  102. package/dist/get-generators/getGenerators.js +58 -55
  103. package/dist/get-generators/utils/binaryTypeToEngineType.js +1 -1
  104. package/dist/get-generators/utils/engineTypeToBinaryType.js +1 -1
  105. package/dist/get-generators/utils/fixBinaryTargets.js +1 -1
  106. package/dist/get-generators/utils/getBinaryPathsByVersion.js +4 -4
  107. package/dist/get-generators/utils/getEngineVersionForGenerator.js +1 -1
  108. package/dist/get-generators/utils/printGeneratorConfig.js +7 -7
  109. package/dist/getPackedPackage.js +9 -9
  110. package/dist/highlight/highlight.js +1 -1
  111. package/dist/highlight/languages/dml.js +1 -1
  112. package/dist/highlight/languages/sql.js +1 -1
  113. package/dist/highlight/prism.js +1 -1
  114. package/dist/highlight/theme.js +1 -1
  115. package/dist/index.d.ts +1 -1
  116. package/dist/index.js +115 -115
  117. package/dist/logger.js +9 -9
  118. package/dist/{multipart-parser-3E7JBBYS.js → multipart-parser-3AFJFP6K.js} +7 -7
  119. package/dist/panic.d.ts +1 -4
  120. package/dist/panic.js +7 -7
  121. package/dist/resolveBinary.js +9 -9
  122. package/dist/resolveOutput.js +1 -1
  123. package/dist/schemaEngineCommands.js +12 -12
  124. package/dist/sendPanic.js +7 -111
  125. package/dist/utils/__tests__/isCi.test.js +1 -1
  126. package/dist/utils/__tests__/isInteractive.test.js +1 -1
  127. package/dist/utils/__tests__/maskSchema.test.js +1 -1
  128. package/dist/utils/assertAlways.js +1 -1
  129. package/dist/utils/assertNever.js +1 -1
  130. package/dist/utils/binaryTargetRegex.js +1 -1
  131. package/dist/utils/byline.js +1 -1
  132. package/dist/utils/callOnce.js +1 -1
  133. package/dist/utils/callOnce.test.js +1 -1
  134. package/dist/utils/canPrompt.js +1 -1
  135. package/dist/utils/chmodPlusX.js +1 -1
  136. package/dist/utils/cloudflareD1.js +4 -4
  137. package/dist/utils/drawBox.js +1 -1
  138. package/dist/utils/extractPreviewFeatures.js +1 -1
  139. package/dist/utils/formatTable.js +1 -1
  140. package/dist/utils/formatms.js +1 -1
  141. package/dist/utils/fs-functional.js +12 -12
  142. package/dist/utils/fs-utils.js +9 -9
  143. package/dist/utils/getCommandWithExecutor.js +4 -4
  144. package/dist/utils/getEnvPaths.js +55 -52
  145. package/dist/utils/getGitHubIssueUrl.js +5 -4
  146. package/dist/utils/getMigrateConfigDir.js +1 -1
  147. package/dist/utils/getVersionFromPackageJson.js +4 -4
  148. package/dist/utils/handleEngineLoadingErrors.js +1 -1
  149. package/dist/utils/handlePanic.js +11 -108
  150. package/dist/utils/hasOwnProperty.js +1 -1
  151. package/dist/utils/isCi.js +1 -1
  152. package/dist/utils/isCurrentBinInstalledGlobally.js +3 -3
  153. package/dist/utils/isInContainer.js +1 -1
  154. package/dist/utils/isInNpmLifecycleHook.js +1 -1
  155. package/dist/utils/isInteractive.js +1 -1
  156. package/dist/utils/isPromiseLike.js +1 -1
  157. package/dist/utils/isValidJsIdentifier.js +4 -4
  158. package/dist/utils/keyBy.js +1 -1
  159. package/dist/utils/link.js +3 -3
  160. package/dist/utils/load.js +3 -3
  161. package/dist/utils/loadEnvFile.js +55 -52
  162. package/dist/utils/mapKeys.js +1 -1
  163. package/dist/utils/mapObjectValues.js +1 -1
  164. package/dist/utils/maskSchema.js +1 -1
  165. package/dist/utils/max.js +1 -1
  166. package/dist/utils/max.test.js +1 -1
  167. package/dist/utils/maybeInGitHook.js +1 -1
  168. package/dist/utils/missingDatasource.js +4 -4
  169. package/dist/utils/missingGeneratorMessage.js +6 -6
  170. package/dist/utils/now.js +1 -1
  171. package/dist/utils/omit.js +1 -1
  172. package/dist/utils/parseAWSNodejsRuntimeEnvVarVersion.js +1 -1
  173. package/dist/utils/parseEnvValue.js +1 -1
  174. package/dist/utils/path.js +1 -1
  175. package/dist/utils/path.test.js +1 -1
  176. package/dist/utils/pick.js +1 -1
  177. package/dist/utils/printConfigWarnings.js +1 -1
  178. package/dist/utils/prismaPostgres.js +1 -1
  179. package/dist/utils/prismaPostgres.test.js +1 -1
  180. package/dist/utils/schemaFileInput.d.ts +0 -4
  181. package/dist/utils/schemaFileInput.js +3 -7
  182. package/dist/utils/serializeQueryEngineName.js +1 -1
  183. package/dist/utils/setClassName.js +1 -1
  184. package/dist/utils/toSchemasContainer.js +1 -1
  185. package/dist/utils/tryLoadEnvs.js +6 -6
  186. package/dist/utils/unique.js +1 -1
  187. package/dist/utils/vercelPkgPathRegex.js +1 -1
  188. package/dist/warnOnce.js +4 -4
  189. package/dist/wasm.js +5 -5
  190. package/package.json +8 -8
  191. package/dist/chunk-5PNJER7H.js +0 -15655
  192. package/dist/chunk-AQJV4AGE.js +0 -15655
  193. package/dist/chunk-YRBRUREX.js +0 -57
@@ -0,0 +1,1076 @@
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 __toESM2 = (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_6ATA6U3B_exports = {};
30
+ __export(chunk_6ATA6U3B_exports, {
31
+ checkTypeScriptVersion: () => checkTypeScriptVersion,
32
+ checkUnsupportedDataProxy: () => checkUnsupportedDataProxy,
33
+ debug: () => debug4,
34
+ forbiddenCmdWithDataProxyFlagMessage: () => forbiddenCmdWithDataProxyFlagMessage,
35
+ formatSchema: () => formatSchema,
36
+ generatorResolvers: () => generatorResolvers,
37
+ getBinaryTargetForCurrentPlatform: () => import_get_platform2.getBinaryTargetForCurrentPlatform,
38
+ getCLIPathHash: () => getCLIPathHash,
39
+ getEnvPaths: () => getEnvPaths,
40
+ getGenerator: () => getGenerator,
41
+ getGenerators: () => getGenerators,
42
+ getNodeAPIName: () => import_get_platform2.getNodeAPIName,
43
+ getPrismaConfigFromPackageJson: () => getPrismaConfigFromPackageJson,
44
+ getProjectHash: () => getProjectHash,
45
+ getSchema: () => getSchema,
46
+ getSchemaDir: () => getSchemaDir,
47
+ getSchemaFromPackageJson: () => getSchemaFromPackageJson,
48
+ getSchemaWithPath: () => getSchemaWithPath,
49
+ getSchemaWithPathOptional: () => getSchemaWithPathOptional,
50
+ knownBinaryTargets: () => knownBinaryTargets,
51
+ loadEnvFile: () => loadEnvFile,
52
+ loadSchemaContext: () => loadSchemaContext,
53
+ prismaClientResolver: () => prismaClientResolver,
54
+ processSchemaResult: () => processSchemaResult,
55
+ skipIndex: () => skipIndex
56
+ });
57
+ module.exports = __toCommonJS(chunk_6ATA6U3B_exports);
58
+ var import_chunk_QGJH4P4N = require("./chunk-QGJH4P4N.js");
59
+ var import_chunk_GHHABGYW = require("./chunk-GHHABGYW.js");
60
+ var import_chunk_EUTJYQDW = require("./chunk-EUTJYQDW.js");
61
+ var import_chunk_EWWOTVR3 = require("./chunk-EWWOTVR3.js");
62
+ var import_chunk_72UZXEBG = require("./chunk-72UZXEBG.js");
63
+ var import_chunk_X77CS5RK = require("./chunk-X77CS5RK.js");
64
+ var import_chunk_EPXBOIA5 = require("./chunk-EPXBOIA5.js");
65
+ var import_chunk_RS2R7COT = require("./chunk-RS2R7COT.js");
66
+ var import_chunk_X3P4J7WW = require("./chunk-X3P4J7WW.js");
67
+ var import_chunk_LRU47BGE = require("./chunk-LRU47BGE.js");
68
+ var import_chunk_UTJGRVMG = require("./chunk-UTJGRVMG.js");
69
+ var import_chunk_5V36RLCO = require("./chunk-5V36RLCO.js");
70
+ var import_chunk_5FJ3MENK = require("./chunk-5FJ3MENK.js");
71
+ var import_chunk_AZV6HVKA = require("./chunk-AZV6HVKA.js");
72
+ var import_chunk_XLTQGAI2 = require("./chunk-XLTQGAI2.js");
73
+ var import_chunk_HAGJ64PM = require("./chunk-HAGJ64PM.js");
74
+ var import_chunk_CRVLHWC5 = require("./chunk-CRVLHWC5.js");
75
+ var import_chunk_J77ZIDXB = require("./chunk-J77ZIDXB.js");
76
+ var import_chunk_BUIBZ427 = require("./chunk-BUIBZ427.js");
77
+ var import_chunk_Q7XOR5W5 = require("./chunk-Q7XOR5W5.js");
78
+ var import_chunk_RAEXBZ6E = require("./chunk-RAEXBZ6E.js");
79
+ var import_chunk_Q6FDURCA = require("./chunk-Q6FDURCA.js");
80
+ var import_chunk_6EV2YAT6 = require("./chunk-6EV2YAT6.js");
81
+ var import_chunk_2B26F5N3 = require("./chunk-2B26F5N3.js");
82
+ var import_chunk_M3GBKLGE = require("./chunk-M3GBKLGE.js");
83
+ var import_chunk_LMVSIVKQ = require("./chunk-LMVSIVKQ.js");
84
+ var import_chunk_DYVL6P7F = require("./chunk-DYVL6P7F.js");
85
+ var import_chunk_IOIAK7V7 = require("./chunk-IOIAK7V7.js");
86
+ var import_chunk_K5W6WZ6E = require("./chunk-K5W6WZ6E.js");
87
+ var import_chunk_VVPSLVOR = require("./chunk-VVPSLVOR.js");
88
+ var import_chunk_ZJWZK45Z = require("./chunk-ZJWZK45Z.js");
89
+ var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
90
+ var import_chunk_4VNS5WPM = require("./chunk-4VNS5WPM.js");
91
+ var import_debug = require("@prisma/debug");
92
+ var import_schema_files_loader = require("@prisma/schema-files-loader");
93
+ var import_fs = __toESM2(require("fs"));
94
+ var import_path = __toESM2(require("path"));
95
+ var import_util = require("util");
96
+ var import_debug2 = __toESM2(require("@prisma/debug"));
97
+ var import_crypto = __toESM2(require("crypto"));
98
+ var import_path2 = __toESM2(require("path"));
99
+ var import_debug3 = __toESM2(require("@prisma/debug"));
100
+ var import_engines = require("@prisma/engines");
101
+ var import_fetch_engine = require("@prisma/fetch-engine");
102
+ var import_get_platform = require("@prisma/get-platform");
103
+ var import_path3 = __toESM2(require("path"));
104
+ var import_debug4 = __toESM2(require("@prisma/debug"));
105
+ var import_fs2 = __toESM2(require("fs"));
106
+ var import_path4 = __toESM2(require("path"));
107
+ var import_debug5 = __toESM2(require("@prisma/debug"));
108
+ var import_fs3 = __toESM2(require("fs"));
109
+ var import_path5 = __toESM2(require("path"));
110
+ var import_debug6 = __toESM2(require("@prisma/debug"));
111
+ var import_node_path = __toESM2(require("node:path"));
112
+ var import_node_process = __toESM2(require("node:process"));
113
+ var import_node_path2 = __toESM2(require("node:path"));
114
+ var import_node_fs = __toESM2(require("node:fs"));
115
+ var import_node_url = require("node:url");
116
+ var import_node_fs2 = __toESM2(require("node:fs"));
117
+ var import_fs4 = __toESM2(require("fs"));
118
+ var import_path6 = __toESM2(require("path"));
119
+ var import_get_platform2 = require("@prisma/get-platform");
120
+ var debug = (0, import_debug2.default)("prisma:format");
121
+ async function formatSchema({ schemas }, inputFormattingOptions) {
122
+ if (process.env.FORCE_PANIC_PRISMA_SCHEMA) {
123
+ handleFormatPanic(() => {
124
+ import_chunk_6EV2YAT6.prismaSchemaWasm.debug_panic();
125
+ });
126
+ }
127
+ const defaultFormattingOptions = {
128
+ tabSize: 2,
129
+ insertSpaces: true
130
+ };
131
+ const documentFormattingParams = {
132
+ textDocument: { uri: "file:/dev/null" },
133
+ options: {
134
+ ...defaultFormattingOptions,
135
+ ...inputFormattingOptions
136
+ }
137
+ };
138
+ const { formattedMultipleSchemas, lintDiagnostics } = handleFormatPanic(() => {
139
+ const formattedMultipleSchemasRaw = formatWasm(JSON.stringify(schemas), documentFormattingParams);
140
+ const formattedMultipleSchemas2 = JSON.parse(formattedMultipleSchemasRaw);
141
+ const lintDiagnostics2 = (0, import_chunk_BUIBZ427.lintSchema)({ schemas: formattedMultipleSchemas2 });
142
+ return { formattedMultipleSchemas: formattedMultipleSchemas2, lintDiagnostics: lintDiagnostics2 };
143
+ });
144
+ const lintWarnings = (0, import_chunk_BUIBZ427.getLintWarningsAsText)(lintDiagnostics);
145
+ if (lintWarnings && import_chunk_ZJWZK45Z.logger_exports.should.warn()) {
146
+ console.warn(lintWarnings);
147
+ }
148
+ return Promise.resolve(formattedMultipleSchemas);
149
+ }
150
+ function handleFormatPanic(tryCb) {
151
+ try {
152
+ return tryCb();
153
+ } catch (e) {
154
+ const { message, stack } = (0, import_chunk_LMVSIVKQ.getWasmError)(e);
155
+ debug(`Error formatting schema: ${message}`);
156
+ debug(stack);
157
+ const panic = new import_chunk_LMVSIVKQ.RustPanic(
158
+ /* message */
159
+ message,
160
+ /* rustStack */
161
+ stack,
162
+ /* request */
163
+ "@prisma/prisma-schema-wasm format",
164
+ "FMT_CLI"
165
+ /* FMT_CLI */
166
+ );
167
+ throw panic;
168
+ }
169
+ }
170
+ function formatWasm(schema, documentFormattingParams) {
171
+ const formattedSchema = import_chunk_6EV2YAT6.prismaSchemaWasm.format(schema, JSON.stringify(documentFormattingParams));
172
+ return formattedSchema;
173
+ }
174
+ var readFile = (0, import_util.promisify)(import_fs.default.readFile);
175
+ var stat = (0, import_util.promisify)(import_fs.default.stat);
176
+ var debug2 = (0, import_debug.Debug)("prisma:getSchema");
177
+ async function getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
178
+ const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
179
+ if (result.ok) {
180
+ return result.schema;
181
+ }
182
+ throw new Error(renderDefaultLookupError(result.error, cwd));
183
+ }
184
+ async function getSchemaWithPathOptional(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
185
+ const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
186
+ if (result.ok) {
187
+ return result.schema;
188
+ }
189
+ return null;
190
+ }
191
+ async function readSchemaFromSingleFile(schemaPath2) {
192
+ debug2("Reading schema from single file", schemaPath2);
193
+ const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath2, "file");
194
+ if (typeError) {
195
+ return { ok: false, error: typeError };
196
+ }
197
+ const file = await readFile(schemaPath2, { encoding: "utf-8" });
198
+ const schemaTuple = [schemaPath2, file];
199
+ return {
200
+ ok: true,
201
+ schema: { schemaPath: schemaPath2, schemaRootDir: import_path.default.dirname(schemaPath2), schemas: [schemaTuple] }
202
+ };
203
+ }
204
+ async function readSchemaFromDirectory(schemaPath2) {
205
+ debug2("Reading schema from multiple files", schemaPath2);
206
+ const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath2, "directory");
207
+ if (typeError) {
208
+ return { ok: false, error: typeError };
209
+ }
210
+ const files = await (0, import_schema_files_loader.loadSchemaFiles)(schemaPath2);
211
+ debug2("Loading config");
212
+ const config = await (0, import_chunk_RAEXBZ6E.getConfig)({
213
+ datamodel: files,
214
+ ignoreEnvVarErrors: true
215
+ });
216
+ debug2("Ok");
217
+ if (!(0, import_schema_files_loader.usesPrismaSchemaFolder)(config)) {
218
+ return { ok: false, error: { kind: "FolderPreviewNotEnabled", path: schemaPath2 } };
219
+ }
220
+ return { ok: true, schema: { schemaPath: schemaPath2, schemaRootDir: schemaPath2, schemas: files } };
221
+ }
222
+ async function readSchemaFromFileOrDirectory(schemaPath2) {
223
+ let stats;
224
+ try {
225
+ stats = await stat(schemaPath2);
226
+ } catch (e) {
227
+ if (e.code === "ENOENT") {
228
+ return { ok: false, error: { kind: "NotFound", path: schemaPath2 } };
229
+ }
230
+ throw e;
231
+ }
232
+ if (stats.isFile()) {
233
+ return readSchemaFromSingleFile(schemaPath2);
234
+ }
235
+ if (stats.isDirectory()) {
236
+ return readSchemaFromDirectory(schemaPath2);
237
+ }
238
+ return { ok: false, error: { kind: "WrongType", path: schemaPath2, expectedTypes: ["file", "directory"] } };
239
+ }
240
+ async function getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName }) {
241
+ if (schemaPathFromArgs) {
242
+ const absPath = import_path.default.resolve(cwd, schemaPathFromArgs);
243
+ const customSchemaResult = await readSchemaFromFileOrDirectory(absPath);
244
+ if (!customSchemaResult.ok) {
245
+ const relPath = import_path.default.relative(cwd, absPath);
246
+ throw new Error(
247
+ `Could not load \`${argumentName}\` from provided path \`${relPath}\`: ${renderLookupError(
248
+ customSchemaResult.error
249
+ )}`
250
+ );
251
+ }
252
+ return customSchemaResult;
253
+ }
254
+ const prismaConfigResult = await readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig);
255
+ if (prismaConfigResult.ok) {
256
+ return prismaConfigResult;
257
+ }
258
+ const pkgJsonResult = await getSchemaFromPackageJson(cwd);
259
+ if (pkgJsonResult.ok) {
260
+ return pkgJsonResult;
261
+ }
262
+ const defaultResult = await getDefaultSchema(cwd);
263
+ if (defaultResult.ok) {
264
+ return defaultResult;
265
+ }
266
+ return {
267
+ ok: false,
268
+ error: defaultResult.error
269
+ };
270
+ }
271
+ function renderLookupError(error) {
272
+ switch (error.kind) {
273
+ case "NotFound": {
274
+ const expected = error.expectedType ?? "file or directory";
275
+ return `${expected} not found`;
276
+ }
277
+ case "FolderPreviewNotEnabled":
278
+ return `"prismaSchemaFolder" preview feature must be enabled`;
279
+ case "WrongType":
280
+ return `expected ${error.expectedTypes.join(" or ")}`;
281
+ }
282
+ }
283
+ function renderDefaultLookupError(error, cwd) {
284
+ const parts = [
285
+ `Could not find Prisma Schema that is required for this command.`,
286
+ `You can either provide it with ${(0, import_chunk_PG5FDKSF.green)(
287
+ "`--schema`"
288
+ )} argument, set it as \`prisma.schema\` in your package.json or put it into the default location.`,
289
+ "Checked following paths:\n"
290
+ ];
291
+ const printedPaths = /* @__PURE__ */ new Set();
292
+ for (const failure of error.failures) {
293
+ const filePath = failure.rule.schemaPath.path;
294
+ if (!printedPaths.has(failure.rule.schemaPath.path)) {
295
+ parts.push(`${import_path.default.relative(cwd, filePath)}: ${renderLookupError(failure.error)}`);
296
+ printedPaths.add(filePath);
297
+ }
298
+ }
299
+ parts.push("\nSee also https://pris.ly/d/prisma-schema-location");
300
+ return parts.join("\n");
301
+ }
302
+ async function getPrismaConfigFromPackageJson(cwd) {
303
+ const pkgJson = await (0, import_chunk_K5W6WZ6E.readPackageUp)({ cwd, normalize: false });
304
+ const prismaPropertyFromPkgJson = pkgJson?.packageJson?.prisma;
305
+ if (!pkgJson) {
306
+ return null;
307
+ }
308
+ return {
309
+ data: prismaPropertyFromPkgJson,
310
+ packagePath: pkgJson.path
311
+ };
312
+ }
313
+ async function readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig) {
314
+ if (!schemaPathFromConfig) {
315
+ return {
316
+ ok: false,
317
+ error: { kind: "PrismaConfigNotConfigured" }
318
+ };
319
+ }
320
+ let schemaResult;
321
+ if (schemaPathFromConfig.kind === "single") {
322
+ schemaResult = await readSchemaFromSingleFile(schemaPathFromConfig.filePath);
323
+ if (!schemaResult.ok) {
324
+ throw new Error(
325
+ `Could not load schema from file \`${schemaPathFromConfig.filePath}\` provided by "prisma.config.ts"\`: ${renderLookupError(schemaResult.error)}`
326
+ );
327
+ }
328
+ } else {
329
+ schemaResult = await readSchemaFromDirectory(schemaPathFromConfig.folderPath);
330
+ if (!schemaResult.ok) {
331
+ throw new Error(
332
+ `Could not load schema from folder \`${schemaPathFromConfig.folderPath}\` provided by "prisma.config.ts"\`: ${renderLookupError(schemaResult.error)}`
333
+ );
334
+ }
335
+ }
336
+ return schemaResult;
337
+ }
338
+ async function getSchemaFromPackageJson(cwd) {
339
+ const prismaConfig = await getPrismaConfigFromPackageJson(cwd);
340
+ debug2("prismaConfig", prismaConfig);
341
+ if (!prismaConfig || !prismaConfig.data?.schema) {
342
+ return { ok: false, error: { kind: "PackageJsonNotConfigured" } };
343
+ }
344
+ const schemaPathFromPkgJson = prismaConfig.data.schema;
345
+ if (typeof schemaPathFromPkgJson !== "string") {
346
+ throw new Error(
347
+ `Provided schema path \`${schemaPathFromPkgJson}\` from \`${import_path.default.relative(
348
+ cwd,
349
+ prismaConfig.packagePath
350
+ )}\` must be of type string`
351
+ );
352
+ }
353
+ const absoluteSchemaPath = import_path.default.isAbsolute(schemaPathFromPkgJson) ? schemaPathFromPkgJson : import_path.default.resolve(import_path.default.dirname(prismaConfig.packagePath), schemaPathFromPkgJson);
354
+ const lookupResult = await readSchemaFromFileOrDirectory(absoluteSchemaPath);
355
+ if (!lookupResult.ok) {
356
+ throw new Error(
357
+ `Could not load schema from \`${import_path.default.relative(
358
+ cwd,
359
+ absoluteSchemaPath
360
+ )}\` provided by "prisma.schema" config of \`${import_path.default.relative(
361
+ cwd,
362
+ prismaConfig.packagePath
363
+ )}\`: ${renderLookupError(lookupResult.error)}`
364
+ );
365
+ }
366
+ return lookupResult;
367
+ }
368
+ async function getDefaultSchema(cwd, failures = []) {
369
+ const schemaPrisma = {
370
+ schemaPath: {
371
+ path: import_path.default.join(cwd, "schema.prisma"),
372
+ kind: "file"
373
+ }
374
+ };
375
+ const prismaSchemaFile = {
376
+ schemaPath: {
377
+ path: import_path.default.join(cwd, "prisma", "schema.prisma"),
378
+ kind: "file"
379
+ },
380
+ conflictsWith: {
381
+ path: import_path.default.join(cwd, "prisma", "schema"),
382
+ kind: "directory"
383
+ }
384
+ };
385
+ const prismaSchemaFolder = {
386
+ schemaPath: {
387
+ path: import_path.default.join(cwd, "prisma", "schema"),
388
+ kind: "directory"
389
+ },
390
+ conflictsWith: {
391
+ path: import_path.default.join(cwd, "prisma", "schema.prisma"),
392
+ kind: "file"
393
+ }
394
+ };
395
+ const rules = [schemaPrisma, prismaSchemaFile, prismaSchemaFolder];
396
+ for (const rule of rules) {
397
+ debug2(`Checking existence of ${rule.schemaPath.path}`);
398
+ const schema = await loadSchemaFromDefaultLocation(rule.schemaPath);
399
+ if (!schema.ok) {
400
+ failures.push({ rule, error: schema.error });
401
+ continue;
402
+ }
403
+ if (rule.conflictsWith) {
404
+ const conflictingSchema = await loadSchemaFromDefaultLocation(rule.conflictsWith);
405
+ if (conflictingSchema.ok) {
406
+ throw new Error(
407
+ `Found Prisma Schemas at both \`${import_path.default.relative(cwd, rule.schemaPath.path)}\` and \`${import_path.default.relative(
408
+ cwd,
409
+ rule.conflictsWith.path
410
+ )}\`. Please remove one.`
411
+ );
412
+ }
413
+ }
414
+ return schema;
415
+ }
416
+ return {
417
+ ok: false,
418
+ error: {
419
+ kind: "NotFoundMultipleLocations",
420
+ failures
421
+ }
422
+ };
423
+ }
424
+ async function loadSchemaFromDefaultLocation(lookupPath) {
425
+ switch (lookupPath.kind) {
426
+ case "file":
427
+ return readSchemaFromSingleFile(lookupPath.path);
428
+ case "directory":
429
+ return readSchemaFromDirectory(lookupPath.path);
430
+ }
431
+ }
432
+ async function getSchemaDir(schemaPathFromArgs) {
433
+ if (schemaPathFromArgs) {
434
+ return import_path.default.resolve(import_path.default.dirname(schemaPathFromArgs));
435
+ }
436
+ const schemaPathResult = await getSchemaWithPath();
437
+ if (!schemaPathResult) {
438
+ return null;
439
+ }
440
+ return import_path.default.dirname(schemaPathResult.schemaPath);
441
+ }
442
+ async function getSchema(schemaPathFromArgs, schemaPathFromConfig) {
443
+ const schemaPathResult = await getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig);
444
+ return schemaPathResult.schemas;
445
+ }
446
+ async function getProjectHash(schemaPathFromArgs, schemaPathFromConfig) {
447
+ const projectPath = (await getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig))?.schemaPath ?? process.cwd();
448
+ return import_crypto.default.createHash("sha256").update(projectPath).digest("hex").substring(0, 8);
449
+ }
450
+ function getCLIPathHash() {
451
+ const cliPath = process.argv[1];
452
+ return import_crypto.default.createHash("sha256").update(cliPath).digest("hex").substring(0, 8);
453
+ }
454
+ async function loadSchemaContext({
455
+ schemaPathFromArg,
456
+ schemaPathFromConfig,
457
+ printLoadMessage = true,
458
+ ignoreEnvVarErrors = false,
459
+ allowNull = false,
460
+ schemaPathArgumentName = "--schema"
461
+ } = {}) {
462
+ let schemaResult = null;
463
+ if (allowNull) {
464
+ schemaResult = await getSchemaWithPathOptional(schemaPathFromArg, schemaPathFromConfig, {
465
+ argumentName: schemaPathArgumentName
466
+ });
467
+ if (!schemaResult) return null;
468
+ } else {
469
+ schemaResult = await getSchemaWithPath(schemaPathFromArg, schemaPathFromConfig, {
470
+ argumentName: schemaPathArgumentName
471
+ });
472
+ }
473
+ return processSchemaResult({ schemaResult, printLoadMessage, ignoreEnvVarErrors });
474
+ }
475
+ async function processSchemaResult({
476
+ schemaResult,
477
+ printLoadMessage = true,
478
+ ignoreEnvVarErrors = false
479
+ }) {
480
+ const cwd = process.cwd();
481
+ const loadedFromPathForLogMessages = import_path2.default.relative(cwd, schemaResult.schemaPath);
482
+ if (printLoadMessage) {
483
+ process.stdout.write((0, import_chunk_PG5FDKSF.dim)(`Prisma schema loaded from ${loadedFromPathForLogMessages}`) + "\n");
484
+ }
485
+ const configFromPsl = await (0, import_chunk_RAEXBZ6E.getConfig)({ datamodel: schemaResult.schemas, ignoreEnvVarErrors });
486
+ const primaryDatasource = configFromPsl.datasources.at(0);
487
+ const schemaRootDir = schemaResult.schemaRootDir || cwd;
488
+ return {
489
+ schemaFiles: schemaResult.schemas,
490
+ schemaPath: schemaResult.schemaPath,
491
+ schemaRootDir,
492
+ datasources: configFromPsl.datasources,
493
+ generators: configFromPsl.generators,
494
+ primaryDatasource,
495
+ primaryDatasourceDirectory: primaryDatasourceDirectory(primaryDatasource) || schemaRootDir,
496
+ warnings: configFromPsl.warnings,
497
+ loadedFromPathForLogMessages
498
+ };
499
+ }
500
+ function primaryDatasourceDirectory(primaryDatasource) {
501
+ const datasourcePath = primaryDatasource?.sourceFilePath;
502
+ if (datasourcePath) {
503
+ return import_path2.default.dirname(datasourcePath);
504
+ }
505
+ return null;
506
+ }
507
+ var import_p_map = (0, import_chunk_4VNS5WPM.__toESM)((0, import_chunk_K5W6WZ6E.require_p_map)());
508
+ var debug3 = (0, import_debug5.default)("prisma:generator");
509
+ async function checkTypeScriptVersion() {
510
+ const minVersion = "4.1.0";
511
+ try {
512
+ const typescriptPath = await (0, import_chunk_VVPSLVOR.resolvePkg)("typescript", {
513
+ basedir: process.cwd()
514
+ });
515
+ debug3("typescriptPath", typescriptPath);
516
+ const typescriptPkg = typescriptPath && import_path5.default.join(typescriptPath, "package.json");
517
+ if (typescriptPkg && import_fs3.default.existsSync(typescriptPkg)) {
518
+ const pjson = (0, import_chunk_4VNS5WPM.__require)(typescriptPkg);
519
+ const currentVersion = pjson.version;
520
+ if ((0, import_chunk_EUTJYQDW.semverLt)(currentVersion, minVersion)) {
521
+ import_chunk_ZJWZK45Z.logger_exports.warn(
522
+ `Prisma detected that your ${(0, import_chunk_PG5FDKSF.bold)(
523
+ "TypeScript"
524
+ )} version ${currentVersion} is outdated. If you want to use Prisma Client with TypeScript please update it to version ${(0, import_chunk_PG5FDKSF.bold)(
525
+ minVersion
526
+ )} or ${(0, import_chunk_PG5FDKSF.bold)("newer")}. ${(0, import_chunk_PG5FDKSF.dim)(`TypeScript found in: ${(0, import_chunk_PG5FDKSF.bold)(typescriptPath)}`)}`
527
+ );
528
+ }
529
+ }
530
+ } catch (e) {
531
+ }
532
+ }
533
+ var debug4 = (0, import_debug4.default)("prisma:generator");
534
+ async function prismaClientResolver(baseDir, version3) {
535
+ let prismaClientDir = await (0, import_chunk_EWWOTVR3.findPrismaClientDir)(baseDir);
536
+ debug4("baseDir", baseDir);
537
+ await checkTypeScriptVersion();
538
+ if (!prismaClientDir && !process.env.PRISMA_GENERATE_SKIP_AUTOINSTALL) {
539
+ let projectRoot = (0, import_chunk_J77ZIDXB.longestCommonPathPrefix)(baseDir, process.cwd());
540
+ debug4("projectRoot", projectRoot);
541
+ const warningTag = `${(0, import_chunk_PG5FDKSF.bold)("Warning:")} ${(0, import_chunk_PG5FDKSF.dim)("[Prisma auto-install on generate]")}`;
542
+ if (projectRoot === void 0) {
543
+ console.warn(
544
+ (0, import_chunk_PG5FDKSF.yellow)(
545
+ `${warningTag} The Prisma schema directory ${(0, import_chunk_PG5FDKSF.bold)(baseDir)} and the current working directory ${(0, import_chunk_PG5FDKSF.bold)(
546
+ process.cwd()
547
+ )} have no common ancestor. The Prisma schema directory will be used as the project root.`
548
+ )
549
+ );
550
+ projectRoot = baseDir;
551
+ }
552
+ if (!import_fs2.default.existsSync(import_path4.default.join(projectRoot, "package.json"))) {
553
+ console.warn(
554
+ (0, import_chunk_PG5FDKSF.yellow)(
555
+ `${warningTag} Prisma could not find a ${(0, import_chunk_PG5FDKSF.bold)("package.json")} file in the inferred project root ${(0, import_chunk_PG5FDKSF.bold)(
556
+ projectRoot
557
+ )}. During the next step, when an auto-install of Prisma package(s) will be attempted, it will then be created by your package manager on the appropriate level if necessary.`
558
+ )
559
+ );
560
+ }
561
+ const prismaCliDir = await (0, import_chunk_VVPSLVOR.resolvePkg)("prisma", { basedir: baseDir });
562
+ if (process.platform === "win32" && await (0, import_chunk_GHHABGYW.isYarnUsed)(baseDir)) {
563
+ const hasCli = (s) => prismaCliDir !== void 0 ? s : "";
564
+ const missingCli = (s) => prismaCliDir === void 0 ? s : "";
565
+ throw new Error(
566
+ `Could not resolve ${missingCli(`${(0, import_chunk_PG5FDKSF.bold)("prisma")} and `)}${(0, import_chunk_PG5FDKSF.bold)(
567
+ "@prisma/client"
568
+ )} in the current project. Please install ${hasCli("it")}${missingCli("them")} with ${missingCli(
569
+ `${(0, import_chunk_PG5FDKSF.bold)((0, import_chunk_PG5FDKSF.green)(`${await (0, import_chunk_72UZXEBG.getPackageCmd)(baseDir, "add", "prisma", "-D")}`))} and `
570
+ )}${(0, import_chunk_PG5FDKSF.bold)((0, import_chunk_PG5FDKSF.green)(`${await (0, import_chunk_72UZXEBG.getPackageCmd)(baseDir, "add", "@prisma/client")}`))}, and rerun ${(0, import_chunk_PG5FDKSF.bold)(
571
+ await (0, import_chunk_72UZXEBG.getPackageCmd)(baseDir, "execute", "prisma generate")
572
+ )} \u{1F64F}.`
573
+ );
574
+ }
575
+ if (!prismaCliDir) {
576
+ await (0, import_chunk_QGJH4P4N.runPackageCmd)(projectRoot, "add", `prisma@${version3 ?? "latest"}`, "-D", "--silent");
577
+ }
578
+ await (0, import_chunk_QGJH4P4N.runPackageCmd)(projectRoot, "add", `@prisma/client@${version3 ?? "latest"}`, "--silent");
579
+ prismaClientDir = await (0, import_chunk_EWWOTVR3.findPrismaClientDir)(import_path4.default.join(".", baseDir));
580
+ if (!prismaClientDir) {
581
+ throw new Error(
582
+ `Could not resolve @prisma/client despite the installation that we just tried.
583
+ Please try to install it by hand with ${(0, import_chunk_PG5FDKSF.bold)(
584
+ (0, import_chunk_PG5FDKSF.green)(`${await (0, import_chunk_72UZXEBG.getPackageCmd)(baseDir, "add", "@prisma/client")}`)
585
+ )} and rerun ${(0, import_chunk_PG5FDKSF.bold)(await (0, import_chunk_72UZXEBG.getPackageCmd)(baseDir, "execute", "prisma generate"))} \u{1F64F}.`
586
+ );
587
+ }
588
+ console.info(
589
+ `
590
+ \u2714 Installed the ${(0, import_chunk_PG5FDKSF.bold)((0, import_chunk_PG5FDKSF.green)("@prisma/client"))} and ${(0, import_chunk_PG5FDKSF.bold)((0, import_chunk_PG5FDKSF.green)("prisma"))} packages in your project`
591
+ );
592
+ }
593
+ if (!prismaClientDir) {
594
+ throw new Error(
595
+ `Could not resolve @prisma/client.
596
+ Please try to install it with ${(0, import_chunk_PG5FDKSF.bold)((0, import_chunk_PG5FDKSF.green)("npm install @prisma/client"))} and rerun ${(0, import_chunk_PG5FDKSF.bold)(
597
+ await (0, import_chunk_72UZXEBG.getPackageCmd)(baseDir, "execute", "prisma generate")
598
+ )} \u{1F64F}.`
599
+ );
600
+ }
601
+ return {
602
+ outputPath: prismaClientDir,
603
+ generatorPath: import_path4.default.resolve(prismaClientDir, "generator-build/index.js"),
604
+ isNode: true
605
+ };
606
+ }
607
+ var generatorResolvers = {
608
+ "prisma-client-js": prismaClientResolver
609
+ };
610
+ var debug5 = (0, import_debug3.default)("prisma:getGenerators");
611
+ async function getGenerators(options) {
612
+ const {
613
+ schemaPath,
614
+ providerAliases: aliases,
615
+ // do you get the pun?
616
+ version,
617
+ cliVersion,
618
+ printDownloadProgress,
619
+ overrideGenerators,
620
+ skipDownload,
621
+ binaryPathsOverride,
622
+ generatorNames = [],
623
+ postinstall,
624
+ noEngine,
625
+ allowNoModels,
626
+ typedSql
627
+ } = options;
628
+ const schemaContext = !options.schemaContext && schemaPath ? await loadSchemaContext({ schemaPathFromArg: schemaPath, ignoreEnvVarErrors: true }) : options.schemaContext;
629
+ if (!schemaContext) {
630
+ throw new Error(`no schema provided for getGenerators`);
631
+ }
632
+ const binaryTarget = await (0, import_get_platform.getBinaryTargetForCurrentPlatform)();
633
+ const queryEngineBinaryType = (0, import_engines.getCliQueryEngineBinaryType)();
634
+ const queryEngineType = (0, import_chunk_RS2R7COT.binaryTypeToEngineType)(queryEngineBinaryType);
635
+ if (version && !binaryPathsOverride?.[queryEngineType]) {
636
+ const potentialPath = eval(`require('path').join(__dirname, '..')`);
637
+ if (!potentialPath.match(import_chunk_M3GBKLGE.vercelPkgPathRegex)) {
638
+ const downloadParams = {
639
+ binaries: {
640
+ [queryEngineBinaryType]: potentialPath
641
+ },
642
+ binaryTargets: [binaryTarget],
643
+ showProgress: false,
644
+ version,
645
+ skipDownload
646
+ };
647
+ await (0, import_fetch_engine.download)(downloadParams);
648
+ }
649
+ }
650
+ if (!schemaContext.primaryDatasource) {
651
+ throw new Error(import_chunk_AZV6HVKA.missingDatasource);
652
+ }
653
+ (0, import_chunk_5FJ3MENK.printConfigWarnings)(schemaContext.warnings);
654
+ const previewFeatures = (0, import_chunk_CRVLHWC5.extractPreviewFeatures)(schemaContext.generators);
655
+ const dmmf = await (0, import_chunk_Q6FDURCA.getDMMF)({
656
+ datamodel: schemaContext.schemaFiles,
657
+ previewFeatures
658
+ });
659
+ if (dmmf.datamodel.models.length === 0 && !allowNoModels) {
660
+ if (schemaContext.primaryDatasource.provider === "mongodb") {
661
+ throw new Error(import_chunk_XLTQGAI2.missingModelMessageMongoDB);
662
+ }
663
+ throw new Error(import_chunk_XLTQGAI2.missingModelMessage);
664
+ }
665
+ const generatorConfigs = filterGenerators(overrideGenerators || schemaContext.generators, generatorNames);
666
+ await validateGenerators(generatorConfigs);
667
+ const runningGenerators = [];
668
+ try {
669
+ const generators = await (0, import_p_map.default)(
670
+ generatorConfigs,
671
+ async (generator, index) => {
672
+ let generatorPath = (0, import_chunk_IOIAK7V7.parseEnvValue)(generator.provider);
673
+ let paths;
674
+ const baseDir = import_path3.default.dirname(generator.sourceFilePath ?? schemaContext.schemaRootDir);
675
+ const providerValue = (0, import_chunk_IOIAK7V7.parseEnvValue)(generator.provider);
676
+ if (aliases && aliases[providerValue]) {
677
+ generatorPath = aliases[providerValue].generatorPath;
678
+ paths = aliases[providerValue];
679
+ } else if (generatorResolvers[providerValue]) {
680
+ paths = await generatorResolvers[providerValue](baseDir, cliVersion);
681
+ generatorPath = paths.generatorPath;
682
+ }
683
+ const generatorInstance = new import_chunk_DYVL6P7F.Generator(generatorPath, generator, paths?.isNode);
684
+ await generatorInstance.init();
685
+ if (generator.output) {
686
+ generator.output = {
687
+ value: import_path3.default.resolve(baseDir, (0, import_chunk_IOIAK7V7.parseEnvValue)(generator.output)),
688
+ fromEnvVar: null
689
+ };
690
+ generator.isCustomOutput = true;
691
+ } else if (paths) {
692
+ generator.output = {
693
+ value: paths.outputPath,
694
+ fromEnvVar: null
695
+ };
696
+ } else {
697
+ if (!generatorInstance.manifest || !generatorInstance.manifest.defaultOutput) {
698
+ throw new Error(
699
+ `Can't resolve output dir for generator ${(0, import_chunk_PG5FDKSF.bold)(generator.name)} with provider ${(0, import_chunk_PG5FDKSF.bold)(
700
+ generator.provider.value
701
+ )}.
702
+ The generator needs to either define the \`defaultOutput\` path in the manifest or you need to define \`output\` in the datamodel.prisma file.`
703
+ );
704
+ }
705
+ generator.output = {
706
+ value: await (0, import_chunk_2B26F5N3.resolveOutput)({
707
+ defaultOutput: generatorInstance.manifest.defaultOutput,
708
+ baseDir
709
+ }),
710
+ fromEnvVar: null
711
+ };
712
+ }
713
+ const datamodel = (0, import_chunk_Q7XOR5W5.mergeSchemas)({ schemas: schemaContext.schemaFiles });
714
+ const envPaths = await getEnvPaths(schemaContext.schemaPath, { cwd: generator.output.value });
715
+ const options2 = {
716
+ datamodel,
717
+ datasources: schemaContext.datasources,
718
+ generator,
719
+ dmmf,
720
+ otherGenerators: skipIndex(generatorConfigs, index),
721
+ schemaPath: schemaContext.schemaPath,
722
+ // TODO:(schemaPath) can we get rid of schema path passing here?
723
+ version: version || import_engines.enginesVersion,
724
+ // this version makes no sense anymore and should be ignored
725
+ postinstall,
726
+ noEngine,
727
+ allowNoModels,
728
+ envPaths,
729
+ typedSql
730
+ };
731
+ generatorInstance.setOptions(options2);
732
+ runningGenerators.push(generatorInstance);
733
+ return generatorInstance;
734
+ },
735
+ {
736
+ stopOnError: false
737
+ // needed so we can first make sure all generators are created properly, then cleaned up properly
738
+ }
739
+ );
740
+ const generatorProviders = generatorConfigs.map((g) => (0, import_chunk_IOIAK7V7.parseEnvValue)(g.provider));
741
+ for (const g of generators) {
742
+ if (g.manifest && g.manifest.requiresGenerators && g.manifest.requiresGenerators.length > 0) {
743
+ for (const neededGenerator of g.manifest.requiresGenerators) {
744
+ if (!generatorProviders.includes(neededGenerator)) {
745
+ throw new Error(
746
+ `Generator "${g.manifest.prettyName}" requires generator "${neededGenerator}", but it is missing in your schema.prisma.
747
+ Please add it to your schema.prisma:
748
+
749
+ generator gen {
750
+ provider = "${neededGenerator}"
751
+ }
752
+ `
753
+ );
754
+ }
755
+ }
756
+ }
757
+ }
758
+ const neededVersions = /* @__PURE__ */ Object.create(null);
759
+ for (const g of generators) {
760
+ if (g.manifest && g.manifest.requiresEngines && Array.isArray(g.manifest.requiresEngines) && g.manifest.requiresEngines.length > 0) {
761
+ const neededVersion = (0, import_chunk_X3P4J7WW.getEngineVersionForGenerator)(g.manifest, version);
762
+ if (!neededVersions[neededVersion]) {
763
+ neededVersions[neededVersion] = { engines: [], binaryTargets: [] };
764
+ }
765
+ for (const engine of g.manifest.requiresEngines) {
766
+ if (!neededVersions[neededVersion].engines.includes(engine)) {
767
+ neededVersions[neededVersion].engines.push(engine);
768
+ }
769
+ }
770
+ const generatorBinaryTargets = g.options?.generator?.binaryTargets;
771
+ if (generatorBinaryTargets && generatorBinaryTargets.length > 0) {
772
+ for (const binaryTarget2 of generatorBinaryTargets) {
773
+ if (!neededVersions[neededVersion].binaryTargets.find((object) => object.value === binaryTarget2.value)) {
774
+ neededVersions[neededVersion].binaryTargets.push(binaryTarget2);
775
+ }
776
+ }
777
+ }
778
+ }
779
+ }
780
+ debug5("neededVersions", JSON.stringify(neededVersions, null, 2));
781
+ const binaryPathsByVersion = await (0, import_chunk_EPXBOIA5.getBinaryPathsByVersion)({
782
+ neededVersions,
783
+ binaryTarget,
784
+ version,
785
+ printDownloadProgress,
786
+ skipDownload,
787
+ binaryPathsOverride
788
+ });
789
+ for (const generator of generators) {
790
+ if (generator.manifest && generator.manifest.requiresEngines) {
791
+ const engineVersion = (0, import_chunk_X3P4J7WW.getEngineVersionForGenerator)(generator.manifest, version);
792
+ const binaryPaths = binaryPathsByVersion[engineVersion];
793
+ const generatorBinaryPaths = (0, import_chunk_5V36RLCO.pick)(binaryPaths, generator.manifest.requiresEngines);
794
+ debug5({ generatorBinaryPaths });
795
+ generator.setBinaryPaths(generatorBinaryPaths);
796
+ if (engineVersion !== version && generator.options && generator.manifest.requiresEngines.includes(queryEngineType) && generatorBinaryPaths[queryEngineType] && generatorBinaryPaths[queryEngineType]?.[binaryTarget]) {
797
+ const customDmmf = await (0, import_chunk_Q6FDURCA.getDMMF)({
798
+ datamodel: schemaContext.schemaFiles,
799
+ previewFeatures
800
+ });
801
+ const options2 = { ...generator.options, dmmf: customDmmf };
802
+ debug5("generator.manifest.prettyName", generator.manifest.prettyName);
803
+ debug5("options", options2);
804
+ debug5("options.generator.binaryTargets", options2.generator.binaryTargets);
805
+ generator.setOptions(options2);
806
+ }
807
+ }
808
+ }
809
+ return generators;
810
+ } catch (e) {
811
+ runningGenerators.forEach((g) => g.stop());
812
+ throw e;
813
+ }
814
+ }
815
+ async function getGenerator(options2) {
816
+ const generators = await getGenerators(options2);
817
+ return generators[0];
818
+ }
819
+ function skipIndex(arr, index) {
820
+ return [...arr.slice(0, index), ...arr.slice(index + 1)];
821
+ }
822
+ var knownBinaryTargets = [...import_get_platform.binaryTargets, "native"];
823
+ var oldToNewBinaryTargetsMapping = {
824
+ "linux-glibc-libssl1.0.1": "debian-openssl-1.0.x",
825
+ "linux-glibc-libssl1.0.2": "debian-openssl-1.0.x",
826
+ "linux-glibc-libssl1.1.0": "debian-openssl1.1.x"
827
+ };
828
+ async function validateGenerators(generators) {
829
+ const binaryTarget2 = await (0, import_get_platform.getBinaryTargetForCurrentPlatform)();
830
+ for (const generator of generators) {
831
+ if (generator.config.platforms) {
832
+ throw new Error(
833
+ `The \`platforms\` field on the generator definition is deprecated. Please rename it to \`binaryTargets\`.`
834
+ );
835
+ }
836
+ if (generator.config.pinnedBinaryTargets) {
837
+ throw new Error(
838
+ `The \`pinnedBinaryTargets\` field on the generator definition is deprecated.
839
+ Please use the PRISMA_QUERY_ENGINE_BINARY env var instead to pin the binary target.`
840
+ );
841
+ }
842
+ if (generator.binaryTargets) {
843
+ const binaryTargets2 = generator.binaryTargets && generator.binaryTargets.length > 0 ? generator.binaryTargets : [{ fromEnvVar: null, value: "native" }];
844
+ const resolvedBinaryTargets = binaryTargets2.flatMap((object) => (0, import_chunk_IOIAK7V7.parseBinaryTargetsEnvValue)(object)).map((p) => p === "native" ? binaryTarget2 : p);
845
+ for (const resolvedBinaryTarget of resolvedBinaryTargets) {
846
+ if (oldToNewBinaryTargetsMapping[resolvedBinaryTarget]) {
847
+ throw new Error(
848
+ `Binary target ${(0, import_chunk_PG5FDKSF.red)((0, import_chunk_PG5FDKSF.bold)(resolvedBinaryTarget))} is deprecated. Please use ${(0, import_chunk_PG5FDKSF.green)(
849
+ (0, import_chunk_PG5FDKSF.bold)(oldToNewBinaryTargetsMapping[resolvedBinaryTarget])
850
+ )} instead.`
851
+ );
852
+ }
853
+ if (!knownBinaryTargets.includes(resolvedBinaryTarget)) {
854
+ throw new Error(
855
+ `Unknown binary target ${(0, import_chunk_PG5FDKSF.red)(resolvedBinaryTarget)} in generator ${(0, import_chunk_PG5FDKSF.bold)(generator.name)}.
856
+ Possible binaryTargets: ${(0, import_chunk_PG5FDKSF.green)(knownBinaryTargets.join(", "))}`
857
+ );
858
+ }
859
+ }
860
+ if (!resolvedBinaryTargets.includes(binaryTarget2)) {
861
+ const originalBinaryTargetsConfig = (0, import_chunk_LRU47BGE.getOriginalBinaryTargetsValue)(generator.binaryTargets);
862
+ console.log(`${(0, import_chunk_PG5FDKSF.yellow)("Warning:")} Your current platform \`${(0, import_chunk_PG5FDKSF.bold)(
863
+ binaryTarget2
864
+ )}\` is not included in your generator's \`binaryTargets\` configuration ${JSON.stringify(
865
+ originalBinaryTargetsConfig
866
+ )}.
867
+ To fix it, use this generator config in your ${(0, import_chunk_PG5FDKSF.bold)("schema.prisma")}:
868
+ ${(0, import_chunk_PG5FDKSF.green)(
869
+ (0, import_chunk_LRU47BGE.printGeneratorConfig)({
870
+ ...generator,
871
+ binaryTargets: (0, import_chunk_X77CS5RK.fixBinaryTargets)(generator.binaryTargets, binaryTarget2)
872
+ })
873
+ )}
874
+ ${(0, import_chunk_PG5FDKSF.gray)(
875
+ `Note, that by providing \`native\`, Prisma Client automatically resolves \`${binaryTarget2}\`.
876
+ Read more about deploying Prisma Client: ${(0, import_chunk_PG5FDKSF.underline)(
877
+ "https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/generators"
878
+ )}`
879
+ )}
880
+ `);
881
+ }
882
+ }
883
+ }
884
+ }
885
+ function filterGenerators(generators, generatorNames2) {
886
+ if (generatorNames2.length < 1) {
887
+ return generators;
888
+ }
889
+ const filtered = generators.filter((generator) => generatorNames2.includes(generator.name));
890
+ if (filtered.length !== generatorNames2.length) {
891
+ const missings = generatorNames2.filter((name) => filtered.find((generator) => generator.name === name) == null);
892
+ const isSingular = missings.length <= 1;
893
+ throw new Error(
894
+ `The ${isSingular ? "generator" : "generators"} ${(0, import_chunk_PG5FDKSF.bold)(missings.join(", "))} specified via ${(0, import_chunk_PG5FDKSF.bold)(
895
+ "--generator"
896
+ )} ${isSingular ? "does" : "do"} not exist in your Prisma schema`
897
+ );
898
+ }
899
+ return filtered;
900
+ }
901
+ var typeMappings = {
902
+ directory: "isDirectory",
903
+ file: "isFile"
904
+ };
905
+ function checkType(type) {
906
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
907
+ return;
908
+ }
909
+ throw new Error(`Invalid type specified: ${type}`);
910
+ }
911
+ var matchType = (type, stat2) => stat2[typeMappings[type]]();
912
+ var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
913
+ function locatePathSync(paths, {
914
+ cwd = import_node_process.default.cwd(),
915
+ type = "file",
916
+ allowSymlinks = true
917
+ } = {}) {
918
+ checkType(type);
919
+ cwd = toPath2(cwd);
920
+ const statFunction = allowSymlinks ? import_node_fs.default.statSync : import_node_fs.default.lstatSync;
921
+ for (const path_ of paths) {
922
+ try {
923
+ const stat2 = statFunction(import_node_path2.default.resolve(cwd, path_), {
924
+ throwIfNoEntry: false
925
+ });
926
+ if (!stat2) {
927
+ continue;
928
+ }
929
+ if (matchType(type, stat2)) {
930
+ return path_;
931
+ }
932
+ } catch {
933
+ }
934
+ }
935
+ }
936
+ function pathExistsSync(path9) {
937
+ try {
938
+ import_node_fs2.default.accessSync(path9);
939
+ return true;
940
+ } catch {
941
+ return false;
942
+ }
943
+ }
944
+ var findUpStop = Symbol("findUpStop");
945
+ function findUpMultipleSync(name, options2 = {}) {
946
+ let directory = import_node_path.default.resolve((0, import_chunk_K5W6WZ6E.toPath)(options2.cwd) ?? "");
947
+ const { root } = import_node_path.default.parse(directory);
948
+ const stopAt = import_node_path.default.resolve(directory, (0, import_chunk_K5W6WZ6E.toPath)(options2.stopAt) ?? root);
949
+ const limit = options2.limit ?? Number.POSITIVE_INFINITY;
950
+ const paths = [name].flat();
951
+ const runMatcher = (locateOptions) => {
952
+ if (typeof name !== "function") {
953
+ return locatePathSync(paths, locateOptions);
954
+ }
955
+ const foundPath = name(locateOptions.cwd);
956
+ if (typeof foundPath === "string") {
957
+ return locatePathSync([foundPath], locateOptions);
958
+ }
959
+ return foundPath;
960
+ };
961
+ const matches = [];
962
+ while (true) {
963
+ const foundPath = runMatcher({ ...options2, cwd: directory });
964
+ if (foundPath === findUpStop) {
965
+ break;
966
+ }
967
+ if (foundPath) {
968
+ matches.push(import_node_path.default.resolve(directory, foundPath));
969
+ }
970
+ if (directory === stopAt || matches.length >= limit) {
971
+ break;
972
+ }
973
+ directory = import_node_path.default.dirname(directory);
974
+ }
975
+ return matches;
976
+ }
977
+ function findUpSync(name, options2 = {}) {
978
+ const matches = findUpMultipleSync(name, { ...options2, limit: 1 });
979
+ return matches[0];
980
+ }
981
+ var debug6 = (0, import_debug6.default)("prisma:loadEnv");
982
+ async function getEnvPaths(schemaPath2, opts = { cwd: process.cwd() }) {
983
+ const rootEnvPath = getProjectRootEnvPath({ cwd: opts.cwd }) ?? null;
984
+ const schemaEnvPathFromArgs = schemaPathToEnvPath(schemaPath2);
985
+ const schemaEnvPathFromPkgJson = schemaPathToEnvPath(await readSchemaPathFromPkgJson());
986
+ const schemaEnvPaths = [
987
+ schemaEnvPathFromArgs,
988
+ // 1 - Check --schema directory for .env
989
+ schemaEnvPathFromPkgJson,
990
+ // 2 - Check package.json schema directory for .env
991
+ "./prisma/.env",
992
+ // 3 - Check ./prisma directory for .env
993
+ "./.env"
994
+ // 4 - Check cwd for .env
995
+ ];
996
+ const schemaEnvPath = schemaEnvPaths.find(import_chunk_UTJGRVMG.exists);
997
+ return { rootEnvPath, schemaEnvPath };
998
+ }
999
+ async function readSchemaPathFromPkgJson() {
1000
+ try {
1001
+ const pkgJsonSchema = await getSchemaFromPackageJson(process.cwd());
1002
+ if (pkgJsonSchema.ok) {
1003
+ pkgJsonSchema.schema.schemaPath;
1004
+ }
1005
+ return null;
1006
+ } catch {
1007
+ return null;
1008
+ }
1009
+ }
1010
+ function getProjectRootEnvPath(opts) {
1011
+ const pkgJsonPath = findUpSync((dir) => {
1012
+ const pkgPath = import_path6.default.join(dir, "package.json");
1013
+ if (pathExistsSync(pkgPath)) {
1014
+ try {
1015
+ const pkg = JSON.parse(import_fs4.default.readFileSync(pkgPath, "utf8"));
1016
+ if (pkg["name"] !== ".prisma/client") {
1017
+ debug6(`project root found at ${pkgPath}`);
1018
+ return pkgPath;
1019
+ }
1020
+ } catch (e) {
1021
+ debug6(`skipping package.json at ${pkgPath}`);
1022
+ }
1023
+ }
1024
+ return void 0;
1025
+ }, opts);
1026
+ if (!pkgJsonPath) {
1027
+ return null;
1028
+ }
1029
+ const candidate = import_path6.default.join(import_path6.default.dirname(pkgJsonPath), ".env");
1030
+ if (!import_fs4.default.existsSync(candidate)) {
1031
+ return null;
1032
+ }
1033
+ return candidate;
1034
+ }
1035
+ function schemaPathToEnvPath(schemaPath2) {
1036
+ if (!schemaPath2) return null;
1037
+ return import_path6.default.join(import_path6.default.dirname(schemaPath2), ".env");
1038
+ }
1039
+ async function loadEnvFile({
1040
+ schemaPath: schemaPath2,
1041
+ config,
1042
+ printMessage = false
1043
+ }) {
1044
+ if (config.loadedFromFile) {
1045
+ process.stdout.write(`Prisma config detected, skipping environment variable loading.
1046
+ `);
1047
+ return;
1048
+ }
1049
+ const envPaths = await getEnvPaths(schemaPath2);
1050
+ const envData = (0, import_chunk_UTJGRVMG.tryLoadEnvs)(envPaths, { conflictCheck: "error" });
1051
+ if (printMessage && envData && envData.message) {
1052
+ process.stdout.write(envData.message + "\n");
1053
+ }
1054
+ }
1055
+ var forbiddenCmdWithDataProxyFlagMessage = (command) => `
1056
+ Using an Accelerate URL is not supported for this CLI command ${(0, import_chunk_PG5FDKSF.green)(`prisma ${command}`)} yet.
1057
+ Please use a direct connection to your database via the datasource \`directUrl\` setting.
1058
+
1059
+ More information about this limitation: ${(0, import_chunk_HAGJ64PM.link)("https://pris.ly/d/accelerate-limitations")}
1060
+ `;
1061
+ function checkUnsupportedDataProxy({
1062
+ cmd,
1063
+ schemaContext: schemaContext2 = void 0,
1064
+ urls = []
1065
+ }) {
1066
+ for (const url2 of urls) {
1067
+ if (url2 && url2.includes("prisma://")) {
1068
+ throw new Error(forbiddenCmdWithDataProxyFlagMessage(cmd));
1069
+ }
1070
+ }
1071
+ if (!schemaContext2?.primaryDatasource) return;
1072
+ const url = (0, import_chunk_RAEXBZ6E.resolveUrl)((0, import_chunk_RAEXBZ6E.getEffectiveUrl)(schemaContext2.primaryDatasource));
1073
+ if (url?.startsWith("prisma://")) {
1074
+ throw new Error(forbiddenCmdWithDataProxyFlagMessage(cmd));
1075
+ }
1076
+ }