@prisma/client-generator-ts 6.14.0-dev.4 → 6.14.0-dev.40

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -494,11 +494,11 @@ var require_graceful_fs = __commonJS({
494
494
  }
495
495
  });
496
496
  }
497
- var debug2 = noop;
497
+ var debug3 = noop;
498
498
  if (util.debuglog)
499
- debug2 = util.debuglog("gfs4");
499
+ debug3 = util.debuglog("gfs4");
500
500
  else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
501
- debug2 = function() {
501
+ debug3 = function() {
502
502
  var m = util.format.apply(util, arguments);
503
503
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
504
504
  console.error(m);
@@ -533,7 +533,7 @@ var require_graceful_fs = __commonJS({
533
533
  }(fs3.closeSync);
534
534
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
535
535
  process.on("exit", function() {
536
- debug2(fs3[gracefulQueue]);
536
+ debug3(fs3[gracefulQueue]);
537
537
  require("assert").equal(fs3[gracefulQueue].length, 0);
538
538
  });
539
539
  }
@@ -786,7 +786,7 @@ var require_graceful_fs = __commonJS({
786
786
  return fs4;
787
787
  }
788
788
  function enqueue(elem) {
789
- debug2("ENQUEUE", elem[0].name, elem[1]);
789
+ debug3("ENQUEUE", elem[0].name, elem[1]);
790
790
  fs3[gracefulQueue].push(elem);
791
791
  retry();
792
792
  }
@@ -813,10 +813,10 @@ var require_graceful_fs = __commonJS({
813
813
  var startTime = elem[3];
814
814
  var lastTime = elem[4];
815
815
  if (startTime === void 0) {
816
- debug2("RETRY", fn.name, args);
816
+ debug3("RETRY", fn.name, args);
817
817
  fn.apply(null, args);
818
818
  } else if (Date.now() - startTime >= 6e4) {
819
- debug2("TIMEOUT", fn.name, args);
819
+ debug3("TIMEOUT", fn.name, args);
820
820
  var cb = args.pop();
821
821
  if (typeof cb === "function")
822
822
  cb.call(null, err);
@@ -825,7 +825,7 @@ var require_graceful_fs = __commonJS({
825
825
  var sinceStart = Math.max(lastTime - startTime, 1);
826
826
  var desiredDelay = Math.min(sinceStart * 1.2, 100);
827
827
  if (sinceAttempt >= desiredDelay) {
828
- debug2("RETRY", fn.name, args);
828
+ debug3("RETRY", fn.name, args);
829
829
  fn.apply(null, args.concat([startTime]));
830
830
  } else {
831
831
  fs3[gracefulQueue].push(elem);
@@ -3444,7 +3444,9 @@ function buildInlineDatasource(ds) {
3444
3444
  var import_node_fs = __toESM(require("node:fs"));
3445
3445
  var import_node_path = __toESM(require("node:path"));
3446
3446
  var import_client_common11 = require("@prisma/client-common");
3447
+ var import_debug = require("@prisma/debug");
3447
3448
  var import_ts_pattern = require("ts-pattern");
3449
+ var debug = (0, import_debug.Debug)("prisma:client-generator-ts:wasm");
3448
3450
  function buildDynamicRequireFn() {
3449
3451
  return `const dynamicRequireFn = async <const T extends string>(name: T) =>
3450
3452
  typeof globalThis.__non_webpack_require__ === 'function'
@@ -3463,20 +3465,43 @@ function buildGetWasmModule({
3463
3465
  moduleFormat
3464
3466
  }) {
3465
3467
  const capitalizedComponent = (0, import_client_common11.capitalize)(component);
3468
+ const extension = (0, import_ts_pattern.match)(moduleFormat).with("esm", () => "mjs").with("cjs", () => "js").exhaustive();
3469
+ const buildNonEdgeLoader = (0, import_ts_pattern.match)(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
3470
+ const buildNodeJsLoader = (0, import_ts_pattern.match)({ runtimeName, target }).with({ target: "nodejs" }, () => buildNonEdgeLoader).otherwise(() => false);
3466
3471
  const buildEdgeLoader = usesEdgeWasmRuntime(component, runtimeName);
3472
+ let wasmPathBase;
3467
3473
  let wasmBindingsPath;
3468
3474
  let wasmModulePath;
3469
3475
  if (buildEdgeLoader) {
3470
- const wasmPathBase = `./query_${component}_bg`;
3476
+ wasmPathBase = `./query_${component}_bg`;
3471
3477
  wasmBindingsPath = `${wasmPathBase}.js`;
3472
3478
  wasmModulePath = `${wasmPathBase}.wasm`;
3473
3479
  } else {
3474
- const wasmPathBase = `${runtimeBase}/query_${component}_bg.${activeProvider}`;
3480
+ wasmPathBase = `${runtimeBase}/query_${component}_bg.${activeProvider}`;
3475
3481
  wasmBindingsPath = `${wasmPathBase}.mjs`;
3476
3482
  wasmModulePath = `${wasmPathBase}.wasm`;
3477
3483
  }
3478
- const buildNodeLoader = (0, import_ts_pattern.match)(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
3479
- if (buildNodeLoader) {
3484
+ if (buildNodeJsLoader) {
3485
+ wasmBindingsPath = `${wasmPathBase}.${extension}`;
3486
+ wasmModulePath = `${wasmPathBase}.wasm-base64.mjs`;
3487
+ return `
3488
+ async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Module> {
3489
+ const { Buffer } = await import('node:buffer')
3490
+ const base64Data = wasmBase64.replace('data:application/wasm;base64,', '')
3491
+ const wasmArray = new Uint8Array(Buffer.from(base64Data, 'base64'))
3492
+ return new WebAssembly.Module(wasmArray)
3493
+ }
3494
+
3495
+ config.${component}Wasm = {
3496
+ getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3497
+
3498
+ getQuery${capitalizedComponent}WasmModule: async () => {
3499
+ const { wasm } = await import(${JSON.stringify(wasmModulePath)})
3500
+ return await decodeBase64AsWasm(wasm)
3501
+ }
3502
+ }`;
3503
+ }
3504
+ if (buildNonEdgeLoader) {
3480
3505
  return `config.${component}Wasm = {
3481
3506
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3482
3507
 
@@ -3514,10 +3539,25 @@ function buildRequire(moduleFormat) {
3514
3539
  const _require = createRequire(import.meta.url)
3515
3540
  `;
3516
3541
  }
3517
- function buildWasmFileMap({ runtimeName, activeProvider }) {
3542
+ function readSourceFile(sourceFile) {
3543
+ const bundledLocation = import_node_path.default.join(__dirname, sourceFile);
3544
+ const sourceLocation = import_node_path.default.join(__dirname, "..", "..", "..", "client", "runtime", sourceFile);
3545
+ if (import_node_fs.default.existsSync(bundledLocation)) {
3546
+ debug("We are in the bundled Prisma CLI");
3547
+ return import_node_fs.default.readFileSync(bundledLocation);
3548
+ } else if (import_node_fs.default.existsSync(sourceLocation)) {
3549
+ debug("We are in a dev/test environment");
3550
+ return import_node_fs.default.readFileSync(sourceLocation);
3551
+ } else {
3552
+ throw new Error(`Could not find ${sourceFile} in ${bundledLocation} or ${sourceLocation}`);
3553
+ }
3554
+ }
3555
+ function buildWasmFileMap({ activeProvider, runtimeName }) {
3518
3556
  const fileMap = {};
3557
+ debug("buildWasmFileMap with", { runtimeName });
3519
3558
  for (const component of ["engine", "compiler"]) {
3520
3559
  if (!usesEdgeWasmRuntime(component, runtimeName)) {
3560
+ debug("Skipping component", component, "for runtime", runtimeName);
3521
3561
  continue;
3522
3562
  }
3523
3563
  const fileNameBase = `query_${component}_bg.${activeProvider}`;
@@ -3526,15 +3566,7 @@ function buildWasmFileMap({ runtimeName, activeProvider }) {
3526
3566
  [`query_${component}_bg.js`]: `${fileNameBase}.mjs`
3527
3567
  };
3528
3568
  for (const [targetFile, sourceFile] of Object.entries(files)) {
3529
- const bundledLocation = import_node_path.default.join(__dirname, sourceFile);
3530
- const sourceLocation = import_node_path.default.join(__dirname, "..", "..", "..", "client", "runtime", sourceFile);
3531
- if (import_node_fs.default.existsSync(bundledLocation)) {
3532
- fileMap[targetFile] = import_node_fs.default.readFileSync(bundledLocation);
3533
- } else if (import_node_fs.default.existsSync(sourceLocation)) {
3534
- fileMap[targetFile] = import_node_fs.default.readFileSync(sourceLocation);
3535
- } else {
3536
- throw new Error(`Could not find ${sourceFile} in ${bundledLocation} or ${sourceLocation}`);
3537
- }
3569
+ fileMap[targetFile] = readSourceFile(sourceFile);
3538
3570
  }
3539
3571
  }
3540
3572
  return fileMap;
@@ -3571,8 +3603,8 @@ function optional(innerType) {
3571
3603
 
3572
3604
  // src/TSClient/PrismaClient.ts
3573
3605
  function extendsPropertyDefinition() {
3574
- const extendsDefinition = ts4.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts4.stringLiteral("extends")).addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("ClientOptions"))).addGenericArgument(ts4.namedType("ExtArgs")).addGenericArgument(
3575
- ts4.namedType("runtime.Types.Utils.Call").addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("ClientOptions"))).addGenericArgument(ts4.objectType().add(ts4.property("extArgs", ts4.namedType("ExtArgs"))))
3606
+ const extendsDefinition = ts4.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts4.stringLiteral("extends")).addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("OmitOpts"))).addGenericArgument(ts4.namedType("ExtArgs")).addGenericArgument(
3607
+ ts4.namedType("runtime.Types.Utils.Call").addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("OmitOpts"))).addGenericArgument(ts4.objectType().add(ts4.property("extArgs", ts4.namedType("ExtArgs"))))
3576
3608
  );
3577
3609
  return ts4.stringify(ts4.property("$extends", extendsDefinition), { indentLevel: 1 });
3578
3610
  }
@@ -3732,9 +3764,9 @@ function runCommandRawDefinition(context) {
3732
3764
  }
3733
3765
  function eventRegistrationMethodDeclaration(runtimeName) {
3734
3766
  if (runtimeName === "binary") {
3735
- 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;`;
3767
+ return `$on<V extends (LogOpts | 'beforeExit')>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : V extends 'beforeExit' ? () => runtime.Types.Utils.JsPromise<void> : Prisma.LogEvent) => void): PrismaClient;`;
3736
3768
  } else {
3737
- return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
3769
+ return `$on<V extends LogOpts>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
3738
3770
  }
3739
3771
  }
3740
3772
  function getPrismaClientClassDocComment({ dmmf }) {
@@ -3777,17 +3809,18 @@ var PrismaClientClass = class {
3777
3809
  export interface PrismaClientConstructor {
3778
3810
  ${(0, import_indent_string3.default)(this.jsDoc, TAB_SIZE)}
3779
3811
  new <
3780
- ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
3781
- const U = LogOptions<ClientOptions>,
3812
+ Options extends Prisma.PrismaClientOptions,
3813
+ LogOpts extends LogOptions<Options>,
3814
+ OmitOpts extends Prisma.PrismaClientOptions['omit'] = Options extends { omit: infer U } ? U : Prisma.PrismaClientOptions['omit'],
3782
3815
  ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3783
- >(options?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>): PrismaClient<ClientOptions, U, ExtArgs>
3816
+ >(options?: Prisma.Subset<Options, Prisma.PrismaClientOptions> ): PrismaClient<LogOpts, OmitOpts, ExtArgs>
3784
3817
  }
3785
3818
 
3786
3819
  ${this.jsDoc}
3787
3820
  export interface PrismaClient<
3788
- ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
3789
- U = LogOptions<ClientOptions>,
3790
- ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3821
+ in LogOpts extends Prisma.LogLevel = never,
3822
+ in out OmitOpts extends Prisma.PrismaClientOptions['omit'] = Prisma.PrismaClientOptions['omit'],
3823
+ in out ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3791
3824
  > {
3792
3825
  [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
3793
3826
 
@@ -3803,13 +3836,6 @@ export interface PrismaClient<
3803
3836
  */
3804
3837
  $disconnect(): runtime.Types.Utils.JsPromise<void>;
3805
3838
 
3806
- /**
3807
- * Add a middleware
3808
- * @deprecated since 4.16.0. For new code, prefer client extensions instead.
3809
- * @see https://pris.ly/d/extensions
3810
- */
3811
- $use(cb: Prisma.Middleware): void
3812
-
3813
3839
  ${[
3814
3840
  executeRawDefinition(this.context),
3815
3841
  queryRawDefinition(this.context),
@@ -3828,7 +3854,7 @@ ${[
3828
3854
  if (methodName === "constructor") {
3829
3855
  methodName = '["constructor"]';
3830
3856
  }
3831
- const generics = ["ExtArgs", "ClientOptions"];
3857
+ const generics = ["ExtArgs", "{ omit: OmitOpts }"];
3832
3858
  return `/**
3833
3859
  * \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
3834
3860
  * Example usage:
@@ -3999,11 +4025,11 @@ function createClientFile(context, options) {
3999
4025
  ts6.moduleExport(
4000
4026
  ts6.typeDeclaration(
4001
4027
  "PrismaClient",
4002
- ts6.namedType("$Class.PrismaClient").addGenericArgument(ts6.namedType("ClientOptions")).addGenericArgument(ts6.namedType("Log")).addGenericArgument(ts6.namedType("ExtArgs"))
4028
+ ts6.namedType("$Class.PrismaClient").addGenericArgument(ts6.namedType("LogOpts")).addGenericArgument(ts6.namedType("OmitOpts")).addGenericArgument(ts6.namedType("ExtArgs"))
4003
4029
  ).addGenericParameter(
4004
- ts6.genericParameter("ClientOptions").extends(ts6.namedType("Prisma.PrismaClientOptions")).default(ts6.namedType("Prisma.PrismaClientOptions"))
4030
+ ts6.genericParameter("LogOpts").extends(ts6.namedType("Prisma.LogLevel")).default(ts6.neverType)
4005
4031
  ).addGenericParameter(
4006
- ts6.genericParameter("Log").default(ts6.namedType("$Class.LogOptions").addGenericArgument(ts6.namedType("ClientOptions")))
4032
+ ts6.genericParameter("OmitOpts").extends(ts6.namedType("Prisma.PrismaClientOptions").subKey("omit")).default(ts6.namedType("Prisma.PrismaClientOptions").subKey("omit"))
4007
4033
  ).addGenericParameter(
4008
4034
  ts6.genericParameter("ExtArgs").extends(ts6.namedType("runtime.Types.Extensions.InternalArgs")).default(ts6.namedType("runtime.Types.Extensions.DefaultArgs"))
4009
4035
  )
@@ -5589,8 +5615,8 @@ var ts16 = __toESM(require("@prisma/ts-builders"));
5589
5615
  function clientTypeMapDefinition(context) {
5590
5616
  const typeMap = `${ts16.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
5591
5617
  return `
5592
- export interface TypeMapCb<ClientOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
5593
- returns: TypeMap<this['params']['extArgs'], ClientOptions extends { omit: infer OmitOptions } ? OmitOptions : {}>
5618
+ export interface TypeMapCb<GlobalOmitOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
5619
+ returns: TypeMap<this['params']['extArgs'], GlobalOmitOptions>
5594
5620
  }
5595
5621
 
5596
5622
  export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
@@ -5810,25 +5836,6 @@ export type PrismaAction =
5810
5836
  | 'findRaw'
5811
5837
  | 'groupBy'
5812
5838
 
5813
- /**
5814
- * These options are being passed into the middleware as "params"
5815
- */
5816
- export type MiddlewareParams = {
5817
- model?: ModelName
5818
- action: PrismaAction
5819
- args: any
5820
- dataPath: string[]
5821
- runInTransaction: boolean
5822
- }
5823
-
5824
- /**
5825
- * The \`T\` type makes sure, that the \`return proceed\` is not forgotten in the middleware implementation
5826
- */
5827
- export type Middleware<T = any> = (
5828
- params: MiddlewareParams,
5829
- next: (params: MiddlewareParams) => runtime.Types.Utils.JsPromise<T>,
5830
- ) => runtime.Types.Utils.JsPromise<T>
5831
-
5832
5839
  /**
5833
5840
  * \`PrismaClient\` proxy available in interactive transactions.
5834
5841
  */
@@ -6580,14 +6587,14 @@ async function deleteOutputDir(outputDir) {
6580
6587
  }
6581
6588
 
6582
6589
  // src/generator.ts
6583
- var import_debug = require("@prisma/debug");
6590
+ var import_debug2 = require("@prisma/debug");
6584
6591
  var import_engines_version = require("@prisma/engines-version");
6585
6592
  var import_internals10 = require("@prisma/internals");
6586
6593
  var import_get_tsconfig = require("get-tsconfig");
6587
6594
  var import_ts_pattern2 = require("ts-pattern");
6588
6595
 
6589
6596
  // package.json
6590
- var version = "6.14.0-dev.4";
6597
+ var version = "6.14.0-dev.40";
6591
6598
 
6592
6599
  // src/module-format.ts
6593
6600
  function parseModuleFormat(format) {
@@ -6664,7 +6671,7 @@ function parseRuntimeTargetFromUnknown(target) {
6664
6671
  }
6665
6672
 
6666
6673
  // src/generator.ts
6667
- var debug = (0, import_debug.Debug)("prisma:client:generator");
6674
+ var debug2 = (0, import_debug2.Debug)("prisma:client:generator");
6668
6675
  var missingOutputErrorMessage = `An output path is required for the \`prisma-client\` generator. Please provide an output path in your schema file:
6669
6676
 
6670
6677
  ${dim(`generator client {
@@ -6684,7 +6691,7 @@ var PrismaClientTsGenerator = class {
6684
6691
  name = "prisma-client-ts";
6685
6692
  getManifest(config) {
6686
6693
  const requiresEngines = (0, import_ts_pattern2.match)((0, import_internals10.getClientEngineType)(config)).with(import_internals10.ClientEngineType.Library, () => ["libqueryEngine"]).with(import_internals10.ClientEngineType.Binary, () => ["queryEngine"]).with(import_internals10.ClientEngineType.Client, () => []).exhaustive();
6687
- debug("requiresEngines", requiresEngines);
6694
+ debug2("requiresEngines", requiresEngines);
6688
6695
  return Promise.resolve({
6689
6696
  defaultOutput: getOutputPath(config),
6690
6697
  prettyName: "Prisma Client",
package/dist/index.mjs CHANGED
@@ -494,11 +494,11 @@ var require_graceful_fs = __commonJS({
494
494
  }
495
495
  });
496
496
  }
497
- var debug2 = noop;
497
+ var debug3 = noop;
498
498
  if (util.debuglog)
499
- debug2 = util.debuglog("gfs4");
499
+ debug3 = util.debuglog("gfs4");
500
500
  else if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || ""))
501
- debug2 = function() {
501
+ debug3 = function() {
502
502
  var m = util.format.apply(util, arguments);
503
503
  m = "GFS4: " + m.split(/\n/).join("\nGFS4: ");
504
504
  console.error(m);
@@ -533,7 +533,7 @@ var require_graceful_fs = __commonJS({
533
533
  }(fs3.closeSync);
534
534
  if (/\bgfs4\b/i.test(process.env.NODE_DEBUG || "")) {
535
535
  process.on("exit", function() {
536
- debug2(fs3[gracefulQueue]);
536
+ debug3(fs3[gracefulQueue]);
537
537
  __require("assert").equal(fs3[gracefulQueue].length, 0);
538
538
  });
539
539
  }
@@ -786,7 +786,7 @@ var require_graceful_fs = __commonJS({
786
786
  return fs4;
787
787
  }
788
788
  function enqueue(elem) {
789
- debug2("ENQUEUE", elem[0].name, elem[1]);
789
+ debug3("ENQUEUE", elem[0].name, elem[1]);
790
790
  fs3[gracefulQueue].push(elem);
791
791
  retry();
792
792
  }
@@ -813,10 +813,10 @@ var require_graceful_fs = __commonJS({
813
813
  var startTime = elem[3];
814
814
  var lastTime = elem[4];
815
815
  if (startTime === void 0) {
816
- debug2("RETRY", fn.name, args);
816
+ debug3("RETRY", fn.name, args);
817
817
  fn.apply(null, args);
818
818
  } else if (Date.now() - startTime >= 6e4) {
819
- debug2("TIMEOUT", fn.name, args);
819
+ debug3("TIMEOUT", fn.name, args);
820
820
  var cb = args.pop();
821
821
  if (typeof cb === "function")
822
822
  cb.call(null, err);
@@ -825,7 +825,7 @@ var require_graceful_fs = __commonJS({
825
825
  var sinceStart = Math.max(lastTime - startTime, 1);
826
826
  var desiredDelay = Math.min(sinceStart * 1.2, 100);
827
827
  if (sinceAttempt >= desiredDelay) {
828
- debug2("RETRY", fn.name, args);
828
+ debug3("RETRY", fn.name, args);
829
829
  fn.apply(null, args.concat([startTime]));
830
830
  } else {
831
831
  fs3[gracefulQueue].push(elem);
@@ -3443,7 +3443,9 @@ function buildInlineDatasource(ds) {
3443
3443
  import fs from "node:fs";
3444
3444
  import path from "node:path";
3445
3445
  import { capitalize as capitalize6 } from "@prisma/client-common";
3446
+ import { Debug } from "@prisma/debug";
3446
3447
  import { match } from "ts-pattern";
3448
+ var debug = Debug("prisma:client-generator-ts:wasm");
3447
3449
  function buildDynamicRequireFn() {
3448
3450
  return `const dynamicRequireFn = async <const T extends string>(name: T) =>
3449
3451
  typeof globalThis.__non_webpack_require__ === 'function'
@@ -3462,20 +3464,43 @@ function buildGetWasmModule({
3462
3464
  moduleFormat
3463
3465
  }) {
3464
3466
  const capitalizedComponent = capitalize6(component);
3467
+ const extension = match(moduleFormat).with("esm", () => "mjs").with("cjs", () => "js").exhaustive();
3468
+ const buildNonEdgeLoader = match(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
3469
+ const buildNodeJsLoader = match({ runtimeName, target }).with({ target: "nodejs" }, () => buildNonEdgeLoader).otherwise(() => false);
3465
3470
  const buildEdgeLoader = usesEdgeWasmRuntime(component, runtimeName);
3471
+ let wasmPathBase;
3466
3472
  let wasmBindingsPath;
3467
3473
  let wasmModulePath;
3468
3474
  if (buildEdgeLoader) {
3469
- const wasmPathBase = `./query_${component}_bg`;
3475
+ wasmPathBase = `./query_${component}_bg`;
3470
3476
  wasmBindingsPath = `${wasmPathBase}.js`;
3471
3477
  wasmModulePath = `${wasmPathBase}.wasm`;
3472
3478
  } else {
3473
- const wasmPathBase = `${runtimeBase}/query_${component}_bg.${activeProvider}`;
3479
+ wasmPathBase = `${runtimeBase}/query_${component}_bg.${activeProvider}`;
3474
3480
  wasmBindingsPath = `${wasmPathBase}.mjs`;
3475
3481
  wasmModulePath = `${wasmPathBase}.wasm`;
3476
3482
  }
3477
- const buildNodeLoader = match(runtimeName).with("library", () => component === "engine" && !!process.env.PRISMA_CLIENT_FORCE_WASM).with("client", () => component === "compiler").otherwise(() => false);
3478
- if (buildNodeLoader) {
3483
+ if (buildNodeJsLoader) {
3484
+ wasmBindingsPath = `${wasmPathBase}.${extension}`;
3485
+ wasmModulePath = `${wasmPathBase}.wasm-base64.mjs`;
3486
+ return `
3487
+ async function decodeBase64AsWasm(wasmBase64: string): Promise<WebAssembly.Module> {
3488
+ const { Buffer } = await import('node:buffer')
3489
+ const base64Data = wasmBase64.replace('data:application/wasm;base64,', '')
3490
+ const wasmArray = new Uint8Array(Buffer.from(base64Data, 'base64'))
3491
+ return new WebAssembly.Module(wasmArray)
3492
+ }
3493
+
3494
+ config.${component}Wasm = {
3495
+ getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3496
+
3497
+ getQuery${capitalizedComponent}WasmModule: async () => {
3498
+ const { wasm } = await import(${JSON.stringify(wasmModulePath)})
3499
+ return await decodeBase64AsWasm(wasm)
3500
+ }
3501
+ }`;
3502
+ }
3503
+ if (buildNonEdgeLoader) {
3479
3504
  return `config.${component}Wasm = {
3480
3505
  getRuntime: async () => await import(${JSON.stringify(wasmBindingsPath)}),
3481
3506
 
@@ -3513,10 +3538,25 @@ function buildRequire(moduleFormat) {
3513
3538
  const _require = createRequire(import.meta.url)
3514
3539
  `;
3515
3540
  }
3516
- function buildWasmFileMap({ runtimeName, activeProvider }) {
3541
+ function readSourceFile(sourceFile) {
3542
+ const bundledLocation = path.join(__dirname, sourceFile);
3543
+ const sourceLocation = path.join(__dirname, "..", "..", "..", "client", "runtime", sourceFile);
3544
+ if (fs.existsSync(bundledLocation)) {
3545
+ debug("We are in the bundled Prisma CLI");
3546
+ return fs.readFileSync(bundledLocation);
3547
+ } else if (fs.existsSync(sourceLocation)) {
3548
+ debug("We are in a dev/test environment");
3549
+ return fs.readFileSync(sourceLocation);
3550
+ } else {
3551
+ throw new Error(`Could not find ${sourceFile} in ${bundledLocation} or ${sourceLocation}`);
3552
+ }
3553
+ }
3554
+ function buildWasmFileMap({ activeProvider, runtimeName }) {
3517
3555
  const fileMap = {};
3556
+ debug("buildWasmFileMap with", { runtimeName });
3518
3557
  for (const component of ["engine", "compiler"]) {
3519
3558
  if (!usesEdgeWasmRuntime(component, runtimeName)) {
3559
+ debug("Skipping component", component, "for runtime", runtimeName);
3520
3560
  continue;
3521
3561
  }
3522
3562
  const fileNameBase = `query_${component}_bg.${activeProvider}`;
@@ -3525,15 +3565,7 @@ function buildWasmFileMap({ runtimeName, activeProvider }) {
3525
3565
  [`query_${component}_bg.js`]: `${fileNameBase}.mjs`
3526
3566
  };
3527
3567
  for (const [targetFile, sourceFile] of Object.entries(files)) {
3528
- const bundledLocation = path.join(__dirname, sourceFile);
3529
- const sourceLocation = path.join(__dirname, "..", "..", "..", "client", "runtime", sourceFile);
3530
- if (fs.existsSync(bundledLocation)) {
3531
- fileMap[targetFile] = fs.readFileSync(bundledLocation);
3532
- } else if (fs.existsSync(sourceLocation)) {
3533
- fileMap[targetFile] = fs.readFileSync(sourceLocation);
3534
- } else {
3535
- throw new Error(`Could not find ${sourceFile} in ${bundledLocation} or ${sourceLocation}`);
3536
- }
3568
+ fileMap[targetFile] = readSourceFile(sourceFile);
3537
3569
  }
3538
3570
  }
3539
3571
  return fileMap;
@@ -3570,8 +3602,8 @@ function optional(innerType) {
3570
3602
 
3571
3603
  // src/TSClient/PrismaClient.ts
3572
3604
  function extendsPropertyDefinition() {
3573
- const extendsDefinition = ts4.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts4.stringLiteral("extends")).addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("ClientOptions"))).addGenericArgument(ts4.namedType("ExtArgs")).addGenericArgument(
3574
- ts4.namedType("runtime.Types.Utils.Call").addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("ClientOptions"))).addGenericArgument(ts4.objectType().add(ts4.property("extArgs", ts4.namedType("ExtArgs"))))
3605
+ const extendsDefinition = ts4.namedType("runtime.Types.Extensions.ExtendsHook").addGenericArgument(ts4.stringLiteral("extends")).addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("OmitOpts"))).addGenericArgument(ts4.namedType("ExtArgs")).addGenericArgument(
3606
+ ts4.namedType("runtime.Types.Utils.Call").addGenericArgument(ts4.namedType("Prisma.TypeMapCb").addGenericArgument(ts4.namedType("OmitOpts"))).addGenericArgument(ts4.objectType().add(ts4.property("extArgs", ts4.namedType("ExtArgs"))))
3575
3607
  );
3576
3608
  return ts4.stringify(ts4.property("$extends", extendsDefinition), { indentLevel: 1 });
3577
3609
  }
@@ -3731,9 +3763,9 @@ function runCommandRawDefinition(context) {
3731
3763
  }
3732
3764
  function eventRegistrationMethodDeclaration(runtimeName) {
3733
3765
  if (runtimeName === "binary") {
3734
- 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;`;
3766
+ return `$on<V extends (LogOpts | 'beforeExit')>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : V extends 'beforeExit' ? () => runtime.Types.Utils.JsPromise<void> : Prisma.LogEvent) => void): PrismaClient;`;
3735
3767
  } else {
3736
- return `$on<V extends U>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
3768
+ return `$on<V extends LogOpts>(eventType: V, callback: (event: V extends 'query' ? Prisma.QueryEvent : Prisma.LogEvent) => void): PrismaClient;`;
3737
3769
  }
3738
3770
  }
3739
3771
  function getPrismaClientClassDocComment({ dmmf }) {
@@ -3776,17 +3808,18 @@ var PrismaClientClass = class {
3776
3808
  export interface PrismaClientConstructor {
3777
3809
  ${indent3(this.jsDoc, TAB_SIZE)}
3778
3810
  new <
3779
- ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
3780
- const U = LogOptions<ClientOptions>,
3811
+ Options extends Prisma.PrismaClientOptions,
3812
+ LogOpts extends LogOptions<Options>,
3813
+ OmitOpts extends Prisma.PrismaClientOptions['omit'] = Options extends { omit: infer U } ? U : Prisma.PrismaClientOptions['omit'],
3781
3814
  ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3782
- >(options?: Prisma.Subset<ClientOptions, Prisma.PrismaClientOptions>): PrismaClient<ClientOptions, U, ExtArgs>
3815
+ >(options?: Prisma.Subset<Options, Prisma.PrismaClientOptions> ): PrismaClient<LogOpts, OmitOpts, ExtArgs>
3783
3816
  }
3784
3817
 
3785
3818
  ${this.jsDoc}
3786
3819
  export interface PrismaClient<
3787
- ClientOptions extends Prisma.PrismaClientOptions = Prisma.PrismaClientOptions,
3788
- U = LogOptions<ClientOptions>,
3789
- ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3820
+ in LogOpts extends Prisma.LogLevel = never,
3821
+ in out OmitOpts extends Prisma.PrismaClientOptions['omit'] = Prisma.PrismaClientOptions['omit'],
3822
+ in out ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs
3790
3823
  > {
3791
3824
  [K: symbol]: { types: Prisma.TypeMap<ExtArgs>['other'] }
3792
3825
 
@@ -3802,13 +3835,6 @@ export interface PrismaClient<
3802
3835
  */
3803
3836
  $disconnect(): runtime.Types.Utils.JsPromise<void>;
3804
3837
 
3805
- /**
3806
- * Add a middleware
3807
- * @deprecated since 4.16.0. For new code, prefer client extensions instead.
3808
- * @see https://pris.ly/d/extensions
3809
- */
3810
- $use(cb: Prisma.Middleware): void
3811
-
3812
3838
  ${[
3813
3839
  executeRawDefinition(this.context),
3814
3840
  queryRawDefinition(this.context),
@@ -3827,7 +3853,7 @@ ${[
3827
3853
  if (methodName === "constructor") {
3828
3854
  methodName = '["constructor"]';
3829
3855
  }
3830
- const generics = ["ExtArgs", "ClientOptions"];
3856
+ const generics = ["ExtArgs", "{ omit: OmitOpts }"];
3831
3857
  return `/**
3832
3858
  * \`prisma.${methodName}\`: Exposes CRUD operations for the **${m.model}** model.
3833
3859
  * Example usage:
@@ -3998,11 +4024,11 @@ function createClientFile(context, options) {
3998
4024
  ts6.moduleExport(
3999
4025
  ts6.typeDeclaration(
4000
4026
  "PrismaClient",
4001
- ts6.namedType("$Class.PrismaClient").addGenericArgument(ts6.namedType("ClientOptions")).addGenericArgument(ts6.namedType("Log")).addGenericArgument(ts6.namedType("ExtArgs"))
4027
+ ts6.namedType("$Class.PrismaClient").addGenericArgument(ts6.namedType("LogOpts")).addGenericArgument(ts6.namedType("OmitOpts")).addGenericArgument(ts6.namedType("ExtArgs"))
4002
4028
  ).addGenericParameter(
4003
- ts6.genericParameter("ClientOptions").extends(ts6.namedType("Prisma.PrismaClientOptions")).default(ts6.namedType("Prisma.PrismaClientOptions"))
4029
+ ts6.genericParameter("LogOpts").extends(ts6.namedType("Prisma.LogLevel")).default(ts6.neverType)
4004
4030
  ).addGenericParameter(
4005
- ts6.genericParameter("Log").default(ts6.namedType("$Class.LogOptions").addGenericArgument(ts6.namedType("ClientOptions")))
4031
+ ts6.genericParameter("OmitOpts").extends(ts6.namedType("Prisma.PrismaClientOptions").subKey("omit")).default(ts6.namedType("Prisma.PrismaClientOptions").subKey("omit"))
4006
4032
  ).addGenericParameter(
4007
4033
  ts6.genericParameter("ExtArgs").extends(ts6.namedType("runtime.Types.Extensions.InternalArgs")).default(ts6.namedType("runtime.Types.Extensions.DefaultArgs"))
4008
4034
  )
@@ -5588,8 +5614,8 @@ import * as ts16 from "@prisma/ts-builders";
5588
5614
  function clientTypeMapDefinition(context) {
5589
5615
  const typeMap = `${ts16.stringify(clientTypeMapModelsDefinition(context))} & ${clientTypeMapOthersDefinition(context)}`;
5590
5616
  return `
5591
- export interface TypeMapCb<ClientOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
5592
- returns: TypeMap<this['params']['extArgs'], ClientOptions extends { omit: infer OmitOptions } ? OmitOptions : {}>
5617
+ export interface TypeMapCb<GlobalOmitOptions = {}> extends runtime.Types.Utils.Fn<{extArgs: runtime.Types.Extensions.InternalArgs }, runtime.Types.Utils.Record<string, any>> {
5618
+ returns: TypeMap<this['params']['extArgs'], GlobalOmitOptions>
5593
5619
  }
5594
5620
 
5595
5621
  export type TypeMap<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> = ${typeMap}`;
@@ -5809,25 +5835,6 @@ export type PrismaAction =
5809
5835
  | 'findRaw'
5810
5836
  | 'groupBy'
5811
5837
 
5812
- /**
5813
- * These options are being passed into the middleware as "params"
5814
- */
5815
- export type MiddlewareParams = {
5816
- model?: ModelName
5817
- action: PrismaAction
5818
- args: any
5819
- dataPath: string[]
5820
- runInTransaction: boolean
5821
- }
5822
-
5823
- /**
5824
- * The \`T\` type makes sure, that the \`return proceed\` is not forgotten in the middleware implementation
5825
- */
5826
- export type Middleware<T = any> = (
5827
- params: MiddlewareParams,
5828
- next: (params: MiddlewareParams) => runtime.Types.Utils.JsPromise<T>,
5829
- ) => runtime.Types.Utils.JsPromise<T>
5830
-
5831
5838
  /**
5832
5839
  * \`PrismaClient\` proxy available in interactive transactions.
5833
5840
  */
@@ -6579,14 +6586,14 @@ async function deleteOutputDir(outputDir) {
6579
6586
  }
6580
6587
 
6581
6588
  // src/generator.ts
6582
- import { Debug } from "@prisma/debug";
6589
+ import { Debug as Debug2 } from "@prisma/debug";
6583
6590
  import { enginesVersion } from "@prisma/engines-version";
6584
6591
  import { ClientEngineType as ClientEngineType4, getClientEngineType as getClientEngineType4, parseEnvValue } from "@prisma/internals";
6585
6592
  import { getTsconfig } from "get-tsconfig";
6586
6593
  import { match as match2 } from "ts-pattern";
6587
6594
 
6588
6595
  // package.json
6589
- var version = "6.14.0-dev.4";
6596
+ var version = "6.14.0-dev.40";
6590
6597
 
6591
6598
  // src/module-format.ts
6592
6599
  function parseModuleFormat(format) {
@@ -6663,7 +6670,7 @@ function parseRuntimeTargetFromUnknown(target) {
6663
6670
  }
6664
6671
 
6665
6672
  // src/generator.ts
6666
- var debug = Debug("prisma:client:generator");
6673
+ var debug2 = Debug2("prisma:client:generator");
6667
6674
  var missingOutputErrorMessage = `An output path is required for the \`prisma-client\` generator. Please provide an output path in your schema file:
6668
6675
 
6669
6676
  ${dim(`generator client {
@@ -6683,7 +6690,7 @@ var PrismaClientTsGenerator = class {
6683
6690
  name = "prisma-client-ts";
6684
6691
  getManifest(config) {
6685
6692
  const requiresEngines = match2(getClientEngineType4(config)).with(ClientEngineType4.Library, () => ["libqueryEngine"]).with(ClientEngineType4.Binary, () => ["queryEngine"]).with(ClientEngineType4.Client, () => []).exhaustive();
6686
- debug("requiresEngines", requiresEngines);
6693
+ debug2("requiresEngines", requiresEngines);
6687
6694
  return Promise.resolve({
6688
6695
  defaultOutput: getOutputPath(config),
6689
6696
  prettyName: "Prisma Client",
@@ -13,7 +13,7 @@ export type BuildWasmModuleOptions = {
13
13
  };
14
14
  export declare function buildGetWasmModule({ component, runtimeName, runtimeBase, target, activeProvider, moduleFormat, }: BuildWasmModuleOptions): string;
15
15
  export type BuildWasmFileMapOptions = {
16
- runtimeName: RuntimeName;
17
16
  activeProvider: ActiveConnectorType;
17
+ runtimeName: RuntimeName;
18
18
  };
19
- export declare function buildWasmFileMap({ runtimeName, activeProvider }: BuildWasmFileMapOptions): FileMap;
19
+ export declare function buildWasmFileMap({ activeProvider, runtimeName }: BuildWasmFileMapOptions): FileMap;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prisma/client-generator-ts",
3
- "version": "6.14.0-dev.4",
3
+ "version": "6.14.0-dev.40",
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-1.b2e5a6c3a6936784f3aefb57ce847e4e7d28986a",
28
+ "@prisma/engines-version": "6.14.0-22.0b03dd192b3c1459e1142ba36decb4194ca1d826",
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.14.0-dev.4",
38
- "@prisma/debug": "6.14.0-dev.4",
39
- "@prisma/dmmf": "6.14.0-dev.4",
40
- "@prisma/fetch-engine": "6.14.0-dev.4",
41
- "@prisma/generator": "6.14.0-dev.4",
42
- "@prisma/get-platform": "6.14.0-dev.4",
43
- "@prisma/internals": "6.14.0-dev.4",
44
- "@prisma/ts-builders": "6.14.0-dev.4"
37
+ "@prisma/debug": "6.14.0-dev.40",
38
+ "@prisma/fetch-engine": "6.14.0-dev.40",
39
+ "@prisma/dmmf": "6.14.0-dev.40",
40
+ "@prisma/client-common": "6.14.0-dev.40",
41
+ "@prisma/generator": "6.14.0-dev.40",
42
+ "@prisma/get-platform": "6.14.0-dev.40",
43
+ "@prisma/internals": "6.14.0-dev.40",
44
+ "@prisma/ts-builders": "6.14.0-dev.40"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/pluralize": "0.0.33",