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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.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,42 +2374,22 @@ 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
 
2334
- // src/TSClient/Generable.ts
2335
- function JS(gen) {
2336
- return gen.toJS?.() ?? "";
2337
- }
2338
- function BrowserJS(gen) {
2339
- return gen.toBrowserJS?.() ?? "";
2340
- }
2341
- function TS(gen) {
2342
- return gen.toTS();
2343
- }
2344
-
2345
2393
  // src/TSClient/Input.ts
2346
2394
  import { uniqueBy } from "@prisma/client-common";
2347
2395
  import * as ts2 from "@prisma/ts-builders";
@@ -2379,28 +2427,28 @@ function getOmitName(modelName) {
2379
2427
  return `${modelName}Omit`;
2380
2428
  }
2381
2429
  function getAggregateName(modelName) {
2382
- return `Aggregate${capitalize2(modelName)}`;
2430
+ return `Aggregate${capitalize3(modelName)}`;
2383
2431
  }
2384
2432
  function getGroupByName(modelName) {
2385
- return `${capitalize2(modelName)}GroupByOutputType`;
2433
+ return `${capitalize3(modelName)}GroupByOutputType`;
2386
2434
  }
2387
2435
  function getAvgAggregateName(modelName) {
2388
- return `${capitalize2(modelName)}AvgAggregateOutputType`;
2436
+ return `${capitalize3(modelName)}AvgAggregateOutputType`;
2389
2437
  }
2390
2438
  function getSumAggregateName(modelName) {
2391
- return `${capitalize2(modelName)}SumAggregateOutputType`;
2439
+ return `${capitalize3(modelName)}SumAggregateOutputType`;
2392
2440
  }
2393
2441
  function getMinAggregateName(modelName) {
2394
- return `${capitalize2(modelName)}MinAggregateOutputType`;
2442
+ return `${capitalize3(modelName)}MinAggregateOutputType`;
2395
2443
  }
2396
2444
  function getMaxAggregateName(modelName) {
2397
- return `${capitalize2(modelName)}MaxAggregateOutputType`;
2445
+ return `${capitalize3(modelName)}MaxAggregateOutputType`;
2398
2446
  }
2399
2447
  function getCountAggregateInputName(modelName) {
2400
- return `${capitalize2(modelName)}CountAggregateInputType`;
2448
+ return `${capitalize3(modelName)}CountAggregateInputType`;
2401
2449
  }
2402
2450
  function getCountAggregateOutputName(modelName) {
2403
- return `${capitalize2(modelName)}CountAggregateOutputType`;
2451
+ return `${capitalize3(modelName)}CountAggregateOutputType`;
2404
2452
  }
2405
2453
  function getAggregateInputType(aggregateOutputType) {
2406
2454
  return aggregateOutputType.replace(/OutputType$/, "InputType");
@@ -2409,13 +2457,13 @@ function getGroupByArgsName(modelName) {
2409
2457
  return `${modelName}GroupByArgs`;
2410
2458
  }
2411
2459
  function getGroupByPayloadName(modelName) {
2412
- return `Get${capitalize2(modelName)}GroupByPayload`;
2460
+ return `Get${capitalize3(modelName)}GroupByPayload`;
2413
2461
  }
2414
2462
  function getAggregateArgsName(modelName) {
2415
- return `${capitalize2(modelName)}AggregateArgs`;
2463
+ return `${capitalize3(modelName)}AggregateArgs`;
2416
2464
  }
2417
2465
  function getAggregateGetName(modelName) {
2418
- return `Get${capitalize2(modelName)}AggregateType`;
2466
+ return `Get${capitalize3(modelName)}AggregateType`;
2419
2467
  }
2420
2468
  function getFieldArgName(field, modelName) {
2421
2469
  if (field.args.length) {
@@ -2473,8 +2521,8 @@ function getModelArgName(modelName, action) {
2473
2521
  assertNever(action, `Unknown action: ${action}`);
2474
2522
  }
2475
2523
  }
2476
- function getPayloadName(modelName, namespace3 = true) {
2477
- if (namespace3) {
2524
+ function getPayloadName(modelName, namespace2 = true) {
2525
+ if (namespace2) {
2478
2526
  return `Prisma.${getPayloadName(modelName, false)}`;
2479
2527
  }
2480
2528
  return `$${modelName}Payload`;
@@ -2482,7 +2530,7 @@ function getPayloadName(modelName, namespace3 = true) {
2482
2530
  function getFieldRefsTypeName(name) {
2483
2531
  return `${name}FieldRefs`;
2484
2532
  }
2485
- function capitalize2(str) {
2533
+ function capitalize3(str) {
2486
2534
  return str[0].toUpperCase() + str.slice(1);
2487
2535
  }
2488
2536
  function getRefAllowedTypeName(type) {
@@ -2494,11 +2542,11 @@ function getRefAllowedTypeName(type) {
2494
2542
  }
2495
2543
  function appendSkipType(context, type) {
2496
2544
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
2497
- return ts.unionType([type, ts.namedType("$Types.Skip")]);
2545
+ return ts.unionType([type, ts.namedType("runtime.Types.Skip")]);
2498
2546
  }
2499
2547
  return type;
2500
2548
  }
2501
- 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"));
2502
2550
 
2503
2551
  // src/utils/common.ts
2504
2552
  function needsNamespace(field) {
@@ -2656,11 +2704,11 @@ import { klona } from "klona";
2656
2704
  import * as ts3 from "@prisma/ts-builders";
2657
2705
 
2658
2706
  // src/TSClient/helpers.ts
2659
- import { capitalize as capitalize4, lowerCase as lowerCase3 } from "@prisma/client-common";
2707
+ import { capitalize as capitalize5, lowerCase as lowerCase3 } from "@prisma/client-common";
2660
2708
  import pluralize2 from "pluralize";
2661
2709
 
2662
2710
  // src/TSClient/jsdoc.ts
2663
- import { capitalize as capitalize3, lowerCase as lowerCase2 } from "@prisma/client-common";
2711
+ import { capitalize as capitalize4, lowerCase as lowerCase2 } from "@prisma/client-common";
2664
2712
  var Docs = {
2665
2713
  cursor: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination#cursor-based-pagination Cursor Docs}`,
2666
2714
  pagination: `{@link https://www.prisma.io/docs/concepts/components/prisma-client/pagination Pagination Docs}`,
@@ -2747,7 +2795,7 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
2747
2795
  body: (ctx) => {
2748
2796
  const onlySelect = ctx.firstScalar ? `
2749
2797
  // Create many ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
2750
- 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}({
2751
2799
  select: { ${ctx.firstScalar.name}: true },
2752
2800
  data: [
2753
2801
  // ... provide data here
@@ -2844,7 +2892,7 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
2844
2892
  body: (ctx) => {
2845
2893
  const onlySelect = ctx.firstScalar ? `
2846
2894
  // Only select the \`${ctx.firstScalar.name}\`
2847
- 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 } })` : "";
2848
2896
  return `Find zero or more ${ctx.plural} that matches the filter.
2849
2897
  ${undefinedNote}
2850
2898
  @param {${getModelArgName(ctx.model.name, ctx.action)}} args - Arguments to filter and select certain fields only.
@@ -3002,7 +3050,7 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
3002
3050
  body: (ctx) => {
3003
3051
  const onlySelect = ctx.firstScalar ? `
3004
3052
  // Update zero or more ${ctx.plural} and only return the \`${ctx.firstScalar.name}\`
3005
- 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}({
3006
3054
  select: { ${ctx.firstScalar.name}: true },
3007
3055
  where: {
3008
3056
  // ... provide filter here
@@ -3081,8 +3129,8 @@ const ${lowerCase2(ctx.mapping.model)} = await ${ctx.method}({
3081
3129
  // src/TSClient/helpers.ts
3082
3130
  function getMethodJSDocBody(action, mapping, model) {
3083
3131
  const ctx = {
3084
- singular: capitalize4(mapping.model),
3085
- plural: capitalize4(mapping.plural),
3132
+ singular: capitalize5(mapping.model),
3133
+ plural: capitalize5(mapping.plural),
3086
3134
  firstScalar: model.fields.find((f) => f.kind === "scalar"),
3087
3135
  method: `prisma.${lowerCase3(mapping.model)}.${action}`,
3088
3136
  action,
@@ -3126,7 +3174,6 @@ var ArgsTypeBuilder = class {
3126
3174
  ).setDocComment(ts3.docComment(`${type.name} ${action ?? "without action"}`));
3127
3175
  }
3128
3176
  moduleExport;
3129
- hasDefaultName = true;
3130
3177
  addProperty(prop) {
3131
3178
  this.moduleExport.declaration.type.add(prop);
3132
3179
  }
@@ -3176,7 +3223,6 @@ var ArgsTypeBuilder = class {
3176
3223
  return this;
3177
3224
  }
3178
3225
  setGeneratedName(name) {
3179
- this.hasDefaultName = false;
3180
3226
  this.moduleExport.declaration.setName(name);
3181
3227
  return this;
3182
3228
  }
@@ -3201,7 +3247,7 @@ var ModelFieldRefs = class {
3201
3247
  /**
3202
3248
  * Fields of the ${name} model
3203
3249
  */
3204
- interface ${getFieldRefsTypeName(name)} {
3250
+ export interface ${getFieldRefsTypeName(name)} {
3205
3251
  ${this.stringifyFields()}
3206
3252
  }
3207
3253
  `;
@@ -3276,8 +3322,8 @@ function buildOutputField(field) {
3276
3322
  }
3277
3323
  function enumTypeName(ref) {
3278
3324
  const name = ref.type;
3279
- const namespace3 = ref.namespace === "model" ? "$Enums" : "Prisma";
3280
- return `${namespace3}.${name}`;
3325
+ const namespace2 = ref.namespace === "model" ? "$Enums" : "Prisma";
3326
+ return `${namespace2}.${name}`;
3281
3327
  }
3282
3328
 
3283
3329
  // src/TSClient/Payload.ts
@@ -3299,7 +3345,7 @@ function buildModelPayload(model, context) {
3299
3345
  scalars.add(buildModelOutputProperty(field, context.dmmf));
3300
3346
  }
3301
3347
  }
3302
- 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)));
3303
3349
  const payloadTypeDeclaration = ts5.typeDeclaration(
3304
3350
  getPayloadName(model.name, false),
3305
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))
@@ -3328,9 +3374,9 @@ function buildOmitType({ modelName, fields, context }) {
3328
3374
  (field) => field.outputType.location === "scalar" || field.outputType.location === "enumTypes" || context.dmmf.isComposite(field.outputType.type)
3329
3375
  ).map((field) => ts6.stringLiteral(field.name))
3330
3376
  );
3331
- 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));
3332
3378
  if (context.isPreviewFeatureOn("strictUndefinedChecks")) {
3333
- omitType.addGenericArgument(ts6.namedType("$Types.Skip"));
3379
+ omitType.addGenericArgument(ts6.namedType("runtime.Types.Skip"));
3334
3380
  }
3335
3381
  return buildExport(getOmitName(modelName), omitType);
3336
3382
  }
@@ -3341,7 +3387,7 @@ function buildSelectType({
3341
3387
  context
3342
3388
  }) {
3343
3389
  const objectType9 = buildSelectOrIncludeObject(modelName, fields, context);
3344
- 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));
3345
3391
  return buildExport(typeName, selectType);
3346
3392
  }
