@zenstackhq/orm 3.0.0-beta.25 → 3.0.0-beta.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -602,6 +602,7 @@ import { invariant as invariant3 } from "@zenstackhq/common-helpers";
602
602
  import Decimal from "decimal.js";
603
603
  import { sql as sql2 } from "kysely";
604
604
  import { match as match3 } from "ts-pattern";
605
+ import z from "zod";
605
606
 
606
607
  // src/client/crud/dialects/base-dialect.ts
607
608
  import { enumerate, invariant as invariant2, isPlainObject } from "@zenstackhq/common-helpers";
@@ -1098,7 +1099,7 @@ var BaseCrudDialect = class {
1098
1099
  if (isRelationField(this.schema, model, field)) {
1099
1100
  continue;
1100
1101
  }
1101
- if (omit?.[field] === true) {
1102
+ if (this.shouldOmitField(omit, model, field)) {
1102
1103
  continue;
1103
1104
  }
1104
1105
  result = this.buildSelectField(result, model, modelAlias, field);
@@ -1119,6 +1120,16 @@ var BaseCrudDialect = class {
1119
1120
  }
1120
1121
  return result;
1121
1122
  }
1123
+ shouldOmitField(omit, model, field) {
1124
+ if (omit && typeof omit === "object" && typeof omit[field] === "boolean") {
1125
+ return omit[field];
1126
+ }
1127
+ if (this.options.omit?.[model] && typeof this.options.omit[model] === "object" && typeof this.options.omit[model][field] === "boolean") {
1128
+ return this.options.omit[model][field];
1129
+ }
1130
+ const fieldDef = requireField(this.schema, model, field);
1131
+ return !!fieldDef.omit;
1132
+ }
1122
1133
  buildModelSelect(model, subQueryAlias, payload, selectAllFields) {
1123
1134
  let subQuery = this.buildSelectModel(model, subQueryAlias);
1124
1135
  if (selectAllFields) {
@@ -1261,6 +1272,10 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
1261
1272
  static {
1262
1273
  __name(this, "PostgresCrudDialect");
1263
1274
  }
1275
+ isoDateSchema = z.iso.datetime({
1276
+ local: true,
1277
+ offset: true
1278
+ });
1264
1279
  constructor(schema, options) {
1265
1280
  super(schema, options);
1266
1281
  }
@@ -1309,7 +1324,12 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
1309
1324
  }
1310
1325
  transformOutputDate(value) {
1311
1326
  if (typeof value === "string") {
1312
- return new Date(value);
1327
+ if (this.isoDateSchema.safeParse(value).success) {
1328
+ const hasOffset = value.endsWith("Z") || /[+-]\d{2}:\d{2}$/.test(value);
1329
+ return new Date(hasOffset ? value : `${value}Z`);
1330
+ } else {
1331
+ return value;
1332
+ }
1313
1333
  } else if (value instanceof Date && this.options.fixPostgresTimezone !== false) {
1314
1334
  return new Date(value.getTime() - value.getTimezoneOffset() * 60 * 1e3);
1315
1335
  } else {
@@ -1382,7 +1402,8 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
1382
1402
  ]).flatMap((v) => v));
1383
1403
  }
