@zenstackhq/orm 3.8.0-beta.3 → 3.8.0

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
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
2
2
  import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "./common-types.mjs";
3
3
  import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
4
4
  import { AliasNode, AndNode, ColumnNode, ColumnUpdateNode, CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor, DeleteQueryNode, ExpressionWrapper, FromNode, IdentifierNode, InsertQueryNode, Kysely, Log, OperationNodeTransformer, OperationNodeVisitor, PrimitiveValueListNode, ReferenceNode, ReturningNode, SelectAllNode, SelectionNode, SingleConnectionProvider, TableNode, Transaction, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode, WhereNode, createQueryId, expressionBuilder, sql } from "kysely";
5
- import z$1, { ZodObject, ZodType, z } from "zod";
5
+ import z, { ZodObject, ZodType, z as z$1 } from "zod";
6
6
  import { fromError } from "zod-validation-error/v4";
7
7
  import { P, match } from "ts-pattern";
8
8
  import { ExpressionUtils } from "@zenstackhq/schema";
@@ -1437,7 +1437,10 @@ var LateralJoinDialectBase = class extends BaseCrudDialect {
1437
1437
  return { [field]: fieldValue };
1438
1438
  }
1439
1439
  }));
1440
- if (typeof payload === "object" && payload.include && typeof payload.include === "object") Object.assign(objArgs, ...Object.entries(payload.include).filter(([, value]) => value).map(([field]) => ({ [field]: eb.ref(`${parentResultName}$${field}.$data`) })));
1440
+ if (typeof payload === "object" && payload.include && typeof payload.include === "object") Object.assign(objArgs, ...Object.entries(payload.include).filter(([, value]) => value).map(([field, value]) => {
1441
+ if (field === "_count") return { [field]: this.buildCountJson(relationModel, eb, relationModelAlias, value) };
1442
+ return { [field]: eb.ref(`${parentResultName}$${field}.$data`) };
1443
+ }));
1441
1444
  return objArgs;
1442
1445
  }
1443
1446
  buildRelationJoins(query, relationModel, relationModelAlias, payload, parentResultName) {
@@ -2112,6 +2115,10 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
2112
2115
  } else return [sql.lit(field), this.fieldRef(relationModel, field, subQueryName, false)];
2113
2116
  }).flatMap((v) => v));
2114
2117
  if (typeof payload === "object" && payload.include && typeof payload.include === "object") objArgs.push(...Object.entries(payload.include).filter(([, value]) => value).map(([field, value]) => {
2118
+ if (field === "_count") {
2119
+ const subJson = this.buildCountJson(relationModel, eb, tmpAlias(`${parentAlias}$${relationField}`), value);
2120
+ return [sql.lit(field), subJson];
2121
+ }
2115
2122
  const subJson = this.buildRelationJSON(relationModel, eb, field, tmpAlias(`${parentAlias}$${relationField}`), value);
2116
2123
  return [sql.lit(field), subJson];
2117
2124
  }).flatMap((v) => v));
