@prisma/internals 6.6.0-dev.34 → 6.6.0-dev.35

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 (61) hide show
  1. package/dist/{chunk-WD2267J3.js → chunk-2VT4AM4Y.js} +17 -17
  2. package/dist/{chunk-MSQTBYIV.js → chunk-2WQVHYBS.js} +5 -5
  3. package/dist/{chunk-7MD6344A.js → chunk-5DBOS77Y.js} +3 -5
  4. package/dist/{chunk-KTB2HCCO.js → chunk-7FH5JKIS.js} +7 -7
  5. package/dist/{chunk-JAWGW6LI.js → chunk-BXZXLEEH.js} +9 -9
  6. package/dist/{chunk-PSYMCJ4B.js → chunk-CMIKSBKL.js} +8 -8
  7. package/dist/{chunk-TSJICM5S.js → chunk-CRVLHWC5.js} +5 -5
  8. package/dist/{chunk-KSJNY56L.js → chunk-DJYSR6QD.js} +22 -22
  9. package/dist/{chunk-T2PFJSAD.js → chunk-GNK3AD6X.js} +13 -13
  10. package/dist/{chunk-RAC7G3AO.js → chunk-LR3WWKZI.js} +5 -5
  11. package/dist/{chunk-LOQLKDQE.js → chunk-NZDLSDLM.js} +5 -5
  12. package/dist/{chunk-RVU5FP25.js → chunk-O3MUXTZX.js} +78 -92
  13. package/dist/{chunk-AYSLETYV.js → chunk-OKJT45NT.js} +38 -67
  14. package/dist/{chunk-JUXIW5NS.js → chunk-OQZDUJAJ.js} +5 -5
  15. package/dist/{chunk-MM4PIVNT.js → chunk-PAIGKNMY.js} +26 -26
  16. package/dist/{chunk-GNEFDTJE.js → chunk-PEB6D6GV.js} +72 -86
  17. package/dist/{chunk-2TQR7BKX.js → chunk-Q6VZHKYE.js} +9 -9
  18. package/dist/{chunk-YBYBY7QI.js → chunk-U4WXIU7C.js} +5 -5
  19. package/dist/{chunk-EORSBI5P.js → chunk-UCI7OFQ4.js} +5 -5
  20. package/dist/{chunk-6E4KJPDH.js → chunk-VEWDTOV5.js} +14 -14
  21. package/dist/{chunk-X3CLVIIZ.js → chunk-VLBKBUPL.js} +35 -64
  22. package/dist/{chunk-PIHBLNPJ.js → chunk-WCWE5A2C.js} +4 -4
  23. package/dist/cli/checkUnsupportedDataProxy.js +20 -21
  24. package/dist/cli/getSchema.js +24 -25
  25. package/dist/cli/hashes.js +20 -21
  26. package/dist/cli/schemaContext.d.ts +16 -2
  27. package/dist/cli/schemaContext.js +20 -20
  28. package/dist/engine-commands/errorHelpers.js +4 -4
  29. package/dist/engine-commands/formatSchema.js +19 -20
  30. package/dist/engine-commands/getConfig.d.ts +0 -4
  31. package/dist/engine-commands/getConfig.js +12 -12
  32. package/dist/engine-commands/getDmmf.d.ts +1 -5
  33. package/dist/engine-commands/getDmmf.js +9 -9
  34. package/dist/engine-commands/getEngineVersion.js +5 -5
  35. package/dist/engine-commands/getEnginesMetaInfo.js +7 -7
  36. package/dist/engine-commands/index.js +30 -31
  37. package/dist/engine-commands/lintSchema.js +8 -8
  38. package/dist/engine-commands/mergeSchemas.js +9 -9
  39. package/dist/engine-commands/queryEngineCommons.js +6 -6
  40. package/dist/engine-commands/validate.js +9 -9
  41. package/dist/get-generators/generatorResolvers/generatorResolvers.js +19 -20
  42. package/dist/get-generators/generatorResolvers/prisma-client-js/check-dependencies/checkTypeScriptVersion.js +19 -20
  43. package/dist/get-generators/generatorResolvers/prisma-client-js/prismaClientResolver.js +20 -21
  44. package/dist/get-generators/getGenerators.d.ts +7 -3
  45. package/dist/get-generators/getGenerators.js +22 -23
  46. package/dist/index.d.ts +1 -1
  47. package/dist/index.js +59 -59
  48. package/dist/resolveBinary.js +7 -7
  49. package/dist/schemaEngineCommands.js +8 -8
  50. package/dist/sendPanic.js +19 -20
  51. package/dist/utils/extractPreviewFeatures.d.ts +2 -2
  52. package/dist/utils/extractPreviewFeatures.js +2 -2
  53. package/dist/utils/getEnvPaths.js +19 -20
  54. package/dist/utils/getVersionFromPackageJson.js +3 -3
  55. package/dist/utils/handlePanic.js +19 -20
  56. package/dist/utils/loadEnvFile.js +19 -20
  57. package/dist/wasm.js +4 -4
  58. package/package.json +8 -8
  59. package/dist/chunk-IPKE37QC.js +0 -25
  60. package/dist/get-generators/utils/check-feature-flags/checkFeatureFlags.d.ts +0 -8
  61. package/dist/get-generators/utils/check-feature-flags/checkFeatureFlags.js +0 -25
