@zenstackhq/orm 3.8.0-beta.1 → 3.8.0-beta.2

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, { ZodObject, ZodType, z as z$1 } from "zod";
5
+ import z$1, { ZodObject, ZodType, z } 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";
@@ -2287,7 +2287,7 @@ function createQuerySchemaFactory(clientOrSchema, options) {
2287
2287
  * @see https://github.com/zenstackhq/zenstack/issues/2631
2288
2288
  */
2289
2289
  function coercedDateTimeSchema() {
2290
- return z$1.preprocess((val) => {
2290
+ return z.preprocess((val) => {
2291
2291
  if (typeof val !== "string") return val;
2292
2292
  if (/^\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d\d(?::\d\d)?)?$/.test(val)) {
2293
2293
  const hasTz = val.endsWith("Z") || /[+-]\d\d(?::\d\d)?$/.test(val);
@@ -2296,10 +2296,10 @@ function coercedDateTimeSchema() {
2296
2296
  }
2297
2297
  const d = new Date(val);
2298
2298
  return isNaN(d.getTime()) ? val : d;
2299
- }, z$1.union([
2300
- z$1.iso.datetime(),
2301
- z$1.iso.date(),
2302
- z$1.date()
2299
+ }, z.union([
2300
+ z.iso.datetime(),
2301
+ z.iso.date(),
2302
+ z.date()
2303
2303
  ]));
2304
2304
  }
2305
2305
  /**
@@ -2307,7 +2307,7 @@ function coercedDateTimeSchema() {
2307
2307
  */
2308
2308
  var ZodSchemaFactory = class {
2309
2309
  schemaCache = /* @__PURE__ */ new Map();
2310
- schemaRegistry = z$1.registry();
2310
+ schemaRegistry = z.registry();
2311
2311
  allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
2312
2312
  schema;
2313
2313
  options;
@@ -2399,7 +2399,7 @@ var ZodSchemaFactory = class {
2399
2399
  this.makeGroupBySchema(m);
2400
2400
  }
2401
2401
  for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
2402
- return z$1.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
2402
+ return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
2403
2403
  }
2404
2404
  get cacheStats() {
2405
2405
  return {
@@ -2428,13 +2428,13 @@ var ZodSchemaFactory = class {
2428
2428
  fields["omit"] = this.makeOmitSchema(model).optional().nullable();
2429
2429
  if (!unique) {
2430
2430
  fields["skip"] = this.makeSkipSchema().optional();
2431
- if (findOne) fields["take"] = z$1.literal(1).optional();
2431
+ if (findOne) fields["take"] = z.literal(1).optional();
2432
2432
  else fields["take"] = this.makeTakeSchema().optional();
2433
2433
  fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
2434
2434
  fields["cursor"] = this.makeCursorSchema(model, options).optional();
2435
2435
  fields["distinct"] = this.makeDistinctSchema(model).optional();
2436
2436
  }
2437
- const baseSchema = z$1.strictObject(fields);
2437
+ const baseSchema = z.strictObject(fields);
2438
2438
  let result = this.mergePluginArgsSchema(baseSchema, operation);
2439
2439
  result = this.refineForSelectIncludeMutuallyExclusive(result);
2440
2440
  result = this.refineForSelectOmitMutuallyExclusive(result);
@@ -2444,7 +2444,7 @@ var ZodSchemaFactory = class {
2444
2444
  return result;
2445
2445
  }
2446
2446
  makeExistsSchema(model, options) {
2447
- const baseSchema = z$1.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
2447
+ const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
2448
2448
  const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
2449
2449
  this.registerSchema(`${model}ExistsArgs`, result);
2450
2450
  return result;
@@ -2452,31 +2452,31 @@ var ZodSchemaFactory = class {
2452
2452
  makeScalarSchema(type, attributes) {
2453
2453
  if (this.schema.typeDefs && type in this.schema.typeDefs) return this.makeTypeDefSchema(type);
2454
2454
  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$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", () => {
2456
- return z$1.union([
2457
- this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number(), attributes) : z$1.number(),
2458
- ZodUtils.addDecimalValidation(z$1.instanceof(Decimal), attributes, this.extraValidationsEnabled),
2459
- ZodUtils.addDecimalValidation(z$1.string(), attributes, this.extraValidationsEnabled)
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)
2460
2460
  ]);
2461
- }).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z$1.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z$1.unknown());
2461
+ }).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
2462
2462
  }
2463
2463
  makeEnumSchema(_enum) {
2464
2464
  const enumDef = getEnum(this.schema, _enum);
2465
2465
  invariant(enumDef, `Enum "${_enum}" not found in schema`);
2466
- const schema = z$1.enum(Object.keys(enumDef.values));
2466
+ const schema = z.enum(Object.keys(enumDef.values));
2467
2467
  this.registerSchema(_enum, schema);
2468
2468
  return schema;
2469
2469
  }
2470
2470
  makeTypeDefSchema(type) {
2471
2471
  const typeDef = getTypeDef(this.schema, type);
2472
2472
  invariant(typeDef, `Type definition "${type}" not found in schema`);
2473
- const schema = z$1.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
2474
- let fieldSchema = isTypeDef(this.schema, def.type) ? z$1.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type);
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);
2475
2475
  if (def.array) fieldSchema = fieldSchema.array();
2476
2476
  if (def.optional) fieldSchema = fieldSchema.nullish();
2477
2477
  return [field, fieldSchema];
2478
2478
  })));