@@ -2287,7 +2294,7 @@ function createQuerySchemaFactory(clientOrSchema, options) {
2287
2294
  * @see https://github.com/zenstackhq/zenstack/issues/2631
2288
2295
  */
2289
2296
  function coercedDateTimeSchema() {
2290
- return z.preprocess((val) => {
2297
+ return z$1.preprocess((val) => {
2291
2298
  if (typeof val !== "string") return val;
2292
2299
  if (/^\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d\d(?::\d\d)?)?$/.test(val)) {
2293
2300
  const hasTz = val.endsWith("Z") || /[+-]\d\d(?::\d\d)?$/.test(val);
@@ -2296,10 +2303,10 @@ function coercedDateTimeSchema() {
2296
2303
  }
2297
2304
  const d = new Date(val);
2298
2305
  return isNaN(d.getTime()) ? val : d;
2299
- }, z.union([
2300
- z.iso.datetime(),
2301
- z.iso.date(),
2302
- z.date()
2306
+ }, z$1.union([
2307
+ z$1.iso.datetime(),
2308
+ z$1.iso.date(),
2309
+ z$1.date()
2303
2310
  ]));
2304
2311
  }
2305
2312
  /**
@@ -2307,7 +2314,7 @@ function coercedDateTimeSchema() {
2307
2314
  */
2308
2315
  var ZodSchemaFactory = class {
2309
2316
  schemaCache = /* @__PURE__ */ new Map();
2310
- schemaRegistry = z.registry();
2317
+ schemaRegistry = z$1.registry();
2311
2318
  allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
2312
2319
  schema;
2313
2320
  options;
@@ -2399,7 +2406,7 @@ var ZodSchemaFactory = class {
2399
2406
  this.makeGroupBySchema(m);
2400
2407
  }
2401
2408
  for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
2402
- return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
2409
+ return z$1.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
2403
2410
  }
2404
2411
  get cacheStats() {
2405
2412
  return {
@@ -2428,13 +2435,13 @@ var ZodSchemaFactory = class {
2428
2435
  fields["omit"] = this.makeOmitSchema(model).optional().nullable();
2429
2436
  if (!unique) {
2430
2437
  fields["skip"] = this.makeSkipSchema().optional();
2431
- if (findOne) fields["take"] = z.literal(1).optional();
2438
+ if (findOne) fields["take"] = z$1.literal(1).optional();
2432
2439
  else fields["take"] = this.makeTakeSchema().optional();
2433
2440
  fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
2434
2441
  fields["cursor"] = this.makeCursorSchema(model, options).optional();
2435
2442
  fields["distinct"] = this.makeDistinctSchema(model).optional();
2436
2443
  }
2437
- const baseSchema = z.strictObject(fields);
2444
+ const baseSchema = z$1.strictObject(fields);
2438
2445
  let result = this.mergePluginArgsSchema(baseSchema, operation);
2439
2446
  result = this.refineForSelectIncludeMutuallyExclusive(result);
2440
2447
  result = this.refineForSelectOmitMutuallyExclusive(result);
@@ -2444,7 +2451,7 @@ var ZodSchemaFactory = class {
2444
2451
  return result;
2445
2452
  }
2446
2453
  makeExistsSchema(model, options) {
2447
- const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
2454
+ const baseSchema = z$1.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
2448
2455
  const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
2449
2456
  this.registerSchema(`${model}ExistsArgs`, result);
2450
2457
  return result;
@@ -2452,31 +2459,31 @@ var ZodSchemaFactory = class {
2452
2459
  makeScalarSchema(type, attributes) {
2453
2460
  if (this.schema.typeDefs && type in this.schema.typeDefs) return this.makeTypeDefSchema(type);
2454
2461
  else if (this.schema.enums && type in this.schema.enums) return this.makeEnumSchema(type);
2455
- else return match(type).with("String", () => this.extraValidationsEnabled ? ZodUtils.addStringValidation(z.string(), attributes) : z.string()).with("Int", () => this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number().int(), attributes) : z.number().int()).with("Float", () => this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number()).with("Boolean", () => z.boolean()).with("BigInt", () => z.union([this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number().int(), attributes) : z.number().int(), this.extraValidationsEnabled ? ZodUtils.addBigIntValidation(z.bigint(), attributes) : z.bigint()])).with("Decimal", () => {
2456
- return z.union([
2457
- this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number(),
2458
- ZodUtils.addDecimalValidation(z.instanceof(Decimal), attributes, this.extraValidationsEnabled),
2459
- ZodUtils.addDecimalValidation(z.string(), attributes, this.extraValidationsEnabled)
2462
+ else return match(type).with("String", () => this.extraValidationsEnabled ? ZodUtils.addStringValidation(z$1.string(), attributes) : z$1.string()).with("Int", () => this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number().int(), attributes) : z$1.number().int()).with("Float", () => this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number(), attributes) : z$1.number()).with("Boolean", () => z$1.boolean()).with("BigInt", () => z$1.union([this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number().int(), attributes) : z$1.number().int(), this.extraValidationsEnabled ? ZodUtils.addBigIntValidation(z$1.bigint(), attributes) : z$1.bigint()])).with("Decimal", () => {
2463
+ return z$1.union([
2464
+ this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number(), attributes) : z$1.number(),
2465
+ ZodUtils.addDecimalValidation(z$1.instanceof(Decimal), attributes, this.extraValidationsEnabled),
2466
+ ZodUtils.addDecimalValidation(z$1.string(), attributes, this.extraValidationsEnabled)
2460
2467
  ]);
2461
- }).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
2468
+ }).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z$1.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z$1.unknown());
2462
2469
  }
2463
2470
  makeEnumSchema(_enum) {
2464
2471
  const enumDef = getEnum(this.schema, _enum);
2465
2472
  invariant(enumDef, `Enum "${_enum}" not found in schema`);
2466
- const schema = z.enum(Object.keys(enumDef.values));
2473
+ const schema = z$1.enum(Object.keys(enumDef.values));
2467
2474
  this.registerSchema(_enum, schema);
2468
2475
  return schema;
2469
2476
  }
2470
2477
  makeTypeDefSchema(type) {
2471
2478
  const typeDef = getTypeDef(this.schema, type);
2472
2479
  invariant(typeDef, `Type definition "${type}" not found in schema`);
2473
- const schema = z.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
2474
- let fieldSchema = isTypeDef(this.schema, def.type) ? z.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type);
2480
+ const schema = z$1.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
2481
+ let fieldSchema = isTypeDef(this.schema, def.type) ? z$1.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type);
2475
2482
  if (def.array) fieldSchema = fieldSchema.array();
2476
2483
  if (def.optional) fieldSchema = fieldSchema.nullish();
2477
2484
  return [field, fieldSchema];
2478
2485
  })));
