@prisma/client-generator-ts 6.6.0-dev.96 → 6.6.0-dev.98

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,38 +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
2397
  // src/TSClient/Input.ts
2340
- var import_client_common3 = require("@prisma/client-common");
2398
+ var import_client_common4 = require("@prisma/client-common");
2341
2399
  var ts2 = __toESM(require("@prisma/ts-builders"));
2342
2400
  var import_indent_string2 = __toESM(require("indent-string"));
2343
2401
 
@@ -2373,28 +2431,28 @@ function getOmitName(modelName) {
2373
2431
  return `${modelName}Omit`;
2374
2432
  }
2375
2433
  function getAggregateName(modelName) {
2376
- return `Aggregate${capitalize2(modelName)}`;
2434
+ return `Aggregate${capitalize3(modelName)}`;
2377
2435
  }
2378
2436
  function getGroupByName(modelName) {
2379
- return `${capitalize2(modelName)}GroupByOutputType`;
2437
+ return `${capitalize3(modelName)}GroupByOutputType`;
2380
2438
  }
2381
2439
  function getAvgAggregateName(modelName) {
2382
- return `${capitalize2(modelName)}AvgAggregateOutputType`;
2440
+ return `${capitalize3(modelName)}AvgAggregateOutputType`;
2383
2441
  }
2384
2442
  function getSumAggregateName(modelName) {
2385
- return `${capitalize2(modelName)}SumAggregateOutputType`;
2443
+ return `${capitalize3(modelName)}SumAggregateOutputType`;
2386
2444
  }
2387
2445
  function getMinAggregateName(modelName) {
2388
- return `${capitalize2(modelName)}MinAggregateOutputType`;
2446
+ return `${capitalize3(modelName)}MinAggregateOutputType`;
2389
2447
  }
2390
2448
  function getMaxAggregateName(modelName) {
2391
- return `${capitalize2(modelName)}MaxAggregateOutputType`;
2449
+ return `${capitalize3(modelName)}MaxAggregateOutputType`;
2392
2450
  }
2393
2451
  function getCountAggregateInputName(modelName) {
2394
- return `${capitalize2(modelName)}CountAggregateInputType`;
2452
+ return `${capitalize3(modelName)}CountAggregateInputType`;
2395
2453
  }
2396
2454
  function getCountAggregateOutputName(modelName) {
2397
- return `${capitalize2(modelName)}CountAggregateOutputType`;
2455
+ return `${capitalize3(modelName)}CountAggregateOutputType`;
2398
2456
  }