1384
1404
  if (payload === true || !payload.select) {
1385
- objArgs.push(...Object.entries(relationModelDef.fields).filter(([, value]) => !value.relation).filter(([name]) => !(typeof payload === "object" && payload.omit?.[name] === true)).map(([field]) => [
1405
+ const omit = typeof payload === "object" ? payload.omit : void 0;
1406
+ objArgs.push(...Object.entries(relationModelDef.fields).filter(([, value]) => !value.relation).filter(([name]) => !this.shouldOmitField(omit, relationModel, name)).map(([field]) => [
1386
1407
  sql2.lit(field),
1387
1408
  this.fieldRef(relationModel, field, relationModelAlias, false)
1388
1409
  ]).flatMap((v) => v));
@@ -1593,7 +1614,8 @@ var SqliteCrudDialect = class extends BaseCrudDialect {
1593
1614
  ]).flatMap((v) => v));
1594
1615
  }
1595
1616
  if (payload === true || !payload.select) {
1596
- objArgs.push(...Object.entries(relationModelDef.fields).filter(([, value]) => !value.relation).filter(([name]) => !(typeof payload === "object" && payload.omit?.[name] === true)).map(([field]) => [
1617
+ const omit = typeof payload === "object" ? payload.omit : void 0;
1618
+ objArgs.push(...Object.entries(relationModelDef.fields).filter(([, value]) => !value.relation).filter(([name]) => !this.shouldOmitField(omit, relationModel, name)).map(([field]) => [
1597
1619
  sql3.lit(field),
1598
1620
  this.fieldRef(relationModel, field, subQueryName, false)
1599
1621
  ]).flatMap((v) => v));
@@ -3069,12 +3091,11 @@ var BaseOperationHandler = class {
3069
3091
  const allFields = Object.keys(modelDef.fields);
3070
3092
  const relationFields = Object.values(modelDef.fields).filter((f) => f.relation).map((f) => f.name);
3071
3093
  const computedFields = Object.values(modelDef.fields).filter((f) => f.computed).map((f) => f.name);
3072
- const omit = Object.entries(args.omit ?? {}).filter(([, v]) => v).map(([k]) => k);
3073
3094
  const allFieldsSelected = [];
3074
3095
  if (!args.select || typeof args.select !== "object") {
3075
- allFieldsSelected.push(...allFields.filter((f) => !relationFields.includes(f) && !omit.includes(f)));
3096
+ allFieldsSelected.push(...allFields.filter((f) => !relationFields.includes(f) && !this.dialect.shouldOmitField(args.omit, model, f)));
3076
3097
  } else {
3077
- allFieldsSelected.push(...Object.entries(args.select).filter(([k, v]) => v && !omit.includes(k)).map(([k]) => k));
3098
+ allFieldsSelected.push(...Object.entries(args.select).filter(([k, v]) => v && !this.dialect.shouldOmitField(args.omit, model, k)).map(([k]) => k));
3078
3099
  }
3079
3100
  if (allFieldsSelected.some((f) => relationFields.includes(f) || computedFields.includes(f))) {
3080
3101
  return {
@@ -3590,7 +3611,7 @@ import { enumerate as enumerate3, invariant as invariant7 } from "@zenstackhq/co
3590
3611
  import Decimal4 from "decimal.js";
3591
3612
  import stableStringify from "json-stable-stringify";
3592
3613
  import { match as match13, P as P3 } from "ts-pattern";
3593
- import { z as z2 } from "zod";
3614
+ import { z as z3 } from "zod";
3594
3615
 
3595
3616
  // src/utils/zod-utils.ts
3596
3617
  import { fromError } from "zod-validation-error/v4";
@@ -3603,7 +3624,7 @@ __name(formatError, "formatError");
3603
3624
  import { invariant as invariant6 } from "@zenstackhq/common-helpers";
3604
3625
  import Decimal3 from "decimal.js";
3605
3626
  import { match as match12, P as P2 } from "ts-pattern";
3606
- import { z } from "zod";
3627
+ import { z as z2 } from "zod";
3607
3628
  import { ZodIssueCode } from "zod/v3";
3608
3629
  function getArgValue(expr) {
3609
3630
  if (!expr || !schema_exports.ExpressionUtils.isLiteral(expr)) {
@@ -3712,13 +3733,13 @@ function addBigIntValidation(schema, attributes) {
3712
3733
  __name(addBigIntValidation, "addBigIntValidation");
3713
3734
  function addDecimalValidation(schema, attributes, addExtraValidation) {
3714
3735
  let result = schema;
3715
- if (schema instanceof z.ZodString) {
3736
+ if (schema instanceof z2.ZodString) {
3716
3737
  result = schema.superRefine((v, ctx) => {
3717
3738
  try {
3718
3739
  new Decimal3(v);
3719
3740
  } catch (err) {
3720
3741
  ctx.addIssue({
3721
- code: z.ZodIssueCode.custom,
3742
+ code: z2.ZodIssueCode.custom,
3722
3743
  message: `Invalid decimal: ${err}`
3723
3744
  });
3724
3745
  }
@@ -3726,7 +3747,7 @@ function addDecimalValidation(schema, attributes, addExtraValidation) {
3726
3747
  }
3727
3748
  function refine(schema2, op, value) {
3728
3749
  return schema2.superRefine((v, ctx) => {
3729
- const base = z.number();
3750
+ const base = z2.number();
3730
3751
  const { error } = base[op](value).safeParse(v.toNumber());
3731
3752
  error?.issues.forEach((issue) => {
3732
3753
  if (op === "gt" || op === "gte") {
@@ -3931,7 +3952,7 @@ function evalCall(data, expr) {
3931
3952
  }
3932
3953
  invariant6(typeof fieldArg === "string", `"${f}" first argument must be a string`);
3933
3954
  const fn = match12(f).with("isEmail", () => "email").with("isUrl", () => "url").with("isDateTime", () => "datetime").exhaustive();
3934
- return z.string()[fn]().safeParse(fieldArg).success;
3955
+ return z2.string()[fn]().safeParse(fieldArg).success;
3935
3956
  }).with(P2.union("has", "hasEvery", "hasSome"), (f) => {
3936
3957
  invariant6(expr.args?.[1], `${f} requires a search argument`);
3937
3958
  if (fieldArg === void 0 || fieldArg === null) {
@@ -3972,6 +3993,9 @@ var InputValidator = class {
3972
3993
  get schema() {
3973
3994
  return this.client.$schema;
3974
3995
  }
3996
+ get options() {
3997
+ return this.client.$options;
3998
+ }
3975
3999
  get extraValidationsEnabled() {
3976
4000
  return this.client.$options.validateInput !== false;
3977
4001
  }
@@ -4066,7 +4090,7 @@ var InputValidator = class {
4066
4090
  if (!options.unique) {
4067
4091
  fields["skip"] = this.makeSkipSchema().optional();
4068
4092
  if (options.findOne) {
4069
- fields["take"] = z2.literal(1).optional();
4093
+ fields["take"] = z3.literal(1).optional();
4070
4094
  } else {
4071
4095
  fields["take"] = this.makeTakeSchema().optional();
4072
4096
  }
@@ -4074,7 +4098,7 @@ var InputValidator = class {
4074
4098
  fields["cursor"] = this.makeCursorSchema(model).optional();
4075
4099
  fields["distinct"] = this.makeDistinctSchema(model).optional();
4076
4100
  }
4077
- let result = z2.strictObject(fields);
4101
+ let result = z3.strictObject(fields);
4078
4102
  result = this.refineForSelectIncludeMutuallyExclusive(result);
4079
4103
  result = this.refineForSelectOmitMutuallyExclusive(result);
4080
4104
  if (!options.unique) {
@@ -4088,19 +4112,19 @@ var InputValidator = class {
4088
4112
  } else if (this.schema.enums && type in this.schema.enums) {
4089
4113
  return this.makeEnumSchema(type);
4090
4114
  } else {
4091
- return match13(type).with("String", () => this.extraValidationsEnabled ? addStringValidation(z2.string(), attributes) : z2.string()).with("Int", () => this.extraValidationsEnabled ? addNumberValidation(z2.number().int(), attributes) : z2.number().int()).with("Float", () => this.extraValidationsEnabled ? addNumberValidation(z2.number(), attributes) : z2.number()).with("Boolean", () => z2.boolean()).with("BigInt", () => z2.union([
4092
- this.extraValidationsEnabled ? addNumberValidation(z2.number().int(), attributes) : z2.number().int(),
4093
- this.extraValidationsEnabled ? addBigIntValidation(z2.bigint(), attributes) : z2.bigint()
4115
+ return match13(type).with("String", () => this.extraValidationsEnabled ? addStringValidation(z3.string(), attributes) : z3.string()).with("Int", () => this.extraValidationsEnabled ? addNumberValidation(z3.number().int(), attributes) : z3.number().int()).with("Float", () => this.extraValidationsEnabled ? addNumberValidation(z3.number(), attributes) : z3.number()).with("Boolean", () => z3.boolean()).with("BigInt", () => z3.union([
4116
+ this.extraValidationsEnabled ? addNumberValidation(z3.number().int(), attributes) : z3.number().int(),
4117
+ this.extraValidationsEnabled ? addBigIntValidation(z3.bigint(), attributes) : z3.bigint()
4094
4118
  ])).with("Decimal", () => {
4095
- return z2.union([
4096
- this.extraValidationsEnabled ? addNumberValidation(z2.number(), attributes) : z2.number(),
4097
- addDecimalValidation(z2.instanceof(Decimal4), attributes, this.extraValidationsEnabled),
4098
- addDecimalValidation(z2.string(), attributes, this.extraValidationsEnabled)
4119
+ return z3.union([
4120
+ this.extraValidationsEnabled ? addNumberValidation(z3.number(), attributes) : z3.number(),
4121
+ addDecimalValidation(z3.instanceof(Decimal4), attributes, this.extraValidationsEnabled),
4122
+ addDecimalValidation(z3.string(), attributes, this.extraValidationsEnabled)
4099
4123
  ]);
4100
- }).with("DateTime", () => z2.union([
4101
- z2.date(),
4102
- z2.string().datetime()
4103
- ])).with("Bytes", () => z2.instanceof(Uint8Array)).otherwise(() => z2.unknown());
4124
+ }).with("DateTime", () => z3.union([
4125
+ z3.date(),
4126
+ z3.string().datetime()
4127
+ ])).with("Bytes", () => z3.instanceof(Uint8Array)).otherwise(() => z3.unknown());
4104
4128
  }
4105
4129
  }
4106
4130
  makeEnumSchema(type) {
@@ -4114,7 +4138,7 @@ var InputValidator = class {
4114
4138
  }
4115
4139
  const enumDef = getEnum(this.schema, type);
4116
4140
  invariant7(enumDef, `Enum "${type}" not found in schema`);
4117
- schema = z2.enum(Object.keys(enumDef.values));
4141
+ schema = z3.enum(Object.keys(enumDef.values));
4118
4142
  this.setSchemaCache(key, schema);
4119
4143
  return schema;
4120
4144
  }
@@ -4130,7 +4154,7 @@ var InputValidator = class {
4130
4154
  }
4131
4155
  const typeDef = getTypeDef(this.schema, type);
4132
4156
  invariant7(typeDef, `Type definition "${type}" not found in schema`);
4133
- schema = z2.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
4157
+ schema = z3.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
4134
4158
  let fieldSchema = this.makePrimitiveSchema(def.type);
4135
4159
  if (def.array) {
4136
4160
  fieldSchema = fieldSchema.array();
@@ -4156,21 +4180,21 @@ var InputValidator = class {
4156
4180
  if (withoutRelationFields) {
4157
4181
  continue;
4158
4182
  }
4159
- fieldSchema = z2.lazy(() => this.makeWhereSchema(fieldDef.type, false).optional());
4183
+ fieldSchema = z3.lazy(() => this.makeWhereSchema(fieldDef.type, false).optional());
4160
4184
  fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
4161
4185
  if (fieldDef.array) {
4162
- fieldSchema = z2.union([
4186
+ fieldSchema = z3.union([
4163
4187
  fieldSchema,
4164
- z2.strictObject({
4188
+ z3.strictObject({
4165
4189
  some: fieldSchema.optional(),
4166
4190
  every: fieldSchema.optional(),
4167
4191
  none: fieldSchema.optional()
4168
4192
  })
4169
4193
  ]);
4170
4194
  } else {
4171
- fieldSchema = z2.union([
4195
+ fieldSchema = z3.union([
4172
4196
  fieldSchema,
4173
- z2.strictObject({
4197
+ z3.strictObject({
4174
4198
  is: fieldSchema.optional(),
4175
4199
  isNot: fieldSchema.optional()
4176
4200
  })
@@ -4196,7 +4220,7 @@ var InputValidator = class {
4196
4220
  const uniqueFields = getUniqueFields(this.schema, model);
4197
4221
  for (const uniqueField of uniqueFields) {
4198
4222
  if ("defs" in uniqueField) {
4199
- fields[uniqueField.name] = z2.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
4223
+ fields[uniqueField.name] = z3.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
4200
4224
  invariant7(!def.relation, "unique field cannot be a relation");
4201
4225
  let fieldSchema;
4202
4226
  const enumDef = getEnum(this.schema, def.type);
@@ -4204,7 +4228,7 @@ var InputValidator = class {
4204
4228
  if (Object.keys(enumDef.values).length > 0) {
4205
4229
  fieldSchema = this.makeEnumFilterSchema(enumDef, !!def.optional, false);
4206
4230
  } else {
4207
- fieldSchema = z2.never();
4231
+ fieldSchema = z3.never();
4208
4232
  }
4209
4233
  } else {
4210
4234
  fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false);
@@ -4217,11 +4241,11 @@ var InputValidator = class {
4217
4241
  }
4218
4242
  }
4219
4243
  }
4220
- fields["$expr"] = z2.custom((v) => typeof v === "function").optional();
4221
- fields["AND"] = this.orArray(z2.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)), true).optional();
4222
- fields["OR"] = z2.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)).array().optional();
4223
- fields["NOT"] = this.orArray(z2.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)), true).optional();
4224
- const baseWhere = z2.strictObject(fields);
4244
+ fields["$expr"] = z3.custom((v) => typeof v === "function").optional();
4245
+ fields["AND"] = this.orArray(z3.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)), true).optional();
4246
+ fields["OR"] = z3.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)).array().optional();
4247
+ fields["NOT"] = this.orArray(z3.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)), true).optional();
4248
+ const baseWhere = z3.strictObject(fields);
4225
4249
  let result = baseWhere;
4226
4250
  if (unique) {
4227
4251
  const uniqueFields = getUniqueFields(this.schema, model);
@@ -4241,8 +4265,8 @@ var InputValidator = class {
4241
4265
  return result;
4242
4266
  }
4243
4267
  makeEnumFilterSchema(enumDef, optional, withAggregations) {
4244
- const baseSchema = z2.enum(Object.keys(enumDef.values));
4245
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z2.lazy(() => this.makeEnumFilterSchema(enumDef, optional, withAggregations)), [
4268
+ const baseSchema = z3.enum(Object.keys(enumDef.values));
4269
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z3.lazy(() => this.makeEnumFilterSchema(enumDef, optional, withAggregations)), [
4246
4270
  "equals",
4247
4271
  "in",
4248
4272
  "notIn",
@@ -4252,41 +4276,41 @@ var InputValidator = class {
4252
4276
  "_min",
4253
4277
  "_max"
4254
4278
  ] : void 0);
4255
- return z2.union([
4279
+ return z3.union([
4256
4280
  this.nullableIf(baseSchema, optional),
4257
- z2.strictObject(components)
4281
+ z3.strictObject(components)
4258
4282
  ]);
4259
4283
  }
4260
4284
  makeArrayFilterSchema(type) {
4261
- return z2.strictObject({
4285
+ return z3.strictObject({
4262
4286
  equals: this.makePrimitiveSchema(type).array().optional(),
4263
4287
  has: this.makePrimitiveSchema(type).optional(),
4264
4288
  hasEvery: this.makePrimitiveSchema(type).array().optional(),
4265
4289
  hasSome: this.makePrimitiveSchema(type).array().optional(),
4266
- isEmpty: z2.boolean().optional()
4290
+ isEmpty: z3.boolean().optional()
4267
4291
  });
4268
4292
  }
4269
4293
  makePrimitiveFilterSchema(type, optional, withAggregations) {
4270
4294
  if (this.schema.typeDefs && type in this.schema.typeDefs) {
4271
4295
  return this.makeTypeDefFilterSchema(type, optional);
4272
4296
  }
4273
- return match13(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations)).with(P3.union("Int", "Float", "Decimal", "BigInt"), (type2) => this.makeNumberFilterSchema(this.makePrimitiveSchema(type2), optional, withAggregations)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations)).with("Json", () => z2.any()).with("Unsupported", () => z2.never()).exhaustive();
4297
+ return match13(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations)).with(P3.union("Int", "Float", "Decimal", "BigInt"), (type2) => this.makeNumberFilterSchema(this.makePrimitiveSchema(type2), optional, withAggregations)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations)).with("Json", () => z3.any()).with("Unsupported", () => z3.never()).exhaustive();
4274
4298
  }
4275
4299
  makeTypeDefFilterSchema(_type, _optional) {
4276
- return z2.never();
4300
+ return z3.never();
4277
4301
  }
4278
4302
  makeDateTimeFilterSchema(optional, withAggregations) {
4279
- return this.makeCommonPrimitiveFilterSchema(z2.union([
4280
- z2.string().datetime(),
4281
- z2.date()
4282
- ]), optional, () => z2.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations)), withAggregations ? [
4303
+ return this.makeCommonPrimitiveFilterSchema(z3.union([
4304
+ z3.string().datetime(),
4305
+ z3.date()
4306
+ ]), optional, () => z3.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations)), withAggregations ? [
4283
4307
  "_count",
4284
4308
  "_min",
4285
4309
  "_max"
4286
4310
  ] : void 0);
4287
4311
  }
4288
4312
  makeBooleanFilterSchema(optional, withAggregations) {
4289
- const components = this.makeCommonPrimitiveFilterComponents(z2.boolean(), optional, () => z2.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations)), [
4313
+ const components = this.makeCommonPrimitiveFilterComponents(z3.boolean(), optional, () => z3.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations)), [
4290
4314
  "equals",
4291
4315
  "not"
4292
4316
  ], withAggregations ? [
@@ -4294,14 +4318,14 @@ var InputValidator = class {
4294
4318
  "_min",
4295
4319
  "_max"
4296
4320
  ] : void 0);
4297
- return z2.union([
4298
- this.nullableIf(z2.boolean(), optional),
4299
- z2.strictObject(components)
4321
+ return z3.union([
4322
+ this.nullableIf(z3.boolean(), optional),
4323
+ z3.strictObject(components)
4300
4324
  ]);
4301
4325
  }
4302
4326
  makeBytesFilterSchema(optional, withAggregations) {
4303
- const baseSchema = z2.instanceof(Uint8Array);
4304
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z2.instanceof(Uint8Array), [
4327
+ const baseSchema = z3.instanceof(Uint8Array);
4328
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z3.instanceof(Uint8Array), [
4305
4329
  "equals",
4306
4330
  "in",
4307
4331
  "notIn",
@@ -4311,9 +4335,9 @@ var InputValidator = class {
4311
4335
  "_min",
4312
4336
  "_max"
4313
4337
  ] : void 0);
4314
- return z2.union([
4338
+ return z3.union([
4315
4339
  this.nullableIf(baseSchema, optional),
4316
- z2.strictObject(components)
4340
+ z3.strictObject(components)
4317
4341
  ]);
4318
4342
  }
4319
4343
  makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, supportedOperators = void 0, withAggregations = void 0) {
@@ -4329,7 +4353,7 @@ var InputValidator = class {
4329
4353
  gte: baseSchema.optional(),
4330
4354
  not: makeThis().optional(),
4331
4355
  ...withAggregations?.includes("_count") ? {
4332
- _count: this.makeNumberFilterSchema(z2.number().int(), false, false).optional()
4356
+ _count: this.makeNumberFilterSchema(z3.number().int(), false, false).optional()
4333
4357
  } : {},
4334
4358
  ...withAggregations?.includes("_avg") ? {
4335
4359
  _avg: commonAggSchema()
@@ -4354,13 +4378,13 @@ var InputValidator = class {
4354
4378
  return result;
4355
4379
  }
4356
4380
  makeCommonPrimitiveFilterSchema(baseSchema, optional, makeThis, withAggregations = void 0) {
4357
- return z2.union([
4381
+ return z3.union([
4358
4382
  this.nullableIf(baseSchema, optional),
4359
- z2.strictObject(this.makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, void 0, withAggregations))
4383
+ z3.strictObject(this.makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, void 0, withAggregations))
4360
4384
  ]);
4361
4385
  }
4362
4386
  makeNumberFilterSchema(baseSchema, optional, withAggregations) {
4363
- return this.makeCommonPrimitiveFilterSchema(baseSchema, optional, () => z2.lazy(() => this.makeNumberFilterSchema(baseSchema, optional, withAggregations)), withAggregations ? [
4387
+ return this.makeCommonPrimitiveFilterSchema(baseSchema, optional, () => z3.lazy(() => this.makeNumberFilterSchema(baseSchema, optional, withAggregations)), withAggregations ? [
4364
4388
  "_count",
4365
4389
  "_avg",
4366
4390
  "_sum",
@@ -4369,17 +4393,17 @@ var InputValidator = class {
4369
4393
  ] : void 0);
4370
4394
  }
4371
4395
  makeStringFilterSchema(optional, withAggregations) {
4372
- return z2.union([
4373
- this.nullableIf(z2.string(), optional),
4374
- z2.strictObject({
4375
- ...this.makeCommonPrimitiveFilterComponents(z2.string(), optional, () => z2.lazy(() => this.makeStringFilterSchema(optional, withAggregations)), void 0, withAggregations ? [
4396
+ return z3.union([
4397
+ this.nullableIf(z3.string(), optional),
4398
+ z3.strictObject({
4399
+ ...this.makeCommonPrimitiveFilterComponents(z3.string(), optional, () => z3.lazy(() => this.makeStringFilterSchema(optional, withAggregations)), void 0, withAggregations ? [
4376
4400
  "_count",
4377
4401
  "_min",
4378
4402
  "_max"
4379
4403
  ] : void 0),
4380
- startsWith: z2.string().optional(),
4381
- endsWith: z2.string().optional(),
4382
- contains: z2.string().optional(),
4404
+ startsWith: z3.string().optional(),
4405
+ endsWith: z3.string().optional(),
4406
+ contains: z3.string().optional(),
4383
4407
  ...this.providerSupportsCaseSensitivity ? {
4384
4408
  mode: this.makeStringModeSchema().optional()
4385
4409
  } : {}
@@ -4387,9 +4411,9 @@ var InputValidator = class {
4387
4411
  ]);
4388
4412
  }
4389
4413
  makeStringModeSchema() {
4390
- return z2.union([
4391
- z2.literal("default"),
4392
- z2.literal("insensitive")
4414
+ return z3.union([
4415
+ z3.literal("default"),
4416
+ z3.literal("insensitive")
4393
4417
  ]);
4394
4418
  }
4395
4419
  makeSelectSchema(model) {
@@ -4400,26 +4424,26 @@ var InputValidator = class {
4400
4424
  if (fieldDef.relation) {
4401
4425
  fields[field] = this.makeRelationSelectIncludeSchema(fieldDef).optional();
4402
4426
  } else {
4403
- fields[field] = z2.boolean().optional();
4427
+ fields[field] = z3.boolean().optional();
4404
4428
  }
4405
4429
  }
4406
4430
  const _countSchema = this.makeCountSelectionSchema(modelDef);
4407
4431
  if (_countSchema) {
4408
4432
  fields["_count"] = _countSchema;
4409
4433
  }
4410
- return z2.strictObject(fields);
4434
+ return z3.strictObject(fields);
4411
4435
  }
4412
4436
  makeCountSelectionSchema(modelDef) {
4413
4437
  const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
4414
4438
  if (toManyRelations.length > 0) {
4415
- return z2.union([
4416
- z2.literal(true),
4417
- z2.strictObject({
4418
- select: z2.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
4439
+ return z3.union([
4440
+ z3.literal(true),
4441
+ z3.strictObject({
4442
+ select: z3.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
4419
4443
  ...acc,
4420
- [fieldDef.name]: z2.union([
4421
- z2.boolean(),
4422
- z2.strictObject({
4444
+ [fieldDef.name]: z3.union([
4445
+ z3.boolean(),
4446
+ z3.strictObject({
4423
4447
  where: this.makeWhereSchema(fieldDef.type, false, false)
4424
4448
  })
4425
4449
  ]).optional()
@@ -4431,17 +4455,17 @@ var InputValidator = class {
4431
4455
  }
4432
4456
  }
4433
4457
  makeRelationSelectIncludeSchema(fieldDef) {
4434
- let objSchema = z2.strictObject({
4458
+ let objSchema = z3.strictObject({
4435
4459
  ...fieldDef.array || fieldDef.optional ? {
4436
4460
  // to-many relations and optional to-one relations are filterable
4437
- where: z2.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional()
4461
+ where: z3.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional()
4438
4462
  } : {},
4439
- select: z2.lazy(() => this.makeSelectSchema(fieldDef.type)).optional().nullable(),
4440
- include: z2.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional().nullable(),
4441
- omit: z2.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
4463
+ select: z3.lazy(() => this.makeSelectSchema(fieldDef.type)).optional().nullable(),
4464
+ include: z3.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional().nullable(),
4465
+ omit: z3.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
4442
4466
  ...fieldDef.array ? {
4443
4467
  // to-many relations can be ordered, skipped, taken, and cursor-located
4444
- orderBy: z2.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false), true)).optional(),
4468
+ orderBy: z3.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false), true)).optional(),
4445
4469
  skip: this.makeSkipSchema().optional(),
4446
4470
  take: this.makeTakeSchema().optional(),
4447
4471
  cursor: this.makeCursorSchema(fieldDef.type).optional(),
@@ -4450,8 +4474,8 @@ var InputValidator = class {
4450
4474
  });
4451
4475
  objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
4452
4476
  objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
4453
- return z2.union([
4454
- z2.boolean(),
4477
+ return z3.union([
4478
+ z3.boolean(),
4455
4479
  objSchema
4456
4480
  ]);
4457
4481
  }
@@ -4461,10 +4485,14 @@ var InputValidator = class {
4461
4485
  for (const field of Object.keys(modelDef.fields)) {
4462
4486
  const fieldDef = requireField(this.schema, model, field);
4463
4487
  if (!fieldDef.relation) {
4464
- fields[field] = z2.boolean().optional();
4488
+ if (this.options.allowQueryTimeOmitOverride !== false) {
4489
+ fields[field] = z3.boolean().optional();
4490
+ } else {
4491
+ fields[field] = z3.literal(true).optional();
4492
+ }
4465
4493
  }
4466
4494
  }
4467
- return z2.strictObject(fields);
4495
+ return z3.strictObject(fields);
4468
4496
  }
4469
4497
  makeIncludeSchema(model) {
4470
4498
  const modelDef = requireModel(this.schema, model);
@@ -4479,20 +4507,20 @@ var InputValidator = class {
4479
4507
  if (_countSchema) {
4480
4508
  fields["_count"] = _countSchema;
4481
4509
  }
4482
- return z2.strictObject(fields);
4510
+ return z3.strictObject(fields);
4483
4511
  }
4484
4512
  makeOrderBySchema(model, withRelation, WithAggregation) {
4485
4513
  const modelDef = requireModel(this.schema, model);
4486
4514
  const fields = {};
4487
- const sort = z2.union([
4488
- z2.literal("asc"),
4489
- z2.literal("desc")
4515
+ const sort = z3.union([
4516
+ z3.literal("asc"),
4517
+ z3.literal("desc")
4490
4518
  ]);
4491
4519
  for (const field of Object.keys(modelDef.fields)) {
4492
4520
  const fieldDef = requireField(this.schema, model, field);
4493
4521
  if (fieldDef.relation) {
4494
4522
  if (withRelation) {
4495
- fields[field] = z2.lazy(() => {
4523
+ fields[field] = z3.lazy(() => {
4496
4524
  let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation);
4497
4525
  if (fieldDef.array) {
4498
4526
  relationOrderBy = relationOrderBy.extend({
@@ -4504,13 +4532,13 @@ var InputValidator = class {
4504
4532
  }
4505
4533
  } else {
4506
4534
  if (fieldDef.optional) {
4507
- fields[field] = z2.union([
4535
+ fields[field] = z3.union([
4508
4536
  sort,
4509
- z2.strictObject({
4537
+ z3.strictObject({
4510
4538
  sort,
4511
- nulls: z2.union([
4512
- z2.literal("first"),
4513
- z2.literal("last")
4539
+ nulls: z3.union([
4540
+ z3.literal("first"),
4541
+ z3.literal("last")
4514
4542
  ])
4515
4543
  })
4516
4544
  ]).optional();
@@ -4528,15 +4556,15 @@ var InputValidator = class {
4528
4556
  "_max"
4529
4557
  ];
4530
4558
  for (const agg of aggregationFields) {
4531
- fields[agg] = z2.lazy(() => this.makeOrderBySchema(model, true, false).optional());
4559
+ fields[agg] = z3.lazy(() => this.makeOrderBySchema(model, true, false).optional());
4532
4560
  }
4533
4561
  }
4534
- return z2.strictObject(fields);
4562
+ return z3.strictObject(fields);
4535
4563
  }
4536
4564
  makeDistinctSchema(model) {
4537
4565
  const modelDef = requireModel(this.schema, model);
4538
4566
  const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation);
4539
- return this.orArray(z2.enum(nonRelationFields), true);
4567
+ return this.orArray(z3.enum(nonRelationFields), true);
4540
4568
  }
4541
4569
  makeCursorSchema(model) {
4542
4570
  return this.makeWhereSchema(model, true, true).optional();
@@ -4545,7 +4573,7 @@ var InputValidator = class {
4545
4573
  // #region Create
4546
4574
  makeCreateSchema(model) {
4547
4575
  const dataSchema = this.makeCreateDataSchema(model, false);
4548
- let schema = z2.strictObject({
4576
+ let schema = z3.strictObject({
4549
4577
  data: dataSchema,
4550
4578
  select: this.makeSelectSchema(model).optional().nullable(),
4551
4579
  include: this.makeIncludeSchema(model).optional().nullable(),
@@ -4595,7 +4623,7 @@ var InputValidator = class {
4595
4623
  excludeFields.push(...oppositeFieldDef.relation.fields);
4596
4624
  }
4597
4625
  }
4598
- let fieldSchema = z2.lazy(() => this.makeRelationManipulationSchema(fieldDef, excludeFields, "create"));
4626
+ let fieldSchema = z3.lazy(() => this.makeRelationManipulationSchema(fieldDef, excludeFields, "create"));
4599
4627
  if (fieldDef.optional || fieldDef.array) {
4600
4628
  fieldSchema = fieldSchema.optional();
4601
4629
  } else {
@@ -4621,9 +4649,9 @@ var InputValidator = class {
4621
4649
  let fieldSchema = this.makePrimitiveSchema(fieldDef.type, fieldDef.attributes);
4622
4650
  if (fieldDef.array) {
4623
4651
  fieldSchema = addListValidation(fieldSchema.array(), fieldDef.attributes);
4624
- fieldSchema = z2.union([
4652
+ fieldSchema = z3.union([
4625
4653
  fieldSchema,
4626
- z2.strictObject({
4654
+ z3.strictObject({
4627
4655
  set: fieldSchema
4628
4656
  })
4629
4657
  ]).optional();
@@ -4640,19 +4668,19 @@ var InputValidator = class {
4640
4668
  }
4641
4669
  }
4642
4670
  });
4643
- const uncheckedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(z2.strictObject(uncheckedVariantFields), modelDef.attributes) : z2.strictObject(uncheckedVariantFields);
4644
- const checkedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(z2.strictObject(checkedVariantFields), modelDef.attributes) : z2.strictObject(checkedVariantFields);
4671
+ const uncheckedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(z3.strictObject(uncheckedVariantFields), modelDef.attributes) : z3.strictObject(uncheckedVariantFields);
4672
+ const checkedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(z3.strictObject(checkedVariantFields), modelDef.attributes) : z3.strictObject(checkedVariantFields);
4645
4673
  if (!hasRelation) {
4646
4674
  return this.orArray(uncheckedCreateSchema, canBeArray);
4647
4675
  } else {
4648
- return z2.union([
4676
+ return z3.union([
4649
4677
  uncheckedCreateSchema,
4650
4678
  checkedCreateSchema,
4651
4679
  ...canBeArray ? [
4652
- z2.array(uncheckedCreateSchema)
4680
+ z3.array(uncheckedCreateSchema)
4653
4681
  ] : [],
4654
4682
  ...canBeArray ? [
4655
- z2.array(checkedCreateSchema)
4683
+ z3.array(checkedCreateSchema)
4656
4684
  ] : []
4657
4685
  ]);
4658
4686
  }
@@ -4680,11 +4708,11 @@ var InputValidator = class {
4680
4708
  fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array).optional();
4681
4709
  fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true).optional();
4682
4710
  }
4683
- fields["update"] = array ? this.orArray(z2.strictObject({
4711
+ fields["update"] = array ? this.orArray(z3.strictObject({
4684
4712
  where: this.makeWhereSchema(fieldType, true).optional(),
4685
4713
  data: this.makeUpdateDataSchema(fieldType, withoutFields)
4686
- }), true).optional() : z2.union([
4687
- z2.strictObject({
4714
+ }), true).optional() : z3.union([
4715
+ z3.strictObject({
4688
4716
  where: this.makeWhereSchema(fieldType, true).optional(),
4689
4717
  data: this.makeUpdateDataSchema(fieldType, withoutFields)
4690
4718
  }),
@@ -4694,21 +4722,21 @@ var InputValidator = class {
4694
4722
  if (!fieldDef.array) {
4695
4723
  upsertWhere = upsertWhere.optional();
4696
4724
  }
4697
- fields["upsert"] = this.orArray(z2.strictObject({
4725
+ fields["upsert"] = this.orArray(z3.strictObject({
4698
4726
  where: upsertWhere,
4699
4727
  create: this.makeCreateDataSchema(fieldType, false, withoutFields),
4700
4728
  update: this.makeUpdateDataSchema(fieldType, withoutFields)
4701
4729
  }), true).optional();
4702
4730
  if (array) {
4703
4731
  fields["set"] = this.makeSetDataSchema(fieldType, true).optional();
4704
- fields["updateMany"] = this.orArray(z2.strictObject({
4732
+ fields["updateMany"] = this.orArray(z3.strictObject({
4705
4733
  where: this.makeWhereSchema(fieldType, false, true),
4706
4734
  data: this.makeUpdateDataSchema(fieldType, withoutFields)
4707
4735
  }), true).optional();
4708
4736
  fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false).optional();
4709
4737
  }
4710
4738
  }
4711
- return z2.strictObject(fields);
4739
+ return z3.strictObject(fields);
4712
4740
  }
4713
4741
  makeSetDataSchema(model, canBeArray) {
4714
4742
  return this.orArray(this.makeWhereSchema(model, true), canBeArray);
@@ -4720,36 +4748,36 @@ var InputValidator = class {
4720
4748
  if (canBeArray) {
4721
4749
  return this.orArray(this.makeWhereSchema(model, true), canBeArray);
4722
4750
  } else {
4723
- return z2.union([
4724
- z2.boolean(),
4751
+ return z3.union([
4752
+ z3.boolean(),
4725
4753
  this.makeWhereSchema(model, false)
4726
4754
  ]);
4727
4755
  }
4728
4756
  }
4729
4757
  makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter) {
4730
- return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter), true) : z2.union([
4731
- z2.boolean(),
4758
+ return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter), true) : z3.union([
4759
+ z3.boolean(),
4732
4760
  this.makeWhereSchema(model, uniqueFilter)
4733
4761
  ]);
4734
4762
  }
4735
4763
  makeConnectOrCreateDataSchema(model, canBeArray, withoutFields) {
4736
4764
  const whereSchema = this.makeWhereSchema(model, true);
4737
4765
  const createSchema = this.makeCreateDataSchema(model, false, withoutFields);
4738
- return this.orArray(z2.strictObject({
4766
+ return this.orArray(z3.strictObject({
4739
4767
  where: whereSchema,
4740
4768
  create: createSchema
4741
4769
  }), canBeArray);
4742
4770
  }
4743
4771
  makeCreateManyDataSchema(model, withoutFields) {
4744
- return z2.strictObject({
4772
+ return z3.strictObject({
4745
4773
  data: this.makeCreateDataSchema(model, true, withoutFields, true),
4746
- skipDuplicates: z2.boolean().optional()
4774
+ skipDuplicates: z3.boolean().optional()
4747
4775
  });
4748
4776
  }
4749
4777
  // #endregion
4750
4778
  // #region Update
4751
4779
  makeUpdateSchema(model) {
4752
- let schema = z2.strictObject({
4780
+ let schema = z3.strictObject({
4753
4781
  where: this.makeWhereSchema(model, true),
4754
4782
  data: this.makeUpdateDataSchema(model),
4755
4783
  select: this.makeSelectSchema(model).optional().nullable(),
@@ -4761,10 +4789,10 @@ var InputValidator = class {
4761
4789
  return schema;
4762
4790
  }
4763
4791
  makeUpdateManySchema(model) {
4764
- return z2.strictObject({
4792
+ return z3.strictObject({
4765
4793
  where: this.makeWhereSchema(model, false).optional(),
4766
4794
  data: this.makeUpdateDataSchema(model, [], true),
4767
- limit: z2.number().int().nonnegative().optional()
4795
+ limit: z3.number().int().nonnegative().optional()
4768
4796
  });
4769
4797
  }
4770
4798
  makeUpdateManyAndReturnSchema(model) {
@@ -4777,7 +4805,7 @@ var InputValidator = class {
4777
4805
  return schema;
4778
4806
  }
4779
4807
  makeUpsertSchema(model) {
4780
- let schema = z2.strictObject({
4808
+ let schema = z3.strictObject({
4781
4809
  where: this.makeWhereSchema(model, true),
4782
4810
  create: this.makeCreateDataSchema(model, false),
4783
4811
  update: this.makeUpdateDataSchema(model),
@@ -4812,7 +4840,7 @@ var InputValidator = class {
4812
4840
  excludeFields.push(...oppositeFieldDef.relation.fields);
4813
4841
  }
4814
4842
  }
4815
- let fieldSchema = z2.lazy(() => this.makeRelationManipulationSchema(fieldDef, excludeFields, "update")).optional();
4843
+ let fieldSchema = z3.lazy(() => this.makeRelationManipulationSchema(fieldDef, excludeFields, "update")).optional();
4816
4844
  if (fieldDef.optional && !fieldDef.array) {
4817
4845
  fieldSchema = fieldSchema.nullable();
4818
4846
  }
@@ -4823,24 +4851,24 @@ var InputValidator = class {
4823
4851
  } else {
4824
4852
  let fieldSchema = this.makePrimitiveSchema(fieldDef.type, fieldDef.attributes);
4825
4853
  if (this.isNumericField(fieldDef)) {
4826
- fieldSchema = z2.union([
4854
+ fieldSchema = z3.union([
4827
4855
  fieldSchema,
4828
- z2.object({
4829
- set: this.nullableIf(z2.number().optional(), !!fieldDef.optional).optional(),
4830
- increment: z2.number().optional(),
4831
- decrement: z2.number().optional(),
4832
- multiply: z2.number().optional(),
4833
- divide: z2.number().optional()
4856
+ z3.object({
4857
+ set: this.nullableIf(z3.number().optional(), !!fieldDef.optional).optional(),
4858
+ increment: z3.number().optional(),
4859
+ decrement: z3.number().optional(),
4860
+ multiply: z3.number().optional(),
4861
+ divide: z3.number().optional()
4834
4862
  }).refine((v) => Object.keys(v).length === 1, 'Only one of "set", "increment", "decrement", "multiply", or "divide" can be provided')
4835
4863
  ]);
4836
4864
  }
4837
4865
  if (fieldDef.array) {
4838
4866
  const arraySchema = addListValidation(fieldSchema.array(), fieldDef.attributes);
4839
- fieldSchema = z2.union([
4867
+ fieldSchema = z3.union([
4840
4868
  arraySchema,
4841
- z2.object({
4869
+ z3.object({
4842
4870
  set: arraySchema.optional(),
4843
- push: z2.union([
4871
+ push: z3.union([
4844
4872
  fieldSchema,
4845
4873
  fieldSchema.array()
4846
4874
  ]).optional()
@@ -4857,12 +4885,12 @@ var InputValidator = class {
4857
4885
  }
4858
4886
  }
4859
4887
  });
4860
- const uncheckedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(z2.strictObject(uncheckedVariantFields), modelDef.attributes) : z2.strictObject(uncheckedVariantFields);
4861
- const checkedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(z2.strictObject(checkedVariantFields), modelDef.attributes) : z2.strictObject(checkedVariantFields);
4888
+ const uncheckedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(z3.strictObject(uncheckedVariantFields), modelDef.attributes) : z3.strictObject(uncheckedVariantFields);
4889
+ const checkedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(z3.strictObject(checkedVariantFields), modelDef.attributes) : z3.strictObject(checkedVariantFields);
4862
4890
  if (!hasRelation) {
4863
4891
  return uncheckedUpdateSchema;
4864
4892
  } else {
4865
- return z2.union([
4893
+ return z3.union([
4866
4894
  uncheckedUpdateSchema,
4867
4895
  checkedUpdateSchema
4868
4896
  ]);
@@ -4871,25 +4899,26 @@ var InputValidator = class {
4871
4899
  // #endregion
4872
4900
  // #region Delete
4873
4901
  makeDeleteSchema(model) {
4874
- let schema = z2.strictObject({
4902
+ let schema = z3.strictObject({
4875
4903
  where: this.makeWhereSchema(model, true),
4876
4904
  select: this.makeSelectSchema(model).optional().nullable(),
4877
- include: this.makeIncludeSchema(model).optional().nullable()
4905
+ include: this.makeIncludeSchema(model).optional().nullable(),
4906
+ omit: this.makeOmitSchema(model).optional().nullable()
4878
4907
  });
4879
4908
  schema = this.refineForSelectIncludeMutuallyExclusive(schema);
4880
4909
  schema = this.refineForSelectOmitMutuallyExclusive(schema);
4881
4910
  return schema;
4882
4911
  }
4883
4912
  makeDeleteManySchema(model) {
4884
- return z2.object({
4913
+ return z3.object({
4885
4914
  where: this.makeWhereSchema(model, false).optional(),
4886
- limit: z2.number().int().nonnegative().optional()
4915
+ limit: z3.number().int().nonnegative().optional()
4887
4916
  }).optional();
4888
4917
  }
4889
4918
  // #endregion
4890
4919
  // #region Count
4891
4920
  makeCountSchema(model) {
4892
- return z2.object({
4921
+ return z3.object({
4893
4922
  where: this.makeWhereSchema(model, false).optional(),
4894
4923
  skip: this.makeSkipSchema().optional(),
4895
4924
  take: this.makeTakeSchema().optional(),
@@ -4899,12 +4928,12 @@ var InputValidator = class {
4899
4928
  }
4900
4929
  makeCountAggregateInputSchema(model) {
4901
4930
  const modelDef = requireModel(this.schema, model);
4902
- return z2.union([
4903
- z2.literal(true),
4904
- z2.strictObject({
4905
- _all: z2.literal(true).optional(),
4931
+ return z3.union([
4932
+ z3.literal(true),
4933
+ z3.strictObject({
4934
+ _all: z3.literal(true).optional(),
4906
4935
  ...Object.keys(modelDef.fields).reduce((acc, field) => {
4907
- acc[field] = z2.literal(true).optional();
4936
+ acc[field] = z3.literal(true).optional();
4908
4937
  return acc;
4909
4938
  }, {})
4910
4939
  })
@@ -4913,7 +4942,7 @@ var InputValidator = class {
4913
4942
  // #endregion
4914
4943
  // #region Aggregate
4915
4944
  makeAggregateSchema(model) {
4916
- return z2.object({
4945
+ return z3.object({
4917
4946
  where: this.makeWhereSchema(model, false).optional(),
4918
4947
  skip: this.makeSkipSchema().optional(),
4919
4948
  take: this.makeTakeSchema().optional(),
@@ -4927,20 +4956,20 @@ var InputValidator = class {
4927
4956
  }
4928
4957
  makeSumAvgInputSchema(model) {
4929
4958
  const modelDef = requireModel(this.schema, model);
4930
- return z2.strictObject(Object.keys(modelDef.fields).reduce((acc, field) => {
4959
+ return z3.strictObject(Object.keys(modelDef.fields).reduce((acc, field) => {
4931
4960
  const fieldDef = requireField(this.schema, model, field);
4932
4961
  if (this.isNumericField(fieldDef)) {
4933
- acc[field] = z2.literal(true).optional();
4962
+ acc[field] = z3.literal(true).optional();
4934
4963
  }
4935
4964
  return acc;
4936
4965
  }, {}));
4937
4966
  }
4938
4967
  makeMinMaxInputSchema(model) {
4939
4968
  const modelDef = requireModel(this.schema, model);
4940
- return z2.strictObject(Object.keys(modelDef.fields).reduce((acc, field) => {
4969
+ return z3.strictObject(Object.keys(modelDef.fields).reduce((acc, field) => {
4941
4970
  const fieldDef = requireField(this.schema, model, field);
4942
4971
  if (!fieldDef.relation && !fieldDef.array) {
4943
- acc[field] = z2.literal(true).optional();
4972
+ acc[field] = z3.literal(true).optional();
4944
4973
  }
4945
4974
  return acc;
4946
4975
  }, {}));
@@ -4948,8 +4977,8 @@ var InputValidator = class {
4948
4977
  makeGroupBySchema(model) {
4949
4978
  const modelDef = requireModel(this.schema, model);
4950
4979
  const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation);
4951
- const bySchema = nonRelationFields.length > 0 ? this.orArray(z2.enum(nonRelationFields), true) : z2.never();
4952
- let schema = z2.strictObject({
4980
+ const bySchema = nonRelationFields.length > 0 ? this.orArray(z3.enum(nonRelationFields), true) : z3.never();
4981
+ let schema = z3.strictObject({
4953
4982
  where: this.makeWhereSchema(model, false).optional(),
4954
4983
  orderBy: this.orArray(this.makeOrderBySchema(model, false, true), true).optional(),
4955
4984
  by: bySchema,
@@ -5016,10 +5045,10 @@ var InputValidator = class {
5016
5045
  // #endregion
5017
5046
  // #region Helpers
5018
5047
  makeSkipSchema() {
5019
- return z2.number().int().nonnegative();
5048
+ return z3.number().int().nonnegative();
5020
5049
  }
5021
5050
  makeTakeSchema() {
5022
- return z2.number().int();
5051
+ return z3.number().int();
5023
5052
  }
5024
5053
  refineForSelectIncludeMutuallyExclusive(schema) {
5025
5054
  return schema.refine((value) => !(value["select"] && value["include"]), '"select" and "include" cannot be used together');
@@ -5031,9 +5060,9 @@ var InputValidator = class {
5031
5060
  return nullable ? schema.nullable() : schema;
5032
5061
  }
5033
5062
  orArray(schema, canBeArray) {
5034
- return canBeArray ? z2.union([
5063
+ return canBeArray ? z3.union([
5035
5064
  schema,
5036
- z2.array(schema)
5065
+ z3.array(schema)
5037
5066
  ]) : schema;
5038
5067
  }
5039
5068
  isNumericField(fieldDef) {
@@ -6796,6 +6825,9 @@ var ClientImpl = class _ClientImpl {
6796
6825
  get $auth() {
6797
6826
  return this.auth;
6798
6827
  }
6828
+ $setOptions(options) {
6829
+ return new _ClientImpl(this.schema, options, this);
6830
+ }
6799
6831
  $setInputValidation(enable) {
6800
6832
  const newOptions = {
6801
6833
  ...this.options,
@@ -7275,7 +7307,8 @@ var DefaultOperationNodeVisitor = class extends OperationNodeVisitor {
7275
7307
  // src/utils/schema-utils.ts
7276
7308
  var schema_utils_exports = {};
7277
7309
  __export(schema_utils_exports, {
7278
- ExpressionVisitor: () => ExpressionVisitor
7310
+ ExpressionVisitor: () => ExpressionVisitor,
7311
+ MatchingExpressionVisitor: () => MatchingExpressionVisitor
7279
7312
  });
7280
7313
  import { match as match17 } from "ts-pattern";
7281
7314
  var ExpressionVisitor = class {
@@ -7283,7 +7316,7 @@ var ExpressionVisitor = class {
7283
7316
  __name(this, "ExpressionVisitor");
7284
7317
  }
7285
7318
  visit(expr) {
7286
- match17(expr).with({
7319
+ return match17(expr).with({
7287
7320
  kind: "literal"
7288
7321
  }, (e) => this.visitLiteral(e)).with({
7289
7322
  kind: "array"
@@ -7306,28 +7339,67 @@ var ExpressionVisitor = class {
7306
7339
  visitLiteral(_e) {
7307
7340
  }
7308
7341
  visitArray(e) {
7309
- e.items.forEach((item) => this.visit(item));
7342
+ for (const item of e.items) {
7343
+ const result = this.visit(item);
7344
+ if (result?.abort) {
7345
+ return result;
7346
+ }
7347
+ }
7310
7348
  }
7311
7349
  visitField(_e) {
7312
7350
  }
7313
7351
  visitMember(e) {
7314
- this.visit(e.receiver);
7352
+ return this.visit(e.receiver);
7315
7353
  }
7316
7354
  visitBinary(e) {
7317
- this.visit(e.left);
7318
- this.visit(e.right);
7355
+ const l = this.visit(e.left);
7356
+ if (l?.abort) {
7357
+ return l;
7358
+ } else {
7359
+ return this.visit(e.right);
7360
+ }
7319
7361
  }
7320
7362
  visitUnary(e) {
7321
- this.visit(e.operand);
7363
+ return this.visit(e.operand);
7322
7364
  }
7323
7365
  visitCall(e) {
7324
- e.args?.forEach((arg) => this.visit(arg));
7366
+ for (const arg of e.args ?? []) {
7367
+ const r = this.visit(arg);
7368
+ if (r?.abort) {
7369
+ return r;
7370
+ }
7371
+ }
7325
7372
  }
7326
7373
  visitThis(_e) {
7327
7374
  }
7328
7375
  visitNull(_e) {
7329
7376
  }
7330
7377
  };
7378
+ var MatchingExpressionVisitor = class extends ExpressionVisitor {
7379
+ static {
7380
+ __name(this, "MatchingExpressionVisitor");
7381
+ }
7382
+ predicate;
7383
+ found = false;
7384
+ constructor(predicate) {
7385
+ super(), this.predicate = predicate;
7386
+ }
7387
+ find(expr) {
7388
+ this.found = false;
7389
+ this.visit(expr);
7390
+ return this.found;
7391
+ }
7392
+ visit(expr) {
7393
+ if (this.predicate(expr)) {
7394
+ this.found = true;
7395
+ return {
7396
+ abort: true
7397
+ };
7398
+ } else {
7399
+ return super.visit(expr);
7400
+ }
7401
+ }
7402
+ };
7331
7403
  export {
7332
7404
  BaseCrudDialect,
7333
7405
  CRUD,