2479
- const finalSchema = z$1.any().superRefine((value, ctx) => {
2479
+ const finalSchema = z.any().superRefine((value, ctx) => {
2480
2480
  const parseResult = schema.safeParse(value);
2481
2481
  if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
2482
2482
  });
@@ -2492,17 +2492,17 @@ var ZodSchemaFactory = class {
2492
2492
  if (fieldDef.relation) {
2493
2493
  if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
2494
2494
  const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
2495
- if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z$1.never();
2495
+ if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
2496
2496
  else {
2497
- fieldSchema = z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
2498
- if (fieldDef.array) fieldSchema = z$1.strictObject({
2497
+ fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
2498
+ if (fieldDef.array) fieldSchema = z.strictObject({
2499
2499
  some: fieldSchema.optional(),
2500
2500
  every: fieldSchema.optional(),
2501
2501
  none: fieldSchema.optional()
2502
2502
  });
2503
2503
  else {
2504
2504
  fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
2505
- fieldSchema = z$1.union([fieldSchema, z$1.strictObject({
2505
+ fieldSchema = z.union([fieldSchema, z.strictObject({
2506
2506
  is: fieldSchema.optional(),
2507
2507
  isNot: fieldSchema.optional()
2508
2508
  })]);
@@ -2521,21 +2521,21 @@ var ZodSchemaFactory = class {
2521
2521
  }
2522
2522
  if (unique) {
2523
2523
  const uniqueFields = getUniqueFields(this.schema, model);
2524
- for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z$1.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
2524
+ for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
2525
2525
  invariant(!def.relation, "unique field cannot be a relation");
2526
2526
  let fieldSchema;
2527
2527
  const enumDef = getEnum(this.schema, def.type);
2528
2528
  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$1.never();
2529
+ else fieldSchema = z.never();
2530
2530
  else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
2531
2531
  return [key, fieldSchema];
2532
2532
  }))).optional();
2533
2533
  }
2534
- fields["$expr"] = z$1.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
2535
- fields["AND"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2536
- fields["OR"] = z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
2537
- fields["NOT"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2538
- const baseWhere = z$1.strictObject(fields);
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);
2539
2539
  let result = baseWhere;
2540
2540
  if (unique) {
2541
2541
  const uniqueFields = getUniqueFields(this.schema, model);
@@ -2561,26 +2561,26 @@ var ZodSchemaFactory = class {
2561
2561
  else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
2562
2562
  else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
2563
2563
  else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(fieldDef.type, !!fieldDef.optional, false, void 0).optional();
2564
- candidates.push(z$1.strictObject(fieldSchemas));
2564
+ candidates.push(z.strictObject(fieldSchemas));
2565
2565
  }
2566
- const recursiveSchema = z$1.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
2567
- if (array) candidates.push(z$1.strictObject({
2566
+ const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
2567
+ if (array) candidates.push(z.strictObject({
2568
2568
  some: recursiveSchema,
2569
2569
  every: recursiveSchema,
2570
2570
  none: recursiveSchema
2571
2571
  }));
2572
- else candidates.push(z$1.strictObject({
2572
+ else candidates.push(z.strictObject({
2573
2573
  is: recursiveSchema,
2574
2574
  isNot: recursiveSchema
2575
2575
  }));
2576
2576
  candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
2577
2577
  if (optional) {
2578
- candidates.push(z$1.null());
2579
- candidates.push(z$1.instanceof(DbNullClass));
2580
- candidates.push(z$1.instanceof(JsonNullClass));
2581
- candidates.push(z$1.instanceof(AnyNullClass));
2578
+ candidates.push(z.null());
2579
+ candidates.push(z.instanceof(DbNullClass));
2580
+ candidates.push(z.instanceof(JsonNullClass));
2581
+ candidates.push(z.instanceof(AnyNullClass));
2582
2582
  }
2583
- const result = z$1.union(candidates);
2583
+ const result = z.union(candidates);
2584
2584
  this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
2585
2585
  optional,
2586
2586
  array,
@@ -2589,7 +2589,7 @@ var ZodSchemaFactory = class {
2589
2589
  return result;
2590
2590
  }
2591
2591
  makeNullableTypedJsonMutationSchema(fieldSchema) {
2592
- return z$1.any().superRefine((value, ctx) => {
2592
+ return z.any().superRefine((value, ctx) => {
2593
2593
  if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
2594
2594
  const parseResult = fieldSchema.safeParse(value);
2595
2595
  if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
@@ -2601,11 +2601,11 @@ var ZodSchemaFactory = class {
2601
2601
  makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
2602
2602
  const enumDef = getEnum(this.schema, enumName);
2603
2603
  invariant(enumDef, `Enum "${enumName}" not found in schema`);
2604
- const baseSchema = z$1.enum(Object.keys(enumDef.values));
2604
+ const baseSchema = z.enum(Object.keys(enumDef.values));
2605
2605
  let schema;
2606
2606
  if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
2607
2607
  else {
2608
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
2608
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
2609
2609
  "equals",
2610
2610
  "in",
2611
2611
  "notIn",
@@ -2639,42 +2639,42 @@ var ZodSchemaFactory = class {
2639
2639
  has: elementSchema.optional(),
2640
2640
  hasEvery: elementSchema.array().optional(),
2641
2641
  hasSome: elementSchema.array().optional(),
2642
- isEmpty: z$1.boolean().optional()
2642
+ isEmpty: z.boolean().optional()
2643
2643
  };
2644
2644
  const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
2645
- return z$1.strictObject(filteredOperators);
2645
+ return z.strictObject(filteredOperators);
2646
2646
  }
2647
2647
  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$1.never()).exhaustive();
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();
2649
2649
  }
2650
2650
  makeJsonValueSchema() {
2651
- const schema = z$1.union([
2652
- z$1.string(),
2653
- z$1.number(),
2654
- z$1.boolean(),
2655
- z$1.instanceof(JsonNullClass),
2656
- z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()]).array()),
2657
- z$1.record(z$1.string(), z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()])))
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
2658
  ]);
2659
2659
  this.registerSchema("JsonValue", schema);
2660
2660
  return schema;
2661
2661
  }
2662
2662
  makeJsonFilterSchema(optional, allowedFilterKinds) {
2663
- if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z$1.never();
2663
+ if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
2664
2664
  const filterMembers = [
2665
2665
  this.makeJsonValueSchema(),
2666
- z$1.instanceof(DbNullClass),
2667
- z$1.instanceof(AnyNullClass)
2666
+ z.instanceof(DbNullClass),
2667
+ z.instanceof(AnyNullClass)
2668
2668
  ];
2669
- if (optional) filterMembers.push(z$1.null());
2670
- const filterValueSchema = z$1.union(filterMembers);
2671
- const schema = z$1.strictObject({
2672
- path: z$1.string().optional(),
2669
+ if (optional) filterMembers.push(z.null());
2670
+ const filterValueSchema = z.union(filterMembers);
2671
+ const schema = z.strictObject({
2672
+ path: z.string().optional(),
2673
2673
  equals: filterValueSchema.optional(),
2674
2674
  not: filterValueSchema.optional(),
2675
- string_contains: z$1.string().optional(),
2676
- string_starts_with: z$1.string().optional(),
2677
- string_ends_with: z$1.string().optional(),
2675
+ string_contains: z.string().optional(),
2676
+ string_starts_with: z.string().optional(),
2677
+ string_ends_with: z.string().optional(),
2678
2678
  mode: this.makeStringModeSchema().optional(),
2679
2679
  array_contains: filterValueSchema.optional(),
2680
2680
  array_starts_with: filterValueSchema.optional(),
@@ -2693,7 +2693,7 @@ var ZodSchemaFactory = class {
2693
2693
  }
2694
2694
  makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
2695
2695
  const filterValueSchema = this.makeDateTimeValueSchema();
2696
- const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z$1.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2696
+ const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2697
2697
  "_count",
2698
2698
  "_min",
2699
2699
  "_max"
@@ -2706,12 +2706,12 @@ var ZodSchemaFactory = class {
2706
2706
  return schema;
2707
2707
  }
2708
2708
  makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
2709
- const components = this.makeCommonPrimitiveFilterComponents(z$1.boolean(), optional, () => z$1.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
2709
+ const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
2710
2710
  "_count",
2711
2711
  "_min",
2712
2712
  "_max"
2713
2713
  ] : void 0, allowedFilterKinds);
2714
- const schema = this.createUnionFilterSchema(z$1.boolean(), optional, components, allowedFilterKinds);
2714
+ const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
2715
2715
  this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
2716
2716
  optional,
2717
2717
  allowedFilterKinds,
@@ -2720,8 +2720,8 @@ var ZodSchemaFactory = class {
2720
2720
  return schema;
2721
2721
  }
2722
2722
  makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
2723
- const baseSchema = z$1.instanceof(Uint8Array);
2724
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.instanceof(Uint8Array), [
2723
+ const baseSchema = z.instanceof(Uint8Array);
2724
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
2725
2725
  "equals",
2726
2726
  "in",
2727
2727
  "notIn",
@@ -2769,7 +2769,7 @@ var ZodSchemaFactory = class {
2769
2769
  return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
2770
2770
  }
2771
2771
  makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
2772
- const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z$1.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2772
+ const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2773
2773
  "_count",
2774
2774
  "_avg",
2775
2775
  "_sum",
@@ -2784,15 +2784,15 @@ var ZodSchemaFactory = class {
2784
2784
  return schema;
2785
2785
  }
2786
2786
  makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
2787
- const baseComponents = this.makeCommonPrimitiveFilterComponents(z$1.string(), optional, () => z$1.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
2787
+ const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
2788
2788
  "_count",
2789
2789
  "_min",
2790
2790
  "_max"
2791
2791
  ] : void 0, allowedFilterKinds);
2792
2792
  const stringSpecificOperators = {
2793
- startsWith: z$1.string().optional(),
2794
- endsWith: z$1.string().optional(),
2795
- contains: z$1.string().optional(),
2793
+ startsWith: z.string().optional(),
2794
+ endsWith: z.string().optional(),
2795
+ contains: z.string().optional(),
2796
2796
  ...withFuzzy && this.providerSupportsFuzzySearch ? { fuzzy: this.makeFuzzyFilterSchema().optional() } : {},
2797
2797
  ...withFullText && this.providerSupportsFullTextSearch ? { fts: this.makeFullTextFilterSchema().optional() } : {},
2798
2798
  ...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
@@ -2802,7 +2802,7 @@ var ZodSchemaFactory = class {
2802
2802
  ...baseComponents,
2803
2803
  ...filteredStringOperators
2804
2804
  };
2805
- const schema = this.createUnionFilterSchema(z$1.string(), optional, allComponents, allowedFilterKinds);
2805
+ const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
2806
2806
  const featureSuffix = `${withFuzzy ? "Fuzzy" : ""}${withFullText ? "FullText" : ""}`;
2807
2807
  this.registerSchema(`StringFilter${this.filterSchemaSuffix({
2808
2808
  optional,
@@ -2812,24 +2812,24 @@ var ZodSchemaFactory = class {
2812
2812
  return schema;
2813
2813
  }
2814
2814
  makeStringModeSchema() {
2815
- return z$1.union([z$1.literal("default"), z$1.literal("insensitive")]);
2815
+ return z.union([z.literal("default"), z.literal("insensitive")]);
2816
2816
  }
2817
2817
  makeFuzzyFilterSchema() {
2818
- return z$1.strictObject({
2819
- search: z$1.string().min(1),
2820
- mode: z$1.union([
2821
- z$1.literal("simple"),
2822
- z$1.literal("word"),
2823
- z$1.literal("strictWord")
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")
2824
2824
  ]).default("simple"),
2825
- threshold: z$1.number().min(0).max(1).optional(),
2826
- unaccent: z$1.boolean().default(false)
2825
+ threshold: z.number().min(0).max(1).optional(),
2826
+ unaccent: z.boolean().default(false)
2827
2827
  });
2828
2828
  }
2829
2829
  makeFullTextFilterSchema() {
2830
- return z$1.strictObject({
2831
- search: z$1.string().min(1),
2832
- config: z$1.string().min(1).optional()
2830
+ return z.strictObject({
2831
+ search: z.string().min(1),
2832
+ config: z.string().min(1).optional()
2833
2833
  });
2834
2834
  }
2835
2835
  makeSelectSchema(model, options) {
@@ -2837,13 +2837,13 @@ var ZodSchemaFactory = class {
2837
2837
  for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
2838
2838
  if (!this.shouldIncludeRelations(options)) continue;
2839
2839
  if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
2840
- } else fields[field] = z$1.boolean().optional();
2840
+ } else fields[field] = z.boolean().optional();
2841
2841
  if (this.shouldIncludeRelations(options)) {
2842
2842
  const _countSchema = this.makeCountSelectionSchema(model, options);
2843
- if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
2843
+ if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
2844
2844
  }
2845
2845
  this.addExtResultFields(model, fields);
2846
- const result = z$1.strictObject(fields);
2846
+ const result = z.strictObject(fields);
2847
2847
  this.registerSchema(`${model}Select`, result);
2848
2848
  return result;
2849
2849
  }
@@ -2852,24 +2852,24 @@ var ZodSchemaFactory = class {
2852
2852
  const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
2853
2853
  if (toManyRelations.length > 0) {
2854
2854
  const nextOpts = this.nextOptions(options);
2855
- const schema = z$1.union([z$1.literal(true), z$1.strictObject({ select: z$1.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
2855
+ const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
2856
2856
  ...acc,
2857
- [fieldDef.name]: z$1.union([z$1.boolean(), z$1.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
2857
+ [fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
2858
2858
  }), {})) })]).optional();
2859
2859
  this.registerSchema(`${model}CountSelection`, schema);
2860
2860
  return schema;
2861
- } else return z$1.never();
2861
+ } else return z.never();
2862
2862
  }
2863
2863
  makeRelationSelectIncludeSchema(model, field, options) {
2864
2864
  const fieldDef = requireField(this.schema, model, field);
2865
2865
  const nextOpts = this.nextOptions(options);
2866
- let objSchema = z$1.strictObject({
2867
- ...fieldDef.array || fieldDef.optional ? { where: z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
2868
- select: z$1.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
2869
- include: z$1.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
2870
- omit: z$1.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
2866
+ let objSchema = z.strictObject({
2867
+ ...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
2868
+ select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
2869
+ include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
2870
+ omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
2871
2871
  ...fieldDef.array ? {
2872
- orderBy: z$1.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
2872
+ orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
2873
2873
  skip: this.makeSkipSchema().optional(),
2874
2874
  take: this.makeTakeSchema().optional(),
2875
2875
  cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
@@ -2879,16 +2879,16 @@ var ZodSchemaFactory = class {
2879
2879
  objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
2880
2880
  objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
2881
2881
  objSchema = this.refineForSelectHasTruthyField(objSchema);
2882
- const result = z$1.union([z$1.boolean(), objSchema]);
2882
+ const result = z.union([z.boolean(), objSchema]);
2883
2883
  this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
2884
2884
  return result;
2885
2885
  }
2886
2886
  makeOmitSchema(model) {
2887
2887
  const fields = {};
2888
- for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z$1.boolean().optional();
2889
- else fields[field] = z$1.literal(true).optional();
2888
+ for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
2889
+ else fields[field] = z.literal(true).optional();
2890
2890
  this.addExtResultFields(model, fields);
2891
- const result = z$1.strictObject(fields);
2891
+ const result = z.strictObject(fields);
2892
2892
  this.registerSchema(`${model}OmitInput`, result);
2893
2893
  return result;
2894
2894
  }
@@ -2897,7 +2897,7 @@ var ZodSchemaFactory = class {
2897
2897
  const resultConfig = plugin.result;
2898
2898
  if (resultConfig) {
2899
2899
  const modelConfig = resultConfig[lowerCaseFirst(model)];
2900
- if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z$1.boolean().optional();
2900
+ if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
2901
2901
  }
2902
2902
  }
2903
2903
  }
@@ -2913,26 +2913,26 @@ var ZodSchemaFactory = class {
2913
2913
  }
2914
2914
  if (this.shouldIncludeRelations(options)) {
2915
2915
  const _countSchema = this.makeCountSelectionSchema(model, options);
2916
- if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
2916
+ if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
2917
2917
  }
2918
- const result = z$1.strictObject(fields);
2918
+ const result = z.strictObject(fields);
2919
2919
  this.registerSchema(`${model}Include`, result);
2920
2920
  return result;
2921
2921
  }
2922
2922
  makeOrderBySchema(model, withRelation, WithAggregation, options) {
2923
2923
  const fields = {};
2924
- const sort = z$1.union([z$1.literal("asc"), z$1.literal("desc")]);
2924
+ const sort = z.union([z.literal("asc"), z.literal("desc")]);
2925
2925
  const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
2926
2926
  const nextOpts = this.nextOptions(options);
2927
2927
  for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
2928
- if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z$1.lazy(() => {
2928
+ if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
2929
2929
  let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
2930
2930
  if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
2931
2931
  return relationOrderBy;
2932
2932
  }).optional();
2933
- } else if (fieldDef.optional) fields[field] = z$1.union([sort, z$1.strictObject({
2933
+ } else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
2934
2934
  sort,
2935
- nulls: z$1.union([z$1.literal("first"), z$1.literal("last")]).optional()
2935
+ nulls: z.union([z.literal("first"), z.literal("last")]).optional()
2936
2936
  })]).optional();
2937
2937
  else fields[field] = sort.optional();
2938
2938
  if (WithAggregation) for (const agg of [
@@ -2941,31 +2941,31 @@ var ZodSchemaFactory = class {
2941
2941
  "_sum",
2942
2942
  "_min",
2943
2943
  "_max"
2944
- ]) fields[agg] = z$1.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
2944
+ ]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
2945
2945
  if (this.providerSupportsFuzzySearch) {
2946
2946
  const fuzzyFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fuzzy === true).map(([name]) => name);
2947
- if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z$1.strictObject({
2948
- fields: z$1.array(z$1.enum(fuzzyFieldNames)).min(1),
2949
- search: z$1.string(),
2950
- mode: z$1.union([
2951
- z$1.literal("simple"),
2952
- z$1.literal("word"),
2953
- z$1.literal("strictWord")
2947
+ if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z.strictObject({
2948
+ fields: z.array(z.enum(fuzzyFieldNames)).min(1),
2949
+ search: z.string(),
2950
+ mode: z.union([
2951
+ z.literal("simple"),
2952
+ z.literal("word"),
2953
+ z.literal("strictWord")
2954
2954
  ]).default("simple"),
2955
- unaccent: z$1.boolean().default(false),
2955
+ unaccent: z.boolean().default(false),
2956
2956
  sort
2957
2957
  }).optional();
2958
2958
  }
2959
2959
  if (this.providerSupportsFullTextSearch) {
2960
2960
  const fullTextFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fullText === true).map(([name]) => name);
2961
- if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z$1.strictObject({
2962
- fields: z$1.array(z$1.enum(fullTextFieldNames)).min(1),
2963
- search: z$1.string().min(1),
2964
- config: z$1.string().min(1).optional(),
2961
+ if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z.strictObject({
2962
+ fields: z.array(z.enum(fullTextFieldNames)).min(1),
2963
+ search: z.string().min(1),
2964
+ config: z.string().min(1).optional(),
2965
2965
  sort
2966
2966
  }).optional();
2967
2967
  }
2968
- const schema = refineAtMostOneKey(z$1.strictObject(fields));
2968
+ const schema = refineAtMostOneKey(z.strictObject(fields));
2969
2969
  let schemaId = `${model}OrderBy`;
2970
2970
  if (withRelation) schemaId += "WithRelation";
2971
2971
  if (WithAggregation) schemaId += "WithAggregation";
@@ -2975,7 +2975,7 @@ var ZodSchemaFactory = class {
2975
2975
  }
2976
2976
  makeDistinctSchema(model) {
2977
2977
  const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
2978
- const schema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
2978
+ const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
2979
2979
  this.registerSchema(`${model}DistinctInput`, schema);
2980
2980
  return schema;
2981
2981
  }
@@ -2986,7 +2986,7 @@ var ZodSchemaFactory = class {
2986
2986
  }
2987
2987
  makeCreateSchema(model, options) {
2988
2988
  const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
2989
- const baseSchema = z$1.strictObject({
2989
+ const baseSchema = z.strictObject({
2990
2990
  data: dataSchema,
2991
2991
  select: this.makeSelectSchema(model, options).optional().nullable(),
2992
2992
  include: this.makeIncludeSchema(model, options).optional().nullable(),
@@ -3035,7 +3035,7 @@ var ZodSchemaFactory = class {
3035
3035
  const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
3036
3036
  if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
3037
3037
  }
3038
- let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
3038
+ let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
3039
3039
  if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
3040
3040
  else {
3041
3041
  let allFksOptional = false;
@@ -3052,23 +3052,23 @@ var ZodSchemaFactory = class {
3052
3052
  let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
3053
3053
  if (fieldDef.array) {
3054
3054
  fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
3055
- fieldSchema = z$1.union([fieldSchema, z$1.strictObject({ set: fieldSchema })]).optional();
3055
+ fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
3056
3056
  }
3057
3057
  if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
3058
- if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
3058
+ if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
3059
3059
  else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
3060
3060
  else fieldSchema = fieldSchema.nullable();
3061
3061
  uncheckedVariantFields[field] = fieldSchema;
3062
3062
  if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
3063
3063
  }
3064
3064
  });
3065
- const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
3066
- const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
3067
- const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z$1.union([
3065
+ const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
3066
+ const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
3067
+ const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
3068
3068
  uncheckedCreateSchema,
3069
3069
  checkedCreateSchema,
3070
- ...canBeArray ? [z$1.array(uncheckedCreateSchema)] : [],
3071
- ...canBeArray ? [z$1.array(checkedCreateSchema)] : []
3070
+ ...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
3071
+ ...canBeArray ? [z.array(checkedCreateSchema)] : []
3072
3072
  ]);
3073
3073
  const idParts = [`${model}CreateData`];
3074
3074
  if (canBeArray) idParts.push("Array");
@@ -3093,17 +3093,17 @@ var ZodSchemaFactory = class {
3093
3093
  fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
3094
3094
  fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
3095
3095
  }
3096
- fields["update"] = array ? this.orArray(z$1.strictObject({
3096
+ fields["update"] = array ? this.orArray(z.strictObject({
3097
3097
  where: this.makeWhereSchema(fieldType, true, false, false, options),
3098
3098
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
3099
- }), true).optional() : z$1.union([z$1.strictObject({
3099
+ }), true).optional() : z.union([z.strictObject({
3100
3100
  where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
3101
3101
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
3102
3102
  }), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
3103
3103
  if (canCreateModel) {
3104
3104
  let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
3105
3105
  if (!fieldDef.array) upsertWhere = upsertWhere.optional();
3106
- fields["upsert"] = this.orArray(z$1.strictObject({
3106
+ fields["upsert"] = this.orArray(z.strictObject({
3107
3107
  where: upsertWhere,
3108
3108
  create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
3109
3109
  update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
@@ -3111,14 +3111,14 @@ var ZodSchemaFactory = class {
3111
3111
  }
3112
3112
  if (array) {
3113
3113
  fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
3114
- fields["updateMany"] = this.orArray(z$1.strictObject({
3114
+ fields["updateMany"] = this.orArray(z.strictObject({
3115
3115
  where: this.makeWhereSchema(fieldType, false, true, false, options),
3116
3116
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
3117
3117
  }), true).optional();
3118
3118
  fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
3119
3119
  }
3120
3120
  }
3121
- return z$1.strictObject(fields);
3121
+ return z.strictObject(fields);
3122
3122
  }
3123
3123
  makeSetDataSchema(model, canBeArray, options) {
3124
3124
  return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
@@ -3128,23 +3128,23 @@ var ZodSchemaFactory = class {
3128
3128
  }
3129
3129
  makeDisconnectDataSchema(model, canBeArray, options) {
3130
3130
  if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
3131
- else return z$1.union([z$1.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
3131
+ else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
3132
3132
  }
3133
3133
  makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
3134
- 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)]);
3134
+ return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
3135
3135
  }
3136
3136
  makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
3137
3137
  const whereSchema = this.makeWhereSchema(model, true, false, false, options);
3138
3138
  const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
3139
- return this.orArray(z$1.strictObject({
3139
+ return this.orArray(z.strictObject({
3140
3140
  where: whereSchema,
3141
3141
  create: createSchema
3142
3142
  }), canBeArray);
3143
3143
  }
3144
3144
  makeCreateManyPayloadSchema(model, withoutFields, options) {
3145
- const schema = z$1.strictObject({
3145
+ const schema = z.strictObject({
3146
3146
  data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
3147
- skipDuplicates: z$1.boolean().optional()
3147
+ skipDuplicates: z.boolean().optional()
3148
3148
  });
3149
3149
  const idParts = [`${model}CreateManyPayload`];
3150
3150
  if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
@@ -3152,7 +3152,7 @@ var ZodSchemaFactory = class {
3152
3152
  return schema;
3153
3153
  }
3154
3154
  makeUpdateSchema(model, options) {
3155
- const baseSchema = z$1.strictObject({
3155
+ const baseSchema = z.strictObject({
3156
3156
  where: this.makeWhereSchema(model, true, false, false, options),
3157
3157
  data: this.makeUpdateDataSchema(model, [], false, options),
3158
3158
  select: this.makeSelectSchema(model, options).optional().nullable(),
@@ -3167,10 +3167,10 @@ var ZodSchemaFactory = class {
3167
3167
  return schema;
3168
3168
  }
3169
3169
  makeUpdateManySchema(model, options) {
3170
- const result = this.mergePluginArgsSchema(z$1.strictObject({
3170
+ const result = this.mergePluginArgsSchema(z.strictObject({
3171
3171
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3172
3172
  data: this.makeUpdateDataSchema(model, [], true, options),
3173
- limit: z$1.number().int().nonnegative().optional()
3173
+ limit: z.number().int().nonnegative().optional()
3174
3174
  }), "updateMany");
3175
3175
  this.registerSchema(`${model}UpdateManyArgs`, result);
3176
3176
  return result;
@@ -3186,7 +3186,7 @@ var ZodSchemaFactory = class {
3186
3186
  return schema;
3187
3187
  }
3188
3188
  makeUpsertSchema(model, options) {
3189
- const baseSchema = z$1.strictObject({
3189
+ const baseSchema = z.strictObject({
3190
3190
  where: this.makeWhereSchema(model, true, false, false, options),
3191
3191
  create: this.makeCreateDataSchema(model, false, [], false, options),
3192
3192
  update: this.makeUpdateDataSchema(model, [], false, options),
@@ -3222,27 +3222,27 @@ var ZodSchemaFactory = class {
3222
3222
  const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
3223
3223
  if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
3224
3224
  }
3225
- let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
3225
+ let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
3226
3226
  if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
3227
3227
  checkedVariantFields[field] = fieldSchema;
3228
3228
  if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
3229
3229
  } else {
3230
3230
  let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
3231
- if (this.isNumericField(fieldDef)) fieldSchema = z$1.union([fieldSchema, z$1.object({
3232
- set: this.nullableIf(z$1.number().optional(), !!fieldDef.optional).optional(),
3233
- increment: z$1.number().optional(),
3234
- decrement: z$1.number().optional(),
3235
- multiply: z$1.number().optional(),
3236
- divide: z$1.number().optional()
3231
+ if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
3232
+ set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
3233
+ increment: z.number().optional(),
3234
+ decrement: z.number().optional(),
3235
+ multiply: z.number().optional(),
3236
+ divide: z.number().optional()
3237
3237
  }).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
3238
3238
  if (fieldDef.array) {
3239
3239
  const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
3240
- fieldSchema = z$1.union([arraySchema, z$1.object({
3240
+ fieldSchema = z.union([arraySchema, z.object({
3241
3241
  set: arraySchema.optional(),
3242
- push: z$1.union([fieldSchema, fieldSchema.array()]).optional()
3242
+ push: z.union([fieldSchema, fieldSchema.array()]).optional()
3243
3243
  }).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
3244
3244
  }
3245
- if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
3245
+ if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
3246
3246
  else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
3247
3247
  else fieldSchema = fieldSchema.nullable();
3248
3248
  fieldSchema = fieldSchema.optional();
@@ -3250,9 +3250,9 @@ var ZodSchemaFactory = class {
3250
3250
  if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
3251
3251
  }
3252
3252
  });
3253
- const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
3254
- const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
3255
- const result = !hasRelation ? uncheckedUpdateSchema : z$1.union([uncheckedUpdateSchema, checkedUpdateSchema]);
3253
+ const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
3254
+ const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
3255
+ const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
3256
3256
  const idParts = [`${model}UpdateData`];
3257
3257
  if (withoutRelationFields) idParts.push("WithoutRelation");
3258
3258
  if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
@@ -3260,7 +3260,7 @@ var ZodSchemaFactory = class {
3260
3260
  return result;
3261
3261
  }
3262
3262
  makeDeleteSchema(model, options) {
3263
- const baseSchema = z$1.strictObject({
3263
+ const baseSchema = z.strictObject({
3264
3264
  where: this.makeWhereSchema(model, true, false, false, options),
3265
3265
  select: this.makeSelectSchema(model, options).optional().nullable(),
3266
3266
  include: this.makeIncludeSchema(model, options).optional().nullable(),
@@ -3274,15 +3274,15 @@ var ZodSchemaFactory = class {
3274
3274
  return schema;
3275
3275
  }
3276
3276
  makeDeleteManySchema(model, options) {
3277
- const result = this.mergePluginArgsSchema(z$1.strictObject({
3277
+ const result = this.mergePluginArgsSchema(z.strictObject({
3278
3278
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3279
- limit: z$1.number().int().nonnegative().optional()
3279
+ limit: z.number().int().nonnegative().optional()
3280
3280
  }), "deleteMany").optional();
3281
3281
  this.registerSchema(`${model}DeleteManyArgs`, result);
3282
3282
  return result;
3283
3283
  }
3284
3284
  makeCountSchema(model, options) {
3285
- const result = this.mergePluginArgsSchema(z$1.strictObject({
3285
+ const result = this.mergePluginArgsSchema(z.strictObject({
3286
3286
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3287
3287
  skip: this.makeSkipSchema().optional(),
3288
3288
  take: this.makeTakeSchema().optional(),
@@ -3293,10 +3293,10 @@ var ZodSchemaFactory = class {
3293
3293
  return result;
3294
3294
  }
3295
3295
  makeCountAggregateInputSchema(model) {
3296
- const schema = z$1.union([z$1.literal(true), z$1.strictObject({
3297
- _all: z$1.literal(true).optional(),
3296
+ const schema = z.union([z.literal(true), z.strictObject({
3297
+ _all: z.literal(true).optional(),
3298
3298
  ...this.getModelFields(model).reduce((acc, [field]) => {
3299
- acc[field] = z$1.literal(true).optional();
3299
+ acc[field] = z.literal(true).optional();
3300
3300
  return acc;
3301
3301
  }, {})
3302
3302
  })]);
@@ -3304,7 +3304,7 @@ var ZodSchemaFactory = class {
3304
3304
  return schema;
3305
3305
  }
3306
3306
  makeAggregateSchema(model, options) {
3307
- const result = this.mergePluginArgsSchema(z$1.strictObject({
3307
+ const result = this.mergePluginArgsSchema(z.strictObject({
3308
3308
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3309
3309
  skip: this.makeSkipSchema().optional(),
3310
3310
  take: this.makeTakeSchema().optional(),
@@ -3319,16 +3319,16 @@ var ZodSchemaFactory = class {
3319
3319
  return result;
3320
3320
  }
3321
3321
  makeSumAvgInputSchema(model) {
3322
- const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3323
- if (this.isNumericField(fieldDef)) acc[field] = z$1.literal(true).optional();
3322
+ const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3323
+ if (this.isNumericField(fieldDef)) acc[field] = z.literal(true).optional();
3324
3324
  return acc;
3325
3325
  }, {}));
3326
3326
  this.registerSchema(`${model}SumAvgAggregateInput`, schema);
3327
3327
  return schema;
3328
3328
  }
3329
3329
  makeMinMaxInputSchema(model) {
3330
- const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3331
- if (!fieldDef.relation && !fieldDef.array) acc[field] = z$1.literal(true).optional();
3330
+ const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3331
+ if (!fieldDef.relation && !fieldDef.array) acc[field] = z.literal(true).optional();
3332
3332
  return acc;
3333
3333
  }, {}));
3334
3334
  this.registerSchema(`${model}MinMaxAggregateInput`, schema);
@@ -3336,8 +3336,8 @@ var ZodSchemaFactory = class {
3336
3336
  }
3337
3337
  makeGroupBySchema(model, options) {
3338
3338
  const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
3339
- const bySchema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
3340
- const baseSchema = z$1.strictObject({
3339
+ const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
3340
+ const baseSchema = z.strictObject({
3341
3341
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3342
3342
  orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
3343
3343
  by: bySchema,
@@ -3389,7 +3389,7 @@ var ZodSchemaFactory = class {
3389
3389
  if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
3390
3390
  const shape = {};
3391
3391
  for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
3392
- const schema = z$1.object(shape);
3392
+ const schema = z.object(shape);
3393
3393
  this.registerSchema(`${procName}ProcArgs`, schema);
3394
3394
  return schema;
3395
3395
  }
@@ -3397,10 +3397,10 @@ var ZodSchemaFactory = class {
3397
3397
  let schema;
3398
3398
  if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
3399
3399
  else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
3400
- else if (param.type in (this.schema.models ?? {})) schema = z$1.record(z$1.string(), z$1.unknown());
3400
+ else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
3401
3401
  else {
3402
3402
  schema = this.makeScalarSchema(param.type);
3403
- if (schema instanceof z$1.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
3403
+ if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
3404
3404
  }
3405
3405
  if (param.array) schema = schema.array();
3406
3406
  if (param.optional) schema = schema.optional();
@@ -3436,10 +3436,10 @@ var ZodSchemaFactory = class {
3436
3436
  return result;
3437
3437
  }
3438
3438
  makeSkipSchema() {
3439
- return z$1.number().int().nonnegative();
3439
+ return z.number().int().nonnegative();
3440
3440
  }
3441
3441
  makeTakeSchema() {
3442
- return z$1.number().int();
3442
+ return z.number().int();
3443
3443
  }
3444
3444
  refineForSelectIncludeMutuallyExclusive(schema) {
3445
3445
  return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
@@ -3458,7 +3458,7 @@ var ZodSchemaFactory = class {
3458
3458
  return nullable ? schema.nullable() : schema;
3459
3459
  }
3460
3460
  orArray(schema, canBeArray) {
3461
- return canBeArray ? z$1.union([schema, z$1.array(schema)]) : schema;
3461
+ return canBeArray ? z.union([schema, z.array(schema)]) : schema;
3462
3462
  }
3463
3463
  isNumericField(fieldDef) {
3464
3464
  return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
@@ -3520,10 +3520,10 @@ var ZodSchemaFactory = class {
3520
3520
  createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
3521
3521
  if (Object.keys(components).length === 0) {
3522
3522
  if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
3523
- return z$1.never();
3523
+ return z.never();
3524
3524
  }
3525
- if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z$1.union([this.nullableIf(valueSchema, optional), z$1.strictObject(components)]);
3526
- else return z$1.strictObject(components);
3525
+ if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
3526
+ else return z.strictObject(components);
3527
3527
  }
3528
3528
  canCreateModel(model) {
3529
3529
  const modelDef = requireModel(this.schema, model);
@@ -7131,9 +7131,9 @@ var ClientImpl = class ClientImpl {
7131
7131
  validateOptions(baseClient, options) {
7132
7132
  if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
7133
7133
  if (options.diagnostics) {
7134
- const parseResult = z.object({
7135
- slowQueryThresholdMs: z.number().nonnegative().optional(),
7136
- slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
7134
+ const parseResult = z$1.object({
7135
+ slowQueryThresholdMs: z$1.number().nonnegative().optional(),
7136
+ slowQueryMaxRecords: z$1.int().nonnegative().or(z$1.literal(Infinity)).optional()
7137
7137
  }).safeParse(options.diagnostics);
7138
7138
  if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
7139
7139
  }