3347
3393
  function modelResultExtensionsType(modelName) {
@@ -3393,6 +3439,18 @@ function getModelActions(dmmf, name) {
3393
3439
  return mappingKeys;
3394
3440
  }
3395
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
+
3396
3454
  // src/TSClient/Model.ts
3397
3455
  var Model = class {
3398
3456
  constructor(model, context) {
@@ -3482,7 +3540,7 @@ var Model = class {
3482
3540
  return `
3483
3541
 
3484
3542
 
3485
- export type ${groupByArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3543
+ export type ${groupByArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3486
3544
  ${indent3(
3487
3545
  groupByRootField.args.map((arg) => {
3488
3546
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.groupBy, arg) };
@@ -3575,7 +3633,7 @@ ${aggregateTypes.length > 1 ? aggregateTypes.slice(1).map((type) => {
3575
3633
  return new InputType(newType, this.context).toTS();
3576
3634
  }).join("\n") : ""}
3577
3635
 
3578
- export type ${aggregateArgsName}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
3636
+ export type ${aggregateArgsName}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
3579
3637
  ${indent3(
3580
3638
  aggregateRootField.args.map((arg) => {
3581
3639
  const updatedArg = { ...arg, comment: getArgFieldJSDoc(this.type, DMMF2.ModelAction.aggregate, arg) };
@@ -3614,7 +3672,7 @@ export type ${getAggregateGetName(model.name)}<T extends ${getAggregateArgsName(
3614
3672
  const modelTypeExport = ts7.moduleExport(
3615
3673
  ts7.typeDeclaration(
3616
3674
  model.name,
3617
- ts7.namedType(`$Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3675
+ ts7.namedType(`runtime.Types.Result.DefaultSelection`).addGenericArgument(ts7.namedType(getPayloadName(model.name)))
3618
3676
  )
3619
3677
  ).setDocComment(ts7.docComment(docs));
3620
3678
  return ts7.stringify(modelTypeExport);
@@ -3692,9 +3750,9 @@ ${omitType}${includeType}${createManyAndReturnIncludeType}${updateManyAndReturnI
3692
3750
 
3693
3751
  ${ts7.stringify(buildModelPayload(this.model, this.context), { newLine: "none" })}
3694
3752
 
3695
- type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3753
+ export type ${model.name}GetPayload<S extends boolean | null | undefined | ${getModelArgName(
3696
3754
  model.name
3697
- )}> = $Result.GetResult<${getPayloadName(model.name)}, S>
3755
+ )}> = runtime.Types.Result.GetResult<${getPayloadName(model.name)}, S>
3698
3756
 
3699
3757
  ${isComposite ? "" : new ModelDelegate(this.type, this.context).toTS()}
3700
3758
 
@@ -3738,7 +3796,7 @@ var ModelDelegate = class {
3738
3796
  excludedArgsForCount.push("relationLoadStrategy");
3739
3797
  }
3740
3798
  const excludedArgsForCountType = excludedArgsForCount.map((name2) => `'${name2}'`).join(" | ");
3741
- 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> =
3742
3800
  Omit<${getModelArgName(name, DMMF2.ModelAction.findMany)}, ${excludedArgsForCountType}> & {
3743
3801
  select?: ${getCountAggregateInputName(name)} | true
3744
3802
  }
@@ -3754,7 +3812,7 @@ ${availableActions.includes(DMMF2.ModelAction.aggregate) ? `${indent3(getMethodJ
3754
3812
  count<T extends ${countArgsName}>(
3755
3813
  args?: Subset<T, ${countArgsName}>,
3756
3814
  ): Prisma.PrismaPromise<
3757
- T extends $Utils.Record<'select', any>
3815
+ T extends runtime.Types.Utils.Record<'select', any>
3758
3816
  ? T['select'] extends true
3759
3817
  ? number
3760
3818
  : GetScalarType<T['select'], ${getCountAggregateOutputName(name)}>
@@ -3885,16 +3943,16 @@ function getReturnType({
3885
3943
  isNullable = false
3886
3944
  }) {
3887
3945
  if (actionName === DMMF2.ModelAction.count) {
3888
- return ts7.promise(ts7.numberType);
3946
+ return promise(ts7.numberType);
3889
3947
  }
3890
3948
  if (actionName === DMMF2.ModelAction.aggregate) {
3891
- return ts7.promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3949
+ return promise(ts7.namedType(getAggregateGetName(modelName)).addGenericArgument(ts7.namedType("T")));
3892
3950
  }
3893
3951
  if (actionName === DMMF2.ModelAction.findRaw || actionName === DMMF2.ModelAction.aggregateRaw) {
3894
- return ts7.prismaPromise(ts7.namedType("JsonObject"));
3952
+ return prismaPromise(ts7.namedType("JsonObject"));
3895
3953
  }
3896
3954
  if (actionName === DMMF2.ModelAction.deleteMany || actionName === DMMF2.ModelAction.updateMany || actionName === DMMF2.ModelAction.createMany) {
3897
- return ts7.prismaPromise(ts7.namedType("BatchPayload"));
3955
+ return prismaPromise(ts7.namedType("BatchPayload"));
3898
3956
  }
3899
3957
  const isList = actionName === DMMF2.ModelAction.findMany || actionName === DMMF2.ModelAction.createManyAndReturn || actionName === DMMF2.ModelAction.updateManyAndReturn;
3900
3958
  if (isList) {
@@ -3902,7 +3960,7 @@ function getReturnType({
3902
3960
  if (isChaining) {
3903
3961
  result = ts7.unionType(result).addVariant(ts7.namedType("Null"));
3904
3962
  }
3905
- return ts7.prismaPromise(result);
3963
+ return prismaPromise(result);
3906
3964
  }
3907
3965
  if (isChaining && actionName === DMMF2.ModelAction.findUniqueOrThrow) {
3908
3966
  const nullType7 = isNullable ? ts7.nullType : ts7.namedType("Null");
@@ -3919,11 +3977,11 @@ function getFluentWrapper(modelName, resultType, nullType7 = ts7.neverType) {
3919
3977
  return ts7.namedType(fluentWrapperName(modelName)).addGenericArgument(resultType).addGenericArgument(nullType7).addGenericArgument(extArgsParam.toArgument()).addGenericArgument(ts7.namedType("GlobalOmitOptions"));
3920
3978
  }
3921
3979
  function getResultType(modelName, actionName) {
3922
- 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"));
3923
3981
  }
3924
3982
  function buildFluentWrapperDefinition(modelName, outputType, context) {
3925
3983
  const definition = ts7.interfaceDeclaration(fluentWrapperName(modelName));
3926
- 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")));
3927
3985
  definition.add(ts7.property(ts7.toStringTag, ts7.stringLiteral("PrismaPromise")).readonly());
3928
3986
  definition.addMultiple(
3929
3987
  outputType.fields.filter(
@@ -3949,7 +4007,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3949
4007
  @param onrejected The callback to execute when the Promise is rejected.
3950
4008
  @returns A Promise for the completion of which ever callback is executed.
3951
4009
  `
3952
- ).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")])))
3953
4011
  );
3954
4012
  definition.add(
3955
4013
  ts7.method("catch").setDocComment(
@@ -3958,7 +4016,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3958
4016
  @param onrejected The callback to execute when the Promise is rejected.
3959
4017
  @returns A Promise for the completion of the callback.
3960
4018
  `
3961
- ).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")])))
3962
4020
  );
3963
4021
  definition.add(
3964
4022
  ts7.method("finally").setDocComment(
@@ -3970,7 +4028,7 @@ function buildFluentWrapperDefinition(modelName, outputType, context) {
3970
4028
  `
3971
4029
  ).addParameter(
3972
4030
  ts7.parameter("onfinally", ts7.unionType([ts7.functionType(), ts7.undefinedType, ts7.nullType])).optional()
3973
- ).setReturnType(ts7.promise(ts7.namedType("T")))
4031
+ ).setReturnType(promise(ts7.namedType("T")))
3974
4032
  );
3975
4033
  return ts7.moduleExport(definition).setDocComment(ts7.docComment`
3976
4034
  The delegate class that acts as a "Promise-like" for ${modelName}.
@@ -4000,13 +4058,13 @@ function fluentWrapperName(modelName) {
4000
4058
  }
4001
4059
 
4002
4060
  // src/TSClient/TSClient.ts
4061
+ import crypto from "node:crypto";
4062
+ import path2 from "node:path";
4003
4063
  import { datamodelEnumToSchemaEnum } from "@prisma/dmmf";
4004
- import { ClientEngineType as ClientEngineType2, getClientEngineType, pathToPosix as pathToPosix3 } from "@prisma/internals";
4064
+ import { ClientEngineType as ClientEngineType2, getClientEngineType, pathToPosix as pathToPosix2 } from "@prisma/internals";
4005
4065
  import * as ts12 from "@prisma/ts-builders";
4006
4066
  import ciInfo from "ci-info";
4007
- import crypto from "crypto";
4008
- import indent8 from "indent-string";
4009
- import path2 from "path";
4067
+ import indent7 from "indent-string";
4010
4068
 
4011
4069
  // src/dmmf.ts
4012
4070
  import { keyBy } from "@prisma/client-common";
@@ -4062,8 +4120,8 @@ var DMMFHelper = class {
4062
4120
  Object.values(this.mappings.otherOperations.read)
4063
4121
  ].flat();
4064
4122
  }
4065
- hasEnumInNamespace(enumName, namespace3) {
4066
- 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;
4067
4125
  }
4068
4126
  resolveInputObjectType(ref) {
4069
4127
  return this.inputTypesByName.get(fullyQualifiedName(ref.type, ref.namespace));
@@ -4118,9 +4176,9 @@ var DMMFHelper = class {
4118
4176
  return result;
4119
4177
  }
4120
4178
  };
4121
- function fullyQualifiedName(typeName, namespace3) {
4122
- if (namespace3) {
4123
- return `${namespace3}.${typeName}`;
4179
+ function fullyQualifiedName(typeName, namespace2) {
4180
+ if (namespace2) {
4181
+ return `${namespace2}.${typeName}`;
4124
4182
  }
4125
4183
  return typeName;
4126
4184
  }
@@ -4240,40 +4298,17 @@ function buildDebugInitialization(edge) {
4240
4298
  }
4241
4299
  const debugVar = getRuntimeEdgeEnvVar("DEBUG");
4242
4300
  return `if (${debugVar}) {
4243
- Debug.enable(${debugVar})
4301
+ runtime.Debug.enable(${debugVar})
4244
4302
  }
4245
4303
  `;
4246
4304
  }
4247
4305
 
4248
4306
  // src/utils/buildDirname.ts
4249
- import { pathToPosix } from "@prisma/internals";
4250
- function buildDirname(edge, relativeOutdir) {
4307
+ function buildDirname(edge) {
4251
4308
  if (edge === true) {
4252
- return buildDirnameDefault();
4309
+ return `config.dirname = '/'`;
4253
4310
  }
4254
- return buildDirnameFind(relativeOutdir);
4255
- }
4256
- function buildDirnameFind(relativeOutdir) {
4257
- return `
4258
- const fs = require('fs')
4259
-
4260
- config.dirname = __dirname
4261
- if (!fs.existsSync(path.join(__dirname, 'schema.prisma'))) {
4262
- const alternativePaths = [
4263
- ${JSON.stringify(pathToPosix(relativeOutdir))},
4264
- ${JSON.stringify(pathToPosix(relativeOutdir).split("/").slice(1).join("/"))},
4265
- ]
4266
-
4267
- const alternativePath = alternativePaths.find((altPath) => {
4268
- return fs.existsSync(path.join(process.cwd(), altPath, 'schema.prisma'))
4269
- }) ?? alternativePaths[0]
4270
-
4271
- config.dirname = path.join(process.cwd(), alternativePath)
4272
- config.isBundled = true
4273
- }`;
4274
- }
4275
- function buildDirnameDefault() {
4276
- return `config.dirname = '/'`;
4311
+ return `config.dirname = __dirname`;
4277
4312
  }
4278
4313
 
4279
4314
  // src/utils/buildDMMF.ts
@@ -4291,65 +4326,65 @@ function buildRuntimeDataModel(datamodel, runtimeName) {
4291
4326
  }
4292
4327
  const datamodelString = escapeJson(JSON.stringify(prunedDataModel));
4293
4328
  return `
4294
- config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})
4295
- defineDmmfProperty(exports.Prisma, config.runtimeDataModel)`;
4329
+ config.runtimeDataModel = JSON.parse(${JSON.stringify(datamodelString)})`;
4296
4330
  }
4297
4331
 