@@ -26,8 +26,8 @@ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS2 = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_RVU5FP25_exports = {};
30
- __export2(chunk_RVU5FP25_exports, {
29
+ var chunk_O3MUXTZX_exports = {};
30
+ __export2(chunk_O3MUXTZX_exports, {
31
31
  checkTypeScriptVersion: () => checkTypeScriptVersion,
32
32
  checkUnsupportedDataProxy: () => checkUnsupportedDataProxy,
33
33
  debug: () => debug5,
@@ -52,15 +52,15 @@ __export2(chunk_RVU5FP25_exports, {
52
52
  loadEnvFile: () => loadEnvFile,
53
53
  loadSchemaContext: () => loadSchemaContext,
54
54
  prismaClientResolver: () => prismaClientResolver,
55
+ processSchemaResult: () => processSchemaResult,
55
56
  sendPanic: () => sendPanic,
56
57
  skipIndex: () => skipIndex
57
58
  });
58
- module.exports = __toCommonJS2(chunk_RVU5FP25_exports);
59
- var import_chunk_ETNCBIDF = require("./chunk-ETNCBIDF.js");
59
+ module.exports = __toCommonJS2(chunk_O3MUXTZX_exports);
60
60
  var import_chunk_GHHABGYW = require("./chunk-GHHABGYW.js");
61
61
  var import_chunk_EUTJYQDW = require("./chunk-EUTJYQDW.js");
62
- var import_chunk_IPKE37QC = require("./chunk-IPKE37QC.js");
63
62
  var import_chunk_DGZO4GAJ = require("./chunk-DGZO4GAJ.js");
63
+ var import_chunk_ETNCBIDF = require("./chunk-ETNCBIDF.js");
64
64
  var import_chunk_72UZXEBG = require("./chunk-72UZXEBG.js");
65
65
  var import_chunk_X77CS5RK = require("./chunk-X77CS5RK.js");
66
66
  var import_chunk_EIERU2IM = require("./chunk-EIERU2IM.js");
@@ -78,14 +78,14 @@ var import_chunk_FNA4EAZ6 = require("./chunk-FNA4EAZ6.js");
78
78
  var import_chunk_J77ZIDXB = require("./chunk-J77ZIDXB.js");
79
79
  var import_chunk_2T4NJDHK = require("./chunk-2T4NJDHK.js");
80
80
  var import_chunk_R3J2O23S = require("./chunk-R3J2O23S.js");
81
- var import_chunk_TSJICM5S = require("./chunk-TSJICM5S.js");
82
- var import_chunk_LOQLKDQE = require("./chunk-LOQLKDQE.js");
83
- var import_chunk_T2PFJSAD = require("./chunk-T2PFJSAD.js");
84
- var import_chunk_KSJNY56L = require("./chunk-KSJNY56L.js");
85
- var import_chunk_AYSLETYV = require("./chunk-AYSLETYV.js");
81
+ var import_chunk_CRVLHWC5 = require("./chunk-CRVLHWC5.js");
82
+ var import_chunk_NZDLSDLM = require("./chunk-NZDLSDLM.js");
83
+ var import_chunk_GNK3AD6X = require("./chunk-GNK3AD6X.js");
84
+ var import_chunk_DJYSR6QD = require("./chunk-DJYSR6QD.js");
85
+ var import_chunk_OKJT45NT = require("./chunk-OKJT45NT.js");
86
86
  var import_chunk_YRBRUREX = require("./chunk-YRBRUREX.js");
87
87
  var import_chunk_XKZ6CBLA = require("./chunk-XKZ6CBLA.js");
88
- var import_chunk_RAC7G3AO = require("./chunk-RAC7G3AO.js");
88
+ var import_chunk_LR3WWKZI = require("./chunk-LR3WWKZI.js");
89
89
  var import_chunk_CCQRDM7X = require("./chunk-CCQRDM7X.js");
90
90
  var import_chunk_2B26F5N3 = require("./chunk-2B26F5N3.js");
91
91
  var import_chunk_RAYPCPVU = require("./chunk-RAYPCPVU.js");
@@ -14013,8 +14013,8 @@ var require_dist = (0, import_chunk_2ESYSVXG.__commonJS)({
14013
14013
  status: "disabled"
14014
14014
  };
14015
14015
  }
14016
- const config2 = await Config.new(state);
14017
- const cacheResponse = await config2.checkCache(state);
14016
+ const config = await Config.new(state);
14017
+ const cacheResponse = await config.checkCache(state);
14018
14018
  state.check_if_update_available = cacheResponse.stale === true || !cacheResponse.cache;
14019
14019
  const child = spawn(state);
14020
14020
  if (state.unref) {
@@ -14029,7 +14029,7 @@ var require_dist = (0, import_chunk_2ESYSVXG.__commonJS)({
14029
14029
  }
14030
14030
  for (const key of Object.keys(state)) {
14031
14031
  if (state[key]) {
14032
- await config2.set({
14032
+ await config.set({
14033
14033
  [key]: state[key]
14034
14034
  });
14035
14035
  }
@@ -14041,7 +14041,7 @@ var require_dist = (0, import_chunk_2ESYSVXG.__commonJS)({
14041
14041
  data: cacheResponse.cache.output
14042
14042
  };
14043
14043
  }
14044
- await config2.set({
14044
+ await config.set({
14045
14045
  last_reminder: state.now()
14046
14046
  });
14047
14047
  return {
@@ -14532,12 +14532,12 @@ async function readSchemaFromDirectory(schemaPath2) {
14532
14532
  }
14533
14533
  const files = await (0, import_schema_files_loader.loadSchemaFiles)(schemaPath2);
14534
14534
  debug2("Loading config");
14535
- const config2 = await (0, import_chunk_KSJNY56L.getConfig)({
14535
+ const config = await (0, import_chunk_DJYSR6QD.getConfig)({
14536
14536
  datamodel: files,
14537
14537
  ignoreEnvVarErrors: true
14538
14538
  });
14539
14539
  debug2("Ok");
14540
- if (!(0, import_schema_files_loader.usesPrismaSchemaFolder)(config2)) {
14540
+ if (!(0, import_schema_files_loader.usesPrismaSchemaFolder)(config)) {
14541
14541
  return { ok: false, error: { kind: "FolderPreviewNotEnabled", path: schemaPath2 } };
14542
14542
  }
14543
14543
  return { ok: true, schema: { schemaPath: schemaPath2, schemaRootDir: schemaPath2, schemas: files } };
@@ -14640,23 +14640,23 @@ async function readSchemaFromPrismaConfigBasedLocation(schemaPathFromConfig) {
14640
14640
  error: { kind: "PrismaConfigNotConfigured" }
14641
14641
  };
14642
14642
  }
14643
- let schemaResult2;
14643
+ let schemaResult;
14644
14644
  if (schemaPathFromConfig.kind === "single") {
14645
- schemaResult2 = await readSchemaFromSingleFile(schemaPathFromConfig.filePath);
14646
- if (!schemaResult2.ok) {
14645
+ schemaResult = await readSchemaFromSingleFile(schemaPathFromConfig.filePath);
14646
+ if (!schemaResult.ok) {
14647
14647
  throw new Error(
14648
- `Could not load schema from file \`${schemaPathFromConfig.filePath}\` provided by "prisma.config.ts"\`: ${renderLookupError(schemaResult2.error)}`
14648
+ `Could not load schema from file \`${schemaPathFromConfig.filePath}\` provided by "prisma.config.ts"\`: ${renderLookupError(schemaResult.error)}`
14649
14649
  );
14650
14650
  }
14651
14651
  } else {
14652
- schemaResult2 = await readSchemaFromDirectory(schemaPathFromConfig.folderPath);
14653
- if (!schemaResult2.ok) {
14652
+ schemaResult = await readSchemaFromDirectory(schemaPathFromConfig.folderPath);
14653
+ if (!schemaResult.ok) {
14654
14654
  throw new Error(
14655
- `Could not load schema from folder \`${schemaPathFromConfig.folderPath}\` provided by "prisma.config.ts"\`: ${renderLookupError(schemaResult2.error)}`
14655
+ `Could not load schema from folder \`${schemaPathFromConfig.folderPath}\` provided by "prisma.config.ts"\`: ${renderLookupError(schemaResult.error)}`
14656
14656
  );
14657
14657
  }
14658
14658
  }
14659
- return schemaResult2;
14659
+ return schemaResult;
14660
14660
  }
14661
14661
  async function getSchemaFromPackageJson(cwd) {
14662
14662
  const prismaConfig = await getPrismaConfigFromPackageJson(cwd);
@@ -14826,10 +14826,10 @@ function schemaPathToEnvPath(schemaPath2) {
14826
14826
  }
14827
14827
  async function loadEnvFile({
14828
14828
  schemaPath: schemaPath2,
14829
- config: config2,
14829
+ config,
14830
14830
  printMessage = false
14831
14831
  }) {
14832
- if (config2.loadedFromFile) {
14832
+ if (config.loadedFromFile) {
14833
14833
  process.stdout.write(`Prisma config detected, skipping environment variable loading.
14834
14834
  `);
14835
14835
  return;
@@ -14858,8 +14858,8 @@ async function checkUnsupportedDataProxyMessage(command, args, schemaPathFromCon
14858
14858
  if (argName.includes("schema")) {
14859
14859
  await loadEnvFile({ schemaPath: argValue, printMessage: false, config: (0, import_config.defaultTestConfig)() });
14860
14860
  const datamodel = await import_fs.default.promises.readFile(argValue, "utf-8");
14861
- const config2 = await (0, import_chunk_KSJNY56L.getConfig)({ datamodel, ignoreEnvVarErrors: true });
14862
- const url = (0, import_chunk_KSJNY56L.resolveUrl)((0, import_chunk_KSJNY56L.getEffectiveUrl)(config2.datasources[0]));
14861
+ const config = await (0, import_chunk_DJYSR6QD.getConfig)({ datamodel, ignoreEnvVarErrors: true });
14862
+ const url = (0, import_chunk_DJYSR6QD.resolveUrl)((0, import_chunk_DJYSR6QD.getEffectiveUrl)(config.datasources[0]));
14863
14863
  if (url?.startsWith("prisma://")) {
14864
14864
  return forbiddenCmdWithDataProxyFlagMessage(command);
14865
14865
  }
@@ -14885,35 +14885,39 @@ async function loadSchemaContext({
14885
14885
  schemaPathFromArg,
14886
14886
  schemaPathFromConfig,
14887
14887
  printLoadMessage = true,
14888
+ ignoreEnvVarErrors = false,
14888
14889
  allowNull = false
14889
- }) {
14890
- let schemaResult2 = null;
14890
+ } = {}) {
14891
+ let schemaResult = null;
14891
14892
  if (allowNull) {
14892
- schemaResult2 = await getSchemaWithPathOptional(schemaPathFromArg, schemaPathFromConfig);
14893
- if (!schemaResult2) return null;
14893
+ schemaResult = await getSchemaWithPathOptional(schemaPathFromArg, schemaPathFromConfig);
14894
+ if (!schemaResult) return null;
14894
14895
  } else {
14895
- schemaResult2 = await getSchemaWithPath(schemaPathFromArg, schemaPathFromConfig);
14896
+ schemaResult = await getSchemaWithPath(schemaPathFromArg, schemaPathFromConfig);
14896
14897
  }
14897
- return processSchemaResult({ schemaResult: schemaResult2, printLoadMessage });
14898
+ return processSchemaResult({ schemaResult, printLoadMessage, ignoreEnvVarErrors });
14898
14899
  }
14899
14900
  async function processSchemaResult({
14900
- schemaResult: schemaResult2,
14901
- printLoadMessage
14901
+ schemaResult,
14902
+ printLoadMessage = true,
14903
+ ignoreEnvVarErrors = false
14902
14904
  }) {
14903
14905
  const cwd = process.cwd();
14904
- const loadedFromPathForLogMessages = import_path3.default.relative(cwd, schemaResult2.schemaPath);
14906
+ const loadedFromPathForLogMessages = import_path3.default.relative(cwd, schemaResult.schemaPath);
14905
14907
  if (printLoadMessage) {
14906
14908
  process.stdout.write((0, import_chunk_PG5FDKSF.dim)(`Prisma schema loaded from ${loadedFromPathForLogMessages}`) + "\n");
14907
14909
  }
14908
- const configFromPsl = await (0, import_chunk_KSJNY56L.getConfig)({ datamodel: schemaResult2.schemas });
14910
+ const configFromPsl = await (0, import_chunk_DJYSR6QD.getConfig)({ datamodel: schemaResult.schemas, ignoreEnvVarErrors });
14909
14911
  const primaryDatasource = configFromPsl.datasources.at(0);
14910
14912
  return {
14911
- schemaFiles: schemaResult2.schemas,
14912
- schemaPath: schemaResult2.schemaPath,
14913
- schemaRootDir: schemaResult2.schemaRootDir || cwd,
14913
+ schemaFiles: schemaResult.schemas,
14914
+ schemaPath: schemaResult.schemaPath,
14915
+ schemaRootDir: schemaResult.schemaRootDir || cwd,
14916
+ datasources: configFromPsl.datasources,
14914
14917
  generators: configFromPsl.generators,
14915
14918
  primaryDatasource,
14916
- primaryDatasourceDirectory: primaryDatasourceDirectory(primaryDatasource) || schemaResult2.schemaRootDir || cwd,
14919
+ primaryDatasourceDirectory: primaryDatasourceDirectory(primaryDatasource) || schemaResult.schemaRootDir || cwd,
14920
+ warnings: configFromPsl.warnings,
14917
14921
  loadedFromPathForLogMessages
14918
14922
  };
14919
14923
  }
@@ -15045,21 +15049,14 @@ async function getGenerators(options) {
15045
15049
  allowNoModels,
15046
15050
  typedSql
15047
15051
  } = options;
15048
- if (!schemaPath) {
15049
- throw new Error(`schemaPath for getGenerators got invalid value ${schemaPath}`);
15052
+ const schemaContext = !options.schemaContext && schemaPath ? await loadSchemaContext({ schemaPathFromArg: schemaPath, ignoreEnvVarErrors: true }) : options.schemaContext;
15053
+ if (!schemaContext) {
15054
+ throw new Error(`no schema provided for getGenerators`);
15050
15055
  }
15051
- let schemaResult = null;
15052
- try {
15053
- schemaResult = await getSchemaWithPath(schemaPath);
15054
- } catch (_2) {
15055
- throw new Error(`${schemaPath} does not exist`);
15056
- }
15057
- const { schemas } = schemaResult;
15058
15056
  const binaryTarget = await (0, import_get_platform.getBinaryTargetForCurrentPlatform)();
15059
15057
  const queryEngineBinaryType = (0, import_engines.getCliQueryEngineBinaryType)();
15060
15058
  const queryEngineType = (0, import_chunk_RS2R7COT.binaryTypeToEngineType)(queryEngineBinaryType);
15061
- let prismaPath = binaryPathsOverride?.[queryEngineType];
15062
- if (version && !prismaPath) {
15059
+ if (version && !binaryPathsOverride?.[queryEngineType]) {
15063
15060
  const potentialPath = eval(`require('path').join(__dirname, '..')`);
15064
15061
  if (!potentialPath.match(import_chunk_M3GBKLGE.vercelPkgPathRegex)) {
15065
15062
  const downloadParams = {
@@ -15071,35 +15068,25 @@ async function getGenerators(options) {
15071
15068
  version,
15072
15069
  skipDownload
15073
15070
  };
15074
- const binaryPathsWithEngineType = await (0, import_fetch_engine.download)(downloadParams);
15075
- prismaPath = binaryPathsWithEngineType[queryEngineBinaryType][binaryTarget];
15071
+ await (0, import_fetch_engine.download)(downloadParams);
15076
15072
  }
15077
15073
  }
15078
- const config = await (0, import_chunk_KSJNY56L.getConfig)({
15079
- datamodel: schemas,
15080
- datamodelPath: schemaPath,
15081
- prismaPath,
15082
- ignoreEnvVarErrors: true
15083
- });
15084
- if (config.datasources.length === 0) {
15074
+ if (!schemaContext.primaryDatasource) {
15085
15075
  throw new Error(import_chunk_2ZPYYZJB.missingDatasource);
15086
15076
  }
15087
- (0, import_chunk_5FJ3MENK.printConfigWarnings)(config.warnings);
15088
- const previewFeatures = (0, import_chunk_TSJICM5S.extractPreviewFeatures)(config);
15089
- const dmmf = await (0, import_chunk_AYSLETYV.getDMMF)({
15090
- datamodel: schemas,
15091
- datamodelPath: schemaPath,
15092
- prismaPath,
15077
+ (0, import_chunk_5FJ3MENK.printConfigWarnings)(schemaContext.warnings);
15078
+ const previewFeatures = (0, import_chunk_CRVLHWC5.extractPreviewFeatures)(schemaContext.generators);
15079
+ const dmmf = await (0, import_chunk_OKJT45NT.getDMMF)({
15080
+ datamodel: schemaContext.schemaFiles,
15093
15081
  previewFeatures
15094
15082
  });
15095
15083
  if (dmmf.datamodel.models.length === 0 && !allowNoModels) {
15096
- if (config.datasources.some((d2) => d2.provider === "mongodb")) {
15084
+ if (schemaContext.primaryDatasource.provider === "mongodb") {
15097
15085
  throw new Error(import_chunk_HL5VFJX4.missingModelMessageMongoDB);
15098
15086
  }
15099
15087
  throw new Error(import_chunk_HL5VFJX4.missingModelMessage);
15100
15088
  }
15101
- (0, import_chunk_IPKE37QC.checkFeatureFlags)(config, options);
15102
- const generatorConfigs = filterGenerators(overrideGenerators || config.generators, generatorNames);
15089
+ const generatorConfigs = filterGenerators(overrideGenerators || schemaContext.generators, generatorNames);
15103
15090
  await validateGenerators(generatorConfigs);
15104
15091
  const runningGenerators = [];
15105
15092
  try {
@@ -15108,7 +15095,7 @@ async function getGenerators(options) {
15108
15095
  async (generator, index2) => {
15109
15096
  let generatorPath = (0, import_chunk_IOIAK7V7.parseEnvValue)(generator.provider);
15110
15097
  let paths2;
15111
- const baseDir = import_path4.default.dirname(generator.sourceFilePath ?? schemaPath);
15098
+ const baseDir = import_path4.default.dirname(generator.sourceFilePath ?? schemaContext.schemaRootDir);
15112
15099
  const providerValue = (0, import_chunk_IOIAK7V7.parseEnvValue)(generator.provider);
15113
15100
  if (aliases && aliases[providerValue]) {
15114
15101
  generatorPath = aliases[providerValue].generatorPath;
@@ -15147,15 +15134,16 @@ The generator needs to either define the \`defaultOutput\` path in the manifest
15147
15134
  fromEnvVar: null
15148
15135
  };
15149
15136
  }
15150
- const datamodel = (0, import_chunk_T2PFJSAD.mergeSchemas)({ schemas });
15151
- const envPaths2 = await getEnvPaths(schemaPath, { cwd: generator.output.value });
15137
+ const datamodel = (0, import_chunk_GNK3AD6X.mergeSchemas)({ schemas: schemaContext.schemaFiles });
15138
+ const envPaths2 = await getEnvPaths(schemaContext.schemaPath, { cwd: generator.output.value });
15152
15139
  const options2 = {
15153
15140
  datamodel,
15154
- datasources: config.datasources,
15141
+ datasources: schemaContext.datasources,
15155
15142
  generator,
15156
15143
  dmmf,
15157
15144
  otherGenerators: skipIndex(generatorConfigs, index2),
15158
- schemaPath,
15145
+ schemaPath: schemaContext.schemaPath,
15146
+ // TODO:(schemaPath) can we get rid of schema path passing here?
15159
15147
  version: version || import_engines.enginesVersion,
15160
15148
  // this version makes no sense anymore and should be ignored
15161
15149
  postinstall,
@@ -15230,10 +15218,8 @@ generator gen {
15230
15218
  debug6({ generatorBinaryPaths });
15231
15219
  generator.setBinaryPaths(generatorBinaryPaths);
15232
15220
  if (engineVersion !== version && generator.options && generator.manifest.requiresEngines.includes(queryEngineType) && generatorBinaryPaths[queryEngineType] && generatorBinaryPaths[queryEngineType]?.[binaryTarget]) {
15233
- const customDmmf = await (0, import_chunk_AYSLETYV.getDMMF)({
15234
- datamodel: schemas,
15235
- datamodelPath: schemaPath,
15236
- prismaPath: generatorBinaryPaths[queryEngineType]?.[binaryTarget],
15221
+ const customDmmf = await (0, import_chunk_OKJT45NT.getDMMF)({
15222
+ datamodel: schemaContext.schemaFiles,
15237
15223
  previewFeatures
15238
15224
  });
15239
15225
  const options2 = { ...generator.options, dmmf: customDmmf };
@@ -15524,13 +15510,13 @@ ${(0, import_chunk_PG5FDKSF.bold)("Thanks a lot for your help! \u{1F64F}")}`);
15524
15510
  process.exit(1);
15525
15511
  }
15526
15512
  var debug7 = (0, import_debug.default)("prisma:format");
15527
- async function formatSchema({ schemas: schemas2 }, inputFormattingOptions) {
15513
+ async function formatSchema({ schemas }, inputFormattingOptions) {
15528
15514
  if (process.env.FORCE_PANIC_PRISMA_SCHEMA) {
15529
15515
  handleFormatPanic(
15530
15516
  () => {
15531
- import_chunk_RAC7G3AO.prismaSchemaWasm.debug_panic();
15517
+ import_chunk_LR3WWKZI.prismaSchemaWasm.debug_panic();
15532
15518
  },
15533
- { schemas: schemas2 }
15519
+ { schemas }
15534
15520
  );
15535
15521
  }
15536
15522
  const defaultFormattingOptions = {
@@ -15546,20 +15532,20 @@ async function formatSchema({ schemas: schemas2 }, inputFormattingOptions) {
15546
15532
  };
15547
15533
  const { formattedMultipleSchemas, lintDiagnostics } = handleFormatPanic(
15548
15534
  () => {
15549
- const formattedMultipleSchemasRaw = formatWasm(JSON.stringify(schemas2), documentFormattingParams);
15535
+ const formattedMultipleSchemasRaw = formatWasm(JSON.stringify(schemas), documentFormattingParams);
15550
15536
  const formattedMultipleSchemas2 = JSON.parse(formattedMultipleSchemasRaw);
15551
- const lintDiagnostics2 = (0, import_chunk_LOQLKDQE.lintSchema)({ schemas: formattedMultipleSchemas2 });
15537
+ const lintDiagnostics2 = (0, import_chunk_NZDLSDLM.lintSchema)({ schemas: formattedMultipleSchemas2 });
15552
15538
  return { formattedMultipleSchemas: formattedMultipleSchemas2, lintDiagnostics: lintDiagnostics2 };
15553
15539
  },
15554
- { schemas: schemas2 }
15540
+ { schemas }
15555
15541
  );
15556
- const lintWarnings = (0, import_chunk_LOQLKDQE.getLintWarningsAsText)(lintDiagnostics);
15542
+ const lintWarnings = (0, import_chunk_NZDLSDLM.getLintWarningsAsText)(lintDiagnostics);
15557
15543
  if (lintWarnings && import_chunk_MBB2KJWX.logger_exports.should.warn()) {
15558
15544
  console.warn(lintWarnings);
15559
15545
  }
15560
15546
  return Promise.resolve(formattedMultipleSchemas);
15561
15547
  }
15562
- function handleFormatPanic(tryCb, { schemas: schemas2 }) {
15548
+ function handleFormatPanic(tryCb, { schemas }) {
15563
15549
  try {
15564
15550
  return tryCb();
15565
15551
  } catch (e) {
@@ -15575,15 +15561,15 @@ function handleFormatPanic(tryCb, { schemas: schemas2 }) {
15575
15561
  "@prisma/prisma-schema-wasm format",
15576
15562
  "FMT_CLI",
15577
15563
  /* schemaPath */
15578
- (0, import_chunk_YRBRUREX.debugMultipleSchemaPaths)(schemas2),
15564
+ (0, import_chunk_YRBRUREX.debugMultipleSchemaPaths)(schemas),
15579
15565
  /* schema */
15580
- schemas2
15566
+ schemas
15581
15567
  );
15582
15568
  throw panic;
15583
15569
  }
15584
15570
  }
15585
15571
  function formatWasm(schema, documentFormattingParams) {
15586
- const formattedSchema = import_chunk_RAC7G3AO.prismaSchemaWasm.format(schema, JSON.stringify(documentFormattingParams));
15572
+ const formattedSchema = import_chunk_LR3WWKZI.prismaSchemaWasm.format(schema, JSON.stringify(documentFormattingParams));
15587
15573
  return formattedSchema;
15588
15574
  }
15589
15575
  /*! Bundled license information:
@@ -26,24 +26,23 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_AYSLETYV_exports = {};
30
- __export(chunk_AYSLETYV_exports, {
29
+ var chunk_OKJT45NT_exports = {};
30
+ __export(chunk_OKJT45NT_exports, {
31
31
  GetDmmfError: () => GetDmmfError,
32
32
  getDMMF: () => getDMMF
33
33
  });
34
- module.exports = __toCommonJS(chunk_AYSLETYV_exports);
34
+ module.exports = __toCommonJS(chunk_OKJT45NT_exports);
35
35
  var import_chunk_YRBRUREX = require("./chunk-YRBRUREX.js");
36
- var import_chunk_PSYMCJ4B = require("./chunk-PSYMCJ4B.js");
36
+ var import_chunk_CMIKSBKL = require("./chunk-CMIKSBKL.js");
37
37
  var import_chunk_ZGAIRZ32 = require("./chunk-ZGAIRZ32.js");
38
- var import_chunk_JUXIW5NS = require("./chunk-JUXIW5NS.js");
38
+ var import_chunk_OQZDUJAJ = require("./chunk-OQZDUJAJ.js");
39
39
  var import_chunk_XKZ6CBLA = require("./chunk-XKZ6CBLA.js");
40
- var import_chunk_RAC7G3AO = require("./chunk-RAC7G3AO.js");
40
+ var import_chunk_LR3WWKZI = require("./chunk-LR3WWKZI.js");
41
41
  var import_chunk_CCQRDM7X = require("./chunk-CCQRDM7X.js");
42
- var import_chunk_7MD6344A = require("./chunk-7MD6344A.js");
42
+ var import_chunk_5DBOS77Y = require("./chunk-5DBOS77Y.js");
43
43
  var import_chunk_PG5FDKSF = require("./chunk-PG5FDKSF.js");
44
44
  var import_chunk_2ESYSVXG = require("./chunk-2ESYSVXG.js");
45
45
  var import_debug = __toESM(require("@prisma/debug"));
46
- var import_fs = __toESM(require("fs"));
47
46
  var import_function = (0, import_chunk_2ESYSVXG.__toESM)((0, import_chunk_ZGAIRZ32.require_function)());
48
47
  var debug = (0, import_debug.default)("prisma:getDMMF");
49
48
  var GetDmmfError = class extends Error {
@@ -60,84 +59,56 @@ ${detailsHeader} ${message}`;
60
59
  }).exhaustive();
61
60
  const errorMessageWithContext = `${constructedErrorMessage}
62
61
  [Context: getDmmf]`;
63
- super((0, import_chunk_JUXIW5NS.addVersionDetailsToErrorMessage)(errorMessageWithContext));
62
+ super((0, import_chunk_OQZDUJAJ.addVersionDetailsToErrorMessage)(errorMessageWithContext));
64
63
  this.name = "GetDmmfError";
65
64
  }
66
65
  };
67
66
  async function getDMMF(options) {
68
- const debugErrorType = (0, import_chunk_PSYMCJ4B.createDebugErrorType)(debug, "getDmmfWasm");
67
+ const debugErrorType = (0, import_chunk_CMIKSBKL.createDebugErrorType)(debug, "getDmmfWasm");
69
68
  debug(`Using getDmmf Wasm`);
70
69
  const dmmfPipeline = (0, import_function.pipe)(
71
- (0, import_chunk_7MD6344A.tryCatch2)(
70
+ (0, import_chunk_5DBOS77Y.tryCatch)(
72
71
  () => {
73
- if (options.datamodel) {
74
- debug("Using given datamodel");
75
- return Promise.resolve(options.datamodel);
72
+ if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_DMMF) {
73
+ debug("Triggering a Rust panic...");
74
+ import_chunk_LR3WWKZI.prismaSchemaWasm.debug_panic();
76
75
  }
77
- debug(`Reading datamodel from the given datamodel path ${options.datamodelPath}`);
78
- return import_fs.default.promises.readFile(options.datamodelPath, { encoding: "utf-8" });
76
+ const params = JSON.stringify({
77
+ prismaSchema: options.datamodel,
78
+ noColor: Boolean(process.env.NO_COLOR)
79
+ });
80
+ const data = import_chunk_LR3WWKZI.prismaSchemaWasm.get_dmmf(params);
81
+ return data;
79
82
  },
80
83
  (e) => ({
81
- type: "read-datamodel-path",
82
- reason: "Error while trying to read the datamodel path",
83
- error: e,
84
- datamodelPath: options.datamodelPath
84
+ type: "wasm-error",
85
+ reason: "(get-dmmf wasm)",
86
+ error: e
85
87
  })
86
88
  ),
87
- (0, import_chunk_7MD6344A.chainW2)((datamodel) => {
88
- return (0, import_function.pipe)(
89
- (0, import_chunk_7MD6344A.tryCatch)(
90
- () => {
91
- if (process.env.FORCE_PANIC_QUERY_ENGINE_GET_DMMF) {
92
- debug("Triggering a Rust panic...");
93
- import_chunk_RAC7G3AO.prismaSchemaWasm.debug_panic();
94
- }
95
- const params = JSON.stringify({
96
- prismaSchema: datamodel,
97
- noColor: Boolean(process.env.NO_COLOR)
98
- });
99
- const data = import_chunk_RAC7G3AO.prismaSchemaWasm.get_dmmf(params);
100
- return data;
101
- },
89
+ (0, import_chunk_5DBOS77Y.map)((result) => ({ result })),
90
+ (0, import_chunk_5DBOS77Y.chainW)(
91
+ ({ result }) => (
92
+ // NOTE: this should never fail, as we expect returned values to be valid JSON-serializable strings
93
+ (0, import_chunk_5DBOS77Y.tryCatch)(
94
+ () => JSON.parse(result),
102
95
  (e) => ({
103
- type: "wasm-error",
104
- reason: "(get-dmmf wasm)",
96
+ type: "parse-json",
97
+ reason: "Unable to parse JSON",
105
98
  error: e
106
99
  })
107
- ),
108
- (0, import_chunk_7MD6344A.map)((result) => ({ result })),
109
- (0, import_chunk_7MD6344A.chainW)(
110
- ({ result }) => (
111
- // NOTE: this should never fail, as we expect returned values to be valid JSON-serializable strings
112
- (0, import_chunk_7MD6344A.tryCatch)(
113
- () => JSON.parse(result),
114
- (e) => ({
115
- type: "parse-json",
116
- reason: "Unable to parse JSON",
117
- error: e
118
- })
119
- )
120
- )
121
- ),
122
- import_chunk_7MD6344A.fromEither
123
- );
124
- })
100
+ )
101
+ )
102
+ ),
103
+ import_chunk_5DBOS77Y.fromEither
125
104
  );
126
105
  const dmmfEither = await dmmfPipeline();
127
- if ((0, import_chunk_7MD6344A.isRight)(dmmfEither)) {
106
+ if ((0, import_chunk_5DBOS77Y.isRight)(dmmfEither)) {
128
107
  debug("dmmf data retrieved without errors in getDmmf Wasm");
129
108
  const { right: data } = dmmfEither;
130
109
  return Promise.resolve(data);
131
110
  }
132
- const error = (0, import_chunk_XKZ6CBLA.z)(dmmfEither.left).with({ type: "read-datamodel-path" }, (e) => {
133
- debugErrorType(e);
134
- return new GetDmmfError({
135
- _tag: "unparsed",
136
- message: `${e.error.message}
137
- Datamodel path: "${e.datamodelPath}"`,
138
- reason: e.reason
139
- });
140
- }).with({ type: "wasm-error" }, (e) => {
111
+ const error = (0, import_chunk_XKZ6CBLA.z)(dmmfEither.left).with({ type: "wasm-error" }, (e) => {
141
112
  debugErrorType(e);
142
113
  if ((0, import_chunk_CCQRDM7X.isWasmPanic)(e.error)) {
143
114
  const { message, stack } = (0, import_chunk_CCQRDM7X.getWasmError)(e.error);
@@ -150,14 +121,14 @@ Datamodel path: "${e.datamodelPath}"`,
150
121
  "@prisma/prisma-schema-wasm get_dmmf",
151
122
  "FMT_CLI",
152
123
  /* schemaPath */
153
- options.prismaPath,
124
+ void 0,
154
125
  /* schema */
155
126
  (0, import_chunk_YRBRUREX.toMultipleSchemas)(options.datamodel)
156
127
  );
157
128
  return panic;
158
129
  }
159
130
  const errorOutput = e.error.message;
160
- return new GetDmmfError((0, import_chunk_PSYMCJ4B.parseQueryEngineError)({ errorOutput, reason: e.reason }));
131
+ return new GetDmmfError((0, import_chunk_CMIKSBKL.parseQueryEngineError)({ errorOutput, reason: e.reason }));
161
132
  }).with({ type: "parse-json" }, (e) => {
162
133
  debugErrorType(e);
163
134
  return new GetDmmfError({ _tag: "unparsed", message: e.error.message, reason: e.reason });
@@ -16,15 +16,15 @@ var __copyProps = (to, from, except, desc) => {
16
16
  return to;
17
17
  };
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var chunk_JUXIW5NS_exports = {};
20
- __export(chunk_JUXIW5NS_exports, {
19
+ var chunk_OQZDUJAJ_exports = {};
20
+ __export(chunk_OQZDUJAJ_exports, {
21
21
  addVersionDetailsToErrorMessage: () => addVersionDetailsToErrorMessage
22
22
  });
23
- module.exports = __toCommonJS(chunk_JUXIW5NS_exports);
24
- var import_chunk_MSQTBYIV = require("./chunk-MSQTBYIV.js");
23
+ module.exports = __toCommonJS(chunk_OQZDUJAJ_exports);
24
+ var import_chunk_2WQVHYBS = require("./chunk-2WQVHYBS.js");
25
25
  var import_chunk_QN6PSQY7 = require("./chunk-QN6PSQY7.js");
26
26
  function addVersionDetailsToErrorMessage(message) {
27
- const rows = [["Prisma CLI Version", import_chunk_MSQTBYIV.version]];
27
+ const rows = [["Prisma CLI Version", import_chunk_2WQVHYBS.version]];
28
28
  return `${message}
29
29
 
30
30
  ${(0, import_chunk_QN6PSQY7.formatTable)(rows)}`;