@prisma/client-generator-ts 6.15.0-dev.3 → 6.15.0-dev.30

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.
@@ -1,5 +1,5 @@
1
1
  import { TsConfigJsonResolved } from 'get-tsconfig';
2
- import { RuntimeTarget } from './runtime-targets';
2
+ import type { RuntimeTargetInternal } from './runtime-targets';
3
3
  declare const expectedGeneratedFileExtensions: readonly ["ts", "mts", "cts"];
4
4
  export type GeneratedFileExtension = (typeof expectedGeneratedFileExtensions)[number] | (string & {});
5
5
  declare const expectedImportFileExtensions: readonly ["", "ts", "mts", "cts", "js", "mjs", "cjs"];
@@ -12,7 +12,7 @@ export declare function importFileNameMapper(importFileExtension: ImportFileExte
12
12
  type InferImportFileExtensionOptions = {
13
13
  tsconfig: TsConfigJsonResolved | undefined;
14
14
  generatedFileExtension: GeneratedFileExtension;
15
- target: RuntimeTarget;
15
+ target: RuntimeTargetInternal;
16
16
  };
17
17
  export declare function inferImportFileExtension({ tsconfig, generatedFileExtension, target, }: InferImportFileExtensionOptions): ImportFileExtension;
18
18
  export {};
@@ -6,7 +6,7 @@ import { EnvPaths } from '@prisma/internals';
6
6
  import type { O } from 'ts-toolbelt';
7
7
  import { GeneratedFileExtension, ImportFileExtension } from './file-extensions';
8
8
  import { ModuleFormat } from './module-format';
9
- import { RuntimeTarget } from './runtime-targets';
9
+ import type { RuntimeTargetInternal } from './runtime-targets';
10
10
  export declare class DenylistError extends Error {
11
11
  constructor(message: string);
12
12
  }
@@ -29,7 +29,7 @@ export interface GenerateClientOptions {
29
29
  /** False when --no-engine is passed via CLI */
30
30
  copyEngine?: boolean;
31
31
  typedSql?: SqlQueryOutput[];
32
- target: RuntimeTarget;
32
+ target: RuntimeTargetInternal;
33
33
  generatedFileExtension: GeneratedFileExtension;
34
34
  importFileExtension: ImportFileExtension;
35
35
  moduleFormat: ModuleFormat;
package/dist/index.d.mts CHANGED
@@ -43,7 +43,7 @@ export declare interface GenerateClientOptions {
43
43
  /** False when --no-engine is passed via CLI */
44
44
  copyEngine?: boolean;
45
45
  typedSql?: SqlQueryOutput[];
46
- target: RuntimeTarget;
46
+ target: RuntimeTargetInternal;
47
47
  generatedFileExtension: GeneratedFileExtension;
48
48
  importFileExtension: ImportFileExtension;
49
49
  moduleFormat: ModuleFormat;
@@ -67,8 +67,11 @@ export declare class PrismaClientTsGenerator implements Generator_2 {
67
67
  generate(options: GeneratorOptions): Promise<void>;
68
68
  }
69
69
 
70
- declare type RuntimeTarget = (typeof supportedRuntimes)[number];
70
+ /**
71
+ * The internal representation of the `runtime` attribute for the `prisma-client` generator.
72
+ */
73
+ declare type RuntimeTargetInternal = (typeof supportedInternalRuntimes)[number];
71
74
 
72
- declare const supportedRuntimes: readonly ["nodejs", "deno", "bun", "workerd", "edge-light", "react-native"];
75
+ declare const supportedInternalRuntimes: readonly ["nodejs", "workerd", "vercel-edge", "deno", "react-native"];
73
76
 
74
77
  export { }
package/dist/index.d.ts CHANGED
@@ -43,7 +43,7 @@ export declare interface GenerateClientOptions {
43
43
  /** False when --no-engine is passed via CLI */
44
44
  copyEngine?: boolean;
45
45
  typedSql?: SqlQueryOutput[];
46
- target: RuntimeTarget;
46
+ target: RuntimeTargetInternal;
47
47
  generatedFileExtension: GeneratedFileExtension;
48
48
  importFileExtension: ImportFileExtension;
49
49
  moduleFormat: ModuleFormat;
@@ -67,8 +67,11 @@ export declare class PrismaClientTsGenerator implements Generator_2 {
67
67
  generate(options: GeneratorOptions): Promise<void>;
68
68
  }
69
69
 
70
- declare type RuntimeTarget = (typeof supportedRuntimes)[number];
70
+ /**
71
+ * The internal representation of the `runtime` attribute for the `prisma-client` generator.
72
+ */
73
+ declare type RuntimeTargetInternal = (typeof supportedInternalRuntimes)[number];
71
74
 
72
- declare const supportedRuntimes: readonly ["nodejs", "deno", "bun", "workerd", "edge-light", "react-native"];
75
+ declare const supportedInternalRuntimes: readonly ["nodejs", "workerd", "vercel-edge", "deno", "react-native"];
73
76
 
74
77
  export { }
package/dist/index.js CHANGED
@@ -2803,7 +2803,7 @@ var DMMFHelper = class {
2803
2803
  }
2804
2804
  buildInputTypesMap() {
2805
2805
  const result = /* @__PURE__ */ new Map();
2806
- for (const type of this.inputObjectTypes.prisma) {
2806
+ for (const type of this.inputObjectTypes.prisma ?? []) {
2807
2807
  result.set(fullyQualifiedName(type.name, "prisma"), type);
2808
2808
  }
2809
2809
  if (!this.inputObjectTypes.model) {
@@ -3446,51 +3446,7 @@ var import_node_path = __toESM(require("node:path"));
3446
3446
  var import_client_common11 = require("@prisma/client-common");
3447
3447
  var import_debug = require("@prisma/debug");
3448
3448
  var import_ts_pattern = require("ts-pattern");
3449
-
3450
- // src/runtime-targets.ts
3451
- var supportedRuntimes = ["nodejs", "deno", "bun", "workerd", "edge-light", "react-native"];
3452
- function parseRuntimeTarget(target) {
3453
- switch (target.toLowerCase()) {
3454
- case "node":
3455
- case "nodejs":
3456
- return "nodejs";
3457
- case "deno":
3458
- case "deno-deploy":
3459
- return "deno";
3460
- case "bun":
3461
- return "bun";
3462
- case "workerd":
3463
- case "cloudflare":
3464
- return "workerd";
3465
- case "edge-light":
3466
- case "vercel":
3467
- return "edge-light";
3468
- case "react-native":
3469
- return "react-native";
3470
- default:
3471
- throw new Error(
3472
- `Unknown target runtime: "${target}". The available options are: ${supportedRuntimes.map((runtime) => `"${runtime}"`).join(", ")}`
3473
- );
3474
- }
3475
- }
3476
- function parseRuntimeTargetFromUnknown(target) {
3477
- if (typeof target !== "string") {
3478
- throw new Error(`Invalid target runtime: ${JSON.stringify(target)}. Expected a string.`);
3479
- }
3480
- return parseRuntimeTarget(target);
3481
- }
3482
- function isNodeJsLike(target) {
3483
- return target === "nodejs" || target === "bun" || target === "deno";
3484
- }
3485
-
3486
- // src/utils/wasm.ts
3487
3449
  var debug = (0, import_debug.Debug)("prisma:client-generator-ts:wasm");
3488
- function buildDynamicRequireFn() {
3489
- return `const dynamicRequireFn = async <const T extends string>(name: T) =>
3490
- typeof globalThis.__non_webpack_require__ === 'function'
3491
- ? Promise.resolve(globalThis.__non_webpack_require__(name))
3492
- : await import(/* webpackIgnore: true */ /* @vite-ignore */ name)`;
3493
- }
3494
3450
  function usesEdgeWasmRuntime(component, runtimeName) {
3495
3451
  return runtimeName === "wasm-engine-edge" && component === "engine" || runtimeName === "wasm-compiler-edge" && component === "compiler";
3496
3452
  }
@@ -3498,14 +3454,12 @@ function buildGetWasmModule({
3498
3454
  component,
3499
3455
  runtimeName,
3500
3456
  runtimeBase,
3501
- target,
3502
3457
  activeProvider,
3503
3458
  moduleFormat
3504
3459
  }) {
3505
3460
  const capitalizedComponent = (0, import_client_common11.capitalize)(component);
3506
3461
  const extension = (0, import_ts_pattern.match)(moduleFormat).with("esm", () => "mjs").with("cjs", () => "js").exhaustive();
3507
3462
  const buildNonEdgeLoader = (0, import_ts_pattern.match)(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
3508
- const buildNodeJsLoader = buildNonEdgeLoader && isNodeJsLike(target);
3509
3463
  const buildEdgeLoader = usesEdgeWasmRuntime(component, runtimeName);
3510
3464
  let wasmPathBase;
3511
3465
  let wasmBindingsPath;
@@ -3519,14 +3473,13 @@ function buildGetWasmModule({
3519
3473
  wasmBindingsPath = `${wasmPathBase}.mjs`;
3520
3474
  wasmModulePath = `${wasmPathBase}.wasm`;
3521
3475
  }
3522
- if (buildNodeJsLoader) {
3476
+ if (buildNonEdgeLoader) {
3523
3477
  wasmBindingsPath = `${wasmPathBase}.${extension}`;
3524
3478
  wasmModulePath = `${wasmPathBase}.wasm-base64.${extension}`;
3525
3479
  return `
3526
3480
  async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Module> {
3527
3481
  const { Buffer } = await import('node:buffer')
3528
- const base64Data = wasmBase64.replace('data:application/wasm;base64,', '')
3529
- const wasmArray = new Uint8Array(Buffer.from(base64Data, 'base64'))
3482
+ const wasmArray = Buffer.from(wasmBase64, 'base64')
3530
3483
  return new WebAssembly.Module(wasmArray)
3531
3484
  }
3532
3485
 
@@ -3537,49 +3490,23 @@ config.${component}Wasm = {
3537
3490
  const { wasm } = await import(${JSON.stringify(wasmModulePath)})
3538
3491
  return await decodeBase64AsWasm(wasm)
3539
3492
  }
3540
- }`;
3541
- }
3542
- if (buildNonEdgeLoader) {
3543
- return `config.${component}Wasm = {
3544
- getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3545
-
3546
- getQuery${capitalizedComponent}WasmModule: async () => {
3547
- ${buildDynamicRequireFn()}
3548
-
3549
- // Note: we must use dynamic imports here to avoid bundling errors like \`Module parse failed: Unexpected character '' (1:0)\`.
3550
- const { readFile } = await dynamicRequireFn('node:fs/promises')
3551
- ${buildRequire(moduleFormat)}
3552
- const wasmModulePath = _require.resolve(${JSON.stringify(wasmModulePath)})
3553
- const wasmModuleBytes = await readFile(wasmModulePath)
3554
-
3555
- return new globalThis.WebAssembly.Module(wasmModuleBytes)
3556
- }
3557
3493
  }`;
3558
3494
  }
3559
3495
  if (buildEdgeLoader) {
3560
- const fullWasmModulePath = target === "edge-light" ? `${wasmModulePath}?module` : wasmModulePath;
3561
3496
  return `config.${component}Wasm = {
3562
3497
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3563
3498
 
3564
3499
  getQuery${capitalizedComponent}WasmModule: async () => {
3565
- const { default: module } = await import(${JSON.stringify(fullWasmModulePath)})
3500
+ const { default: module } = await import(${JSON.stringify(`${wasmModulePath}?module`)})
3566
3501
  return module
3567
3502
  }
3568
3503
  }`;
3569
3504
  }
3570
3505
  return `config.${component}Wasm = undefined`;
3571
3506
  }
3572
- function buildRequire(moduleFormat) {
3573
- if (moduleFormat === "cjs") {
3574
- return "const _require = require\n";
3575
- }
3576
- return `const { createRequire } = await dynamicRequireFn('node:module')
3577
- const _require = createRequire(import.meta.url)
3578
- `;
3579
- }
3580
3507
  function readSourceFile(sourceFile) {
3581
3508
  const bundledLocation = import_node_path.default.join(__dirname, sourceFile);
3582
- const sourceLocation = import_node_path.default.join(__dirname, "..", "..", "..", "client", "runtime", sourceFile);
3509
+ const sourceLocation = import_node_path.default.join(__dirname, "..", "..", "..", "cli", "build", sourceFile);
3583
3510
  if (import_node_fs.default.existsSync(bundledLocation)) {
3584
3511
  debug("We are in the bundled Prisma CLI");
3585
3512
  return import_node_fs.default.readFileSync(bundledLocation);
@@ -3847,8 +3774,8 @@ var PrismaClientClass = class {
3847
3774
  export interface PrismaClientConstructor {
3848
3775
  ${(0, import_indent_string3.default)(this.jsDoc, TAB_SIZE)}
3849
3776
  new <
3850
- Options extends Prisma.PrismaClientOptions,
3851
- LogOpts extends LogOptions<Options>,
3777
+ Options extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
3778
+ LogOpts extends LogOptions<Options> = LogOptions<Options>,
3852
3779
  OmitOpts extends Prisma.PrismaClientOptions['omit'] = Options extends { omit: infer U } ? U : Prisma.PrismaClientOptions['omit'],
3853
3780
  ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3854
3781
  >(options?: Prisma.Subset<Options, Prisma.PrismaClientOptions> ): PrismaClient<LogOpts, OmitOpts, ExtArgs>
@@ -3919,7 +3846,7 @@ get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
3919
3846
  };
3920
3847
 
3921
3848
  // src/TSClient/file-generators/ClassFile.ts
3922
- var jsDocHeader = `/**
3849
+ var jsDocHeader = `/*
3923
3850
  * WARNING: This is an internal file that is subject to change!
3924
3851
  *
3925
3852
  * \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
@@ -4040,7 +3967,7 @@ path.join(process.cwd(), ${JSON.stringify((0, import_internals4.pathToPosix)(rel
4040
3967
  }
4041
3968
 
4042
3969
  // src/TSClient/file-generators/ClientFile.ts
4043
- var jsDocHeader2 = `/**
3970
+ var jsDocHeader2 = `/*
4044
3971
  * This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
4045
3972
  *
4046
3973
  * \u{1F7E2} You can import this file directly.
@@ -4111,7 +4038,7 @@ ${modelEnumsAliases.length > 0 ? `${modelEnumsAliases.join("\n\n")}` : ""}
4111
4038
  }
4112
4039
  function buildPreamble(edge, moduleFormat) {
4113
4040
  if (edge) {
4114
- return `const __dirname = '/'
4041
+ return `globalThis['__dirname'] = '/'
4115
4042
  `;
4116
4043
  }
4117
4044
  let preamble = `import * as process from 'node:process'
@@ -4119,7 +4046,7 @@ import * as path from 'node:path'
4119
4046
  `;
4120
4047
  if (moduleFormat === "esm") {
4121
4048
  preamble += `import { fileURLToPath } from 'node:url'
4122
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
4049
+ globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url))
4123
4050
  `;
4124
4051
  }
4125
4052
  return preamble;
@@ -4127,7 +4054,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
4127
4054
 
4128
4055
  // src/TSClient/file-generators/CommonInputTypesFile.ts
4129
4056
  var ts7 = __toESM(require("@prisma/ts-builders"));
4130
- var jsDocHeader3 = `/**
4057
+ var jsDocHeader3 = `/*
4131
4058
  * This file exports various common sort, input & filter types that are not directly linked to a particular model.
4132
4059
  *
4133
4060
  * \u{1F7E2} You can import this file directly.
@@ -4139,7 +4066,7 @@ function createCommonInputTypeFiles(context) {
4139
4066
  ts7.moduleImport(context.importFileName(`./enums`)).asNamespace("$Enums"),
4140
4067
  ts7.moduleImport(context.importFileName(`./internal/prismaNamespace`)).asNamespace("Prisma").typeOnly()
4141
4068
  ].map((i) => ts7.stringify(i));
4142
- const genericInputTypes = context.dmmf.inputObjectTypes.prisma.filter((i) => !i.meta?.grouping).map((inputType) => new InputType(inputType, context).toTS());
4069
+ const genericInputTypes = context.dmmf.inputObjectTypes.prisma?.filter((i) => !i.meta?.grouping)?.map((inputType) => new InputType(inputType, context).toTS()) ?? [];
4143
4070
  return `${jsDocHeader3}
4144
4071
  ${imports.join("\n")}
4145
4072
 
@@ -4151,11 +4078,12 @@ ${context.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputTyp
4151
4078
 
4152
4079
  // src/TSClient/file-generators/EnumsFile.ts
4153
4080
  var import_dmmf = require("@prisma/dmmf");
4154
- var jsDocHeader4 = `/**
4081
+ var jsDocHeader4 = `/*
4155
4082
  * This file exports all enum related types from the schema.
4156
4083
  *
4157
4084
  * \u{1F7E2} You can import this file directly.
4158
4085
  */
4086
+
4159
4087
  `;
4160
4088
  function createEnumsFile(context) {
4161
4089
  const modelEnums = [];
@@ -5175,7 +5103,7 @@ function fluentWrapperName(modelName) {
5175
5103
 
5176
5104
  // src/TSClient/file-generators/ModelFile.ts
5177
5105
  function createModelFile(context, modelName) {
5178
- const jsDocHeader7 = `/**
5106
+ const jsDocHeader7 = `/*
5179
5107
  * This file exports the \`${modelName}\` model and its related types.
5180
5108
  *
5181
5109
  * \u{1F7E2} You can import this file directly.
@@ -5192,7 +5120,7 @@ function createModelFile(context, modelName) {
5192
5120
  }
5193
5121
 
5194
5122
  // src/TSClient/file-generators/ModelsFile.ts
5195
- var jsDocHeader5 = `/**
5123
+ var jsDocHeader5 = `/*
5196
5124
  * This is a barrel export file for all models and their related types.
5197
5125
  *
5198
5126
  * \u{1F7E2} You can import this file directly.
@@ -5755,7 +5683,7 @@ function payloadToResult(modelName) {
5755
5683
  }
5756
5684
 
5757
5685
  // src/TSClient/file-generators/PrismaNamespaceFile.ts
5758
- var jsDocHeader6 = `/**
5686
+ var jsDocHeader6 = `/*
5759
5687
  * WARNING: This is an internal file that is subject to change!
5760
5688
  *
5761
5689
  * \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
@@ -6564,10 +6492,9 @@ function getRuntimeNameForTarget(target, engineType, previewFeatures) {
6564
6492
  switch (target) {
6565
6493
  case "nodejs":
6566
6494
  case "deno":
6567
- case "bun":
6568
6495
  return getNodeRuntimeName(engineType);
6569
6496
  case "workerd":
6570
- case "edge-light":
6497
+ case "vercel-edge":
6571
6498
  if (previewFeatures.includes("driverAdapters")) {
6572
6499
  return engineType === import_internals9.ClientEngineType.Client ? "wasm-compiler-edge" : "wasm-engine-edge";
6573
6500
  } else {
@@ -6606,6 +6533,7 @@ async function deleteOutputDir(outputDir) {
6606
6533
  (await (0, import_fast_glob.glob)(
6607
6534
  [
6608
6535
  `${outputDir}/**/*.{js,ts,mts,cts,d.ts}`,
6536
+ `${outputDir}/**/*.wasm`,
6609
6537
  `${outputDir}/*.node`,
6610
6538
  `${outputDir}/{query,schema}-engine-*`,
6611
6539
  `${outputDir}/package.json`,
@@ -6631,7 +6559,7 @@ var import_get_tsconfig = require("get-tsconfig");
6631
6559
  var import_ts_pattern2 = require("ts-pattern");
6632
6560
 
6633
6561
  // package.json
6634
- var version = "6.15.0-dev.3";
6562
+ var version = "6.15.0-dev.30";
6635
6563
 
6636
6564
  // src/module-format.ts
6637
6565
  function parseModuleFormat(format) {
@@ -6673,6 +6601,45 @@ function fromTsConfigModule(module2) {
6673
6601
  return "esm";
6674
6602
  }
6675
6603
 
6604
+ // src/runtime-targets.ts
6605
+ var supportedPublicRuntimes = [
6606
+ "nodejs",
6607
+ "deno",
6608
+ "bun",
6609
+ "workerd",
6610
+ "cloudflare",
6611
+ "vercel-edge",
6612
+ "edge-light",
6613
+ "react-native"
6614
+ ];
6615
+ function parseRuntimeTarget(target) {
6616
+ switch (target.toLowerCase()) {
6617
+ case "workerd":
6618
+ case "cloudflare":
6619
+ return "workerd";
6620
+ case "edge-light":
6621
+ case "vercel-edge":
6622
+ return "vercel-edge";
6623
+ case "nodejs":
6624
+ case "bun":
6625
+ return "nodejs";
6626
+ case "deno":
6627
+ return "deno";
6628
+ case "react-native":
6629
+ return "react-native";
6630
+ default:
6631
+ throw new Error(
6632
+ `Unknown target runtime: "${target}". The available options are: ${supportedPublicRuntimes.map((runtime) => `"${runtime}"`).join(", ")}`
6633
+ );
6634
+ }
6635
+ }
6636
+ function parseRuntimeTargetFromUnknown(target) {
6637
+ if (typeof target !== "string") {
6638
+ throw new Error(`Invalid target runtime: ${JSON.stringify(target)}. Expected a string.`);
6639
+ }
6640
+ return parseRuntimeTarget(target);
6641
+ }
6642
+
6676
6643
  // src/generator.ts
6677
6644
  var debug2 = (0, import_debug2.Debug)("prisma:client:generator");
6678
6645
  var missingOutputErrorMessage = `An output path is required for the \`prisma-client\` generator. Please provide an output path in your schema file:
package/dist/index.mjs CHANGED
@@ -2799,7 +2799,7 @@ var DMMFHelper = class {
2799
2799
  }
2800
2800
  buildInputTypesMap() {
2801
2801
  const result = /* @__PURE__ */ new Map();
2802
- for (const type of this.inputObjectTypes.prisma) {
2802
+ for (const type of this.inputObjectTypes.prisma ?? []) {
2803
2803
  result.set(fullyQualifiedName(type.name, "prisma"), type);
2804
2804
  }
2805
2805
  if (!this.inputObjectTypes.model) {
@@ -3445,51 +3445,7 @@ import path from "node:path";
3445
3445
  import { capitalize as capitalize6 } from "@prisma/client-common";
3446
3446
  import { Debug } from "@prisma/debug";
3447
3447
  import { match } from "ts-pattern";
3448
-
3449
- // src/runtime-targets.ts
3450
- var supportedRuntimes = ["nodejs", "deno", "bun", "workerd", "edge-light", "react-native"];
3451
- function parseRuntimeTarget(target) {
3452
- switch (target.toLowerCase()) {
3453
- case "node":
3454
- case "nodejs":
3455
- return "nodejs";
3456
- case "deno":
3457
- case "deno-deploy":
3458
- return "deno";
3459
- case "bun":
3460
- return "bun";
3461
- case "workerd":
3462
- case "cloudflare":
3463
- return "workerd";
3464
- case "edge-light":
3465
- case "vercel":
3466
- return "edge-light";
3467
- case "react-native":
3468
- return "react-native";
3469
- default:
3470
- throw new Error(
3471
- `Unknown target runtime: "${target}". The available options are: ${supportedRuntimes.map((runtime) => `"${runtime}"`).join(", ")}`
3472
- );
3473
- }
3474
- }
3475
- function parseRuntimeTargetFromUnknown(target) {
3476
- if (typeof target !== "string") {
3477
- throw new Error(`Invalid target runtime: ${JSON.stringify(target)}. Expected a string.`);
3478
- }
3479
- return parseRuntimeTarget(target);
3480
- }
3481
- function isNodeJsLike(target) {
3482
- return target === "nodejs" || target === "bun" || target === "deno";
3483
- }
3484
-
3485
- // src/utils/wasm.ts
3486
3448
  var debug = Debug("prisma:client-generator-ts:wasm");
3487
- function buildDynamicRequireFn() {
3488
- return `const dynamicRequireFn = async <const T extends string>(name: T) =>
3489
- typeof globalThis.__non_webpack_require__ === 'function'
3490
- ? Promise.resolve(globalThis.__non_webpack_require__(name))
3491
- : await import(/* webpackIgnore: true */ /* @vite-ignore */ name)`;
3492
- }
3493
3449
  function usesEdgeWasmRuntime(component, runtimeName) {
3494
3450
  return runtimeName === "wasm-engine-edge" && component === "engine" || runtimeName === "wasm-compiler-edge" && component === "compiler";
3495
3451
  }
@@ -3497,14 +3453,12 @@ function buildGetWasmModule({
3497
3453
  component,
3498
3454
  runtimeName,
3499
3455
  runtimeBase,
3500
- target,
3501
3456
  activeProvider,
3502
3457
  moduleFormat
3503
3458
  }) {
3504
3459
  const capitalizedComponent = capitalize6(component);
3505
3460
  const extension = match(moduleFormat).with("esm", () => "mjs").with("cjs", () => "js").exhaustive();
3506
3461
  const buildNonEdgeLoader = match(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
3507
- const buildNodeJsLoader = buildNonEdgeLoader && isNodeJsLike(target);
3508
3462
  const buildEdgeLoader = usesEdgeWasmRuntime(component, runtimeName);
3509
3463
  let wasmPathBase;
3510
3464
  let wasmBindingsPath;
@@ -3518,14 +3472,13 @@ function buildGetWasmModule({
3518
3472
  wasmBindingsPath = `${wasmPathBase}.mjs`;
3519
3473
  wasmModulePath = `${wasmPathBase}.wasm`;
3520
3474
  }
3521
- if (buildNodeJsLoader) {
3475
+ if (buildNonEdgeLoader) {
3522
3476
  wasmBindingsPath = `${wasmPathBase}.${extension}`;
3523
3477
  wasmModulePath = `${wasmPathBase}.wasm-base64.${extension}`;
3524
3478
  return `
3525
3479
  async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Module> {
3526
3480
  const { Buffer } = await import('node:buffer')
3527
- const base64Data = wasmBase64.replace('data:application/wasm;base64,', '')
3528
- const wasmArray = new Uint8Array(Buffer.from(base64Data, 'base64'))
3481
+ const wasmArray = Buffer.from(wasmBase64, 'base64')
3529
3482
  return new WebAssembly.Module(wasmArray)
3530
3483
  }
3531
3484
 
@@ -3536,49 +3489,23 @@ config.${component}Wasm = {
3536
3489
  const { wasm } = await import(${JSON.stringify(wasmModulePath)})
3537
3490
  return await decodeBase64AsWasm(wasm)
3538
3491
  }
3539
- }`;
3540
- }
3541
- if (buildNonEdgeLoader) {
3542
- return `config.${component}Wasm = {
3543
- getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3544
-
3545
- getQuery${capitalizedComponent}WasmModule: async () => {
3546
- ${buildDynamicRequireFn()}
3547
-
3548
- // Note: we must use dynamic imports here to avoid bundling errors like \`Module parse failed: Unexpected character '' (1:0)\`.
3549
- const { readFile } = await dynamicRequireFn('node:fs/promises')
3550
- ${buildRequire(moduleFormat)}
3551
- const wasmModulePath = _require.resolve(${JSON.stringify(wasmModulePath)})
3552
- const wasmModuleBytes = await readFile(wasmModulePath)
3553
-
3554
- return new globalThis.WebAssembly.Module(wasmModuleBytes)
3555
- }
3556
3492
  }`;
3557
3493
  }
3558
3494
  if (buildEdgeLoader) {
3559
- const fullWasmModulePath = target === "edge-light" ? `${wasmModulePath}?module` : wasmModulePath;
3560
3495
  return `config.${component}Wasm = {
3561
3496
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3562
3497
 
3563
3498
  getQuery${capitalizedComponent}WasmModule: async () => {
3564
- const { default: module } = await import(${JSON.stringify(fullWasmModulePath)})
3499
+ const { default: module } = await import(${JSON.stringify(`${wasmModulePath}?module`)})
3565
3500
  return module
3566
3501
  }
3567
3502
  }`;
3568
3503
  }
3569
3504
  return `config.${component}Wasm = undefined`;
3570
3505
  }
3571
- function buildRequire(moduleFormat) {
3572
- if (moduleFormat === "cjs") {
3573
- return "const _require = require\n";
3574
- }
3575
- return `const { createRequire } = await dynamicRequireFn('node:module')
3576
- const _require = createRequire(import.meta.url)
3577
- `;
3578
- }
3579
3506
  function readSourceFile(sourceFile) {
3580
3507
  const bundledLocation = path.join(__dirname, sourceFile);
3581
- const sourceLocation = path.join(__dirname, "..", "..", "..", "client", "runtime", sourceFile);
3508
+ const sourceLocation = path.join(__dirname, "..", "..", "..", "cli", "build", sourceFile);
3582
3509
  if (fs.existsSync(bundledLocation)) {
3583
3510
  debug("We are in the bundled Prisma CLI");
3584
3511
  return fs.readFileSync(bundledLocation);
@@ -3846,8 +3773,8 @@ var PrismaClientClass = class {
3846
3773
  export interface PrismaClientConstructor {
3847
3774
  ${indent3(this.jsDoc, TAB_SIZE)}
3848
3775
  new <
3849
- Options extends Prisma.PrismaClientOptions,
3850
- LogOpts extends LogOptions<Options>,
3776
+ Options extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
3777
+ LogOpts extends LogOptions<Options> = LogOptions<Options>,
3851
3778
  OmitOpts extends Prisma.PrismaClientOptions['omit'] = Options extends { omit: infer U } ? U : Prisma.PrismaClientOptions['omit'],
3852
3779
  ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3853
3780
  >(options?: Prisma.Subset<Options, Prisma.PrismaClientOptions> ): PrismaClient<LogOpts, OmitOpts, ExtArgs>
@@ -3918,7 +3845,7 @@ get ${methodName}(): Prisma.${m.model}Delegate<${generics.join(", ")}>;`;
3918
3845
  };
3919
3846
 
3920
3847
  // src/TSClient/file-generators/ClassFile.ts
3921
- var jsDocHeader = `/**
3848
+ var jsDocHeader = `/*
3922
3849
  * WARNING: This is an internal file that is subject to change!
3923
3850
  *
3924
3851
  * \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
@@ -4039,7 +3966,7 @@ path.join(process.cwd(), ${JSON.stringify(pathToPosix2(relativeFilePath))})`;
4039
3966
  }
4040
3967
 
4041
3968
  // src/TSClient/file-generators/ClientFile.ts
4042
- var jsDocHeader2 = `/**
3969
+ var jsDocHeader2 = `/*
4043
3970
  * This file should be your main import to use Prisma. Through it you get access to all the models, enums, and input types.
4044
3971
  *
4045
3972
  * \u{1F7E2} You can import this file directly.
@@ -4110,7 +4037,7 @@ ${modelEnumsAliases.length > 0 ? `${modelEnumsAliases.join("\n\n")}` : ""}
4110
4037
  }
4111
4038
  function buildPreamble(edge, moduleFormat) {
4112
4039
  if (edge) {
4113
- return `const __dirname = '/'
4040
+ return `globalThis['__dirname'] = '/'
4114
4041
  `;
4115
4042
  }
4116
4043
  let preamble = `import * as process from 'node:process'
@@ -4118,7 +4045,7 @@ import * as path from 'node:path'
4118
4045
  `;
4119
4046
  if (moduleFormat === "esm") {
4120
4047
  preamble += `import { fileURLToPath } from 'node:url'
4121
- const __dirname = path.dirname(fileURLToPath(import.meta.url))
4048
+ globalThis['__dirname'] = path.dirname(fileURLToPath(import.meta.url))
4122
4049
  `;
4123
4050
  }
4124
4051
  return preamble;
@@ -4126,7 +4053,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url))
4126
4053
 
4127
4054
  // src/TSClient/file-generators/CommonInputTypesFile.ts
4128
4055
  import * as ts7 from "@prisma/ts-builders";
4129
- var jsDocHeader3 = `/**
4056
+ var jsDocHeader3 = `/*
4130
4057
  * This file exports various common sort, input & filter types that are not directly linked to a particular model.
4131
4058
  *
4132
4059
  * \u{1F7E2} You can import this file directly.
@@ -4138,7 +4065,7 @@ function createCommonInputTypeFiles(context) {
4138
4065
  ts7.moduleImport(context.importFileName(`./enums`)).asNamespace("$Enums"),
4139
4066
  ts7.moduleImport(context.importFileName(`./internal/prismaNamespace`)).asNamespace("Prisma").typeOnly()
4140
4067
  ].map((i) => ts7.stringify(i));
4141
- const genericInputTypes = context.dmmf.inputObjectTypes.prisma.filter((i) => !i.meta?.grouping).map((inputType) => new InputType(inputType, context).toTS());
4068
+ const genericInputTypes = context.dmmf.inputObjectTypes.prisma?.filter((i) => !i.meta?.grouping)?.map((inputType) => new InputType(inputType, context).toTS()) ?? [];
4142
4069
  return `${jsDocHeader3}
4143
4070
  ${imports.join("\n")}
4144
4071
 
@@ -4150,11 +4077,12 @@ ${context.dmmf.inputObjectTypes.model?.map((inputType) => new InputType(inputTyp
4150
4077
 
4151
4078
  // src/TSClient/file-generators/EnumsFile.ts
4152
4079
  import { datamodelEnumToSchemaEnum } from "@prisma/dmmf";
4153
- var jsDocHeader4 = `/**
4080
+ var jsDocHeader4 = `/*
4154
4081
  * This file exports all enum related types from the schema.
4155
4082
  *
4156
4083
  * \u{1F7E2} You can import this file directly.
4157
4084
  */
4085
+
4158
4086
  `;
4159
4087
  function createEnumsFile(context) {
4160
4088
  const modelEnums = [];
@@ -5174,7 +5102,7 @@ function fluentWrapperName(modelName) {
5174
5102
 
5175
5103
  // src/TSClient/file-generators/ModelFile.ts
5176
5104
  function createModelFile(context, modelName) {
5177
- const jsDocHeader7 = `/**
5105
+ const jsDocHeader7 = `/*
5178
5106
  * This file exports the \`${modelName}\` model and its related types.
5179
5107
  *
5180
5108
  * \u{1F7E2} You can import this file directly.
@@ -5191,7 +5119,7 @@ function createModelFile(context, modelName) {
5191
5119
  }
5192
5120
 
5193
5121
  // src/TSClient/file-generators/ModelsFile.ts
5194
- var jsDocHeader5 = `/**
5122
+ var jsDocHeader5 = `/*
5195
5123
  * This is a barrel export file for all models and their related types.
5196
5124
  *
5197
5125
  * \u{1F7E2} You can import this file directly.
@@ -5754,7 +5682,7 @@ function payloadToResult(modelName) {
5754
5682
  }
5755
5683
 
5756
5684
  // src/TSClient/file-generators/PrismaNamespaceFile.ts
5757
- var jsDocHeader6 = `/**
5685
+ var jsDocHeader6 = `/*
5758
5686
  * WARNING: This is an internal file that is subject to change!
5759
5687
  *
5760
5688
  * \u{1F6D1} Under no circumstances should you import this file directly! \u{1F6D1}
@@ -6563,10 +6491,9 @@ function getRuntimeNameForTarget(target, engineType, previewFeatures) {
6563
6491
  switch (target) {
6564
6492
  case "nodejs":
6565
6493
  case "deno":
6566
- case "bun":
6567
6494
  return getNodeRuntimeName(engineType);
6568
6495
  case "workerd":
6569
- case "edge-light":
6496
+ case "vercel-edge":
6570
6497
  if (previewFeatures.includes("driverAdapters")) {
6571
6498
  return engineType === ClientEngineType3.Client ? "wasm-compiler-edge" : "wasm-engine-edge";
6572
6499
  } else {
@@ -6605,6 +6532,7 @@ async function deleteOutputDir(outputDir) {
6605
6532
  (await glob(
6606
6533
  [
6607
6534
  `${outputDir}/**/*.{js,ts,mts,cts,d.ts}`,
6535
+ `${outputDir}/**/*.wasm`,
6608
6536
  `${outputDir}/*.node`,
6609
6537
  `${outputDir}/{query,schema}-engine-*`,
6610
6538
  `${outputDir}/package.json`,
@@ -6630,7 +6558,7 @@ import { getTsconfig } from "get-tsconfig";
6630
6558
  import { match as match2 } from "ts-pattern";
6631
6559
 
6632
6560
  // package.json
6633
- var version = "6.15.0-dev.3";
6561
+ var version = "6.15.0-dev.30";
6634
6562
 
6635
6563
  // src/module-format.ts
6636
6564
  function parseModuleFormat(format) {
@@ -6672,6 +6600,45 @@ function fromTsConfigModule(module) {
6672
6600
  return "esm";
6673
6601
  }
6674
6602
 
6603
+ // src/runtime-targets.ts
6604
+ var supportedPublicRuntimes = [
6605
+ "nodejs",
6606
+ "deno",
6607
+ "bun",
6608
+ "workerd",
6609
+ "cloudflare",
6610
+ "vercel-edge",
6611
+ "edge-light",
6612
+ "react-native"
6613
+ ];
6614
+ function parseRuntimeTarget(target) {
6615
+ switch (target.toLowerCase()) {
6616
+ case "workerd":
6617
+ case "cloudflare":
6618
+ return "workerd";
6619
+ case "edge-light":
6620
+ case "vercel-edge":
6621
+ return "vercel-edge";
6622
+ case "nodejs":
6623
+ case "bun":
6624
+ return "nodejs";
6625
+ case "deno":
6626
+ return "deno";
6627
+ case "react-native":
6628
+ return "react-native";
6629
+ default:
6630
+ throw new Error(
6631
+ `Unknown target runtime: "${target}". The available options are: ${supportedPublicRuntimes.map((runtime) => `"${runtime}"`).join(", ")}`
6632
+ );
6633
+ }
6634
+ }
6635
+ function parseRuntimeTargetFromUnknown(target) {
6636
+ if (typeof target !== "string") {
6637
+ throw new Error(`Invalid target runtime: ${JSON.stringify(target)}. Expected a string.`);
6638
+ }
6639
+ return parseRuntimeTarget(target);
6640
+ }
6641
+
6675
6642
  // src/generator.ts
6676
6643
  var debug2 = Debug2("prisma:client:generator");
6677
6644
  var missingOutputErrorMessage = `An output path is required for the \`prisma-client\` generator. Please provide an output path in your schema file:
@@ -1,6 +1,12 @@
1
- declare const supportedRuntimes: readonly ["nodejs", "deno", "bun", "workerd", "edge-light", "react-native"];
2
- export type RuntimeTarget = (typeof supportedRuntimes)[number];
3
- export declare function parseRuntimeTarget(target: string): RuntimeTarget;
4
- export declare function parseRuntimeTargetFromUnknown(target: unknown): RuntimeTarget;
5
- export declare function isNodeJsLike(target: RuntimeTarget): boolean;
1
+ export declare const supportedInternalRuntimes: readonly ["nodejs", "workerd", "vercel-edge", "deno", "react-native"];
2
+ declare const supportedPublicRuntimes: readonly ["nodejs", "deno", "bun", "workerd", "cloudflare", "vercel-edge", "edge-light", "react-native"];
3
+ /**
4
+ * The user-facing `runtime` attribute for the `prisma-client` generator.
5
+ */
6
+ export type RuntimeTarget = (typeof supportedPublicRuntimes)[number];
7
+ /**
8
+ * The internal representation of the `runtime` attribute for the `prisma-client` generator.
9
+ */
10
+ export type RuntimeTargetInternal = (typeof supportedInternalRuntimes)[number];
11
+ export declare function parseRuntimeTargetFromUnknown(target: unknown): "nodejs" | "workerd" | "vercel-edge" | "deno" | "react-native";
6
12
  export {};
@@ -1,17 +1,17 @@
1
1
  import { ActiveConnectorType } from '@prisma/generator';
2
2
  import type { FileMap } from '../generateClient';
3
- import { ModuleFormat } from '../module-format';
4
- import { RuntimeTarget } from '../runtime-targets';
5
- import { RuntimeName } from '../TSClient/TSClient';
3
+ import type { ModuleFormat } from '../module-format';
4
+ import type { RuntimeTargetInternal } from '../runtime-targets';
5
+ import type { RuntimeName } from '../TSClient/TSClient';
6
6
  export type BuildWasmModuleOptions = {
7
7
  component: 'engine' | 'compiler';
8
8
  runtimeName: RuntimeName;
9
9
  runtimeBase: string;
10
- target: RuntimeTarget;
10
+ target: RuntimeTargetInternal;
11
11
  activeProvider: ActiveConnectorType;
12
12
  moduleFormat: ModuleFormat;
13
13
  };
14
- export declare function buildGetWasmModule({ component, runtimeName, runtimeBase, target, activeProvider, moduleFormat, }: BuildWasmModuleOptions): string;
14
+ export declare function buildGetWasmModule({ component, runtimeName, runtimeBase, activeProvider, moduleFormat, }: BuildWasmModuleOptions): string;
15
15
  export type BuildWasmFileMapOptions = {
16
16
  activeProvider: ActiveConnectorType;
17
17
  runtimeName: RuntimeName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-generator-ts",
3
- "version": "6.15.0-dev.3",
3
+ "version": "6.15.0-dev.30",
4
4
  "description": "This package is intended for Prisma's internal use",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -25,7 +25,7 @@
25
25
  "license": "Apache-2.0",
26
26
  "dependencies": {
27
27
  "@antfu/ni": "0.21.12",
28
- "@prisma/engines-version": "6.14.0-25.717184b7b35ea05dfa71a3236b7af656013e1e49",
28
+ "@prisma/engines-version": "6.15.0-5.85179d7826409ee107a6ba334b5e305ae3fba9fb",
29
29
  "ci-info": "4.2.0",
30
30
  "fast-glob": "3.3.3",
31
31
  "get-tsconfig": "4.10.0",
@@ -34,14 +34,14 @@
34
34
  "pkg-up": "3.1.0",
35
35
  "pluralize": "8.0.0",
36
36
  "ts-pattern": "5.6.2",
37
- "@prisma/client-common": "6.15.0-dev.3",
38
- "@prisma/dmmf": "6.15.0-dev.3",
39
- "@prisma/debug": "6.15.0-dev.3",
40
- "@prisma/generator": "6.15.0-dev.3",
41
- "@prisma/fetch-engine": "6.15.0-dev.3",
42
- "@prisma/internals": "6.15.0-dev.3",
43
- "@prisma/get-platform": "6.15.0-dev.3",
44
- "@prisma/ts-builders": "6.15.0-dev.3"
37
+ "@prisma/client-common": "6.15.0-dev.30",
38
+ "@prisma/dmmf": "6.15.0-dev.30",
39
+ "@prisma/fetch-engine": "6.15.0-dev.30",
40
+ "@prisma/generator": "6.15.0-dev.30",
41
+ "@prisma/get-platform": "6.15.0-dev.30",
42
+ "@prisma/internals": "6.15.0-dev.30",
43
+ "@prisma/ts-builders": "6.15.0-dev.30",
44
+ "@prisma/debug": "6.15.0-dev.30"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/pluralize": "0.0.33",