4298
- // src/utils/buildGetQueryCompilerWasmModule.ts
4299
- function buildQueryCompilerWasmModule(wasm, copyCompiler, runtimeName) {
4300
- if (copyCompiler && runtimeName === "client") {
4301
- return `config.compilerWasm = {
4302
- getRuntime: () => require('./query_compiler_bg.js'),
4303
- getQueryCompilerWasmModule: async () => {
4304
- const queryCompilerWasmFilePath = require('path').join(config.dirname, 'query_compiler_bg.wasm')
4305
- const queryCompilerWasmFileBytes = require('fs').readFileSync(queryCompilerWasmFilePath)
4306
-
4307
- return new WebAssembly.Module(queryCompilerWasmFileBytes)
4308
- }
4309
- }`;
4310
- }
4311
- if (copyCompiler && runtimeName === "client" && wasm === true) {
4312
- return `config.compilerWasm = {
4313
- getRuntime: () => require('./query_compiler_bg.js'),
4314
- getQueryCompilerWasmModule: async () => {
4315
- const loader = (await import('#wasm-compiler-loader')).default
4316
- const compiler = (await loader).default
4317
- return compiler
4332
+ // src/utils/buildGetWasmModule.ts
4333
+ import { capitalize as capitalize6 } from "@prisma/client-common";
4334
+ import { match } from "ts-pattern";
4335
+ function buildGetWasmModule({
4336
+ component,
4337
+ runtimeName,
4338
+ runtimeBase,
4339
+ target,
4340
+ activeProvider,
4341
+ moduleFormat
4342
+ }) {
4343
+ const capitalizedComponent = capitalize6(component);
4344
+ const wasmPathBase = `${runtimeBase}/query_compiler_bg.${activeProvider}`;
4345
+ const wasmBindingsPath = `${wasmPathBase}.mjs`;
4346
+ const wasmModulePath = `${wasmPathBase}.wasm`;
4347
+ const buildNodeLoader = match(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
4348
+ const buildEdgeLoader = runtimeName === "wasm" && component === "engine";
4349
+ if (buildNodeLoader) {
4350
+ return `config.${component}Wasm = {
4351
+ getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
4352
+
4353
+ getQuery${capitalizedComponent}WasmModule: async () => {
4354
+ const { readFile } = await import('node:fs/promises')
4355
+ ${buildRequire(moduleFormat)}
4356
+ const wasmModulePath = require.resolve(${JSON.stringify(wasmModulePath)})
4357
+ const wasmModuleBytes = await readFile(wasmModulePath)
4358
+
4359
+ return new globalThis.WebAssembly.Module(wasmModuleBytes)
4318
4360
  }
4319
4361
  }`;
4320
4362
  }
4321
- return `config.compilerWasm = undefined`;
4322
- }
4323
-
4324
- // src/utils/buildGetQueryEngineWasmModule.ts
4325
- function buildQueryEngineWasmModule(wasm, copyEngine, runtimeName) {
4326
- if (copyEngine && runtimeName === "library" && process.env.PRISMA_CLIENT_FORCE_WASM) {
4327
- return `config.engineWasm = {
4328
- getRuntime: () => require('./query_engine_bg.js'),
4329
- getQueryEngineWasmModule: async () => {
4330
- const queryEngineWasmFilePath = require('path').join(config.dirname, 'query_engine_bg.wasm')
4331
- const queryEngineWasmFileBytes = require('fs').readFileSync(queryEngineWasmFilePath)
4363
+ if (buildEdgeLoader) {
4364
+ const fullWasmModulePath = target === "edge-light" ? `${wasmModulePath}?module` : wasmModulePath;
4365
+ return `config.${component}Wasm = {
4366
+ getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
4332
4367
 
4333
- return new WebAssembly.Module(queryEngineWasmFileBytes)
4334
- }
4335
- }`;
4336
- }
4337
- if (copyEngine && wasm === true) {
4338
- return `config.engineWasm = {
4339
- getRuntime: () => require('./query_engine_bg.js'),
4340
- getQueryEngineWasmModule: async () => {
4341
- const loader = (await import('#wasm-engine-loader')).default
4342
- const engine = (await loader).default
4343
- return engine
4368
+ getQuery${capitalizedComponent}WasmModule: async () => {
4369
+ const { default: module } = await import(${JSON.stringify(fullWasmModulePath)})
4370
+ return module
4344
4371
  }
4345
4372
  }`;
4346
4373
  }
4347
- return `config.engineWasm = undefined`;
4374
+ return `config.${component}Wasm = undefined`;
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
+ `;
4348
4383
  }
4349
4384
 
4350
4385
  // src/utils/buildNFTAnnotations.ts
4351
4386
  import { getNodeAPIName } from "@prisma/get-platform";
4352
- import { ClientEngineType, parseAWSNodejsRuntimeEnvVarVersion, pathToPosix as pathToPosix2 } from "@prisma/internals";
4387
+ import { ClientEngineType, parseAWSNodejsRuntimeEnvVarVersion, pathToPosix } from "@prisma/internals";
4353
4388
  import path from "path";
4354
4389
  function buildNFTAnnotations(noEngine, engineType, binaryTargets, relativeOutdir) {
4355
4390
  if (noEngine === true) return "";
@@ -4387,207 +4422,70 @@ function buildNFTAnnotation(fileName, relativeOutdir) {
4387
4422
  const relativeFilePath = path.join(relativeOutdir, fileName);
4388
4423
  return `
4389
4424
  // file annotations for bundling tools to include these files
4390
- path.join(__dirname, ${JSON.stringify(pathToPosix2(fileName))});
4391
- path.join(process.cwd(), ${JSON.stringify(pathToPosix2(relativeFilePath))})`;
4392
- }
4393
-
4394
- // src/utils/buildRequirePath.ts
4395
- function buildRequirePath(edge) {
4396
- if (edge === true) return "";
4397
- return `
4398
- const path = require('path')`;
4399
- }
4400
-
4401
- // src/utils/buildWarnEnvConflicts.ts
4402
- function buildWarnEnvConflicts(edge, runtimeBase, runtimeName) {
4403
- if (edge === true) return "";
4404
- return `
4405
- const { warnEnvConflicts } = require('${runtimeBase}/${runtimeName}')
4406
-
4407
- warnEnvConflicts({
4408
- rootEnvPath: config.relativeEnvPaths.rootEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.rootEnvPath),
4409
- schemaEnvPath: config.relativeEnvPaths.schemaEnvPath && path.resolve(config.dirname, config.relativeEnvPaths.schemaEnvPath)
4410
- })`;
4425
+ path.join(__dirname, ${JSON.stringify(pathToPosix(fileName))})
4426
+ path.join(process.cwd(), ${JSON.stringify(pathToPosix(relativeFilePath))})`;
4411
4427
  }
4412
4428
 
4413
4429
  // src/TSClient/common.ts
4414
- import indent4 from "indent-string";
4415
- var commonCodeJS = ({
4430
+ var commonCodeTS = ({
4416
4431
  runtimeBase,
4417
4432
  runtimeName,
4418
- browser,
4419
4433
  clientVersion,
4420
4434
  engineVersion,
4421
4435
  generator,
4422
- deno
4423
- }) => `${deno ? "const exports = {}" : ""}
4424
- Object.defineProperty(exports, "__esModule", { value: true });
4425
- ${deno ? `
4426
- import {
4427
- PrismaClientKnownRequestError,
4428
- PrismaClientUnknownRequestError,
4429
- PrismaClientRustPanicError,
4430
- PrismaClientInitializationError,
4431
- PrismaClientValidationError,
4432
- getPrismaClient,
4433
- sqltag,
4434
- empty,
4435
- join,
4436
- raw,
4437
- Decimal,
4438
- Debug,
4439
- objectEnumValues,
4440
- makeStrictEnum,
4441
- Extensions,
4442
- defineDmmfProperty,
4443
- Public,
4444
- getRuntime,
4445
- skip
4446
- } from '${runtimeBase}/${runtimeName}'` : browser ? `
4447
- const {
4448
- Decimal,
4449
- objectEnumValues,
4450
- makeStrictEnum,
4451
- Public,
4452
- getRuntime,
4453
- skip
4454
- } = require('${runtimeBase}/${runtimeName}')
4455
- ` : `
4456
- const {
4457
- PrismaClientKnownRequestError,
4458
- PrismaClientUnknownRequestError,
4459
- PrismaClientRustPanicError,
4460
- PrismaClientInitializationError,
4461
- PrismaClientValidationError,
4462
- getPrismaClient,
4463
- sqltag,
4464
- empty,
4465
- join,
4466
- raw,
4467
- skip,
4468
- Decimal,
4469
- Debug,
4470
- objectEnumValues,
4471
- makeStrictEnum,
4472
- Extensions,
4473
- warnOnce,
4474
- defineDmmfProperty,
4475
- Public,
4476
- getRuntime,
4477
- createParam,
4478
- } = require('${runtimeBase}/${runtimeName}')
4479
- `}
4480
-
4481
- const Prisma = {}
4482
-
4483
- exports.Prisma = Prisma
4484
- exports.$Enums = {}
4436
+ moduleFormat,
4437
+ edge
4438
+ }) => ({
4439
+ tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}'
4440
+ ${buildPreamble(edge, moduleFormat)}
4485
4441
 
4486
- /**
4487
- * Prisma Client JS version: ${clientVersion}
4488
- * Query Engine version: ${engineVersion}
4489
- */
4490
- Prisma.prismaVersion = {
4491
- client: "${clientVersion}",
4492
- engine: "${engineVersion}"
4493
- }
4442
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4443
+ `,
4444
+ ts: () => `export type DMMF = typeof runtime.DMMF
4494
4445
 
4495
- Prisma.PrismaClientKnownRequestError = ${notSupportOnBrowser("PrismaClientKnownRequestError", browser)};
4496
- Prisma.PrismaClientUnknownRequestError = ${notSupportOnBrowser("PrismaClientUnknownRequestError", browser)}
4497
- Prisma.PrismaClientRustPanicError = ${notSupportOnBrowser("PrismaClientRustPanicError", browser)}
4498
- Prisma.PrismaClientInitializationError = ${notSupportOnBrowser("PrismaClientInitializationError", browser)}
4499
- Prisma.PrismaClientValidationError = ${notSupportOnBrowser("PrismaClientValidationError", browser)}
4500
- Prisma.Decimal = Decimal
4446
+ export type PrismaPromise<T> = runtime.Types.Public.PrismaPromise<T>
4501
4447
 
4502
4448
  /**
4503
- * Re-export of sql-template-tag
4449
+ * Validator
4504
4450
  */
4505
- Prisma.sql = ${notSupportOnBrowser("sqltag", browser)}
4506
- Prisma.empty = ${notSupportOnBrowser("empty", browser)}
4507
- Prisma.join = ${notSupportOnBrowser("join", browser)}
4508
- Prisma.raw = ${notSupportOnBrowser("raw", browser)}
4509
- Prisma.validator = Public.validator
4510
-
4511
- /**
4512
- * Extensions
4513
- */
4514
- Prisma.getExtensionContext = ${notSupportOnBrowser("Extensions.getExtensionContext", browser)}
4515
- Prisma.defineExtension = ${notSupportOnBrowser("Extensions.defineExtension", browser)}
4451
+ export const validator = runtime.Public.validator
4516
4452
 
4517
4453
  /**
4518
- * Shorthand utilities for JSON filtering
4454
+ * Prisma Errors
4519
4455
  */
4520
- Prisma.DbNull = objectEnumValues.instances.DbNull
4521
- Prisma.JsonNull = objectEnumValues.instances.JsonNull
4522
- Prisma.AnyNull = objectEnumValues.instances.AnyNull
4523
4456
 
4524
- Prisma.NullTypes = {
4525
- DbNull: objectEnumValues.classes.DbNull,
4526
- JsonNull: objectEnumValues.classes.JsonNull,
4527
- AnyNull: objectEnumValues.classes.AnyNull
4528
- }
4457
+ export const PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4458
+ export type PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4529
4459
 
4530
- ${buildPrismaSkipJs(generator.previewFeatures)}
4531
- `;
4532
- var notSupportOnBrowser = (fnc, browser) => {
4533
- if (browser) {
4534
- return `() => {
4535
- const runtimeName = getRuntime().prettyName;
4536
- throw new Error(\`${fnc} is unable to run in this browser environment, or has been bundled for the browser (running in \${runtimeName}).
4537
- In case this error is unexpected for you, please report it in https://pris.ly/prisma-prisma-bug-report\`,
4538
- )}`;
4539
- }
4540
- return fnc;
4541
- };
4542
- var commonCodeTS = ({
4543
- runtimeBase,
4544
- runtimeName,
4545
- clientVersion,
4546
- engineVersion,
4547
- generator
4548
- }) => ({
4549
- tsWithoutNamespace: () => `import * as runtime from '${runtimeBase}/${runtimeName}';
4550
- import $Types = runtime.Types // general types
4551
- import $Public = runtime.Types.Public
4552
- import $Utils = runtime.Types.Utils
4553
- import $Extensions = runtime.Types.Extensions
4554
- import $Result = runtime.Types.Result
4555
-
4556
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4557
- `,
4558
- ts: () => `export import DMMF = runtime.DMMF
4460
+ export const PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4461
+ export type PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4559
4462
 
4560
- export type PrismaPromise<T> = $Public.PrismaPromise<T>
4463
+ export const PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4464
+ export type PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4561
4465
 
4562
- /**
4563
- * Validator
4564
- */
4565
- export import validator = runtime.Public.validator
4466
+ export const PrismaClientInitializationError = runtime.PrismaClientInitializationError
4467
+ export type PrismaClientInitializationError = runtime.PrismaClientInitializationError
4566
4468
 
4567
- /**
4568
- * Prisma Errors
4569
- */
4570
- export import PrismaClientKnownRequestError = runtime.PrismaClientKnownRequestError
4571
- export import PrismaClientUnknownRequestError = runtime.PrismaClientUnknownRequestError
4572
- export import PrismaClientRustPanicError = runtime.PrismaClientRustPanicError
4573
- export import PrismaClientInitializationError = runtime.PrismaClientInitializationError
4574
- export import PrismaClientValidationError = runtime.PrismaClientValidationError
4469
+ export const PrismaClientValidationError = runtime.PrismaClientValidationError
4470
+ export type PrismaClientValidationError = runtime.PrismaClientValidationError
4575
4471
 
4576
4472
  /**
4577
4473
  * Re-export of sql-template-tag
4578
4474
  */
4579
- export import sql = runtime.sqltag
4580
- export import empty = runtime.empty
4581
- export import join = runtime.join
4582
- export import raw = runtime.raw
4583
- 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
4584
4481
 
4585
4482
  ${buildPrismaSkipTs(generator.previewFeatures)}
4586
4483
 
4587
4484
  /**
4588
4485
  * Decimal.js
4589
4486
  */
4590
- export import Decimal = runtime.Decimal
4487
+ export const Decimal = runtime.Decimal
4488
+ export type Decimal = runtime.Decimal
4591
4489
 
4592
4490
  export type DecimalJsLike = runtime.DecimalJsLike
4593
4491
 
@@ -4602,46 +4500,43 @@ export type MetricHistogramBucket = runtime.MetricHistogramBucket
4602
4500
  /**
4603
4501
  * Extensions
4604
4502
  */
4605
- export import Extension = $Extensions.UserArgs
4606
- export import getExtensionContext = runtime.Extensions.getExtensionContext
4607
- export import Args = $Public.Args
4608
- export import Payload = $Public.Payload
4609
- export import Result = $Public.Result
4610
- 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
+ }
4611
4514
 
4612
4515
  /**
4613
4516
  * Prisma Client JS version: ${clientVersion}
4614
4517
  * Query Engine version: ${engineVersion}
4615
4518
  */
4616
- export type PrismaVersion = {
4617
- client: string
4519
+ export const prismaVersion: PrismaVersion = {
4520
+ client: "${clientVersion}",
4521
+ engine: "${engineVersion}"
4618
4522
  }
4619
4523
 
4620
- export const prismaVersion: PrismaVersion
4621
-
4622
4524
  /**
4623
4525
  * Utility Types
4624
4526
  */
4625
4527
 
4626
4528
 
4627
- export import JsonObject = runtime.JsonObject
4628
- export import JsonArray = runtime.JsonArray
4629
- export import JsonValue = runtime.JsonValue
4630
- export import InputJsonObject = runtime.InputJsonObject
4631
- export import InputJsonArray = runtime.InputJsonArray
4632
- 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
4633
4535
 
4634
- /**
4635
- * Types of the values used to represent different kinds of \`null\` values when working with JSON fields.
4636
- *
4637
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4638
- */
4639
- namespace NullTypes {
4640
- ${buildNullClass("DbNull")}
4641
-
4642
- ${buildNullClass("JsonNull")}
4643
-
4644
- ${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),
4645
4540
  }
4646
4541
 
4647
4542
  /**
@@ -4649,21 +4544,21 @@ ${buildNullClass("AnyNull")}
4649
4544
  *
4650
4545
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4651
4546
  */
4652
- export const DbNull: NullTypes.DbNull
4547
+ export const DbNull = runtime.objectEnumValues.instances.DbNull
4653
4548
 
4654
4549
  /**
4655
4550
  * Helper for filtering JSON entries that have JSON \`null\` values (not empty on the db)
4656
4551
  *
4657
4552
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4658
4553
  */
4659
- export const JsonNull: NullTypes.JsonNull
4554
+ export const JsonNull = runtime.objectEnumValues.instances.JsonNull
4660
4555
 
4661
4556
  /**
4662
4557
  * Helper for filtering JSON entries that are \`Prisma.DbNull\` or \`Prisma.JsonNull\`
4663
4558
  *
4664
4559
  * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4665
4560
  */
4666
- export const AnyNull: NullTypes.AnyNull
4561
+ export const AnyNull = runtime.objectEnumValues.instances.AnyNull
4667
4562
 
4668
4563
  type SelectAndInclude = {
4669
4564
  select: any
@@ -4675,16 +4570,6 @@ type SelectAndOmit = {
4675
4570
  omit: any
4676
4571
  }
4677
4572
 
4678
- /**
4679
- * Get the type of the value, that the Promise holds.
4680
- */
4681
- export type PromiseType<T extends PromiseLike<any>> = T extends PromiseLike<infer U> ? U : T;
4682
-
4683
- /**
4684
- * Get the return type of a function which returns a Promise.
4685
- */
4686
- export type PromiseReturnType<T extends (...args: any) => $Utils.JsPromise<any>> = PromiseType<ReturnType<T>>
4687
-
4688
4573
  /**
4689
4574
  * From T, pick a set of properties whose keys are in the union K
4690
4575
  */
@@ -4692,19 +4577,8 @@ type Prisma__Pick<T, K extends keyof T> = {
4692
4577
  [P in K]: T[P];
4693
4578
  };
4694
4579
 
4695
-
4696
4580
  export type Enumerable<T> = T | Array<T>;
4697
4581
 
4698
- export type RequiredKeys<T> = {
4699
- [K in keyof T]-?: {} extends Prisma__Pick<T, K> ? never : K
4700
- }[keyof T]
4701
-
4702
- export type TruthyKeys<T> = keyof {
4703
- [K in keyof T as T[K] extends false | undefined | null ? never : K]: K
4704
- }
4705
-
4706
- export type TrueKeys<T> = TruthyKeys<Prisma__Pick<T, RequiredKeys<T>>>
4707
-
4708
4582
  /**
4709
4583
  * Subset
4710
4584
  * @desc From \`T\` pick properties that exist in \`U\`. Simple version of Intersection
@@ -4821,7 +4695,6 @@ type _Merge<U extends object> = IntersectOf<Overwrite<U, {
4821
4695
  }>>;
4822
4696
 
4823
4697
  type Key = string | number | symbol;
4824
- type AtBasic<O extends object, K extends Key> = K extends keyof O ? O[K] : never;
4825
4698
  type AtStrict<O extends object, K extends Key> = O[K & keyof O];
4826
4699
  type AtLoose<O extends object, K extends Key> = O extends unknown ? AtStrict<O, K> : never;
4827
4700
  export type At<O extends object, K extends Key, strict extends Boolean = 1> = {
@@ -4845,7 +4718,7 @@ type _Record<K extends keyof any, T> = {
4845
4718
  type NoExpand<T> = T extends unknown ? T : never;
4846
4719
 
4847
4720
  // this type assumes the passed object is entirely optional
4848
- type AtLeast<O extends object, K extends string> = NoExpand<
4721
+ export type AtLeast<O extends object, K extends string> = NoExpand<
4849
4722
  O extends unknown
4850
4723
  ? | (K extends keyof O ? { [P in K]: O[P] } & O : O)
4851
4724
  | {[P in keyof O as P extends K ? P : never]-?: O[P]} & O
@@ -4858,19 +4731,10 @@ export type Strict<U extends object> = ComputeRaw<_Strict<U>>;
4858
4731
 
4859
4732
  export type Merge<U extends object> = ComputeRaw<_Merge<Strict<U>>>;
4860
4733
 
4861
- /**
4862
- A [[Boolean]]
4863
- */
4864
4734
  export type Boolean = True | False
4865
4735
 
4866
- // /**
4867
- // 1
4868
- // */
4869
4736
  export type True = 1
4870
4737
 
4871
- /**
4872
- 0
4873
- */
4874
4738
  export type False = 0
4875
4739
 
4876
4740
  export type Not<B extends Boolean> = {
@@ -4901,16 +4765,6 @@ export type Or<B1 extends Boolean, B2 extends Boolean> = {
4901
4765
 
4902
4766
  export type Keys<U extends Union> = U extends unknown ? keyof U : never
4903
4767
 
4904
- type Cast<A, B> = A extends B ? A : B;
4905
-
4906
- export const type: unique symbol;
4907
-
4908
-
4909
-
4910
- /**
4911
- * Used by group by
4912
- */
4913
-
4914
4768
  export type GetScalarType<T, O> = O extends object ? {
4915
4769
  [P in keyof T]: P extends keyof O
4916
4770
  ? O[P]
@@ -4962,43 +4816,36 @@ type FieldRefInputType<Model, FieldType> = Model extends never ? never : FieldRe
4962
4816
 
4963
4817
  `
4964
4818
  });
4965
- function buildNullClass(name) {
4966
- const source = `/**
4967
- * Type of \`Prisma.${name}\`.
4968
- *
4969
- * You cannot use other instances of this class. Please use the \`Prisma.${name}\` value.
4970
- *
4971
- * @see https://www.prisma.io/docs/concepts/components/prisma-client/working-with-fields/working-with-json-fields#filtering-on-a-json-field
4972
- */
4973
- class ${name} {
4974
- private ${name}: never
4975
- private constructor()
4976
- }`;
4977
- return indent4(source, TAB_SIZE);
4978
- }
4979
4819
  function buildPrismaSkipTs(previewFeatures) {
4980
4820
  if (previewFeatures.includes("strictUndefinedChecks")) {
4981
4821
  return `
4982
4822
  /**
4983
4823
  * Prisma.skip
4984
4824
  */
4985
- export import skip = runtime.skip
4825
+ export const skip = runtime.skip
4986
4826
  `;
4987
4827
  }
4988
4828
  return "";
4989
4829
  }
4990
- function buildPrismaSkipJs(previewFeatures) {
4991
- if (previewFeatures.includes("strictUndefinedChecks")) {
4992
- return `
4993
- 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))
4994
4841
  `;
4995
4842
  }
4996
- return "";
4843
+ return preamble;
4997
4844
  }
4998
4845
 
4999
4846
  // src/TSClient/Count.ts
5000
4847
  import * as ts8 from "@prisma/ts-builders";
5001
- import indent5 from "indent-string";
4848
+ import indent4 from "indent-string";
5002
4849
  var Count = class {
5003
4850
  constructor(type, context) {
5004
4851
  this.type = type;
@@ -5029,8 +4876,10 @@ var Count = class {
5029
4876
 
5030
4877
  ${ts8.stringify(outputType)}
5031
4878
 
5032
- export type ${getSelectName(name)}<ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs> = {
5033
- ${indent5(
4879
+ export type ${getSelectName(
4880
+ name
4881
+ )}<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
4882
+ ${indent4(
5034
4883
  type.fields.map((field) => {
5035
4884
  const types = ["boolean"];
5036
4885
  if (field.outputType.location === "outputObjectTypes") {
@@ -5051,7 +4900,7 @@ ${this.argsTypes.map((typeExport) => ts8.stringify(typeExport)).join("\n\n")}
5051
4900
  }
5052
4901
  };
5053
4902
  function getCountArgsType(typeName, fieldName) {
5054
- return `${typeName}Count${capitalize2(fieldName)}Args`;
4903
+ return `${typeName}Count${capitalize3(fieldName)}Args`;
5055
4904
  }
5056
4905
 
5057
4906
  // src/TSClient/FieldRefInput.ts
@@ -5092,7 +4941,7 @@ var GenerateContext = class {
5092
4941
  import { lowerCase as lowerCase7 } from "@prisma/client-common";
5093
4942
  import { assertNever as assertNever2 } from "@prisma/internals";
5094
4943
  import * as ts11 from "@prisma/ts-builders";
5095
- import indent7 from "indent-string";
4944
+ import indent6 from "indent-string";
5096
4945
 
5097
4946
  // src/utils/runtimeImport.ts
5098
4947
  import * as ts9 from "@prisma/ts-builders";
@@ -5104,7 +4953,7 @@ function runtimeImportedType(name) {
5104
4953
  }
5105
4954
 
5106
4955
  // src/TSClient/Datasources.ts
5107
- import indent6 from "indent-string";
4956
+ import indent5 from "indent-string";
5108
4957
  var Datasources = class {
5109
4958
  constructor(internalDatasources) {
5110
4959
  this.internalDatasources = internalDatasources;
@@ -5112,7 +4961,7 @@ var Datasources = class {
5112
4961
  toTS() {
5113
4962
  const sources = this.internalDatasources;
5114
4963
  return `export type Datasources = {
5115
- ${indent6(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
4964
+ ${indent5(sources.map((s) => `${s.name}?: Datasource`).join("\n"), 2)}
5116
4965
  }`;
5117
4966
  }
5118
4967
  };
@@ -5168,9 +5017,9 @@ function clientTypeMapModelsDefinition(context) {
5168
5017
  }
5169
5018
  function clientTypeMapModelsResultDefinition(modelName, action) {
5170
5019
  if (action === "count")
5171
- return ts11.unionType([ts11.optional(ts11.namedType(getCountAggregateOutputName(modelName))), ts11.numberType]);
5172
- if (action === "groupBy") return ts11.array(ts11.optional(ts11.namedType(getGroupByName(modelName))));
5173
- 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)));
5174
5023
  if (action === "findRaw") return ts11.namedType("JsonObject");
5175
5024
  if (action === "aggregateRaw") return ts11.namedType("JsonObject");
5176
5025
  if (action === "deleteMany") return ts11.namedType("BatchPayload");
@@ -5190,7 +5039,7 @@ function clientTypeMapModelsResultDefinition(modelName, action) {
5190
5039
  assertNever2(action, `Unknown action: ${action}`);
5191
5040
  }
5192
5041
  function payloadToResult(modelName) {
5193
- return ts11.namedType("$Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5042
+ return ts11.namedType("runtime.Types.Utils.PayloadToResult").addGenericArgument(ts11.namedType(getPayloadName(modelName)));
5194
5043
  }
5195
5044
  function clientTypeMapOthersDefinition(context) {
5196
5045
  const otherOperationsNames = context.dmmf.getOtherOperationNames().flatMap((name) => {
@@ -5228,25 +5077,26 @@ function clientTypeMapOthersDefinition(context) {
5228
5077
  function clientTypeMapDefinition(context) {
5229
5078
  const typeMap = `${ts11.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
5230
5079
  return `
5231
- 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>> {
5232
5081
  returns: Prisma.TypeMap<this['params']['extArgs'], ClientOptions extends { omit: infer OmitOptions } ? OmitOptions : {}>
5233
5082
  }
5234
5083
 
5235
- 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}`;
5236
5085
  }
5237
5086
  function clientExtensionsDefinitions(context) {
5238
5087
  const typeMap = clientTypeMapDefinition(context);
5239
5088
  const define = ts11.moduleExport(
5240
- ts11.constDeclaration(
5241
- "defineExtension",
5242
- 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
+ )
5243
5093
  )
5244
5094
  );
5245
5095
  return [typeMap, ts11.stringify(define)].join("\n");
5246
5096
  }
5247
5097
  function extendsPropertyDefinition() {
5248
- const extendsDefinition = ts11.namedType("$Extensions.ExtendsHook").addGenericArgument(ts11.stringLiteral("extends")).addGenericArgument(ts11.namedType("Prisma.TypeMapCb").addGenericArgument(ts11.namedType("ClientOptions"))).addGenericArgument(ts11.namedType("ExtArgs")).addGenericArgument(
5249
- 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"))))
5250
5100
  );
5251
5101
  return ts11.stringify(ts11.property("$extends", extendsDefinition), { indentLevel: 1 });
5252
5102
  }
@@ -5265,7 +5115,7 @@ function batchingTransactionDefinition(context) {
5265
5115
 
5266
5116
  Read more in our [docs](https://www.prisma.io/docs/concepts/components/prisma-client/transactions).
5267
5117
  `
5268
- ).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"))));
5269
5119
  if (context.dmmf.hasEnumInNamespace("TransactionIsolationLevel", "prisma")) {
5270
5120
  const options = ts11.objectType().formatInline().add(ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional());
5271
5121
  method3.addParameter(ts11.parameter("options", options).optional());
@@ -5278,7 +5128,7 @@ function interactiveTransactionDefinition(context) {
5278
5128
  const isolationLevel = ts11.property("isolationLevel", ts11.namedType("Prisma.TransactionIsolationLevel")).optional();
5279
5129
  options.add(isolationLevel);
5280
5130
  }
5281
- const returnType = ts11.promise(ts11.namedType("R"));
5131
+ const returnType = promise(ts11.namedType("R"));
5282
5132
  const callbackType = ts11.functionType().addParameter(
5283
5133
  ts11.parameter("prisma", ts11.omit(ts11.namedType("PrismaClient"), ts11.namedType("runtime.ITXClientDenyList")))
5284
5134
  ).setReturnType(returnType);
@@ -5364,7 +5214,7 @@ function queryRawTypedDefinition(context) {
5364
5214
  "typedSql",
5365
5215
  runtimeImportedType("TypedSql").addGenericArgument(ts11.array(ts11.unknownType)).addGenericArgument(param.toArgument())
5366
5216
  )
5367
- ).setReturnType(ts11.prismaPromise(ts11.array(param.toArgument())));
5217
+ ).setReturnType(prismaPromise(ts11.array(param.toArgument())));
5368
5218
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5369
5219
  }
5370
5220
  function metricDefinition(context) {
@@ -5389,7 +5239,7 @@ function runCommandRawDefinition(context) {
5389
5239
  if (!context.dmmf.mappings.otherOperations.write.includes("runCommandRaw")) {
5390
5240
  return "";
5391
5241
  }
5392
- 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`
5393
5243
  Executes a raw MongoDB command and returns the result of it.
5394
5244
  @example
5395
5245
  \`\`\`
@@ -5408,25 +5258,24 @@ function applyPendingMigrationsDefinition() {
5408
5258
  if (this.runtimeName !== "react-native") {
5409
5259
  return null;
5410
5260
  }
5411
- const method3 = ts11.method("$applyPendingMigrations").setReturnType(ts11.promise(ts11.voidType)).setDocComment(
5261
+ const method3 = ts11.method("$applyPendingMigrations").setReturnType(promise(ts11.voidType)).setDocComment(
5412
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.`
5413
5263
  );
5414
5264
  return ts11.stringify(method3, { indentLevel: 1, newLine: "leading" });
5415
5265
  }
5416
5266
  function eventRegistrationMethodDeclaration(runtimeName) {
5417
5267
  if (runtimeName === "binary") {
5418
- 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;`;
5419
5269
  } else {
5420
5270
  return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
5421
5271
  }
5422
5272
  }
5423
5273
  var PrismaClientClass = class {
5424
- constructor(context, internalDatasources, outputDir, runtimeName, browser) {
5274
+ constructor(context, internalDatasources, outputDir, runtimeName) {
5425
5275
  this.context = context;
5426
5276
  this.internalDatasources = internalDatasources;
5427
5277
  this.outputDir = outputDir;
5428
5278
  this.runtimeName = runtimeName;
5429
- this.browser = browser;
5430
5279
  }
5431
5280
  get jsDoc() {
5432
5281
  const { dmmf } = this.context;
@@ -5440,44 +5289,49 @@ var PrismaClientClass = class {
5440
5289
  };
5441
5290
  }
5442
5291
  return `/**
5443
- * ## Prisma Client \u02B2\u02E2
5292
+ * ## Prisma Client
5444
5293
  *
5445
- * Type-safe database client for TypeScript & Node.js
5294
+ * Type-safe database client for TypeScript
5446
5295
  * @example
5447
5296
  * \`\`\`
5448
5297
  * const prisma = new PrismaClient()
5449
- * // Fetch zero or more ${capitalize2(example.plural)}
5298
+ * // Fetch zero or more ${capitalize3(example.plural)}
5450
5299
  * const ${lowerCase7(example.plural)} = await prisma.${lowerCase7(example.model)}.findMany()
5451
5300
  * \`\`\`
5452
5301
  *
5453
- *
5454
5302
  * Read more in our [docs](https://www.prisma.io/docs/reference/tools-and-interfaces/prisma-client).
5455
5303
  */`;
5456
5304
  }
5457
5305
  toTSWithoutNamespace() {
5458
5306
  const { dmmf } = this.context;
5459
- return `${this.jsDoc}
5460
- 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<
5461
5318
  ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
5462
5319
  U = 'log' extends keyof ClientOptions ? ClientOptions['log'] extends Array<Prisma.LogLevel | Prisma.LogDefinition> ? Prisma.GetEvents<ClientOptions['log']> : never : never,
5463
- ExtArgs extends $Extensions.InternalArgs = $Extensions.DefaultArgs
5320
+ ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
5464
5321
  > {
5465
5322
  [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
5466
5323
 
5467
- ${indent7(this.jsDoc, TAB_SIZE)}
5468
-
5469
- constructor(optionsArg ?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>);
5470
5324
  ${eventRegistrationMethodDeclaration(this.runtimeName)}
5471
5325
 
5472
5326
  /**
5473
5327
  * Connect with the database
5474
5328
  */
5475
- $connect(): $Utils.JsPromise<void>;
5329
+ $connect(): runtime.Types.Utils.JsPromise<void>;
5476
5330
 
5477
5331
  /**
5478
5332
  * Disconnect from the database
5479
5333
  */
5480
- $disconnect(): $Utils.JsPromise<void>;
5334
+ $disconnect(): runtime.Types.Utils.JsPromise<void>;
5481
5335
 
5482
5336
  /**
5483
5337
  * Add a middleware
@@ -5498,7 +5352,7 @@ ${[
5498
5352
  extendsPropertyDefinition()
5499
5353
  ].filter((d) => d !== null).join("\n").trim()}
5500
5354
 
5501
- ${indent7(
5355
+ ${indent6(
5502
5356
  dmmf.mappings.modelOperations.filter((m) => m.findMany).map((m) => {
5503
5357
  let methodName = lowerCase7(m.model);
5504
5358
  if (methodName === "constructor") {
@@ -5509,7 +5363,7 @@ ${[
5509
5363
  * \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
5510
5364
  * Example usage:
5511
5365
  * \`\`\`ts
5512
- * // Fetch zero or more ${capitalize2(m.plural)}
5366
+ * // Fetch zero or more ${capitalize3(m.plural)}
5513
5367
  * const ${lowerCase7(m.plural)} = await prisma.${methodName}.findMany()
5514
5368
  * \`\`\`
5515
5369
  */
@@ -5517,7 +5371,9 @@ get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
5517
5371
  }).join("\n\n"),
5518
5372
  2
5519
5373
  )}
5520
- }`;
5374
+ }
5375
+
5376
+ export const PrismaClient = runtime.getPrismaClient(config) as unknown as PrismaClientConstructor`;
5521
5377
  }
5522
5378
  toTS() {
5523
5379
  const clientOptions = this.buildClientOptions();
@@ -5595,11 +5451,8 @@ export type MiddlewareParams = {
5595
5451
  */
5596
5452
  export type Middleware<T = any> = (
5597
5453
  params: MiddlewareParams,
5598
- next: (params: MiddlewareParams) => $Utils.JsPromise<T>,
5599
- ) => $Utils.JsPromise<T>
5600
-
5601
- // tested in getLogLevel.test.ts
5602
- export function getLogLevel(log: Array<LogLevel | LogDefinition>): LogLevel | undefined;
5454
+ next: (params: MiddlewareParams) => runtime.Types.Utils.JsPromise<T>,
5455
+ ) => runtime.Types.Utils.JsPromise<T>
5603
5456
 
5604
5457
  /**
5605
5458
  * \`PrismaClient\` proxy available in interactive transactions.
@@ -5679,10 +5532,9 @@ var TSClient = class {
5679
5532
  }
5680
5533
  dmmf;
5681
5534
  genericsInfo;
5682
- toJS() {
5535
+ toTS() {
5683
5536
  const {
5684
5537
  edge,
5685
- wasm,
5686
5538
  binaryPaths,
5687
5539
  generator,
5688
5540
  outputDir,
@@ -5690,14 +5542,11 @@ var TSClient = class {
5690
5542
  runtimeBase,
5691
5543
  runtimeName,
5692
5544
  datasources,
5693
- deno,
5694
5545
  copyEngine = true,
5695
- envPaths
5546
+ target,
5547
+ activeProvider,
5548
+ moduleFormat
5696
5549
  } = this.options;
5697
- const relativeEnvPaths = {
5698
- rootEnvPath: envPaths.rootEnvPath && pathToPosix3(path2.relative(outputDir, envPaths.rootEnvPath)),
5699
- schemaEnvPath: envPaths.schemaEnvPath && pathToPosix3(path2.relative(outputDir, envPaths.schemaEnvPath))
5700
- };
5701
5550
  const clientEngineType = getClientEngineType(generator);
5702
5551
  generator.config.engineType = clientEngineType;
5703
5552
  const binaryTargets = clientEngineType === ClientEngineType2.Library ? Object.keys(binaryPaths.libqueryEngine ?? {}) : Object.keys(binaryPaths.queryEngine ?? {});
@@ -5705,8 +5554,7 @@ var TSClient = class {
5705
5554
  const datasourceFilePath = datasources[0].sourceFilePath;
5706
5555
  const config = {
5707
5556
  generator,
5708
- relativeEnvPaths,
5709
- relativePath: pathToPosix3(path2.relative(outputDir, path2.dirname(datasourceFilePath))),
5557
+ relativePath: pathToPosix2(path2.relative(outputDir, path2.dirname(datasourceFilePath))),
5710
5558
  clientVersion: this.options.clientVersion,
5711
5559
  engineVersion: this.options.engineVersion,
5712
5560
  datasourceNames: datasources.map((d) => d.name),
@@ -5718,44 +5566,24 @@ var TSClient = class {
5718
5566
  }, {}),
5719
5567
  inlineSchema,
5720
5568
  inlineSchemaHash,
5721
- copyEngine
5569
+ copyEngine,
5570
+ runtimeDataModel: { models: {}, enums: {}, types: {} },
5571
+ dirname: ""
5722
5572
  };
5723
5573
  const relativeOutdir = path2.relative(process.cwd(), outputDir);
5724
- const code = `${commonCodeJS({ ...this.options, browser: false })}
5725
- ${buildRequirePath(edge)}
5726
-
5727
- /**
5728
- * Enums
5729
- */
5730
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5731
- ${this.dmmf.datamodel.enums.map((datamodelEnum) => new Enum(datamodelEnumToSchemaEnum(datamodelEnum), false).toJS()).join("\n\n")}
5732
-
5733
- ${new Enum(
5734
- {
5735
- name: "ModelName",
5736
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5737
- },
5738
- true
5739
- ).toJS()}
5574
+ const clientConfig = `
5740
5575
  /**
5741
5576
  * Create the Client
5742
5577
  */
5743
- const config = ${JSON.stringify(config, null, 2)}
5744
- ${buildDirname(edge, relativeOutdir)}
5578
+ const config: runtime.GetPrismaClientConfig = ${JSON.stringify(config, null, 2)}
5579
+ ${buildDirname(edge)}
5745
5580
  ${buildRuntimeDataModel(this.dmmf.datamodel, runtimeName)}
5746
- ${buildQueryEngineWasmModule(wasm, copyEngine, runtimeName)}
5747
- ${buildQueryCompilerWasmModule(wasm, copyEngine, runtimeName)}
5581
+ ${buildGetWasmModule({ component: "engine", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5582
+ ${buildGetWasmModule({ component: "compiler", runtimeBase, runtimeName, target, activeProvider, moduleFormat })}
5748
5583
  ${buildInjectableEdgeEnv(edge, datasources)}
5749
- ${buildWarnEnvConflicts(edge, runtimeBase, runtimeName)}
5750
5584
  ${buildDebugInitialization(edge)}
5751
- const PrismaClient = getPrismaClient(config)
5752
- exports.PrismaClient = PrismaClient
5753
- Object.assign(exports, Prisma)${deno ? "\nexport { exports as default, Prisma, PrismaClient }" : ""}
5754
5585
  ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, relativeOutdir)}
5755
5586
  `;
5756
- return code;
5757
- }
5758
- toTS() {
5759
5587
  const context = new GenerateContext({
5760
5588
  dmmf: this.dmmf,
5761
5589
  genericArgsInfo: this.genericsInfo,
@@ -5765,8 +5593,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5765
5593
  context,
5766
5594
  this.options.datasources,
5767
5595
  this.options.outputDir,
5768
- this.options.runtimeName,
5769
- this.options.browser
5596
+ this.options.runtimeName
5770
5597
  );
5771
5598
  const commonCode = commonCodeTS(this.options);
5772
5599
  const modelAndTypes = Object.values(this.dmmf.typeAndModelMap).reduce((acc, modelOrType) => {
@@ -5785,7 +5612,9 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5785
5612
  ts12.moduleExport(ts12.typeDeclaration(datamodelEnum.name, ts12.namedType(`$Enums.${datamodelEnum.name}`)))
5786
5613
  ),
5787
5614
  ts12.stringify(
5788
- 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
+ )
5789
5618
  )
5790
5619
  );
5791
5620
  }
@@ -5794,7 +5623,7 @@ ${buildNFTAnnotations(edge || !copyEngine, clientEngineType, binaryTargets, rela
5794
5623
  const code = `
5795
5624
  /**
5796
5625
  * Client
5797
- **/
5626
+ */
5798
5627
 
5799
5628
  ${commonCode.tsWithoutNamespace()}
5800
5629
 
@@ -5809,10 +5638,13 @@ export namespace $Enums {
5809
5638
 
5810
5639
  ${modelEnumsAliases.join("\n\n")}
5811
5640
  ` : ""}
5641
+
5642
+ ${clientConfig}
5643
+
5812
5644
  ${prismaClientClass.toTSWithoutNamespace()}
5813
5645
 
5814
5646
  export namespace Prisma {
5815
- ${indent8(
5647
+ ${indent7(
5816
5648
  `${commonCode.ts()}
5817
5649
  ${new Enum(
5818
5650
  {
@@ -5881,70 +5713,11 @@ ${this.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputType,
5881
5713
  export type BatchPayload = {
5882
5714
  count: number
5883
5715
  }
5884
-
5885
- /**
5886
- * DMMF
5887
- */
5888
- export const dmmf: runtime.BaseDMMF
5889
5716
  `,
5890
5717
  2
5891
5718
  )}}`;
5892
5719
  return code;
5893
5720
  }
5894
- toBrowserJS() {
5895
- const code = `${commonCodeJS({
5896
- ...this.options,
5897
- runtimeName: "index-browser",
5898
- browser: true
5899
- })}
5900
- /**
5901
- * Enums
5902
- */
5903
-
5904
- ${this.dmmf.schema.enumTypes.prisma?.map((type) => new Enum(type, true).toJS()).join("\n\n")}
5905
- ${this.dmmf.schema.enumTypes.model?.map((type) => new Enum(type, false).toJS()).join("\n\n") ?? ""}
5906
-
5907
- ${new Enum(
5908
- {
5909
- name: "ModelName",
5910
- values: this.dmmf.mappings.modelOperations.map((m) => m.model)
5911
- },
5912
- true
5913
- ).toJS()}
5914
-
5915
- /**
5916
- * This is a stub Prisma Client that will error at runtime if called.
5917
- */
5918
- class PrismaClient {
5919
- constructor() {
5920
- return new Proxy(this, {
5921
- get(target, prop) {
5922
- let message
5923
- const runtime = getRuntime()
5924
- if (runtime.isEdge) {
5925
- message = \`PrismaClient is not configured to run in \${runtime.prettyName}. In order to run Prisma Client on edge runtime, either:
5926
- - Use Prisma Accelerate: https://pris.ly/d/accelerate
5927
- - Use Driver Adapters: https://pris.ly/d/driver-adapters
5928
- \`;
5929
- } else {
5930
- message = 'PrismaClient is unable to run in this browser environment, or has been bundled for the browser (running in \`' + runtime.prettyName + '\`).'
5931
- }
5932
-
5933
- message += \`
5934
- If this is unexpected, please open an issue: https://pris.ly/prisma-prisma-bug-report\`
5935
-
5936
- throw new Error(message)
5937
- }
5938
- })
5939
- }
5940
- }
5941
-
5942
- exports.PrismaClient = PrismaClient
5943
-
5944
- Object.assign(exports, Prisma)
5945
- `;
5946
- return code;
5947
- }
5948
5721
  };
5949
5722
 
5950
5723
  // src/typedSql/buildDbEnums.ts
@@ -5981,23 +5754,12 @@ var DbEnumsList = class {
5981
5754
  };
5982
5755
  function buildDbEnums(list) {
5983
5756
  const file4 = ts13.file();
5984
- file4.add(buildInvalidIdentifierEnums(list));
5985
- file4.add(buildValidIdentifierEnums(list));
5986
- return ts13.stringify(file4);
5987
- }
5988
- function buildValidIdentifierEnums(list) {
5989
- const namespace3 = ts13.namespace("$DbEnums");
5990
- for (const dbEnum of list.validJsIdentifiers()) {
5991
- namespace3.add(ts13.typeDeclaration(dbEnum.name, enumToUnion(dbEnum)));
5992
- }
5993
- return ts13.moduleExport(namespace3);
5994
- }
5995
- function buildInvalidIdentifierEnums(list) {
5996
5757
  const iface = ts13.interfaceDeclaration("$DbEnums");
5997
- for (const dbEnum of list.invalidJsIdentifiers()) {
5758
+ for (const dbEnum of list.enums) {
5998
5759
  iface.add(ts13.property(dbEnum.name, enumToUnion(dbEnum)));
5999
5760
  }
6000
- return ts13.moduleExport(iface);
5761
+ file4.add(ts13.moduleExport(iface));
5762
+ return ts13.stringify(file4);
6001
5763
  }
6002
5764
  function enumToUnion(dbEnum) {
6003
5765
  return ts13.unionType(dbEnum.values.map(ts13.stringLiteral));
@@ -6011,41 +5773,21 @@ function queryUsesEnums(query, enums) {
6011
5773
 
6012
5774
  // src/typedSql/buildIndex.ts
6013
5775
  import * as ts14 from "@prisma/ts-builders";
6014
- import { Writer } from "@prisma/ts-builders";
6015
- function buildIndexTs(queries, enums) {
5776
+ function buildIndex({ queries, enums, importName }) {
6016
5777
  const file4 = ts14.file();
6017
5778
  if (!enums.isEmpty()) {
6018
- file4.add(ts14.moduleExportFrom("./$DbEnums").named("$DbEnums"));
5779
+ file4.add(ts14.moduleExportFrom(importName("./sql/$DbEnums")).named(ts14.namedExport("$DbEnums").typeOnly()));
6019
5780
  }
6020
5781
  for (const query of queries) {
6021
- file4.add(ts14.moduleExportFrom(`./${query.name}`));
5782
+ file4.add(ts14.moduleExportFrom(importName(`./sql/${query.name}`)));
6022
5783
  }
6023
5784
  return ts14.stringify(file4);
6024
5785
  }
6025
- function buildIndexCjs(queries, edgeRuntimeSuffix) {
6026
- const writer = new Writer(0, void 0);
6027
- writer.writeLine('"use strict"');
6028
- for (const { name } of queries) {
6029
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6030
- writer.writeLine(`exports.${name} = require("./${fileName}.js").${name}`);
6031
- }
6032
- return writer.toString();
6033
- }
6034
- function buildIndexEsm(queries, edgeRuntimeSuffix) {
6035
- const writer = new Writer(0, void 0);
6036
- for (const { name } of queries) {
6037
- const fileName = edgeRuntimeSuffix ? `${name}.${edgeRuntimeSuffix}` : name;
6038
- writer.writeLine(`export * from "./${fileName}.mjs"`);
6039
- }
6040
- return writer.toString();
6041
- }
6042
5786
 
6043
5787
  // src/typedSql/buildTypedQuery.ts
6044
5788
  import * as ts16 from "@prisma/ts-builders";
6045
- import { Writer as Writer2 } from "@prisma/ts-builders";
6046
5789
 
6047
5790
  // src/typedSql/mapTypes.ts
6048
- import { isValidJsIdentifier as isValidJsIdentifier2 } from "@prisma/internals";
6049
5791
  import * as ts15 from "@prisma/ts-builders";
6050
5792
  var decimal = ts15.namedType("$runtime.Decimal");
6051
5793
  var uint8Array = ts15.namedType("Uint8Array");
@@ -6139,18 +5881,15 @@ function getMappingConfig(introspectionType, enums) {
6139
5881
  return config;
6140
5882
  }
6141
5883
  function getEnumType(name) {
6142
- if (isValidJsIdentifier2(name)) {
6143
- return ts15.namedType(`$DbEnums.${name}`);
6144
- }
6145
5884
  return ts15.namedType("$DbEnums").subKey(name);
6146
5885
  }
6147
5886
 
6148
5887
  // src/typedSql/buildTypedQuery.ts
6149
- function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
5888
+ function buildTypedQuery({ query, runtimeBase, runtimeName, enums, importName }) {
6150
5889
  const file4 = ts16.file();
6151
5890
  file4.addImport(ts16.moduleImport(`${runtimeBase}/${runtimeName}`).asNamespace("$runtime"));
6152
5891
  if (queryUsesEnums(query, enums)) {
6153
- file4.addImport(ts16.moduleImport("./$DbEnums").named("$DbEnums"));
5892
+ file4.addImport(ts16.moduleImport(importName("./$DbEnums")).named(ts16.namedImport("$DbEnums").typeOnly()));
6154
5893
  }
6155
5894
  const doc = ts16.docComment(query.documentation ?? void 0);
6156
5895
  const factoryType = ts16.functionType();
@@ -6168,11 +5907,17 @@ function buildTypedQueryTs({ query, runtimeBase, runtimeName, enums }) {
6168
5907
  factoryType.setReturnType(
6169
5908
  ts16.namedType("$runtime.TypedSql").addGenericArgument(ts16.namedType(`${query.name}.Parameters`)).addGenericArgument(ts16.namedType(`${query.name}.Result`))
6170
5909
  );
6171
- file4.add(ts16.moduleExport(ts16.constDeclaration(query.name, factoryType)).setDocComment(doc));
6172
- const namespace3 = ts16.namespace(query.name);
6173
- namespace3.add(ts16.moduleExport(ts16.typeDeclaration("Parameters", parametersType)));
6174
- namespace3.add(buildResultType(query, enums));
6175
- 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));
6176
5921
  return ts16.stringify(file4);
6177
5922
  }
6178
5923
  function buildResultType(query, enums) {
@@ -6181,47 +5926,28 @@ function buildResultType(query, enums) {
6181
5926
  );
6182
5927
  return ts16.moduleExport(ts16.typeDeclaration("Result", type));
6183
5928
  }
6184
- function buildTypedQueryCjs({ query, runtimeBase, runtimeName }) {
6185
- const writer = new Writer2(0, void 0);
6186
- writer.writeLine('"use strict"');
6187
- writer.writeLine(`const { makeTypedQueryFactory: $mkFactory } = require("${runtimeBase}/${runtimeName}")`);
6188
- writer.writeLine(`exports.${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6189
- return writer.toString();
6190
- }
6191
- function buildTypedQueryEsm({ query, runtimeBase, runtimeName }) {
6192
- const writer = new Writer2(0, void 0);
6193
- writer.writeLine(`import { makeTypedQueryFactory as $mkFactory } from "${runtimeBase}/${runtimeName}"`);
6194
- writer.writeLine(`export const ${query.name} = /*#__PURE__*/ $mkFactory(${JSON.stringify(query.source)})`);
6195
- return writer.toString();
6196
- }
6197
5929
 
6198
5930
  // src/typedSql/typedSql.ts
6199
5931
  function buildTypedSql({
6200
5932
  queries,
6201
5933
  runtimeBase,
6202
- edgeRuntimeName,
6203
- mainRuntimeName,
6204
- dmmf
5934
+ runtimeName,
5935
+ dmmf,
5936
+ outputName,
5937
+ importName
6205
5938
  }) {
6206
- const fileMap = {};
5939
+ const fileMap = {
5940
+ sql: {}
5941
+ };
6207
5942
  const enums = new DbEnumsList(dmmf.datamodel.enums);
6208
5943
  if (!enums.isEmpty()) {
6209
- fileMap["$DbEnums.d.ts"] = buildDbEnums(enums);
5944
+ fileMap.sql[outputName("$DbEnums")] = buildDbEnums(enums);
6210
5945
  }
6211
5946
  for (const query of queries) {
6212
- const options = { query, runtimeBase, runtimeName: mainRuntimeName, enums };
6213
- const edgeOptions = { ...options, runtimeName: `${edgeRuntimeName}.js` };
6214
- fileMap[`${query.name}.d.ts`] = buildTypedQueryTs(options);
6215
- fileMap[`${query.name}.js`] = buildTypedQueryCjs(options);
6216
- fileMap[`${query.name}.${edgeRuntimeName}.js`] = buildTypedQueryCjs(edgeOptions);
6217
- fileMap[`${query.name}.mjs`] = buildTypedQueryEsm(options);
6218
- fileMap[`${query.name}.edge.mjs`] = buildTypedQueryEsm(edgeOptions);
6219
- }
6220
- fileMap["index.d.ts"] = buildIndexTs(queries, enums);
6221
- fileMap["index.js"] = buildIndexCjs(queries);
6222
- fileMap["index.mjs"] = buildIndexEsm(queries);
6223
- fileMap[`index.${edgeRuntimeName}.mjs`] = buildIndexEsm(queries, edgeRuntimeName);
6224
- 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 });
6225
5951
  return fileMap;
6226
5952
  }
6227
5953
 
@@ -6248,10 +5974,17 @@ function buildClient({
6248
5974
  postinstall,
6249
5975
  copyEngine,
6250
5976
  envPaths,
6251
- typedSql
5977
+ typedSql,
5978
+ target,
5979
+ generatedFileExtension,
5980
+ importFileExtension,
5981
+ moduleFormat
6252
5982
  }) {
6253
5983
  const clientEngineType = getClientEngineType2(generator);
6254
- const baseClientOptions = {
5984
+ const runtimeName = getRuntimeNameForTarget(target, clientEngineType, generator.previewFeatures);
5985
+ const outputName = generatedFileNameMapper(generatedFileExtension);
5986
+ const importName = importFileNameMapper(importFileExtension);
5987
+ const clientOptions = {
6255
5988
  dmmf: getPrismaClientDMMF(dmmf),
6256
5989
  envPaths: envPaths ?? { rootEnvPath: null, schemaEnvPath: void 0 },
6257
5990
  datasources,
@@ -6266,89 +5999,32 @@ function buildClient({
6266
5999
  postinstall,
6267
6000
  copyEngine,
6268
6001
  datamodel,
6269
- browser: false,
6270
- deno: false,
6271
- edge: false,
6272
- wasm: false
6273
- };
6274
- const nodeClientOptions = {
6275
- ...baseClientOptions,
6276
- runtimeName: getNodeRuntimeName(clientEngineType)
6002
+ edge: ["edge", "wasm", "react-native"].includes(runtimeName),
6003
+ runtimeName,
6004
+ target,
6005
+ generatedFileExtension,
6006
+ importFileExtension,
6007
+ moduleFormat
6277
6008
  };
6278
- const nodeClient = new TSClient(nodeClientOptions);
6279
- const defaultClient = new TSClient({
6280
- ...nodeClientOptions
6281
- });
6282
- const edgeClient = new TSClient({
6283
- ...baseClientOptions,
6284
- runtimeName: "edge",
6285
- edge: true
6286
- });
6287
- const rnTsClient = new TSClient({
6288
- ...baseClientOptions,
6289
- runtimeName: "react-native",
6290
- edge: true
6291
- });
6292
- const fileMap = {};
6293
- fileMap["index.js"] = JS(nodeClient);
6294
- fileMap["index.d.ts"] = TS(nodeClient);
6295
- fileMap["default.js"] = JS(defaultClient);
6296
- fileMap["default.d.ts"] = TS(defaultClient);
6297
- fileMap["index-browser.js"] = BrowserJS(nodeClient);
6298
- fileMap["edge.js"] = JS(edgeClient);
6299
- fileMap["edge.d.ts"] = TS(edgeClient);
6300
- fileMap["client.js"] = JS(defaultClient);
6301
- fileMap["client.d.ts"] = TS(defaultClient);
6302
- if (generator.previewFeatures.includes("reactNative")) {
6303
- fileMap["react-native.js"] = JS(rnTsClient);
6304
- fileMap["react-native.d.ts"] = TS(rnTsClient);
6305
- }
6306
- const usesWasmRuntime = generator.previewFeatures.includes("driverAdapters");
6307
- if (usesWasmRuntime) {
6308
- const usesClientEngine = clientEngineType === ClientEngineType3.Client;
6309
- if (usesClientEngine) {
6310
- fileMap["wasm-worker-loader.mjs"] = `export default import('./query_compiler_bg.wasm')`;
6311
- fileMap["wasm-edge-light-loader.mjs"] = `export default import('./query_compiler_bg.wasm?module')`;
6312
- } else {
6313
- fileMap["wasm-worker-loader.mjs"] = `export default import('./query_engine_bg.wasm')`;
6314
- fileMap["wasm-edge-light-loader.mjs"] = `export default import('./query_engine_bg.wasm?module')`;
6315
- }
6316
- const wasmClient = new TSClient({
6317
- ...baseClientOptions,
6318
- runtimeName: "wasm",
6319
- edge: true,
6320
- wasm: true
6321
- });
6322
- fileMap["wasm.js"] = JS(wasmClient);
6323
- fileMap["wasm.d.ts"] = TS(wasmClient);
6324
- } else {
6325
- fileMap["wasm.js"] = fileMap["index-browser.js"];
6326
- fileMap["wasm.d.ts"] = fileMap["default.d.ts"];
6327
- }
6328
- if (generator.previewFeatures.includes("deno") && !!globalThis.Deno) {
6329
- const denoEdgeClient = new TSClient({
6330
- ...baseClientOptions,
6331
- runtimeBase: `../${runtimeBase}`,
6332
- runtimeName: "edge",
6333
- deno: true,
6334
- edge: true
6335
- });
6336
- fileMap["deno/edge.js"] = JS(denoEdgeClient);
6337
- fileMap["deno/index.d.ts"] = TS(denoEdgeClient);
6338
- fileMap["deno/edge.ts"] = `
6339
- import './polyfill.js'
6340
- // @deno-types="./index.d.ts"
6341
- export * from './edge.js'`;
6342
- fileMap["deno/polyfill.js"] = "globalThis.process = { env: Deno.env.toObject() }; globalThis.global = globalThis";
6009
+ if (runtimeName === "react-native" && !generator.previewFeatures.includes("reactNative")) {
6010
+ throw new Error(`Using the "react-native" runtime requires the "reactNative" preview feature to be enabled.`);
6343
6011
  }
6012
+ const client = new TSClient(clientOptions);
6013
+ let fileMap = {};
6014
+ fileMap[outputName("client")] = client.toTS();
6015
+ fileMap[outputName("index")] = `export * from '${importName("./client")}'`;
6344
6016
  if (typedSql && typedSql.length > 0) {
6345
- fileMap["sql"] = buildTypedSql({
6346
- dmmf,
6347
- runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6348
- mainRuntimeName: getNodeRuntimeName(clientEngineType),
6349
- queries: typedSql,
6350
- edgeRuntimeName: usesWasmRuntime ? "wasm" : "edge"
6351
- });
6017
+ fileMap = {
6018
+ ...fileMap,
6019
+ ...buildTypedSql({
6020
+ dmmf,
6021
+ runtimeBase: getTypedSqlRuntimeBase(runtimeBase),
6022
+ runtimeName,
6023
+ queries: typedSql,
6024
+ outputName,
6025
+ importName
6026
+ })
6027
+ };
6352
6028
  }
6353
6029
  return {
6354
6030
  fileMap,
@@ -6380,7 +6056,11 @@ async function generateClient(options) {
6380
6056
  postinstall,
6381
6057
  envPaths,
6382
6058
  copyEngine = true,
6383
- typedSql
6059
+ typedSql,
6060
+ target,
6061
+ generatedFileExtension,
6062
+ importFileExtension,
6063
+ moduleFormat
6384
6064
  } = options;
6385
6065
  const clientEngineType = getClientEngineType2(generator);
6386
6066
  const { runtimeBase, outputDir } = await getGenerationDirs(options);
@@ -6399,7 +6079,11 @@ async function generateClient(options) {
6399
6079
  postinstall,
6400
6080
  copyEngine,
6401
6081
  envPaths,
6402
- typedSql
6082
+ typedSql,
6083
+ target,
6084
+ generatedFileExtension,
6085
+ importFileExtension,
6086
+ moduleFormat
6403
6087
  });
6404
6088
  const denylistsErrors = validateDmmfAgainstDenylists(prismaClientDmmf);
6405
6089
  if (denylistsErrors) {
@@ -6416,40 +6100,23 @@ To learn more about how to rename models, check out https://pris.ly/d/naming-mod
6416
6100
  }
6417
6101
  await deleteOutputDir(outputDir);
6418
6102
  await (0, import_fs_extra.ensureDir)(outputDir);
6419
- if (generator.previewFeatures.includes("deno") && !!globalThis.Deno) {
6420
- await (0, import_fs_extra.ensureDir)(path3.join(outputDir, "deno"));
6421
- }
6422
6103
  await writeFileMap(outputDir, fileMap);
6423
6104
  const enginePath = clientEngineType === ClientEngineType3.Library ? binaryPaths.libqueryEngine : binaryPaths.queryEngine;
6424
- if (!enginePath) {
6425
- throw new Error(
6426
- `Prisma Client needs \`${clientEngineType === ClientEngineType3.Library ? "libqueryEngine" : "queryEngine"}\` in the \`binaryPaths\` object.`
6427
- );
6428
- }
6429
- if (copyEngine) {
6105
+ if (copyEngine && enginePath) {
6430
6106
  if (process.env.NETLIFY) {
6431
6107
  await (0, import_fs_extra.ensureDir)("/tmp/prisma-engines");
6432
6108
  }
6433
6109
  for (const [binaryTarget, filePath] of Object.entries(enginePath)) {
6434
6110
  const fileName = path3.basename(filePath);
6435
- let target;
6111
+ let target2;
6436
6112
  if (process.env.NETLIFY && !["rhel-openssl-1.0.x", "rhel-openssl-3.0.x"].includes(binaryTarget)) {
6437
- target = path3.join("/tmp/prisma-engines", fileName);
6113
+ target2 = path3.join("/tmp/prisma-engines", fileName);
6438
6114
  } else {
6439
- target = path3.join(outputDir, fileName);
6115
+ target2 = path3.join(outputDir, fileName);
6440
6116
  }
6441
- await overwriteFile(filePath, target);
6117
+ await overwriteFile(filePath, target2);
6442
6118
  }
6443
6119
  }
6444
- const schemaTargetPath = path3.join(outputDir, "schema.prisma");
6445
- await fs.writeFile(schemaTargetPath, datamodel, { encoding: "utf-8" });
6446
- try {
6447
- const prismaCache = paths("prisma").cache;
6448
- const signalsPath = path3.join(prismaCache, "last-generate");
6449
- await fs.mkdir(prismaCache, { recursive: true });
6450
- await fs.writeFile(signalsPath, Date.now().toString());
6451
- } catch {
6452
- }
6453
6120
  }
6454
6121
  function writeFileMap(outputDir, fileMap) {
6455
6122
  return Promise.all(
@@ -6544,7 +6211,7 @@ function validateDmmfAgainstDenylists(prismaClientDmmf) {
6544
6211
  }
6545
6212
  async function getGenerationDirs({ runtimeBase, outputDir }) {
6546
6213
  const normalizedOutputDir = path3.normalize(outputDir);
6547
- const normalizedRuntimeBase = pathToPosix4(runtimeBase);
6214
+ const normalizedRuntimeBase = pathToPosix3(runtimeBase);
6548
6215
  const userPackageRoot = await pkgUp({ cwd: path3.dirname(normalizedOutputDir) });
6549
6216
  const userProjectRoot = userPackageRoot ? path3.dirname(userPackageRoot) : process.cwd();
6550
6217
  return {
@@ -6553,6 +6220,26 @@ async function getGenerationDirs({ runtimeBase, outputDir }) {
6553
6220
  projectRoot: userProjectRoot
6554
6221
  };
6555
6222
  }
6223
+ function getRuntimeNameForTarget(target, engineType, previewFeatures) {
6224
+ switch (target) {
6225
+ case "nodejs":
6226
+ case "deno":
6227
+ case "bun":
6228
+ return getNodeRuntimeName(engineType);
6229
+ case "workerd":
6230
+ case "edge-light":
6231
+ case "deno-deploy":
6232
+ if (previewFeatures.includes("driverAdapters")) {
6233
+ return "wasm";
6234
+ } else {
6235
+ return "edge";
6236
+ }
6237
+ case "react-native":
6238
+ return "react-native";
6239
+ default:
6240
+ assertNever3(target, "Unknown runtime target");
6241
+ }
6242
+ }
6556
6243
  function getNodeRuntimeName(engineType) {
6557
6244
  if (engineType === ClientEngineType3.Binary) {
6558
6245
  return "binary";
@@ -6576,15 +6263,13 @@ async function deleteOutputDir(outputDir) {
6576
6263
  if (files.length === 0) {
6577
6264
  return;
6578
6265
  }
6579
- if (!files.includes("client.d.ts")) {
6266
+ if (!files.includes("client.ts") && !files.includes("client.mts") && !files.includes("client.cts")) {
6580
6267
  throw new Error(
6581
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.`
6582
6269
  );
6583
6270
  }
6584
6271
  await Promise.allSettled(
6585
- (await glob(`${outputDir}/**/*.ts`, {
6586
- globstar: true,
6587
- onlyFiles: true,
6272
+ (await glob([`${outputDir}/**/*.{ts,mts,cts}`, `${outputDir}/*.node`, `${outputDir}/{query,schema}-engine-*`], {
6588
6273
  followSymbolicLinks: false
6589
6274
  })).map(fs.unlink)
6590
6275
  );
@@ -6596,13 +6281,88 @@ async function deleteOutputDir(outputDir) {
6596
6281
  }
6597
6282
 
6598
6283
  // src/generator.ts
6599
- import Debug from "@prisma/debug";
6284
+ import { Debug } from "@prisma/debug";
6600
6285
  import { enginesVersion } from "@prisma/engines-version";
6601
6286
  import { ClientEngineType as ClientEngineType4, getClientEngineType as getClientEngineType3, parseEnvValue } from "@prisma/internals";
6602
- import { match } from "ts-pattern";
6287
+ import { getTsconfig } from "get-tsconfig";
6288
+ import { match as match2 } from "ts-pattern";
6603
6289
 
6604
6290
  // package.json
6605
- var version = "6.6.0-dev.95";
6291
+ var version = "6.6.0-dev.97";
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
+ }
6332
+
6333
+ // src/runtime-targets.ts
6334
+ var supportedRuntimes = ["nodejs", "deno", "deno-deploy", "bun", "workerd", "edge-light", "react-native"];
6335
+ function parseRuntimeTarget(target) {
6336
+ switch (target.toLowerCase()) {
6337
+ case "node":
6338
+ case "nodejs":
6339
+ return "nodejs";
6340
+ case "deno":
6341
+ return "deno";
6342
+ case "deno-deploy":
6343
+ return "deno-deploy";
6344
+ case "bun":
6345
+ return "bun";
6346
+ case "workerd":
6347
+ case "cloudflare":
6348
+ return "workerd";
6349
+ case "edge-light":
6350
+ case "vercel":
6351
+ return "edge-light";
6352
+ case "react-native":
6353
+ return "react-native";
6354
+ default:
6355
+ throw new Error(
6356
+ `Unknown target runtime: "${target}". The available options are: ${supportedRuntimes.map((runtime) => `"${runtime}"`).join(", ")}`
6357
+ );
6358
+ }
6359
+ }
6360
+ function parseRuntimeTargetFromUnknown(target) {
6361
+ if (typeof target !== "string") {
6362
+ throw new Error(`Invalid target runtime: ${JSON.stringify(target)}. Expected a string.`);
6363
+ }
6364
+ return parseRuntimeTarget(target);
6365
+ }
6606
6366
 
6607
6367
  // src/generator.ts
6608
6368
  var debug = Debug("prisma:client:generator");
@@ -6624,7 +6384,7 @@ function getOutputPath(config) {
6624
6384
  var PrismaClientTsGenerator = class {
6625
6385
  name = "prisma-client-ts";
6626
6386
  getManifest(config) {
6627
- const requiresEngines = match(getClientEngineType3(config)).with(ClientEngineType4.Library, () => ["libqueryEngine"]).with(ClientEngineType4.Binary, () => ["queryEngine"]).with(ClientEngineType4.Client, () => []).exhaustive();
6387
+ const requiresEngines = match2(getClientEngineType3(config)).with(ClientEngineType4.Library, () => ["libqueryEngine"]).with(ClientEngineType4.Binary, () => ["queryEngine"]).with(ClientEngineType4.Client, () => []).exhaustive();
6628
6388
  debug("requiresEngines", requiresEngines);
6629
6389
  return Promise.resolve({
6630
6390
  defaultOutput: getOutputPath(config),
@@ -6635,13 +6395,27 @@ var PrismaClientTsGenerator = class {
6635
6395
  });
6636
6396
  }
6637
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
+ });
6638
6412
  await generateClient({
6639
6413
  datamodel: options.datamodel,
6640
6414
  schemaPath: options.schemaPath,
6641
6415
  binaryPaths: options.binaryPaths,
6642
6416
  datasources: options.datasources,
6643
6417
  envPaths: options.envPaths,
6644
- outputDir: getOutputPath(options.generator),
6418
+ outputDir,
6645
6419
  runtimeBase: "@prisma/client/runtime",
6646
6420
  dmmf: options.dmmf,
6647
6421
  generator: options.generator,
@@ -6650,48 +6424,16 @@ var PrismaClientTsGenerator = class {
6650
6424
  activeProvider: options.datasources[0]?.activeProvider,
6651
6425
  postinstall: options.postinstall,
6652
6426
  copyEngine: !options.noEngine,
6653
- typedSql: options.typedSql
6427
+ typedSql: options.typedSql,
6428
+ target,
6429
+ generatedFileExtension,
6430
+ importFileExtension,
6431
+ moduleFormat
6654
6432
  });
6655
6433
  }
6656
6434
  };
6657
-
6658
- // src/utils/types/dmmfToTypes.ts
6659
- function dmmfToTypes(dmmf) {
6660
- return new TSClient({
6661
- dmmf,
6662
- datasources: [],
6663
- clientVersion: "",
6664
- engineVersion: "",
6665
- runtimeBase: "@prisma/client",
6666
- runtimeName: "library",
6667
- schemaPath: "",
6668
- outputDir: "",
6669
- activeProvider: "",
6670
- binaryPaths: {},
6671
- generator: {
6672
- binaryTargets: [],
6673
- config: {},
6674
- name: "prisma-client-ts",
6675
- output: null,
6676
- provider: { value: "prisma-client-ts", fromEnvVar: null },
6677
- previewFeatures: [],
6678
- isCustomOutput: false,
6679
- sourceFilePath: "schema.prisma"
6680
- },
6681
- datamodel: "",
6682
- browser: false,
6683
- deno: false,
6684
- edge: false,
6685
- wasm: false,
6686
- envPaths: {
6687
- rootEnvPath: null,
6688
- schemaEnvPath: void 0
6689
- }
6690
- }).toTS();
6691
- }
6692
6435
  export {
6693
6436
  PrismaClientTsGenerator,
6694
- dmmfToTypes,
6695
6437
  externalToInternalDmmf,
6696
6438
  generateClient,
6697
6439
  getDMMF