@prisma/internals 6.6.0-dev.6 → 6.6.0-dev.60

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 (240) hide show
  1. package/dist/Generator.d.ts +23 -5
  2. package/dist/Generator.js +5 -3
  3. package/dist/WasmPanicRegistry.js +3 -3
  4. package/dist/{chunk-PIPE5DSU.js → chunk-2H6XXXKO.js} +18 -21
  5. package/dist/chunk-2QTAK7KO.js +101 -0
  6. package/dist/{chunk-EXVN2NDU.js → chunk-2T7STDS2.js} +5 -5
  7. package/dist/{chunk-XLGODPZH.js → chunk-3DQANJMY.js} +12 -12
  8. package/dist/{chunk-WWAWV7DQ.js → chunk-4VNS5WPM.js} +3 -33
  9. package/dist/{chunk-KQOJB3ZW.js → chunk-5AI4FIZ3.js} +10 -10
  10. package/dist/{chunk-7MD6344A.js → chunk-5DBOS77Y.js} +3 -5
  11. package/dist/{chunk-TZCE3PWZ.js → chunk-5VQNKCKW.js} +7 -7
  12. package/dist/{chunk-DQS4NTNF.js → chunk-65V2QRRG.js} +46 -79
  13. package/dist/{chunk-YXD4CJDK.js → chunk-67I7CEQJ.js} +30 -31
  14. package/dist/{chunk-I7IEEULS.js → chunk-6TTRTZXU.js} +5 -5
  15. package/dist/{chunk-ESBSOM7H.js → chunk-6WQVUWQM.js} +5 -5
  16. package/dist/{chunk-5RV3EMX6.js → chunk-75BIJ5PX.js} +57 -57
  17. package/dist/{chunk-GRHK5FCK.js → chunk-7NOJLPRW.js} +5 -5
  18. package/dist/{chunk-C4KFH4DG.js → chunk-A6IRWWSZ.js} +10 -9
  19. package/dist/{chunk-BGFWFIPR.js → chunk-AZV6HVKA.js} +5 -5
  20. package/dist/{chunk-ZYW3HGSH.js → chunk-BPDMLM32.js} +49 -17
  21. package/dist/{chunk-5MCWLJSR.js → chunk-CR3XKUEA.js} +10 -10
  22. package/dist/{chunk-TSJICM5S.js → chunk-CRVLHWC5.js} +5 -5
  23. package/dist/{chunk-NON34H7K.js → chunk-CW6KQ3VH.js} +30 -34
  24. package/dist/{chunk-SHJNE6T7.js → chunk-D4VDA2TZ.js} +7 -7
  25. package/dist/{chunk-Q22BLLK3.js → chunk-D4VZUY3O.js} +6 -6
  26. package/dist/{chunk-KTBNIQ7N.js → chunk-DKSUHQGA.js} +8 -8
  27. package/dist/{chunk-EUTJYQDW.js → chunk-DODIJPCS.js} +13 -25
  28. package/dist/{chunk-UNUCCAXA.js → chunk-DTPFRZWV.js} +5 -5
  29. package/dist/{chunk-NJQWZ447.js → chunk-EPXBOIA5.js} +6 -6
  30. package/dist/{chunk-7XNZDY2V.js → chunk-ETYWYJBX.js} +60 -60
  31. package/dist/chunk-FQ6KDS3H.js +900 -0
  32. package/dist/{chunk-5SN5JBT2.js → chunk-FXMGS3L5.js} +21 -40
  33. package/dist/{chunk-B3FIG77N.js → chunk-GDQW4HII.js} +23 -27
  34. package/dist/{chunk-I7L2MZHS.js → chunk-GNKWZC7O.js} +11 -15
  35. package/dist/{chunk-L6GBFCXG.js → chunk-HAGJ64PM.js} +142 -155
  36. package/dist/{chunk-3ERIN7PH.js → chunk-HG3YOAAE.js} +10 -10
  37. package/dist/{chunk-GXDYIY4M.js → chunk-IDINCQMN.js} +56 -57
  38. package/dist/{chunk-VNUGIB23.js → chunk-JETLVL4E.js} +5 -5
  39. package/dist/{chunk-53LS3WUO.js → chunk-JOIIWB3U.js} +116 -116
  40. package/dist/{chunk-CZL7DCL2.js → chunk-JYMY3OAI.js} +6 -6
  41. package/dist/{chunk-TATYN3T2.js → chunk-KB5DKCI4.js} +29 -29
  42. package/dist/{chunk-LKTTJWFT.js → chunk-KDP6C3CB.js} +5 -5
  43. package/dist/{chunk-ATFQZVBS.js → chunk-LMVSIVKQ.js} +9 -14
  44. package/dist/{chunk-HNUYQRMW.js → chunk-LOQLID3N.js} +23 -27
  45. package/dist/{chunk-OE6YQBXZ.js → chunk-LP3KMVJQ.js} +11 -10
  46. package/dist/{chunk-ZKAW5JSN.js → chunk-LRJ4X43J.js} +5 -5
  47. package/dist/{chunk-ONHKZPSV.js → chunk-LRU47BGE.js} +6 -6
  48. package/dist/{chunk-C2WD2XUT.js → chunk-MJIP3FY5.js} +968 -1220
  49. package/dist/{chunk-4E7A3GDU.js → chunk-MM4ARWWY.js} +5 -5
  50. package/dist/{chunk-V2ZF7ETH.js → chunk-NVNI2SRU.js} +66 -68
  51. package/dist/{chunk-JHQHVXIR.js → chunk-OSHZ4P3G.js} +6 -7
  52. package/dist/{chunk-IPKE37QC.js → chunk-PFYALFCY.js} +6 -5
  53. package/dist/{chunk-ZRU4X7P5.js → chunk-PMQCRDR2.js} +11 -15
  54. package/dist/{chunk-7RSJWEVV.js → chunk-QJ72IP2K.js} +46 -79
  55. package/dist/chunk-QXNNDOVP.js +900 -0
  56. package/dist/{chunk-FCYHZHVW.js → chunk-R3J2O23S.js} +4 -4
  57. package/dist/{chunk-PFLLVWZX.js → chunk-R6QH57HZ.js} +5 -5
  58. package/dist/{chunk-VXJLHQT3.js → chunk-T5MMBF2S.js} +9 -9
  59. package/dist/{chunk-O342S7ZQ.js → chunk-TN4KCTWC.js} +22 -26
  60. package/dist/{chunk-Y3OWT3K2.js → chunk-TQFONRJP.js} +7 -7
  61. package/dist/{chunk-YHZJOEOE.js → chunk-U62GA743.js} +22 -26
  62. package/dist/{chunk-O3UVWF5W.js → chunk-UEJQWA37.js} +30 -34
  63. package/dist/{chunk-3BND5XB4.js → chunk-UTJGRVMG.js} +11 -11
  64. package/dist/{chunk-CHMJ5V7I.js → chunk-UZTXEBTM.js} +7 -7
  65. package/dist/{chunk-PB6AJZNB.js → chunk-W3X73CAW.js} +9 -9
  66. package/dist/{chunk-6TXVGFQA.js → chunk-WSZXPLJQ.js} +11 -11
  67. package/dist/{chunk-BPZFDGKN.js → chunk-WXRVYSYN.js} +4 -7
  68. package/dist/{chunk-2MWIMEFK.js → chunk-XLTQGAI2.js} +6 -6
  69. package/dist/chunk-YR5KNFKN.js +1834 -0
  70. package/dist/{chunk-AZNLB67U.js → chunk-ZJWZK45Z.js} +5 -5
  71. package/dist/chunk-ZSINRHD4.js +43 -0
  72. package/dist/cli/Help.js +1 -1
  73. package/dist/cli/checkUnsupportedDataProxy.d.ts +12 -17
  74. package/dist/cli/checkUnsupportedDataProxy.js +75 -78
  75. package/dist/cli/directoryConfig.d.ts +7 -0
  76. package/dist/cli/directoryConfig.js +25 -0
  77. package/dist/cli/getGeneratorSuccessMessage.js +1 -1
  78. package/dist/cli/getSchema.d.ts +3 -28
  79. package/dist/cli/getSchema.js +78 -82
  80. package/dist/cli/getTypescriptVersion.js +1 -1
  81. package/dist/cli/hashes.d.ts +1 -2
  82. package/dist/cli/hashes.js +75 -78
  83. package/dist/cli/schemaContext.d.ts +59 -0
  84. package/dist/cli/schemaContext.js +133 -0
  85. package/dist/cli/utils.js +5 -5
  86. package/dist/client/getClientEngineType.d.ts +1 -1
  87. package/dist/client/getClientEngineType.js +1 -1
  88. package/dist/convertCredentials.d.ts +1 -1
  89. package/dist/convertCredentials.js +1 -1
  90. package/dist/dotenvExpand.js +1 -1
  91. package/dist/engine-commands/errorHelpers.js +5 -5
  92. package/dist/engine-commands/formatSchema.js +74 -77
  93. package/dist/engine-commands/getConfig.d.ts +1 -5
  94. package/dist/engine-commands/getConfig.js +16 -17
  95. package/dist/engine-commands/getDmmf.d.ts +3 -6
  96. package/dist/engine-commands/getDmmf.js +13 -14
  97. package/dist/engine-commands/getEngineVersion.js +12 -12
  98. package/dist/engine-commands/getEnginesMetaInfo.js +15 -15
  99. package/dist/engine-commands/index.js +85 -88
  100. package/dist/engine-commands/lintSchema.d.ts +1 -1
  101. package/dist/engine-commands/lintSchema.js +11 -12
  102. package/dist/engine-commands/mergeSchemas.js +13 -14
  103. package/dist/engine-commands/queryEngineCommons.js +8 -8
  104. package/dist/engine-commands/relativizePathInPSLError.js +1 -1
  105. package/dist/engine-commands/validate.js +13 -14
  106. package/dist/errorReporting.d.ts +0 -1
  107. package/dist/errorReporting.js +7 -7
  108. package/dist/get-generators/getGenerators.d.ts +22 -9
  109. package/dist/get-generators/getGenerators.js +77 -80
  110. package/dist/get-generators/utils/binaryTypeToEngineType.d.ts +1 -1
  111. package/dist/get-generators/utils/binaryTypeToEngineType.js +1 -1
  112. package/dist/get-generators/utils/engineTypeToBinaryType.d.ts +1 -1
  113. package/dist/get-generators/utils/engineTypeToBinaryType.js +1 -1
  114. package/dist/get-generators/utils/fixBinaryTargets.d.ts +1 -1
  115. package/dist/get-generators/utils/fixBinaryTargets.js +1 -1
  116. package/dist/get-generators/utils/getBinaryPathsByVersion.d.ts +1 -1
  117. package/dist/get-generators/utils/getBinaryPathsByVersion.js +4 -4
  118. package/dist/get-generators/utils/getEngineVersionForGenerator.d.ts +1 -1
  119. package/dist/get-generators/utils/getEngineVersionForGenerator.js +1 -1
  120. package/dist/get-generators/utils/printGeneratorConfig.d.ts +1 -1
  121. package/dist/get-generators/utils/printGeneratorConfig.js +7 -7
  122. package/dist/getPackedPackage.js +9 -9
  123. package/dist/highlight/highlight.js +1 -1
  124. package/dist/highlight/languages/dml.js +1 -1
  125. package/dist/highlight/languages/sql.js +1 -1
  126. package/dist/highlight/prism.js +1 -1
  127. package/dist/highlight/theme.js +1 -1
  128. package/dist/index.d.ts +7 -7
  129. package/dist/index.js +141 -145
  130. package/dist/logger.js +9 -9
  131. package/dist/migrateTypes.d.ts +63 -0
  132. package/dist/{multipart-parser-32AROPTR.js → multipart-parser-3AFJFP6K.js} +7 -7
  133. package/dist/panic.d.ts +1 -4
  134. package/dist/panic.js +7 -7
  135. package/dist/resolveBinary.js +10 -10
  136. package/dist/resolveOutput.js +1 -1
  137. package/dist/resolvePkg.d.ts +7 -0
  138. package/dist/{get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.js → resolvePkg.js} +6 -6
  139. package/dist/schemaEngineCommands.js +13 -13
  140. package/dist/sendPanic.js +7 -111
  141. package/dist/types.d.ts +1 -1
  142. package/dist/utils/__tests__/isCi.test.js +1 -1
  143. package/dist/utils/__tests__/isInteractive.test.js +1 -1
  144. package/dist/utils/__tests__/maskSchema.test.js +1 -1
  145. package/dist/utils/assertAlways.js +1 -1
  146. package/dist/utils/assertNever.js +1 -1
  147. package/dist/utils/binaryTargetRegex.js +3 -3
  148. package/dist/utils/byline.js +1 -1
  149. package/dist/utils/callOnce.js +1 -1
  150. package/dist/utils/callOnce.test.js +1 -1
  151. package/dist/utils/canPrompt.js +4 -4
  152. package/dist/utils/chmodPlusX.js +1 -1
  153. package/dist/utils/cloudflareD1.js +4 -4
  154. package/dist/utils/drawBox.js +1 -1
  155. package/dist/utils/extractPreviewFeatures.d.ts +2 -2
  156. package/dist/utils/extractPreviewFeatures.js +3 -3
  157. package/dist/utils/formatTable.js +1 -1
  158. package/dist/utils/formatms.js +1 -1
  159. package/dist/utils/fs-functional.js +12 -12
  160. package/dist/utils/fs-utils.js +9 -9
  161. package/dist/utils/getCommandWithExecutor.js +4 -4
  162. package/dist/utils/getEnvPaths.d.ts +1 -1
  163. package/dist/utils/getEnvPaths.js +74 -77
  164. package/dist/utils/getGitHubIssueUrl.js +5 -4
  165. package/dist/utils/getMigrateConfigDir.js +1 -1
  166. package/dist/utils/getVersionFromPackageJson.js +4 -4
  167. package/dist/utils/handleEngineLoadingErrors.js +1 -1
  168. package/dist/utils/handlePanic.js +13 -110
  169. package/dist/utils/hasOwnProperty.js +1 -1
  170. package/dist/utils/isCi.js +1 -1
  171. package/dist/utils/isCurrentBinInstalledGlobally.js +3 -3
  172. package/dist/utils/isInContainer.js +1 -1
  173. package/dist/utils/isInNpmLifecycleHook.js +1 -1
  174. package/dist/utils/isInteractive.js +1 -1
  175. package/dist/utils/isPromiseLike.js +1 -1
  176. package/dist/utils/isValidJsIdentifier.js +4 -4
  177. package/dist/utils/keyBy.js +1 -1
  178. package/dist/utils/link.js +3 -3
  179. package/dist/utils/load.js +3 -3
  180. package/dist/utils/loadEnvFile.js +74 -77
  181. package/dist/utils/mapKeys.js +1 -1
  182. package/dist/utils/mapObjectValues.js +1 -1
  183. package/dist/utils/maskSchema.js +1 -1
  184. package/dist/utils/max.js +1 -1
  185. package/dist/utils/max.test.js +1 -1
  186. package/dist/utils/maybeInGitHook.js +1 -1
  187. package/dist/utils/missingDatasource.js +4 -4
  188. package/dist/utils/missingGeneratorMessage.js +6 -6
  189. package/dist/utils/now.js +1 -1
  190. package/dist/utils/omit.js +1 -1
  191. package/dist/utils/parseAWSNodejsRuntimeEnvVarVersion.js +1 -1
  192. package/dist/utils/parseEnvValue.d.ts +1 -1
  193. package/dist/utils/parseEnvValue.js +1 -1
  194. package/dist/utils/path.js +1 -1
  195. package/dist/utils/path.test.js +1 -1
  196. package/dist/utils/pick.js +1 -1
  197. package/dist/utils/printConfigWarnings.js +1 -1
  198. package/dist/utils/prismaPostgres.js +1 -1
  199. package/dist/utils/prismaPostgres.test.js +1 -1
  200. package/dist/utils/schemaFileInput.d.ts +0 -4
  201. package/dist/utils/schemaFileInput.js +3 -7
  202. package/dist/utils/serializeQueryEngineName.js +1 -1
  203. package/dist/utils/setClassName.js +1 -1
  204. package/dist/utils/toSchemasContainer.d.ts +2 -3
  205. package/dist/utils/toSchemasContainer.js +4 -5
  206. package/dist/utils/tryLoadEnvs.js +6 -6
  207. package/dist/utils/unique.js +1 -1
  208. package/dist/utils/vercelPkgPathRegex.js +1 -1
  209. package/dist/warnOnce.js +4 -4
  210. package/dist/wasm.js +6 -6
  211. package/package.json +13 -12
  212. package/dist/chunk-77IC3DNO.js +0 -35
  213. package/dist/chunk-AOQIUJT4.js +0 -41
  214. package/dist/chunk-KQKHO2IC.js +0 -15631
  215. package/dist/chunk-MGZOEY6N.js +0 -28
  216. package/dist/chunk-O2CGGO6D.js +0 -15631
  217. package/dist/chunk-S57RMXZW.js +0 -28
  218. package/dist/chunk-VRT7T6MF.js +0 -4959
  219. package/dist/chunk-YRBRUREX.js +0 -57
  220. package/dist/get-generators/generatorResolvers/generatorResolvers.d.ts +0 -15
  221. package/dist/get-generators/generatorResolvers/generatorResolvers.js +0 -135
  222. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.d.ts +0 -6
  223. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/findPrismaClientDir.js +0 -26
  224. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.d.ts +0 -9
  225. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/getPackageCmd.js +0 -26
  226. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.d.ts +0 -8
  227. package/dist/get-generators/generatorResolvers/prisma-client-js/auto-installation/runPackageCmd.js +0 -29
  228. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.d.ts +0 -6
  229. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.js +0 -135
  230. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.d.ts +0 -1
  231. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/isYarnUsed.js +0 -26
  232. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.d.ts +0 -20
  233. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/resolve.js +0 -26
  234. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.d.ts +0 -7
  235. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.test.d.ts +0 -1
  236. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/semverLt.test.js +0 -17
  237. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.d.ts +0 -20
  238. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.js +0 -136
  239. package/dist/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
  240. package/dist/get-generators/utils/check-feature-flags/checkFeatureFlags.js +0 -25
