@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.mjs CHANGED
@@ -2220,10 +2220,9 @@ import {
2220
2220
  assertNever as assertNever3,
2221
2221
  ClientEngineType as ClientEngineType3,
2222
2222
  getClientEngineType as getClientEngineType2,
2223
- pathToPosix as pathToPosix4,
2223
+ pathToPosix as pathToPosix3,
2224
2224
  setClassName
2225
2225
  } from "@prisma/internals";
2226
- import paths from "env-paths";
2227
2226
  import { glob } from "fast-glob";
2228
2227
 
2229
2228
  // ../../node_modules/.pnpm/kleur@4.1.5/node_modules/kleur/colors.mjs
@@ -2277,6 +2276,75 @@ var bgWhite = init(47, 49);
2277
2276
  // src/generateClient.ts
2278
2277
  import pkgUp from "pkg-up";
2279
2278
 
2279
+ // src/file-extensions.ts
2280
+ import { capitalize as capitalize2 } from "@prisma/client-common";
2281
+ var expectedGeneratedFileExtensions = ["ts", "mts", "cts"];
2282
+ var expectedImportFileExtensions = ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
2283
+ function validateFileExtension(extension, kind, recommended) {
2284
+ if (!recommended.includes(extension) && !process.env.PRISMA_DISABLE_WARNINGS) {
2285
+ console.warn(
2286
+ `${capitalize2(kind)} file extension ${JSON.stringify(
2287
+ extension
2288
+ )} is unexpected and may be a mistake. Expected one of: ${recommended.map((ext) => JSON.stringify(ext)).join(", ")}`
2289
+ );
2290
+ }
2291
+ return extension;
2292
+ }
2293
+ function parseFileExtensionFromUnknown(extension, kind, recommended) {
2294
+ if (typeof extension === "string") {
2295
+ return validateFileExtension(extension, kind, recommended);
2296
+ }
2297
+ throw new Error(`Invalid ${kind} file extension: ${JSON.stringify(extension)}, expected a string`);
2298
+ }
2299
+ function parseGeneratedFileExtension(extension) {
2300
+ return parseFileExtensionFromUnknown(extension, "generated", expectedGeneratedFileExtensions);
2301
+ }
2302
+ function parseImportFileExtension(extension) {
2303
+ return parseFileExtensionFromUnknown(extension, "import", expectedImportFileExtensions);
2304
+ }
2305
+ function extensionToSuffix(extension) {
2306
+ return extension === "" ? "" : `.${extension}`;
2307
+ }
2308
+ function generatedFileNameMapper(generatedFileExtension) {
2309
+ return (baseName) => baseName + extensionToSuffix(generatedFileExtension);
2310
+ }
2311
+ function importFileNameMapper(importFileExtension) {
2312
+ return (baseName) => baseName + extensionToSuffix(importFileExtension);
2313
+ }
2314
+ function inferImportFileExtension({
2315
+ tsconfig,
2316
+ generatedFileExtension
2317
+ }) {
2318
+ if (tsconfig) {
2319
+ return inferImportFileExtensionFromTsConfig(tsconfig, generatedFileExtension);
2320
+ }
2321
+ return generatedFileExtension;
2322
+ }
2323
+ function inferImportFileExtensionFromTsConfig(tsconfig, generatedFileExtension) {
2324
+ if (tsconfig.compilerOptions?.allowImportingTsExtensions || // @ts-expect-error `get-tsconfig` types don't yet include the new option introduced in TypeScript 5.7
2325
+ tsconfig.compilerOptions?.rewriteRelativeImportExtensions) {
2326
+ return generatedFileExtension;
2327
+ }
2328
+ const moduleResolution = tsconfig.compilerOptions?.moduleResolution?.toLowerCase();
2329
+ const module = tsconfig.compilerOptions?.module?.toLowerCase();
2330
+ if (moduleResolution !== void 0 && moduleResolution !== "classic" && module === "commonjs") {
2331
+ return "";
2332
+ }
2333
+ return matchingJsExtension(generatedFileExtension);
2334
+ }
2335
+ function matchingJsExtension(generatedFileExtension) {
2336
+ switch (generatedFileExtension) {
2337
+ case "ts":
2338
+ return "js";
2339
+ case "mts":
2340
+ return "mjs";
2341
+ case "cts":
2342
+ return "cjs";
2343
+ default:
2344
+ return generatedFileExtension;
2345
+ }
2346
+ }
2347
+
2280
2348
  // src/getDMMF.ts
2281
2349
  import { getDMMF as getRawDMMF } from "@prisma/internals";
