@prisma/client-generator-ts 6.6.0-dev.95 → 6.6.0-dev.97

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.
package/dist/index.js CHANGED
@@ -2170,7 +2170,6 @@ var require_lib = __commonJS({
2170
2170
  var index_exports = {};
2171
2171
  __export(index_exports, {
2172
2172
  PrismaClientTsGenerator: () => PrismaClientTsGenerator,
2173
- dmmfToTypes: () => dmmfToTypes,
2174
2173
  externalToInternalDmmf: () => externalToInternalDmmf,
2175
2174
  generateClient: () => generateClient,
2176
2175
  getDMMF: () => getDMMF
@@ -2224,10 +2223,9 @@ function getMappings(mappings, datamodel) {
2224
2223
 
2225
2224
  // src/generateClient.ts
2226
2225
  var import_promises = __toESM(require("node:fs/promises"));
2227
- var import_node_path = __toESM(require("node:path"));
2226
+ var import_node_path2 = __toESM(require("node:path"));
2228
2227
  var import_fetch_engine = require("@prisma/fetch-engine");
2229
- var import_internals10 = require("@prisma/internals");
2230
- var import_env_paths = __toESM(require("env-paths"));
2228
+ var import_internals8 = require("@prisma/internals");
2231
2229
  var import_fast_glob = require("fast-glob");
2232
2230
  var import_fs_extra = __toESM(require_lib());
2233
2231
 
@@ -2282,6 +2280,75 @@ var bgWhite = init(47, 49);
2282
2280
  // src/generateClient.ts
2283
2281
  var import_pkg_up = __toESM(require("pkg-up"));
2284
2282
 
2283
+ // src/file-extensions.ts
2284
+ var import_client_common2 = require("@prisma/client-common");
2285
+ var expectedGeneratedFileExtensions = ["ts", "mts", "cts"];
2286
+ var expectedImportFileExtensions = ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
2287
+ function validateFileExtension(extension, kind, recommended) {
2288
+ if (!recommended.includes(extension) && !process.env.PRISMA_DISABLE_WARNINGS) {
2289
+ console.warn(
2290
+ `${(0, import_client_common2.capitalize)(kind)} file extension ${JSON.stringify(
2291
+ extension
2292
+ )} is unexpected and may be a mistake. Expected one of: ${recommended.map((ext) => JSON.stringify(ext)).join(", ")}`
2293
+ );
2294
+ }
2295
+ return extension;
2296
+ }
2297
+ function parseFileExtensionFromUnknown(extension, kind, recommended) {
2298
+ if (typeof extension === "string") {
2299
+ return validateFileExtension(extension, kind, recommended);
2300
+ }
2301
+ throw new Error(`Invalid ${kind} file extension: ${JSON.stringify(extension)}, expected a string`);
2302
+ }
2303
+ function parseGeneratedFileExtension(extension) {
2304
+ return parseFileExtensionFromUnknown(extension, "generated", expectedGeneratedFileExtensions);
2305
+ }
2306
+ function parseImportFileExtension(extension) {
2307
+ return parseFileExtensionFromUnknown(extension, "import", expectedImportFileExtensions);
2308
+ }
2309
+ function extensionToSuffix(extension) {
2310
+ return extension === "" ? "" : `.${extension}`;
2311
+ }
2312
+ function generatedFileNameMapper(generatedFileExtension) {
2313
+ return (baseName) => baseName + extensionToSuffix(generatedFileExtension);
2314
+ }
2315
+ function importFileNameMapper(importFileExtension) {
2316
+ return (baseName) => baseName + extensionToSuffix(importFileExtension);
2317
+ }
2318
+ function inferImportFileExtension({
2319
+ tsconfig,
2320
+ generatedFileExtension
2321
+ }) {
2322
+ if (tsconfig) {
2323
+ return inferImportFileExtensionFromTsConfig(tsconfig, generatedFileExtension);
2324
+ }
2325
+ return generatedFileExtension;
2326
+ }
2327
+ function inferImportFileExtensionFromTsConfig(tsconfig, generatedFileExtension) {
2328
+ if (tsconfig.compilerOptions?.allowImportingTsExtensions || // @ts-expect-error `get-tsconfig` types don't yet include the new option introduced in TypeScript 5.7
2329
+ tsconfig.compilerOptions?.rewriteRelativeImportExtensions) {
2330
+ return generatedFileExtension;
2331
+ }
2332
+ const moduleResolution = tsconfig.compilerOptions?.moduleResolution?.toLowerCase();
2333
+ const module2 = tsconfig.compilerOptions?.module?.toLowerCase();
2334
+ if (moduleResolution !== void 0 && moduleResolution !== "classic" && module2 === "commonjs") {
2335
+ return "";
2336
+ }
2337
+ return matchingJsExtension(generatedFileExtension);
2338
+ }
2339
+ function matchingJsExtension(generatedFileExtension) {
2340
+ switch (generatedFileExtension) {
2341
+ case "ts":
2342
+ return "js";
2343
+ case "mts":
2344
+ return "mjs";
2345
+ case "cts":
2346
+ return "cjs";
2347
+ default:
2348
+ return generatedFileExtension;
2349
+ }
2350
+ }
2351
+
2285
2352
  // src/getDMMF.ts
2286
2353
  var import_internals = require("@prisma/internals");
2287
2354
  function getPrismaClientDMMF(dmmf) {
@@ -2293,7 +2360,7 @@ async function getDMMF(options) {
2293
2360
  }
2294
2361
 
2295
2362
  // src/TSClient/Enum.ts
2296
- var import_client_common2 = require("@prisma/client-common");
2363
+ var import_client_common3 = require("@prisma/client-common");
2297
2364
  var import_indent_string = __toESM(require("indent-string"));
2298
2365
 
2299
2366
  // src/TSClient/constants.ts
@@ -2306,49 +2373,29 @@ var Enum = class {
2306
2373
  this.useNamespace = useNamespace;
2307
2374
  }
2308
2375
  isObjectEnum() {
2309
- return this.useNamespace && import_client_common2.objectEnumNames.includes(this.type.name);
2376
+ return this.useNamespace && import_client_common3.objectEnumNames.includes(this.type.name);
2310
2377
  }
2311
2378
  isStrictEnum() {
2312
- return this.useNamespace && import_client_common2.strictEnumNames.includes(this.type.name);
2313
- }
2314
- toJS() {
2315
- const { type } = this;
2316
- const enumVariants = `{
2317
- ${(0, import_indent_string.default)(type.values.map((v) => `${v}: ${this.getValueJS(v)}`).join(",\n"), TAB_SIZE)}
2318
- }`;
2319
- const enumBody = this.isStrictEnum() ? `makeStrictEnum(${enumVariants})` : enumVariants;
2320
- return this.useNamespace ? `exports.Prisma.${type.name} = ${enumBody};` : `exports.${type.name} = exports.$Enums.${type.name} = ${enumBody};`;
2321
- }
2322
- getValueJS(value) {
2323
- return this.isObjectEnum() ? `Prisma.${value}` : `'${value}'`;
2379
+ return this.useNamespace && import_client_common3.strictEnumNames.includes(this.type.name);
2324
2380
  }
2325
2381
  toTS() {
2326
2382
  const { type } = this;
2327
- return `export const ${type.name}: {
2328
- ${(0, import_indent_string.default)(type.values.map((v) => `${v}: ${this.getValueTS(v)}`).join(",\n"), TAB_SIZE)}
2329
- };
2383
+ const enumVariants = `{
2384
+ ${(0, import_indent_string.default)(type.values.map((v) => `${v}: ${this.getValue(v)}`).join(",\n"), TAB_SIZE)}
2385
+ } as const`;
2386
+ const enumBody = this.isStrictEnum() ? `runtime.makeStrictEnum(${enumVariants})` : enumVariants;
2387
+ return `export const ${type.name} = ${enumBody}
2330
2388
 
2331
2389
  export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]
2332
2390
  `;
2333
2391
  }
2334
- getValueTS(value) {
2335
- return this.isObjectEnum() ? `typeof ${value}` : `'${value}'`;
2392
+ getValue(value) {
2393
+ return this.isObjectEnum() ? value : `'${value}'`;
2336
2394
  }
2337
2395
  };
2338
2396
 
2339
- // src/TSClient/Generable.ts
2340
- function JS(gen) {
2341
- return gen.toJS?.() ?? "";
2342
- }
2343
- function BrowserJS(gen) {
2344
- return gen.toBrowserJS?.() ?? "";
2345
- }
2346
- function TS(gen) {
2347
- return gen.toTS();
2348
- }
2349
-
2350
2397
  // src/TSClient/Input.ts
2351
- var import_client_common3 = require("@prisma/client-common");
2398
+ var import_client_common4 = require("@prisma/client-common");
2352
2399
  var ts2 = __toESM(require("@prisma/ts-builders"));
2353
2400
  var import_indent_string2 = __toESM(require("indent-string"));
2354
2401
 
@@ -2384,28 +2431,28 @@ function getOmitName(modelName) {
2384
2431
  return `${modelName}Omit`;
2385
2432
  }
2386
2433
  function getAggregateName(modelName) {
2387
- return `Aggregate${capitalize2(modelName)}`;
2434
+ return `Aggregate${capitalize3(modelName)}`;
2388
2435
  }
2389
2436
  function getGroupByName(modelName) {
2390
- return `${capitalize2(modelName)}GroupByOutputType`;
2437
+ return `${capitalize3(modelName)}GroupByOutputType`;
2391
2438
  }
2392
2439
  function getAvgAggregateName(modelName) {
2393
- return `${capitalize2(modelName)}AvgAggregateOutputType`;
2440
+ return `${capitalize3(modelName)}AvgAggregateOutputType`;
2394
2441
  }
2395
2442
  function getSumAggregateName(modelName) {
2396
- return `${capitalize2(modelName)}SumAggregateOutputType`;
2443
+ return `${capitalize3(modelName)}SumAggregateOutputType`;
2397
2444
  }
2398
2445
  function getMinAggregateName(modelName) {
2399
- return `${capitalize2(modelName)}MinAggregateOutputType`;
2446
+ return `${capitalize3(modelName)}MinAggregateOutputType`;
2400
2447
  }
2401
2448
  function getMaxAggregateName(modelName) {
2402
- return `${capitalize2(modelName)}MaxAggregateOutputType`;
2449
+ return `${capitalize3(modelName)}MaxAggregateOutputType`;
2403
2450
  }
2404
2451
  function getCountAggregateInputName(modelName) {
2405
- return `${capitalize2(modelName)}CountAggregateInputType`;
2452
+ return `${capitalize3(modelName)}CountAggregateInputType`;
2406
2453
  }
2407
2454
  function getCountAggregateOutputName(modelName) {
2408
- return `${capitalize2(modelName)}CountAggregateOutputType`;
2455
+ return `${capitalize3(modelName)}CountAggregateOutputType`;
2409
2456
  }
2410
2457
  function getAggregateInputType(aggregateOutputType) {
2411
2458
  return aggregateOutputType.replace(/OutputType$/, "InputType");
@@ -2414,13 +2461,13 @@ function getGroupByArgsName(modelName) {
2414
2461
  return `${modelName}GroupByArgs`;
2415
2462
  }
2416
2463
  function getGroupByPayloadName(modelName) {
2417
- return `Get${capitalize2(modelName)}GroupByPayload`;
2464
+ return `Get${capitalize3(modelName)}GroupByPayload`;
2418
2465
  }
2419
2466
  function getAggregateArgsName(modelName) {
2420
- return `${capitalize2(modelName)}AggregateArgs`;
2467
+ return `${capitalize3(modelName)}AggregateArgs`;
2421
2468
  }
2422
2469
  function getAggregateGetName(modelName) {
2423
- return `Get${capitalize2(modelName)}AggregateType`;
2470
+ return `Get${capitalize3(modelName)}AggregateType`;
2424
2471
  }
2425
2472
  function getFieldArgName(field, modelName) {
2426
2473
  if (field.args.length) {
@@ -2478,8 +2525,8 @@ function getModelArgName(modelName, action) {
2478
2525
  (0, import_internals2.assertNever)(action, `Unknown action: ${action}`);
2479
2526
  }
2480
2527
  }
2481
- function getPayloadName(modelName, namespace3 = true) {
2482
- if (namespace3) {
2528
+ function getPayloadName(modelName, namespace2 = true) {
2529
+ if (namespace2) {
2483
2530
  return `Prisma.${getPayloadName(modelName, false)}`;
2484
2531
  }
2485
2532
  return `$${modelName}Payload`;
@@ -2487,7 +2534,7 @@ function getPayloadName(modelName, namespace3 = true) {
2487
2534
  function getFieldRefsTypeName(name) {
2488
2535
  return `${name}FieldRefs`;
2489
2536
  }
2490
- function capitalize2(str) {
2537
+ function capitalize3(str) {
2491
2538
  return str[0].toUpperCase() + str.slice(1);
2492
2539
  }
2493
2540
  function getRefAllowedTypeName(type) {
@@ -2499,11 +2546,11 @@ function getRefAllowedTypeName(type) {
2499
2546
  }
2500
2547
  function appendSkipType(context, type) {
2501
2548
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
2502
- return ts.unionType([type, ts.namedType("$Types.Skip")]);
2549
+ return ts.unionType([type, ts.namedType("runtime.Types.Skip")]);
2503
2550
  }
2504
2551
  return type;
2505
2552
  }
2506
- var extArgsParam = ts.genericParameter("ExtArgs").extends(ts.namedType("$Extensions.InternalArgs")).default(ts.namedType("$Extensions.DefaultArgs"));
2553
+ var extArgsParam = ts.genericParameter("ExtArgs").extends(ts.namedType("runtime.Types.Extensions.InternalArgs")).default(ts.namedType("runtime.Types.Extensions.DefaultArgs"));
2507
2554
 
2508
2555
  // src/utils/common.ts
2509
2556
  function needsNamespace(field) {
@@ -2620,7 +2667,7 @@ var InputType = class {
2620
2667
  toTS() {
2621
2668
  const { type } = this;
2622
2669
  const source = type.meta?.source;
2623
- const fields = (0, import_client_common3.uniqueBy)(type.fields, (f) => f.name);
2670
+ const fields = (0, import_client_common4.uniqueBy)(type.fields, (f) => f.name);
2624
2671
  const body = `{
2625
2672
  ${(0, import_indent_string2.default)(
2626
2673
  fields.map((arg) => {
@@ -2661,11 +2708,11 @@ var import_klona = require("klona");
2661
2708
  var ts3 = __toESM(require("@prisma/ts-builders"));
2662
2709
 
2663
2710
  // src/TSClient/helpers.ts
2664
- var import_client_common5 = require("@prisma/client-common");
2711
+ var import_client_common6 = require("@prisma/client-common");
2665
2712
  var import_pluralize2 = __toESM(require("pluralize"));
2666
2713
 
2667
2714
  // src/TSClient/jsdoc.ts
2668
- var import_client_common4 = require("@prisma/client-common");
2715
+ var import_client_common5 = require("@prisma/client-common");
2669
2716
  var Docs = {
2670
2717
  cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
2671
2718
  pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
@@ -2738,7 +2785,7 @@ const ${ctx.singular} = await ${ctx.method}({
2738
2785
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
2739
2786
  @example
2740
2787
  // Create many ${ctx.plural}
2741
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2788
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2742
2789
  data: [
2743
2790
  // ... provide data here
2744
2791
  ]
@@ -2752,7 +2799,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2752
2799
  body: (ctx) => {
2753
2800
  const onlySelect = ctx.firstScalar ? `
2754
2801
  // Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
2755
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import_client_common4.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
2802
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)}With${(0, import_client_common5.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
2756
2803
  select: { ${ctx.firstScalar.name}: true },
2757
2804
  data: [
2758
2805
  // ... provide data here
@@ -2762,7 +2809,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import
2762
2809
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
2763
2810
  @example
2764
2811
  // Create many ${ctx.plural}
2765
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2812
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2766
2813
  data: [
2767
2814
  // ... provide data here
2768
2815
  ]
@@ -2780,7 +2827,7 @@ ${undefinedNote}
2780
2827
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2781
2828
  @example
2782
2829
  // Get one ${ctx.singular}
2783
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2830
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2784
2831
  where: {
2785
2832
  // ... provide filter here
2786
2833
  }
@@ -2795,7 +2842,7 @@ if no matches were found.
2795
2842
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2796
2843
  @example
2797
2844
  // Get one ${ctx.singular}
2798
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2845
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2799
2846
  where: {
2800
2847
  // ... provide filter here
2801
2848
  }
@@ -2810,7 +2857,7 @@ ${undefinedNote}
2810
2857
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2811
2858
  @example
2812
2859
  // Get one ${ctx.singular}
2813
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2860
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2814
2861
  where: {
2815
2862
  // ... provide filter here
2816
2863
  }
@@ -2831,7 +2878,7 @@ ${undefinedNote}
2831
2878
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2832
2879
  @example
2833
2880
  // Get one ${ctx.singular}
2834
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2881
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2835
2882
  where: {
2836
2883
  // ... provide filter here
2837
2884
  }
@@ -2849,7 +2896,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2849
2896
  body: (ctx) => {
2850
2897
  const onlySelect = ctx.firstScalar ? `
2851
2898
  // Only select the \`${ctx.firstScalar.name}\`
2852
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import_client_common4.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
2899
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)}With${(0, import_client_common5.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
2853
2900
  return `Find zero or more ${ctx.plural} that matches the filter.
2854
2901
  ${undefinedNote}
2855
2902
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
@@ -2875,7 +2922,7 @@ ${onlySelect}
2875
2922
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one ${ctx.singular}.
2876
2923
  @example
2877
2924
  // Update one ${ctx.singular}
2878
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2925
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2879
2926
  where: {
2880
2927
  // ... provide filter here
2881
2928
  },
@@ -2894,7 +2941,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2894
2941
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update or create a ${ctx.singular}.
2895
2942
  @example
2896
2943
  // Update or create a ${ctx.singular}
2897
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2944
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2898
2945
  create: {
2899
2946
  // ... data to create a ${ctx.singular}
2900
2947
  },
@@ -2988,7 +3035,7 @@ ${undefinedNote}
2988
3035
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one or more rows.
2989
3036
  @example
2990
3037
  // Update many ${ctx.plural}
2991
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3038
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
2992
3039
  where: {
2993
3040
  // ... provide filter here
2994
3041
  },
@@ -3007,7 +3054,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
3007
3054
  body: (ctx) => {
3008
3055
  const onlySelect = ctx.firstScalar ? `
3009
3056
  // Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
3010
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import_client_common4.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
3057
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)}With${(0, import_client_common5.capitalize)(ctx.firstScalar.name)}Only = await ${ctx.method}({
3011
3058
  select: { ${ctx.firstScalar.name}: true },
3012
3059
  where: {
3013
3060
  // ... provide filter here
@@ -3020,7 +3067,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import
3020
3067
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update many ${ctx.plural}.
3021
3068
  @example
3022
3069
  // Update many ${ctx.plural}
3023
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3070
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3024
3071
  where: {
3025
3072
  // ... provide filter here
3026
3073
  },
@@ -3058,7 +3105,7 @@ const { count } = await ${ctx.method}({
3058
3105
  body: (ctx) => `Perform aggregation operations on a ${ctx.singular}.
3059
3106
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which aggregations you would like to apply.
3060
3107
  @example
3061
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3108
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3062
3109
  pipeline: [
3063
3110
  { $match: { status: "registered" } },
3064
3111
  { $group: { _id: "$country", total: { $sum: 1 } } }
@@ -3073,7 +3120,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
3073
3120
  body: (ctx) => `Find zero or more ${ctx.plural} that matches the filter.
3074
3121
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which filters you would like to apply.
3075
3122
  @example
3076
- const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3123
+ const ${(0, import_client_common5.lowerCase)(ctx.mapping.model)} = await ${ctx.method}({
3077
3124
  filter: { age: { $gt: 25 } }
3078
3125
  })`,
3079
3126
  fields: {
@@ -3086,10 +3133,10 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
3086
3133
  // src/TSClient/helpers.ts
3087
3134
  function getMethodJSDocBody(action, mapping, model) {
3088
3135
  const ctx = {
3089
- singular: (0, import_client_common5.capitalize)(mapping.model),
3090
- plural: (0, import_client_common5.capitalize)(mapping.plural),
3136
+ singular: (0, import_client_common6.capitalize)(mapping.model),
3137
+ plural: (0, import_client_common6.capitalize)(mapping.plural),
3091
3138
  firstScalar: model.fields.find((f) => f.kind === "scalar"),
3092
- method: `prisma.${(0, import_client_common5.lowerCase)(mapping.model)}.${action}`,
3139
+ method: `prisma.${(0, import_client_common6.lowerCase)(mapping.model)}.${action}`,
3093
3140
  action,
3094
3141
  mapping,
3095
3142
  model
@@ -3131,7 +3178,6 @@ var ArgsTypeBuilder = class {
3131
3178
  ).setDocComment(ts3.docComment(`${type.name} ${action ?? "without action"}`));
3132
3179
  }
3133
3180
  moduleExport;
3134
- hasDefaultName = true;
3135
3181
  addProperty(prop) {
3136
3182
  this.moduleExport.declaration.type.add(prop);
3137
3183
  }
@@ -3181,7 +3227,6 @@ var ArgsTypeBuilder = class {
3181
3227
  return this;
3182
3228
  }
3183
3229
  setGeneratedName(name) {
3184
- this.hasDefaultName = false;
3185
3230
  this.moduleExport.declaration.setName(name);
3186
3231
  return this;
3187
3232
  }
@@ -3206,7 +3251,7 @@ var ModelFieldRefs = class {
3206
3251
  /**
3207
3252
  * Fields of the ${name} model
3208
3253
  */
3209
- interface ${getFieldRefsTypeName(name)} {
3254
+ export interface ${getFieldRefsTypeName(name)} {
3210
3255
  ${this.stringifyFields()}
3211
3256
  }
3212
3257
  `;
@@ -3281,12 +3326,12 @@ function buildOutputField(field) {
3281
3326
  }
3282
3327
  function enumTypeName(ref) {
3283
3328
  const name = ref.type;
3284
- const namespace3 = ref.namespace === "model" ? "$Enums" : "Prisma";
3285
- return `${namespace3}.${name}`;
3329
+ const namespace2 = ref.namespace === "model" ? "$Enums" : "Prisma";
3330
+ return `${namespace2}.${name}`;
3286
3331
  }
3287
3332
 
3288
3333
  // src/TSClient/Payload.ts
3289
- var import_client_common6 = require("@prisma/client-common");
3334
+ var import_client_common7 = require("@prisma/client-common");
3290
3335
  var ts5 = __toESM(require("@prisma/ts-builders"));
3291
3336
  function buildModelPayload(model, context) {
3292
3337
  const isComposite = context.dmmf.isComposite(model.name);
@@ -3304,7 +3349,7 @@ function buildModelPayload(model, context) {
3304
3349
  scalars.add(buildModelOutputProperty(field, context.dmmf));
3305
3350
  }
3306
3351
  }
3307
- const scalarsType = isComposite ? scalars : ts5.namedType("$Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts5.namedType("ExtArgs").subKey("result").subKey((0, import_client_common6.lowerCase)(model.name)));
3352
+ const scalarsType = isComposite ? scalars : ts5.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts5.namedType("ExtArgs").subKey("result").subKey((0, import_client_common7.lowerCase)(model.name)));
3308
3353
  const payloadTypeDeclaration = ts5.typeDeclaration(
3309
3354
  getPayloadName(model.name, false),
3310
3355
  ts5.objectType().add(ts5.property("name", ts5.stringLiteral(model.name))).add(ts5.property("objects", objects)).add(ts5.property("scalars", scalarsType)).add(ts5.property("composites", composites))
@@ -3316,7 +3361,7 @@ function buildModelPayload(model, context) {
3316
3361
  }
3317
3362
 
3318
3363
  // src/TSClient/SelectIncludeOmit.ts
3319
- var import_client_common7 = require("@prisma/client-common");
3364
+ var import_client_common8 = require("@prisma/client-common");
3320
3365
  var ts6 = __toESM(require("@prisma/ts-builders"));
3321
3366
  function buildIncludeType({
3322
3367
  modelName,
@@ -3333,9 +3378,9 @@ function buildOmitType({ modelName, fields, context }) {
3333
3378
  (field) => field.outputType.location === "scalar" || field.outputType.location === "enumTypes" || context.dmmf.isComposite(field.outputType.type)
3334
3379
  ).map((field) => ts6.stringLiteral(field.name))
3335
3380
  );
3336
- const omitType = ts6.namedType("$Extensions.GetOmit").addGenericArgument(keysType).addGenericArgument(modelResultExtensionsType(modelName));
3381
+ const omitType = ts6.namedType("runtime.Types.Extensions.GetOmit").addGenericArgument(keysType).addGenericArgument(modelResultExtensionsType(modelName));
3337
3382
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
3338
- omitType.addGenericArgument(ts6.namedType("$Types.Skip"));
3383
+ omitType.addGenericArgument(ts6.namedType("runtime.Types.Skip"));
3339
3384
  }
3340
3385
  return buildExport(getOmitName(modelName), omitType);
3341
3386
  }
@@ -3346,11 +3391,11 @@ function buildSelectType({
3346
3391
  context
3347
3392
  }) {
3348
3393
  const objectType9 = buildSelectOrIncludeObject(modelName, fields, context);
3349
- const selectType = ts6.namedType("$Extensions.GetSelect").addGenericArgument(objectType9).addGenericArgument(modelResultExtensionsType(modelName));
3394
+ const selectType = ts6.namedType("runtime.Types.Extensions.GetSelect").addGenericArgument(objectType9).addGenericArgument(modelResultExtensionsType(modelName));
3350
3395
  return buildExport(typeName, selectType);
3351
3396
  }
3352
3397
  function modelResultExtensionsType(modelName) {
3353
- return extArgsParam.toArgument().subKey("result").subKey((0, import_client_common7.lowerCase)(modelName));
3398
+ return extArgsParam.toArgument().subKey("result").subKey((0, import_client_common8.lowerCase)(modelName));
3354
3399
  }
3355
3400
  function buildScalarSelectType({ modelName, fields, context }) {
3356
3401
  const object = buildSelectOrIncludeObject(
@@ -3398,6 +3443,18 @@ function getModelActions(dmmf, name) {
3398
3443
  return mappingKeys;
3399
3444
  }
3400
3445
 
3446
+ // src/TSClient/utils/type-builders.ts
3447
+ var import_ts_builders = require("@prisma/ts-builders");
3448
+ function promise(resultType) {
3449
+ return new import_ts_builders.NamedType("runtime.Types.Utils.JsPromise").addGenericArgument(resultType);
3450
+ }
3451
+ function prismaPromise(resultType) {
3452
+ return new import_ts_builders.NamedType("Prisma.PrismaPromise").addGenericArgument(resultType);
3453
+ }
3454
+ function optional(innerType) {
3455
+ return new import_ts_builders.NamedType("runtime.Types.Utils.Optional").addGenericArgument(innerType);
3456
+ }
3457
+
3401
3458
  // src/TSClient/Model.ts
3402
3459
  var Model = class {
3403
3460
  constructor(model, context) {
@@ -3487,7 +3544,7 @@ var Model = class {
3487
3544
  return `
3488
3545
 
3489
3546
 
3490
- export type ${groupByArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3547
+ export type ${groupByArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3491
3548
  ${(0, import_indent_string3.default)(
3492
3549
  groupByRootField.args.map((arg) => {
3493
3550
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.groupBy, arg) };
@@ -3580,7 +3637,7 @@ ${aggregateTypes.length > 1 ? aggregateTypes.slice(1).map((type) => {
3580
3637
  return new InputType(newType, this.context).toTS();
3581
3638
  }).join("\n") : ""}
3582
3639
 
3583
- export type ${aggregateArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3640
+ export type ${aggregateArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3584
3641
  ${(0, import_indent_string3.default)(
3585
3642
  aggregateRootField.args.map((arg) => {
3586
3643
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.aggregate, arg) };
@@ -3619,7 +3676,7 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
3619
3676
  const modelTypeExport = ts7.moduleExport(
3620
3677
  ts7.typeDeclaration(
3621
3678
  model.name,
3622
- ts7.namedType(`$Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3679
+ ts7.namedType(`runtime.Types.Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3623
3680
  )
3624
3681
  ).setDocComment(ts7.docComment(docs));
3625
3682
  return ts7.stringify(modelTypeExport);
@@ -3697,9 +3754,9 @@ ${omitType}${includeType}${createManyAndReturnIncludeType}${updateManyAndReturnI
3697
3754
 
3698
3755
  ${ts7.stringify(buildModelPayload(this.model, this.context), { newLine: "none" })}
3699
3756
 
3700
- type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3757
+ export type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3701
3758
  model.name
3702
- )}> = $Result.GetResult<${getPayloadName(model.name)}, S>
3759
+ )}> = runtime.Types.Result.GetResult<${getPayloadName(model.name)}, S>
3703
3760
 
3704
3761
  ${isComposite ? "" : new ModelDelegate(this.type, this.context).toTS()}
3705
3762
 
@@ -3743,7 +3800,7 @@ var ModelDelegate = class {
3743
3800
  excludedArgsForCount.push("relationLoadStrategy");
3744
3801
  }
3745
3802
  const excludedArgsForCountType = excludedArgsForCount.map((name2) => `'${name2}'`).join(" | ");
3746
- return `${availableActions.includes(DMMF2.ModelAction.aggregate) ? `type ${countArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> =
3803
+ return `${availableActions.includes(DMMF2.ModelAction.aggregate) ? `export type ${countArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> =
3747
3804
  Omit<${getModelArgName(name, DMMF2.ModelAction.findMany)}, ${excludedArgsForCountType}> & {
3748
3805
  select?: ${getCountAggregateInputName(name)} | true
3749
3806
  }
@@ -3759,7 +3816,7 @@ ${availableActions.includes(DMMF2.ModelAction.aggregate) ? `${(0, import_indent_
3759
3816
  count<T extends ${countArgsName}>(
3760
3817
  args?: Subset<T, ${countArgsName}>,
3761
3818
  ): Prisma.PrismaPromise<
3762
- T extends $Utils.Record<'select', any>
3819
+ T extends runtime.Types.Utils.Record<'select', any>
3763
3820
  ? T['select'] extends true
3764
3821
  ? number
3765
3822
  : GetScalarType<T['select'], ${getCountAggregateOutputName(name)}>
@@ -3890,16 +3947,16 @@ function getReturnType({
3890
3947
  isNullable = false
3891
3948
  }) {
3892
3949
  if (actionName === DMMF2.ModelAction.count) {
3893
- return ts7.promise(ts7.numberType);
3950
+ return promise(ts7.numberType);
3894
3951
  }
3895
3952
  if (actionName === DMMF2.ModelAction.aggregate) {
3896
- return ts7.promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3953
+ return promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3897
3954
  }
3898
3955
  if (actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
3899
- return ts7.prismaPromise(ts7.namedType("JsonObject"));
3956
+ return prismaPromise(ts7.namedType("JsonObject"));
3900
3957
  }
3901
3958
  if (actionName === DMMF2.ModelAction.deleteMany || actionName === DMMF2.ModelAction.updateMany || actionName === DMMF2.ModelAction.createMany) {
3902
- return ts7.prismaPromise(ts7.namedType("BatchPayload"));
3959
+ return prismaPromise(ts7.namedType("BatchPayload"));
3903
3960
  }
3904
3961
  const isList = actionName === DMMF2.ModelAction.findMany || actionName === DMMF2.ModelAction.createManyAndReturn || actionName === DMMF2.ModelAction.updateManyAndReturn;
3905
3962
  if (isList) {
@@ -3907,7 +3964,7 @@ function getReturnType({
3907
3964
  if (isChaining) {
3908
3965
  result = ts7.unionType(result).addVariant(ts7.namedType("Null"));
3909
3966
  }
3910
- return ts7.prismaPromise(result);
3967
+ return prismaPromise(result);
3911
3968
  }
3912
3969
  if (isChaining && actionName === DMMF2.ModelAction.findUniqueOrThrow) {
3913
3970
  const nullType7 = isNullable ? ts7.nullType : ts7.namedType("Null");
@@ -3924,11 +3981,11 @@ function getFluentWrapper(modelName, resultType, nullType7 = ts7.neverType) {
3924
3981
  return ts7.namedType(fluentWrapperName(modelName)).addGenericArgument(resultType).addGenericArgument(nullType7).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(ts7.namedType("GlobalOmitOptions"));
3925
3982
  }
3926
3983
  function getResultType(modelName, actionName) {
3927
- return ts7.namedType("$Result.GetResult").addGenericArgument(ts7.namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument())).addGenericArgument(ts7.namedType("T")).addGenericArgument(ts7.stringLiteral(actionName)).addGenericArgument(ts7.namedType("GlobalOmitOptions"));
3984
+ return ts7.namedType("runtime.Types.Result.GetResult").addGenericArgument(ts7.namedType(getPayloadName(modelName)).addGenericArgument(extArgsParam.toArgument())).addGenericArgument(ts7.namedType("T")).addGenericArgument(ts7.stringLiteral(actionName)).addGenericArgument(ts7.namedType("GlobalOmitOptions"));
3928
3985
  }
3929
3986
  function buildFluentWrapperDefinition(modelName, outputType, context) {
3930
3987
  const definition = ts7.interfaceDeclaration(fluentWrapperName(modelName));
3931
- definition.addGenericParameter(ts7.genericParameter("T")).addGenericParameter(ts7.genericParameter("Null").default(ts7.neverType)).addGenericParameter(extArgsParam).addGenericParameter(ts7.genericParameter("GlobalOmitOptions").default(ts7.objectType())).extends(ts7.prismaPromise(ts7.namedType("T")));
3988
+ definition.addGenericParameter(ts7.genericParameter("T")).addGenericParameter(ts7.genericParameter("Null").default(ts7.neverType)).addGenericParameter(extArgsParam).addGenericParameter(ts7.genericParameter("GlobalOmitOptions").default(ts7.objectType())).extends(prismaPromise(ts7.namedType("T")));
3932
3989
  definition.add(ts7.property(ts7.toStringTag, ts7.stringLiteral("PrismaPromise")).readonly());
3933
3990
  definition.addMultiple(
3934
3991
  outputType.fields.filter(
@@ -3954,7 +4011,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3954
4011
  @param onrejected The callback to execute when the Promise is rejected.
3955
4012
  @returns A Promise for the completion of which ever callback is executed.
3956
4013
  `
3957
- ).addGenericParameter(ts7.genericParameter("TResult1").default(ts7.namedType("T"))).addGenericParameter(ts7.genericParameter("TResult2").default(ts7.neverType)).addParameter(promiseCallback("onfulfilled", ts7.parameter("value", ts7.namedType("T")), ts7.namedType("TResult1"))).addParameter(promiseCallback("onrejected", ts7.parameter("reason", ts7.anyType), ts7.namedType("TResult2"))).setReturnType(ts7.promise(ts7.unionType([ts7.namedType("TResult1"), ts7.namedType("TResult2")])))
4014
+ ).addGenericParameter(ts7.genericParameter("TResult1").default(ts7.namedType("T"))).addGenericParameter(ts7.genericParameter("TResult2").default(ts7.neverType)).addParameter(promiseCallback("onfulfilled", ts7.parameter("value", ts7.namedType("T")), ts7.namedType("TResult1"))).addParameter(promiseCallback("onrejected", ts7.parameter("reason", ts7.anyType), ts7.namedType("TResult2"))).setReturnType(promise(ts7.unionType([ts7.namedType("TResult1"), ts7.namedType("TResult2")])))
3958
4015
  );
3959
4016
  definition.add(
3960
4017
  ts7.method("catch").setDocComment(
@@ -3963,7 +4020,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3963
4020
  @param onrejected The callback to execute when the Promise is rejected.
3964
4021
  @returns A Promise for the completion of the callback.
3965
4022
  `
3966
- ).addGenericParameter(ts7.genericParameter("TResult").default(ts7.neverType)).addParameter(promiseCallback("onrejected", ts7.parameter("reason", ts7.anyType), ts7.namedType("TResult"))).setReturnType(ts7.promise(ts7.unionType([ts7.namedType("T"), ts7.namedType("TResult")])))
4023
+ ).addGenericParameter(ts7.genericParameter("TResult").default(ts7.neverType)).addParameter(promiseCallback("onrejected", ts7.parameter("reason", ts7.anyType), ts7.namedType("TResult"))).setReturnType(promise(ts7.unionType([ts7.namedType("T"), ts7.namedType("TResult")])))
3967
4024
  );
3968
4025
  definition.add(
3969
4026
  ts7.method("finally").setDocComment(
@@ -3975,7 +4032,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3975
4032
  `
3976
4033
  ).addParameter(
3977
4034
  ts7.parameter("onfinally", ts7.unionType([ts7.functionType(), ts7.undefinedType, ts7.nullType])).optional()
3978
- ).setReturnType(ts7.promise(ts7.namedType("T")))
4035
+ ).setReturnType(promise(ts7.namedType("T")))
3979
4036
  );
3980
4037
  return ts7.moduleExport(definition).setDocComment(ts7.docComment`
3981
4038
  The delegate class that acts as a "Promise-like" for ${modelName}.
@@ -4005,16 +4062,16 @@ function fluentWrapperName(modelName) {
4005
4062
  }
4006
4063
 
4007
4064
  // src/TSClient/TSClient.ts
4065
+ var import_node_crypto = __toESM(require("node:crypto"));
4066
+ var import_node_path = __toESM(require("node:path"));
4008
4067
  var import_dmmf = require("@prisma/dmmf");
4009
- var import_internals7 = require("@prisma/internals");
4068
+ var import_internals6 = require("@prisma/internals");
4010
4069
  var ts12 = __toESM(require("@prisma/ts-builders"));
4011
4070
  var import_ci_info = __toESM(require("ci-info"));
4012
- var import_crypto = __toESM(require("crypto"));
4013
- var import_indent_string8 = __toESM(require("indent-string"));
4014
- var import_path2 = __toESM(require("path"));
4071
+ var import_indent_string7 = __toESM(require("indent-string"));
4015
4072
 
4016
4073
  // src/dmmf.ts
4017
- var import_client_common8 = require("@prisma/client-common");
4074
+ var import_client_common9 = require("@prisma/client-common");
4018
4075
  var DMMFHelper = class {
4019
4076
  constructor(document) {
4020
4077
  this.document = document;
@@ -4067,8 +4124,8 @@ var DMMFHelper = class {
4067
4124
  Object.values(this.mappings.otherOperations.read)
4068
4125
  ].flat();
4069
4126
  }
4070
- hasEnumInNamespace(enumName, namespace3) {
4071
- return this.schema.enumTypes[namespace3]?.find((schemaEnum) => schemaEnum.name === enumName) !== void 0;
4127
+ hasEnumInNamespace(enumName, namespace2) {
4128
+ return this.schema.enumTypes[namespace2]?.find((schemaEnum) => schemaEnum.name === enumName) !== void 0;
4072
4129
  }
4073
4130
  resolveInputObjectType(ref) {
4074
4131
  return this.inputTypesByName.get(fullyQualifiedName(ref.type, ref.namespace));
@@ -4080,33 +4137,33 @@ var DMMFHelper = class {
4080
4137
  return this.outputObjectTypes[ref.namespace ?? "prisma"].find((outputObject) => outputObject.name === ref.type);
4081
4138
  }
4082
4139
  buildModelMap() {
4083
- return (0, import_client_common8.keyBy)(this.datamodel.models, "name");
4140
+ return (0, import_client_common9.keyBy)(this.datamodel.models, "name");
4084
4141
  }
4085
4142
  buildTypeMap() {
4086
- return (0, import_client_common8.keyBy)(this.datamodel.types, "name");
4143
+ return (0, import_client_common9.keyBy)(this.datamodel.types, "name");
4087
4144
  }
4088
4145
  buildTypeModelMap() {
4089
4146
  return { ...this.buildTypeMap(), ...this.buildModelMap() };
4090
4147
  }
4091
4148
  buildMappingsMap() {
4092
- return (0, import_client_common8.keyBy)(this.mappings.modelOperations, "model");
4149
+ return (0, import_client_common9.keyBy)(this.mappings.modelOperations, "model");
4093
4150
  }
4094
4151
  buildMergedOutputTypeMap() {
4095
4152
  if (!this.schema.outputObjectTypes.prisma) {
4096
4153
  return {
4097
- model: (0, import_client_common8.keyBy)(this.schema.outputObjectTypes.model, "name"),
4098
- prisma: (0, import_client_common8.keyBy)([], "name")
4154
+ model: (0, import_client_common9.keyBy)(this.schema.outputObjectTypes.model, "name"),
4155
+ prisma: (0, import_client_common9.keyBy)([], "name")
4099
4156
  };
4100
4157
  }
4101
4158
  return {
4102
- model: (0, import_client_common8.keyBy)(this.schema.outputObjectTypes.model, "name"),
4103
- prisma: (0, import_client_common8.keyBy)(this.schema.outputObjectTypes.prisma, "name")
4159
+ model: (0, import_client_common9.keyBy)(this.schema.outputObjectTypes.model, "name"),
4160
+ prisma: (0, import_client_common9.keyBy)(this.schema.outputObjectTypes.prisma, "name")
4104
4161
  };
4105
4162
  }
4106
4163
  buildRootFieldMap() {
4107
4164
  return {
4108
- ...(0, import_client_common8.keyBy)(this.outputTypeMap.prisma.Query.fields, "name"),
4109
- ...(0, import_client_common8.keyBy)(this.outputTypeMap.prisma.Mutation.fields, "name")
4165
+ ...(0, import_client_common9.keyBy)(this.outputTypeMap.prisma.Query.fields, "name"),
4166
+ ...(0, import_client_common9.keyBy)(this.outputTypeMap.prisma.Mutation.fields, "name")
4110
4167
  };
4111
4168
  }
4112
4169
  buildInputTypesMap() {
@@ -4123,20 +4180,20 @@ var DMMFHelper = class {
4123
4180
  return result;
4124
4181
  }
4125
4182
  };
4126
- function fullyQualifiedName(typeName, namespace3) {
4127
- if (namespace3) {
4128
- return `${namespace3}.${typeName}`;
4183
+ function fullyQualifiedName(typeName, namespace2) {
4184
+ if (namespace2) {
4185
+ return `${namespace2}.${typeName}`;
4129
4186
  }
4130
4187
  return typeName;
4131
4188
  }
4132
4189
 
4133
4190
  // src/GenericsArgsInfo.ts
4134
- var import_client_common9 = require("@prisma/client-common");
4191
+ var import_client_common10 = require("@prisma/client-common");
4135
4192
  var GenericArgsInfo = class {
4136
4193
  constructor(_dmmf) {
4137
4194
  this._dmmf = _dmmf;
4138
4195
  }
4139
- _cache = new import_client_common9.Cache();
4196
+ _cache = new import_client_common10.Cache();
4140
4197
  /**
4141
4198
  * Determines if arg types need generic <$PrismaModel> argument added.
4142
4199
  * Essentially, performs breadth-first search for any fieldRefTypes that
@@ -4245,113 +4302,90 @@ function buildDebugInitialization(edge) {
4245
4302
  }
4246
4303
  const debugVar = getRuntimeEdgeEnvVar("DEBUG");
4247
4304
  return `if (${debugVar}) {
4248
- Debug.enable(${debugVar})
4305
+ runtime.Debug.enable(${debugVar})
4249
4306
  }
4250
4307
  `;
4251
4308
  }
4252
4309
 
4253
4310
  // src/utils/buildDirname.ts
4254
- var import_internals4 = require("@prisma/internals");
4255
- function buildDirname(edge, relativeOutdir) {
4311
+ function buildDirname(edge) {
4256
4312
  if (edge === true) {
4257
- return buildDirnameDefault();
4313
+ return `config.dirname = '/'`;
4258
4314
  }
4259
- return buildDirnameFind(relativeOutdir);
4260
- }
4261
- function buildDirnameFind(relativeOutdir) {
4262
- return `
4263
- const fs = require('fs')
4264
-
4265
- config.dirname = __dirname
4266
- if (!fs.existsSync(path.join(__dirname, 'schema.prisma'))) {
4267
- const alternativePaths = [
4268
- ${JSON.stringify((0, import_internals4.pathToPosix)(relativeOutdir))},
4269
- ${JSON.stringify((0, import_internals4.pathToPosix)(relativeOutdir).split("/").slice(1).join("/"))},
4270
- ]
4271
-
4272
- const alternativePath = alternativePaths.find((altPath) => {
4273
- return fs.existsSync(path.join(process.cwd(), altPath, 'schema.prisma'))
4274
- }) ?? alternativePaths[0]
4275
-
4276
- config.dirname = path.join(process.cwd(), alternativePath)
4277
- config.isBundled = true
4278
- }`;
4279
- }
4280
- function buildDirnameDefault() {
4281
- return `config.dirname = '/'`;
4315
+ return `config.dirname = __dirname`;
4282
4316
  }
4283
4317
 
4284
4318
  // src/utils/buildDMMF.ts
4285
- var import_client_common10 = require("@prisma/client-common");
4319
+ var import_client_common11 = require("@prisma/client-common");
4286
4320
  function buildRuntimeDataModel(datamodel, runtimeName) {
4287
- const runtimeDataModel = (0, import_client_common10.dmmfToRuntimeDataModel)(datamodel);
4321
+ const runtimeDataModel = (0, import_client_common11.dmmfToRuntimeDataModel)(datamodel);
4288
4322
  let prunedDataModel;
4289
4323
  if (runtimeName === "wasm" || runtimeName === "client") {
4290
- prunedDataModel = (0, import_client_common10.pruneRuntimeDataModel)(runtimeDataModel);
4324
+ prunedDataModel = (0, import_client_common11.pruneRuntimeDataModel)(runtimeDataModel);
4291
4325
  } else {
4292
4326
  prunedDataModel = runtimeDataModel;
4293
4327
  }
4294
4328
  const datamodelString = escapeJson(JSON.stringify(prunedDataModel));
4295
4329
  return `
4296
- config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})
4297
- defineDmmfProperty(exports.Prisma, config.runtimeDataModel)`;
4330
+ config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})`;
4298
4331
  }
4299
4332
 
4300
- // src/utils/buildGetQueryCompilerWasmModule.ts
4301
- function buildQueryCompilerWasmModule(wasm, copyCompiler, runtimeName) {
4302
- if (copyCompiler && runtimeName === "client") {
4303
- return `config.compilerWasm = {
4304
- getRuntime: () => require('./query_compiler_bg.js'),
4305
- getQueryCompilerWasmModule: async () => {
4306
- const queryCompilerWasmFilePath = require('path').join(config.dirname, 'query_compiler_bg.wasm')
4307
- const queryCompilerWasmFileBytes = require('fs').readFileSync(queryCompilerWasmFilePath)
4308
-
4309
- return new WebAssembly.Module(queryCompilerWasmFileBytes)
4310
- }
4311
- }`;
4312
- }
4313
- if (copyCompiler && runtimeName === "client" && wasm === true) {
4314
- return `config.compilerWasm = {
4315
- getRuntime: () => require('./query_compiler_bg.js'),
4316
- getQueryCompilerWasmModule: async () => {
4317
- const loader = (await import('#wasm-compiler-loader')).default
4318
- const compiler = (await loader).default
4319
- return compiler
4333
+ // src/utils/buildGetWasmModule.ts
4334
+ var import_client_common12 = require("@prisma/client-common");
4335
+ var import_ts_pattern = require("ts-pattern");
4336
+ function buildGetWasmModule({
4337
+ component,
4338
+ runtimeName,
4339
+ runtimeBase,
4340
+ target,
4341
+ activeProvider,
4342
+ moduleFormat
4343
+ }) {
4344
+ const capitalizedComponent = (0, import_client_common12.capitalize)(component);
4345
+ const wasmPathBase = `${runtimeBase}/query_compiler_bg.${activeProvider}`;
4346
+ const wasmBindingsPath = `${wasmPathBase}.mjs`;
4347
+ const wasmModulePath = `${wasmPathBase}.wasm`;
4348
+ const buildNodeLoader = (0, import_ts_pattern.match)(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
4349
+ const buildEdgeLoader = runtimeName === "wasm" && component === "engine";
4350
+ if (buildNodeLoader) {
4351
+ return `config.${component}Wasm = {
4352
+ getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
4353
+
4354
+ getQuery${capitalizedComponent}WasmModule: async () => {
4355
+ const { readFile } = await import('node:fs/promises')
4356
+ ${buildRequire(moduleFormat)}
4357
+ const wasmModulePath = require.resolve(${JSON.stringify(wasmModulePath)})
4358
+ const wasmModuleBytes = await readFile(wasmModulePath)
4359
+
4360
+ return new globalThis.WebAssembly.Module(wasmModuleBytes)
4320
4361
  }
4321
4362
  }`;
4322
4363
  }
4323
- return `config.compilerWasm = undefined`;
4324
- }
4364
+ if (buildEdgeLoader) {
4365
+ const fullWasmModulePath = target === "edge-light" ? `${wasmModulePath}?module` : wasmModulePath;
4366
+ return `config.${component}Wasm = {
4367
+ getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
4325
4368
 
4326
- // src/utils/buildGetQueryEngineWasmModule.ts
4327
- function buildQueryEngineWasmModule(wasm, copyEngine, runtimeName) {
4328
- if (copyEngine && runtimeName === "library" && process.env.PRISMA_CLIENT_FORCE_WASM) {
4329
- return `config.engineWasm = {
4330
- getRuntime: () => require('./query_engine_bg.js'),
4331
- getQueryEngineWasmModule: async () => {
4332
- const queryEngineWasmFilePath = require('path').join(config.dirname, 'query_engine_bg.wasm')
4333
- const queryEngineWasmFileBytes = require('fs').readFileSync(queryEngineWasmFilePath)
4334
-
4335
- return new WebAssembly.Module(queryEngineWasmFileBytes)
4336
- }
4337
- }`;
4338
- }
4339
- if (copyEngine && wasm === true) {
4340
- return `config.engineWasm = {
4341
- getRuntime: () => require('./query_engine_bg.js'),
4342
- getQueryEngineWasmModule: async () => {
4343
- const loader = (await import('#wasm-engine-loader')).default
4344
- const engine = (await loader).default
4345
- return engine
4369
+ getQuery${capitalizedComponent}WasmModule: async () => {
4370
+ const { default: module } = await import(${JSON.stringify(fullWasmModulePath)})
4371
+ return module
4346
4372
  }
4347
4373
  }`;
4348
4374
  }
4349
- return `config.engineWasm = undefined`;
4375
+ return `config.${component}Wasm = undefined`;
4376
+ }
4377
+ function buildRequire(moduleFormat) {
4378
+ if (moduleFormat === "cjs") {
4379
+ return "";
4380
+ }
4381
+ return `const { createRequire } = await import('node:module')
4382
+ const require = createRequire(import.meta.url)
4383
+ `;
4350
4384
  }
4351
4385
 
4352
4386
  // src/utils/buildNFTAnnotations.ts
4353
4387
  var import_get_platform = require("@prisma/get-platform");
4354
- var import_internals5 = require("@prisma/internals");
4388
+ var import_internals4 = require("@prisma/internals");
4355
4389
  var import_path = __toESM(require("path"));
4356
4390
  function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir) {
4357
4391
  if (noEngine === true) return "";
@@ -4360,7 +4394,7 @@ function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir
4360
4394
  }
4361
4395
  if (process.env.NETLIFY) {
4362
4396
  const isNodeMajor20OrUp = parseInt(process.versions.node.split(".")[0]) >= 20;
4363
- const awsRuntimeVersion = (0, import_internals5.parseAWSNodejsRuntimeEnvVarVersion)();
4397
+ const awsRuntimeVersion = (0, import_internals4.parseAWSNodejsRuntimeEnvVarVersion)();
4364
4398
  const isRuntimeEnvVar20OrUp = awsRuntimeVersion && awsRuntimeVersion >= 20;
4365
4399
  const isRuntimeEnvVar18OrDown = awsRuntimeVersion && awsRuntimeVersion <= 18;
4366
4400
  if ((isNodeMajor20OrUp || isRuntimeEnvVar20OrUp) && !isRuntimeEnvVar18OrDown) {
@@ -4377,10 +4411,10 @@ function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir
4377
4411
  return `${engineAnnotations}${schemaAnnotations}`;
4378
4412
  }
4379
4413
  function getQueryEngineFilename(engineType, binaryTarget) {
4380
- if (engineType === import_internals5.ClientEngineType.Library) {
4414
+ if (engineType === import_internals4.ClientEngineType.Library) {
4381
4415
  return (0, import_get_platform.getNodeAPIName)(binaryTarget, "fs");
4382
4416
  }
4383
- if (engineType === import_internals5.ClientEngineType.Binary) {
4417
+ if (engineType === import_internals4.ClientEngineType.Binary) {
4384
4418
  return `query-engine-${binaryTarget}`;
4385
4419
  }
4386
4420
  return void 0;
@@ -4389,207 +4423,70 @@ function buildNFTAnnotation(fileName, relativeOutdir) {
4389
4423
  const relativeFilePath = import_path.default.join(relativeOutdir, fileName);
4390
4424
  return `
4391
4425
  // file annotations for bundling tools to include these files
4392
- path.join(__dirname, ${JSON.stringify((0, import_internals5.pathToPosix)(fileName))});
4393
- path.join(process.cwd(), ${JSON.stringify((0, import_internals5.pathToPosix)(relativeFilePath))})`;
4394
- }
4395
-
4396
- // src/utils/buildRequirePath.ts
4397
- function buildRequirePath(edge) {
4398
- if (edge === true) return "";
4399
- return `
4400
- const path = require('path')`;
4401
- }
4402
-
4403
- // src/utils/buildWarnEnvConflicts.ts
4404
- function buildWarnEnvConflicts(edge, runtimeBase, runtimeName) {
4405
- if (edge === true) return "";
4406
- return `
4407
- const { warnEnvConflicts } = require('${runtimeBase}/${runtimeName}')
4408
-
4409
- warnEnvConflicts({
4410
- rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.rootEnvPath),
4411
- schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.schemaEnvPath)
4412
- })`;
4426
+ path.join(__dirname, ${JSON.stringify((0, import_internals4.pathToPosix)(fileName))})
4427
+ path.join(process.cwd(), ${JSON.stringify((0, import_internals4.pathToPosix)(relativeFilePath))})`;
4413
4428
  }
4414
4429
 
4415
4430
  // src/TSClient/common.ts
4416
- var import_indent_string4 = __toESM(require("indent-string"));
4417
- var commonCodeJS = ({
4431
+ var commonCodeTS = ({
4418
4432
  runtimeBase,
4419
4433
  runtimeName,
4420
- browser,
4421
4434
  clientVersion,
4422
4435
  engineVersion,
4423
4436
  generator,
4424
- deno
4425
- }) => `${deno ? "const exports = {}" : ""}
4426
- Object.defineProperty(exports, "__esModule", { value: true });
4427
- ${deno ? `
4428
- import {
4429
- PrismaClientKnownRequestError,
4430
- PrismaClientUnknownRequestError,
4431
- PrismaClientRustPanicError,
4432
- PrismaClientInitializationError,
4433
- PrismaClientValidationError,
4434
- getPrismaClient,
4435
- sqltag,
4436
- empty,
4437
- join,
4438
- raw,
4439
- Decimal,
4440
- Debug,
4441
- objectEnumValues,
4442
- makeStrictEnum,
4443
- Extensions,
4444
- defineDmmfProperty,
4445
- Public,
4446
- getRuntime,
4447
- skip
4448
- } from '${runtimeBase}/${runtimeName}'` : browser ? `
4449
- const {
4450
- Decimal,
4451
- objectEnumValues,
4452
- makeStrictEnum,
4453
- Public,
4454
- getRuntime,
4455
- skip
4456
- } = require('${runtimeBase}/${runtimeName}')
4457
- ` : `
4458
- const {
4459
- PrismaClientKnownRequestError,
4460
- PrismaClientUnknownRequestError,
4461
- PrismaClientRustPanicError,
4462
- PrismaClientInitializationError,
4463
- PrismaClientValidationError,
4464
- getPrismaClient,
4465
- sqltag,
4466
- empty,
4467
- join,
4468
- raw,
4469
- skip,
4470
- Decimal,
4471
- Debug,
4472
- objectEnumValues,
4473
- makeStrictEnum,
4474
- Extensions,
4475
- warnOnce,
4476
- defineDmmfProperty,
4477
- Public,
4478
- getRuntime,
4479
- createParam,
4480
- } = require('${runtimeBase}/${runtimeName}')
4481
- `}
4482
-
4483
- const Prisma = {}
4484
-
4485
- exports.Prisma = Prisma
4486
- exports.$Enums = {}
4437
+ moduleFormat,
4438
+ edge
4439
+ }) => ({
4440
+ tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}'
4441
+ ${buildPreamble(edge, moduleFormat)}
4487
4442
 
4488
- /**
4489
- * Prisma Client JS version: ${clientVersion}
4490
- * Query Engine version: ${engineVersion}
4491
- */
4492
- Prisma.prismaVersion = {
4493
- client: "${clientVersion}",
4494
- engine: "${engineVersion}"
4495
- }
4443
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4444
+ `,
4445
+ ts: () => `export type DMMF = typeof runtime.DMMF
4496
4446
 
4497
- Prisma.PrismaClientKnownRequestError = ${notSupportOnBrowser("PrismaClientKnownRequestError", browser)};
4498
- Prisma.PrismaClientUnknownRequestError = ${notSupportOnBrowser("PrismaClientUnknownRequestError", browser)}
4499
- Prisma.PrismaClientRustPanicError = ${notSupportOnBrowser("PrismaClientRustPanicError", browser)}
4500
- Prisma.PrismaClientInitializationError = ${notSupportOnBrowser("PrismaClientInitializationError", browser)}
4501
- Prisma.PrismaClientValidationError = ${notSupportOnBrowser("PrismaClientValidationError", browser)}
4502
- Prisma.Decimal = Decimal
4447
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4503
4448
 
4504
4449
  /**
4505
- * Re-export of sql-template-tag
4450
+ * Validator
4506
4451
  */
4507
- Prisma.sql = ${notSupportOnBrowser("sqltag", browser)}
4508
- Prisma.empty = ${notSupportOnBrowser("empty", browser)}
4509
- Prisma.join = ${notSupportOnBrowser("join", browser)}
4510
- Prisma.raw = ${notSupportOnBrowser("raw", browser)}
4511
- Prisma.validator = Public.validator
4452
+ export const validator = runtime.Public.validator
4512
4453
 
4513
4454
  /**
4514
- * Extensions
4515
- */
4516
- Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
4517
- Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
4518
-
4519
- /**
4520
- * Shorthand utilities for JSON filtering
4455
+ * Prisma Errors
4521
4456
  */
4522
- Prisma.DbNull = objectEnumValues.instances.DbNull
4523
- Prisma.JsonNull = objectEnumValues.instances.JsonNull
4524
- Prisma.AnyNull = objectEnumValues.instances.AnyNull
4525
4457
 
4526
- Prisma.NullTypes = {
4527
- DbNull: objectEnumValues.classes.DbNull,
4528
- JsonNull: objectEnumValues.classes.JsonNull,
4529
- AnyNull: objectEnumValues.classes.AnyNull
4530
- }
4458
+ export const PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4459
+ export type PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4531
4460
 
4532
- ${buildPrismaSkipJs(generator.previewFeatures)}
4533
- `;
4534
- var notSupportOnBrowser = (fnc, browser) => {
4535
- if (browser) {
4536
- return `() => {
4537
- const runtimeName = getRuntime().prettyName;
4538
- throw new Error(\`${fnc} is unable to run in this browser environment, or has been bundled for the browser (running in \${runtimeName}).
4539
- In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report\`,
4540
- )}`;
4541
- }
4542
- return fnc;
4543
- };
4544
- var commonCodeTS = ({
4545
- runtimeBase,
4546
- runtimeName,
4547
- clientVersion,
4548
- engineVersion,
4549
- generator
4550
- }) => ({
4551
- tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}';
4552
- import $Types = runtime.Types // general types
4553
- import $Public = runtime.Types.Public
4554
- import $Utils = runtime.Types.Utils
4555
- import $Extensions = runtime.Types.Extensions
4556
- import $Result = runtime.Types.Result
4557
-
4558
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4559
- `,
4560
- ts: () => `export import DMMF = runtime.DMMF
4461
+ export const PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4462
+ export type PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4561
4463
 
4562
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4464
+ export const PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4465
+ export type PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4563
4466
 
4564
- /**
4565
- * Validator
4566
- */
4567
- export import validator = runtime.Public.validator
4467
+ export const PrismaClientInitializationError = runtime.PrismaClientInitializationError
4468
+ export type PrismaClientInitializationError = runtime.PrismaClientInitializationError
4568
4469
 
4569
- /**
4570
- * Prisma Errors
4571
- */
4572
- export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4573
- export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4574
- export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4575
- export import PrismaClientInitializationError = runtime.PrismaClientInitializationError
4576
- export import PrismaClientValidationError = runtime.PrismaClientValidationError
4470
+ export const PrismaClientValidationError = runtime.PrismaClientValidationError
4471
+ export type PrismaClientValidationError = runtime.PrismaClientValidationError
4577
4472
 
4578
4473
  /**
4579
4474
  * Re-export of sql-template-tag
4580
4475
  */
4581
- export import sql = runtime.sqltag
4582
- export import empty = runtime.empty
4583
- export import join = runtime.join
4584
- export import raw = runtime.raw
4585
- export import Sql = runtime.Sql
4476
+ export const sql = runtime.sqltag
4477
+ export const empty = runtime.empty
4478
+ export const join = runtime.join
4479
+ export const raw = runtime.raw
4480
+ export const Sql = runtime.Sql
4481
+ export type Sql = runtime.Sql
4586
4482
 
4587
4483
  ${buildPrismaSkipTs(generator.previewFeatures)}
4588
4484
 
4589
4485
  /**
4590
4486
  * Decimal.js
4591
4487
  */
4592
- export import Decimal = runtime.Decimal
4488
+ export const Decimal = runtime.Decimal
4489
+ export type Decimal = runtime.Decimal
4593
4490
 
4594
4491
  export type DecimalJsLike = runtime.DecimalJsLike
4595
4492
 
@@ -4604,46 +4501,43 @@ export type MetricHistogramBucket = runtime.MetricHistogramBucket
4604
4501
  /**
4605
4502
  * Extensions
4606
4503
  */
4607
- export import Extension = $Extensions.UserArgs
4608
- export import getExtensionContext = runtime.Extensions.getExtensionContext
4609
- export import Args = $Public.Args
4610
- export import Payload = $Public.Payload
4611
- export import Result = $Public.Result
4612
- export import Exact = $Public.Exact
4504
+ export type Extension = runtime.Types.Extensions.UserArgs
4505
+ export const getExtensionContext = runtime.Extensions.getExtensionContext
4506
+ export type Args<T, F extends runtime.Operation> = runtime.Types.Public.Args<T, F>
4507
+ export type Payload<T, F extends runtime.Operation = never> = runtime.Types.Public.Payload<T, F>
4508
+ export type Result<T, A, F extends runtime.Operation> = runtime.Types.Public.Result<T, A, F>
4509
+ export type Exact<A, W> = runtime.Types.Public.Exact<A, W>
4510
+
4511
+ export type PrismaVersion = {
4512
+ client: string
4513
+ engine: string
4514
+ }
4613
4515
 
4614
4516
  /**
4615
4517
  * Prisma Client JS version: ${clientVersion}
4616
4518
  * Query Engine version: ${engineVersion}
4617
4519
  */
4618
- export type PrismaVersion = {
4619
- client: string
4520
+ export const prismaVersion: PrismaVersion = {
4521
+ client: "${clientVersion}",
4522
+ engine: "${engineVersion}"
4620
4523
  }
4621
4524
 
4622
- export const prismaVersion: PrismaVersion
4623
-
4624
4525
  /**
4625
4526
  * Utility Types
4626
4527
  */
4627
4528
 
4628
4529
 
4629
- export import JsonObject = runtime.JsonObject
4630
- export import JsonArray = runtime.JsonArray
4631
- export import JsonValue = runtime.JsonValue
4632
- export import InputJsonObject = runtime.InputJsonObject
4633
- export import InputJsonArray = runtime.InputJsonArray
4634
- export import InputJsonValue = runtime.InputJsonValue
4635
-
4636
- /**
4637
- * Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
4638
- *
4639
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4640
- */
4641
- namespace NullTypes {
4642
- ${buildNullClass("DbNull")}
4643
-
4644
- ${buildNullClass("JsonNull")}
4530
+ export type JsonObject = runtime.JsonObject
4531
+ export type JsonArray = runtime.JsonArray
4532
+ export type JsonValue = runtime.JsonValue
4533
+ export type InputJsonObject = runtime.InputJsonObject
4534
+ export type InputJsonArray = runtime.InputJsonArray
4535
+ export type InputJsonValue = runtime.InputJsonValue
4645
4536
 
4646
- ${buildNullClass("AnyNull")}
4537
+ export const NullTypes = {
4538
+ DbNull: runtime.objectEnumValues.classes.DbNull as (new (secret: never) => typeof runtime.objectEnumValues.instances.DbNull),
4539
+ JsonNull: runtime.objectEnumValues.classes.JsonNull as (new (secret: never) => typeof runtime.objectEnumValues.instances.JsonNull),
4540
+ AnyNull: runtime.objectEnumValues.classes.AnyNull as (new (secret: never) => typeof runtime.objectEnumValues.instances.AnyNull),
4647
4541
  }
4648
4542
 
4649
4543
  /**
@@ -4651,21 +4545,21 @@ ${buildNullClass("AnyNull")}
4651
4545
  *
4652
4546
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4653
4547
  */
4654
- export const DbNull: NullTypes.DbNull
4548
+ export const DbNull = runtime.objectEnumValues.instances.DbNull
4655
4549
 
4656
4550
  /**
4657
4551
  * Helper for filtering JSON entries that have JSON \`null\` values (not empty on the db)
4658
4552
  *
4659
4553
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4660
4554
  */
4661
- export const JsonNull: NullTypes.JsonNull
4555
+ export const JsonNull = runtime.objectEnumValues.instances.JsonNull
4662
4556
 
4663
4557
  /**
4664
4558
  * Helper for filtering JSON entries that are \`Prisma.DbNull\` or \`Prisma.JsonNull\`
4665
4559
  *
4666
4560
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4667
4561
  */
4668
- export const AnyNull: NullTypes.AnyNull
4562
+ export const AnyNull = runtime.objectEnumValues.instances.AnyNull
4669
4563
 
4670
4564
  type SelectAndInclude = {
4671
4565
  select: any
@@ -4677,16 +4571,6 @@ type SelectAndOmit = {
4677
4571
  omit: any
4678
4572
  }
4679
4573
 
4680
- /**
4681
- * Get the type of the value, that the Promise holds.
4682
- */
4683
- export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T;
4684
-
4685
- /**
4686
- * Get the return type of a function which returns a Promise.
4687
- */
4688
- export type PromiseReturnType<T extends (...args: any) => $Utils.JsPromise<any>> = PromiseType<ReturnType<T>>
4689
-
4690
4574
  /**
4691
4575
  * From T, pick a set of properties whose keys are in the union K
4692
4576
  */
@@ -4694,19 +4578,8 @@ type Prisma__Pick<T, K extends keyof T> = {
4694
4578
  [P in K]: T[P];
4695
4579
  };
4696
4580
 
4697
-
4698
4581
  export type Enumerable<T> = T | Array<T>;
4699
4582
 
4700
- export type RequiredKeys<T> = {
4701
- [K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K
4702
- }[keyof T]
4703
-
4704
- export type TruthyKeys<T> = keyof {
4705
- [K in keyof T as T[K] extends false | undefined | null ? never : K]: K
4706
- }
4707
-
4708
- export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>
4709
-
4710
4583
  /**
4711
4584
  * Subset
4712
4585
  * @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection
@@ -4823,7 +4696,6 @@ type _Merge<U extends object> = IntersectOf<Overwrite<U, {
4823
4696
  }>>;
4824
4697
 
4825
4698
  type Key = string | number | symbol;
4826
- type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never;
4827
4699
  type AtStrict<O extends object, K extends Key> = O[K & keyof O];
4828
4700
  type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
4829
4701
  export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
@@ -4847,7 +4719,7 @@ type _Record<K extends keyof any, T> = {
4847
4719
  type NoExpand<T> = T extends unknown ? T : never;
4848
4720
 
4849
4721
  // this type assumes the passed object is entirely optional
4850
- type AtLeast<O extends object, K extends string> = NoExpand<
4722
+ export type AtLeast<O extends object, K extends string> = NoExpand<
4851
4723
  O extends unknown
4852
4724
  ? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
4853
4725
  | {[P in keyof O as P extends K ? P : never]-?: O[P]} & O
@@ -4860,19 +4732,10 @@ export type Strict<U extends object> = ComputeRaw<_Strict<U>>;
4860
4732
 
4861
4733
  export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
4862
4734
 
4863
- /**
4864
- A [[Boolean]]
4865
- */
4866
4735
  export type Boolean = True | False
4867
4736
 
4868
- // /**
4869
- // 1
4870
- // */
4871
4737
  export type True = 1
4872
4738
 
4873
- /**
4874
- 0
4875
- */
4876
4739
  export type False = 0
4877
4740
 
4878
4741
  export type Not<B extends Boolean> = {
@@ -4903,16 +4766,6 @@ export type Or<B1 extends Boolean, B2 extends Boolean> = {
4903
4766
 
4904
4767
  export type Keys<U extends Union> = U extends unknown ? keyof U : never
4905
4768
 
4906
- type Cast<A, B> = A extends B ? A : B;
4907
-
4908
- export const type: unique symbol;
4909
-
4910
-
4911
-
4912
- /**
4913
- * Used by group by
4914
- */
4915
-
4916
4769
  export type GetScalarType<T, O> = O extends object ? {
4917
4770
  [P in keyof T]: P extends keyof O
4918
4771
  ? O[P]
@@ -4964,43 +4817,36 @@ type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRe
4964
4817
 
4965
4818
  `
4966
4819
  });
4967
- function buildNullClass(name) {
4968
- const source = `/**
4969
- * Type of \`Prisma.${name}\`.
4970
- *
4971
- * You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
4972
- *
4973
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4974
- */
4975
- class ${name} {
4976
- private ${name}: never
4977
- private constructor()
4978
- }`;
4979
- return (0, import_indent_string4.default)(source, TAB_SIZE);
4980
- }
4981
4820
  function buildPrismaSkipTs(previewFeatures) {
4982
4821
  if (previewFeatures.includes("strictUndefinedChecks")) {
4983
4822
  return `
4984
4823
  /**
4985
4824
  * Prisma.skip
4986
4825
  */
4987
- export import skip = runtime.skip
4826
+ export const skip = runtime.skip
4988
4827
  `;
4989
4828
  }
4990
4829
  return "";
4991
4830
  }
4992
- function buildPrismaSkipJs(previewFeatures) {
4993
- if (previewFeatures.includes("strictUndefinedChecks")) {
4994
- return `
4995
- Prisma.skip = skip
4831
+ function buildPreamble(edge, moduleFormat) {
4832
+ if (edge) {
4833
+ return "";
4834
+ }
4835
+ let preamble = `import * as process from 'node:process'
4836
+ import * as path from 'node:path'
4837
+ `;
4838
+ if (moduleFormat === "esm") {
4839
+ preamble += ` import { fileURLToPath } from 'node:url'
4840
+
4841
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
4996
4842
  `;
4997
4843
  }
4998
- return "";
4844
+ return preamble;
4999
4845
  }
5000
4846
 
5001
4847
  // src/TSClient/Count.ts
5002
4848
  var ts8 = __toESM(require("@prisma/ts-builders"));
5003
- var import_indent_string5 = __toESM(require("indent-string"));
4849
+ var import_indent_string4 = __toESM(require("indent-string"));
5004
4850
  var Count = class {
5005
4851
  constructor(type, context) {
5006
4852
  this.type = type;
@@ -5031,8 +4877,10 @@ var Count = class {
5031
4877
 
5032
4878
  ${ts8.stringify(outputType)}
5033
4879
 
5034
- export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
5035
- ${(0, import_indent_string5.default)(
4880
+ export type ${getSelectName(
4881
+ name
4882
+ )}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
4883
+ ${(0, import_indent_string4.default)(
5036
4884
  type.fields.map((field) => {
5037
4885
  const types = ["boolean"];
5038
4886
  if (field.outputType.location === "outputObjectTypes") {
@@ -5053,7 +4901,7 @@ ${this.argsTypes.map((typeExport) => ts8.stringify(typeExport)).join("\n\n")}
5053
4901
  }
5054
4902
  };
5055
4903
  function getCountArgsType(typeName, fieldName) {
5056
- return `${typeName}Count${capitalize2(fieldName)}Args`;
4904
+ return `${typeName}Count${capitalize3(fieldName)}Args`;
5057
4905
  }
5058
4906
 
5059
4907
  // src/TSClient/FieldRefInput.ts
@@ -5091,10 +4939,10 @@ var GenerateContext = class {
5091
4939
  };
5092
4940
 
5093
4941
  // src/TSClient/PrismaClient.ts
5094
- var import_client_common12 = require("@prisma/client-common");
5095
- var import_internals6 = require("@prisma/internals");
4942
+ var import_client_common14 = require("@prisma/client-common");
4943
+ var import_internals5 = require("@prisma/internals");
5096
4944
  var ts11 = __toESM(require("@prisma/ts-builders"));
5097
- var import_indent_string7 = __toESM(require("indent-string"));
4945
+ var import_indent_string6 = __toESM(require("indent-string"));
5098
4946
 
5099
4947
  // src/utils/runtimeImport.ts
5100
4948
  var ts9 = __toESM(require("@prisma/ts-builders"));
@@ -5106,7 +4954,7 @@ function runtimeImportedType(name) {
5106
4954
  }
5107
4955
 
5108
4956
  // src/TSClient/Datasources.ts
5109
- var import_indent_string6 = __toESM(require("indent-string"));
4957
+ var import_indent_string5 = __toESM(require("indent-string"));
5110
4958
  var Datasources = class {
5111
4959
  constructor(internalDatasources) {
5112
4960
  this.internalDatasources = internalDatasources;
@@ -5114,19 +4962,19 @@ var Datasources = class {
5114
4962
  toTS() {
5115
4963
  const sources = this.internalDatasources;
5116
4964
  return `export type Datasources = {
5117
- ${(0, import_indent_string6.default)(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
4965
+ ${(0, import_indent_string5.default)(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
5118
4966
  }`;
5119
4967
  }
5120
4968
  };
5121
4969
 
5122
4970
  // src/TSClient/globalOmit.ts
5123
- var import_client_common11 = require("@prisma/client-common");
4971
+ var import_client_common13 = require("@prisma/client-common");
5124
4972
  var ts10 = __toESM(require("@prisma/ts-builders"));
5125
4973
  function globalOmitConfig(dmmf) {
5126
4974
  const objectType9 = ts10.objectType().addMultiple(
5127
4975
  dmmf.datamodel.models.map((model) => {
5128
4976
  const type = ts10.namedType(getOmitName(model.name));
5129
- return ts10.property((0, import_client_common11.lowerCase)(model.name), type).optional();
4977
+ return ts10.property((0, import_client_common13.lowerCase)(model.name), type).optional();
5130
4978
  })
5131
4979
  );
5132
4980
  return ts10.moduleExport(ts10.typeDeclaration("GlobalOmitConfig", objectType9));
@@ -5139,7 +4987,7 @@ function clientTypeMapModelsDefinition(context) {
5139
4987
  if (modelNames.length === 0) {
5140
4988
  meta.add(ts11.property("modelProps", ts11.neverType));
5141
4989
  } else {
5142
- meta.add(ts11.property("modelProps", ts11.unionType(modelNames.map((name) => ts11.stringLiteral((0, import_client_common12.lowerCase)(name))))));
4990
+ meta.add(ts11.property("modelProps", ts11.unionType(modelNames.map((name) => ts11.stringLiteral((0, import_client_common14.lowerCase)(name))))));
5143
4991
  }
5144
4992
  const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? ts11.namedType("Prisma.TransactionIsolationLevel") : ts11.neverType;
5145
4993
  meta.add(ts11.property("txIsolationLevel", isolationLevel));
@@ -5170,9 +5018,9 @@ function clientTypeMapModelsDefinition(context) {
5170
5018
  }
5171
5019
  function clientTypeMapModelsResultDefinition(modelName, action) {
5172
5020
  if (action === "count")
5173
- return ts11.unionType([ts11.optional(ts11.namedType(getCountAggregateOutputName(modelName))), ts11.numberType]);
5174
- if (action === "groupBy") return ts11.array(ts11.optional(ts11.namedType(getGroupByName(modelName))));
5175
- if (action === "aggregate") return ts11.optional(ts11.namedType(getAggregateName(modelName)));
5021
+ return ts11.unionType([optional(ts11.namedType(getCountAggregateOutputName(modelName))), ts11.numberType]);
5022
+ if (action === "groupBy") return ts11.array(optional(ts11.namedType(getGroupByName(modelName))));
5023
+ if (action === "aggregate") return optional(ts11.namedType(getAggregateName(modelName)));
5176
5024
  if (action === "findRaw") return ts11.namedType("JsonObject");
5177
5025
  if (action === "aggregateRaw") return ts11.namedType("JsonObject");
5178
5026
  if (action === "deleteMany") return ts11.namedType("BatchPayload");
@@ -5189,10 +5037,10 @@ function clientTypeMapModelsResultDefinition(modelName, action) {
5189
5037
  if (action === "update") return payloadToResult(modelName);
5190
5038
  if (action === "upsert") return payloadToResult(modelName);
5191
5039
  if (action === "delete") return payloadToResult(modelName);
5192
- (0, import_internals6.assertNever)(action, `Unknown action: ${action}`);
5040
+ (0, import_internals5.assertNever)(action, `Unknown action: ${action}`);
5193
5041
  }
5194
5042
  function payloadToResult(modelName) {
5195
- return ts11.namedType("$Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5043
+ return ts11.namedType("runtime.Types.Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5196
5044
  }
5197
5045
  function clientTypeMapOthersDefinition(context) {
5198
5046
  const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
@@ -5230,25 +5078,26 @@ function clientTypeMapOthersDefinition(context) {
5230
5078
  function clientTypeMapDefinition(context) {
5231
5079
  const typeMap = `${ts11.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
5232
5080
  return `
5233
- interface TypeMapCb<ClientOptions = {}> extends $Utils.Fn<{extArgs: $Extensions.InternalArgs }, $Utils.Record<string, any>> {
5081
+ export interface TypeMapCb<ClientOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
5234
5082
  returns: Prisma.TypeMap<this['params']['extArgs'], ClientOptions extends { omit: infer OmitOptions } ? OmitOptions : {}>
5235
5083
  }
5236
5084
 
5237
- export type TypeMap<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
5085
+ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
5238
5086
  }
5239
5087
  function clientExtensionsDefinitions(context) {
5240
5088
  const typeMap = clientTypeMapDefinition(context);
5241
5089
  const define = ts11.moduleExport(
5242
- ts11.constDeclaration(
5243
- "defineExtension",
5244
- ts11.namedType("$Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("define")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb")).addGenericArgument(ts11.namedType("$Extensions.DefaultArgs"))
5090
+ ts11.constDeclaration("defineExtension").setValue(
5091
+ ts11.namedValue("runtime.Extensions.defineExtension").as(ts11.namedType("unknown")).as(
5092
+ ts11.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("define")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb")).addGenericArgument(ts11.namedType("runtime.Types.Extensions.DefaultArgs"))
5093
+ )
5245
5094
  )
5246
5095
  );
5247
5096
  return [typeMap, ts11.stringify(define)].join("\n");
5248
5097
  }
5249
5098
  function extendsPropertyDefinition() {
5250
- const extendsDefinition = ts11.namedType("$Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("extends")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.namedType("ExtArgs")).addGenericArgument(
5251
- ts11.namedType("$Utils.Call").addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.objectType().add(ts11.property("extArgs", ts11.namedType("ExtArgs"))))
5099
+ const extendsDefinition = ts11.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("extends")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.namedType("ExtArgs")).addGenericArgument(
5100
+ ts11.namedType("runtime.Types.Utils.Call").addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.objectType().add(ts11.property("extArgs", ts11.namedType("ExtArgs"))))
5252
5101
  );
5253
5102
  return ts11.stringify(ts11.property("$extends", extendsDefinition), { indentLevel: 1 });
5254
5103
  }
@@ -5267,7 +5116,7 @@ function batchingTransactionDefinition(context) {
5267
5116
 
5268
5117
  Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
5269
5118
  `
5270
- ).addGenericParameter(ts11.genericParameter("P").extends(ts11.array(ts11.prismaPromise(ts11.anyType)))).addParameter(ts11.parameter("arg", ts11.arraySpread(ts11.namedType("P")))).setReturnType(ts11.promise(ts11.namedType("runtime.Types.Utils.UnwrapTuple").addGenericArgument(ts11.namedType("P"))));
5119
+ ).addGenericParameter(ts11.genericParameter("P").extends(ts11.array(prismaPromise(ts11.anyType)))).addParameter(ts11.parameter("arg", ts11.arraySpread(ts11.namedType("P")))).setReturnType(promise(ts11.namedType("runtime.Types.Utils.UnwrapTuple").addGenericArgument(ts11.namedType("P"))));
5271
5120
  if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
5272
5121
  const options = ts11.objectType().formatInline().add(ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional());
5273
5122
  method3.addParameter(ts11.parameter("options", options).optional());
@@ -5280,7 +5129,7 @@ function interactiveTransactionDefinition(context) {
5280
5129
  const isolationLevel = ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional();
5281
5130
  options.add(isolationLevel);
5282
5131
  }
5283
- const returnType = ts11.promise(ts11.namedType("R"));
5132
+ const returnType = promise(ts11.namedType("R"));
5284
5133
  const callbackType = ts11.functionType().addParameter(
5285
5134
  ts11.parameter("prisma", ts11.omit(ts11.namedType("PrismaClient"), ts11.namedType("runtime.ITXClientDenyList")))
5286
5135
  ).setReturnType(returnType);
@@ -5366,7 +5215,7 @@ function queryRawTypedDefinition(context) {
5366
5215
  "typedSql",
5367
5216
  runtimeImportedType("TypedSql").addGenericArgument(ts11.array(ts11.unknownType)).addGenericArgument(param.toArgument())
5368
5217
  )
5369
- ).setReturnType(ts11.prismaPromise(ts11.array(param.toArgument())));
5218
+ ).setReturnType(prismaPromise(ts11.array(param.toArgument())));
5370
5219
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5371
5220
  }
5372
5221
  function metricDefinition(context) {
@@ -5391,7 +5240,7 @@ function runCommandRawDefinition(context) {
5391
5240
  if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
5392
5241
  return "";
5393
5242
  }
5394
- const method3 = ts11.method("$runCommandRaw").addParameter(ts11.parameter("command", ts11.namedType("Prisma.InputJsonObject"))).setReturnType(ts11.prismaPromise(ts11.namedType("Prisma.JsonObject"))).setDocComment(ts11.docComment`
5243
+ const method3 = ts11.method("$runCommandRaw").addParameter(ts11.parameter("command", ts11.namedType("Prisma.InputJsonObject"))).setReturnType(prismaPromise(ts11.namedType("Prisma.JsonObject"))).setDocComment(ts11.docComment`
5395
5244
  Executes a raw MongoDB command and returns the result of it.
5396
5245
  @example
5397
5246
  \`\`\`
@@ -5410,25 +5259,24 @@ function applyPendingMigrationsDefinition() {
5410
5259
  if (this.runtimeName !== "react-native") {
5411
5260
  return null;
5412
5261
  }
5413
- const method3 = ts11.method("$applyPendingMigrations").setReturnType(ts11.promise(ts11.voidType)).setDocComment(
5262
+ const method3 = ts11.method("$applyPendingMigrations").setReturnType(promise(ts11.voidType)).setDocComment(
5414
5263
  ts11.docComment`Tries to apply pending migrations one by one. If a migration fails to apply, the function will stop and throw an error. You are responsible for informing the user and possibly blocking the app as we cannot guarantee the state of the database.`
5415
5264
  );
5416
5265
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5417
5266
  }
5418
5267
  function eventRegistrationMethodDeclaration(runtimeName) {
5419
5268
  if (runtimeName === "binary") {
5420
- return `$on<V extends (U | 'beforeExit')>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : V extends 'beforeExit' ? () => $Utils.JsPromise<void> : Prisma.LogEvent) => void): PrismaClient;`;
5269
+ return `$on<V extends (U | 'beforeExit')>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : V extends 'beforeExit' ? () => runtime.Types.Utils.JsPromise<void> : Prisma.LogEvent) => void): PrismaClient;`;
5421
5270
  } else {
5422
5271
  return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
5423
5272
  }
5424
5273
  }
5425
5274
  var PrismaClientClass = class {
5426
- constructor(context, internalDatasources, outputDir, runtimeName, browser) {
5275
+ constructor(context, internalDatasources, outputDir, runtimeName) {
5427
5276
  this.context = context;
5428
5277
  this.internalDatasources = internalDatasources;
5429
5278
  this.outputDir = outputDir;
5430
5279
  this.runtimeName = runtimeName;
5431
- this.browser = browser;
5432
5280
  }
5433
5281
  get jsDoc() {
5434
5282
  const { dmmf } = this.context;
@@ -5442,44 +5290,49 @@ var PrismaClientClass = class {
5442
5290
  };
5443
5291
  }
5444
5292
  return `/**
5445
- * ## Prisma Client \u02B2\u02E2
5293
+ * ## Prisma Client
5446
5294
  *
5447
- * Type-safe database client for TypeScript & Node.js
5295
+ * Type-safe database client for TypeScript
5448
5296
  * @example
5449
5297
  * \`\`\`
5450
5298
  * const prisma = new PrismaClient()
5451
- * // Fetch zero or more ${capitalize2(example.plural)}
5452
- * const ${(0, import_client_common12.lowerCase)(example.plural)} = await prisma.${(0, import_client_common12.lowerCase)(example.model)}.findMany()
5299
+ * // Fetch zero or more ${capitalize3(example.plural)}
5300
+ * const ${(0, import_client_common14.lowerCase)(example.plural)} = await prisma.${(0, import_client_common14.lowerCase)(example.model)}.findMany()
5453
5301
  * \`\`\`
5454
5302
  *
5455
- *
5456
5303
  * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
5457
5304
  */`;
5458
5305
  }
5459
5306
  toTSWithoutNamespace() {
5460
5307
  const { dmmf } = this.context;
5461
- return `${this.jsDoc}
5462
- export class PrismaClient<
5308
+ return `interface PrismaClientConstructor {
5309
+ ${(0, import_indent_string6.default)(this.jsDoc, TAB_SIZE)}
5310
+ new <
5311
+ ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
5312
+ U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
5313
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
5314
+ >(options?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>): PrismaClient<ClientOptions, U, ExtArgs>
5315
+ }
5316
+
5317
+ ${this.jsDoc}
5318
+ export interface PrismaClient<
5463
5319
  ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
5464
5320
  U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
5465
- ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
5321
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
5466
5322
  > {
5467
5323
  [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
5468
5324
 
5469
- ${(0, import_indent_string7.default)(this.jsDoc, TAB_SIZE)}
5470
-
5471
- constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
5472
5325
  ${eventRegistrationMethodDeclaration(this.runtimeName)}
5473
5326
 
5474
5327
  /**
5475
5328
  * Connect with the database
5476
5329
  */
5477
- $connect(): $Utils.JsPromise<void>;
5330
+ $connect(): runtime.Types.Utils.JsPromise<void>;
5478
5331
 
5479
5332
  /**
5480
5333
  * Disconnect from the database
5481
5334
  */
5482
- $disconnect(): $Utils.JsPromise<void>;
5335
+ $disconnect(): runtime.Types.Utils.JsPromise<void>;
5483
5336
 
5484
5337
  /**
5485
5338
  * Add a middleware
@@ -5500,9 +5353,9 @@ ${[
5500
5353
  extendsPropertyDefinition()
5501
5354
  ].filter((d) => d !== null).join("\n").trim()}
5502
5355
 
5503
- ${(0, import_indent_string7.default)(
5356
+ ${(0, import_indent_string6.default)(
5504
5357
  dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
5505
- let methodName = (0, import_client_common12.lowerCase)(m.model);
5358
+ let methodName = (0, import_client_common14.lowerCase)(m.model);
5506
5359
  if (methodName === "constructor") {
5507
5360
  methodName = '["constructor"]';
5508
5361
  }
@@ -5511,15 +5364,17 @@ ${[
5511
5364
  * \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
5512
5365
  * Example usage:
5513
5366
  * \`\`\`ts
5514
- * // Fetch zero or more ${capitalize2(m.plural)}
5515
- * const ${(0, import_client_common12.lowerCase)(m.plural)} = await prisma.${methodName}.findMany()
5367
+ * // Fetch zero or more ${capitalize3(m.plural)}
5368
+ * const ${(0, import_client_common14.lowerCase)(m.plural)} = await prisma.${methodName}.findMany()
5516
5369
  * \`\`\`
5517
5370
  */
5518
5371
  get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
5519
5372
  }).join("\n\n"),
5520
5373
  2
5521
5374
  )}
5522
- }`;
5375
+ }
5376
+
5377
+ export const PrismaClient = runtime.getPrismaClient(config) as unknown as PrismaClientConstructor`;
5523
5378
  }
5524
5379
  toTS() {
5525
5380
  const clientOptions = this.buildClientOptions();
@@ -5597,11 +5452,8 @@ export type MiddlewareParams = {
5597
5452
  */
5598
5453
  export type Middleware<T = any> = (
5599
5454
  params: MiddlewareParams,
5600
- next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
5601
- ) => $Utils.JsPromise<T>
5602
-
5603
- // tested in getLogLevel.test.ts
5604
- export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
5455
+ next: (params: MiddlewareParams) => runtime.Types.Utils.JsPromise<T>,
5456
+ ) => runtime.Types.Utils.JsPromise<T>
5605
5457
 
5606
5458
  /**
5607
5459
  * \`PrismaClient\` proxy available in interactive transactions.
@@ -5681,10 +5533,9 @@ var TSClient = class {
5681
5533
  }
5682
5534
  dmmf;
5683
5535
  genericsInfo;
5684
- toJS() {
5536
+ toTS() {
5685
5537
  const {
5686
5538
  edge,
5687
- wasm,
5688
5539
  binaryPaths,
5689
5540
  generator,
5690
5541
  outputDir,
@@ -5692,23 +5543,19 @@ var TSClient = class {
5692
5543
  runtimeBase,
5693
5544
  runtimeName,
5694
5545
  datasources,
5695
- deno,
5696
5546
  copyEngine = true,
5697
- envPaths
5547
+ target,
5548
+ activeProvider,
5549
+ moduleFormat
5698
5550
  } = this.options;
5699
- const relativeEnvPaths = {
5700
- rootEnvPath: envPaths.rootEnvPath && (0, import_internals7.pathToPosix)(import_path2.default.relative(outputDir, envPaths.rootEnvPath)),
5701
- schemaEnvPath: envPaths.schemaEnvPath && (0, import_internals7.pathToPosix)(import_path2.default.relative(outputDir, envPaths.schemaEnvPath))
5702
- };
5703
- const clientEngineType = (0, import_internals7.getClientEngineType)(generator);
5551
+ const clientEngineType = (0, import_internals6.getClientEngineType)(generator);
5704
5552
  generator.config.engineType = clientEngineType;
5705
- const binaryTargets = clientEngineType === import_internals7.ClientEngineType.Library ? Object.keys(binaryPaths.libqueryEngine ?? {}) : Object.keys(binaryPaths.queryEngine ?? {});
5706
- const inlineSchemaHash = import_crypto.default.createHash("sha256").update(Buffer.from(inlineSchema, "utf8").toString("base64")).digest("hex");
5553
+ const binaryTargets = clientEngineType === import_internals6.ClientEngineType.Library ? Object.keys(binaryPaths.libqueryEngine ?? {}) : Object.keys(binaryPaths.queryEngine ?? {});
5554
+ const inlineSchemaHash = import_node_crypto.default.createHash("sha256").update(Buffer.from(inlineSchema, "utf8").toString("base64")).digest("hex");
5707
5555
  const datasourceFilePath = datasources[0].sourceFilePath;
5708
5556
  const config = {
5709
5557
  generator,
5710
- relativeEnvPaths,
5711
- relativePath: (0, import_internals7.pathToPosix)(import_path2.default.relative(outputDir, import_path2.default.dirname(datasourceFilePath))),
5558
+ relativePath: (0, import_internals6.pathToPosix)(import_node_path.default.relative(outputDir, import_node_path.default.dirname(datasourceFilePath))),
5712
5559
  clientVersion: this.options.clientVersion,
5713
5560
  engineVersion: this.options.engineVersion,
5714
5561
  datasourceNames: datasources.map((d) => d.name),
@@ -5720,44 +5567,24 @@ var TSClient = class {
5720
5567
  }, {}),
5721
5568
  inlineSchema,
5722
5569
  inlineSchemaHash,
5723
- copyEngine
5570
+ copyEngine,
5571
+ runtimeDataModel: { models: {}, enums: {}, types: {} },
5572
+ dirname: ""
5724
5573
  };
5725
- const relativeOutdir = import_path2.default.relative(process.cwd(), outputDir);
5726
- const code = `${commonCodeJS({ ...this.options, browser: false })}
5727
- ${buildRequirePath(edge)}
5728
-
5729
- /**
5730
- * Enums
5731
- */
5732
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5733
- ${this.dmmf.datamodel.enums.map((datamodelEnum) => new Enum((0, import_dmmf.datamodelEnumToSchemaEnum)(datamodelEnum), false).toJS()).join("\n\n")}
5734
-
5735
- ${new Enum(
5736
- {
5737
- name: "ModelName",
5738
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5739
- },
5740
- true
5741
- ).toJS()}
5574
+ const relativeOutdir = import_node_path.default.relative(process.cwd(), outputDir);
5575
+ const clientConfig = `
5742
5576
  /**
5743
5577
  * Create the Client
5744
5578
  */
5745
- const config = ${JSON.stringify(config, null, 2)}
5746
- ${buildDirname(edge, relativeOutdir)}
5579
+ const config: runtime.GetPrismaClientConfig = ${JSON.stringify(config, null, 2)}
5580
+ ${buildDirname(edge)}
5747
5581
  ${buildRuntimeDataModel(this.dmmf.datamodel, runtimeName)}
5748
- ${buildQueryEngineWasmModule(wasm, copyEngine, runtimeName)}
5749
- ${buildQueryCompilerWasmModule(wasm, copyEngine, runtimeName)}
5582
+ ${buildGetWasmModule({ component: "engine", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5583
+ ${buildGetWasmModule({ component: "compiler", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5750
5584
  ${buildInjectableEdgeEnv(edge, datasources)}
5751
- ${buildWarnEnvConflicts(edge, runtimeBase, runtimeName)}
5752
5585
  ${buildDebugInitialization(edge)}
5753
- const PrismaClient = getPrismaClient(config)
5754
- exports.PrismaClient = PrismaClient
5755
- Object.assign(exports, Prisma)${deno ? "\nexport { exports as default, Prisma, PrismaClient }" : ""}
5756
5586
  ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, relativeOutdir)}
5757
5587
  `;
5758
- return code;
5759
- }
5760
- toTS() {
5761
5588
  const context = new GenerateContext({
5762
5589
  dmmf: this.dmmf,
5763
5590
  genericArgsInfo: this.genericsInfo,
@@ -5767,8 +5594,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5767
5594
  context,
5768
5595
  this.options.datasources,
5769
5596
  this.options.outputDir,
5770
- this.options.runtimeName,
5771
- this.options.browser
5597
+ this.options.runtimeName
5772
5598
  );
5773
5599
  const commonCode = commonCodeTS(this.options);
5774
5600
  const modelAndTypes = Object.values(this.dmmf.typeAndModelMap).reduce((acc, modelOrType) => {
@@ -5787,7 +5613,9 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5787
5613
  ts12.moduleExport(ts12.typeDeclaration(datamodelEnum.name, ts12.namedType(`$Enums.${datamodelEnum.name}`)))
5788
5614
  ),
5789
5615
  ts12.stringify(
5790
- ts12.moduleExport(ts12.constDeclaration(datamodelEnum.name, ts12.namedType(`typeof $Enums.${datamodelEnum.name}`)))
5616
+ ts12.moduleExport(
5617
+ ts12.constDeclaration(datamodelEnum.name).setValue(ts12.namedValue(`$Enums.${datamodelEnum.name}`))
5618
+ )
5791
5619
  )
5792
5620
  );
5793
5621
  }
@@ -5796,7 +5624,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5796
5624
  const code = `
5797
5625
  /**
5798
5626
  * Client
5799
- **/
5627
+ */
5800
5628
 
5801
5629
  ${commonCode.tsWithoutNamespace()}
5802
5630
 
@@ -5811,10 +5639,13 @@ export namespace $Enums {
5811
5639
 
5812
5640
  ${modelEnumsAliases.join("\n\n")}
5813
5641
  ` : ""}
5642
+
5643
+ ${clientConfig}
5644
+
5814
5645
  ${prismaClientClass.toTSWithoutNamespace()}
5815
5646
 
5816
5647
  export namespace Prisma {
5817
- ${(0, import_indent_string8.default)(
5648
+ ${(0, import_indent_string7.default)(
5818
5649
  `${commonCode.ts()}
5819
5650
  ${new Enum(
5820
5651
  {
@@ -5883,74 +5714,15 @@ ${this.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputType,
5883
5714
  export type BatchPayload = {
5884
5715
  count: number
5885
5716
  }
5886
-
5887
- /**
5888
- * DMMF
5889
- */
5890
- export const dmmf: runtime.BaseDMMF
5891
5717
  `,
5892
5718
  2
5893
5719
  )}}`;
5894
5720
  return code;
5895
5721
  }
5896
- toBrowserJS() {
5897
- const code = `${commonCodeJS({
5898
- ...this.options,
5899
- runtimeName: "index-browser",
5900
- browser: true
5901
- })}
5902
- /**
5903
- * Enums
5904
- */
5905
-
5906
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5907
- ${this.dmmf.schema.enumTypes.model?.map((type) => new Enum(type, false).toJS()).join("\n\n") ?? ""}
5908
-
5909
- ${new Enum(
5910
- {
5911
- name: "ModelName",
5912
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5913
- },
5914
- true
5915
- ).toJS()}
5916
-
5917
- /**
5918
- * This is a stub Prisma Client that will error at runtime if called.
5919
- */
5920
- class PrismaClient {
5921
- constructor() {
5922
- return new Proxy(this, {
5923
- get(target, prop) {
5924
- let message
5925
- const runtime = getRuntime()
5926
- if (runtime.isEdge) {
5927
- message = \`PrismaClient is not configured to run in \${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
5928
- - Use Prisma Accelerate: https://pris.ly/d/accelerate
5929
- - Use Driver Adapters: https://pris.ly/d/driver-adapters
5930
- \`;
5931
- } else {
5932
- message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in \`' + runtime.prettyName + '\`).'
5933
- }
5934
-
5935
- message += \`
5936
- If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report\`
5937
-
5938
- throw new Error(message)
5939
- }
5940
- })
5941
- }
5942
- }
5943
-
5944
- exports.PrismaClient = PrismaClient
5945
-
5946
- Object.assign(exports, Prisma)
5947
- `;
5948
- return code;
5949
- }
5950
5722
  };
5951
5723
 
5952
5724
  // src/typedSql/buildDbEnums.ts
5953
- var import_internals8 = require("@prisma/internals");
5725
+ var import_internals7 = require("@prisma/internals");
5954
5726
  var ts13 = __toESM(require("@prisma/ts-builders"));
5955
5727
  var DbEnumsList = class {
5956
5728
  enums;
@@ -5968,14 +5740,14 @@ var DbEnumsList = class {
5968
5740
  }
5969
5741
  *validJsIdentifiers() {
5970
5742
  for (const dbEnum of this.enums) {
5971
- if ((0, import_internals8.isValidJsIdentifier)(dbEnum.name)) {
5743
+ if ((0, import_internals7.isValidJsIdentifier)(dbEnum.name)) {
5972
5744
  yield dbEnum;
5973
5745
  }
5974
5746
  }
5975
5747
  }
5976
5748
  *invalidJsIdentifiers() {
5977
5749
  for (const dbEnum of this.enums) {
5978
- if (!(0, import_internals8.isValidJsIdentifier)(dbEnum.name)) {
5750
+ if (!(0, import_internals7.isValidJsIdentifier)(dbEnum.name)) {
5979
5751
  yield dbEnum;
5980
5752
  }
5981
5753
  }
@@ -5983,23 +5755,12 @@ var DbEnumsList = class {
5983
5755
  };
5984
5756
  function buildDbEnums(list) {
5985
5757
  const file4 = ts13.file();
5986
- file4.add(buildInvalidIdentifierEnums(list));
5987
- file4.add(buildValidIdentifierEnums(list));
5988
- return ts13.stringify(file4);
5989
- }
5990
- function buildValidIdentifierEnums(list) {
5991
- const namespace3 = ts13.namespace("$DbEnums");
5992
- for (const dbEnum of list.validJsIdentifiers()) {
5993
- namespace3.add(ts13.typeDeclaration(dbEnum.name, enumToUnion(dbEnum)));
5994
- }
5995
- return ts13.moduleExport(namespace3);
5996
- }
5997
- function buildInvalidIdentifierEnums(list) {
5998
5758
  const iface = ts13.interfaceDeclaration("$DbEnums");
5999
- for (const dbEnum of list.invalidJsIdentifiers()) {
5759
+ for (const dbEnum of list.enums) {
6000
5760
  iface.add(ts13.property(dbEnum.name, enumToUnion(dbEnum)));
6001
5761
  }
6002
- return ts13.moduleExport(iface);
5762
+ file4.add(ts13.moduleExport(iface));
5763
+ return ts13.stringify(file4);
6003
5764
  }
6004
5765
  function enumToUnion(dbEnum) {
6005
5766
  return ts13.unionType(dbEnum.values.map(ts13.stringLiteral));
@@ -6013,41 +5774,21 @@ function queryUsesEnums(query, enums) {
6013
5774
 
6014
5775
  // src/typedSql/buildIndex.ts
6015
5776
  var ts14 = __toESM(require("@prisma/ts-builders"));
6016
- var import_ts_builders = require("@prisma/ts-builders");
6017
- function buildIndexTs(queries, enums) {
5777
+ function buildIndex({ queries, enums, importName }) {
6018
5778
  const file4 = ts14.file();
6019
5779
  if (!enums.isEmpty()) {
6020
- file4.add(ts14.moduleExportFrom("./$DbEnums").named("$DbEnums"));
5780
+ file4.add(ts14.moduleExportFrom(importName("./sql/$DbEnums")).named(ts14.namedExport("$DbEnums").typeOnly()));
6021
5781
  }
6022
5782
  for (const query of queries) {
6023
- file4.add(ts14.moduleExportFrom(`./${query.name}`));
5783
+ file4.add(ts14.moduleExportFrom(importName(`./sql/${query.name}`)));
6024
5784
  }
6025
5785
  return ts14.stringify(file4);
6026
5786
  }
6027
- function buildIndexCjs(queries, edgeRuntimeSuffix) {
6028
- const writer = new import_ts_builders.Writer(0, void 0);
6029
- writer.writeLine('"use strict"');
6030
- for (const { name } of queries) {
6031
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6032
- writer.writeLine(`exports.${name} = require("./${fileName}.js").${name}`);
6033
- }
6034
- return writer.toString();
6035
- }
6036
- function buildIndexEsm(queries, edgeRuntimeSuffix) {
6037
- const writer = new import_ts_builders.Writer(0, void 0);
6038
- for (const { name } of queries) {
6039
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6040
- writer.writeLine(`export * from "./${fileName}.mjs"`);
6041
- }
6042
- return writer.toString();
6043
- }
6044
5787
 
6045
5788
  // src/typedSql/buildTypedQuery.ts
6046
5789
  var ts16 = __toESM(require("@prisma/ts-builders"));
6047
- var import_ts_builders2 = require("@prisma/ts-builders");
6048
5790
 
6049
5791
  // src/typedSql/mapTypes.ts
6050
- var import_internals9 = require("@prisma/internals");
6051
5792
  var ts15 = __toESM(require("@prisma/ts-builders"));
6052
5793
  var decimal = ts15.namedType("$runtime.Decimal");
6053
5794
  var uint8Array = ts15.namedType("Uint8Array");
@@ -6141,18 +5882,15 @@ function getMappingConfig(introspectionType, enums) {
6141
5882
  return config;
6142
5883
  }
6143
5884
  function getEnumType(name) {
6144
- if ((0, import_internals9.isValidJsIdentifier)(name)) {
6145
- return ts15.namedType(`$DbEnums.${name}`);
6146
- }
6147
5885
  return ts15.namedType("$DbEnums").subKey(name);
6148
5886
  }
6149
5887
 
6150
5888
  // src/typedSql/buildTypedQuery.ts
6151
- function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
5889
+ function buildTypedQuery({ query, runtimeBase, runtimeName, enums, importName }) {
6152
5890
  const file4 = ts16.file();
6153
5891
  file4.addImport(ts16.moduleImport(`${runtimeBase}/${runtimeName}`).asNamespace("$runtime"));
6154
5892
  if (queryUsesEnums(query, enums)) {
6155
- file4.addImport(ts16.moduleImport("./$DbEnums").named("$DbEnums"));
5893
+ file4.addImport(ts16.moduleImport(importName("./$DbEnums")).named(ts16.namedImport("$DbEnums").typeOnly()));
6156
5894
  }
6157
5895
  const doc = ts16.docComment(query.documentation ?? void 0);
6158
5896
  const factoryType = ts16.functionType();
@@ -6170,11 +5908,17 @@ function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
6170
5908
  factoryType.setReturnType(
6171
5909
  ts16.namedType("$runtime.TypedSql").addGenericArgument(ts16.namedType(`${query.name}.Parameters`)).addGenericArgument(ts16.namedType(`${query.name}.Result`))
6172
5910
  );
6173
- file4.add(ts16.moduleExport(ts16.constDeclaration(query.name, factoryType)).setDocComment(doc));
6174
- const namespace3 = ts16.namespace(query.name);
6175
- namespace3.add(ts16.moduleExport(ts16.typeDeclaration("Parameters", parametersType)));
6176
- namespace3.add(buildResultType(query, enums));
6177
- file4.add(ts16.moduleExport(namespace3));
5911
+ file4.add(
5912
+ ts16.moduleExport(
5913
+ ts16.constDeclaration(query.name).setValue(
5914
+ ts16.functionCall("$runtime.makeTypedQueryFactory").addArgument(ts16.stringLiteral(query.source).asValue()).as(factoryType)
5915
+ )
5916
+ ).setDocComment(doc)
5917
+ );
5918
+ const namespace2 = ts16.namespace(query.name);
5919
+ namespace2.add(ts16.moduleExport(ts16.typeDeclaration("Parameters", parametersType)));
5920
+ namespace2.add(buildResultType(query, enums));
5921
+ file4.add(ts16.moduleExport(namespace2));
6178
5922
  return ts16.stringify(file4);
6179
5923
  }
6180
5924
  function buildResultType(query, enums) {
@@ -6183,47 +5927,28 @@ function buildResultType(query, enums) {
6183
5927
  );
6184
5928
  return ts16.moduleExport(ts16.typeDeclaration("Result", type));
6185
5929
  }
6186
- function buildTypedQueryCjs({ query, runtimeBase, runtimeName }) {
6187
- const writer = new import_ts_builders2.Writer(0, void 0);
6188
- writer.writeLine('"use strict"');
6189
- writer.writeLine(`const { makeTypedQueryFactory: $mkFactory } = require("${runtimeBase}/${runtimeName}")`);
6190
- writer.writeLine(`exports.${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6191
- return writer.toString();
6192
- }
6193
- function buildTypedQueryEsm({ query, runtimeBase, runtimeName }) {
6194
- const writer = new import_ts_builders2.Writer(0, void 0);
6195
- writer.writeLine(`import { makeTypedQueryFactory as $mkFactory } from "${runtimeBase}/${runtimeName}"`);
6196
- writer.writeLine(`export const ${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6197
- return writer.toString();
6198
- }
6199
5930
 
6200
5931
  // src/typedSql/typedSql.ts
6201
5932
  function buildTypedSql({
6202
5933
  queries,
6203
5934
  runtimeBase,
6204
- edgeRuntimeName,
6205
- mainRuntimeName,
6206
- dmmf
5935
+ runtimeName,
5936
+ dmmf,
5937
+ outputName,
5938
+ importName
6207
5939
  }) {
6208
- const fileMap = {};
5940
+ const fileMap = {
5941
+ sql: {}
5942
+ };
6209
5943
  const enums = new DbEnumsList(dmmf.datamodel.enums);
6210
5944
  if (!enums.isEmpty()) {
6211
- fileMap["$DbEnums.d.ts"] = buildDbEnums(enums);
5945
+ fileMap.sql[outputName("$DbEnums")] = buildDbEnums(enums);
6212
5946
  }
6213
5947
  for (const query of queries) {
6214
- const options = { query, runtimeBase, runtimeName: mainRuntimeName, enums };
6215
- const edgeOptions = { ...options, runtimeName: `${edgeRuntimeName}.js` };
6216
- fileMap[`${query.name}.d.ts`] = buildTypedQueryTs(options);
6217
- fileMap[`${query.name}.js`] = buildTypedQueryCjs(options);
6218
- fileMap[`${query.name}.${edgeRuntimeName}.js`] = buildTypedQueryCjs(edgeOptions);
6219
- fileMap[`${query.name}.mjs`] = buildTypedQueryEsm(options);
6220
- fileMap[`${query.name}.edge.mjs`] = buildTypedQueryEsm(edgeOptions);
6221
- }
6222
- fileMap["index.d.ts"] = buildIndexTs(queries, enums);
6223
- fileMap["index.js"] = buildIndexCjs(queries);
6224
- fileMap["index.mjs"] = buildIndexEsm(queries);
6225
- fileMap[`index.${edgeRuntimeName}.mjs`] = buildIndexEsm(queries, edgeRuntimeName);
6226
- fileMap[`index.${edgeRuntimeName}.js`] = buildIndexCjs(queries, edgeRuntimeName);
5948
+ const options = { query, runtimeBase, runtimeName, enums, importName };
5949
+ fileMap.sql[outputName(query.name)] = buildTypedQuery(options);
5950
+ }
5951
+ fileMap[outputName("sql")] = buildIndex({ queries, enums, importName });
6227
5952
  return fileMap;
6228
5953
  }
6229
5954
 
@@ -6234,7 +5959,7 @@ var DenylistError = class extends Error {
6234
5959
  this.stack = void 0;
6235
5960
  }
6236
5961
  };
6237
- (0, import_internals10.setClassName)(DenylistError, "DenylistError");
5962
+ (0, import_internals8.setClassName)(DenylistError, "DenylistError");
6238
5963
  function buildClient({
6239
5964
  schemaPath,
6240
5965
  runtimeBase,
@@ -6250,10 +5975,17 @@ function buildClient({
6250
5975
  postinstall,
6251
5976
  copyEngine,
6252
5977
  envPaths,
6253
- typedSql
5978
+ typedSql,
5979
+ target,
5980
+ generatedFileExtension,
5981
+ importFileExtension,
5982
+ moduleFormat
6254
5983
  }) {
6255
- const clientEngineType = (0, import_internals10.getClientEngineType)(generator);
6256
- const baseClientOptions = {
5984
+ const clientEngineType = (0, import_internals8.getClientEngineType)(generator);
5985
+ const runtimeName = getRuntimeNameForTarget(target, clientEngineType, generator.previewFeatures);
5986
+ const outputName = generatedFileNameMapper(generatedFileExtension);
5987
+ const importName = importFileNameMapper(importFileExtension);
5988
+ const clientOptions = {
6257
5989
  dmmf: getPrismaClientDMMF(dmmf),
6258
5990
  envPaths: envPaths ?? { rootEnvPath: null, schemaEnvPath: void 0 },
6259
5991
  datasources,
@@ -6268,89 +6000,32 @@ function buildClient({
6268
6000
  postinstall,
6269
6001
  copyEngine,
6270
6002
  datamodel,
6271
- browser: false,
6272
- deno: false,
6273
- edge: false,
6274
- wasm: false
6275
- };
6276
- const nodeClientOptions = {
6277
- ...baseClientOptions,
6278
- runtimeName: getNodeRuntimeName(clientEngineType)
6003
+ edge: ["edge", "wasm", "react-native"].includes(runtimeName),
6004
+ runtimeName,
6005
+ target,
6006
+ generatedFileExtension,
6007
+ importFileExtension,
6008
+ moduleFormat
6279
6009
  };
6280
- const nodeClient = new TSClient(nodeClientOptions);
6281
- const defaultClient = new TSClient({
6282
- ...nodeClientOptions
6283
- });
6284
- const edgeClient = new TSClient({
6285
- ...baseClientOptions,
6286
- runtimeName: "edge",
6287
- edge: true
6288
- });
6289
- const rnTsClient = new TSClient({
6290
- ...baseClientOptions,
6291
- runtimeName: "react-native",
6292
- edge: true
6293
- });
6294
- const fileMap = {};
6295
- fileMap["index.js"] = JS(nodeClient);
6296
- fileMap["index.d.ts"] = TS(nodeClient);
6297
- fileMap["default.js"] = JS(defaultClient);
6298
- fileMap["default.d.ts"] = TS(defaultClient);
6299
- fileMap["index-browser.js"] = BrowserJS(nodeClient);
6300
- fileMap["edge.js"] = JS(edgeClient);
6301
- fileMap["edge.d.ts"] = TS(edgeClient);
6302
- fileMap["client.js"] = JS(defaultClient);
6303
- fileMap["client.d.ts"] = TS(defaultClient);
6304
- if (generator.previewFeatures.includes("reactNative")) {
6305
- fileMap["react-native.js"] = JS(rnTsClient);
6306
- fileMap["react-native.d.ts"] = TS(rnTsClient);
6307
- }
6308
- const usesWasmRuntime = generator.previewFeatures.includes("driverAdapters");
6309
- if (usesWasmRuntime) {
6310
- const usesClientEngine = clientEngineType === import_internals10.ClientEngineType.Client;
6311
- if (usesClientEngine) {
6312
- fileMap["wasm-worker-loader.mjs"] = `export default import('./query_compiler_bg.wasm')`;
6313
- fileMap["wasm-edge-light-loader.mjs"] = `export default import('./query_compiler_bg.wasm?module')`;
6314
- } else {
6315
- fileMap["wasm-worker-loader.mjs"] = `export default import('./query_engine_bg.wasm')`;
6316
- fileMap["wasm-edge-light-loader.mjs"] = `export default import('./query_engine_bg.wasm?module')`;
6317
- }
6318
- const wasmClient = new TSClient({
6319
- ...baseClientOptions,
6320
- runtimeName: "wasm",
6321
- edge: true,
6322
- wasm: true
6323
- });
6324
- fileMap["wasm.js"] = JS(wasmClient);
6325
- fileMap["wasm.d.ts"] = TS(wasmClient);
6326
- } else {
6327
- fileMap["wasm.js"] = fileMap["index-browser.js"];
6328
- fileMap["wasm.d.ts"] = fileMap["default.d.ts"];
6329
- }
6330
- if (generator.previewFeatures.includes("deno") && !!globalThis.Deno) {
6331
- const denoEdgeClient = new TSClient({
6332
- ...baseClientOptions,
6333
- runtimeBase: `../${runtimeBase}`,
6334
- runtimeName: "edge",
6335
- deno: true,
6336
- edge: true
6337
- });
6338
- fileMap["deno/edge.js"] = JS(denoEdgeClient);
6339
- fileMap["deno/index.d.ts"] = TS(denoEdgeClient);
6340
- fileMap["deno/edge.ts"] = `
6341
- import './polyfill.js'
6342
- // @deno-types="./index.d.ts"
6343
- export * from './edge.js'`;
6344
- fileMap["deno/polyfill.js"] = "globalThis.process = { env: Deno.env.toObject() }; globalThis.global = globalThis";
6010
+ if (runtimeName === "react-native" && !generator.previewFeatures.includes("reactNative")) {
6011
+ throw new Error(`Using the "react-native" runtime requires the "reactNative" preview feature to be enabled.`);
6345
6012
  }
6013
+ const client = new TSClient(clientOptions);
6014
+ let fileMap = {};
6015
+ fileMap[outputName("client")] = client.toTS();
6016
+ fileMap[outputName("index")] = `export * from '${importName("./client")}'`;
6346
6017
  if (typedSql && typedSql.length > 0) {
6347
- fileMap["sql"] = buildTypedSql({
6348
- dmmf,
6349
- runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6350
- mainRuntimeName: getNodeRuntimeName(clientEngineType),
6351
- queries: typedSql,
6352
- edgeRuntimeName: usesWasmRuntime ? "wasm" : "edge"
6353
- });
6018
+ fileMap = {
6019
+ ...fileMap,
6020
+ ...buildTypedSql({
6021
+ dmmf,
6022
+ runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6023
+ runtimeName,
6024
+ queries: typedSql,
6025
+ outputName,
6026
+ importName
6027
+ })
6028
+ };
6354
6029
  }
6355
6030
  return {
6356
6031
  fileMap,
@@ -6382,9 +6057,13 @@ async function generateClient(options) {
6382
6057
  postinstall,
6383
6058
  envPaths,
6384
6059
  copyEngine = true,
6385
- typedSql
6060
+ typedSql,
6061
+ target,
6062
+ generatedFileExtension,
6063
+ importFileExtension,
6064
+ moduleFormat
6386
6065
  } = options;
6387
- const clientEngineType = (0, import_internals10.getClientEngineType)(generator);
6066
+ const clientEngineType = (0, import_internals8.getClientEngineType)(generator);
6388
6067
  const { runtimeBase, outputDir } = await getGenerationDirs(options);
6389
6068
  const { prismaClientDmmf, fileMap } = buildClient({
6390
6069
  datamodel,
@@ -6401,7 +6080,11 @@ async function generateClient(options) {
6401
6080
  postinstall,
6402
6081
  copyEngine,
6403
6082
  envPaths,
6404
- typedSql
6083
+ typedSql,
6084
+ target,
6085
+ generatedFileExtension,
6086
+ importFileExtension,
6087
+ moduleFormat
6405
6088
  });
6406
6089
  const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf);
6407
6090
  if (denylistsErrors) {
@@ -6418,45 +6101,28 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
6418
6101
  }
6419
6102
  await deleteOutputDir(outputDir);
6420
6103
  await (0, import_fs_extra.ensureDir)(outputDir);
6421
- if (generator.previewFeatures.includes("deno") && !!globalThis.Deno) {
6422
- await (0, import_fs_extra.ensureDir)(import_node_path.default.join(outputDir, "deno"));
6423
- }
6424
6104
  await writeFileMap(outputDir, fileMap);
6425
- const enginePath = clientEngineType === import_internals10.ClientEngineType.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
6426
- if (!enginePath) {
6427
- throw new Error(
6428
- `Prisma Client needs \`${clientEngineType === import_internals10.ClientEngineType.Library ? "libqueryEngine" : "queryEngine"}\` in the \`binaryPaths\` object.`
6429
- );
6430
- }
6431
- if (copyEngine) {
6105
+ const enginePath = clientEngineType === import_internals8.ClientEngineType.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
6106
+ if (copyEngine && enginePath) {
6432
6107
  if (process.env.NETLIFY) {
6433
6108
  await (0, import_fs_extra.ensureDir)("/tmp/prisma-engines");
6434
6109
  }
6435
6110
  for (const [binaryTarget, filePath] of Object.entries(enginePath)) {
6436
- const fileName = import_node_path.default.basename(filePath);
6437
- let target;
6111
+ const fileName = import_node_path2.default.basename(filePath);
6112
+ let target2;
6438
6113
  if (process.env.NETLIFY && !["rhel-openssl-1.0.x", "rhel-openssl-3.0.x"].includes(binaryTarget)) {
6439
- target = import_node_path.default.join("/tmp/prisma-engines", fileName);
6114
+ target2 = import_node_path2.default.join("/tmp/prisma-engines", fileName);
6440
6115
  } else {
6441
- target = import_node_path.default.join(outputDir, fileName);
6116
+ target2 = import_node_path2.default.join(outputDir, fileName);
6442
6117
  }
6443
- await (0, import_fetch_engine.overwriteFile)(filePath, target);
6118
+ await (0, import_fetch_engine.overwriteFile)(filePath, target2);
6444
6119
  }
6445
6120
  }
6446
- const schemaTargetPath = import_node_path.default.join(outputDir, "schema.prisma");
6447
- await import_promises.default.writeFile(schemaTargetPath, datamodel, { encoding: "utf-8" });
6448
- try {
6449
- const prismaCache = (0, import_env_paths.default)("prisma").cache;
6450
- const signalsPath = import_node_path.default.join(prismaCache, "last-generate");
6451
- await import_promises.default.mkdir(prismaCache, { recursive: true });
6452
- await import_promises.default.writeFile(signalsPath, Date.now().toString());
6453
- } catch {
6454
- }
6455
6121
  }
6456
6122
  function writeFileMap(outputDir, fileMap) {
6457
6123
  return Promise.all(
6458
6124
  Object.entries(fileMap).map(async ([fileName, content]) => {
6459
- const absolutePath = import_node_path.default.join(outputDir, fileName);
6125
+ const absolutePath = import_node_path2.default.join(outputDir, fileName);
6460
6126
  await import_promises.default.rm(absolutePath, { recursive: true, force: true });
6461
6127
  if (typeof content === "string") {
6462
6128
  await import_promises.default.writeFile(absolutePath, content);
@@ -6545,24 +6211,44 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
6545
6211
  return errorArray.length > 0 ? errorArray : null;
6546
6212
  }
6547
6213
  async function getGenerationDirs({ runtimeBase, outputDir }) {
6548
- const normalizedOutputDir = import_node_path.default.normalize(outputDir);
6549
- const normalizedRuntimeBase = (0, import_internals10.pathToPosix)(runtimeBase);
6550
- const userPackageRoot = await (0, import_pkg_up.default)({ cwd: import_node_path.default.dirname(normalizedOutputDir) });
6551
- const userProjectRoot = userPackageRoot ? import_node_path.default.dirname(userPackageRoot) : process.cwd();
6214
+ const normalizedOutputDir = import_node_path2.default.normalize(outputDir);
6215
+ const normalizedRuntimeBase = (0, import_internals8.pathToPosix)(runtimeBase);
6216
+ const userPackageRoot = await (0, import_pkg_up.default)({ cwd: import_node_path2.default.dirname(normalizedOutputDir) });
6217
+ const userProjectRoot = userPackageRoot ? import_node_path2.default.dirname(userPackageRoot) : process.cwd();
6552
6218
  return {
6553
6219
  runtimeBase: normalizedRuntimeBase,
6554
6220
  outputDir: normalizedOutputDir,
6555
6221
  projectRoot: userProjectRoot
6556
6222
  };
6557
6223
  }
6224
+ function getRuntimeNameForTarget(target, engineType, previewFeatures) {
6225
+ switch (target) {
6226
+ case "nodejs":
6227
+ case "deno":
6228
+ case "bun":
6229
+ return getNodeRuntimeName(engineType);
6230
+ case "workerd":
6231
+ case "edge-light":
6232
+ case "deno-deploy":
6233
+ if (previewFeatures.includes("driverAdapters")) {
6234
+ return "wasm";
6235
+ } else {
6236
+ return "edge";
6237
+ }
6238
+ case "react-native":
6239
+ return "react-native";
6240
+ default:
6241
+ (0, import_internals8.assertNever)(target, "Unknown runtime target");
6242
+ }
6243
+ }
6558
6244
  function getNodeRuntimeName(engineType) {
6559
- if (engineType === import_internals10.ClientEngineType.Binary) {
6245
+ if (engineType === import_internals8.ClientEngineType.Binary) {
6560
6246
  return "binary";
6561
6247
  }
6562
- if (engineType === import_internals10.ClientEngineType.Library) {
6248
+ if (engineType === import_internals8.ClientEngineType.Library) {
6563
6249
  return "library";
6564
6250
  }
6565
- if (engineType === import_internals10.ClientEngineType.Client) {
6251
+ if (engineType === import_internals8.ClientEngineType.Client) {
6566
6252
  if (!process.env.PRISMA_UNSTABLE_CLIENT_ENGINE_TYPE) {
6567
6253
  throw new Error(
6568
6254
  'Unstable Feature: engineType="client" is in a proof of concept phase and not ready to be used publicly yet!'
@@ -6570,7 +6256,7 @@ function getNodeRuntimeName(engineType) {
6570
6256
  }
6571
6257
  return "client";
6572
6258
  }
6573
- (0, import_internals10.assertNever)(engineType, "Unknown engine type");
6259
+ (0, import_internals8.assertNever)(engineType, "Unknown engine type");
6574
6260
  }
6575
6261
  async function deleteOutputDir(outputDir) {
6576
6262
  try {
@@ -6578,15 +6264,13 @@ async function deleteOutputDir(outputDir) {
6578
6264
  if (files.length === 0) {
6579
6265
  return;
6580
6266
  }
6581
- if (!files.includes("client.d.ts")) {
6267
+ if (!files.includes("client.ts") && !files.includes("client.mts") && !files.includes("client.cts")) {
6582
6268
  throw new Error(
6583
6269
  `${outputDir} exists and is not empty but doesn't look like a generated Prisma Client. Please check your output path and remove the existing directory if you indeed want to generate the Prisma Client in that location.`
6584
6270
  );
6585
6271
  }
6586
6272
  await Promise.allSettled(
6587
- (await (0, import_fast_glob.glob)(`${outputDir}/**/*.ts`, {
6588
- globstar: true,
6589
- onlyFiles: true,
6273
+ (await (0, import_fast_glob.glob)([`${outputDir}/**/*.{ts,mts,cts}`, `${outputDir}/*.node`, `${outputDir}/{query,schema}-engine-*`], {
6590
6274
  followSymbolicLinks: false
6591
6275
  })).map(import_promises.default.unlink)
6592
6276
  );
@@ -6598,16 +6282,91 @@ async function deleteOutputDir(outputDir) {
6598
6282
  }
6599
6283
 
6600
6284
  // src/generator.ts
6601
- var import_debug = __toESM(require("@prisma/debug"));
6285
+ var import_debug = require("@prisma/debug");
6602
6286
  var import_engines_version = require("@prisma/engines-version");
6603
- var import_internals11 = require("@prisma/internals");
6604
- var import_ts_pattern = require("ts-pattern");
6287
+ var import_internals9 = require("@prisma/internals");
6288
+ var import_get_tsconfig = require("get-tsconfig");
6289
+ var import_ts_pattern2 = require("ts-pattern");
6605
6290
 
6606
6291
  // package.json
6607
- var version = "6.6.0-dev.95";
6292
+ var version = "6.6.0-dev.97";
6293
+
6294
+ // src/module-format.ts
6295
+ function parseModuleFormat(format) {
6296
+ switch (format.toLowerCase()) {
6297
+ case "cjs":
6298
+ case "commonjs":
6299
+ return "cjs";
6300
+ case "esm":
6301
+ return "esm";
6302
+ default:
6303
+ throw new Error(`Invalid module format: "${format}", expected "esm" or "cjs"`);
6304
+ }
6305
+ }
6306
+ function parseModuleFormatFromUnknown(value) {
6307
+ if (typeof value === "string") {
6308
+ return parseModuleFormat(value);
6309
+ } else {
6310
+ throw new Error(`Invalid module format: ${JSON.stringify(value)}, expected "esm" or "cjs"`);
6311
+ }
6312
+ }
6313
+ function inferModuleFormat({
6314
+ tsconfig,
6315
+ generatedFileExtension,
6316
+ importFileExtension
6317
+ }) {
6318
+ if (tsconfig?.compilerOptions?.module) {
6319
+ return fromTsConfigModule(tsconfig.compilerOptions.module);
6320
+ }
6321
+ if (generatedFileExtension === "cts" || importFileExtension === "cjs") {
6322
+ return "cjs";
6323
+ }
6324
+ return "esm";
6325
+ }
6326
+ function fromTsConfigModule(module2) {
6327
+ const normalizedModule = module2.toLowerCase();
6328
+ if (normalizedModule === "commonjs") {
6329
+ return "cjs";
6330
+ }
6331
+ return "esm";
6332
+ }
6333
+
6334
+ // src/runtime-targets.ts
6335
+ var supportedRuntimes = ["nodejs", "deno", "deno-deploy", "bun", "workerd", "edge-light", "react-native"];
6336
+ function parseRuntimeTarget(target) {
6337
+ switch (target.toLowerCase()) {
6338
+ case "node":
6339
+ case "nodejs":
6340
+ return "nodejs";
6341
+ case "deno":
6342
+ return "deno";
6343
+ case "deno-deploy":
6344
+ return "deno-deploy";
6345
+ case "bun":
6346
+ return "bun";
6347
+ case "workerd":
6348
+ case "cloudflare":
6349
+ return "workerd";
6350
+ case "edge-light":
6351
+ case "vercel":
6352
+ return "edge-light";
6353
+ case "react-native":
6354
+ return "react-native";
6355
+ default:
6356
+ throw new Error(
6357
+ `Unknown target runtime: "${target}". The available options are: ${supportedRuntimes.map((runtime) => `"${runtime}"`).join(", ")}`
6358
+ );
6359
+ }
6360
+ }
6361
+ function parseRuntimeTargetFromUnknown(target) {
6362
+ if (typeof target !== "string") {
6363
+ throw new Error(`Invalid target runtime: ${JSON.stringify(target)}. Expected a string.`);
6364
+ }
6365
+ return parseRuntimeTarget(target);
6366
+ }
6608
6367
 
6609
6368
  // src/generator.ts
6610
- var debug = (0, import_debug.default)("prisma:client:generator");
6369
+ var debug = (0, import_debug.Debug)("prisma:client:generator");
6611
6370
  var missingOutputErrorMessage = `An output path is required for the \`prisma-client-ts\` generator. Please provide an output path in your schema file:
6612
6371
 
6613
6372
  ${dim(`generator client {
@@ -6621,12 +6380,12 @@ function getOutputPath(config) {
6621
6380
  if (!config.output) {
6622
6381
  throw new Error(missingOutputErrorMessage);
6623
6382
  }
6624
- return (0, import_internals11.parseEnvValue)(config.output);
6383
+ return (0, import_internals9.parseEnvValue)(config.output);
6625
6384
  }
6626
6385
  var PrismaClientTsGenerator = class {
6627
6386
  name = "prisma-client-ts";
6628
6387
  getManifest(config) {
6629
- const requiresEngines = (0, import_ts_pattern.match)((0, import_internals11.getClientEngineType)(config)).with(import_internals11.ClientEngineType.Library, () => ["libqueryEngine"]).with(import_internals11.ClientEngineType.Binary, () => ["queryEngine"]).with(import_internals11.ClientEngineType.Client, () => []).exhaustive();
6388
+ const requiresEngines = (0, import_ts_pattern2.match)((0, import_internals9.getClientEngineType)(config)).with(import_internals9.ClientEngineType.Library, () => ["libqueryEngine"]).with(import_internals9.ClientEngineType.Binary, () => ["queryEngine"]).with(import_internals9.ClientEngineType.Client, () => []).exhaustive();
6630
6389
  debug("requiresEngines", requiresEngines);
6631
6390
  return Promise.resolve({
6632
6391
  defaultOutput: getOutputPath(config),
@@ -6637,13 +6396,27 @@ var PrismaClientTsGenerator = class {
6637
6396
  });
6638
6397
  }
6639
6398
  async generate(options) {
6399
+ const { config } = options.generator;
6400
+ const outputDir = getOutputPath(options.generator);
6401
+ const tsconfig = (0, import_get_tsconfig.getTsconfig)(outputDir)?.config;
6402
+ const target = config.runtime !== void 0 ? parseRuntimeTargetFromUnknown(config.runtime) : "nodejs";
6403
+ const generatedFileExtension = config.generatedFileExtension !== void 0 ? parseGeneratedFileExtension(config.generatedFileExtension) : "ts";
6404
+ const importFileExtension = config.importFileExtension !== void 0 ? parseImportFileExtension(config.importFileExtension) : inferImportFileExtension({
6405
+ tsconfig,
6406
+ generatedFileExtension
6407
+ });
6408
+ const moduleFormat = config.moduleFormat !== void 0 ? parseModuleFormatFromUnknown(config.moduleFormat) : inferModuleFormat({
6409
+ tsconfig,
6410
+ generatedFileExtension,
6411
+ importFileExtension
6412
+ });
6640
6413
  await generateClient({
6641
6414
  datamodel: options.datamodel,
6642
6415
  schemaPath: options.schemaPath,
6643
6416
  binaryPaths: options.binaryPaths,
6644
6417
  datasources: options.datasources,
6645
6418
  envPaths: options.envPaths,
6646
- outputDir: getOutputPath(options.generator),
6419
+ outputDir,
6647
6420
  runtimeBase: "@prisma/client/runtime",
6648
6421
  dmmf: options.dmmf,
6649
6422
  generator: options.generator,
@@ -6652,49 +6425,17 @@ var PrismaClientTsGenerator = class {
6652
6425
  activeProvider: options.datasources[0]?.activeProvider,
6653
6426
  postinstall: options.postinstall,
6654
6427
  copyEngine: !options.noEngine,
6655
- typedSql: options.typedSql
6428
+ typedSql: options.typedSql,
6429
+ target,
6430
+ generatedFileExtension,
6431
+ importFileExtension,
6432
+ moduleFormat
6656
6433
  });
6657
6434
  }
6658
6435
  };
6659
-
6660
- // src/utils/types/dmmfToTypes.ts
6661
- function dmmfToTypes(dmmf) {
6662
- return new TSClient({
6663
- dmmf,
6664
- datasources: [],
6665
- clientVersion: "",
6666
- engineVersion: "",
6667
- runtimeBase: "@prisma/client",
6668
- runtimeName: "library",
6669
- schemaPath: "",
6670
- outputDir: "",
6671
- activeProvider: "",
6672
- binaryPaths: {},
6673
- generator: {
6674
- binaryTargets: [],
6675
- config: {},
6676
- name: "prisma-client-ts",
6677
- output: null,
6678
- provider: { value: "prisma-client-ts", fromEnvVar: null },
6679
- previewFeatures: [],
6680
- isCustomOutput: false,
6681
- sourceFilePath: "schema.prisma"
6682
- },
6683
- datamodel: "",
6684
- browser: false,
6685
- deno: false,
6686
- edge: false,
6687
- wasm: false,
6688
- envPaths: {
6689
- rootEnvPath: null,
6690
- schemaEnvPath: void 0
6691
- }
6692
- }).toTS();
6693
- }
6694
6436
  // Annotate the CommonJS export names for ESM import in node:
6695
6437
  0 && (module.exports = {
6696
6438
  PrismaClientTsGenerator,
6697
- dmmfToTypes,
6698
6439
  externalToInternalDmmf,
6699
6440
  generateClient,
6700
6441
  getDMMF