2479
- const finalSchema = z.any().superRefine((value, ctx) => {
2486
+ const finalSchema = z$1.any().superRefine((value, ctx) => {
2480
2487
  const parseResult = schema.safeParse(value);
2481
2488
  if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
2482
2489
  });
@@ -2492,17 +2499,17 @@ var ZodSchemaFactory = class {
2492
2499
  if (fieldDef.relation) {
2493
2500
  if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
2494
2501
  const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
2495
- if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
2502
+ if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z$1.never();
2496
2503
  else {
2497
- fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
2498
- if (fieldDef.array) fieldSchema = z.strictObject({
2504
+ fieldSchema = z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
2505
+ if (fieldDef.array) fieldSchema = z$1.strictObject({
2499
2506
  some: fieldSchema.optional(),
2500
2507
  every: fieldSchema.optional(),
2501
2508
  none: fieldSchema.optional()
2502
2509
  });
2503
2510
  else {
2504
2511
  fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
2505
- fieldSchema = z.union([fieldSchema, z.strictObject({
2512
+ fieldSchema = z$1.union([fieldSchema, z$1.strictObject({
2506
2513
  is: fieldSchema.optional(),
2507
2514
  isNot: fieldSchema.optional()
2508
2515
  })]);
@@ -2521,21 +2528,21 @@ var ZodSchemaFactory = class {
2521
2528
  }
2522
2529
  if (unique) {
2523
2530
  const uniqueFields = getUniqueFields(this.schema, model);
2524
- for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
2531
+ for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z$1.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
2525
2532
  invariant(!def.relation, "unique field cannot be a relation");
2526
2533
  let fieldSchema;
2527
2534
  const enumDef = getEnum(this.schema, def.type);
2528
2535
  if (enumDef) if (Object.keys(enumDef.values).length > 0) fieldSchema = this.makeEnumFilterSchema(def.type, !!def.optional, !!def.array, false, void 0);
2529
- else fieldSchema = z.never();
2536
+ else fieldSchema = z$1.never();
2530
2537
  else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
2531
2538
  return [key, fieldSchema];
2532
2539
  }))).optional();
2533
2540
  }
2534
- fields["$expr"] = z.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
2535
- fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2536
- fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
2537
- fields["NOT"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2538
- const baseWhere = z.strictObject(fields);
2541
+ fields["$expr"] = z$1.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
2542
+ fields["AND"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2543
+ fields["OR"] = z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
2544
+ fields["NOT"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2545
+ const baseWhere = z$1.strictObject(fields);
2539
2546
  let result = baseWhere;
2540
2547
  if (unique) {
2541
2548
  const uniqueFields = getUniqueFields(this.schema, model);
@@ -2561,26 +2568,26 @@ var ZodSchemaFactory = class {
2561
2568
  else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
2562
2569
  else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
2563
2570
  else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(fieldDef.type, !!fieldDef.optional, false, void 0).optional();
2564
- candidates.push(z.strictObject(fieldSchemas));
2571
+ candidates.push(z$1.strictObject(fieldSchemas));
2565
2572
  }
2566
- const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
2567
- if (array) candidates.push(z.strictObject({
2573
+ const recursiveSchema = z$1.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
2574
+ if (array) candidates.push(z$1.strictObject({
2568
2575
  some: recursiveSchema,
2569
2576
  every: recursiveSchema,
2570
2577
  none: recursiveSchema
2571
2578
  }));
2572
- else candidates.push(z.strictObject({
2579
+ else candidates.push(z$1.strictObject({
2573
2580
  is: recursiveSchema,
2574
2581
  isNot: recursiveSchema
2575
2582
  }));
2576
2583
  candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
2577
2584
  if (optional) {
2578
- candidates.push(z.null());
2579
- candidates.push(z.instanceof(DbNullClass));
2580
- candidates.push(z.instanceof(JsonNullClass));
2581
- candidates.push(z.instanceof(AnyNullClass));
2585
+ candidates.push(z$1.null());
2586
+ candidates.push(z$1.instanceof(DbNullClass));
2587
+ candidates.push(z$1.instanceof(JsonNullClass));
2588
+ candidates.push(z$1.instanceof(AnyNullClass));
2582
2589
  }
2583
- const result = z.union(candidates);
2590
+ const result = z$1.union(candidates);
2584
2591
  this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
2585
2592
  optional,
2586
2593
  array,
@@ -2589,7 +2596,7 @@ var ZodSchemaFactory = class {
2589
2596
  return result;
2590
2597
  }
2591
2598
  makeNullableTypedJsonMutationSchema(fieldSchema) {
2592
- return z.any().superRefine((value, ctx) => {
2599
+ return z$1.any().superRefine((value, ctx) => {
2593
2600
  if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
2594
2601
  const parseResult = fieldSchema.safeParse(value);
2595
2602
  if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
@@ -2601,11 +2608,11 @@ var ZodSchemaFactory = class {
2601
2608
  makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
2602
2609
  const enumDef = getEnum(this.schema, enumName);
2603
2610
  invariant(enumDef, `Enum "${enumName}" not found in schema`);
2604
- const baseSchema = z.enum(Object.keys(enumDef.values));
2611
+ const baseSchema = z$1.enum(Object.keys(enumDef.values));
2605
2612
  let schema;
2606
2613
  if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
2607
2614
  else {
2608
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
2615
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
2609
2616
  "equals",
2610
2617
  "in",
2611
2618
  "notIn",
@@ -2639,42 +2646,42 @@ var ZodSchemaFactory = class {
2639
2646
  has: elementSchema.optional(),
2640
2647
  hasEvery: elementSchema.array().optional(),
2641
2648
  hasSome: elementSchema.array().optional(),
2642
- isEmpty: z.boolean().optional()
2649
+ isEmpty: z$1.boolean().optional()
2643
2650
  };
2644
2651
  const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
2645
- return z.strictObject(filteredOperators);
2652
+ return z$1.strictObject(filteredOperators);
2646
2653
  }
2647
2654
  makePrimitiveFilterSchema(type, optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
2648
- return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)).with(P.union("Int", "Float", "Decimal", "BigInt"), (type) => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(optional, allowedFilterKinds)).with("Unsupported", () => z.never()).exhaustive();
2655
+ return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)).with(P.union("Int", "Float", "Decimal", "BigInt"), (type) => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(optional, allowedFilterKinds)).with("Unsupported", () => z$1.never()).exhaustive();
2649
2656
  }
2650
2657
  makeJsonValueSchema() {
2651
- const schema = z.union([
2652
- z.string(),
2653
- z.number(),
2654
- z.boolean(),
2655
- z.instanceof(JsonNullClass),
2656
- z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()]).array()),
2657
- z.record(z.string(), z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()])))
2658
+ const schema = z$1.union([
2659
+ z$1.string(),
2660
+ z$1.number(),
2661
+ z$1.boolean(),
2662
+ z$1.instanceof(JsonNullClass),
2663
+ z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()]).array()),
2664
+ z$1.record(z$1.string(), z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()])))
2658
2665
  ]);
2659
2666
  this.registerSchema("JsonValue", schema);
2660
2667
  return schema;
2661
2668
  }
2662
2669
  makeJsonFilterSchema(optional, allowedFilterKinds) {
2663
- if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
2670
+ if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z$1.never();
2664
2671
  const filterMembers = [
2665
2672
  this.makeJsonValueSchema(),
2666
- z.instanceof(DbNullClass),
2667
- z.instanceof(AnyNullClass)
2673
+ z$1.instanceof(DbNullClass),
2674
+ z$1.instanceof(AnyNullClass)
2668
2675
  ];
2669
- if (optional) filterMembers.push(z.null());
2670
- const filterValueSchema = z.union(filterMembers);
2671
- const schema = z.strictObject({
2672
- path: z.string().optional(),
2676
+ if (optional) filterMembers.push(z$1.null());
2677
+ const filterValueSchema = z$1.union(filterMembers);
2678
+ const schema = z$1.strictObject({
2679
+ path: z$1.string().optional(),
2673
2680
  equals: filterValueSchema.optional(),
2674
2681
  not: filterValueSchema.optional(),
2675
- string_contains: z.string().optional(),
2676
- string_starts_with: z.string().optional(),
2677
- string_ends_with: z.string().optional(),
2682
+ string_contains: z$1.string().optional(),
2683
+ string_starts_with: z$1.string().optional(),
2684
+ string_ends_with: z$1.string().optional(),
2678
2685
  mode: this.makeStringModeSchema().optional(),
2679
2686
  array_contains: filterValueSchema.optional(),
2680
2687
  array_starts_with: filterValueSchema.optional(),
@@ -2693,7 +2700,7 @@ var ZodSchemaFactory = class {
2693
2700
  }
2694
2701
  makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
2695
2702
  const filterValueSchema = this.makeDateTimeValueSchema();
2696
- const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2703
+ const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z$1.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2697
2704
  "_count",
2698
2705
  "_min",
2699
2706
  "_max"
@@ -2706,12 +2713,12 @@ var ZodSchemaFactory = class {
2706
2713
  return schema;
2707
2714
  }
2708
2715
  makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
2709
- const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
2716
+ const components = this.makeCommonPrimitiveFilterComponents(z$1.boolean(), optional, () => z$1.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
2710
2717
  "_count",
2711
2718
  "_min",
2712
2719
  "_max"
2713
2720
  ] : void 0, allowedFilterKinds);
2714
- const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
2721
+ const schema = this.createUnionFilterSchema(z$1.boolean(), optional, components, allowedFilterKinds);
2715
2722
  this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
2716
2723
  optional,
2717
2724
  allowedFilterKinds,
@@ -2720,8 +2727,8 @@ var ZodSchemaFactory = class {
2720
2727
  return schema;
2721
2728
  }
2722
2729
  makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
2723
- const baseSchema = z.instanceof(Uint8Array);
2724
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
2730
+ const baseSchema = z$1.instanceof(Uint8Array);
2731
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.instanceof(Uint8Array), [
2725
2732
  "equals",
2726
2733
  "in",
2727
2734
  "notIn",
@@ -2769,7 +2776,7 @@ var ZodSchemaFactory = class {
2769
2776
  return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
2770
2777
  }
2771
2778
  makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
2772
- const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2779
+ const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z$1.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2773
2780
  "_count",
2774
2781
  "_avg",
2775
2782
  "_sum",
@@ -2784,15 +2791,15 @@ var ZodSchemaFactory = class {
2784
2791
  return schema;
2785
2792
  }
2786
2793
  makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
2787
- const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
2794
+ const baseComponents = this.makeCommonPrimitiveFilterComponents(z$1.string(), optional, () => z$1.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
2788
2795
  "_count",
2789
2796
  "_min",
2790
2797
  "_max"
2791
2798
  ] : void 0, allowedFilterKinds);
2792
2799
  const stringSpecificOperators = {
2793
- startsWith: z.string().optional(),
2794
- endsWith: z.string().optional(),
2795
- contains: z.string().optional(),
2800
+ startsWith: z$1.string().optional(),
2801
+ endsWith: z$1.string().optional(),
2802
+ contains: z$1.string().optional(),
2796
2803
  ...withFuzzy && this.providerSupportsFuzzySearch ? { fuzzy: this.makeFuzzyFilterSchema().optional() } : {},
2797
2804
  ...withFullText && this.providerSupportsFullTextSearch ? { fts: this.makeFullTextFilterSchema().optional() } : {},
2798
2805
  ...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
@@ -2802,7 +2809,7 @@ var ZodSchemaFactory = class {
2802
2809
  ...baseComponents,
2803
2810
  ...filteredStringOperators
2804
2811
  };
2805
- const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
2812
+ const schema = this.createUnionFilterSchema(z$1.string(), optional, allComponents, allowedFilterKinds);
2806
2813
  const featureSuffix = `${withFuzzy ? "Fuzzy" : ""}${withFullText ? "FullText" : ""}`;
2807
2814
  this.registerSchema(`StringFilter${this.filterSchemaSuffix({
2808
2815
  optional,
@@ -2812,24 +2819,24 @@ var ZodSchemaFactory = class {
2812
2819
  return schema;
2813
2820
  }
2814
2821
  makeStringModeSchema() {
2815
- return z.union([z.literal("default"), z.literal("insensitive")]);
2822
+ return z$1.union([z$1.literal("default"), z$1.literal("insensitive")]);
2816
2823
  }
2817
2824
  makeFuzzyFilterSchema() {
2818
- return z.strictObject({
2819
- search: z.string().min(1),
2820
- mode: z.union([
2821
- z.literal("simple"),
2822
- z.literal("word"),
2823
- z.literal("strictWord")
2825
+ return z$1.strictObject({
2826
+ search: z$1.string().min(1),
2827
+ mode: z$1.union([
2828
+ z$1.literal("simple"),
2829
+ z$1.literal("word"),
2830
+ z$1.literal("strictWord")
2824
2831
  ]).default("simple"),
2825
- threshold: z.number().min(0).max(1).optional(),
2826
- unaccent: z.boolean().default(false)
2832
+ threshold: z$1.number().min(0).max(1).optional(),
2833
+ unaccent: z$1.boolean().default(false)
2827
2834
  });
2828
2835
  }
2829
2836
  makeFullTextFilterSchema() {
2830
- return z.strictObject({
2831
- search: z.string().min(1),
2832
- config: z.string().min(1).optional()
2837
+ return z$1.strictObject({
2838
+ search: z$1.string().min(1),
2839
+ config: z$1.string().min(1).optional()
2833
2840
  });
2834
2841
  }
2835
2842
  makeSelectSchema(model, options) {
@@ -2837,14 +2844,14 @@ var ZodSchemaFactory = class {
2837
2844
  for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
2838
2845
  if (!this.shouldIncludeRelations(options)) continue;
2839
2846
  if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
2840
- } else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z.literal(false).optional();
2841
- else fields[field] = z.boolean().optional();
2847
+ } else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z$1.literal(false).optional();
2848
+ else fields[field] = z$1.boolean().optional();
2842
2849
  if (this.shouldIncludeRelations(options)) {
2843
2850
  const _countSchema = this.makeCountSelectionSchema(model, options);
2844
- if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
2851
+ if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
2845
2852
  }
2846
2853
  this.addExtResultFields(model, fields);
2847
- const result = z.strictObject(fields);
2854
+ const result = z$1.strictObject(fields);
2848
2855
  this.registerSchema(`${model}Select`, result);
2849
2856
  return result;
2850
2857
  }
@@ -2853,24 +2860,24 @@ var ZodSchemaFactory = class {
2853
2860
  const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
2854
2861
  if (toManyRelations.length > 0) {
2855
2862
  const nextOpts = this.nextOptions(options);
2856
- const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
2863
+ const schema = z$1.union([z$1.literal(true), z$1.strictObject({ select: z$1.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
2857
2864
  ...acc,
2858
- [fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
2865
+ [fieldDef.name]: z$1.union([z$1.boolean(), z$1.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
2859
2866
  }), {})) })]).optional();
2860
2867
  this.registerSchema(`${model}CountSelection`, schema);
2861
2868
  return schema;
2862
- } else return z.never();
2869
+ } else return z$1.never();
2863
2870
  }
2864
2871
  makeRelationSelectIncludeSchema(model, field, options) {
2865
2872
  const fieldDef = requireField(this.schema, model, field);
2866
2873
  const nextOpts = this.nextOptions(options);
2867
- let objSchema = z.strictObject({
2868
- ...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
2869
- select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
2870
- include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
2871
- omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
2874
+ let objSchema = z$1.strictObject({
2875
+ ...fieldDef.array || fieldDef.optional ? { where: z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
2876
+ select: z$1.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
2877
+ include: z$1.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
2878
+ omit: z$1.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
2872
2879
  ...fieldDef.array ? {
2873
- orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
2880
+ orderBy: z$1.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
2874
2881
  skip: this.makeSkipSchema().optional(),
2875
2882
  take: this.makeTakeSchema().optional(),
2876
2883
  cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
@@ -2880,7 +2887,7 @@ var ZodSchemaFactory = class {
2880
2887
  objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
2881
2888
  objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
2882
2889
  objSchema = this.refineForSelectHasTruthyField(objSchema);
2883
- const result = z.union([z.boolean(), objSchema]);
2890
+ const result = z$1.union([z$1.boolean(), objSchema]);
2884
2891
  this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
2885
2892
  return result;
2886
2893
  }
@@ -2895,10 +2902,10 @@ var ZodSchemaFactory = class {
2895
2902
  }
2896
2903
  makeOmitSchema(model) {
2897
2904
  const fields = {};
2898
- for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
2899
- else fields[field] = z.literal(true).optional();
2905
+ for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z$1.boolean().optional();
2906
+ else fields[field] = z$1.literal(true).optional();
2900
2907
  this.addExtResultFields(model, fields);
2901
- const result = z.strictObject(fields);
2908
+ const result = z$1.strictObject(fields);
2902
2909
  this.registerSchema(`${model}OmitInput`, result);
2903
2910
  return result;
2904
2911
  }
@@ -2907,7 +2914,7 @@ var ZodSchemaFactory = class {
2907
2914
  const resultConfig = plugin.result;
2908
2915
  if (resultConfig) {
2909
2916
  const modelConfig = resultConfig[lowerCaseFirst(model)];
2910
- if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
2917
+ if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z$1.boolean().optional();
2911
2918
  }
2912
2919
  }
2913
2920
  }
@@ -2923,26 +2930,26 @@ var ZodSchemaFactory = class {
2923
2930
  }
2924
2931
  if (this.shouldIncludeRelations(options)) {
2925
2932
  const _countSchema = this.makeCountSelectionSchema(model, options);
2926
- if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
2933
+ if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
2927
2934
  }
2928
- const result = z.strictObject(fields);
2935
+ const result = z$1.strictObject(fields);
2929
2936
  this.registerSchema(`${model}Include`, result);
2930
2937
  return result;
2931
2938
  }
2932
2939
  makeOrderBySchema(model, withRelation, WithAggregation, options) {
2933
2940
  const fields = {};
2934
- const sort = z.union([z.literal("asc"), z.literal("desc")]);
2941
+ const sort = z$1.union([z$1.literal("asc"), z$1.literal("desc")]);
2935
2942
  const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
2936
2943
  const nextOpts = this.nextOptions(options);
2937
2944
  for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
2938
- if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
2945
+ if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z$1.lazy(() => {
2939
2946
  let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
2940
2947
  if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
2941
2948
  return relationOrderBy;
2942
2949
  }).optional();
2943
- } else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
2950
+ } else if (fieldDef.optional) fields[field] = z$1.union([sort, z$1.strictObject({
2944
2951
  sort,
2945
- nulls: z.union([z.literal("first"), z.literal("last")]).optional()
2952
+ nulls: z$1.union([z$1.literal("first"), z$1.literal("last")]).optional()
2946
2953
  })]).optional();
2947
2954
  else fields[field] = sort.optional();
2948
2955
  if (WithAggregation) for (const agg of [
@@ -2951,31 +2958,31 @@ var ZodSchemaFactory = class {
2951
2958
  "_sum",
2952
2959
  "_min",
2953
2960
  "_max"
2954
- ]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
2961
+ ]) fields[agg] = z$1.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
2955
2962
  if (this.providerSupportsFuzzySearch) {
2956
2963
  const fuzzyFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fuzzy === true).map(([name]) => name);
2957
- if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z.strictObject({
2958
- fields: z.array(z.enum(fuzzyFieldNames)).min(1),
2959
- search: z.string(),
2960
- mode: z.union([
2961
- z.literal("simple"),
2962
- z.literal("word"),
2963
- z.literal("strictWord")
2964
+ if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z$1.strictObject({
2965
+ fields: z$1.array(z$1.enum(fuzzyFieldNames)).min(1),
2966
+ search: z$1.string(),
2967
+ mode: z$1.union([
2968
+ z$1.literal("simple"),
2969
+ z$1.literal("word"),
2970
+ z$1.literal("strictWord")
2964
2971
  ]).default("simple"),
2965
- unaccent: z.boolean().default(false),
2972
+ unaccent: z$1.boolean().default(false),
2966
2973
  sort
2967
2974
  }).optional();
2968
2975
  }
2969
2976
  if (this.providerSupportsFullTextSearch) {
2970
2977
  const fullTextFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fullText === true).map(([name]) => name);
2971
- if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z.strictObject({
2972
- fields: z.array(z.enum(fullTextFieldNames)).min(1),
2973
- search: z.string().min(1),
2974
- config: z.string().min(1).optional(),
2978
+ if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z$1.strictObject({
2979
+ fields: z$1.array(z$1.enum(fullTextFieldNames)).min(1),
2980
+ search: z$1.string().min(1),
2981
+ config: z$1.string().min(1).optional(),
2975
2982
  sort
2976
2983
  }).optional();
2977
2984
  }
2978
- const schema = refineAtMostOneKey(z.strictObject(fields));
2985
+ const schema = refineAtMostOneKey(z$1.strictObject(fields));
2979
2986
  let schemaId = `${model}OrderBy`;
2980
2987
  if (withRelation) schemaId += "WithRelation";
2981
2988
  if (WithAggregation) schemaId += "WithAggregation";
@@ -2985,7 +2992,7 @@ var ZodSchemaFactory = class {
2985
2992
  }
2986
2993
  makeDistinctSchema(model) {
2987
2994
  const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
2988
- const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
2995
+ const schema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
2989
2996
  this.registerSchema(`${model}DistinctInput`, schema);
2990
2997
  return schema;
2991
2998
  }
@@ -2996,7 +3003,7 @@ var ZodSchemaFactory = class {
2996
3003
  }
2997
3004
  makeCreateSchema(model, options) {
2998
3005
  const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
2999
- const baseSchema = z.strictObject({
3006
+ const baseSchema = z$1.strictObject({
3000
3007
  data: dataSchema,
3001
3008
  select: this.makeSelectSchema(model, options).optional().nullable(),
3002
3009
  include: this.makeIncludeSchema(model, options).optional().nullable(),
@@ -3045,7 +3052,7 @@ var ZodSchemaFactory = class {
3045
3052
  const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
3046
3053
  if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
3047
3054
  }
3048
- let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
3055
+ let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
3049
3056
  if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
3050
3057
  else {
3051
3058
  let allFksOptional = false;
@@ -3062,23 +3069,23 @@ var ZodSchemaFactory = class {
3062
3069
  let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
3063
3070
  if (fieldDef.array) {
3064
3071
  fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
3065
- fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
3072
+ fieldSchema = z$1.union([fieldSchema, z$1.strictObject({ set: fieldSchema })]).optional();
3066
3073
  }
3067
3074
  if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
3068
- if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
3075
+ if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
3069
3076
  else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
3070
3077
  else fieldSchema = fieldSchema.nullable();
3071
3078
  uncheckedVariantFields[field] = fieldSchema;
3072
3079
  if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
3073
3080
  }
3074
3081
  });
3075
- const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
3076
- const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
3077
- const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
3082
+ const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
3083
+ const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
3084
+ const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z$1.union([
3078
3085
  uncheckedCreateSchema,
3079
3086
  checkedCreateSchema,
3080
- ...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
3081
- ...canBeArray ? [z.array(checkedCreateSchema)] : []
3087
+ ...canBeArray ? [z$1.array(uncheckedCreateSchema)] : [],
3088
+ ...canBeArray ? [z$1.array(checkedCreateSchema)] : []
3082
3089
  ]);
3083
3090
  const idParts = [`${model}CreateData`];
3084
3091
  if (canBeArray) idParts.push("Array");
@@ -3103,17 +3110,17 @@ var ZodSchemaFactory = class {
3103
3110
  fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
3104
3111
  fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
3105
3112
  }
3106
- fields["update"] = array ? this.orArray(z.strictObject({
3113
+ fields["update"] = array ? this.orArray(z$1.strictObject({
3107
3114
  where: this.makeWhereSchema(fieldType, true, false, false, options),
3108
3115
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
3109
- }), true).optional() : z.union([z.strictObject({
3116
+ }), true).optional() : z$1.union([z$1.strictObject({
3110
3117
  where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
3111
3118
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
3112
3119
  }), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
3113
3120
  if (canCreateModel) {
3114
3121
  let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
3115
3122
  if (!fieldDef.array) upsertWhere = upsertWhere.optional();
3116
- fields["upsert"] = this.orArray(z.strictObject({
3123
+ fields["upsert"] = this.orArray(z$1.strictObject({
3117
3124
  where: upsertWhere,
3118
3125
  create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
3119
3126
  update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
@@ -3121,14 +3128,14 @@ var ZodSchemaFactory = class {
3121
3128
  }
3122
3129
  if (array) {
3123
3130
  fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
3124
- fields["updateMany"] = this.orArray(z.strictObject({
3131
+ fields["updateMany"] = this.orArray(z$1.strictObject({
3125
3132
  where: this.makeWhereSchema(fieldType, false, true, false, options),
3126
3133
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
3127
3134
  }), true).optional();
3128
3135
  fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
3129
3136
  }
3130
3137
  }
3131
- return z.strictObject(fields);
3138
+ return z$1.strictObject(fields);
3132
3139
  }
3133
3140
  makeSetDataSchema(model, canBeArray, options) {
3134
3141
  return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
@@ -3138,23 +3145,23 @@ var ZodSchemaFactory = class {
3138
3145
  }
3139
3146
  makeDisconnectDataSchema(model, canBeArray, options) {
3140
3147
  if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
3141
- else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
3148
+ else return z$1.union([z$1.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
3142
3149
  }
3143
3150
  makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
3144
- return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
3151
+ return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z$1.union([z$1.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
3145
3152
  }
3146
3153
  makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
3147
3154
  const whereSchema = this.makeWhereSchema(model, true, false, false, options);
3148
3155
  const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
3149
- return this.orArray(z.strictObject({
3156
+ return this.orArray(z$1.strictObject({
3150
3157
  where: whereSchema,
3151
3158
  create: createSchema
3152
3159
  }), canBeArray);
3153
3160
  }
3154
3161
  makeCreateManyPayloadSchema(model, withoutFields, options) {
3155
- const schema = z.strictObject({
3162
+ const schema = z$1.strictObject({
3156
3163
  data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
3157
- skipDuplicates: z.boolean().optional()
3164
+ skipDuplicates: z$1.boolean().optional()
3158
3165
  });
3159
3166
  const idParts = [`${model}CreateManyPayload`];
3160
3167
  if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
@@ -3162,7 +3169,7 @@ var ZodSchemaFactory = class {
3162
3169
  return schema;
3163
3170
  }
3164
3171
  makeUpdateSchema(model, options) {
3165
- const baseSchema = z.strictObject({
3172
+ const baseSchema = z$1.strictObject({
3166
3173
  where: this.makeWhereSchema(model, true, false, false, options),
3167
3174
  data: this.makeUpdateDataSchema(model, [], false, options),
3168
3175
  select: this.makeSelectSchema(model, options).optional().nullable(),
@@ -3177,10 +3184,10 @@ var ZodSchemaFactory = class {
3177
3184
  return schema;
3178
3185
  }
3179
3186
  makeUpdateManySchema(model, options) {
3180
- const result = this.mergePluginArgsSchema(z.strictObject({
3187
+ const result = this.mergePluginArgsSchema(z$1.strictObject({
3181
3188
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3182
3189
  data: this.makeUpdateDataSchema(model, [], true, options),
3183
- limit: z.number().int().nonnegative().optional()
3190
+ limit: z$1.number().int().nonnegative().optional()
3184
3191
  }), "updateMany");
3185
3192
  this.registerSchema(`${model}UpdateManyArgs`, result);
3186
3193
  return result;
@@ -3196,7 +3203,7 @@ var ZodSchemaFactory = class {
3196
3203
  return schema;
3197
3204
  }
3198
3205
  makeUpsertSchema(model, options) {
3199
- const baseSchema = z.strictObject({
3206
+ const baseSchema = z$1.strictObject({
3200
3207
  where: this.makeWhereSchema(model, true, false, false, options),
3201
3208
  create: this.makeCreateDataSchema(model, false, [], false, options),
3202
3209
  update: this.makeUpdateDataSchema(model, [], false, options),
@@ -3232,27 +3239,27 @@ var ZodSchemaFactory = class {
3232
3239
  const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
3233
3240
  if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
3234
3241
  }
3235
- let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
3242
+ let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
3236
3243
  if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
3237
3244
  checkedVariantFields[field] = fieldSchema;
3238
3245
  if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
3239
3246
  } else {
3240
3247
  let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
3241
- if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
3242
- set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
3243
- increment: z.number().optional(),
3244
- decrement: z.number().optional(),
3245
- multiply: z.number().optional(),
3246
- divide: z.number().optional()
3248
+ if (this.isNumericField(fieldDef)) fieldSchema = z$1.union([fieldSchema, z$1.object({
3249
+ set: this.nullableIf(z$1.number().optional(), !!fieldDef.optional).optional(),
3250
+ increment: z$1.number().optional(),
3251
+ decrement: z$1.number().optional(),
3252
+ multiply: z$1.number().optional(),
3253
+ divide: z$1.number().optional()
3247
3254
  }).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
3248
3255
  if (fieldDef.array) {
3249
3256
  const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
3250
- fieldSchema = z.union([arraySchema, z.object({
3257
+ fieldSchema = z$1.union([arraySchema, z$1.object({
3251
3258
  set: arraySchema.optional(),
3252
- push: z.union([fieldSchema, fieldSchema.array()]).optional()
3259
+ push: z$1.union([fieldSchema, fieldSchema.array()]).optional()
3253
3260
  }).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
3254
3261
  }
3255
- if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
3262
+ if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
3256
3263
  else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
3257
3264
  else fieldSchema = fieldSchema.nullable();
3258
3265
  fieldSchema = fieldSchema.optional();
@@ -3260,9 +3267,9 @@ var ZodSchemaFactory = class {
3260
3267
  if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
3261
3268
  }
3262
3269
  });
3263
- const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
3264
- const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
3265
- const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
3270
+ const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
3271
+ const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
3272
+ const result = !hasRelation ? uncheckedUpdateSchema : z$1.union([uncheckedUpdateSchema, checkedUpdateSchema]);
3266
3273
  const idParts = [`${model}UpdateData`];
3267
3274
  if (withoutRelationFields) idParts.push("WithoutRelation");
3268
3275
  if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
@@ -3270,7 +3277,7 @@ var ZodSchemaFactory = class {
3270
3277
  return result;
3271
3278
  }
3272
3279
  makeDeleteSchema(model, options) {
3273
- const baseSchema = z.strictObject({
3280
+ const baseSchema = z$1.strictObject({
3274
3281
  where: this.makeWhereSchema(model, true, false, false, options),
3275
3282
  select: this.makeSelectSchema(model, options).optional().nullable(),
3276
3283
  include: this.makeIncludeSchema(model, options).optional().nullable(),
@@ -3284,15 +3291,15 @@ var ZodSchemaFactory = class {
3284
3291
  return schema;
3285
3292
  }
3286
3293
  makeDeleteManySchema(model, options) {
3287
- const result = this.mergePluginArgsSchema(z.strictObject({
3294
+ const result = this.mergePluginArgsSchema(z$1.strictObject({
3288
3295
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3289
- limit: z.number().int().nonnegative().optional()
3296
+ limit: z$1.number().int().nonnegative().optional()
3290
3297
  }), "deleteMany").optional();
3291
3298
  this.registerSchema(`${model}DeleteManyArgs`, result);
3292
3299
  return result;
3293
3300
  }
3294
3301
  makeCountSchema(model, options) {
3295
- const result = this.mergePluginArgsSchema(z.strictObject({
3302
+ const result = this.mergePluginArgsSchema(z$1.strictObject({
3296
3303
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3297
3304
  skip: this.makeSkipSchema().optional(),
3298
3305
  take: this.makeTakeSchema().optional(),
@@ -3303,10 +3310,10 @@ var ZodSchemaFactory = class {
3303
3310
  return result;
3304
3311
  }
3305
3312
  makeCountAggregateInputSchema(model) {
3306
- const schema = z.union([z.literal(true), z.strictObject({
3307
- _all: z.literal(true).optional(),
3313
+ const schema = z$1.union([z$1.literal(true), z$1.strictObject({
3314
+ _all: z$1.literal(true).optional(),
3308
3315
  ...this.getModelFields(model).reduce((acc, [field]) => {
3309
- acc[field] = z.literal(true).optional();
3316
+ acc[field] = z$1.literal(true).optional();
3310
3317
  return acc;
3311
3318
  }, {})
3312
3319
  })]);
@@ -3314,7 +3321,7 @@ var ZodSchemaFactory = class {
3314
3321
  return schema;
3315
3322
  }
3316
3323
  makeAggregateSchema(model, options) {
3317
- const result = this.mergePluginArgsSchema(z.strictObject({
3324
+ const result = this.mergePluginArgsSchema(z$1.strictObject({
3318
3325
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3319
3326
  skip: this.makeSkipSchema().optional(),
3320
3327
  take: this.makeTakeSchema().optional(),
@@ -3329,16 +3336,16 @@ var ZodSchemaFactory = class {
3329
3336
  return result;
3330
3337
  }
3331
3338
  makeSumAvgInputSchema(model) {
3332
- const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3333
- if (this.isNumericField(fieldDef)) acc[field] = z.literal(true).optional();
3339
+ const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3340
+ if (this.isNumericField(fieldDef)) acc[field] = z$1.literal(true).optional();
3334
3341
  return acc;
3335
3342
  }, {}));
3336
3343
  this.registerSchema(`${model}SumAvgAggregateInput`, schema);
3337
3344
  return schema;
3338
3345
  }
3339
3346
  makeMinMaxInputSchema(model) {
3340
- const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3341
- if (!fieldDef.relation && !fieldDef.array) acc[field] = z.literal(true).optional();
3347
+ const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3348
+ if (!fieldDef.relation && !fieldDef.array) acc[field] = z$1.literal(true).optional();
3342
3349
  return acc;
3343
3350
  }, {}));
3344
3351
  this.registerSchema(`${model}MinMaxAggregateInput`, schema);
@@ -3346,8 +3353,8 @@ var ZodSchemaFactory = class {
3346
3353
  }
3347
3354
  makeGroupBySchema(model, options) {
3348
3355
  const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
3349
- const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
3350
- const baseSchema = z.strictObject({
3356
+ const bySchema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
3357
+ const baseSchema = z$1.strictObject({
3351
3358
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3352
3359
  orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
3353
3360
  by: bySchema,
@@ -3399,7 +3406,7 @@ var ZodSchemaFactory = class {
3399
3406
  if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
3400
3407
  const shape = {};
3401
3408
  for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
3402
- const schema = z.object(shape);
3409
+ const schema = z$1.object(shape);
3403
3410
  this.registerSchema(`${procName}ProcArgs`, schema);
3404
3411
  return schema;
3405
3412
  }
@@ -3407,10 +3414,10 @@ var ZodSchemaFactory = class {
3407
3414
  let schema;
3408
3415
  if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
3409
3416
  else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
3410
- else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
3417
+ else if (param.type in (this.schema.models ?? {})) schema = z$1.record(z$1.string(), z$1.unknown());
3411
3418
  else {
3412
3419
  schema = this.makeScalarSchema(param.type);
3413
- if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
3420
+ if (schema instanceof z$1.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
3414
3421
  }
3415
3422
  if (param.array) schema = schema.array();
3416
3423
  if (param.optional) schema = schema.optional();
@@ -3446,10 +3453,10 @@ var ZodSchemaFactory = class {
3446
3453
  return result;
3447
3454
  }
3448
3455
  makeSkipSchema() {
3449
- return z.number().int().nonnegative();
3456
+ return z$1.number().int().nonnegative();
3450
3457
  }
3451
3458
  makeTakeSchema() {
3452
- return z.number().int();
3459
+ return z$1.number().int();
3453
3460
  }
3454
3461
  refineForSelectIncludeMutuallyExclusive(schema) {
3455
3462
  return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
@@ -3468,7 +3475,7 @@ var ZodSchemaFactory = class {
3468
3475
  return nullable ? schema.nullable() : schema;
3469
3476
  }
3470
3477
  orArray(schema, canBeArray) {
3471
- return canBeArray ? z.union([schema, z.array(schema)]) : schema;
3478
+ return canBeArray ? z$1.union([schema, z$1.array(schema)]) : schema;
3472
3479
  }
3473
3480
  isNumericField(fieldDef) {
3474
3481
  return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
@@ -3530,10 +3537,10 @@ var ZodSchemaFactory = class {
3530
3537
  createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
3531
3538
  if (Object.keys(components).length === 0) {
3532
3539
  if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
3533
- return z.never();
3540
+ return z$1.never();
3534
3541
  }
3535
- if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
3536
- else return z.strictObject(components);
3542
+ if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z$1.union([this.nullableIf(valueSchema, optional), z$1.strictObject(components)]);
3543
+ else return z$1.strictObject(components);
3537
3544
  }
3538
3545
  canCreateModel(model) {
3539
3546
  const modelDef = requireModel(this.schema, model);
@@ -7141,9 +7148,9 @@ var ClientImpl = class ClientImpl {
7141
7148
  validateOptions(baseClient, options) {
7142
7149
  if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
7143
7150
  if (options.diagnostics) {
7144
- const parseResult = z$1.object({
7145
- slowQueryThresholdMs: z$1.number().nonnegative().optional(),
7146
- slowQueryMaxRecords: z$1.int().nonnegative().or(z$1.literal(Infinity)).optional()
7151
+ const parseResult = z.object({
7152
+ slowQueryThresholdMs: z.number().nonnegative().optional(),
7153
+ slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
7147
7154
  }).safeParse(options.diagnostics);
7148
7155
  if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
7149
7156
  }