@prisma/internals 6.6.0-integration-engines-6-6-0-17-refactor-migrate-to-new-interface-a65ab979bf81a122861f2a68231321419d7fb303.1 → 6.6.0-integration-push-xmzqvqxpztks.1

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