2399
2457
  function getAggregateInputType(aggregateOutputType) {
2400
2458
  return aggregateOutputType.replace(/OutputType$/, "InputType");
@@ -2403,13 +2461,13 @@ function getGroupByArgsName(modelName) {
2403
2461
  return `${modelName}GroupByArgs`;
2404
2462
  }
2405
2463
  function getGroupByPayloadName(modelName) {
2406
- return `Get${capitalize2(modelName)}GroupByPayload`;
2464
+ return `Get${capitalize3(modelName)}GroupByPayload`;
2407
2465
  }
2408
2466
  function getAggregateArgsName(modelName) {
2409
- return `${capitalize2(modelName)}AggregateArgs`;
2467
+ return `${capitalize3(modelName)}AggregateArgs`;
2410
2468
  }
2411
2469
  function getAggregateGetName(modelName) {
2412
- return `Get${capitalize2(modelName)}AggregateType`;
2470
+ return `Get${capitalize3(modelName)}AggregateType`;
2413
2471
  }
2414
2472
  function getFieldArgName(field, modelName) {
2415
2473
  if (field.args.length) {
@@ -2467,8 +2525,8 @@ function getModelArgName(modelName, action) {
2467
2525
  (0, import_internals2.assertNever)(action, `Unknown action: ${action}`);
2468
2526
  }
2469
2527
  }
2470
- function getPayloadName(modelName, namespace3 = true) {
2471
- if (namespace3) {
2528
+ function getPayloadName(modelName, namespace2 = true) {
2529
+ if (namespace2) {
2472
2530
  return `Prisma.${getPayloadName(modelName, false)}`;
2473
2531
  }
2474
2532
  return `$${modelName}Payload`;
@@ -2476,7 +2534,7 @@ function getPayloadName(modelName, namespace3 = true) {
2476
2534
  function getFieldRefsTypeName(name) {
2477
2535
  return `${name}FieldRefs`;
2478
2536
  }
2479
- function capitalize2(str) {
2537
+ function capitalize3(str) {
2480
2538
  return str[0].toUpperCase() + str.slice(1);
2481
2539
  }
2482
2540
  function getRefAllowedTypeName(type) {
@@ -2488,11 +2546,11 @@ function getRefAllowedTypeName(type) {
2488
2546
  }
2489
2547
  function appendSkipType(context, type) {
2490
2548
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
2491
- return ts.unionType([type, ts.namedType("$Types.Skip")]);
2549
+ return ts.unionType([type, ts.namedType("runtime.Types.Skip")]);
2492
2550
  }
2493
2551
  return type;
2494
2552
  }
2495
- 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"));
2496
2554
 
2497
2555
  // src/utils/common.ts
2498
2556
  function needsNamespace(field) {
@@ -2609,7 +2667,7 @@ var InputType = class {
2609
2667
  toTS() {
2610
2668
  const { type } = this;
2611
2669
  const source = type.meta?.source;
2612
- 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);
2613
2671
  const body = `{
2614
2672
  ${(0, import_indent_string2.default)(
2615
2673
  fields.map((arg) => {
@@ -2650,11 +2708,11 @@ var import_klona = require("klona");
2650
2708
  var ts3 = __toESM(require("@prisma/ts-builders"));
2651
2709
 
2652
2710
  // src/TSClient/helpers.ts
2653
- var import_client_common5 = require("@prisma/client-common");
2711
+ var import_client_common6 = require("@prisma/client-common");
2654
2712
  var import_pluralize2 = __toESM(require("pluralize"));
2655
2713
 
2656
2714
  // src/TSClient/jsdoc.ts
2657
- var import_client_common4 = require("@prisma/client-common");
2715
+ var import_client_common5 = require("@prisma/client-common");
2658
2716
  var Docs = {
2659
2717
  cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
2660
2718
  pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
@@ -2727,7 +2785,7 @@ const ${ctx.singular} = await ${ctx.method}({
2727
2785
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
2728
2786
  @example
2729
2787
  // Create many ${ctx.plural}
2730
- 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}({
2731
2789
  data: [
2732
2790
  // ... provide data here
2733
2791
  ]
@@ -2741,7 +2799,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2741
2799
  body: (ctx) => {
2742
2800
  const onlySelect = ctx.firstScalar ? `
2743
2801
  // Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
2744
- 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}({
2745
2803
  select: { ${ctx.firstScalar.name}: true },
2746
2804
  data: [
2747
2805
  // ... provide data here
@@ -2751,7 +2809,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import
2751
2809
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to create many ${ctx.plural}.
2752
2810
  @example
2753
2811
  // Create many ${ctx.plural}
2754
- 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}({
2755
2813
  data: [
2756
2814
  // ... provide data here
2757
2815
  ]
@@ -2769,7 +2827,7 @@ ${undefinedNote}
2769
2827
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2770
2828
  @example
2771
2829
  // Get one ${ctx.singular}
2772
- 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}({
2773
2831
  where: {
2774
2832
  // ... provide filter here
2775
2833
  }
@@ -2784,7 +2842,7 @@ if no matches were found.
2784
2842
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2785
2843
  @example
2786
2844
  // Get one ${ctx.singular}
2787
- 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}({
2788
2846
  where: {
2789
2847
  // ... provide filter here
2790
2848
  }
@@ -2799,7 +2857,7 @@ ${undefinedNote}
2799
2857
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2800
2858
  @example
2801
2859
  // Get one ${ctx.singular}
2802
- 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}({
2803
2861
  where: {
2804
2862
  // ... provide filter here
2805
2863
  }
@@ -2820,7 +2878,7 @@ ${undefinedNote}
2820
2878
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to find a ${ctx.singular}
2821
2879
  @example
2822
2880
  // Get one ${ctx.singular}
2823
- 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}({
2824
2882
  where: {
2825
2883
  // ... provide filter here
2826
2884
  }
@@ -2838,7 +2896,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2838
2896
  body: (ctx) => {
2839
2897
  const onlySelect = ctx.firstScalar ? `
2840
2898
  // Only select the \`${ctx.firstScalar.name}\`
2841
- 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 } })` : "";
2842
2900
  return `Find zero or more ${ctx.plural} that matches the filter.
2843
2901
  ${undefinedNote}
2844
2902
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
@@ -2864,7 +2922,7 @@ ${onlySelect}
2864
2922
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one ${ctx.singular}.
2865
2923
  @example
2866
2924
  // Update one ${ctx.singular}
2867
- 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}({
2868
2926
  where: {
2869
2927
  // ... provide filter here
2870
2928
  },
@@ -2883,7 +2941,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2883
2941
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update or create a ${ctx.singular}.
2884
2942
  @example
2885
2943
  // Update or create a ${ctx.singular}
2886
- 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}({
2887
2945
  create: {
2888
2946
  // ... data to create a ${ctx.singular}
2889
2947
  },
@@ -2977,7 +3035,7 @@ ${undefinedNote}
2977
3035
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update one or more rows.
2978
3036
  @example
2979
3037
  // Update many ${ctx.plural}
2980
- 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}({
2981
3039
  where: {
2982
3040
  // ... provide filter here
2983
3041
  },
@@ -2996,7 +3054,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
2996
3054
  body: (ctx) => {
2997
3055
  const onlySelect = ctx.firstScalar ? `
2998
3056
  // Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
2999
- 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}({
3000
3058
  select: { ${ctx.firstScalar.name}: true },
3001
3059
  where: {
3002
3060
  // ... provide filter here
@@ -3009,7 +3067,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)}With${(0, import
3009
3067
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to update many ${ctx.plural}.
3010
3068
  @example
3011
3069
  // Update many ${ctx.plural}
3012
- 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}({
3013
3071
  where: {
3014
3072
  // ... provide filter here
3015
3073
  },
@@ -3047,7 +3105,7 @@ const { count } = await ${ctx.method}({
3047
3105
  body: (ctx) => `Perform aggregation operations on a ${ctx.singular}.
3048
3106
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which aggregations you would like to apply.
3049
3107
  @example
3050
- 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}({
3051
3109
  pipeline: [
3052
3110
  { $match: { status: "registered" } },
3053
3111
  { $group: { _id: "$country", total: { $sum: 1 } } }
@@ -3062,7 +3120,7 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
3062
3120
  body: (ctx) => `Find zero or more ${ctx.plural} that matches the filter.
3063
3121
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Select which filters you would like to apply.
3064
3122
  @example
3065
- 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}({
3066
3124
  filter: { age: { $gt: 25 } }
3067
3125
  })`,
3068
3126
  fields: {
@@ -3075,10 +3133,10 @@ const ${(0, import_client_common4.lowerCase)(ctx.mapping.model)} = await ${ctx.m
3075
3133
  // src/TSClient/helpers.ts
3076
3134
  function getMethodJSDocBody(action, mapping, model) {
3077
3135
  const ctx = {
3078
- singular: (0, import_client_common5.capitalize)(mapping.model),
3079
- 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),
3080
3138
  firstScalar: model.fields.find((f) => f.kind === "scalar"),
3081
- method: `prisma.${(0, import_client_common5.lowerCase)(mapping.model)}.${action}`,
3139
+ method: `prisma.${(0, import_client_common6.lowerCase)(mapping.model)}.${action}`,
3082
3140
  action,
3083
3141
  mapping,
3084
3142
  model
@@ -3120,7 +3178,6 @@ var ArgsTypeBuilder = class {
3120
3178
  ).setDocComment(ts3.docComment(`${type.name} ${action ?? "without action"}`));
3121
3179
  }
3122
3180
  moduleExport;
3123
- hasDefaultName = true;
3124
3181
  addProperty(prop) {
3125
3182
  this.moduleExport.declaration.type.add(prop);
3126
3183
  }
@@ -3170,7 +3227,6 @@ var ArgsTypeBuilder = class {
3170
3227
  return this;
3171
3228
  }
3172
3229
  setGeneratedName(name) {
3173
- this.hasDefaultName = false;
3174
3230
  this.moduleExport.declaration.setName(name);
3175
3231
  return this;
3176
3232
  }
@@ -3195,7 +3251,7 @@ var ModelFieldRefs = class {
3195
3251
  /**
3196
3252
  * Fields of the ${name} model
3197
3253
  */
3198
- interface ${getFieldRefsTypeName(name)} {
3254
+ export interface ${getFieldRefsTypeName(name)} {
3199
3255
  ${this.stringifyFields()}
3200
3256
  }
3201
3257
  `;
@@ -3270,12 +3326,12 @@ function buildOutputField(field) {
3270
3326
  }
3271
3327
  function enumTypeName(ref) {
3272
3328
  const name = ref.type;
3273
- const namespace3 = ref.namespace === "model" ? "$Enums" : "Prisma";
3274
- return `${namespace3}.${name}`;
3329
+ const namespace2 = ref.namespace === "model" ? "$Enums" : "Prisma";
3330
+ return `${namespace2}.${name}`;
3275
3331
  }
3276
3332
 
3277
3333
  // src/TSClient/Payload.ts
3278
- var import_client_common6 = require("@prisma/client-common");
3334
+ var import_client_common7 = require("@prisma/client-common");
3279
3335
  var ts5 = __toESM(require("@prisma/ts-builders"));
3280
3336
  function buildModelPayload(model, context) {
3281
3337
  const isComposite = context.dmmf.isComposite(model.name);
@@ -3293,7 +3349,7 @@ function buildModelPayload(model, context) {
3293
3349
  scalars.add(buildModelOutputProperty(field, context.dmmf));
3294
3350
  }
3295
3351
  }
3296
- 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)));
3297
3353
  const payloadTypeDeclaration = ts5.typeDeclaration(
3298
3354
  getPayloadName(model.name, false),
3299
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))
@@ -3305,7 +3361,7 @@ function buildModelPayload(model, context) {
3305
3361
  }
3306
3362
 
3307
3363
  // src/TSClient/SelectIncludeOmit.ts
3308
- var import_client_common7 = require("@prisma/client-common");
3364
+ var import_client_common8 = require("@prisma/client-common");
3309
3365
  var ts6 = __toESM(require("@prisma/ts-builders"));
3310
3366
  function buildIncludeType({
3311
3367
  modelName,
@@ -3322,9 +3378,9 @@ function buildOmitType({ modelName, fields, context }) {
3322
3378
  (field) => field.outputType.location === "scalar" || field.outputType.location === "enumTypes" || context.dmmf.isComposite(field.outputType.type)
3323
3379
  ).map((field) => ts6.stringLiteral(field.name))
3324
3380
  );
3325
- 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));
3326
3382
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
3327
- omitType.addGenericArgument(ts6.namedType("$Types.Skip"));
3383
+ omitType.addGenericArgument(ts6.namedType("runtime.Types.Skip"));
3328
3384
  }
3329
3385
  return buildExport(getOmitName(modelName), omitType);
3330
3386
  }
@@ -3335,11 +3391,11 @@ function buildSelectType({
3335
3391
  context
3336
3392
  }) {
3337
3393
  const objectType9 = buildSelectOrIncludeObject(modelName, fields, context);
3338
- 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));
3339
3395
  return buildExport(typeName, selectType);
3340
3396
  }
3341
3397
  function modelResultExtensionsType(modelName) {
3342
- 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));
3343
3399
  }
3344
3400
  function buildScalarSelectType({ modelName, fields, context }) {
3345
3401
  const object = buildSelectOrIncludeObject(
@@ -3387,6 +3443,18 @@ function getModelActions(dmmf, name) {
3387
3443
  return mappingKeys;
3388
3444
  }
3389
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
+
3390
3458
  // src/TSClient/Model.ts
3391
3459
  var Model = class {
3392
3460
  constructor(model, context) {
@@ -3476,7 +3544,7 @@ var Model = class {
3476
3544
  return `
3477
3545
 
3478
3546
 
3479
- export type ${groupByArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3547
+ export type ${groupByArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3480
3548
  ${(0, import_indent_string3.default)(
3481
3549
  groupByRootField.args.map((arg) => {
3482
3550
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.groupBy, arg) };
@@ -3569,7 +3637,7 @@ ${aggregateTypes.length > 1 ? aggregateTypes.slice(1).map((type) => {
3569
3637
  return new InputType(newType, this.context).toTS();
3570
3638
  }).join("\n") : ""}
3571
3639
 
3572
- export type ${aggregateArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3640
+ export type ${aggregateArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3573
3641
  ${(0, import_indent_string3.default)(
3574
3642
  aggregateRootField.args.map((arg) => {
3575
3643
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.aggregate, arg) };
@@ -3608,7 +3676,7 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
3608
3676
  const modelTypeExport = ts7.moduleExport(
3609
3677
  ts7.typeDeclaration(
3610
3678
  model.name,
3611
- ts7.namedType(`$Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3679
+ ts7.namedType(`runtime.Types.Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3612
3680
  )
3613
3681
  ).setDocComment(ts7.docComment(docs));
3614
3682
  return ts7.stringify(modelTypeExport);
@@ -3686,9 +3754,9 @@ ${omitType}${includeType}${createManyAndReturnIncludeType}${updateManyAndReturnI
3686
3754
 
3687
3755
  ${ts7.stringify(buildModelPayload(this.model, this.context), { newLine: "none" })}
3688
3756
 
3689
- type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3757
+ export type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3690
3758
  model.name
3691
- )}> = $Result.GetResult<${getPayloadName(model.name)}, S>
3759
+ )}> = runtime.Types.Result.GetResult<${getPayloadName(model.name)}, S>
3692
3760
 
3693
3761
  ${isComposite ? "" : new ModelDelegate(this.type, this.context).toTS()}
3694
3762
 
@@ -3732,7 +3800,7 @@ var ModelDelegate = class {
3732
3800
  excludedArgsForCount.push("relationLoadStrategy");
3733
3801
  }
3734
3802
  const excludedArgsForCountType = excludedArgsForCount.map((name2) => `'${name2}'`).join(" | ");
3735
- 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> =
3736
3804
  Omit<${getModelArgName(name, DMMF2.ModelAction.findMany)}, ${excludedArgsForCountType}> & {
3737
3805
  select?: ${getCountAggregateInputName(name)} | true
3738
3806
  }
@@ -3748,7 +3816,7 @@ ${availableActions.includes(DMMF2.ModelAction.aggregate) ? `${(0, import_indent_
3748
3816
  count<T extends ${countArgsName}>(
3749
3817
  args?: Subset<T, ${countArgsName}>,
3750
3818
  ): Prisma.PrismaPromise<
3751
- T extends $Utils.Record<'select', any>
3819
+ T extends runtime.Types.Utils.Record<'select', any>
3752
3820
  ? T['select'] extends true
3753
3821
  ? number
3754
3822
  : GetScalarType<T['select'], ${getCountAggregateOutputName(name)}>
@@ -3879,16 +3947,16 @@ function getReturnType({
3879
3947
  isNullable = false
3880
3948
  }) {
3881
3949
  if (actionName === DMMF2.ModelAction.count) {
3882
- return ts7.promise(ts7.numberType);
3950
+ return promise(ts7.numberType);
3883
3951
  }
3884
3952
  if (actionName === DMMF2.ModelAction.aggregate) {
3885
- return ts7.promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3953
+ return promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3886
3954
  }
3887
3955
  if (actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
3888
- return ts7.prismaPromise(ts7.namedType("JsonObject"));
3956
+ return prismaPromise(ts7.namedType("JsonObject"));
3889
3957
  }
3890
3958
  if (actionName === DMMF2.ModelAction.deleteMany || actionName === DMMF2.ModelAction.updateMany || actionName === DMMF2.ModelAction.createMany) {
3891
- return ts7.prismaPromise(ts7.namedType("BatchPayload"));
3959
+ return prismaPromise(ts7.namedType("BatchPayload"));
3892
3960
  }
3893
3961
  const isList = actionName === DMMF2.ModelAction.findMany || actionName === DMMF2.ModelAction.createManyAndReturn || actionName === DMMF2.ModelAction.updateManyAndReturn;
3894
3962
  if (isList) {
@@ -3896,7 +3964,7 @@ function getReturnType({
3896
3964
  if (isChaining) {
3897
3965
  result = ts7.unionType(result).addVariant(ts7.namedType("Null"));
3898
3966
  }
3899
- return ts7.prismaPromise(result);
3967
+ return prismaPromise(result);
3900
3968
  }
3901
3969
  if (isChaining && actionName === DMMF2.ModelAction.findUniqueOrThrow) {
3902
3970
  const nullType7 = isNullable ? ts7.nullType : ts7.namedType("Null");
@@ -3913,11 +3981,11 @@ function getFluentWrapper(modelName, resultType, nullType7 = ts7.neverType) {
3913
3981
  return ts7.namedType(fluentWrapperName(modelName)).addGenericArgument(resultType).addGenericArgument(nullType7).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(ts7.namedType("GlobalOmitOptions"));
3914
3982
  }
3915
3983
  function getResultType(modelName, actionName) {
3916
- 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"));
3917
3985
  }
3918
3986
  function buildFluentWrapperDefinition(modelName, outputType, context) {
3919
3987
  const definition = ts7.interfaceDeclaration(fluentWrapperName(modelName));
3920
- 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")));
3921
3989
  definition.add(ts7.property(ts7.toStringTag, ts7.stringLiteral("PrismaPromise")).readonly());
3922
3990
  definition.addMultiple(
3923
3991
  outputType.fields.filter(
@@ -3943,7 +4011,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3943
4011
  @param onrejected The callback to execute when the Promise is rejected.
3944
4012
  @returns A Promise for the completion of which ever callback is executed.
3945
4013
  `
3946
- ).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")])))
3947
4015
  );
3948
4016
  definition.add(
3949
4017
  ts7.method("catch").setDocComment(
@@ -3952,7 +4020,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3952
4020
  @param onrejected The callback to execute when the Promise is rejected.
3953
4021
  @returns A Promise for the completion of the callback.
3954
4022
  `
3955
- ).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")])))
3956
4024
  );
3957
4025
  definition.add(
3958
4026
  ts7.method("finally").setDocComment(
@@ -3964,7 +4032,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3964
4032
  `
3965
4033
  ).addParameter(
3966
4034
  ts7.parameter("onfinally", ts7.unionType([ts7.functionType(), ts7.undefinedType, ts7.nullType])).optional()
3967
- ).setReturnType(ts7.promise(ts7.namedType("T")))
4035
+ ).setReturnType(promise(ts7.namedType("T")))
3968
4036
  );
3969
4037
  return ts7.moduleExport(definition).setDocComment(ts7.docComment`
3970
4038
  The delegate class that acts as a "Promise-like" for ${modelName}.
@@ -3994,16 +4062,16 @@ function fluentWrapperName(modelName) {
3994
4062
  }
3995
4063
 
3996
4064
  // src/TSClient/TSClient.ts
4065
+ var import_node_crypto = __toESM(require("node:crypto"));
4066
+ var import_node_path = __toESM(require("node:path"));
3997
4067
  var import_dmmf = require("@prisma/dmmf");
3998
- var import_internals7 = require("@prisma/internals");
4068
+ var import_internals6 = require("@prisma/internals");
3999
4069
  var ts12 = __toESM(require("@prisma/ts-builders"));
4000
4070
  var import_ci_info = __toESM(require("ci-info"));
4001
- var import_crypto = __toESM(require("crypto"));
4002
- var import_indent_string8 = __toESM(require("indent-string"));
4003
- var import_path2 = __toESM(require("path"));
4071
+ var import_indent_string7 = __toESM(require("indent-string"));
4004
4072
 
4005
4073
  // src/dmmf.ts
4006
- var import_client_common8 = require("@prisma/client-common");
4074
+ var import_client_common9 = require("@prisma/client-common");
4007
4075
  var DMMFHelper = class {
4008
4076
  constructor(document) {
4009
4077
  this.document = document;
@@ -4056,8 +4124,8 @@ var DMMFHelper = class {
4056
4124
  Object.values(this.mappings.otherOperations.read)
4057
4125
  ].flat();
4058
4126
  }
4059
- hasEnumInNamespace(enumName, namespace3) {
4060
- 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;
4061
4129
  }
4062
4130
  resolveInputObjectType(ref) {
4063
4131
  return this.inputTypesByName.get(fullyQualifiedName(ref.type, ref.namespace));
@@ -4069,33 +4137,33 @@ var DMMFHelper = class {
4069
4137
  return this.outputObjectTypes[ref.namespace ?? "prisma"].find((outputObject) => outputObject.name === ref.type);
4070
4138
  }
4071
4139
  buildModelMap() {
4072
- return (0, import_client_common8.keyBy)(this.datamodel.models, "name");
4140
+ return (0, import_client_common9.keyBy)(this.datamodel.models, "name");
4073
4141
  }
4074
4142
  buildTypeMap() {
4075
- return (0, import_client_common8.keyBy)(this.datamodel.types, "name");
4143
+ return (0, import_client_common9.keyBy)(this.datamodel.types, "name");
4076
4144
  }
4077
4145
  buildTypeModelMap() {
4078
4146
  return { ...this.buildTypeMap(), ...this.buildModelMap() };
4079
4147
  }
4080
4148
  buildMappingsMap() {
4081
- return (0, import_client_common8.keyBy)(this.mappings.modelOperations, "model");
4149
+ return (0, import_client_common9.keyBy)(this.mappings.modelOperations, "model");
4082
4150
  }
4083
4151
  buildMergedOutputTypeMap() {
4084
4152
  if (!this.schema.outputObjectTypes.prisma) {
4085
4153
  return {
4086
- model: (0, import_client_common8.keyBy)(this.schema.outputObjectTypes.model, "name"),
4087
- 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")
4088
4156
  };
4089
4157
  }
4090
4158
  return {
4091
- model: (0, import_client_common8.keyBy)(this.schema.outputObjectTypes.model, "name"),
4092
- 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")
4093
4161
  };
4094
4162
  }
4095
4163
  buildRootFieldMap() {
4096
4164
  return {
4097
- ...(0, import_client_common8.keyBy)(this.outputTypeMap.prisma.Query.fields, "name"),
4098
- ...(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")
4099
4167
  };
4100
4168
  }
4101
4169
  buildInputTypesMap() {
@@ -4112,20 +4180,20 @@ var DMMFHelper = class {
4112
4180
  return result;
4113
4181
  }
4114
4182
  };
4115
- function fullyQualifiedName(typeName, namespace3) {
4116
- if (namespace3) {
4117
- return `${namespace3}.${typeName}`;
4183
+ function fullyQualifiedName(typeName, namespace2) {
4184
+ if (namespace2) {
4185
+ return `${namespace2}.${typeName}`;
4118
4186
  }
4119
4187
  return typeName;
4120
4188
  }
4121
4189
 
4122
4190
  // src/GenericsArgsInfo.ts
4123
- var import_client_common9 = require("@prisma/client-common");
4191
+ var import_client_common10 = require("@prisma/client-common");
4124
4192
  var GenericArgsInfo = class {
4125
4193
  constructor(_dmmf) {
4126
4194
  this._dmmf = _dmmf;
4127
4195
  }
4128
- _cache = new import_client_common9.Cache();
4196
+ _cache = new import_client_common10.Cache();
4129
4197
  /**
4130
4198
  * Determines if arg types need generic <$PrismaModel> argument added.
4131
4199
  * Essentially, performs breadth-first search for any fieldRefTypes that
@@ -4234,69 +4302,46 @@ function buildDebugInitialization(edge) {
4234
4302
  }
4235
4303
  const debugVar = getRuntimeEdgeEnvVar("DEBUG");
4236
4304
  return `if (${debugVar}) {
4237
- Debug.enable(${debugVar})
4305
+ runtime.Debug.enable(${debugVar})
4238
4306
  }
4239
4307
  `;
4240
4308
  }
4241
4309
 
4242
4310
  // src/utils/buildDirname.ts
4243
- var import_internals4 = require("@prisma/internals");
4244
- function buildDirname(edge, relativeOutdir) {
4311
+ function buildDirname(edge) {
4245
4312
  if (edge === true) {
4246
- return buildDirnameDefault();
4313
+ return `config.dirname = '/'`;
4247
4314
  }
4248
- return buildDirnameFind(relativeOutdir);
4249
- }
4250
- function buildDirnameFind(relativeOutdir) {
4251
- return `
4252
- const fs = require('fs')
4253
-
4254
- config.dirname = __dirname
4255
- if (!fs.existsSync(path.join(__dirname, 'schema.prisma'))) {
4256
- const alternativePaths = [
4257
- ${JSON.stringify((0, import_internals4.pathToPosix)(relativeOutdir))},
4258
- ${JSON.stringify((0, import_internals4.pathToPosix)(relativeOutdir).split("/").slice(1).join("/"))},
4259
- ]
4260
-
4261
- const alternativePath = alternativePaths.find((altPath) => {
4262
- return fs.existsSync(path.join(process.cwd(), altPath, 'schema.prisma'))
4263
- }) ?? alternativePaths[0]
4264
-
4265
- config.dirname = path.join(process.cwd(), alternativePath)
4266
- config.isBundled = true
4267
- }`;
4268
- }
4269
- function buildDirnameDefault() {
4270
- return `config.dirname = '/'`;
4315
+ return `config.dirname = __dirname`;
4271
4316
  }
4272
4317
 
4273
4318
  // src/utils/buildDMMF.ts
4274
- var import_client_common10 = require("@prisma/client-common");
4319
+ var import_client_common11 = require("@prisma/client-common");
4275
4320
  function buildRuntimeDataModel(datamodel, runtimeName) {
4276
- const runtimeDataModel = (0, import_client_common10.dmmfToRuntimeDataModel)(datamodel);
4321
+ const runtimeDataModel = (0, import_client_common11.dmmfToRuntimeDataModel)(datamodel);
4277
4322
  let prunedDataModel;
4278
4323
  if (runtimeName === "wasm" || runtimeName === "client") {
4279
- prunedDataModel = (0, import_client_common10.pruneRuntimeDataModel)(runtimeDataModel);
4324
+ prunedDataModel = (0, import_client_common11.pruneRuntimeDataModel)(runtimeDataModel);
4280
4325
  } else {
4281
4326
  prunedDataModel = runtimeDataModel;
4282
4327
  }
4283
4328
  const datamodelString = escapeJson(JSON.stringify(prunedDataModel));
4284
4329
  return `
4285
- config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})
4286
- defineDmmfProperty(exports.Prisma, config.runtimeDataModel)`;
4330
+ config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})`;
4287
4331
  }
4288
4332
 
4289
4333
  // src/utils/buildGetWasmModule.ts
4290
- var import_client_common11 = require("@prisma/client-common");
4334
+ var import_client_common12 = require("@prisma/client-common");
4291
4335
  var import_ts_pattern = require("ts-pattern");
4292
4336
  function buildGetWasmModule({
4293
4337
  component,
4294
4338
  runtimeName,
4295
4339
  runtimeBase,
4296
4340
  target,
4297
- activeProvider
4341
+ activeProvider,
4342
+ moduleFormat
4298
4343
  }) {
4299
- const capitalizedComponent = (0, import_client_common11.capitalize)(component);
4344
+ const capitalizedComponent = (0, import_client_common12.capitalize)(component);
4300
4345
  const wasmPathBase = `${runtimeBase}/query_compiler_bg.${activeProvider}`;
4301
4346
  const wasmBindingsPath = `${wasmPathBase}.mjs`;
4302
4347
  const wasmModulePath = `${wasmPathBase}.wasm`;
@@ -4307,10 +4352,8 @@ function buildGetWasmModule({
4307
4352
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
4308
4353
 
4309
4354
  getQuery${capitalizedComponent}WasmModule: async () => {
4310
- const { createRequire } = await import('node:module')
4311
4355
  const { readFile } = await import('node:fs/promises')
4312
-
4313
- const require = createRequire(import.meta.url)
4356
+ ${buildRequire(moduleFormat)}
4314
4357
  const wasmModulePath = require.resolve(${JSON.stringify(wasmModulePath)})
4315
4358
  const wasmModuleBytes = await readFile(wasmModulePath)
4316
4359
 
@@ -4331,10 +4374,18 @@ function buildGetWasmModule({
4331
4374
  }
4332
4375
  return `config.${component}Wasm = undefined`;
4333
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
+ `;
4384
+ }
4334
4385
 
4335
4386
  // src/utils/buildNFTAnnotations.ts
4336
4387
  var import_get_platform = require("@prisma/get-platform");
4337
- var import_internals5 = require("@prisma/internals");
4388
+ var import_internals4 = require("@prisma/internals");
4338
4389
  var import_path = __toESM(require("path"));
4339
4390
  function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir) {
4340
4391
  if (noEngine === true) return "";
@@ -4343,7 +4394,7 @@ function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir
4343
4394
  }
4344
4395
  if (process.env.NETLIFY) {
4345
4396
  const isNodeMajor20OrUp = parseInt(process.versions.node.split(".")[0]) >= 20;
4346
- const awsRuntimeVersion = (0, import_internals5.parseAWSNodejsRuntimeEnvVarVersion)();
4397
+ const awsRuntimeVersion = (0, import_internals4.parseAWSNodejsRuntimeEnvVarVersion)();
4347
4398
  const isRuntimeEnvVar20OrUp = awsRuntimeVersion && awsRuntimeVersion >= 20;
4348
4399
  const isRuntimeEnvVar18OrDown = awsRuntimeVersion && awsRuntimeVersion <= 18;
4349
4400
  if ((isNodeMajor20OrUp || isRuntimeEnvVar20OrUp) && !isRuntimeEnvVar18OrDown) {
@@ -4360,10 +4411,10 @@ function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir
4360
4411
  return `${engineAnnotations}${schemaAnnotations}`;
4361
4412
  }
4362
4413
  function getQueryEngineFilename(engineType, binaryTarget) {
4363
- if (engineType === import_internals5.ClientEngineType.Library) {
4414
+ if (engineType === import_internals4.ClientEngineType.Library) {
4364
4415
  return (0, import_get_platform.getNodeAPIName)(binaryTarget, "fs");
4365
4416
  }
4366
- if (engineType === import_internals5.ClientEngineType.Binary) {
4417
+ if (engineType === import_internals4.ClientEngineType.Binary) {
4367
4418
  return `query-engine-${binaryTarget}`;
4368
4419
  }
4369
4420
  return void 0;
@@ -4372,207 +4423,70 @@ function buildNFTAnnotation(fileName, relativeOutdir) {
4372
4423
  const relativeFilePath = import_path.default.join(relativeOutdir, fileName);
4373
4424
  return `
4374
4425
  // file annotations for bundling tools to include these files
4375
- path.join(__dirname, ${JSON.stringify((0, import_internals5.pathToPosix)(fileName))});
4376
- path.join(process.cwd(), ${JSON.stringify((0, import_internals5.pathToPosix)(relativeFilePath))})`;
4377
- }
4378
-
4379
- // src/utils/buildRequirePath.ts
4380
- function buildRequirePath(edge) {
4381
- if (edge === true) return "";
4382
- return `
4383
- const path = require('path')`;
4384
- }
4385
-
4386
- // src/utils/buildWarnEnvConflicts.ts
4387
- function buildWarnEnvConflicts(edge, runtimeBase, runtimeName) {
4388
- if (edge === true) return "";
4389
- return `
4390
- const { warnEnvConflicts } = require('${runtimeBase}/${runtimeName}')
4391
-
4392
- warnEnvConflicts({
4393
- rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.rootEnvPath),
4394
- schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.schemaEnvPath)
4395
- })`;
4426
+ path.join(__dirname, ${JSON.stringify((0, import_internals4.pathToPosix)(fileName))})
4427
+ path.join(process.cwd(), ${JSON.stringify((0, import_internals4.pathToPosix)(relativeFilePath))})`;
4396
4428
  }
4397
4429
 
4398
4430
  // src/TSClient/common.ts
4399
- var import_indent_string4 = __toESM(require("indent-string"));
4400
- var commonCodeJS = ({
4431
+ var commonCodeTS = ({
4401
4432
  runtimeBase,
4402
4433
  runtimeName,
4403
- browser,
4404
4434
  clientVersion,
4405
4435
  engineVersion,
4406
4436
  generator,
4407
- deno
4408
- }) => `${deno ? "const exports = {}" : ""}
4409
- Object.defineProperty(exports, "__esModule", { value: true });
4410
- ${deno ? `
4411
- import {
4412
- PrismaClientKnownRequestError,
4413
- PrismaClientUnknownRequestError,
4414
- PrismaClientRustPanicError,
4415
- PrismaClientInitializationError,
4416
- PrismaClientValidationError,
4417
- getPrismaClient,
4418
- sqltag,
4419
- empty,
4420
- join,
4421
- raw,
4422
- Decimal,
4423
- Debug,
4424
- objectEnumValues,
4425
- makeStrictEnum,
4426
- Extensions,
4427
- defineDmmfProperty,
4428
- Public,
4429
- getRuntime,
4430
- skip
4431
- } from '${runtimeBase}/${runtimeName}'` : browser ? `
4432
- const {
4433
- Decimal,
4434
- objectEnumValues,
4435
- makeStrictEnum,
4436
- Public,
4437
- getRuntime,
4438
- skip
4439
- } = require('${runtimeBase}/${runtimeName}')
4440
- ` : `
4441
- const {
4442
- PrismaClientKnownRequestError,
4443
- PrismaClientUnknownRequestError,
4444
- PrismaClientRustPanicError,
4445
- PrismaClientInitializationError,
4446
- PrismaClientValidationError,
4447
- getPrismaClient,
4448
- sqltag,
4449
- empty,
4450
- join,
4451
- raw,
4452
- skip,
4453
- Decimal,
4454
- Debug,
4455
- objectEnumValues,
4456
- makeStrictEnum,
4457
- Extensions,
4458
- warnOnce,
4459
- defineDmmfProperty,
4460
- Public,
4461
- getRuntime,
4462
- createParam,
4463
- } = require('${runtimeBase}/${runtimeName}')
4464
- `}
4465
-
4466
- const Prisma = {}
4467
-
4468
- exports.Prisma = Prisma
4469
- exports.$Enums = {}
4437
+ moduleFormat,
4438
+ edge
4439
+ }) => ({
4440
+ tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}'
4441
+ ${buildPreamble(edge, moduleFormat)}
4470
4442
 
4471
- /**
4472
- * Prisma Client JS version: ${clientVersion}
4473
- * Query Engine version: ${engineVersion}
4474
- */
4475
- Prisma.prismaVersion = {
4476
- client: "${clientVersion}",
4477
- engine: "${engineVersion}"
4478
- }
4443
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4444
+ `,
4445
+ ts: () => `export type DMMF = typeof runtime.DMMF
4479
4446
 
4480
- Prisma.PrismaClientKnownRequestError = ${notSupportOnBrowser("PrismaClientKnownRequestError", browser)};
4481
- Prisma.PrismaClientUnknownRequestError = ${notSupportOnBrowser("PrismaClientUnknownRequestError", browser)}
4482
- Prisma.PrismaClientRustPanicError = ${notSupportOnBrowser("PrismaClientRustPanicError", browser)}
4483
- Prisma.PrismaClientInitializationError = ${notSupportOnBrowser("PrismaClientInitializationError", browser)}
4484
- Prisma.PrismaClientValidationError = ${notSupportOnBrowser("PrismaClientValidationError", browser)}
4485
- Prisma.Decimal = Decimal
4447
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4486
4448
 
4487
4449
  /**
4488
- * Re-export of sql-template-tag
4450
+ * Validator
4489
4451
  */
4490
- Prisma.sql = ${notSupportOnBrowser("sqltag", browser)}
4491
- Prisma.empty = ${notSupportOnBrowser("empty", browser)}
4492
- Prisma.join = ${notSupportOnBrowser("join", browser)}
4493
- Prisma.raw = ${notSupportOnBrowser("raw", browser)}
4494
- Prisma.validator = Public.validator
4452
+ export const validator = runtime.Public.validator
4495
4453
 
4496
4454
  /**
4497
- * Extensions
4498
- */
4499
- Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
4500
- Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
4501
-
4502
- /**
4503
- * Shorthand utilities for JSON filtering
4455
+ * Prisma Errors
4504
4456
  */
4505
- Prisma.DbNull = objectEnumValues.instances.DbNull
4506
- Prisma.JsonNull = objectEnumValues.instances.JsonNull
4507
- Prisma.AnyNull = objectEnumValues.instances.AnyNull
4508
4457
 
4509
- Prisma.NullTypes = {
4510
- DbNull: objectEnumValues.classes.DbNull,
4511
- JsonNull: objectEnumValues.classes.JsonNull,
4512
- AnyNull: objectEnumValues.classes.AnyNull
4513
- }
4458
+ export const PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4459
+ export type PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4514
4460
 
4515
- ${buildPrismaSkipJs(generator.previewFeatures)}
4516
- `;
4517
- var notSupportOnBrowser = (fnc, browser) => {
4518
- if (browser) {
4519
- return `() => {
4520
- const runtimeName = getRuntime().prettyName;
4521
- throw new Error(\`${fnc} is unable to run in this browser environment, or has been bundled for the browser (running in \${runtimeName}).
4522
- In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report\`,
4523
- )}`;
4524
- }
4525
- return fnc;
4526
- };
4527
- var commonCodeTS = ({
4528
- runtimeBase,
4529
- runtimeName,
4530
- clientVersion,
4531
- engineVersion,
4532
- generator
4533
- }) => ({
4534
- tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}';
4535
- import $Types = runtime.Types // general types
4536
- import $Public = runtime.Types.Public
4537
- import $Utils = runtime.Types.Utils
4538
- import $Extensions = runtime.Types.Extensions
4539
- import $Result = runtime.Types.Result
4540
-
4541
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4542
- `,
4543
- ts: () => `export import DMMF = runtime.DMMF
4461
+ export const PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4462
+ export type PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4544
4463
 
4545
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4464
+ export const PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4465
+ export type PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4546
4466
 
4547
- /**
4548
- * Validator
4549
- */
4550
- export import validator = runtime.Public.validator
4467
+ export const PrismaClientInitializationError = runtime.PrismaClientInitializationError
4468
+ export type PrismaClientInitializationError = runtime.PrismaClientInitializationError
4551
4469
 
4552
- /**
4553
- * Prisma Errors
4554
- */
4555
- export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4556
- export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4557
- export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4558
- export import PrismaClientInitializationError = runtime.PrismaClientInitializationError
4559
- export import PrismaClientValidationError = runtime.PrismaClientValidationError
4470
+ export const PrismaClientValidationError = runtime.PrismaClientValidationError
4471
+ export type PrismaClientValidationError = runtime.PrismaClientValidationError
4560
4472
 
4561
4473
  /**
4562
4474
  * Re-export of sql-template-tag
4563
4475
  */
4564
- export import sql = runtime.sqltag
4565
- export import empty = runtime.empty
4566
- export import join = runtime.join
4567
- export import raw = runtime.raw
4568
- 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
4569
4482
 
4570
4483
  ${buildPrismaSkipTs(generator.previewFeatures)}
4571
4484
 
4572
4485
  /**
4573
4486
  * Decimal.js
4574
4487
  */
4575
- export import Decimal = runtime.Decimal
4488
+ export const Decimal = runtime.Decimal
4489
+ export type Decimal = runtime.Decimal
4576
4490
 
4577
4491
  export type DecimalJsLike = runtime.DecimalJsLike
4578
4492
 
@@ -4587,46 +4501,43 @@ export type MetricHistogramBucket = runtime.MetricHistogramBucket
4587
4501
  /**
4588
4502
  * Extensions
4589
4503
  */
4590
- export import Extension = $Extensions.UserArgs
4591
- export import getExtensionContext = runtime.Extensions.getExtensionContext
4592
- export import Args = $Public.Args
4593
- export import Payload = $Public.Payload
4594
- export import Result = $Public.Result
4595
- 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
+ }
4596
4515
 
4597
4516
  /**
4598
4517
  * Prisma Client JS version: ${clientVersion}
4599
4518
  * Query Engine version: ${engineVersion}
4600
4519
  */
4601
- export type PrismaVersion = {
4602
- client: string
4520
+ export const prismaVersion: PrismaVersion = {
4521
+ client: "${clientVersion}",
4522
+ engine: "${engineVersion}"
4603
4523
  }
4604
4524
 
4605
- export const prismaVersion: PrismaVersion
4606
-
4607
4525
  /**
4608
4526
  * Utility Types
4609
4527
  */
4610
4528
 
4611
4529
 
4612
- export import JsonObject = runtime.JsonObject
4613
- export import JsonArray = runtime.JsonArray
4614
- export import JsonValue = runtime.JsonValue
4615
- export import InputJsonObject = runtime.InputJsonObject
4616
- export import InputJsonArray = runtime.InputJsonArray
4617
- export import InputJsonValue = runtime.InputJsonValue
4618
-
4619
- /**
4620
- * Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
4621
- *
4622
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4623
- */
4624
- namespace NullTypes {
4625
- ${buildNullClass("DbNull")}
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
4626
4536
 
4627
- ${buildNullClass("JsonNull")}
4628
-
4629
- ${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),
4630
4541
  }
4631
4542
 
4632
4543
  /**
@@ -4634,21 +4545,21 @@ ${buildNullClass("AnyNull")}
4634
4545
  *
4635
4546
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4636
4547
  */
4637
- export const DbNull: NullTypes.DbNull
4548
+ export const DbNull = runtime.objectEnumValues.instances.DbNull
4638
4549
 
4639
4550
  /**
4640
4551
  * Helper for filtering JSON entries that have JSON \`null\` values (not empty on the db)
4641
4552
  *
4642
4553
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4643
4554
  */
4644
- export const JsonNull: NullTypes.JsonNull
4555
+ export const JsonNull = runtime.objectEnumValues.instances.JsonNull
4645
4556
 
4646
4557
  /**
4647
4558
  * Helper for filtering JSON entries that are \`Prisma.DbNull\` or \`Prisma.JsonNull\`
4648
4559
  *
4649
4560
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4650
4561
  */
4651
- export const AnyNull: NullTypes.AnyNull
4562
+ export const AnyNull = runtime.objectEnumValues.instances.AnyNull
4652
4563
 
4653
4564
  type SelectAndInclude = {
4654
4565
  select: any
@@ -4660,16 +4571,6 @@ type SelectAndOmit = {
4660
4571
  omit: any
4661
4572
  }
4662
4573
 
4663
- /**
4664
- * Get the type of the value, that the Promise holds.
4665
- */
4666
- export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T;
4667
-
4668
- /**
4669
- * Get the return type of a function which returns a Promise.
4670
- */
4671
- export type PromiseReturnType<T extends (...args: any) => $Utils.JsPromise<any>> = PromiseType<ReturnType<T>>
4672
-
4673
4574
  /**
4674
4575
  * From T, pick a set of properties whose keys are in the union K
4675
4576
  */
@@ -4677,19 +4578,8 @@ type Prisma__Pick<T, K extends keyof T> = {
4677
4578
  [P in K]: T[P];
4678
4579
  };
4679
4580
 
4680
-
4681
4581
  export type Enumerable<T> = T | Array<T>;
4682
4582
 
4683
- export type RequiredKeys<T> = {
4684
- [K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K
4685
- }[keyof T]
4686
-
4687
- export type TruthyKeys<T> = keyof {
4688
- [K in keyof T as T[K] extends false | undefined | null ? never : K]: K
4689
- }
4690
-
4691
- export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>
4692
-
4693
4583
  /**
4694
4584
  * Subset
4695
4585
  * @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection
@@ -4806,7 +4696,6 @@ type _Merge<U extends object> = IntersectOf<Overwrite<U, {
4806
4696
  }>>;
4807
4697
 
4808
4698
  type Key = string | number | symbol;
4809
- type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never;
4810
4699
  type AtStrict<O extends object, K extends Key> = O[K & keyof O];
4811
4700
  type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
4812
4701
  export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
@@ -4830,7 +4719,7 @@ type _Record<K extends keyof any, T> = {
4830
4719
  type NoExpand<T> = T extends unknown ? T : never;
4831
4720
 
4832
4721
  // this type assumes the passed object is entirely optional
4833
- type AtLeast<O extends object, K extends string> = NoExpand<
4722
+ export type AtLeast<O extends object, K extends string> = NoExpand<
4834
4723
  O extends unknown
4835
4724
  ? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
4836
4725
  | {[P in keyof O as P extends K ? P : never]-?: O[P]} & O
@@ -4843,19 +4732,10 @@ export type Strict<U extends object> = ComputeRaw<_Strict<U>>;
4843
4732
 
4844
4733
  export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
4845
4734
 
4846
- /**
4847
- A [[Boolean]]
4848
- */
4849
4735
  export type Boolean = True | False
4850
4736
 
4851
- // /**
4852
- // 1
4853
- // */
4854
4737
  export type True = 1
4855
4738
 
4856
- /**
4857
- 0
4858
- */
4859
4739
  export type False = 0
4860
4740
 
4861
4741
  export type Not<B extends Boolean> = {
@@ -4886,16 +4766,6 @@ export type Or<B1 extends Boolean, B2 extends Boolean> = {
4886
4766
 
4887
4767
  export type Keys<U extends Union> = U extends unknown ? keyof U : never
4888
4768
 
4889
- type Cast<A, B> = A extends B ? A : B;
4890
-
4891
- export const type: unique symbol;
4892
-
4893
-
4894
-
4895
- /**
4896
- * Used by group by
4897
- */
4898
-
4899
4769
  export type GetScalarType<T, O> = O extends object ? {
4900
4770
  [P in keyof T]: P extends keyof O
4901
4771
  ? O[P]
@@ -4947,43 +4817,36 @@ type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRe
4947
4817
 
4948
4818
  `
4949
4819
  });
4950
- function buildNullClass(name) {
4951
- const source = `/**
4952
- * Type of \`Prisma.${name}\`.
4953
- *
4954
- * You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
4955
- *
4956
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4957
- */
4958
- class ${name} {
4959
- private ${name}: never
4960
- private constructor()
4961
- }`;
4962
- return (0, import_indent_string4.default)(source, TAB_SIZE);
4963
- }
4964
4820
  function buildPrismaSkipTs(previewFeatures) {
4965
4821
  if (previewFeatures.includes("strictUndefinedChecks")) {
4966
4822
  return `
4967
4823
  /**
4968
4824
  * Prisma.skip
4969
4825
  */
4970
- export import skip = runtime.skip
4826
+ export const skip = runtime.skip
4971
4827
  `;
4972
4828
  }
4973
4829
  return "";
4974
4830
  }
4975
- function buildPrismaSkipJs(previewFeatures) {
4976
- if (previewFeatures.includes("strictUndefinedChecks")) {
4977
- return `
4978
- 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))
4979
4842
  `;
4980
4843
  }
4981
- return "";
4844
+ return preamble;
4982
4845
  }
4983
4846
 
4984
4847
  // src/TSClient/Count.ts
4985
4848
  var ts8 = __toESM(require("@prisma/ts-builders"));
4986
- var import_indent_string5 = __toESM(require("indent-string"));
4849
+ var import_indent_string4 = __toESM(require("indent-string"));
4987
4850
  var Count = class {
4988
4851
  constructor(type, context) {
4989
4852
  this.type = type;
@@ -5014,8 +4877,10 @@ var Count = class {
5014
4877
 
5015
4878
  ${ts8.stringify(outputType)}
5016
4879
 
5017
- export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
5018
- ${(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)(
5019
4884
  type.fields.map((field) => {
5020
4885
  const types = ["boolean"];
5021
4886
  if (field.outputType.location === "outputObjectTypes") {
@@ -5036,7 +4901,7 @@ ${this.argsTypes.map((typeExport) => ts8.stringify(typeExport)).join("\n\n")}
5036
4901
  }
5037
4902
  };
5038
4903
  function getCountArgsType(typeName, fieldName) {
5039
- return `${typeName}Count${capitalize2(fieldName)}Args`;
4904
+ return `${typeName}Count${capitalize3(fieldName)}Args`;
5040
4905
  }
5041
4906
 
5042
4907
  // src/TSClient/FieldRefInput.ts
@@ -5074,10 +4939,10 @@ var GenerateContext = class {
5074
4939
  };
5075
4940
 
5076
4941
  // src/TSClient/PrismaClient.ts
5077
- var import_client_common13 = require("@prisma/client-common");
5078
- var import_internals6 = require("@prisma/internals");
4942
+ var import_client_common14 = require("@prisma/client-common");
4943
+ var import_internals5 = require("@prisma/internals");
5079
4944
  var ts11 = __toESM(require("@prisma/ts-builders"));
5080
- var import_indent_string7 = __toESM(require("indent-string"));
4945
+ var import_indent_string6 = __toESM(require("indent-string"));
5081
4946
 
5082
4947
  // src/utils/runtimeImport.ts
5083
4948
  var ts9 = __toESM(require("@prisma/ts-builders"));
@@ -5089,7 +4954,7 @@ function runtimeImportedType(name) {
5089
4954
  }
5090
4955
 
5091
4956
  // src/TSClient/Datasources.ts
5092
- var import_indent_string6 = __toESM(require("indent-string"));
4957
+ var import_indent_string5 = __toESM(require("indent-string"));
5093
4958
  var Datasources = class {
5094
4959
  constructor(internalDatasources) {
5095
4960
  this.internalDatasources = internalDatasources;
@@ -5097,19 +4962,19 @@ var Datasources = class {
5097
4962
  toTS() {
5098
4963
  const sources = this.internalDatasources;
5099
4964
  return `export type Datasources = {
5100
- ${(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)}
5101
4966
  }`;
5102
4967
  }
5103
4968
  };
5104
4969
 
5105
4970
  // src/TSClient/globalOmit.ts
5106
- var import_client_common12 = require("@prisma/client-common");
4971
+ var import_client_common13 = require("@prisma/client-common");
5107
4972
  var ts10 = __toESM(require("@prisma/ts-builders"));
5108
4973
  function globalOmitConfig(dmmf) {
5109
4974
  const objectType9 = ts10.objectType().addMultiple(
5110
4975
  dmmf.datamodel.models.map((model) => {
5111
4976
  const type = ts10.namedType(getOmitName(model.name));
5112
- return ts10.property((0, import_client_common12.lowerCase)(model.name), type).optional();
4977
+ return ts10.property((0, import_client_common13.lowerCase)(model.name), type).optional();
5113
4978
  })
5114
4979
  );
5115
4980
  return ts10.moduleExport(ts10.typeDeclaration("GlobalOmitConfig", objectType9));
@@ -5122,7 +4987,7 @@ function clientTypeMapModelsDefinition(context) {
5122
4987
  if (modelNames.length === 0) {
5123
4988
  meta.add(ts11.property("modelProps", ts11.neverType));
5124
4989
  } else {
5125
- meta.add(ts11.property("modelProps", ts11.unionType(modelNames.map((name) => ts11.stringLiteral((0, import_client_common13.lowerCase)(name))))));
4990
+ meta.add(ts11.property("modelProps", ts11.unionType(modelNames.map((name) => ts11.stringLiteral((0, import_client_common14.lowerCase)(name))))));
5126
4991
  }
5127
4992
  const isolationLevel = context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma") ? ts11.namedType("Prisma.TransactionIsolationLevel") : ts11.neverType;
5128
4993
  meta.add(ts11.property("txIsolationLevel", isolationLevel));
@@ -5153,9 +5018,9 @@ function clientTypeMapModelsDefinition(context) {
5153
5018
  }
5154
5019
  function clientTypeMapModelsResultDefinition(modelName, action) {
5155
5020
  if (action === "count")
5156
- return ts11.unionType([ts11.optional(ts11.namedType(getCountAggregateOutputName(modelName))), ts11.numberType]);
5157
- if (action === "groupBy") return ts11.array(ts11.optional(ts11.namedType(getGroupByName(modelName))));
5158
- 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)));
5159
5024
  if (action === "findRaw") return ts11.namedType("JsonObject");
5160
5025
  if (action === "aggregateRaw") return ts11.namedType("JsonObject");
5161
5026
  if (action === "deleteMany") return ts11.namedType("BatchPayload");
@@ -5172,10 +5037,10 @@ function clientTypeMapModelsResultDefinition(modelName, action) {
5172
5037
  if (action === "update") return payloadToResult(modelName);
5173
5038
  if (action === "upsert") return payloadToResult(modelName);
5174
5039
  if (action === "delete") return payloadToResult(modelName);
5175
- (0, import_internals6.assertNever)(action, `Unknown action: ${action}`);
5040
+ (0, import_internals5.assertNever)(action, `Unknown action: ${action}`);
5176
5041
  }
5177
5042
  function payloadToResult(modelName) {
5178
- return ts11.namedType("$Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5043
+ return ts11.namedType("runtime.Types.Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5179
5044
  }
5180
5045
  function clientTypeMapOthersDefinition(context) {
5181
5046
  const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
@@ -5213,25 +5078,26 @@ function clientTypeMapOthersDefinition(context) {
5213
5078
  function clientTypeMapDefinition(context) {
5214
5079
  const typeMap = `${ts11.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
5215
5080
  return `
5216
- 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>> {
5217
5082
  returns: Prisma.TypeMap<this['params']['extArgs'], ClientOptions extends { omit: infer OmitOptions } ? OmitOptions : {}>
5218
5083
  }
5219
5084
 
5220
- 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}`;
5221
5086
  }
5222
5087
  function clientExtensionsDefinitions(context) {
5223
5088
  const typeMap = clientTypeMapDefinition(context);
5224
5089
  const define = ts11.moduleExport(
5225
- ts11.constDeclaration(
5226
- "defineExtension",
5227
- 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
+ )
5228
5094
  )
5229
5095
  );
5230
5096
  return [typeMap, ts11.stringify(define)].join("\n");
5231
5097
  }
5232
5098
  function extendsPropertyDefinition() {
5233
- const extendsDefinition = ts11.namedType("$Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("extends")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.namedType("ExtArgs")).addGenericArgument(
5234
- 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"))))
5235
5101
  );
5236
5102
  return ts11.stringify(ts11.property("$extends", extendsDefinition), { indentLevel: 1 });
5237
5103
  }
@@ -5250,7 +5116,7 @@ function batchingTransactionDefinition(context) {
5250
5116
 
5251
5117
  Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
5252
5118
  `
5253
- ).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"))));
5254
5120
  if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
5255
5121
  const options = ts11.objectType().formatInline().add(ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional());
5256
5122
  method3.addParameter(ts11.parameter("options", options).optional());
@@ -5263,7 +5129,7 @@ function interactiveTransactionDefinition(context) {
5263
5129
  const isolationLevel = ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional();
5264
5130
  options.add(isolationLevel);
5265
5131
  }
5266
- const returnType = ts11.promise(ts11.namedType("R"));
5132
+ const returnType = promise(ts11.namedType("R"));
5267
5133
  const callbackType = ts11.functionType().addParameter(
5268
5134
  ts11.parameter("prisma", ts11.omit(ts11.namedType("PrismaClient"), ts11.namedType("runtime.ITXClientDenyList")))
5269
5135
  ).setReturnType(returnType);
@@ -5349,7 +5215,7 @@ function queryRawTypedDefinition(context) {
5349
5215
  "typedSql",
5350
5216
  runtimeImportedType("TypedSql").addGenericArgument(ts11.array(ts11.unknownType)).addGenericArgument(param.toArgument())
5351
5217
  )
5352
- ).setReturnType(ts11.prismaPromise(ts11.array(param.toArgument())));
5218
+ ).setReturnType(prismaPromise(ts11.array(param.toArgument())));
5353
5219
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5354
5220
  }
5355
5221
  function metricDefinition(context) {
@@ -5374,7 +5240,7 @@ function runCommandRawDefinition(context) {
5374
5240
  if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
5375
5241
  return "";
5376
5242
  }
5377
- 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`
5378
5244
  Executes a raw MongoDB command and returns the result of it.
5379
5245
  @example
5380
5246
  \`\`\`
@@ -5393,25 +5259,24 @@ function applyPendingMigrationsDefinition() {
5393
5259
  if (this.runtimeName !== "react-native") {
5394
5260
  return null;
5395
5261
  }
5396
- const method3 = ts11.method("$applyPendingMigrations").setReturnType(ts11.promise(ts11.voidType)).setDocComment(
5262
+ const method3 = ts11.method("$applyPendingMigrations").setReturnType(promise(ts11.voidType)).setDocComment(
5397
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.`
5398
5264
  );
5399
5265
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5400
5266
  }
5401
5267
  function eventRegistrationMethodDeclaration(runtimeName) {
5402
5268
  if (runtimeName === "binary") {
5403
- 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;`;
5404
5270
  } else {
5405
5271
  return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
5406
5272
  }
5407
5273
  }
5408
5274
  var PrismaClientClass = class {
5409
- constructor(context, internalDatasources, outputDir, runtimeName, browser) {
5275
+ constructor(context, internalDatasources, outputDir, runtimeName) {
5410
5276
  this.context = context;
5411
5277
  this.internalDatasources = internalDatasources;
5412
5278
  this.outputDir = outputDir;
5413
5279
  this.runtimeName = runtimeName;
5414
- this.browser = browser;
5415
5280
  }
5416
5281
  get jsDoc() {
5417
5282
  const { dmmf } = this.context;
@@ -5425,44 +5290,49 @@ var PrismaClientClass = class {
5425
5290
  };
5426
5291
  }
5427
5292
  return `/**
5428
- * ## Prisma Client \u02B2\u02E2
5293
+ * ## Prisma Client
5429
5294
  *
5430
- * Type-safe database client for TypeScript & Node.js
5295
+ * Type-safe database client for TypeScript
5431
5296
  * @example
5432
5297
  * \`\`\`
5433
5298
  * const prisma = new PrismaClient()
5434
- * // Fetch zero or more ${capitalize2(example.plural)}
5435
- * const ${(0, import_client_common13.lowerCase)(example.plural)} = await prisma.${(0, import_client_common13.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()
5436
5301
  * \`\`\`
5437
5302
  *
5438
- *
5439
5303
  * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
5440
5304
  */`;
5441
5305
  }
5442
5306
  toTSWithoutNamespace() {
5443
5307
  const { dmmf } = this.context;
5444
- return `${this.jsDoc}
5445
- 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<
5446
5319
  ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
5447
5320
  U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
5448
- ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
5321
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
5449
5322
  > {
5450
5323
  [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
5451
5324
 
5452
- ${(0, import_indent_string7.default)(this.jsDoc, TAB_SIZE)}
5453
-
5454
- constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
5455
5325
  ${eventRegistrationMethodDeclaration(this.runtimeName)}
5456
5326
 
5457
5327
  /**
5458
5328
  * Connect with the database
5459
5329
  */
5460
- $connect(): $Utils.JsPromise<void>;
5330
+ $connect(): runtime.Types.Utils.JsPromise<void>;
5461
5331
 
5462
5332
  /**
5463
5333
  * Disconnect from the database
5464
5334
  */
5465
- $disconnect(): $Utils.JsPromise<void>;
5335
+ $disconnect(): runtime.Types.Utils.JsPromise<void>;
5466
5336
 
5467
5337
  /**
5468
5338
  * Add a middleware
@@ -5483,9 +5353,9 @@ ${[
5483
5353
  extendsPropertyDefinition()
5484
5354
  ].filter((d) => d !== null).join("\n").trim()}
5485
5355
 
5486
- ${(0, import_indent_string7.default)(
5356
+ ${(0, import_indent_string6.default)(
5487
5357
  dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
5488
- let methodName = (0, import_client_common13.lowerCase)(m.model);
5358
+ let methodName = (0, import_client_common14.lowerCase)(m.model);
5489
5359
  if (methodName === "constructor") {
5490
5360
  methodName = '["constructor"]';
5491
5361
  }
@@ -5494,15 +5364,17 @@ ${[
5494
5364
  * \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
5495
5365
  * Example usage:
5496
5366
  * \`\`\`ts
5497
- * // Fetch zero or more ${capitalize2(m.plural)}
5498
- * const ${(0, import_client_common13.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()
5499
5369
  * \`\`\`
5500
5370
  */
5501
5371
  get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
5502
5372
  }).join("\n\n"),
5503
5373
  2
5504
5374
  )}
5505
- }`;
5375
+ }
5376
+
5377
+ export const PrismaClient = runtime.getPrismaClient(config) as unknown as PrismaClientConstructor`;
5506
5378
  }
5507
5379
  toTS() {
5508
5380
  const clientOptions = this.buildClientOptions();
@@ -5580,11 +5452,8 @@ export type MiddlewareParams = {
5580
5452
  */
5581
5453
  export type Middleware<T = any> = (
5582
5454
  params: MiddlewareParams,
5583
- next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
5584
- ) => $Utils.JsPromise<T>
5585
-
5586
- // tested in getLogLevel.test.ts
5587
- export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
5455
+ next: (params: MiddlewareParams) => runtime.Types.Utils.JsPromise<T>,
5456
+ ) => runtime.Types.Utils.JsPromise<T>
5588
5457
 
5589
5458
  /**
5590
5459
  * \`PrismaClient\` proxy available in interactive transactions.
@@ -5664,7 +5533,7 @@ var TSClient = class {
5664
5533
  }
5665
5534
  dmmf;
5666
5535
  genericsInfo;
5667
- toJS() {
5536
+ toTS() {
5668
5537
  const {
5669
5538
  edge,
5670
5539
  binaryPaths,
@@ -5674,25 +5543,19 @@ var TSClient = class {
5674
5543
  runtimeBase,
5675
5544
  runtimeName,
5676
5545
  datasources,
5677
- deno,
5678
5546
  copyEngine = true,
5679
- envPaths,
5680
5547
  target,
5681
- activeProvider
5548
+ activeProvider,
5549
+ moduleFormat
5682
5550
  } = this.options;
5683
- const relativeEnvPaths = {
5684
- rootEnvPath: envPaths.rootEnvPath && (0, import_internals7.pathToPosix)(import_path2.default.relative(outputDir, envPaths.rootEnvPath)),
5685
- schemaEnvPath: envPaths.schemaEnvPath && (0, import_internals7.pathToPosix)(import_path2.default.relative(outputDir, envPaths.schemaEnvPath))
5686
- };
5687
- const clientEngineType = (0, import_internals7.getClientEngineType)(generator);
5551
+ const clientEngineType = (0, import_internals6.getClientEngineType)(generator);
5688
5552
  generator.config.engineType = clientEngineType;
5689
- const binaryTargets = clientEngineType === import_internals7.ClientEngineType.Library ? Object.keys(binaryPaths.libqueryEngine ?? {}) : Object.keys(binaryPaths.queryEngine ?? {});
5690
- 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");
5691
5555
  const datasourceFilePath = datasources[0].sourceFilePath;
5692
5556
  const config = {
5693
5557
  generator,
5694
- relativeEnvPaths,
5695
- 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))),
5696
5559
  clientVersion: this.options.clientVersion,
5697
5560
  engineVersion: this.options.engineVersion,
5698
5561
  datasourceNames: datasources.map((d) => d.name),
@@ -5704,44 +5567,24 @@ var TSClient = class {
5704
5567
  }, {}),
5705
5568
  inlineSchema,
5706
5569
  inlineSchemaHash,
5707
- copyEngine
5570
+ copyEngine,
5571
+ runtimeDataModel: { models: {}, enums: {}, types: {} },
5572
+ dirname: ""
5708
5573
  };
5709
- const relativeOutdir = import_path2.default.relative(process.cwd(), outputDir);
5710
- const code = `${commonCodeJS({ ...this.options, browser: false })}
5711
- ${buildRequirePath(edge)}
5712
-
5713
- /**
5714
- * Enums
5715
- */
5716
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5717
- ${this.dmmf.datamodel.enums.map((datamodelEnum) => new Enum((0, import_dmmf.datamodelEnumToSchemaEnum)(datamodelEnum), false).toJS()).join("\n\n")}
5718
-
5719
- ${new Enum(
5720
- {
5721
- name: "ModelName",
5722
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5723
- },
5724
- true
5725
- ).toJS()}
5574
+ const relativeOutdir = import_node_path.default.relative(process.cwd(), outputDir);
5575
+ const clientConfig = `
5726
5576
  /**
5727
5577
  * Create the Client
5728
5578
  */
5729
- const config = ${JSON.stringify(config, null, 2)}
5730
- ${buildDirname(edge, relativeOutdir)}
5579
+ const config: runtime.GetPrismaClientConfig = ${JSON.stringify(config, null, 2)}
5580
+ ${buildDirname(edge)}
5731
5581
  ${buildRuntimeDataModel(this.dmmf.datamodel, runtimeName)}
5732
- ${buildGetWasmModule({ component: "engine", runtimeBase, runtimeName, target, activeProvider })}
5733
- ${buildGetWasmModule({ component: "compiler", runtimeBase, runtimeName, target, activeProvider })}
5582
+ ${buildGetWasmModule({ component: "engine", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5583
+ ${buildGetWasmModule({ component: "compiler", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5734
5584
  ${buildInjectableEdgeEnv(edge, datasources)}
5735
- ${buildWarnEnvConflicts(edge, runtimeBase, runtimeName)}
5736
5585
  ${buildDebugInitialization(edge)}
5737
- const PrismaClient = getPrismaClient(config)
5738
- exports.PrismaClient = PrismaClient
5739
- Object.assign(exports, Prisma)${deno ? "\nexport { exports as default, Prisma, PrismaClient }" : ""}
5740
5586
  ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, relativeOutdir)}
5741
5587
  `;
5742
- return code;
5743
- }
5744
- toTS() {
5745
5588
  const context = new GenerateContext({
5746
5589
  dmmf: this.dmmf,
5747
5590
  genericArgsInfo: this.genericsInfo,
@@ -5751,8 +5594,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5751
5594
  context,
5752
5595
  this.options.datasources,
5753
5596
  this.options.outputDir,
5754
- this.options.runtimeName,
5755
- this.options.browser
5597
+ this.options.runtimeName
5756
5598
  );
5757
5599
  const commonCode = commonCodeTS(this.options);
5758
5600
  const modelAndTypes = Object.values(this.dmmf.typeAndModelMap).reduce((acc, modelOrType) => {
@@ -5771,7 +5613,9 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5771
5613
  ts12.moduleExport(ts12.typeDeclaration(datamodelEnum.name, ts12.namedType(`$Enums.${datamodelEnum.name}`)))
5772
5614
  ),
5773
5615
  ts12.stringify(
5774
- 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
+ )
5775
5619
  )
5776
5620
  );
5777
5621
  }
@@ -5780,7 +5624,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5780
5624
  const code = `
5781
5625
  /**
5782
5626
  * Client
5783
- **/
5627
+ */
5784
5628
 
5785
5629
  ${commonCode.tsWithoutNamespace()}
5786
5630
 
@@ -5795,10 +5639,13 @@ export namespace $Enums {
5795
5639
 
5796
5640
  ${modelEnumsAliases.join("\n\n")}
5797
5641
  ` : ""}
5642
+
5643
+ ${clientConfig}
5644
+
5798
5645
  ${prismaClientClass.toTSWithoutNamespace()}
5799
5646
 
5800
5647
  export namespace Prisma {
5801
- ${(0, import_indent_string8.default)(
5648
+ ${(0, import_indent_string7.default)(
5802
5649
  `${commonCode.ts()}
5803
5650
  ${new Enum(
5804
5651
  {
@@ -5867,74 +5714,15 @@ ${this.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputType,
5867
5714
  export type BatchPayload = {
5868
5715
  count: number
5869
5716
  }
5870
-
5871
- /**
5872
- * DMMF
5873
- */
5874
- export const dmmf: runtime.BaseDMMF
5875
5717
  `,
5876
5718
  2
5877
5719
  )}}`;
5878
5720
  return code;
5879
5721
  }
5880
- toBrowserJS() {
5881
- const code = `${commonCodeJS({
5882
- ...this.options,
5883
- runtimeName: "index-browser",
5884
- browser: true
5885
- })}
5886
- /**
5887
- * Enums
5888
- */
5889
-
5890
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5891
- ${this.dmmf.schema.enumTypes.model?.map((type) => new Enum(type, false).toJS()).join("\n\n") ?? ""}
5892
-
5893
- ${new Enum(
5894
- {
5895
- name: "ModelName",
5896
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5897
- },
5898
- true
5899
- ).toJS()}
5900
-
5901
- /**
5902
- * This is a stub Prisma Client that will error at runtime if called.
5903
- */
5904
- class PrismaClient {
5905
- constructor() {
5906
- return new Proxy(this, {
5907
- get(target, prop) {
5908
- let message
5909
- const runtime = getRuntime()
5910
- if (runtime.isEdge) {
5911
- message = \`PrismaClient is not configured to run in \${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
5912
- - Use Prisma Accelerate: https://pris.ly/d/accelerate
5913
- - Use Driver Adapters: https://pris.ly/d/driver-adapters
5914
- \`;
5915
- } else {
5916
- message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in \`' + runtime.prettyName + '\`).'
5917
- }
5918
-
5919
- message += \`
5920
- If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report\`
5921
-
5922
- throw new Error(message)
5923
- }
5924
- })
5925
- }
5926
- }
5927
-
5928
- exports.PrismaClient = PrismaClient
5929
-
5930
- Object.assign(exports, Prisma)
5931
- `;
5932
- return code;
5933
- }
5934
5722
  };
5935
5723
 
5936
5724
  // src/typedSql/buildDbEnums.ts
5937
- var import_internals8 = require("@prisma/internals");
5725
+ var import_internals7 = require("@prisma/internals");
5938
5726
  var ts13 = __toESM(require("@prisma/ts-builders"));
5939
5727
  var DbEnumsList = class {
5940
5728
  enums;
@@ -5952,14 +5740,14 @@ var DbEnumsList = class {
5952
5740
  }
5953
5741
  *validJsIdentifiers() {
5954
5742
  for (const dbEnum of this.enums) {
5955
- if ((0, import_internals8.isValidJsIdentifier)(dbEnum.name)) {
5743
+ if ((0, import_internals7.isValidJsIdentifier)(dbEnum.name)) {
5956
5744
  yield dbEnum;
5957
5745
  }
5958
5746
  }
5959
5747
  }
5960
5748
  *invalidJsIdentifiers() {
5961
5749
  for (const dbEnum of this.enums) {
5962
- if (!(0, import_internals8.isValidJsIdentifier)(dbEnum.name)) {
5750
+ if (!(0, import_internals7.isValidJsIdentifier)(dbEnum.name)) {
5963
5751
  yield dbEnum;
5964
5752
  }
5965
5753
  }
@@ -5967,23 +5755,12 @@ var DbEnumsList = class {
5967
5755
  };
5968
5756
  function buildDbEnums(list) {
5969
5757
  const file4 = ts13.file();
5970
- file4.add(buildInvalidIdentifierEnums(list));
5971
- file4.add(buildValidIdentifierEnums(list));
5972
- return ts13.stringify(file4);
5973
- }
5974
- function buildValidIdentifierEnums(list) {
5975
- const namespace3 = ts13.namespace("$DbEnums");
5976
- for (const dbEnum of list.validJsIdentifiers()) {
5977
- namespace3.add(ts13.typeDeclaration(dbEnum.name, enumToUnion(dbEnum)));
5978
- }
5979
- return ts13.moduleExport(namespace3);
5980
- }
5981
- function buildInvalidIdentifierEnums(list) {
5982
5758
  const iface = ts13.interfaceDeclaration("$DbEnums");
5983
- for (const dbEnum of list.invalidJsIdentifiers()) {
5759
+ for (const dbEnum of list.enums) {
5984
5760
  iface.add(ts13.property(dbEnum.name, enumToUnion(dbEnum)));
5985
5761
  }
5986
- return ts13.moduleExport(iface);
5762
+ file4.add(ts13.moduleExport(iface));
5763
+ return ts13.stringify(file4);
5987
5764
  }
5988
5765
  function enumToUnion(dbEnum) {
5989
5766
  return ts13.unionType(dbEnum.values.map(ts13.stringLiteral));
@@ -5997,41 +5774,21 @@ function queryUsesEnums(query, enums) {
5997
5774
 
5998
5775
  // src/typedSql/buildIndex.ts
5999
5776
  var ts14 = __toESM(require("@prisma/ts-builders"));
6000
- var import_ts_builders = require("@prisma/ts-builders");
6001
- function buildIndexTs(queries, enums) {
5777
+ function buildIndex({ queries, enums, importName }) {
6002
5778
  const file4 = ts14.file();
6003
5779
  if (!enums.isEmpty()) {
6004
- file4.add(ts14.moduleExportFrom("./$DbEnums").named("$DbEnums"));
5780
+ file4.add(ts14.moduleExportFrom(importName("./sql/$DbEnums")).named(ts14.namedExport("$DbEnums").typeOnly()));
6005
5781
  }
6006
5782
  for (const query of queries) {
6007
- file4.add(ts14.moduleExportFrom(`./${query.name}`));
5783
+ file4.add(ts14.moduleExportFrom(importName(`./sql/${query.name}`)));
6008
5784
  }
6009
5785
  return ts14.stringify(file4);
6010
5786
  }
6011
- function buildIndexCjs(queries, edgeRuntimeSuffix) {
6012
- const writer = new import_ts_builders.Writer(0, void 0);
6013
- writer.writeLine('"use strict"');
6014
- for (const { name } of queries) {
6015
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6016
- writer.writeLine(`exports.${name} = require("./${fileName}.js").${name}`);
6017
- }
6018
- return writer.toString();
6019
- }
6020
- function buildIndexEsm(queries, edgeRuntimeSuffix) {
6021
- const writer = new import_ts_builders.Writer(0, void 0);
6022
- for (const { name } of queries) {
6023
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6024
- writer.writeLine(`export * from "./${fileName}.mjs"`);
6025
- }
6026
- return writer.toString();
6027
- }
6028
5787
 
6029
5788
  // src/typedSql/buildTypedQuery.ts
6030
5789
  var ts16 = __toESM(require("@prisma/ts-builders"));
6031
- var import_ts_builders2 = require("@prisma/ts-builders");
6032
5790
 
6033
5791
  // src/typedSql/mapTypes.ts
6034
- var import_internals9 = require("@prisma/internals");
6035
5792
  var ts15 = __toESM(require("@prisma/ts-builders"));
6036
5793
  var decimal = ts15.namedType("$runtime.Decimal");
6037
5794
  var uint8Array = ts15.namedType("Uint8Array");
@@ -6125,18 +5882,15 @@ function getMappingConfig(introspectionType, enums) {
6125
5882
  return config;
6126
5883
  }
6127
5884
  function getEnumType(name) {
6128
- if ((0, import_internals9.isValidJsIdentifier)(name)) {
6129
- return ts15.namedType(`$DbEnums.${name}`);
6130
- }
6131
5885
  return ts15.namedType("$DbEnums").subKey(name);
6132
5886
  }
6133
5887
 
6134
5888
  // src/typedSql/buildTypedQuery.ts
6135
- function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
5889
+ function buildTypedQuery({ query, runtimeBase, runtimeName, enums, importName }) {
6136
5890
  const file4 = ts16.file();
6137
5891
  file4.addImport(ts16.moduleImport(`${runtimeBase}/${runtimeName}`).asNamespace("$runtime"));
6138
5892
  if (queryUsesEnums(query, enums)) {
6139
- file4.addImport(ts16.moduleImport("./$DbEnums").named("$DbEnums"));
5893
+ file4.addImport(ts16.moduleImport(importName("./$DbEnums")).named(ts16.namedImport("$DbEnums").typeOnly()));
6140
5894
  }
6141
5895
  const doc = ts16.docComment(query.documentation ?? void 0);
6142
5896
  const factoryType = ts16.functionType();
@@ -6154,11 +5908,17 @@ function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
6154
5908
  factoryType.setReturnType(
6155
5909
  ts16.namedType("$runtime.TypedSql").addGenericArgument(ts16.namedType(`${query.name}.Parameters`)).addGenericArgument(ts16.namedType(`${query.name}.Result`))
6156
5910
  );
6157
- file4.add(ts16.moduleExport(ts16.constDeclaration(query.name, factoryType)).setDocComment(doc));
6158
- const namespace3 = ts16.namespace(query.name);
6159
- namespace3.add(ts16.moduleExport(ts16.typeDeclaration("Parameters", parametersType)));
6160
- namespace3.add(buildResultType(query, enums));
6161
- 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));
6162
5922
  return ts16.stringify(file4);
6163
5923
  }
6164
5924
  function buildResultType(query, enums) {
@@ -6167,47 +5927,28 @@ function buildResultType(query, enums) {
6167
5927
  );
6168
5928
  return ts16.moduleExport(ts16.typeDeclaration("Result", type));
6169
5929
  }
6170
- function buildTypedQueryCjs({ query, runtimeBase, runtimeName }) {
6171
- const writer = new import_ts_builders2.Writer(0, void 0);
6172
- writer.writeLine('"use strict"');
6173
- writer.writeLine(`const { makeTypedQueryFactory: $mkFactory } = require("${runtimeBase}/${runtimeName}")`);
6174
- writer.writeLine(`exports.${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6175
- return writer.toString();
6176
- }
6177
- function buildTypedQueryEsm({ query, runtimeBase, runtimeName }) {
6178
- const writer = new import_ts_builders2.Writer(0, void 0);
6179
- writer.writeLine(`import { makeTypedQueryFactory as $mkFactory } from "${runtimeBase}/${runtimeName}"`);
6180
- writer.writeLine(`export const ${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6181
- return writer.toString();
6182
- }
6183
5930
 
6184
5931
  // src/typedSql/typedSql.ts
6185
5932
  function buildTypedSql({
6186
5933
  queries,
6187
5934
  runtimeBase,
6188
- edgeRuntimeName,
6189
- mainRuntimeName,
6190
- dmmf
5935
+ runtimeName,
5936
+ dmmf,
5937
+ outputName,
5938
+ importName
6191
5939
  }) {
6192
- const fileMap = {};
5940
+ const fileMap = {
5941
+ sql: {}
5942
+ };
6193
5943
  const enums = new DbEnumsList(dmmf.datamodel.enums);
6194
5944
  if (!enums.isEmpty()) {
6195
- fileMap["$DbEnums.d.ts"] = buildDbEnums(enums);
5945
+ fileMap.sql[outputName("$DbEnums")] = buildDbEnums(enums);
6196
5946
  }
6197
5947
  for (const query of queries) {
6198
- const options = { query, runtimeBase, runtimeName: mainRuntimeName, enums };
6199
- const edgeOptions = { ...options, runtimeName: `${edgeRuntimeName}.js` };
6200
- fileMap[`${query.name}.d.ts`] = buildTypedQueryTs(options);
6201
- fileMap[`${query.name}.js`] = buildTypedQueryCjs(options);
6202
- fileMap[`${query.name}.${edgeRuntimeName}.js`] = buildTypedQueryCjs(edgeOptions);
6203
- fileMap[`${query.name}.mjs`] = buildTypedQueryEsm(options);
6204
- fileMap[`${query.name}.edge.mjs`] = buildTypedQueryEsm(edgeOptions);
6205
- }
6206
- fileMap["index.d.ts"] = buildIndexTs(queries, enums);
6207
- fileMap["index.js"] = buildIndexCjs(queries);
6208
- fileMap["index.mjs"] = buildIndexEsm(queries);
6209
- fileMap[`index.${edgeRuntimeName}.mjs`] = buildIndexEsm(queries, edgeRuntimeName);
6210
- 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 });
6211
5952
  return fileMap;
6212
5953
  }
6213
5954
 
@@ -6218,7 +5959,7 @@ var DenylistError = class extends Error {
6218
5959
  this.stack = void 0;
6219
5960
  }
6220
5961
  };
6221
- (0, import_internals10.setClassName)(DenylistError, "DenylistError");
5962
+ (0, import_internals8.setClassName)(DenylistError, "DenylistError");
6222
5963
  function buildClient({
6223
5964
  schemaPath,
6224
5965
  runtimeBase,
@@ -6235,10 +5976,15 @@ function buildClient({
6235
5976
  copyEngine,
6236
5977
  envPaths,
6237
5978
  typedSql,
6238
- target
5979
+ target,
5980
+ generatedFileExtension,
5981
+ importFileExtension,
5982
+ moduleFormat
6239
5983
  }) {
6240
- const clientEngineType = (0, import_internals10.getClientEngineType)(generator);
5984
+ const clientEngineType = (0, import_internals8.getClientEngineType)(generator);
6241
5985
  const runtimeName = getRuntimeNameForTarget(target, clientEngineType, generator.previewFeatures);
5986
+ const outputName = generatedFileNameMapper(generatedFileExtension);
5987
+ const importName = importFileNameMapper(importFileExtension);
6242
5988
  const clientOptions = {
6243
5989
  dmmf: getPrismaClientDMMF(dmmf),
6244
5990
  envPaths: envPaths ?? { rootEnvPath: null, schemaEnvPath: void 0 },
@@ -6254,28 +6000,32 @@ function buildClient({
6254
6000
  postinstall,
6255
6001
  copyEngine,
6256
6002
  datamodel,
6257
- browser: false,
6258
- deno: false,
6259
6003
  edge: ["edge", "wasm", "react-native"].includes(runtimeName),
6260
6004
  runtimeName,
6261
- target
6005
+ target,
6006
+ generatedFileExtension,
6007
+ importFileExtension,
6008
+ moduleFormat
6262
6009
  };
6263
6010
  if (runtimeName === "react-native" && !generator.previewFeatures.includes("reactNative")) {
6264
6011
  throw new Error(`Using the "react-native" runtime requires the "reactNative" preview feature to be enabled.`);
6265
6012
  }
6266
6013
  const client = new TSClient(clientOptions);
6267
- const fileMap = {};
6268
- fileMap["index.js"] = client.toJS();
6269
- fileMap["index.d.ts"] = client.toTS();
6270
- const usesWasmRuntimeOnEdge = generator.previewFeatures.includes("driverAdapters");
6014
+ let fileMap = {};
6015
+ fileMap[outputName("client")] = client.toTS();
6016
+ fileMap[outputName("index")] = `export * from '${importName("./client")}'`;
6271
6017
  if (typedSql && typedSql.length > 0) {
6272
- fileMap["sql"] = buildTypedSql({
6273
- dmmf,
6274
- runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6275
- mainRuntimeName: getNodeRuntimeName(clientEngineType),
6276
- queries: typedSql,
6277
- edgeRuntimeName: usesWasmRuntimeOnEdge ? "wasm" : "edge"
6278
- });
6018
+ fileMap = {
6019
+ ...fileMap,
6020
+ ...buildTypedSql({
6021
+ dmmf,
6022
+ runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6023
+ runtimeName,
6024
+ queries: typedSql,
6025
+ outputName,
6026
+ importName
6027
+ })
6028
+ };
6279
6029
  }
6280
6030
  return {
6281
6031
  fileMap,
@@ -6308,9 +6058,12 @@ async function generateClient(options) {
6308
6058
  envPaths,
6309
6059
  copyEngine = true,
6310
6060
  typedSql,
6311
- target
6061
+ target,
6062
+ generatedFileExtension,
6063
+ importFileExtension,
6064
+ moduleFormat
6312
6065
  } = options;
6313
- const clientEngineType = (0, import_internals10.getClientEngineType)(generator);
6066
+ const clientEngineType = (0, import_internals8.getClientEngineType)(generator);
6314
6067
  const { runtimeBase, outputDir } = await getGenerationDirs(options);
6315
6068
  const { prismaClientDmmf, fileMap } = buildClient({
6316
6069
  datamodel,
@@ -6328,7 +6081,10 @@ async function generateClient(options) {
6328
6081
  copyEngine,
6329
6082
  envPaths,
6330
6083
  typedSql,
6331
- target
6084
+ target,
6085
+ generatedFileExtension,
6086
+ importFileExtension,
6087
+ moduleFormat
6332
6088
  });
6333
6089
  const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf);
6334
6090
  if (denylistsErrors) {
@@ -6346,41 +6102,27 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
6346
6102
  await deleteOutputDir(outputDir);
6347
6103
  await (0, import_fs_extra.ensureDir)(outputDir);
6348
6104
  await writeFileMap(outputDir, fileMap);
6349
- const enginePath = clientEngineType === import_internals10.ClientEngineType.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
6350
- if (!enginePath) {
6351
- throw new Error(
6352
- `Prisma Client needs \`${clientEngineType === import_internals10.ClientEngineType.Library ? "libqueryEngine" : "queryEngine"}\` in the \`binaryPaths\` object.`
6353
- );
6354
- }
6355
- if (copyEngine) {
6105
+ const enginePath = clientEngineType === import_internals8.ClientEngineType.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
6106
+ if (copyEngine && enginePath) {
6356
6107
  if (process.env.NETLIFY) {
6357
6108
  await (0, import_fs_extra.ensureDir)("/tmp/prisma-engines");
6358
6109
  }
6359
6110
  for (const [binaryTarget, filePath] of Object.entries(enginePath)) {
6360
- const fileName = import_node_path.default.basename(filePath);
6111
+ const fileName = import_node_path2.default.basename(filePath);
6361
6112
  let target2;
6362
6113
  if (process.env.NETLIFY && !["rhel-openssl-1.0.x", "rhel-openssl-3.0.x"].includes(binaryTarget)) {
6363
- target2 = import_node_path.default.join("/tmp/prisma-engines", fileName);
6114
+ target2 = import_node_path2.default.join("/tmp/prisma-engines", fileName);
6364
6115
  } else {
6365
- target2 = import_node_path.default.join(outputDir, fileName);
6116
+ target2 = import_node_path2.default.join(outputDir, fileName);
6366
6117
  }
6367
6118
  await (0, import_fetch_engine.overwriteFile)(filePath, target2);
6368
6119
  }
6369
6120
  }
6370
- const schemaTargetPath = import_node_path.default.join(outputDir, "schema.prisma");
6371
- await import_promises.default.writeFile(schemaTargetPath, datamodel, { encoding: "utf-8" });
6372
- try {
6373
- const prismaCache = (0, import_env_paths.default)("prisma").cache;
6374
- const signalsPath = import_node_path.default.join(prismaCache, "last-generate");
6375
- await import_promises.default.mkdir(prismaCache, { recursive: true });
6376
- await import_promises.default.writeFile(signalsPath, Date.now().toString());
6377
- } catch {
6378
- }
6379
6121
  }
6380
6122
  function writeFileMap(outputDir, fileMap) {
6381
6123
  return Promise.all(
6382
6124
  Object.entries(fileMap).map(async ([fileName, content]) => {
6383
- const absolutePath = import_node_path.default.join(outputDir, fileName);
6125
+ const absolutePath = import_node_path2.default.join(outputDir, fileName);
6384
6126
  await import_promises.default.rm(absolutePath, { recursive: true, force: true });
6385
6127
  if (typeof content === "string") {
6386
6128
  await import_promises.default.writeFile(absolutePath, content);
@@ -6469,10 +6211,10 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
6469
6211
  return errorArray.length > 0 ? errorArray : null;
6470
6212
  }
6471
6213
  async function getGenerationDirs({ runtimeBase, outputDir }) {
6472
- const normalizedOutputDir = import_node_path.default.normalize(outputDir);
6473
- const normalizedRuntimeBase = (0, import_internals10.pathToPosix)(runtimeBase);
6474
- const userPackageRoot = await (0, import_pkg_up.default)({ cwd: import_node_path.default.dirname(normalizedOutputDir) });
6475
- 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();
6476
6218
  return {
6477
6219
  runtimeBase: normalizedRuntimeBase,
6478
6220
  outputDir: normalizedOutputDir,
@@ -6496,17 +6238,17 @@ function getRuntimeNameForTarget(target, engineType, previewFeatures) {
6496
6238
  case "react-native":
6497
6239
  return "react-native";
6498
6240
  default:
6499
- (0, import_internals10.assertNever)(target, "Unknown runtime target");
6241
+ (0, import_internals8.assertNever)(target, "Unknown runtime target");
6500
6242
  }
6501
6243
  }
6502
6244
  function getNodeRuntimeName(engineType) {
6503
- if (engineType === import_internals10.ClientEngineType.Binary) {
6245
+ if (engineType === import_internals8.ClientEngineType.Binary) {
6504
6246
  return "binary";
6505
6247
  }
6506
- if (engineType === import_internals10.ClientEngineType.Library) {
6248
+ if (engineType === import_internals8.ClientEngineType.Library) {
6507
6249
  return "library";
6508
6250
  }
6509
- if (engineType === import_internals10.ClientEngineType.Client) {
6251
+ if (engineType === import_internals8.ClientEngineType.Client) {
6510
6252
  if (!process.env.PRISMA_UNSTABLE_CLIENT_ENGINE_TYPE) {
6511
6253
  throw new Error(
6512
6254
  'Unstable Feature: engineType="client" is in a proof of concept phase and not ready to be used publicly yet!'
@@ -6514,7 +6256,7 @@ function getNodeRuntimeName(engineType) {
6514
6256
  }
6515
6257
  return "client";
6516
6258
  }
6517
- (0, import_internals10.assertNever)(engineType, "Unknown engine type");
6259
+ (0, import_internals8.assertNever)(engineType, "Unknown engine type");
6518
6260
  }
6519
6261
  async function deleteOutputDir(outputDir) {
6520
6262
  try {
@@ -6522,15 +6264,13 @@ async function deleteOutputDir(outputDir) {
6522
6264
  if (files.length === 0) {
6523
6265
  return;
6524
6266
  }
6525
- if (!files.includes("index.d.ts")) {
6267
+ if (!files.includes("client.ts") && !files.includes("client.mts") && !files.includes("client.cts")) {
6526
6268
  throw new Error(
6527
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.`
6528
6270
  );
6529
6271
  }
6530
6272
  await Promise.allSettled(
6531
- (await (0, import_fast_glob.glob)(`${outputDir}/**/*.ts`, {
6532
- globstar: true,
6533
- onlyFiles: true,
6273
+ (await (0, import_fast_glob.glob)([`${outputDir}/**/*.{ts,mts,cts}`, `${outputDir}/*.node`, `${outputDir}/{query,schema}-engine-*`], {
6534
6274
  followSymbolicLinks: false
6535
6275
  })).map(import_promises.default.unlink)
6536
6276
  );
@@ -6542,13 +6282,54 @@ async function deleteOutputDir(outputDir) {
6542
6282
  }
6543
6283
 
6544
6284
  // src/generator.ts
6545
- var import_debug = __toESM(require("@prisma/debug"));
6285
+ var import_debug = require("@prisma/debug");
6546
6286
  var import_engines_version = require("@prisma/engines-version");
6547
- var import_internals11 = require("@prisma/internals");
6287
+ var import_internals9 = require("@prisma/internals");
6288
+ var import_get_tsconfig = require("get-tsconfig");
6548
6289
  var import_ts_pattern2 = require("ts-pattern");
6549
6290
 
6550
6291
  // package.json
6551
- var version = "6.6.0-dev.96";
6292
+ var version = "6.6.0-dev.98";
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
+ }
6552
6333
 
6553
6334
  // src/runtime-targets.ts
6554
6335
  var supportedRuntimes = ["nodejs", "deno", "deno-deploy", "bun", "workerd", "edge-light", "react-native"];
@@ -6585,7 +6366,7 @@ function parseRuntimeTargetFromUnknown(target) {
6585
6366
  }
6586
6367
 
6587
6368
  // src/generator.ts
6588
- var debug = (0, import_debug.default)("prisma:client:generator");
6369
+ var debug = (0, import_debug.Debug)("prisma:client:generator");
6589
6370
  var missingOutputErrorMessage = `An output path is required for the \`prisma-client-ts\` generator. Please provide an output path in your schema file:
6590
6371
 
6591
6372
  ${dim(`generator client {
@@ -6599,12 +6380,12 @@ function getOutputPath(config) {
6599
6380
  if (!config.output) {
6600
6381
  throw new Error(missingOutputErrorMessage);
6601
6382
  }
6602
- return (0, import_internals11.parseEnvValue)(config.output);
6383
+ return (0, import_internals9.parseEnvValue)(config.output);
6603
6384
  }
6604
6385
  var PrismaClientTsGenerator = class {
6605
6386
  name = "prisma-client-ts";
6606
6387
  getManifest(config) {
6607
- const requiresEngines = (0, import_ts_pattern2.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();
6608
6389
  debug("requiresEngines", requiresEngines);
6609
6390
  return Promise.resolve({
6610
6391
  defaultOutput: getOutputPath(config),
@@ -6615,13 +6396,27 @@ var PrismaClientTsGenerator = class {
6615
6396
  });
6616
6397
  }
6617
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
+ });
6618
6413
  await generateClient({
6619
6414
  datamodel: options.datamodel,
6620
6415
  schemaPath: options.schemaPath,
6621
6416
  binaryPaths: options.binaryPaths,
6622
6417
  datasources: options.datasources,
6623
6418
  envPaths: options.envPaths,
6624
- outputDir: getOutputPath(options.generator),
6419
+ outputDir,
6625
6420
  runtimeBase: "@prisma/client/runtime",
6626
6421
  dmmf: options.dmmf,
6627
6422
  generator: options.generator,
@@ -6631,49 +6426,16 @@ var PrismaClientTsGenerator = class {
6631
6426
  postinstall: options.postinstall,
6632
6427
  copyEngine: !options.noEngine,
6633
6428
  typedSql: options.typedSql,
6634
- target: options.generator.config.runtime !== void 0 ? parseRuntimeTargetFromUnknown(options.generator.config.runtime) : "nodejs"
6429
+ target,
6430
+ generatedFileExtension,
6431
+ importFileExtension,
6432
+ moduleFormat
6635
6433
  });
6636
6434
  }
6637
6435
  };
6638
-
6639
- // src/utils/types/dmmfToTypes.ts
6640
- function dmmfToTypes(dmmf) {
6641
- return new TSClient({
6642
- dmmf,
6643
- datasources: [],
6644
- clientVersion: "",
6645
- engineVersion: "",
6646
- runtimeBase: "@prisma/client",
6647
- runtimeName: "library",
6648
- schemaPath: "",
6649
- outputDir: "",
6650
- activeProvider: "",
6651
- binaryPaths: {},
6652
- generator: {
6653
- binaryTargets: [],
6654
- config: {},
6655
- name: "prisma-client-ts",
6656
- output: null,
6657
- provider: { value: "prisma-client-ts", fromEnvVar: null },
6658
- previewFeatures: [],
6659
- isCustomOutput: false,
6660
- sourceFilePath: "schema.prisma"
6661
- },
6662
- datamodel: "",
6663
- browser: false,
6664
- deno: false,
6665
- edge: false,
6666
- envPaths: {
6667
- rootEnvPath: null,
6668
- schemaEnvPath: void 0
6669
- },
6670
- target: "nodejs"
6671
- }).toTS();
6672
- }
6673
6436
  // Annotate the CommonJS export names for ESM import in node:
6674
6437
  0 && (module.exports = {
6675
6438
  PrismaClientTsGenerator,
6676
- dmmfToTypes,
6677
6439
  externalToInternalDmmf,
6678
6440
  generateClient,
6679
6441
  getDMMF