@@ -0,0 +1,900 @@
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_QXNNDOVP_exports = {};
30
+ __export(chunk_QXNNDOVP_exports, {
31
+ checkUnsupportedDataProxy: () => checkUnsupportedDataProxy,
32
+ forbiddenCmdWithDataProxyFlagMessage: () => forbiddenCmdWithDataProxyFlagMessage,
33
+ formatSchema: () => formatSchema,
34
+ getBinaryTargetForCurrentPlatform: () => import_get_platform2.getBinaryTargetForCurrentPlatform,
35
+ getCLIPathHash: () => getCLIPathHash,
36
+ getEnvPaths: () => getEnvPaths,
37
+ getGenerator: () => getGenerator,
38
+ getGenerators: () => getGenerators,
39
+ getNodeAPIName: () => import_get_platform2.getNodeAPIName,
40
+ getPrismaConfigFromPackageJson: () => getPrismaConfigFromPackageJson,
41
+ getProjectHash: () => getProjectHash,
42
+ getSchemaFromPackageJson: () => getSchemaFromPackageJson,
43
+ getSchemaWithPath: () => getSchemaWithPath,
44
+ getSchemaWithPathOptional: () => getSchemaWithPathOptional,
45
+ knownBinaryTargets: () => knownBinaryTargets,
46
+ loadEnvFile: () => loadEnvFile,
47
+ loadSchemaContext: () => loadSchemaContext,
48
+ printSchemaLoadedMessage: () => printSchemaLoadedMessage,
49
+ processSchemaResult: () => processSchemaResult,
50
+ skipIndex: () => skipIndex
51
+ });
52
+ module.exports = __toCommonJS(chunk_QXNNDOVP_exports);
53
+ var import_chunk_X77CS5RK = require("./chunk-X77CS5RK.js");
54
+ var import_chunk_EPXBOIA5 = require("./chunk-EPXBOIA5.js");
55
+ var import_chunk_RS2R7COT = require("./chunk-RS2R7COT.js");
56
+ var import_chunk_X3P4J7WW = require("./chunk-X3P4J7WW.js");
57
+ var import_chunk_LRU47BGE = require("./chunk-LRU47BGE.js");
58
+ var import_chunk_5FJ3MENK = require("./chunk-5FJ3MENK.js");
59
+ var import_chunk_UTJGRVMG = require("./chunk-UTJGRVMG.js");
60
+ var import_chunk_XLTQGAI2 = require("./chunk-XLTQGAI2.js");
61
+ var import_chunk_5V36RLCO = require("./chunk-5V36RLCO.js");
62
+ var import_chunk_AZV6HVKA = require("./chunk-AZV6HVKA.js");
63
+ var import_chunk_HAGJ64PM = require("./chunk-HAGJ64PM.js");
64
+ var import_chunk_CRVLHWC5 = require("./chunk-CRVLHWC5.js");
65
+ var import_chunk_QJ72IP2K = require("./chunk-QJ72IP2K.js");
66
+ var import_chunk_GNKWZC7O = require("./chunk-GNKWZC7O.js");
67
+ var import_chunk_TN4KCTWC = require("./chunk-TN4KCTWC.js");
68
+ var import_chunk_CW6KQ3VH = require("./chunk-CW6KQ3VH.js");
69
+ var import_chunk_T5MMBF2S = require("./chunk-T5MMBF2S.js");
70
+ var import_chunk_2B26F5N3 = require("./chunk-2B26F5N3.js");
71
+ var import_chunk_M3GBKLGE = require("./chunk-M3GBKLGE.js");
72
+ var import_chunk_XKZ6CBLA = require("./chunk-XKZ6CBLA.js");
73
+ var import_chunk_LMVSIVKQ = require("./chunk-LMVSIVKQ.js");
74
+ var import_chunk_BPDMLM32 = require("./chunk-BPDMLM32.js");
75
+ var import_chunk_IOIAK7V7 = require("./chunk-IOIAK7V7.js");
76
+ var import_chunk_MJIP3FY5 = require("./chunk-MJIP3FY5.js");
77
+ var import_chunk_ZJWZK45Z = require("./chunk-ZJWZK45Z.js");
78
+ var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
79
+ var import_chunk_4VNS5WPM = require("./chunk-4VNS5WPM.js");
80
+ var import_debug = require("@prisma/debug");
81
+ var import_schema_files_loader = require("@prisma/schema-files-loader");
82
+ var import_fs = __toESM2(require("fs"));
83
+ var import_path = __toESM2(require("path"));
84
+ var import_util = require("util");
85
+ var import_debug2 = __toESM2(require("@prisma/debug"));
86
+ var import_crypto = __toESM2(require("crypto"));
87
+ var import_path2 = __toESM2(require("path"));
88
+ var import_debug3 = __toESM2(require("@prisma/debug"));
89
+ var import_engines = require("@prisma/engines");
90
+ var import_fetch_engine = require("@prisma/fetch-engine");
91
+ var import_get_platform = require("@prisma/get-platform");
92
+ var import_path3 = __toESM2(require("path"));
93
+ var import_debug4 = __toESM2(require("@prisma/debug"));
94
+ var import_node_path = __toESM2(require("node:path"));
95
+ var import_node_process = __toESM2(require("node:process"));
96
+ var import_node_path2 = __toESM2(require("node:path"));
97
+ var import_node_fs = __toESM2(require("node:fs"));
98
+ var import_node_url = require("node:url");
99
+ var import_node_fs2 = __toESM2(require("node:fs"));
100
+ var import_fs2 = __toESM2(require("fs"));
101
+ var import_path4 = __toESM2(require("path"));
102
+ var import_get_platform2 = require("@prisma/get-platform");
103
+ var debug = (0, import_debug2.default)("prisma:format");
104
+ async function formatSchema({ schemas }, inputFormattingOptions) {
105
+ if (process.env.FORCE_PANIC_PRISMA_SCHEMA) {
106
+ handleFormatPanic(() => {
107
+ import_chunk_T5MMBF2S.prismaSchemaWasm.debug_panic();
108
+ });
109
+ }
110
+ const defaultFormattingOptions = {
111
+ tabSize: 2,
112
+ insertSpaces: true
113
+ };
114
+ const documentFormattingParams = {
115
+ textDocument: { uri: "file:/dev/null" },
116
+ options: {
117
+ ...defaultFormattingOptions,
118
+ ...inputFormattingOptions
119
+ }
120
+ };
121
+ const { formattedMultipleSchemas, lintDiagnostics } = handleFormatPanic(() => {
122
+ const formattedMultipleSchemasRaw = formatWasm(JSON.stringify(schemas), documentFormattingParams);
123
+ const formattedMultipleSchemas2 = JSON.parse(formattedMultipleSchemasRaw);
124
+ const lintDiagnostics2 = (0, import_chunk_GNKWZC7O.lintSchema)({ schemas: formattedMultipleSchemas2 });
125
+ return { formattedMultipleSchemas: formattedMultipleSchemas2, lintDiagnostics: lintDiagnostics2 };
126
+ });
127
+ const lintWarnings = (0, import_chunk_GNKWZC7O.getLintWarningsAsText)(lintDiagnostics);
128
+ if (lintWarnings && import_chunk_ZJWZK45Z.logger_exports.should.warn()) {
129
+ console.warn(lintWarnings);
130
+ }
131
+ return Promise.resolve(formattedMultipleSchemas);
132
+ }
133
+ function handleFormatPanic(tryCb) {
134
+ try {
135
+ return tryCb();
136
+ } catch (e) {
137
+ const { message, stack } = (0, import_chunk_LMVSIVKQ.getWasmError)(e);
138
+ debug(`Error formatting schema: ${message}`);
139
+ debug(stack);
140
+ const panic = new import_chunk_LMVSIVKQ.RustPanic(
141
+ /* message */
142
+ message,
143
+ /* rustStack */
144
+ stack,
145
+ /* request */
146
+ "@prisma/prisma-schema-wasm format",
147
+ "FMT_CLI"
148
+ /* FMT_CLI */
149
+ );
150
+ throw panic;
151
+ }
152
+ }
153
+ function formatWasm(schema, documentFormattingParams) {
154
+ const formattedSchema = import_chunk_T5MMBF2S.prismaSchemaWasm.format(schema, JSON.stringify(documentFormattingParams));
155
+ return formattedSchema;
156
+ }
157
+ var readFile = (0, import_util.promisify)(import_fs.default.readFile);
158
+ var stat = (0, import_util.promisify)(import_fs.default.stat);
159
+ var debug2 = (0, import_debug.Debug)("prisma:getSchema");
160
+ async function getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
161
+ const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
162
+ if (result.ok) {
163
+ return result.schema;
164
+ }
165
+ throw new Error(renderDefaultLookupError(result.error, cwd));
166
+ }
167
+ async function getSchemaWithPathOptional(schemaPathFromArgs, schemaPathFromConfig, { cwd = process.cwd(), argumentName = "--schema" } = {}) {
168
+ const result = await getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName });
169
+ if (result.ok) {
170
+ return result.schema;
171
+ }
172
+ return null;
173
+ }
174
+ function printSchemaLoadedMessage(schemaPath2) {
175
+ process.stdout.write((0, import_chunk_PG5FDKSF.dim)(`Prisma schema loaded from ${import_path.default.relative(process.cwd(), schemaPath2)}`) + "\n");
176
+ }
177
+ async function readSchemaFromSingleFile(schemaPath2) {
178
+ debug2("Reading schema from single file", schemaPath2);
179
+ const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath2, "file");
180
+ if (typeError) {
181
+ return { ok: false, error: typeError };
182
+ }
183
+ const file = await readFile(schemaPath2, { encoding: "utf-8" });
184
+ const schemaTuple = [schemaPath2, file];
185
+ return {
186
+ ok: true,
187
+ schema: { schemaPath: schemaPath2, schemaRootDir: import_path.default.dirname(schemaPath2), schemas: [schemaTuple] }
188
+ };
189
+ }
190
+ async function readSchemaFromDirectory(schemaPath2) {
191
+ debug2("Reading schema from multiple files", schemaPath2);
192
+ const typeError = await (0, import_schema_files_loader.ensureType)(schemaPath2, "directory");
193
+ if (typeError) {
194
+ return { ok: false, error: typeError };
195
+ }
196
+ const files = await (0, import_schema_files_loader.loadSchemaFiles)(schemaPath2);
197
+ debug2("Loading config");
198
+ const config = await (0, import_chunk_CW6KQ3VH.getConfig)({
199
+ datamodel: files,
200
+ ignoreEnvVarErrors: true
201
+ });
202
+ debug2("Ok");
203
+ if (!(0, import_schema_files_loader.usesPrismaSchemaFolder)(config)) {
204
+ return { ok: false, error: { kind: "FolderPreviewNotEnabled", path: schemaPath2 } };
205
+ }
206
+ return { ok: true, schema: { schemaPath: schemaPath2, schemaRootDir: schemaPath2, schemas: files } };
207
+ }
208
+ async function readSchemaFromFileOrDirectory(schemaPath2) {
209
+ let stats;
210
+ try {
211
+ stats = await stat(schemaPath2);
212
+ } catch (e) {
213
+ if (e.code === "ENOENT") {
214
+ return { ok: false, error: { kind: "NotFound", path: schemaPath2 } };
215
+ }
216
+ throw e;
217
+ }
218
+ if (stats.isFile()) {
219
+ return readSchemaFromSingleFile(schemaPath2);
220
+ }
221
+ if (stats.isDirectory()) {
222
+ return readSchemaFromDirectory(schemaPath2);
223
+ }
224
+ return { ok: false, error: { kind: "WrongType", path: schemaPath2, expectedTypes: ["file", "directory"] } };
225
+ }
226
+ async function getSchemaWithPathInternal(schemaPathFromArgs, schemaPathFromConfig, { cwd, argumentName }) {
227
+ if (schemaPathFromArgs) {
228
+ const absPath = import_path.default.resolve(cwd, schemaPathFromArgs);
229
+ const customSchemaResult = await readSchemaFromFileOrDirectory(absPath);
230
+ if (!customSchemaResult.ok) {
231
+ const relPath = import_path.default.relative(cwd, absPath);
232
+ throw new Error(
233
+ `Could not load \`${argumentName}\` from provided path \`${relPath}\`: ${renderLookupError(
234
+ customSchemaResult.error
235
+ )}`
236
+ );
237
+ }
238
+ return customSchemaResult;
239
+ }
240
+ const prismaConfigResult = await readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig);
241
+ if (prismaConfigResult.ok) {
242
+ return prismaConfigResult;
243
+ }
244
+ const pkgJsonResult = await getSchemaFromPackageJson(cwd);
245
+ if (pkgJsonResult.ok) {
246
+ return pkgJsonResult;
247
+ }
248
+ const defaultResult = await getDefaultSchema(cwd);
249
+ if (defaultResult.ok) {
250
+ return defaultResult;
251
+ }
252
+ return {
253
+ ok: false,
254
+ error: defaultResult.error
255
+ };
256
+ }
257
+ function renderLookupError(error) {
258
+ switch (error.kind) {
259
+ case "NotFound": {
260
+ const expected = error.expectedType ?? "file or directory";
261
+ return `${expected} not found`;
262
+ }
263
+ case "FolderPreviewNotEnabled":
264
+ return `"prismaSchemaFolder" preview feature must be enabled`;
265
+ case "WrongType":
266
+ return `expected ${error.expectedTypes.join(" or ")}`;
267
+ }
268
+ }
269
+ function renderDefaultLookupError(error, cwd) {
270
+ const parts = [
271
+ `Could not find Prisma Schema that is required for this command.`,
272
+ `You can either provide it with ${(0, import_chunk_PG5FDKSF.green)("`--schema`")} argument,`,
273
+ `set it in your ${(0, import_chunk_PG5FDKSF.green)("`prisma.config.ts`")},`,
274
+ `set it as ${(0, import_chunk_PG5FDKSF.green)("`prisma.schema`")} in your ${(0, import_chunk_PG5FDKSF.green)("package.json")},`,
275
+ `or put it into the default location (${(0, import_chunk_PG5FDKSF.green)("`./prisma/schema.prisma`")}, or ${(0, import_chunk_PG5FDKSF.green)("`./schema.prisma`")}.`,
276
+ "Checked following paths:\n"
277
+ ];
278
+ const printedPaths = /* @__PURE__ */ new Set();
279
+ for (const failure of error.failures) {
280
+ const filePath = failure.path;
281
+ if (!printedPaths.has(failure.path)) {
282
+ parts.push(`${import_path.default.relative(cwd, filePath)}: ${renderLookupError(failure.error)}`);
283
+ printedPaths.add(filePath);
284
+ }
285
+ }
286
+ parts.push("\nSee also https://pris.ly/d/prisma-schema-location");
287
+ return parts.join("\n");
288
+ }
289
+ async function getPrismaConfigFromPackageJson(cwd) {
290
+ const pkgJson = await (0, import_chunk_MJIP3FY5.readPackageUp)({ cwd, normalize: false });
291
+ const prismaPropertyFromPkgJson = pkgJson?.packageJson?.prisma;
292
+ if (!pkgJson) {
293
+ return null;
294
+ }
295
+ return {
296
+ data: prismaPropertyFromPkgJson,
297
+ packagePath: pkgJson.path
298
+ };
299
+ }
300
+ async function readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig) {
301
+ if (!schemaPathFromConfig) {
302
+ return {
303
+ ok: false,
304
+ error: { kind: "PrismaConfigNotConfigured" }
305
+ };
306
+ }
307
+ const schemaResult = await readSchemaFromFileOrDirectory(schemaPathFromConfig);
308
+ if (!schemaResult.ok) {
309
+ throw new Error(
310
+ `Could not load schema from \`${schemaPathFromConfig}\` provided by "prisma.config.ts"\`: ${renderLookupError(
311
+ schemaResult.error
312
+ )}`
313
+ );
314
+ }
315
+ return schemaResult;
316
+ }
317
+ async function getSchemaFromPackageJson(cwd) {
318
+ const prismaConfig = await getPrismaConfigFromPackageJson(cwd);
319
+ debug2("prismaConfig", prismaConfig);
320
+ if (!prismaConfig || !prismaConfig.data?.schema) {
321
+ return { ok: false, error: { kind: "PackageJsonNotConfigured" } };
322
+ }
323
+ const schemaPathFromPkgJson = prismaConfig.data.schema;
324
+ if (typeof schemaPathFromPkgJson !== "string") {
325
+ throw new Error(
326
+ `Provided schema path \`${schemaPathFromPkgJson}\` from \`${import_path.default.relative(
327
+ cwd,
328
+ prismaConfig.packagePath
329
+ )}\` must be of type string`
330
+ );
331
+ }
332
+ const absoluteSchemaPath = import_path.default.isAbsolute(schemaPathFromPkgJson) ? schemaPathFromPkgJson : import_path.default.resolve(import_path.default.dirname(prismaConfig.packagePath), schemaPathFromPkgJson);
333
+ const lookupResult = await readSchemaFromFileOrDirectory(absoluteSchemaPath);
334
+ if (!lookupResult.ok) {
335
+ throw new Error(
336
+ `Could not load schema from \`${import_path.default.relative(
337
+ cwd,
338
+ absoluteSchemaPath
339
+ )}\` provided by "prisma.schema" config of \`${import_path.default.relative(
340
+ cwd,
341
+ prismaConfig.packagePath
342
+ )}\`: ${renderLookupError(lookupResult.error)}`
343
+ );
344
+ }
345
+ return lookupResult;
346
+ }
347
+ async function getDefaultSchema(cwd, failures = []) {
348
+ const lookupPaths = [import_path.default.join(cwd, "schema.prisma"), import_path.default.join(cwd, "prisma", "schema.prisma")];
349
+ for (const path7 of lookupPaths) {
350
+ debug2(`Checking existence of ${path7}`);
351
+ const schema = await readSchemaFromSingleFile(path7);
352
+ if (!schema.ok) {
353
+ failures.push({ path: path7, error: schema.error });
354
+ continue;
355
+ }
356
+ return schema;
357
+ }
358
+ return {
359
+ ok: false,
360
+ error: {
361
+ kind: "NotFoundMultipleLocations",
362
+ failures
363
+ }
364
+ };
365
+ }
366
+ async function getProjectHash(schemaPathFromArgs, schemaPathFromConfig) {
367
+ const projectPath = (await getSchemaWithPath(schemaPathFromArgs, schemaPathFromConfig))?.schemaPath ?? process.cwd();
368
+ return import_crypto.default.createHash("sha256").update(projectPath).digest("hex").substring(0, 8);
369
+ }
370
+ function getCLIPathHash() {
371
+ const cliPath = process.argv[1];
372
+ return import_crypto.default.createHash("sha256").update(cliPath).digest("hex").substring(0, 8);
373
+ }
374
+ async function loadSchemaContext({
375
+ schemaPathFromArg,
376
+ schemaPathFromConfig,
377
+ printLoadMessage = true,
378
+ ignoreEnvVarErrors = false,
379
+ allowNull = false,
380
+ schemaPathArgumentName = "--schema",
381
+ cwd = process.cwd()
382
+ } = {}) {
383
+ let schemaResult = null;
384
+ if (allowNull) {
385
+ schemaResult = await getSchemaWithPathOptional(schemaPathFromArg, schemaPathFromConfig, {
386
+ argumentName: schemaPathArgumentName,
387
+ cwd
388
+ });
389
+ if (!schemaResult) return null;
390
+ } else {
391
+ schemaResult = await getSchemaWithPath(schemaPathFromArg, schemaPathFromConfig, {
392
+ argumentName: schemaPathArgumentName,
393
+ cwd
394
+ });
395
+ }
396
+ return processSchemaResult({ schemaResult, printLoadMessage, ignoreEnvVarErrors, cwd });
397
+ }
398
+ async function processSchemaResult({
399
+ schemaResult,
400
+ printLoadMessage = true,
401
+ ignoreEnvVarErrors = false,
402
+ cwd = process.cwd()
403
+ }) {
404
+ const loadedFromPathForLogMessages = import_path2.default.relative(cwd, schemaResult.schemaPath);
405
+ if (printLoadMessage) {
406
+ printSchemaLoadedMessage(loadedFromPathForLogMessages);
407
+ }
408
+ const configFromPsl = await (0, import_chunk_CW6KQ3VH.getConfig)({ datamodel: schemaResult.schemas, ignoreEnvVarErrors });
409
+ const primaryDatasource = configFromPsl.datasources.at(0);
410
+ const schemaRootDir = schemaResult.schemaRootDir || cwd;
411
+ return {
412
+ schemaFiles: schemaResult.schemas,
413
+ schemaPath: schemaResult.schemaPath,
414
+ schemaRootDir,
415
+ datasources: configFromPsl.datasources,
416
+ generators: configFromPsl.generators,
417
+ primaryDatasource,
418
+ primaryDatasourceDirectory: primaryDatasourceDirectory(primaryDatasource) || schemaRootDir,
419
+ warnings: configFromPsl.warnings,
420
+ loadedFromPathForLogMessages
421
+ };
422
+ }
423
+ function primaryDatasourceDirectory(primaryDatasource) {
424
+ const datasourcePath = primaryDatasource?.sourceFilePath;
425
+ if (datasourcePath) {
426
+ return import_path2.default.dirname(datasourcePath);
427
+ }
428
+ return null;
429
+ }
430
+ var import_p_map = (0, import_chunk_4VNS5WPM.__toESM)((0, import_chunk_MJIP3FY5.require_p_map)());
431
+ var debug3 = (0, import_debug3.default)("prisma:getGenerators");
432
+ async function getGenerators(options) {
433
+ if (options.registry === void 0 && options.providerAliases !== void 0) {
434
+ options.registry = Object.fromEntries(
435
+ Object.entries(options.providerAliases).map(([name, definition]) => [
436
+ name,
437
+ {
438
+ type: "rpc",
439
+ generatorPath: definition.generatorPath,
440
+ isNode: definition.isNode
441
+ }
442
+ ])
443
+ );
444
+ }
445
+ const {
446
+ schemaPath,
447
+ registry,
448
+ version,
449
+ printDownloadProgress,
450
+ overrideGenerators,
451
+ skipDownload,
452
+ binaryPathsOverride,
453
+ generatorNames = [],
454
+ postinstall,
455
+ noEngine,
456
+ allowNoModels,
457
+ typedSql
458
+ } = options;
459
+ const schemaContext = !options.schemaContext && schemaPath ? await loadSchemaContext({ schemaPathFromArg: schemaPath, ignoreEnvVarErrors: true }) : options.schemaContext;
460
+ if (!schemaContext) {
461
+ throw new Error(`no schema provided for getGenerators`);
462
+ }
463
+ const binaryTarget = await (0, import_get_platform.getBinaryTargetForCurrentPlatform)();
464
+ const queryEngineBinaryType = (0, import_engines.getCliQueryEngineBinaryType)();
465
+ const queryEngineType = (0, import_chunk_RS2R7COT.binaryTypeToEngineType)(queryEngineBinaryType);
466
+ if (version && !binaryPathsOverride?.[queryEngineType]) {
467
+ const potentialPath = eval(`require('path').join(__dirname, '..')`);
468
+ if (!potentialPath.match(import_chunk_M3GBKLGE.vercelPkgPathRegex)) {
469
+ const downloadParams = {
470
+ binaries: {
471
+ [queryEngineBinaryType]: potentialPath
472
+ },
473
+ binaryTargets: [binaryTarget],
474
+ showProgress: false,
475
+ version,
476
+ skipDownload
477
+ };
478
+ await (0, import_fetch_engine.download)(downloadParams);
479
+ }
480
+ }
481
+ if (!schemaContext.primaryDatasource) {
482
+ throw new Error(import_chunk_AZV6HVKA.missingDatasource);
483
+ }
484
+ (0, import_chunk_5FJ3MENK.printConfigWarnings)(schemaContext.warnings);
485
+ const previewFeatures = (0, import_chunk_CRVLHWC5.extractPreviewFeatures)(schemaContext.generators);
486
+ const dmmf = await (0, import_chunk_QJ72IP2K.getDMMF)({
487
+ datamodel: schemaContext.schemaFiles,
488
+ previewFeatures
489
+ });
490
+ if (dmmf.datamodel.models.length === 0 && !allowNoModels) {
491
+ if (schemaContext.primaryDatasource.provider === "mongodb") {
492
+ throw new Error(import_chunk_XLTQGAI2.missingModelMessageMongoDB);
493
+ }
494
+ throw new Error(import_chunk_XLTQGAI2.missingModelMessage);
495
+ }
496
+ const generatorConfigs = filterGenerators(overrideGenerators || schemaContext.generators, generatorNames);
497
+ await validateGenerators(generatorConfigs);
498
+ const runningGenerators = [];
499
+ try {
500
+ const generators = await (0, import_p_map.default)(
501
+ generatorConfigs,
502
+ async (generatorConfig, index) => {
503
+ const baseDir = import_path3.default.dirname(generatorConfig.sourceFilePath ?? schemaContext.schemaRootDir);
504
+ const providerValue = (0, import_chunk_IOIAK7V7.parseEnvValue)(generatorConfig.provider);
505
+ const generatorDefinition = registry[providerValue] ?? {
506
+ type: "rpc",
507
+ generatorPath: providerValue
508
+ };
509
+ const generatorInstance = (0, import_chunk_XKZ6CBLA.z)(generatorDefinition).with({ type: "in-process" }, ({ generator }) => new import_chunk_BPDMLM32.InProcessGenerator(generatorConfig, generator)).with(
510
+ { type: "rpc" },
511
+ ({ generatorPath, isNode }) => new import_chunk_BPDMLM32.JsonRpcGenerator(generatorPath, generatorConfig, isNode)
512
+ ).exhaustive();
513
+ await generatorInstance.init();
514
+ if (generatorConfig.output) {
515
+ generatorConfig.output = {
516
+ value: import_path3.default.resolve(baseDir, (0, import_chunk_IOIAK7V7.parseEnvValue)(generatorConfig.output)),
517
+ fromEnvVar: null
518
+ };
519
+ generatorConfig.isCustomOutput = true;
520
+ } else {
521
+ if (!generatorInstance.manifest?.defaultOutput) {
522
+ throw new Error(
523
+ `Can't resolve output dir for generator ${(0, import_chunk_PG5FDKSF.bold)(generatorConfig.name)} with provider ${(0, import_chunk_PG5FDKSF.bold)(
524
+ generatorConfig.provider.value
525
+ )}.
526
+ You need to define \`output\` in the generator block in the schema file.`
527
+ );
528
+ }
529
+ generatorConfig.output = {
530
+ value: await (0, import_chunk_2B26F5N3.resolveOutput)({
531
+ defaultOutput: generatorInstance.manifest.defaultOutput,
532
+ baseDir
533
+ }),
534
+ fromEnvVar: null
535
+ };
536
+ }
537
+ const datamodel = (0, import_chunk_TN4KCTWC.mergeSchemas)({ schemas: schemaContext.schemaFiles });
538
+ const envPaths = await getEnvPaths(schemaContext.schemaPath, { cwd: generatorConfig.output.value });
539
+ const options2 = {
540
+ datamodel,
541
+ datasources: schemaContext.datasources,
542
+ generator: generatorConfig,
543
+ dmmf,
544
+ otherGenerators: skipIndex(generatorConfigs, index),
545
+ schemaPath: schemaContext.schemaPath,
546
+ // TODO:(schemaPath) can we get rid of schema path passing here?
547
+ version: version || import_engines.enginesVersion,
548
+ // this version makes no sense anymore and should be ignored
549
+ postinstall,
550
+ noEngine,
551
+ allowNoModels,
552
+ envPaths,
553
+ typedSql
554
+ };
555
+ generatorInstance.setOptions(options2);
556
+ runningGenerators.push(generatorInstance);
557
+ return generatorInstance;
558
+ },
559
+ {
560
+ stopOnError: false
561
+ // needed so we can first make sure all generators are created properly, then cleaned up properly
562
+ }
563
+ );
564
+ const generatorProviders = generatorConfigs.map((g) => (0, import_chunk_IOIAK7V7.parseEnvValue)(g.provider));
565
+ for (const g of generators) {
566
+ if (g.manifest && g.manifest.requiresGenerators && g.manifest.requiresGenerators.length > 0) {
567
+ for (const neededGenerator of g.manifest.requiresGenerators) {
568
+ if (!generatorProviders.includes(neededGenerator)) {
569
+ throw new Error(
570
+ `Generator "${g.manifest.prettyName}" requires generator "${neededGenerator}", but it is missing in your schema.prisma.
571
+ Please add it to your schema.prisma:
572
+
573
+ generator gen {
574
+ provider = "${neededGenerator}"
575
+ }
576
+ `
577
+ );
578
+ }
579
+ }
580
+ }
581
+ }
582
+ const neededVersions = /* @__PURE__ */ Object.create(null);
583
+ for (const g of generators) {
584
+ if (g.manifest && g.manifest.requiresEngines && Array.isArray(g.manifest.requiresEngines) && g.manifest.requiresEngines.length > 0) {
585
+ const neededVersion = (0, import_chunk_X3P4J7WW.getEngineVersionForGenerator)(g.manifest, version);
586
+ if (!neededVersions[neededVersion]) {
587
+ neededVersions[neededVersion] = { engines: [], binaryTargets: [] };
588
+ }
589
+ for (const engine of g.manifest.requiresEngines) {
590
+ if (!neededVersions[neededVersion].engines.includes(engine)) {
591
+ neededVersions[neededVersion].engines.push(engine);
592
+ }
593
+ }
594
+ const generatorBinaryTargets = g.options?.generator?.binaryTargets;
595
+ if (generatorBinaryTargets && generatorBinaryTargets.length > 0) {
596
+ for (const binaryTarget2 of generatorBinaryTargets) {
597
+ if (!neededVersions[neededVersion].binaryTargets.find((object) => object.value === binaryTarget2.value)) {
598
+ neededVersions[neededVersion].binaryTargets.push(binaryTarget2);
599
+ }
600
+ }
601
+ }
602
+ }
603
+ }
604
+ debug3("neededVersions", JSON.stringify(neededVersions, null, 2));
605
+ const binaryPathsByVersion = await (0, import_chunk_EPXBOIA5.getBinaryPathsByVersion)({
606
+ neededVersions,
607
+ binaryTarget,
608
+ version,
609
+ printDownloadProgress,
610
+ skipDownload,
611
+ binaryPathsOverride
612
+ });
613
+ for (const generator of generators) {
614
+ if (generator.manifest && generator.manifest.requiresEngines) {
615
+ const engineVersion = (0, import_chunk_X3P4J7WW.getEngineVersionForGenerator)(generator.manifest, version);
616
+ const binaryPaths = binaryPathsByVersion[engineVersion];
617
+ const generatorBinaryPaths = (0, import_chunk_5V36RLCO.pick)(binaryPaths, generator.manifest.requiresEngines);
618
+ debug3({ generatorBinaryPaths });
619
+ generator.setBinaryPaths(generatorBinaryPaths);
620
+ if (engineVersion !== version && generator.options && generator.manifest.requiresEngines.includes(queryEngineType) && generatorBinaryPaths[queryEngineType] && generatorBinaryPaths[queryEngineType]?.[binaryTarget]) {
621
+ const customDmmf = await (0, import_chunk_QJ72IP2K.getDMMF)({
622
+ datamodel: schemaContext.schemaFiles,
623
+ previewFeatures
624
+ });
625
+ const options2 = { ...generator.options, dmmf: customDmmf };
626
+ debug3("generator.manifest.prettyName", generator.manifest.prettyName);
627
+ debug3("options", options2);
628
+ debug3("options.generator.binaryTargets", options2.generator.binaryTargets);
629
+ generator.setOptions(options2);
630
+ }
631
+ }
632
+ }
633
+ return generators;
634
+ } catch (e) {
635
+ runningGenerators.forEach((g) => g.stop());
636
+ throw e;
637
+ }
638
+ }
639
+ async function getGenerator(options2) {
640
+ const generators = await getGenerators(options2);
641
+ return generators[0];
642
+ }
643
+ function skipIndex(arr, index) {
644
+ return [...arr.slice(0, index), ...arr.slice(index + 1)];
645
+ }
646
+ var knownBinaryTargets = [...import_get_platform.binaryTargets, "native"];
647
+ var oldToNewBinaryTargetsMapping = {
648
+ "linux-glibc-libssl1.0.1": "debian-openssl-1.0.x",
649
+ "linux-glibc-libssl1.0.2": "debian-openssl-1.0.x",
650
+ "linux-glibc-libssl1.1.0": "debian-openssl1.1.x"
651
+ };
652
+ async function validateGenerators(generators) {
653
+ const binaryTarget2 = await (0, import_get_platform.getBinaryTargetForCurrentPlatform)();
654
+ for (const generator of generators) {
655
+ if (generator.config.platforms) {
656
+ throw new Error(
657
+ `The \`platforms\` field on the generator definition is deprecated. Please rename it to \`binaryTargets\`.`
658
+ );
659
+ }
660
+ if (generator.config.pinnedBinaryTargets) {
661
+ throw new Error(
662
+ `The \`pinnedBinaryTargets\` field on the generator definition is deprecated.
663
+ Please use the PRISMA_QUERY_ENGINE_BINARY env var instead to pin the binary target.`
664
+ );
665
+ }
666
+ if (generator.binaryTargets) {
667
+ const binaryTargets2 = generator.binaryTargets && generator.binaryTargets.length > 0 ? generator.binaryTargets : [{ fromEnvVar: null, value: "native" }];
668
+ const resolvedBinaryTargets = binaryTargets2.flatMap((object) => (0, import_chunk_IOIAK7V7.parseBinaryTargetsEnvValue)(object)).map((p) => p === "native" ? binaryTarget2 : p);
669
+ for (const resolvedBinaryTarget of resolvedBinaryTargets) {
670
+ if (oldToNewBinaryTargetsMapping[resolvedBinaryTarget]) {
671
+ throw new Error(
672
+ `Binary target ${(0, import_chunk_PG5FDKSF.red)((0, import_chunk_PG5FDKSF.bold)(resolvedBinaryTarget))} is deprecated. Please use ${(0, import_chunk_PG5FDKSF.green)(
673
+ (0, import_chunk_PG5FDKSF.bold)(oldToNewBinaryTargetsMapping[resolvedBinaryTarget])
674
+ )} instead.`
675
+ );
676
+ }
677
+ if (!knownBinaryTargets.includes(resolvedBinaryTarget)) {
678
+ throw new Error(
679
+ `Unknown binary target ${(0, import_chunk_PG5FDKSF.red)(resolvedBinaryTarget)} in generator ${(0, import_chunk_PG5FDKSF.bold)(generator.name)}.
680
+ Possible binaryTargets: ${(0, import_chunk_PG5FDKSF.green)(knownBinaryTargets.join(", "))}`
681
+ );
682
+ }
683
+ }
684
+ if (!resolvedBinaryTargets.includes(binaryTarget2)) {
685
+ const originalBinaryTargetsConfig = (0, import_chunk_LRU47BGE.getOriginalBinaryTargetsValue)(generator.binaryTargets);
686
+ console.log(`${(0, import_chunk_PG5FDKSF.yellow)("Warning:")} Your current platform \`${(0, import_chunk_PG5FDKSF.bold)(
687
+ binaryTarget2
688
+ )}\` is not included in your generator's \`binaryTargets\` configuration ${JSON.stringify(
689
+ originalBinaryTargetsConfig
690
+ )}.
691
+ To fix it, use this generator config in your ${(0, import_chunk_PG5FDKSF.bold)("schema.prisma")}:
692
+ ${(0, import_chunk_PG5FDKSF.green)(
693
+ (0, import_chunk_LRU47BGE.printGeneratorConfig)({
694
+ ...generator,
695
+ binaryTargets: (0, import_chunk_X77CS5RK.fixBinaryTargets)(generator.binaryTargets, binaryTarget2)
696
+ })
697
+ )}
698
+ ${(0, import_chunk_PG5FDKSF.gray)(
699
+ `Note, that by providing \`native\`, Prisma Client automatically resolves \`${binaryTarget2}\`.
700
+ Read more about deploying Prisma Client: ${(0, import_chunk_PG5FDKSF.underline)(
701
+ "https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-schema/generators"
702
+ )}`
703
+ )}
704
+ `);
705
+ }
706
+ }
707
+ }
708
+ }
709
+ function filterGenerators(generators, generatorNames2) {
710
+ if (generatorNames2.length < 1) {
711
+ return generators;
712
+ }
713
+ const filtered = generators.filter((generator) => generatorNames2.includes(generator.name));
714
+ if (filtered.length !== generatorNames2.length) {
715
+ const missings = generatorNames2.filter((name) => filtered.find((generator) => generator.name === name) == null);
716
+ const isSingular = missings.length <= 1;
717
+ throw new Error(
718
+ `The ${isSingular ? "generator" : "generators"} ${(0, import_chunk_PG5FDKSF.bold)(missings.join(", "))} specified via ${(0, import_chunk_PG5FDKSF.bold)(
719
+ "--generator"
720
+ )} ${isSingular ? "does" : "do"} not exist in your Prisma schema`
721
+ );
722
+ }
723
+ return filtered;
724
+ }
725
+ var typeMappings = {
726
+ directory: "isDirectory",
727
+ file: "isFile"
728
+ };
729
+ function checkType(type) {
730
+ if (Object.hasOwnProperty.call(typeMappings, type)) {
731
+ return;
732
+ }
733
+ throw new Error(`Invalid type specified: ${type}`);
734
+ }
735
+ var matchType = (type, stat2) => stat2[typeMappings[type]]();
736
+ var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? (0, import_node_url.fileURLToPath)(urlOrPath) : urlOrPath;
737
+ function locatePathSync(paths, {
738
+ cwd = import_node_process.default.cwd(),
739
+ type = "file",
740
+ allowSymlinks = true
741
+ } = {}) {
742
+ checkType(type);
743
+ cwd = toPath2(cwd);
744
+ const statFunction = allowSymlinks ? import_node_fs.default.statSync : import_node_fs.default.lstatSync;
745
+ for (const path_ of paths) {
746
+ try {
747
+ const stat2 = statFunction(import_node_path2.default.resolve(cwd, path_), {
748
+ throwIfNoEntry: false
749
+ });
750
+ if (!stat2) {
751
+ continue;
752
+ }
753
+ if (matchType(type, stat2)) {
754
+ return path_;
755
+ }
756
+ } catch {
757
+ }
758
+ }
759
+ }
760
+ function pathExistsSync(path7) {
761
+ try {
762
+ import_node_fs2.default.accessSync(path7);
763
+ return true;
764
+ } catch {
765
+ return false;
766
+ }
767
+ }
768
+ var findUpStop = Symbol("findUpStop");
769
+ function findUpMultipleSync(name, options2 = {}) {
770
+ let directory = import_node_path.default.resolve((0, import_chunk_MJIP3FY5.toPath)(options2.cwd) ?? "");
771
+ const { root } = import_node_path.default.parse(directory);
772
+ const stopAt = import_node_path.default.resolve(directory, (0, import_chunk_MJIP3FY5.toPath)(options2.stopAt) ?? root);
773
+ const limit = options2.limit ?? Number.POSITIVE_INFINITY;
774
+ const paths = [name].flat();
775
+ const runMatcher = (locateOptions) => {
776
+ if (typeof name !== "function") {
777
+ return locatePathSync(paths, locateOptions);
778
+ }
779
+ const foundPath = name(locateOptions.cwd);
780
+ if (typeof foundPath === "string") {
781
+ return locatePathSync([foundPath], locateOptions);
782
+ }
783
+ return foundPath;
784
+ };
785
+ const matches = [];
786
+ while (true) {
787
+ const foundPath = runMatcher({ ...options2, cwd: directory });
788
+ if (foundPath === findUpStop) {
789
+ break;
790
+ }
791
+ if (foundPath) {
792
+ matches.push(import_node_path.default.resolve(directory, foundPath));
793
+ }
794
+ if (directory === stopAt || matches.length >= limit) {
795
+ break;
796
+ }
797
+ directory = import_node_path.default.dirname(directory);
798
+ }
799
+ return matches;
800
+ }
801
+ function findUpSync(name, options2 = {}) {
802
+ const matches = findUpMultipleSync(name, { ...options2, limit: 1 });
803
+ return matches[0];
804
+ }
805
+ var debug4 = (0, import_debug4.default)("prisma:loadEnv");
806
+ async function getEnvPaths(schemaPath2, opts = { cwd: process.cwd() }) {
807
+ const rootEnvPath = getProjectRootEnvPath({ cwd: opts.cwd }) ?? null;
808
+ const schemaEnvPathFromArgs = schemaPathToEnvPath(schemaPath2);
809
+ const schemaEnvPathFromPkgJson = schemaPathToEnvPath(await readSchemaPathFromPkgJson());
810
+ const schemaEnvPaths = [
811
+ schemaEnvPathFromArgs,
812
+ // 1 - Check --schema directory for .env
813
+ schemaEnvPathFromPkgJson,
814
+ // 2 - Check package.json schema directory for .env
815
+ "./prisma/.env",
816
+ // 3 - Check ./prisma directory for .env
817
+ "./.env"
818
+ // 4 - Check cwd for .env
819
+ ];
820
+ const schemaEnvPath = schemaEnvPaths.find(import_chunk_UTJGRVMG.exists);
821
+ return { rootEnvPath, schemaEnvPath };
822
+ }
823
+ async function readSchemaPathFromPkgJson() {
824
+ try {
825
+ const pkgJsonSchema = await getSchemaFromPackageJson(process.cwd());
826
+ if (pkgJsonSchema.ok) {
827
+ pkgJsonSchema.schema.schemaPath;
828
+ }
829
+ return null;
830
+ } catch {
831
+ return null;
832
+ }
833
+ }
834
+ function getProjectRootEnvPath(opts) {
835
+ const pkgJsonPath = findUpSync((dir) => {
836
+ const pkgPath = import_path4.default.join(dir, "package.json");
837
+ if (pathExistsSync(pkgPath)) {
838
+ try {
839
+ const pkg = JSON.parse(import_fs2.default.readFileSync(pkgPath, "utf8"));
840
+ if (pkg["name"] !== ".prisma/client") {
841
+ debug4(`project root found at ${pkgPath}`);
842
+ return pkgPath;
843
+ }
844
+ } catch (e) {
845
+ debug4(`skipping package.json at ${pkgPath}`);
846
+ }
847
+ }
848
+ return void 0;
849
+ }, opts);
850
+ if (!pkgJsonPath) {
851
+ return null;
852
+ }
853
+ const candidate = import_path4.default.join(import_path4.default.dirname(pkgJsonPath), ".env");
854
+ if (!import_fs2.default.existsSync(candidate)) {
855
+ return null;
856
+ }
857
+ return candidate;
858
+ }
859
+ function schemaPathToEnvPath(schemaPath2) {
860
+ if (!schemaPath2) return null;
861
+ return import_path4.default.join(import_path4.default.dirname(schemaPath2), ".env");
862
+ }
863
+ async function loadEnvFile({
864
+ schemaPath: schemaPath2,
865
+ config,
866
+ printMessage = false
867
+ }) {
868
+ if (config.loadedFromFile) {
869
+ process.stdout.write(`Prisma config detected, skipping environment variable loading.
870
+ `);
871
+ return;
872
+ }
873
+ const envPaths = await getEnvPaths(schemaPath2);
874
+ const envData = (0, import_chunk_UTJGRVMG.tryLoadEnvs)(envPaths, { conflictCheck: "error" });
875
+ if (printMessage && envData && envData.message) {
876
+ process.stdout.write(envData.message + "\n");
877
+ }
878
+ }
879
+ var forbiddenCmdWithDataProxyFlagMessage = (command) => `
880
+ Using an Accelerate URL is not supported for this CLI command ${(0, import_chunk_PG5FDKSF.green)(`prisma ${command}`)} yet.
881
+ Please use a direct connection to your database via the datasource \`directUrl\` setting.
882
+
883
+ More information about this limitation: ${(0, import_chunk_HAGJ64PM.link)("https://pris.ly/d/accelerate-limitations")}
884
+ `;
885
+ function checkUnsupportedDataProxy({
886
+ cmd,
887
+ schemaContext: schemaContext2 = void 0,
888
+ urls = []
889
+ }) {
890
+ for (const url2 of urls) {
891
+ if (url2 && url2.includes("prisma://")) {
892
+ throw new Error(forbiddenCmdWithDataProxyFlagMessage(cmd));
893
+ }
894
+ }
895
+ if (!schemaContext2?.primaryDatasource) return;
896
+ const url = (0, import_chunk_CW6KQ3VH.resolveUrl)((0, import_chunk_CW6KQ3VH.getEffectiveUrl)(schemaContext2.primaryDatasource));
897
+ if (url?.startsWith("prisma://")) {
898
+ throw new Error(forbiddenCmdWithDataProxyFlagMessage(cmd));
899
+ }
900
+ }