2282
2350
  function getPrismaClientDMMF(dmmf) {
@@ -2306,28 +2374,19 @@ var Enum = class {
2306
2374
  isStrictEnum() {
2307
2375
  return this.useNamespace && strictEnumNames.includes(this.type.name);
2308
2376
  }
2309
- toJS() {
2310
- const { type } = this;
2311
- const enumVariants = `{
2312
- ${indent(type.values.map((v) => `${v}: ${this.getValueJS(v)}`).join(",\n"), TAB_SIZE)}
2313
- }`;
2314
- const enumBody = this.isStrictEnum() ? `makeStrictEnum(${enumVariants})` : enumVariants;
2315
- return this.useNamespace ? `exports.Prisma.${type.name} = ${enumBody};` : `exports.${type.name} = exports.$Enums.${type.name} = ${enumBody};`;
2316
- }
2317
- getValueJS(value) {
2318
- return this.isObjectEnum() ? `Prisma.${value}` : `'${value}'`;
2319
- }
2320
2377
  toTS() {
2321
2378
  const { type } = this;
2322
- return `export const ${type.name}: {
2323
- ${indent(type.values.map((v) => `${v}: ${this.getValueTS(v)}`).join(",\n"), TAB_SIZE)}
2324
- };
2379
+ const enumVariants = `{
2380
+ ${indent(type.values.map((v) => `${v}: ${this.getValue(v)}`).join(",\n"), TAB_SIZE)}
2381
+ } as const`;
2382
+ const enumBody = this.isStrictEnum() ? `runtime.makeStrictEnum(${enumVariants})` : enumVariants;
2383
+ return `export const ${type.name} = ${enumBody}
2325
2384
 
2326
2385
  export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]
2327
2386
  `;
2328
2387
  }
2329
- getValueTS(value) {
2330
- return this.isObjectEnum() ? `typeof ${value}` : `'${value}'`;
2388
+ getValue(value) {
2389
+ return this.isObjectEnum() ? value : `'${value}'`;
2331
2390
  }
2332
2391
  };
2333
2392
 
@@ -2368,28 +2427,28 @@ function getOmitName(modelName) {
2368
2427
  return `${modelName}Omit`;
2369
2428
  }
2370
2429
  function getAggregateName(modelName) {
2371
- return `Aggregate${capitalize2(modelName)}`;
2430
+ return `Aggregate${capitalize3(modelName)}`;
2372
2431
  }
2373
2432
  function getGroupByName(modelName) {
2374
- return `${capitalize2(modelName)}GroupByOutputType`;
2433
+ return `${capitalize3(modelName)}GroupByOutputType`;
2375
2434
  }
2376
2435
  function getAvgAggregateName(modelName) {
2377
- return `${capitalize2(modelName)}AvgAggregateOutputType`;
2436
+ return `${capitalize3(modelName)}AvgAggregateOutputType`;
2378
2437
  }
2379
2438
  function getSumAggregateName(modelName) {
2380
- return `${capitalize2(modelName)}SumAggregateOutputType`;
2439
+ return `${capitalize3(modelName)}SumAggregateOutputType`;
2381
2440
  }
2382
2441
  function getMinAggregateName(modelName) {
2383
- return `${capitalize2(modelName)}MinAggregateOutputType`;
2442
+ return `${capitalize3(modelName)}MinAggregateOutputType`;
2384
2443
  }
2385
2444
  function getMaxAggregateName(modelName) {
2386
- return `${capitalize2(modelName)}MaxAggregateOutputType`;
2445
+ return `${capitalize3(modelName)}MaxAggregateOutputType`;
2387
2446
  }
2388
2447
  function getCountAggregateInputName(modelName) {
2389
- return `${capitalize2(modelName)}CountAggregateInputType`;
2448
+ return `${capitalize3(modelName)}CountAggregateInputType`;
2390
2449
  }
2391
2450
  function getCountAggregateOutputName(modelName) {
2392
- return `${capitalize2(modelName)}CountAggregateOutputType`;
2451
+ return `${capitalize3(modelName)}CountAggregateOutputType`;
2393
2452
  }
2394
2453
  function getAggregateInputType(aggregateOutputType) {
2395
2454
  return aggregateOutputType.replace(/OutputType$/, "InputType");
@@ -2398,13 +2457,13 @@ function getGroupByArgsName(modelName) {
2398
2457
  return `${modelName}GroupByArgs`;
2399
2458
  }
2400
2459
  function getGroupByPayloadName(modelName) {
2401
- return `Get${capitalize2(modelName)}GroupByPayload`;
2460
+ return `Get${capitalize3(modelName)}GroupByPayload`;
2402
2461
  }
2403
2462
  function getAggregateArgsName(modelName) {
2404
- return `${capitalize2(modelName)}AggregateArgs`;
2463
+ return `${capitalize3(modelName)}AggregateArgs`;
2405
2464
  }
2406
2465
  function getAggregateGetName(modelName) {
2407
- return `Get${capitalize2(modelName)}AggregateType`;
2466
+ return `Get${capitalize3(modelName)}AggregateType`;
2408
2467
  }
2409
2468
  function getFieldArgName(field, modelName) {
2410
2469
  if (field.args.length) {
@@ -2462,8 +2521,8 @@ function getModelArgName(modelName, action) {
2462
2521
  assertNever(action, `Unknown action: ${action}`);
2463
2522
  }
2464
2523
  }
2465
- function getPayloadName(modelName, namespace3 = true) {
2466
- if (namespace3) {
2524
+ function getPayloadName(modelName, namespace2 = true) {
2525
+ if (namespace2) {
2467
2526
  return `Prisma.${getPayloadName(modelName, false)}`;
2468
2527
  }
2469
2528
  return `$${modelName}Payload`;
@@ -2471,7 +2530,7 @@ function getPayloadName(modelName, namespace3 = true) {
2471
2530
  function getFieldRefsTypeName(name) {
2472
2531
  return `${name}FieldRefs`;
2473
2532
  }
2474
- function capitalize2(str) {
2533
+ function capitalize3(str) {
2475
2534
  return str[0].toUpperCase() + str.slice(1);
2476
2535
  }
2477
2536
  function getRefAllowedTypeName(type) {
@@ -2483,11 +2542,11 @@ function getRefAllowedTypeName(type) {
2483
2542
  }
2484
2543
  function appendSkipType(context, type) {
2485
2544
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
2486
- return ts.unionType([type, ts.namedType("$Types.Skip")]);
2545
+ return ts.unionType([type, ts.namedType("runtime.Types.Skip")]);
2487
2546
  }
2488
2547
  return type;
2489
2548
  }
2490
- var extArgsParam = ts.genericParameter("ExtArgs").extends(ts.namedType("$Extensions.InternalArgs")).default(ts.namedType("$Extensions.DefaultArgs"));
2549
+ var extArgsParam = ts.genericParameter("ExtArgs").extends(ts.namedType("runtime.Types.Extensions.InternalArgs")).default(ts.namedType("runtime.Types.Extensions.DefaultArgs"));
2491
2550
 
2492
2551
  // src/utils/common.ts
2493
2552
  function needsNamespace(field) {
@@ -2645,11 +2704,11 @@ import { klona } from "klona";
2645
2704
  import * as ts3 from "@prisma/ts-builders";
2646
2705
 
2647
2706
  // src/TSClient/helpers.ts
2648
- import { capitalize as capitalize4, lowerCase as lowerCase3 } from "@prisma/client-common";
2707
+ import { capitalize as capitalize5, lowerCase as lowerCase3 } from "@prisma/client-common";
2649
2708
  import pluralize2 from "pluralize";
2650
2709
 
2651
2710
  // src/TSClient/jsdoc.ts
2652
- import { capitalize as capitalize3, lowerCase as lowerCase2 } from "@prisma/client-common";
2711
+ import { capitalize as capitalize4, lowerCase as lowerCase2 } from "@prisma/client-common";
2653
2712
  var Docs = {
2654
2713
  cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
2655
2714
  pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
@@ -2736,7 +2795,7 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
2736
2795
  body: (ctx) => {
2737
2796
  const onlySelect = ctx.firstScalar ? `
2738
2797
  // Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
2739
- const ${lowerCase2(ctx.mapping.model)}With${capitalize3(ctx.firstScalar.name)}Only = await ${ctx.method}({
2798
+ const ${lowerCase2(ctx.mapping.model)}With${capitalize4(ctx.firstScalar.name)}Only = await ${ctx.method}({
2740
2799
  select: { ${ctx.firstScalar.name}: true },
2741
2800
  data: [
2742
2801
  // ... provide data here
@@ -2833,7 +2892,7 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
2833
2892
  body: (ctx) => {
2834
2893
  const onlySelect = ctx.firstScalar ? `
2835
2894
  // Only select the \`${ctx.firstScalar.name}\`
2836
- const ${lowerCase2(ctx.mapping.model)}With${capitalize3(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
2895
+ const ${lowerCase2(ctx.mapping.model)}With${capitalize4(ctx.firstScalar.name)}Only = await ${ctx.method}({ select: { ${ctx.firstScalar.name}: true } })` : "";
2837
2896
  return `Find zero or more ${ctx.plural} that matches the filter.
2838
2897
  ${undefinedNote}
2839
2898
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
@@ -2991,7 +3050,7 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
2991
3050
  body: (ctx) => {
2992
3051
  const onlySelect = ctx.firstScalar ? `
2993
3052
  // Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
2994
- const ${lowerCase2(ctx.mapping.model)}With${capitalize3(ctx.firstScalar.name)}Only = await ${ctx.method}({
3053
+ const ${lowerCase2(ctx.mapping.model)}With${capitalize4(ctx.firstScalar.name)}Only = await ${ctx.method}({
2995
3054
  select: { ${ctx.firstScalar.name}: true },
2996
3055
  where: {
2997
3056
  // ... provide filter here
@@ -3070,8 +3129,8 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
3070
3129
  // src/TSClient/helpers.ts
3071
3130
  function getMethodJSDocBody(action, mapping, model) {
3072
3131
  const ctx = {
3073
- singular: capitalize4(mapping.model),
3074
- plural: capitalize4(mapping.plural),
3132
+ singular: capitalize5(mapping.model),
3133
+ plural: capitalize5(mapping.plural),
3075
3134
  firstScalar: model.fields.find((f) => f.kind === "scalar"),
3076
3135
  method: `prisma.${lowerCase3(mapping.model)}.${action}`,
3077
3136
  action,
@@ -3115,7 +3174,6 @@ var ArgsTypeBuilder = class {
3115
3174
  ).setDocComment(ts3.docComment(`${type.name} ${action ?? "without action"}`));
3116
3175
  }
3117
3176
  moduleExport;
3118
- hasDefaultName = true;
3119
3177
  addProperty(prop) {
3120
3178
  this.moduleExport.declaration.type.add(prop);
3121
3179
  }
@@ -3165,7 +3223,6 @@ var ArgsTypeBuilder = class {
3165
3223
  return this;
3166
3224
  }
3167
3225
  setGeneratedName(name) {
3168
- this.hasDefaultName = false;
3169
3226
  this.moduleExport.declaration.setName(name);
3170
3227
  return this;
3171
3228
  }
@@ -3190,7 +3247,7 @@ var ModelFieldRefs = class {
3190
3247
  /**
3191
3248
  * Fields of the ${name} model
3192
3249
  */
3193
- interface ${getFieldRefsTypeName(name)} {
3250
+ export interface ${getFieldRefsTypeName(name)} {
3194
3251
  ${this.stringifyFields()}
3195
3252
  }
3196
3253
  `;
@@ -3265,8 +3322,8 @@ function buildOutputField(field) {
3265
3322
  }
3266
3323
  function enumTypeName(ref) {
3267
3324
  const name = ref.type;
3268
- const namespace3 = ref.namespace === "model" ? "$Enums" : "Prisma";
3269
- return `${namespace3}.${name}`;
3325
+ const namespace2 = ref.namespace === "model" ? "$Enums" : "Prisma";
3326
+ return `${namespace2}.${name}`;
3270
3327
  }
3271
3328
 
3272
3329
  // src/TSClient/Payload.ts
@@ -3288,7 +3345,7 @@ function buildModelPayload(model, context) {
3288
3345
  scalars.add(buildModelOutputProperty(field, context.dmmf));
3289
3346
  }
3290
3347
  }
3291
- const scalarsType = isComposite ? scalars : ts5.namedType("$Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts5.namedType("ExtArgs").subKey("result").subKey(lowerCase4(model.name)));
3348
+ const scalarsType = isComposite ? scalars : ts5.namedType("runtime.Types.Extensions.GetPayloadResult").addGenericArgument(scalars).addGenericArgument(ts5.namedType("ExtArgs").subKey("result").subKey(lowerCase4(model.name)));
3292
3349
  const payloadTypeDeclaration = ts5.typeDeclaration(
3293
3350
  getPayloadName(model.name, false),
3294
3351
  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))
@@ -3317,9 +3374,9 @@ function buildOmitType({ modelName, fields, context }) {
3317
3374
  (field) => field.outputType.location === "scalar" || field.outputType.location === "enumTypes" || context.dmmf.isComposite(field.outputType.type)
3318
3375
  ).map((field) => ts6.stringLiteral(field.name))
3319
3376
  );
3320
- const omitType = ts6.namedType("$Extensions.GetOmit").addGenericArgument(keysType).addGenericArgument(modelResultExtensionsType(modelName));
3377
+ const omitType = ts6.namedType("runtime.Types.Extensions.GetOmit").addGenericArgument(keysType).addGenericArgument(modelResultExtensionsType(modelName));
3321
3378
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
3322
- omitType.addGenericArgument(ts6.namedType("$Types.Skip"));
3379
+ omitType.addGenericArgument(ts6.namedType("runtime.Types.Skip"));
3323
3380
  }
3324
3381
  return buildExport(getOmitName(modelName), omitType);
3325
3382
  }
@@ -3330,7 +3387,7 @@ function buildSelectType({
3330
3387
  context
3331
3388
  }) {
3332
3389
  const objectType9 = buildSelectOrIncludeObject(modelName, fields, context);
3333
- const selectType = ts6.namedType("$Extensions.GetSelect").addGenericArgument(objectType9).addGenericArgument(modelResultExtensionsType(modelName));
3390
+ const selectType = ts6.namedType("runtime.Types.Extensions.GetSelect").addGenericArgument(objectType9).addGenericArgument(modelResultExtensionsType(modelName));
3334
3391
  return buildExport(typeName, selectType);
3335
3392
  }
3336
3393
  function modelResultExtensionsType(modelName) {
@@ -3382,6 +3439,18 @@ function getModelActions(dmmf, name) {
3382
3439
  return mappingKeys;
3383
3440
  }
3384
3441
 
3442
+ // src/TSClient/utils/type-builders.ts
3443
+ import { NamedType } from "@prisma/ts-builders";
3444
+ function promise(resultType) {
3445
+ return new NamedType("runtime.Types.Utils.JsPromise").addGenericArgument(resultType);
3446
+ }
3447
+ function prismaPromise(resultType) {
3448
+ return new NamedType("Prisma.PrismaPromise").addGenericArgument(resultType);
3449
+ }
3450
+ function optional(innerType) {
3451
+ return new NamedType("runtime.Types.Utils.Optional").addGenericArgument(innerType);
3452
+ }
3453
+
3385
3454
  // src/TSClient/Model.ts
3386
3455
  var Model = class {
3387
3456
  constructor(model, context) {
@@ -3471,7 +3540,7 @@ var Model = class {
3471
3540
  return `
3472
3541
 
3473
3542
 
3474
- export type ${groupByArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3543
+ export type ${groupByArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3475
3544
  ${indent3(
3476
3545
  groupByRootField.args.map((arg) => {
3477
3546
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.groupBy, arg) };
@@ -3564,7 +3633,7 @@ ${aggregateTypes.length > 1 ? aggregateTypes.slice(1).map((type) => {
3564
3633
  return new InputType(newType, this.context).toTS();
3565
3634
  }).join("\n") : ""}
3566
3635
 
3567
- export type ${aggregateArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3636
+ export type ${aggregateArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3568
3637
  ${indent3(
3569
3638
  aggregateRootField.args.map((arg) => {
3570
3639
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.aggregate, arg) };
@@ -3603,7 +3672,7 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
3603
3672
  const modelTypeExport = ts7.moduleExport(
3604
3673
  ts7.typeDeclaration(
3605
3674
  model.name,
3606
- ts7.namedType(`$Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3675
+ ts7.namedType(`runtime.Types.Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3607
3676
  )
3608
3677
  ).setDocComment(ts7.docComment(docs));
3609
3678
  return ts7.stringify(modelTypeExport);
@@ -3681,9 +3750,9 @@ ${omitType}${includeType}${createManyAndReturnIncludeType}${updateManyAndReturnI
3681
3750
 
3682
3751
  ${ts7.stringify(buildModelPayload(this.model, this.context), { newLine: "none" })}
3683
3752
 
3684
- type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3753
+ export type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3685
3754
  model.name
3686
- )}> = $Result.GetResult<${getPayloadName(model.name)}, S>
3755
+ )}> = runtime.Types.Result.GetResult<${getPayloadName(model.name)}, S>
3687
3756
 
3688
3757
  ${isComposite ? "" : new ModelDelegate(this.type, this.context).toTS()}
3689
3758
 
@@ -3727,7 +3796,7 @@ var ModelDelegate = class {
3727
3796
  excludedArgsForCount.push("relationLoadStrategy");
3728
3797
  }
3729
3798
  const excludedArgsForCountType = excludedArgsForCount.map((name2) => `'${name2}'`).join(" | ");
3730
- return `${availableActions.includes(DMMF2.ModelAction.aggregate) ? `type ${countArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> =
3799
+ return `${availableActions.includes(DMMF2.ModelAction.aggregate) ? `export type ${countArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> =
3731
3800
  Omit<${getModelArgName(name, DMMF2.ModelAction.findMany)}, ${excludedArgsForCountType}> & {
3732
3801
  select?: ${getCountAggregateInputName(name)} | true
3733
3802
  }
@@ -3743,7 +3812,7 @@ ${availableActions.includes(DMMF2.ModelAction.aggregate) ? `${indent3(getMethodJ
3743
3812
  count<T extends ${countArgsName}>(
3744
3813
  args?: Subset<T, ${countArgsName}>,
3745
3814
  ): Prisma.PrismaPromise<
3746
- T extends $Utils.Record<'select', any>
3815
+ T extends runtime.Types.Utils.Record<'select', any>
3747
3816
  ? T['select'] extends true
3748
3817
  ? number
3749
3818
  : GetScalarType<T['select'], ${getCountAggregateOutputName(name)}>
@@ -3874,16 +3943,16 @@ function getReturnType({
3874
3943
  isNullable = false
3875
3944
  }) {
3876
3945
  if (actionName === DMMF2.ModelAction.count) {
3877
- return ts7.promise(ts7.numberType);
3946
+ return promise(ts7.numberType);
3878
3947
  }
3879
3948
  if (actionName === DMMF2.ModelAction.aggregate) {
3880
- return ts7.promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3949
+ return promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3881
3950
  }
3882
3951
  if (actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
3883
- return ts7.prismaPromise(ts7.namedType("JsonObject"));
3952
+ return prismaPromise(ts7.namedType("JsonObject"));
3884
3953
  }
3885
3954
  if (actionName === DMMF2.ModelAction.deleteMany || actionName === DMMF2.ModelAction.updateMany || actionName === DMMF2.ModelAction.createMany) {
3886
- return ts7.prismaPromise(ts7.namedType("BatchPayload"));
3955
+ return prismaPromise(ts7.namedType("BatchPayload"));
3887
3956
  }
3888
3957
  const isList = actionName === DMMF2.ModelAction.findMany || actionName === DMMF2.ModelAction.createManyAndReturn || actionName === DMMF2.ModelAction.updateManyAndReturn;
3889
3958
  if (isList) {
@@ -3891,7 +3960,7 @@ function getReturnType({
3891
3960
  if (isChaining) {
3892
3961
  result = ts7.unionType(result).addVariant(ts7.namedType("Null"));
3893
3962
  }
3894
- return ts7.prismaPromise(result);
3963
+ return prismaPromise(result);
3895
3964
  }
3896
3965
  if (isChaining && actionName === DMMF2.ModelAction.findUniqueOrThrow) {
3897
3966
  const nullType7 = isNullable ? ts7.nullType : ts7.namedType("Null");
@@ -3908,11 +3977,11 @@ function getFluentWrapper(modelName, resultType, nullType7 = ts7.neverType) {
3908
3977
  return ts7.namedType(fluentWrapperName(modelName)).addGenericArgument(resultType).addGenericArgument(nullType7).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(ts7.namedType("GlobalOmitOptions"));
3909
3978
  }
3910
3979
  function getResultType(modelName, actionName) {
3911
- 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"));
3980
+ 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"));
3912
3981
  }
3913
3982
  function buildFluentWrapperDefinition(modelName, outputType, context) {
3914
3983
  const definition = ts7.interfaceDeclaration(fluentWrapperName(modelName));
3915
- 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")));
3984
+ 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")));
3916
3985
  definition.add(ts7.property(ts7.toStringTag, ts7.stringLiteral("PrismaPromise")).readonly());
3917
3986
  definition.addMultiple(
3918
3987
  outputType.fields.filter(
@@ -3938,7 +4007,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3938
4007
  @param onrejected The callback to execute when the Promise is rejected.
3939
4008
  @returns A Promise for the completion of which ever callback is executed.
3940
4009
  `
3941
- ).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")])))
4010
+ ).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")])))
3942
4011
  );
3943
4012
  definition.add(
3944
4013
  ts7.method("catch").setDocComment(
@@ -3947,7 +4016,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3947
4016
  @param onrejected The callback to execute when the Promise is rejected.
3948
4017
  @returns A Promise for the completion of the callback.
3949
4018
  `
3950
- ).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")])))
4019
+ ).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")])))
3951
4020
  );
3952
4021
  definition.add(
3953
4022
  ts7.method("finally").setDocComment(
@@ -3959,7 +4028,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3959
4028
  `
3960
4029
  ).addParameter(
3961
4030
  ts7.parameter("onfinally", ts7.unionType([ts7.functionType(), ts7.undefinedType, ts7.nullType])).optional()
3962
- ).setReturnType(ts7.promise(ts7.namedType("T")))
4031
+ ).setReturnType(promise(ts7.namedType("T")))
3963
4032
  );
3964
4033
  return ts7.moduleExport(definition).setDocComment(ts7.docComment`
3965
4034
  The delegate class that acts as a "Promise-like" for ${modelName}.
@@ -3989,13 +4058,13 @@ function fluentWrapperName(modelName) {
3989
4058
  }
3990
4059
 
3991
4060
  // src/TSClient/TSClient.ts
4061
+ import crypto from "node:crypto";
4062
+ import path2 from "node:path";
3992
4063
  import { datamodelEnumToSchemaEnum } from "@prisma/dmmf";
3993
- import { ClientEngineType as ClientEngineType2, getClientEngineType, pathToPosix as pathToPosix3 } from "@prisma/internals";
4064
+ import { ClientEngineType as ClientEngineType2, getClientEngineType, pathToPosix as pathToPosix2 } from "@prisma/internals";
3994
4065
  import * as ts12 from "@prisma/ts-builders";
3995
4066
  import ciInfo from "ci-info";
3996
- import crypto from "crypto";
3997
- import indent8 from "indent-string";
3998
- import path2 from "path";
4067
+ import indent7 from "indent-string";
3999
4068
 
4000
4069
  // src/dmmf.ts
4001
4070
  import { keyBy } from "@prisma/client-common";
@@ -4051,8 +4120,8 @@ var DMMFHelper = class {
4051
4120
  Object.values(this.mappings.otherOperations.read)
4052
4121
  ].flat();
4053
4122
  }
4054
- hasEnumInNamespace(enumName, namespace3) {
4055
- return this.schema.enumTypes[namespace3]?.find((schemaEnum) => schemaEnum.name === enumName) !== void 0;
4123
+ hasEnumInNamespace(enumName, namespace2) {
4124
+ return this.schema.enumTypes[namespace2]?.find((schemaEnum) => schemaEnum.name === enumName) !== void 0;
4056
4125
  }
4057
4126
  resolveInputObjectType(ref) {
4058
4127
  return this.inputTypesByName.get(fullyQualifiedName(ref.type, ref.namespace));
@@ -4107,9 +4176,9 @@ var DMMFHelper = class {
4107
4176
  return result;
4108
4177
  }
4109
4178
  };
4110
- function fullyQualifiedName(typeName, namespace3) {
4111
- if (namespace3) {
4112
- return `${namespace3}.${typeName}`;
4179
+ function fullyQualifiedName(typeName, namespace2) {
4180
+ if (namespace2) {
4181
+ return `${namespace2}.${typeName}`;
4113
4182
  }
4114
4183
  return typeName;
4115
4184
  }
@@ -4229,40 +4298,17 @@ function buildDebugInitialization(edge) {
4229
4298
  }
4230
4299
  const debugVar = getRuntimeEdgeEnvVar("DEBUG");
4231
4300
  return `if (${debugVar}) {
4232
- Debug.enable(${debugVar})
4301
+ runtime.Debug.enable(${debugVar})
4233
4302
  }
4234
4303
  `;
4235
4304
  }
4236
4305
 
4237
4306
  // src/utils/buildDirname.ts
4238
- import { pathToPosix } from "@prisma/internals";
4239
- function buildDirname(edge, relativeOutdir) {
4307
+ function buildDirname(edge) {
4240
4308
  if (edge === true) {
4241
- return buildDirnameDefault();
4309
+ return `config.dirname = '/'`;
4242
4310
  }
4243
- return buildDirnameFind(relativeOutdir);
4244
- }
4245
- function buildDirnameFind(relativeOutdir) {
4246
- return `
4247
- const fs = require('fs')
4248
-
4249
- config.dirname = __dirname
4250
- if (!fs.existsSync(path.join(__dirname, 'schema.prisma'))) {
4251
- const alternativePaths = [
4252
- ${JSON.stringify(pathToPosix(relativeOutdir))},
4253
- ${JSON.stringify(pathToPosix(relativeOutdir).split("/").slice(1).join("/"))},
4254
- ]
4255
-
4256
- const alternativePath = alternativePaths.find((altPath) => {
4257
- return fs.existsSync(path.join(process.cwd(), altPath, 'schema.prisma'))
4258
- }) ?? alternativePaths[0]
4259
-
4260
- config.dirname = path.join(process.cwd(), alternativePath)
4261
- config.isBundled = true
4262
- }`;
4263
- }
4264
- function buildDirnameDefault() {
4265
- return `config.dirname = '/'`;
4311
+ return `config.dirname = __dirname`;
4266
4312
  }
4267
4313
 
4268
4314
  // src/utils/buildDMMF.ts
@@ -4280,21 +4326,21 @@ function buildRuntimeDataModel(datamodel, runtimeName) {
4280
4326
  }
4281
4327
  const datamodelString = escapeJson(JSON.stringify(prunedDataModel));
4282
4328
  return `
4283
- config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})
4284
- defineDmmfProperty(exports.Prisma, config.runtimeDataModel)`;
4329
+ config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})`;
4285
4330
  }
4286
4331
 
4287
4332
  // src/utils/buildGetWasmModule.ts
4288
- import { capitalize as capitalize5 } from "@prisma/client-common";
4333
+ import { capitalize as capitalize6 } from "@prisma/client-common";
4289
4334
  import { match } from "ts-pattern";
4290
4335
  function buildGetWasmModule({
4291
4336
  component,
4292
4337
  runtimeName,
4293
4338
  runtimeBase,
4294
4339
  target,
4295
- activeProvider
4340
+ activeProvider,
4341
+ moduleFormat
4296
4342
  }) {
4297
- const capitalizedComponent = capitalize5(component);
4343
+ const capitalizedComponent = capitalize6(component);
4298
4344
  const wasmPathBase = `${runtimeBase}/query_compiler_bg.${activeProvider}`;
4299
4345
  const wasmBindingsPath = `${wasmPathBase}.mjs`;
4300
4346
  const wasmModulePath = `${wasmPathBase}.wasm`;
@@ -4305,10 +4351,8 @@ function buildGetWasmModule({
4305
4351
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
4306
4352
 
4307
4353
  getQuery${capitalizedComponent}WasmModule: async () => {
4308
- const { createRequire } = await import('node:module')
4309
4354
  const { readFile } = await import('node:fs/promises')
4310
-
4311
- const require = createRequire(import.meta.url)
4355
+ ${buildRequire(moduleFormat)}
4312
4356
  const wasmModulePath = require.resolve(${JSON.stringify(wasmModulePath)})
4313
4357
  const wasmModuleBytes = await readFile(wasmModulePath)
4314
4358
 
@@ -4329,10 +4373,18 @@ function buildGetWasmModule({
4329
4373
  }
4330
4374
  return `config.${component}Wasm = undefined`;
4331
4375
  }
4376
+ function buildRequire(moduleFormat) {
4377
+ if (moduleFormat === "cjs") {
4378
+ return "";
4379
+ }
4380
+ return `const { createRequire } = await import('node:module')
4381
+ const require = createRequire(import.meta.url)
4382
+ `;
4383
+ }
4332
4384
 
4333
4385
  // src/utils/buildNFTAnnotations.ts
4334
4386
  import { getNodeAPIName } from "@prisma/get-platform";
4335
- import { ClientEngineType, parseAWSNodejsRuntimeEnvVarVersion, pathToPosix as pathToPosix2 } from "@prisma/internals";
4387
+ import { ClientEngineType, parseAWSNodejsRuntimeEnvVarVersion, pathToPosix } from "@prisma/internals";
4336
4388
  import path from "path";
4337
4389
  function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir) {
4338
4390
  if (noEngine === true) return "";
@@ -4370,207 +4422,70 @@ function buildNFTAnnotation(fileName, relativeOutdir) {
4370
4422
  const relativeFilePath = path.join(relativeOutdir, fileName);
4371
4423
  return `
4372
4424
  // file annotations for bundling tools to include these files
4373
- path.join(__dirname, ${JSON.stringify(pathToPosix2(fileName))});
4374
- path.join(process.cwd(), ${JSON.stringify(pathToPosix2(relativeFilePath))})`;
4375
- }
4376
-
4377
- // src/utils/buildRequirePath.ts
4378
- function buildRequirePath(edge) {
4379
- if (edge === true) return "";
4380
- return `
4381
- const path = require('path')`;
4382
- }
4383
-
4384
- // src/utils/buildWarnEnvConflicts.ts
4385
- function buildWarnEnvConflicts(edge, runtimeBase, runtimeName) {
4386
- if (edge === true) return "";
4387
- return `
4388
- const { warnEnvConflicts } = require('${runtimeBase}/${runtimeName}')
4389
-
4390
- warnEnvConflicts({
4391
- rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.rootEnvPath),
4392
- schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.schemaEnvPath)
4393
- })`;
4425
+ path.join(__dirname, ${JSON.stringify(pathToPosix(fileName))})
4426
+ path.join(process.cwd(), ${JSON.stringify(pathToPosix(relativeFilePath))})`;
4394
4427
  }
4395
4428
 
4396
4429
  // src/TSClient/common.ts
4397
- import indent4 from "indent-string";
4398
- var commonCodeJS = ({
4430
+ var commonCodeTS = ({
4399
4431
  runtimeBase,
4400
4432
  runtimeName,
4401
- browser,
4402
4433
  clientVersion,
4403
4434
  engineVersion,
4404
4435
  generator,
4405
- deno
4406
- }) => `${deno ? "const exports = {}" : ""}
4407
- Object.defineProperty(exports, "__esModule", { value: true });
4408
- ${deno ? `
4409
- import {
4410
- PrismaClientKnownRequestError,
4411
- PrismaClientUnknownRequestError,
4412
- PrismaClientRustPanicError,
4413
- PrismaClientInitializationError,
4414
- PrismaClientValidationError,
4415
- getPrismaClient,
4416
- sqltag,
4417
- empty,
4418
- join,
4419
- raw,
4420
- Decimal,
4421
- Debug,
4422
- objectEnumValues,
4423
- makeStrictEnum,
4424
- Extensions,
4425
- defineDmmfProperty,
4426
- Public,
4427
- getRuntime,
4428
- skip
4429
- } from '${runtimeBase}/${runtimeName}'` : browser ? `
4430
- const {
4431
- Decimal,
4432
- objectEnumValues,
4433
- makeStrictEnum,
4434
- Public,
4435
- getRuntime,
4436
- skip
4437
- } = require('${runtimeBase}/${runtimeName}')
4438
- ` : `
4439
- const {
4440
- PrismaClientKnownRequestError,
4441
- PrismaClientUnknownRequestError,
4442
- PrismaClientRustPanicError,
4443
- PrismaClientInitializationError,
4444
- PrismaClientValidationError,
4445
- getPrismaClient,
4446
- sqltag,
4447
- empty,
4448
- join,
4449
- raw,
4450
- skip,
4451
- Decimal,
4452
- Debug,
4453
- objectEnumValues,
4454
- makeStrictEnum,
4455
- Extensions,
4456
- warnOnce,
4457
- defineDmmfProperty,
4458
- Public,
4459
- getRuntime,
4460
- createParam,
4461
- } = require('${runtimeBase}/${runtimeName}')
4462
- `}
4463
-
4464
- const Prisma = {}
4465
-
4466
- exports.Prisma = Prisma
4467
- exports.$Enums = {}
4436
+ moduleFormat,
4437
+ edge
4438
+ }) => ({
4439
+ tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}'
4440
+ ${buildPreamble(edge, moduleFormat)}
4468
4441
 
4469
- /**
4470
- * Prisma Client JS version: ${clientVersion}
4471
- * Query Engine version: ${engineVersion}
4472
- */
4473
- Prisma.prismaVersion = {
4474
- client: "${clientVersion}",
4475
- engine: "${engineVersion}"
4476
- }
4442
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4443
+ `,
4444
+ ts: () => `export type DMMF = typeof runtime.DMMF
4477
4445
 
4478
- Prisma.PrismaClientKnownRequestError = ${notSupportOnBrowser("PrismaClientKnownRequestError", browser)};
4479
- Prisma.PrismaClientUnknownRequestError = ${notSupportOnBrowser("PrismaClientUnknownRequestError", browser)}
4480
- Prisma.PrismaClientRustPanicError = ${notSupportOnBrowser("PrismaClientRustPanicError", browser)}
4481
- Prisma.PrismaClientInitializationError = ${notSupportOnBrowser("PrismaClientInitializationError", browser)}
4482
- Prisma.PrismaClientValidationError = ${notSupportOnBrowser("PrismaClientValidationError", browser)}
4483
- Prisma.Decimal = Decimal
4446
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4484
4447
 
4485
4448
  /**
4486
- * Re-export of sql-template-tag
4449
+ * Validator
4487
4450
  */
4488
- Prisma.sql = ${notSupportOnBrowser("sqltag", browser)}
4489
- Prisma.empty = ${notSupportOnBrowser("empty", browser)}
4490
- Prisma.join = ${notSupportOnBrowser("join", browser)}
4491
- Prisma.raw = ${notSupportOnBrowser("raw", browser)}
4492
- Prisma.validator = Public.validator
4451
+ export const validator = runtime.Public.validator
4493
4452
 
4494
4453
  /**
4495
- * Extensions
4496
- */
4497
- Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
4498
- Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
4499
-
4500
- /**
4501
- * Shorthand utilities for JSON filtering
4454
+ * Prisma Errors
4502
4455
  */
4503
- Prisma.DbNull = objectEnumValues.instances.DbNull
4504
- Prisma.JsonNull = objectEnumValues.instances.JsonNull
4505
- Prisma.AnyNull = objectEnumValues.instances.AnyNull
4506
4456
 
4507
- Prisma.NullTypes = {
4508
- DbNull: objectEnumValues.classes.DbNull,
4509
- JsonNull: objectEnumValues.classes.JsonNull,
4510
- AnyNull: objectEnumValues.classes.AnyNull
4511
- }
4457
+ export const PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4458
+ export type PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4512
4459
 
4513
- ${buildPrismaSkipJs(generator.previewFeatures)}
4514
- `;
4515
- var notSupportOnBrowser = (fnc, browser) => {
4516
- if (browser) {
4517
- return `() => {
4518
- const runtimeName = getRuntime().prettyName;
4519
- throw new Error(\`${fnc} is unable to run in this browser environment, or has been bundled for the browser (running in \${runtimeName}).
4520
- In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report\`,
4521
- )}`;
4522
- }
4523
- return fnc;
4524
- };
4525
- var commonCodeTS = ({
4526
- runtimeBase,
4527
- runtimeName,
4528
- clientVersion,
4529
- engineVersion,
4530
- generator
4531
- }) => ({
4532
- tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}';
4533
- import $Types = runtime.Types // general types
4534
- import $Public = runtime.Types.Public
4535
- import $Utils = runtime.Types.Utils
4536
- import $Extensions = runtime.Types.Extensions
4537
- import $Result = runtime.Types.Result
4538
-
4539
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4540
- `,
4541
- ts: () => `export import DMMF = runtime.DMMF
4460
+ export const PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4461
+ export type PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4542
4462
 
4543
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4463
+ export const PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4464
+ export type PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4544
4465
 
4545
- /**
4546
- * Validator
4547
- */
4548
- export import validator = runtime.Public.validator
4466
+ export const PrismaClientInitializationError = runtime.PrismaClientInitializationError
4467
+ export type PrismaClientInitializationError = runtime.PrismaClientInitializationError
4549
4468
 
4550
- /**
4551
- * Prisma Errors
4552
- */
4553
- export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4554
- export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4555
- export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4556
- export import PrismaClientInitializationError = runtime.PrismaClientInitializationError
4557
- export import PrismaClientValidationError = runtime.PrismaClientValidationError
4469
+ export const PrismaClientValidationError = runtime.PrismaClientValidationError
4470
+ export type PrismaClientValidationError = runtime.PrismaClientValidationError
4558
4471
 
4559
4472
  /**
4560
4473
  * Re-export of sql-template-tag
4561
4474
  */
4562
- export import sql = runtime.sqltag
4563
- export import empty = runtime.empty
4564
- export import join = runtime.join
4565
- export import raw = runtime.raw
4566
- export import Sql = runtime.Sql
4475
+ export const sql = runtime.sqltag
4476
+ export const empty = runtime.empty
4477
+ export const join = runtime.join
4478
+ export const raw = runtime.raw
4479
+ export const Sql = runtime.Sql
4480
+ export type Sql = runtime.Sql
4567
4481
 
4568
4482
  ${buildPrismaSkipTs(generator.previewFeatures)}
4569
4483
 
4570
4484
  /**
4571
4485
  * Decimal.js
4572
4486
  */
4573
- export import Decimal = runtime.Decimal
4487
+ export const Decimal = runtime.Decimal
4488
+ export type Decimal = runtime.Decimal
4574
4489
 
4575
4490
  export type DecimalJsLike = runtime.DecimalJsLike
4576
4491
 
@@ -4585,46 +4500,43 @@ export type MetricHistogramBucket = runtime.MetricHistogramBucket
4585
4500
  /**
4586
4501
  * Extensions
4587
4502
  */
4588
- export import Extension = $Extensions.UserArgs
4589
- export import getExtensionContext = runtime.Extensions.getExtensionContext
4590
- export import Args = $Public.Args
4591
- export import Payload = $Public.Payload
4592
- export import Result = $Public.Result
4593
- export import Exact = $Public.Exact
4503
+ export type Extension = runtime.Types.Extensions.UserArgs
4504
+ export const getExtensionContext = runtime.Extensions.getExtensionContext
4505
+ export type Args<T, F extends runtime.Operation> = runtime.Types.Public.Args<T, F>
4506
+ export type Payload<T, F extends runtime.Operation = never> = runtime.Types.Public.Payload<T, F>
4507
+ export type Result<T, A, F extends runtime.Operation> = runtime.Types.Public.Result<T, A, F>
4508
+ export type Exact<A, W> = runtime.Types.Public.Exact<A, W>
4509
+
4510
+ export type PrismaVersion = {
4511
+ client: string
4512
+ engine: string
4513
+ }
4594
4514
 
4595
4515
  /**
4596
4516
  * Prisma Client JS version: ${clientVersion}
4597
4517
  * Query Engine version: ${engineVersion}
4598
4518
  */
4599
- export type PrismaVersion = {
4600
- client: string
4519
+ export const prismaVersion: PrismaVersion = {
4520
+ client: "${clientVersion}",
4521
+ engine: "${engineVersion}"
4601
4522
  }
4602
4523
 
4603
- export const prismaVersion: PrismaVersion
4604
-
4605
4524
  /**
4606
4525
  * Utility Types
4607
4526
  */
4608
4527
 
4609
4528
 
4610
- export import JsonObject = runtime.JsonObject
4611
- export import JsonArray = runtime.JsonArray
4612
- export import JsonValue = runtime.JsonValue
4613
- export import InputJsonObject = runtime.InputJsonObject
4614
- export import InputJsonArray = runtime.InputJsonArray
4615
- export import InputJsonValue = runtime.InputJsonValue
4529
+ export type JsonObject = runtime.JsonObject
4530
+ export type JsonArray = runtime.JsonArray
4531
+ export type JsonValue = runtime.JsonValue
4532
+ export type InputJsonObject = runtime.InputJsonObject
4533
+ export type InputJsonArray = runtime.InputJsonArray
4534
+ export type InputJsonValue = runtime.InputJsonValue
4616
4535
 
4617
- /**
4618
- * Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
4619
- *
4620
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4621
- */
4622
- namespace NullTypes {
4623
- ${buildNullClass("DbNull")}
4624
-
4625
- ${buildNullClass("JsonNull")}
4626
-
4627
- ${buildNullClass("AnyNull")}
4536
+ export const NullTypes = {
4537
+ DbNull: runtime.objectEnumValues.classes.DbNull as (new (secret: never) => typeof runtime.objectEnumValues.instances.DbNull),
4538
+ JsonNull: runtime.objectEnumValues.classes.JsonNull as (new (secret: never) => typeof runtime.objectEnumValues.instances.JsonNull),
4539
+ AnyNull: runtime.objectEnumValues.classes.AnyNull as (new (secret: never) => typeof runtime.objectEnumValues.instances.AnyNull),
4628
4540
  }
4629
4541
 
4630
4542
  /**
@@ -4632,21 +4544,21 @@ ${buildNullClass("AnyNull")}
4632
4544
  *
4633
4545
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4634
4546
  */
4635
- export const DbNull: NullTypes.DbNull
4547
+ export const DbNull = runtime.objectEnumValues.instances.DbNull
4636
4548
 
4637
4549
  /**
4638
4550
  * Helper for filtering JSON entries that have JSON \`null\` values (not empty on the db)
4639
4551
  *
4640
4552
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4641
4553
  */
4642
- export const JsonNull: NullTypes.JsonNull
4554
+ export const JsonNull = runtime.objectEnumValues.instances.JsonNull
4643
4555
 
4644
4556
  /**
4645
4557
  * Helper for filtering JSON entries that are \`Prisma.DbNull\` or \`Prisma.JsonNull\`
4646
4558
  *
4647
4559
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4648
4560
  */
4649
- export const AnyNull: NullTypes.AnyNull
4561
+ export const AnyNull = runtime.objectEnumValues.instances.AnyNull
4650
4562
 
4651
4563
  type SelectAndInclude = {
4652
4564
  select: any
@@ -4658,16 +4570,6 @@ type SelectAndOmit = {
4658
4570
  omit: any
4659
4571
  }
4660
4572
 
4661
- /**
4662
- * Get the type of the value, that the Promise holds.
4663
- */
4664
- export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T;
4665
-
4666
- /**
4667
- * Get the return type of a function which returns a Promise.
4668
- */
4669
- export type PromiseReturnType<T extends (...args: any) => $Utils.JsPromise<any>> = PromiseType<ReturnType<T>>
4670
-
4671
4573
  /**
4672
4574
  * From T, pick a set of properties whose keys are in the union K
4673
4575
  */
@@ -4675,19 +4577,8 @@ type Prisma__Pick<T, K extends keyof T> = {
4675
4577
  [P in K]: T[P];
4676
4578
  };
4677
4579
 
4678
-
4679
4580
  export type Enumerable<T> = T | Array<T>;
4680
4581
 
4681
- export type RequiredKeys<T> = {
4682
- [K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K
4683
- }[keyof T]
4684
-
4685
- export type TruthyKeys<T> = keyof {
4686
- [K in keyof T as T[K] extends false | undefined | null ? never : K]: K
4687
- }
4688
-
4689
- export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>
4690
-
4691
4582
  /**
4692
4583
  * Subset
4693
4584
  * @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection
@@ -4804,7 +4695,6 @@ type _Merge<U extends object> = IntersectOf<Overwrite<U, {
4804
4695
  }>>;
4805
4696
 
4806
4697
  type Key = string | number | symbol;
4807
- type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never;
4808
4698
  type AtStrict<O extends object, K extends Key> = O[K & keyof O];
4809
4699
  type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
4810
4700
  export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
@@ -4828,7 +4718,7 @@ type _Record<K extends keyof any, T> = {
4828
4718
  type NoExpand<T> = T extends unknown ? T : never;
4829
4719
 
4830
4720
  // this type assumes the passed object is entirely optional
4831
- type AtLeast<O extends object, K extends string> = NoExpand<
4721
+ export type AtLeast<O extends object, K extends string> = NoExpand<
4832
4722
  O extends unknown
4833
4723
  ? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
4834
4724
  | {[P in keyof O as P extends K ? P : never]-?: O[P]} & O
@@ -4841,19 +4731,10 @@ export type Strict<U extends object> = ComputeRaw<_Strict<U>>;
4841
4731
 
4842
4732
  export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
4843
4733
 
4844
- /**
4845
- A [[Boolean]]
4846
- */
4847
4734
  export type Boolean = True | False
4848
4735
 
4849
- // /**
4850
- // 1
4851
- // */
4852
4736
  export type True = 1
4853
4737
 
4854
- /**
4855
- 0
4856
- */
4857
4738
  export type False = 0
4858
4739
 
4859
4740
  export type Not<B extends Boolean> = {
@@ -4884,16 +4765,6 @@ export type Or<B1 extends Boolean, B2 extends Boolean> = {
4884
4765
 
4885
4766
  export type Keys<U extends Union> = U extends unknown ? keyof U : never
4886
4767
 
4887
- type Cast<A, B> = A extends B ? A : B;
4888
-
4889
- export const type: unique symbol;
4890
-
4891
-
4892
-
4893
- /**
4894
- * Used by group by
4895
- */
4896
-
4897
4768
  export type GetScalarType<T, O> = O extends object ? {
4898
4769
  [P in keyof T]: P extends keyof O
4899
4770
  ? O[P]
@@ -4945,43 +4816,36 @@ type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRe
4945
4816
 
4946
4817
  `
4947
4818
  });
4948
- function buildNullClass(name) {
4949
- const source = `/**
4950
- * Type of \`Prisma.${name}\`.
4951
- *
4952
- * You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
4953
- *
4954
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4955
- */
4956
- class ${name} {
4957
- private ${name}: never
4958
- private constructor()
4959
- }`;
4960
- return indent4(source, TAB_SIZE);
4961
- }
4962
4819
  function buildPrismaSkipTs(previewFeatures) {
4963
4820
  if (previewFeatures.includes("strictUndefinedChecks")) {
4964
4821
  return `
4965
4822
  /**
4966
4823
  * Prisma.skip
4967
4824
  */
4968
- export import skip = runtime.skip
4825
+ export const skip = runtime.skip
4969
4826
  `;
4970
4827
  }
4971
4828
  return "";
4972
4829
  }
4973
- function buildPrismaSkipJs(previewFeatures) {
4974
- if (previewFeatures.includes("strictUndefinedChecks")) {
4975
- return `
4976
- Prisma.skip = skip
4830
+ function buildPreamble(edge, moduleFormat) {
4831
+ if (edge) {
4832
+ return "";
4833
+ }
4834
+ let preamble = `import * as process from 'node:process'
4835
+ import * as path from 'node:path'
4836
+ `;
4837
+ if (moduleFormat === "esm") {
4838
+ preamble += ` import { fileURLToPath } from 'node:url'
4839
+
4840
+ const __dirname = path.dirname(fileURLToPath(import.meta.url))
4977
4841
  `;
4978
4842
  }
4979
- return "";
4843
+ return preamble;
4980
4844
  }
4981
4845
 
4982
4846
  // src/TSClient/Count.ts
4983
4847
  import * as ts8 from "@prisma/ts-builders";
4984
- import indent5 from "indent-string";
4848
+ import indent4 from "indent-string";
4985
4849
  var Count = class {
4986
4850
  constructor(type, context) {
4987
4851
  this.type = type;
@@ -5012,8 +4876,10 @@ var Count = class {
5012
4876
 
5013
4877
  ${ts8.stringify(outputType)}
5014
4878
 
5015
- export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
5016
- ${indent5(
4879
+ export type ${getSelectName(
4880
+ name
4881
+ )}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
4882
+ ${indent4(
5017
4883
  type.fields.map((field) => {
5018
4884
  const types = ["boolean"];
5019
4885
  if (field.outputType.location === "outputObjectTypes") {
@@ -5034,7 +4900,7 @@ ${this.argsTypes.map((typeExport) => ts8.stringify(typeExport)).join("\n\n")}
5034
4900
  }
5035
4901
  };
5036
4902
  function getCountArgsType(typeName, fieldName) {
5037
- return `${typeName}Count${capitalize2(fieldName)}Args`;
4903
+ return `${typeName}Count${capitalize3(fieldName)}Args`;
5038
4904
  }
5039
4905
 
5040
4906
  // src/TSClient/FieldRefInput.ts
@@ -5075,7 +4941,7 @@ var GenerateContext = class {
5075
4941
  import { lowerCase as lowerCase7 } from "@prisma/client-common";
5076
4942
  import { assertNever as assertNever2 } from "@prisma/internals";
5077
4943
  import * as ts11 from "@prisma/ts-builders";
5078
- import indent7 from "indent-string";
4944
+ import indent6 from "indent-string";
5079
4945
 
5080
4946
  // src/utils/runtimeImport.ts
5081
4947
  import * as ts9 from "@prisma/ts-builders";
@@ -5087,7 +4953,7 @@ function runtimeImportedType(name) {
5087
4953
  }
5088
4954
 
5089
4955
  // src/TSClient/Datasources.ts
5090
- import indent6 from "indent-string";
4956
+ import indent5 from "indent-string";
5091
4957
  var Datasources = class {
5092
4958
  constructor(internalDatasources) {
5093
4959
  this.internalDatasources = internalDatasources;
@@ -5095,7 +4961,7 @@ var Datasources = class {
5095
4961
  toTS() {
5096
4962
  const sources = this.internalDatasources;
5097
4963
  return `export type Datasources = {
5098
- ${indent6(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
4964
+ ${indent5(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
5099
4965
  }`;
5100
4966
  }
5101
4967
  };
@@ -5151,9 +5017,9 @@ function clientTypeMapModelsDefinition(context) {
5151
5017
  }
5152
5018
  function clientTypeMapModelsResultDefinition(modelName, action) {
5153
5019
  if (action === "count")
5154
- return ts11.unionType([ts11.optional(ts11.namedType(getCountAggregateOutputName(modelName))), ts11.numberType]);
5155
- if (action === "groupBy") return ts11.array(ts11.optional(ts11.namedType(getGroupByName(modelName))));
5156
- if (action === "aggregate") return ts11.optional(ts11.namedType(getAggregateName(modelName)));
5020
+ return ts11.unionType([optional(ts11.namedType(getCountAggregateOutputName(modelName))), ts11.numberType]);
5021
+ if (action === "groupBy") return ts11.array(optional(ts11.namedType(getGroupByName(modelName))));
5022
+ if (action === "aggregate") return optional(ts11.namedType(getAggregateName(modelName)));
5157
5023
  if (action === "findRaw") return ts11.namedType("JsonObject");
5158
5024
  if (action === "aggregateRaw") return ts11.namedType("JsonObject");
5159
5025
  if (action === "deleteMany") return ts11.namedType("BatchPayload");
@@ -5173,7 +5039,7 @@ function clientTypeMapModelsResultDefinition(modelName, action) {
5173
5039
  assertNever2(action, `Unknown action: ${action}`);
5174
5040
  }
5175
5041
  function payloadToResult(modelName) {
5176
- return ts11.namedType("$Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5042
+ return ts11.namedType("runtime.Types.Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5177
5043
  }
5178
5044
  function clientTypeMapOthersDefinition(context) {
5179
5045
  const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
@@ -5211,25 +5077,26 @@ function clientTypeMapOthersDefinition(context) {
5211
5077
  function clientTypeMapDefinition(context) {
5212
5078
  const typeMap = `${ts11.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
5213
5079
  return `
5214
- interface TypeMapCb<ClientOptions = {}> extends $Utils.Fn<{extArgs: $Extensions.InternalArgs }, $Utils.Record<string, any>> {
5080
+ export interface TypeMapCb<ClientOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
5215
5081
  returns: Prisma.TypeMap<this['params']['extArgs'], ClientOptions extends { omit: infer OmitOptions } ? OmitOptions : {}>
5216
5082
  }
5217
5083
 
5218
- export type TypeMap<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
5084
+ export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
5219
5085
  }
5220
5086
  function clientExtensionsDefinitions(context) {
5221
5087
  const typeMap = clientTypeMapDefinition(context);
5222
5088
  const define = ts11.moduleExport(
5223
- ts11.constDeclaration(
5224
- "defineExtension",
5225
- ts11.namedType("$Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("define")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb")).addGenericArgument(ts11.namedType("$Extensions.DefaultArgs"))
5089
+ ts11.constDeclaration("defineExtension").setValue(
5090
+ ts11.namedValue("runtime.Extensions.defineExtension").as(ts11.namedType("unknown")).as(
5091
+ ts11.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("define")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb")).addGenericArgument(ts11.namedType("runtime.Types.Extensions.DefaultArgs"))
5092
+ )
5226
5093
  )
5227
5094
  );
5228
5095
  return [typeMap, ts11.stringify(define)].join("\n");
5229
5096
  }
5230
5097
  function extendsPropertyDefinition() {
5231
- const extendsDefinition = ts11.namedType("$Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("extends")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.namedType("ExtArgs")).addGenericArgument(
5232
- ts11.namedType("$Utils.Call").addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.objectType().add(ts11.property("extArgs", ts11.namedType("ExtArgs"))))
5098
+ 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(
5099
+ 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"))))
5233
5100
  );
5234
5101
  return ts11.stringify(ts11.property("$extends", extendsDefinition), { indentLevel: 1 });
5235
5102
  }
@@ -5248,7 +5115,7 @@ function batchingTransactionDefinition(context) {
5248
5115
 
5249
5116
  Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
5250
5117
  `
5251
- ).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"))));
5118
+ ).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"))));
5252
5119
  if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
5253
5120
  const options = ts11.objectType().formatInline().add(ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional());
5254
5121
  method3.addParameter(ts11.parameter("options", options).optional());
@@ -5261,7 +5128,7 @@ function interactiveTransactionDefinition(context) {
5261
5128
  const isolationLevel = ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional();
5262
5129
  options.add(isolationLevel);
5263
5130
  }
5264
- const returnType = ts11.promise(ts11.namedType("R"));
5131
+ const returnType = promise(ts11.namedType("R"));
5265
5132
  const callbackType = ts11.functionType().addParameter(
5266
5133
  ts11.parameter("prisma", ts11.omit(ts11.namedType("PrismaClient"), ts11.namedType("runtime.ITXClientDenyList")))
5267
5134
  ).setReturnType(returnType);
@@ -5347,7 +5214,7 @@ function queryRawTypedDefinition(context) {
5347
5214
  "typedSql",
5348
5215
  runtimeImportedType("TypedSql").addGenericArgument(ts11.array(ts11.unknownType)).addGenericArgument(param.toArgument())
5349
5216
  )
5350
- ).setReturnType(ts11.prismaPromise(ts11.array(param.toArgument())));
5217
+ ).setReturnType(prismaPromise(ts11.array(param.toArgument())));
5351
5218
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5352
5219
  }
5353
5220
  function metricDefinition(context) {
@@ -5372,7 +5239,7 @@ function runCommandRawDefinition(context) {
5372
5239
  if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
5373
5240
  return "";
5374
5241
  }
5375
- const method3 = ts11.method("$runCommandRaw").addParameter(ts11.parameter("command", ts11.namedType("Prisma.InputJsonObject"))).setReturnType(ts11.prismaPromise(ts11.namedType("Prisma.JsonObject"))).setDocComment(ts11.docComment`
5242
+ const method3 = ts11.method("$runCommandRaw").addParameter(ts11.parameter("command", ts11.namedType("Prisma.InputJsonObject"))).setReturnType(prismaPromise(ts11.namedType("Prisma.JsonObject"))).setDocComment(ts11.docComment`
5376
5243
  Executes a raw MongoDB command and returns the result of it.
5377
5244
  @example
5378
5245
  \`\`\`
@@ -5391,25 +5258,24 @@ function applyPendingMigrationsDefinition() {
5391
5258
  if (this.runtimeName !== "react-native") {
5392
5259
  return null;
5393
5260
  }
5394
- const method3 = ts11.method("$applyPendingMigrations").setReturnType(ts11.promise(ts11.voidType)).setDocComment(
5261
+ const method3 = ts11.method("$applyPendingMigrations").setReturnType(promise(ts11.voidType)).setDocComment(
5395
5262
  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.`
5396
5263
  );
5397
5264
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5398
5265
  }
5399
5266
  function eventRegistrationMethodDeclaration(runtimeName) {
5400
5267
  if (runtimeName === "binary") {
5401
- 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;`;
5268
+ 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;`;
5402
5269
  } else {
5403
5270
  return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
5404
5271
  }
5405
5272
  }
5406
5273
  var PrismaClientClass = class {
5407
- constructor(context, internalDatasources, outputDir, runtimeName, browser) {
5274
+ constructor(context, internalDatasources, outputDir, runtimeName) {
5408
5275
  this.context = context;
5409
5276
  this.internalDatasources = internalDatasources;
5410
5277
  this.outputDir = outputDir;
5411
5278
  this.runtimeName = runtimeName;
5412
- this.browser = browser;
5413
5279
  }
5414
5280
  get jsDoc() {
5415
5281
  const { dmmf } = this.context;
@@ -5423,44 +5289,49 @@ var PrismaClientClass = class {
5423
5289
  };
5424
5290
  }
5425
5291
  return `/**
5426
- * ## Prisma Client \u02B2\u02E2
5292
+ * ## Prisma Client
5427
5293
  *
5428
- * Type-safe database client for TypeScript & Node.js
5294
+ * Type-safe database client for TypeScript
5429
5295
  * @example
5430
5296
  * \`\`\`
5431
5297
  * const prisma = new PrismaClient()
5432
- * // Fetch zero or more ${capitalize2(example.plural)}
5298
+ * // Fetch zero or more ${capitalize3(example.plural)}
5433
5299
  * const ${lowerCase7(example.plural)} = await prisma.${lowerCase7(example.model)}.findMany()
5434
5300
  * \`\`\`
5435
5301
  *
5436
- *
5437
5302
  * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
5438
5303
  */`;
5439
5304
  }
5440
5305
  toTSWithoutNamespace() {
5441
5306
  const { dmmf } = this.context;
5442
- return `${this.jsDoc}
5443
- export class PrismaClient<
5307
+ return `interface PrismaClientConstructor {
5308
+ ${indent6(this.jsDoc, TAB_SIZE)}
5309
+ new <
5310
+ ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
5311
+ U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
5312
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
5313
+ >(options?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>): PrismaClient<ClientOptions, U, ExtArgs>
5314
+ }
5315
+
5316
+ ${this.jsDoc}
5317
+ export interface PrismaClient<
5444
5318
  ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
5445
5319
  U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
5446
- ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
5320
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
5447
5321
  > {
5448
5322
  [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
5449
5323
 
5450
- ${indent7(this.jsDoc, TAB_SIZE)}
5451
-
5452
- constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
5453
5324
  ${eventRegistrationMethodDeclaration(this.runtimeName)}
5454
5325
 
5455
5326
  /**
5456
5327
  * Connect with the database
5457
5328
  */
5458
- $connect(): $Utils.JsPromise<void>;
5329
+ $connect(): runtime.Types.Utils.JsPromise<void>;
5459
5330
 
5460
5331
  /**
5461
5332
  * Disconnect from the database
5462
5333
  */
5463
- $disconnect(): $Utils.JsPromise<void>;
5334
+ $disconnect(): runtime.Types.Utils.JsPromise<void>;
5464
5335
 
5465
5336
  /**
5466
5337
  * Add a middleware
@@ -5481,7 +5352,7 @@ ${[
5481
5352
  extendsPropertyDefinition()
5482
5353
  ].filter((d) => d !== null).join("\n").trim()}
5483
5354
 
5484
- ${indent7(
5355
+ ${indent6(
5485
5356
  dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
5486
5357
  let methodName = lowerCase7(m.model);
5487
5358
  if (methodName === "constructor") {
@@ -5492,7 +5363,7 @@ ${[
5492
5363
  * \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
5493
5364
  * Example usage:
5494
5365
  * \`\`\`ts
5495
- * // Fetch zero or more ${capitalize2(m.plural)}
5366
+ * // Fetch zero or more ${capitalize3(m.plural)}
5496
5367
  * const ${lowerCase7(m.plural)} = await prisma.${methodName}.findMany()
5497
5368
  * \`\`\`
5498
5369
  */
@@ -5500,7 +5371,9 @@ get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
5500
5371
  }).join("\n\n"),
5501
5372
  2
5502
5373
  )}
5503
- }`;
5374
+ }
5375
+
5376
+ export const PrismaClient = runtime.getPrismaClient(config) as unknown as PrismaClientConstructor`;
5504
5377
  }
5505
5378
  toTS() {
5506
5379
  const clientOptions = this.buildClientOptions();
@@ -5578,11 +5451,8 @@ export type MiddlewareParams = {
5578
5451
  */
5579
5452
  export type Middleware<T = any> = (
5580
5453
  params: MiddlewareParams,
5581
- next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
5582
- ) => $Utils.JsPromise<T>
5583
-
5584
- // tested in getLogLevel.test.ts
5585
- export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
5454
+ next: (params: MiddlewareParams) => runtime.Types.Utils.JsPromise<T>,
5455
+ ) => runtime.Types.Utils.JsPromise<T>
5586
5456
 
5587
5457
  /**
5588
5458
  * \`PrismaClient\` proxy available in interactive transactions.
@@ -5662,7 +5532,7 @@ var TSClient = class {
5662
5532
  }
5663
5533
  dmmf;
5664
5534
  genericsInfo;
5665
- toJS() {
5535
+ toTS() {
5666
5536
  const {
5667
5537
  edge,
5668
5538
  binaryPaths,
@@ -5672,16 +5542,11 @@ var TSClient = class {
5672
5542
  runtimeBase,
5673
5543
  runtimeName,
5674
5544
  datasources,
5675
- deno,
5676
5545
  copyEngine = true,
5677
- envPaths,
5678
5546
  target,
5679
- activeProvider
5547
+ activeProvider,
5548
+ moduleFormat
5680
5549
  } = this.options;
5681
- const relativeEnvPaths = {
5682
- rootEnvPath: envPaths.rootEnvPath && pathToPosix3(path2.relative(outputDir, envPaths.rootEnvPath)),
5683
- schemaEnvPath: envPaths.schemaEnvPath && pathToPosix3(path2.relative(outputDir, envPaths.schemaEnvPath))
5684
- };
5685
5550
  const clientEngineType = getClientEngineType(generator);
5686
5551
  generator.config.engineType = clientEngineType;
5687
5552
  const binaryTargets = clientEngineType === ClientEngineType2.Library ? Object.keys(binaryPaths.libqueryEngine ?? {}) : Object.keys(binaryPaths.queryEngine ?? {});
@@ -5689,8 +5554,7 @@ var TSClient = class {
5689
5554
  const datasourceFilePath = datasources[0].sourceFilePath;
5690
5555
  const config = {
5691
5556
  generator,
5692
- relativeEnvPaths,
5693
- relativePath: pathToPosix3(path2.relative(outputDir, path2.dirname(datasourceFilePath))),
5557
+ relativePath: pathToPosix2(path2.relative(outputDir, path2.dirname(datasourceFilePath))),
5694
5558
  clientVersion: this.options.clientVersion,
5695
5559
  engineVersion: this.options.engineVersion,
5696
5560
  datasourceNames: datasources.map((d) => d.name),
@@ -5702,44 +5566,24 @@ var TSClient = class {
5702
5566
  }, {}),
5703
5567
  inlineSchema,
5704
5568
  inlineSchemaHash,
5705
- copyEngine
5569
+ copyEngine,
5570
+ runtimeDataModel: { models: {}, enums: {}, types: {} },
5571
+ dirname: ""
5706
5572
  };
5707
5573
  const relativeOutdir = path2.relative(process.cwd(), outputDir);
5708
- const code = `${commonCodeJS({ ...this.options, browser: false })}
5709
- ${buildRequirePath(edge)}
5710
-
5711
- /**
5712
- * Enums
5713
- */
5714
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5715
- ${this.dmmf.datamodel.enums.map((datamodelEnum) => new Enum(datamodelEnumToSchemaEnum(datamodelEnum), false).toJS()).join("\n\n")}
5716
-
5717
- ${new Enum(
5718
- {
5719
- name: "ModelName",
5720
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5721
- },
5722
- true
5723
- ).toJS()}
5574
+ const clientConfig = `
5724
5575
  /**
5725
5576
  * Create the Client
5726
5577
  */
5727
- const config = ${JSON.stringify(config, null, 2)}
5728
- ${buildDirname(edge, relativeOutdir)}
5578
+ const config: runtime.GetPrismaClientConfig = ${JSON.stringify(config, null, 2)}
5579
+ ${buildDirname(edge)}
5729
5580
  ${buildRuntimeDataModel(this.dmmf.datamodel, runtimeName)}
5730
- ${buildGetWasmModule({ component: "engine", runtimeBase, runtimeName, target, activeProvider })}
5731
- ${buildGetWasmModule({ component: "compiler", runtimeBase, runtimeName, target, activeProvider })}
5581
+ ${buildGetWasmModule({ component: "engine", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5582
+ ${buildGetWasmModule({ component: "compiler", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5732
5583
  ${buildInjectableEdgeEnv(edge, datasources)}
5733
- ${buildWarnEnvConflicts(edge, runtimeBase, runtimeName)}
5734
5584
  ${buildDebugInitialization(edge)}
5735
- const PrismaClient = getPrismaClient(config)
5736
- exports.PrismaClient = PrismaClient
5737
- Object.assign(exports, Prisma)${deno ? "\nexport { exports as default, Prisma, PrismaClient }" : ""}
5738
5585
  ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, relativeOutdir)}
5739
5586
  `;
5740
- return code;
5741
- }
5742
- toTS() {
5743
5587
  const context = new GenerateContext({
5744
5588
  dmmf: this.dmmf,
5745
5589
  genericArgsInfo: this.genericsInfo,
@@ -5749,8 +5593,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5749
5593
  context,
5750
5594
  this.options.datasources,
5751
5595
  this.options.outputDir,
5752
- this.options.runtimeName,
5753
- this.options.browser
5596
+ this.options.runtimeName
5754
5597
  );
5755
5598
  const commonCode = commonCodeTS(this.options);
5756
5599
  const modelAndTypes = Object.values(this.dmmf.typeAndModelMap).reduce((acc, modelOrType) => {
@@ -5769,7 +5612,9 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5769
5612
  ts12.moduleExport(ts12.typeDeclaration(datamodelEnum.name, ts12.namedType(`$Enums.${datamodelEnum.name}`)))
5770
5613
  ),
5771
5614
  ts12.stringify(
5772
- ts12.moduleExport(ts12.constDeclaration(datamodelEnum.name, ts12.namedType(`typeof $Enums.${datamodelEnum.name}`)))
5615
+ ts12.moduleExport(
5616
+ ts12.constDeclaration(datamodelEnum.name).setValue(ts12.namedValue(`$Enums.${datamodelEnum.name}`))
5617
+ )
5773
5618
  )
5774
5619
  );
5775
5620
  }
@@ -5778,7 +5623,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5778
5623
  const code = `
5779
5624
  /**
5780
5625
  * Client
5781
- **/
5626
+ */
5782
5627
 
5783
5628
  ${commonCode.tsWithoutNamespace()}
5784
5629
 
@@ -5793,10 +5638,13 @@ export namespace $Enums {
5793
5638
 
5794
5639
  ${modelEnumsAliases.join("\n\n")}
5795
5640
  ` : ""}
5641
+
5642
+ ${clientConfig}
5643
+
5796
5644
  ${prismaClientClass.toTSWithoutNamespace()}
5797
5645
 
5798
5646
  export namespace Prisma {
5799
- ${indent8(
5647
+ ${indent7(
5800
5648
  `${commonCode.ts()}
5801
5649
  ${new Enum(
5802
5650
  {
@@ -5865,70 +5713,11 @@ ${this.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputType,
5865
5713
  export type BatchPayload = {
5866
5714
  count: number
5867
5715
  }
5868
-
5869
- /**
5870
- * DMMF
5871
- */
5872
- export const dmmf: runtime.BaseDMMF
5873
5716
  `,
5874
5717
  2
5875
5718
  )}}`;
5876
5719
  return code;
5877
5720
  }
5878
- toBrowserJS() {
5879
- const code = `${commonCodeJS({
5880
- ...this.options,
5881
- runtimeName: "index-browser",
5882
- browser: true
5883
- })}
5884
- /**
5885
- * Enums
5886
- */
5887
-
5888
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5889
- ${this.dmmf.schema.enumTypes.model?.map((type) => new Enum(type, false).toJS()).join("\n\n") ?? ""}
5890
-
5891
- ${new Enum(
5892
- {
5893
- name: "ModelName",
5894
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5895
- },
5896
- true
5897
- ).toJS()}
5898
-
5899
- /**
5900
- * This is a stub Prisma Client that will error at runtime if called.
5901
- */
5902
- class PrismaClient {
5903
- constructor() {
5904
- return new Proxy(this, {
5905
- get(target, prop) {
5906
- let message
5907
- const runtime = getRuntime()
5908
- if (runtime.isEdge) {
5909
- message = \`PrismaClient is not configured to run in \${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
5910
- - Use Prisma Accelerate: https://pris.ly/d/accelerate
5911
- - Use Driver Adapters: https://pris.ly/d/driver-adapters
5912
- \`;
5913
- } else {
5914
- message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in \`' + runtime.prettyName + '\`).'
5915
- }
5916
-
5917
- message += \`
5918
- If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report\`
5919
-
5920
- throw new Error(message)
5921
- }
5922
- })
5923
- }
5924
- }
5925
-
5926
- exports.PrismaClient = PrismaClient
5927
-
5928
- Object.assign(exports, Prisma)
5929
- `;
5930
- return code;
5931
- }
5932
5721
  };
5933
5722
 
5934
5723
  // src/typedSql/buildDbEnums.ts
@@ -5965,23 +5754,12 @@ var DbEnumsList = class {
5965
5754
  };
5966
5755
  function buildDbEnums(list) {
5967
5756
  const file4 = ts13.file();
5968
- file4.add(buildInvalidIdentifierEnums(list));
5969
- file4.add(buildValidIdentifierEnums(list));
5970
- return ts13.stringify(file4);
5971
- }
5972
- function buildValidIdentifierEnums(list) {
5973
- const namespace3 = ts13.namespace("$DbEnums");
5974
- for (const dbEnum of list.validJsIdentifiers()) {
5975
- namespace3.add(ts13.typeDeclaration(dbEnum.name, enumToUnion(dbEnum)));
5976
- }
5977
- return ts13.moduleExport(namespace3);
5978
- }
5979
- function buildInvalidIdentifierEnums(list) {
5980
5757
  const iface = ts13.interfaceDeclaration("$DbEnums");
5981
- for (const dbEnum of list.invalidJsIdentifiers()) {
5758
+ for (const dbEnum of list.enums) {
5982
5759
  iface.add(ts13.property(dbEnum.name, enumToUnion(dbEnum)));
5983
5760
  }
5984
- return ts13.moduleExport(iface);
5761
+ file4.add(ts13.moduleExport(iface));
5762
+ return ts13.stringify(file4);
5985
5763
  }
5986
5764
  function enumToUnion(dbEnum) {
5987
5765
  return ts13.unionType(dbEnum.values.map(ts13.stringLiteral));
@@ -5995,41 +5773,21 @@ function queryUsesEnums(query, enums) {
5995
5773
 
5996
5774
  // src/typedSql/buildIndex.ts
5997
5775
  import * as ts14 from "@prisma/ts-builders";
5998
- import { Writer } from "@prisma/ts-builders";
5999
- function buildIndexTs(queries, enums) {
5776
+ function buildIndex({ queries, enums, importName }) {
6000
5777
  const file4 = ts14.file();
6001
5778
  if (!enums.isEmpty()) {
6002
- file4.add(ts14.moduleExportFrom("./$DbEnums").named("$DbEnums"));
5779
+ file4.add(ts14.moduleExportFrom(importName("./sql/$DbEnums")).named(ts14.namedExport("$DbEnums").typeOnly()));
6003
5780
  }
6004
5781
  for (const query of queries) {
6005
- file4.add(ts14.moduleExportFrom(`./${query.name}`));
5782
+ file4.add(ts14.moduleExportFrom(importName(`./sql/${query.name}`)));
6006
5783
  }
6007
5784
  return ts14.stringify(file4);
6008
5785
  }
6009
- function buildIndexCjs(queries, edgeRuntimeSuffix) {
6010
- const writer = new Writer(0, void 0);
6011
- writer.writeLine('"use strict"');
6012
- for (const { name } of queries) {
6013
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6014
- writer.writeLine(`exports.${name} = require("./${fileName}.js").${name}`);
6015
- }
6016
- return writer.toString();
6017
- }
6018
- function buildIndexEsm(queries, edgeRuntimeSuffix) {
6019
- const writer = new Writer(0, void 0);
6020
- for (const { name } of queries) {
6021
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6022
- writer.writeLine(`export * from "./${fileName}.mjs"`);
6023
- }
6024
- return writer.toString();
6025
- }
6026
5786
 
6027
5787
  // src/typedSql/buildTypedQuery.ts
6028
5788
  import * as ts16 from "@prisma/ts-builders";
6029
- import { Writer as Writer2 } from "@prisma/ts-builders";
6030
5789
 
6031
5790
  // src/typedSql/mapTypes.ts
6032
- import { isValidJsIdentifier as isValidJsIdentifier2 } from "@prisma/internals";
6033
5791
  import * as ts15 from "@prisma/ts-builders";
6034
5792
  var decimal = ts15.namedType("$runtime.Decimal");
6035
5793
  var uint8Array = ts15.namedType("Uint8Array");
@@ -6123,18 +5881,15 @@ function getMappingConfig(introspectionType, enums) {
6123
5881
  return config;
6124
5882
  }
6125
5883
  function getEnumType(name) {
6126
- if (isValidJsIdentifier2(name)) {
6127
- return ts15.namedType(`$DbEnums.${name}`);
6128
- }
6129
5884
  return ts15.namedType("$DbEnums").subKey(name);
6130
5885
  }
6131
5886
 
6132
5887
  // src/typedSql/buildTypedQuery.ts
6133
- function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
5888
+ function buildTypedQuery({ query, runtimeBase, runtimeName, enums, importName }) {
6134
5889
  const file4 = ts16.file();
6135
5890
  file4.addImport(ts16.moduleImport(`${runtimeBase}/${runtimeName}`).asNamespace("$runtime"));
6136
5891
  if (queryUsesEnums(query, enums)) {
6137
- file4.addImport(ts16.moduleImport("./$DbEnums").named("$DbEnums"));
5892
+ file4.addImport(ts16.moduleImport(importName("./$DbEnums")).named(ts16.namedImport("$DbEnums").typeOnly()));
6138
5893
  }
6139
5894
  const doc = ts16.docComment(query.documentation ?? void 0);
6140
5895
  const factoryType = ts16.functionType();
@@ -6152,11 +5907,17 @@ function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
6152
5907
  factoryType.setReturnType(
6153
5908
  ts16.namedType("$runtime.TypedSql").addGenericArgument(ts16.namedType(`${query.name}.Parameters`)).addGenericArgument(ts16.namedType(`${query.name}.Result`))
6154
5909
  );
6155
- file4.add(ts16.moduleExport(ts16.constDeclaration(query.name, factoryType)).setDocComment(doc));
6156
- const namespace3 = ts16.namespace(query.name);
6157
- namespace3.add(ts16.moduleExport(ts16.typeDeclaration("Parameters", parametersType)));
6158
- namespace3.add(buildResultType(query, enums));
6159
- file4.add(ts16.moduleExport(namespace3));
5910
+ file4.add(
5911
+ ts16.moduleExport(
5912
+ ts16.constDeclaration(query.name).setValue(
5913
+ ts16.functionCall("$runtime.makeTypedQueryFactory").addArgument(ts16.stringLiteral(query.source).asValue()).as(factoryType)
5914
+ )
5915
+ ).setDocComment(doc)
5916
+ );
5917
+ const namespace2 = ts16.namespace(query.name);
5918
+ namespace2.add(ts16.moduleExport(ts16.typeDeclaration("Parameters", parametersType)));
5919
+ namespace2.add(buildResultType(query, enums));
5920
+ file4.add(ts16.moduleExport(namespace2));
6160
5921
  return ts16.stringify(file4);
6161
5922
  }
6162
5923
  function buildResultType(query, enums) {
@@ -6165,47 +5926,28 @@ function buildResultType(query, enums) {
6165
5926
  );
6166
5927
  return ts16.moduleExport(ts16.typeDeclaration("Result", type));
6167
5928
  }
6168
- function buildTypedQueryCjs({ query, runtimeBase, runtimeName }) {
6169
- const writer = new Writer2(0, void 0);
6170
- writer.writeLine('"use strict"');
6171
- writer.writeLine(`const { makeTypedQueryFactory: $mkFactory } = require("${runtimeBase}/${runtimeName}")`);
6172
- writer.writeLine(`exports.${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6173
- return writer.toString();
6174
- }
6175
- function buildTypedQueryEsm({ query, runtimeBase, runtimeName }) {
6176
- const writer = new Writer2(0, void 0);
6177
- writer.writeLine(`import { makeTypedQueryFactory as $mkFactory } from "${runtimeBase}/${runtimeName}"`);
6178
- writer.writeLine(`export const ${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6179
- return writer.toString();
6180
- }
6181
5929
 
6182
5930
  // src/typedSql/typedSql.ts
6183
5931
  function buildTypedSql({
6184
5932
  queries,
6185
5933
  runtimeBase,
6186
- edgeRuntimeName,
6187
- mainRuntimeName,
6188
- dmmf
5934
+ runtimeName,
5935
+ dmmf,
5936
+ outputName,
5937
+ importName
6189
5938
  }) {
6190
- const fileMap = {};
5939
+ const fileMap = {
5940
+ sql: {}
5941
+ };
6191
5942
  const enums = new DbEnumsList(dmmf.datamodel.enums);
6192
5943
  if (!enums.isEmpty()) {
6193
- fileMap["$DbEnums.d.ts"] = buildDbEnums(enums);
5944
+ fileMap.sql[outputName("$DbEnums")] = buildDbEnums(enums);
6194
5945
  }
6195
5946
  for (const query of queries) {
6196
- const options = { query, runtimeBase, runtimeName: mainRuntimeName, enums };
6197
- const edgeOptions = { ...options, runtimeName: `${edgeRuntimeName}.js` };
6198
- fileMap[`${query.name}.d.ts`] = buildTypedQueryTs(options);
6199
- fileMap[`${query.name}.js`] = buildTypedQueryCjs(options);
6200
- fileMap[`${query.name}.${edgeRuntimeName}.js`] = buildTypedQueryCjs(edgeOptions);
6201
- fileMap[`${query.name}.mjs`] = buildTypedQueryEsm(options);
6202
- fileMap[`${query.name}.edge.mjs`] = buildTypedQueryEsm(edgeOptions);
6203
- }
6204
- fileMap["index.d.ts"] = buildIndexTs(queries, enums);
6205
- fileMap["index.js"] = buildIndexCjs(queries);
6206
- fileMap["index.mjs"] = buildIndexEsm(queries);
6207
- fileMap[`index.${edgeRuntimeName}.mjs`] = buildIndexEsm(queries, edgeRuntimeName);
6208
- fileMap[`index.${edgeRuntimeName}.js`] = buildIndexCjs(queries, edgeRuntimeName);
5947
+ const options = { query, runtimeBase, runtimeName, enums, importName };
5948
+ fileMap.sql[outputName(query.name)] = buildTypedQuery(options);
5949
+ }
5950
+ fileMap[outputName("sql")] = buildIndex({ queries, enums, importName });
6209
5951
  return fileMap;
6210
5952
  }
6211
5953
 
@@ -6233,10 +5975,15 @@ function buildClient({
6233
5975
  copyEngine,
6234
5976
  envPaths,
6235
5977
  typedSql,
6236
- target
5978
+ target,
5979
+ generatedFileExtension,
5980
+ importFileExtension,
5981
+ moduleFormat
6237
5982
  }) {
6238
5983
  const clientEngineType = getClientEngineType2(generator);
6239
5984
  const runtimeName = getRuntimeNameForTarget(target, clientEngineType, generator.previewFeatures);
5985
+ const outputName = generatedFileNameMapper(generatedFileExtension);
5986
+ const importName = importFileNameMapper(importFileExtension);
6240
5987
  const clientOptions = {
6241
5988
  dmmf: getPrismaClientDMMF(dmmf),
6242
5989
  envPaths: envPaths ?? { rootEnvPath: null, schemaEnvPath: void 0 },
@@ -6252,28 +5999,32 @@ function buildClient({
6252
5999
  postinstall,
6253
6000
  copyEngine,
6254
6001
  datamodel,
6255
- browser: false,
6256
- deno: false,
6257
6002
  edge: ["edge", "wasm", "react-native"].includes(runtimeName),
6258
6003
  runtimeName,
6259
- target
6004
+ target,
6005
+ generatedFileExtension,
6006
+ importFileExtension,
6007
+ moduleFormat
6260
6008
  };
6261
6009
  if (runtimeName === "react-native" && !generator.previewFeatures.includes("reactNative")) {
6262
6010
  throw new Error(`Using the "react-native" runtime requires the "reactNative" preview feature to be enabled.`);
6263
6011
  }
6264
6012
  const client = new TSClient(clientOptions);
6265
- const fileMap = {};
6266
- fileMap["index.js"] = client.toJS();
6267
- fileMap["index.d.ts"] = client.toTS();
6268
- const usesWasmRuntimeOnEdge = generator.previewFeatures.includes("driverAdapters");
6013
+ let fileMap = {};
6014
+ fileMap[outputName("client")] = client.toTS();
6015
+ fileMap[outputName("index")] = `export * from '${importName("./client")}'`;
6269
6016
  if (typedSql && typedSql.length > 0) {
6270
- fileMap["sql"] = buildTypedSql({
6271
- dmmf,
6272
- runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6273
- mainRuntimeName: getNodeRuntimeName(clientEngineType),
6274
- queries: typedSql,
6275
- edgeRuntimeName: usesWasmRuntimeOnEdge ? "wasm" : "edge"
6276
- });
6017
+ fileMap = {
6018
+ ...fileMap,
6019
+ ...buildTypedSql({
6020
+ dmmf,
6021
+ runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6022
+ runtimeName,
6023
+ queries: typedSql,
6024
+ outputName,
6025
+ importName
6026
+ })
6027
+ };
6277
6028
  }
6278
6029
  return {
6279
6030
  fileMap,
@@ -6306,7 +6057,10 @@ async function generateClient(options) {
6306
6057
  envPaths,
6307
6058
  copyEngine = true,
6308
6059
  typedSql,
6309
- target
6060
+ target,
6061
+ generatedFileExtension,
6062
+ importFileExtension,
6063
+ moduleFormat
6310
6064
  } = options;
6311
6065
  const clientEngineType = getClientEngineType2(generator);
6312
6066
  const { runtimeBase, outputDir } = await getGenerationDirs(options);
@@ -6326,7 +6080,10 @@ async function generateClient(options) {
6326
6080
  copyEngine,
6327
6081
  envPaths,
6328
6082
  typedSql,
6329
- target
6083
+ target,
6084
+ generatedFileExtension,
6085
+ importFileExtension,
6086
+ moduleFormat
6330
6087
  });
6331
6088
  const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf);
6332
6089
  if (denylistsErrors) {
@@ -6345,12 +6102,7 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
6345
6102
  await (0, import_fs_extra.ensureDir)(outputDir);
6346
6103
  await writeFileMap(outputDir, fileMap);
6347
6104
  const enginePath = clientEngineType === ClientEngineType3.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
6348
- if (!enginePath) {
6349
- throw new Error(
6350
- `Prisma Client needs \`${clientEngineType === ClientEngineType3.Library ? "libqueryEngine" : "queryEngine"}\` in the \`binaryPaths\` object.`
6351
- );
6352
- }
6353
- if (copyEngine) {
6105
+ if (copyEngine && enginePath) {
6354
6106
  if (process.env.NETLIFY) {
6355
6107
  await (0, import_fs_extra.ensureDir)("/tmp/prisma-engines");
6356
6108
  }
@@ -6365,15 +6117,6 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
6365
6117
  await overwriteFile(filePath, target2);
6366
6118
  }
6367
6119
  }
6368
- const schemaTargetPath = path3.join(outputDir, "schema.prisma");
6369
- await fs.writeFile(schemaTargetPath, datamodel, { encoding: "utf-8" });
6370
- try {
6371
- const prismaCache = paths("prisma").cache;
6372
- const signalsPath = path3.join(prismaCache, "last-generate");
6373
- await fs.mkdir(prismaCache, { recursive: true });
6374
- await fs.writeFile(signalsPath, Date.now().toString());
6375
- } catch {
6376
- }
6377
6120
  }
6378
6121
  function writeFileMap(outputDir, fileMap) {
6379
6122
  return Promise.all(
@@ -6468,7 +6211,7 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
6468
6211
  }
6469
6212
  async function getGenerationDirs({ runtimeBase, outputDir }) {
6470
6213
  const normalizedOutputDir = path3.normalize(outputDir);
6471
- const normalizedRuntimeBase = pathToPosix4(runtimeBase);
6214
+ const normalizedRuntimeBase = pathToPosix3(runtimeBase);
6472
6215
  const userPackageRoot = await pkgUp({ cwd: path3.dirname(normalizedOutputDir) });
6473
6216
  const userProjectRoot = userPackageRoot ? path3.dirname(userPackageRoot) : process.cwd();
6474
6217
  return {
@@ -6520,15 +6263,13 @@ async function deleteOutputDir(outputDir) {
6520
6263
  if (files.length === 0) {
6521
6264
  return;
6522
6265
  }
6523
- if (!files.includes("index.d.ts")) {
6266
+ if (!files.includes("client.ts") && !files.includes("client.mts") && !files.includes("client.cts")) {
6524
6267
  throw new Error(
6525
6268
  `${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.`
6526
6269
  );
6527
6270
  }
6528
6271
  await Promise.allSettled(
6529
- (await glob(`${outputDir}/**/*.ts`, {
6530
- globstar: true,
6531
- onlyFiles: true,
6272
+ (await glob([`${outputDir}/**/*.{ts,mts,cts}`, `${outputDir}/*.node`, `${outputDir}/{query,schema}-engine-*`], {
6532
6273
  followSymbolicLinks: false
6533
6274
  })).map(fs.unlink)
6534
6275
  );
@@ -6540,13 +6281,54 @@ async function deleteOutputDir(outputDir) {
6540
6281
  }
6541
6282
 
6542
6283
  // src/generator.ts
6543
- import Debug from "@prisma/debug";
6284
+ import { Debug } from "@prisma/debug";
6544
6285
  import { enginesVersion } from "@prisma/engines-version";
6545
6286
  import { ClientEngineType as ClientEngineType4, getClientEngineType as getClientEngineType3, parseEnvValue } from "@prisma/internals";
6287
+ import { getTsconfig } from "get-tsconfig";
6546
6288
  import { match as match2 } from "ts-pattern";
6547
6289
 
6548
6290
  // package.json
6549
- var version = "6.6.0-dev.96";
6291
+ var version = "6.6.0-dev.98";
6292
+
6293
+ // src/module-format.ts
6294
+ function parseModuleFormat(format) {
6295
+ switch (format.toLowerCase()) {
6296
+ case "cjs":
6297
+ case "commonjs":
6298
+ return "cjs";
6299
+ case "esm":
6300
+ return "esm";
6301
+ default:
6302
+ throw new Error(`Invalid module format: "${format}", expected "esm" or "cjs"`);
6303
+ }
6304
+ }
6305
+ function parseModuleFormatFromUnknown(value) {
6306
+ if (typeof value === "string") {
6307
+ return parseModuleFormat(value);
6308
+ } else {
6309
+ throw new Error(`Invalid module format: ${JSON.stringify(value)}, expected "esm" or "cjs"`);
6310
+ }
6311
+ }
6312
+ function inferModuleFormat({
6313
+ tsconfig,
6314
+ generatedFileExtension,
6315
+ importFileExtension
6316
+ }) {
6317
+ if (tsconfig?.compilerOptions?.module) {
6318
+ return fromTsConfigModule(tsconfig.compilerOptions.module);
6319
+ }
6320
+ if (generatedFileExtension === "cts" || importFileExtension === "cjs") {
6321
+ return "cjs";
6322
+ }
6323
+ return "esm";
6324
+ }
6325
+ function fromTsConfigModule(module) {
6326
+ const normalizedModule = module.toLowerCase();
6327
+ if (normalizedModule === "commonjs") {
6328
+ return "cjs";
6329
+ }
6330
+ return "esm";
6331
+ }
6550
6332
 
6551
6333
  // src/runtime-targets.ts
6552
6334
  var supportedRuntimes = ["nodejs", "deno", "deno-deploy", "bun", "workerd", "edge-light", "react-native"];
@@ -6613,13 +6395,27 @@ var PrismaClientTsGenerator = class {
6613
6395
  });
6614
6396
  }
6615
6397
  async generate(options) {
6398
+ const { config } = options.generator;
6399
+ const outputDir = getOutputPath(options.generator);
6400
+ const tsconfig = getTsconfig(outputDir)?.config;
6401
+ const target = config.runtime !== void 0 ? parseRuntimeTargetFromUnknown(config.runtime) : "nodejs";
6402
+ const generatedFileExtension = config.generatedFileExtension !== void 0 ? parseGeneratedFileExtension(config.generatedFileExtension) : "ts";
6403
+ const importFileExtension = config.importFileExtension !== void 0 ? parseImportFileExtension(config.importFileExtension) : inferImportFileExtension({
6404
+ tsconfig,
6405
+ generatedFileExtension
6406
+ });
6407
+ const moduleFormat = config.moduleFormat !== void 0 ? parseModuleFormatFromUnknown(config.moduleFormat) : inferModuleFormat({
6408
+ tsconfig,
6409
+ generatedFileExtension,
6410
+ importFileExtension
6411
+ });
6616
6412
  await generateClient({
6617
6413
  datamodel: options.datamodel,
6618
6414
  schemaPath: options.schemaPath,
6619
6415
  binaryPaths: options.binaryPaths,
6620
6416
  datasources: options.datasources,
6621
6417
  envPaths: options.envPaths,
6622
- outputDir: getOutputPath(options.generator),
6418
+ outputDir,
6623
6419
  runtimeBase: "@prisma/client/runtime",
6624
6420
  dmmf: options.dmmf,
6625
6421
  generator: options.generator,
@@ -6629,48 +6425,15 @@ var PrismaClientTsGenerator = class {
6629
6425
  postinstall: options.postinstall,
6630
6426
  copyEngine: !options.noEngine,
6631
6427
  typedSql: options.typedSql,
6632
- target: options.generator.config.runtime !== void 0 ? parseRuntimeTargetFromUnknown(options.generator.config.runtime) : "nodejs"
6428
+ target,
6429
+ generatedFileExtension,
6430
+ importFileExtension,
6431
+ moduleFormat
6633
6432
  });
6634
6433
  }
6635
6434
  };
6636
-
6637
- // src/utils/types/dmmfToTypes.ts
6638
- function dmmfToTypes(dmmf) {
6639
- return new TSClient({
6640
- dmmf,
6641
- datasources: [],
6642
- clientVersion: "",
6643
- engineVersion: "",
6644
- runtimeBase: "@prisma/client",
6645
- runtimeName: "library",
6646
- schemaPath: "",
6647
- outputDir: "",
6648
- activeProvider: "",
6649
- binaryPaths: {},
6650
- generator: {
6651
- binaryTargets: [],
6652
- config: {},
6653
- name: "prisma-client-ts",
6654
- output: null,
6655
- provider: { value: "prisma-client-ts", fromEnvVar: null },
6656
- previewFeatures: [],
6657
- isCustomOutput: false,
6658
- sourceFilePath: "schema.prisma"
6659
- },
6660
- datamodel: "",
6661
- browser: false,
6662
- deno: false,
6663
- edge: false,
6664
- envPaths: {
6665
- rootEnvPath: null,
6666
- schemaEnvPath: void 0
6667
- },
6668
- target: "nodejs"
6669
- }).toTS();
6670
- }
6671
6435
  export {
6672
6436
  PrismaClientTsGenerator,
6673
- dmmfToTypes,
6674
6437
  externalToInternalDmmf,
6675
6438
  generateClient,
6676
6439
  getDMMF