@zenstackhq/orm 3.6.4 → 3.7.0-beta.1

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
@@ -1,7 +1,8 @@
1
1
  import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
2
+ import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "./common-types.mjs";
2
3
  import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
3
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";
4
- import z, { ZodObject, ZodType, z as z$1 } from "zod";
5
+ import z$1, { ZodObject, ZodType, z } from "zod";
5
6
  import { fromError } from "zod-validation-error/v4";
6
7
  import { P, match } from "ts-pattern";
7
8
  import { ExpressionUtils } from "@zenstackhq/schema";
@@ -562,20 +563,6 @@ const CRUD = [
562
563
  */
563
564
  const CRUD_EXT = [...CRUD, "post-update"];
564
565
  //#endregion
565
- //#region src/common-types.ts
566
- var DbNullClass = class {
567
- __brand = "DbNull";
568
- };
569
- const DbNull = new DbNullClass();
570
- var JsonNullClass = class {
571
- __brand = "JsonNull";
572
- };
573
- const JsonNull = new JsonNullClass();
574
- var AnyNullClass = class {
575
- __brand = "AnyNull";
576
- };
577
- const AnyNull = new AnyNullClass();
578
- //#endregion
579
566
  //#region src/client/crud/dialects/base-dialect.ts
580
567
  var BaseCrudDialect = class {
581
568
  eb = expressionBuilder();
@@ -2075,7 +2062,7 @@ function createQuerySchemaFactory(clientOrSchema, options) {
2075
2062
  */
2076
2063
  var ZodSchemaFactory = class {
2077
2064
  schemaCache = /* @__PURE__ */ new Map();
2078
- schemaRegistry = z$1.registry();
2065
+ schemaRegistry = z.registry();
2079
2066
  allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
2080
2067
  schema;
2081
2068
  options;
@@ -2167,7 +2154,7 @@ var ZodSchemaFactory = class {
2167
2154
  this.makeGroupBySchema(m);
2168
2155
  }
2169
2156
  for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
2170
- return z$1.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
2157
+ return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
2171
2158
  }
2172
2159
  get cacheStats() {
2173
2160
  return {
@@ -2196,13 +2183,13 @@ var ZodSchemaFactory = class {
2196
2183
  fields["omit"] = this.makeOmitSchema(model).optional().nullable();
2197
2184
  if (!unique) {
2198
2185
  fields["skip"] = this.makeSkipSchema().optional();
2199
- if (findOne) fields["take"] = z$1.literal(1).optional();
2186
+ if (findOne) fields["take"] = z.literal(1).optional();
2200
2187
  else fields["take"] = this.makeTakeSchema().optional();
2201
2188
  fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
2202
2189
  fields["cursor"] = this.makeCursorSchema(model, options).optional();
2203
2190
  fields["distinct"] = this.makeDistinctSchema(model).optional();
2204
2191
  }
2205
- const baseSchema = z$1.strictObject(fields);
2192
+ const baseSchema = z.strictObject(fields);
2206
2193
  let result = this.mergePluginArgsSchema(baseSchema, operation);
2207
2194
  result = this.refineForSelectIncludeMutuallyExclusive(result);
2208
2195
  result = this.refineForSelectOmitMutuallyExclusive(result);
@@ -2212,7 +2199,7 @@ var ZodSchemaFactory = class {
2212
2199
  return result;
2213
2200
  }
2214
2201
  makeExistsSchema(model, options) {
2215
- const baseSchema = z$1.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
2202
+ const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
2216
2203
  const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
2217
2204
  this.registerSchema(`${model}ExistsArgs`, result);
2218
2205
  return result;
@@ -2220,31 +2207,31 @@ var ZodSchemaFactory = class {
2220
2207
  makeScalarSchema(type, attributes) {
2221
2208
  if (this.schema.typeDefs && type in this.schema.typeDefs) return this.makeTypeDefSchema(type);
2222
2209
  else if (this.schema.enums && type in this.schema.enums) return this.makeEnumSchema(type);
2223
- 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", () => {
2224
- return z$1.union([
2225
- this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number(), attributes) : z$1.number(),
2226
- ZodUtils.addDecimalValidation(z$1.instanceof(Decimal), attributes, this.extraValidationsEnabled),
2227
- ZodUtils.addDecimalValidation(z$1.string(), attributes, this.extraValidationsEnabled)
2210
+ 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", () => {
2211
+ return z.union([
2212
+ this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number(),
2213
+ ZodUtils.addDecimalValidation(z.instanceof(Decimal), attributes, this.extraValidationsEnabled),
2214
+ ZodUtils.addDecimalValidation(z.string(), attributes, this.extraValidationsEnabled)
2228
2215
  ]);
2229
- }).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z$1.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z$1.unknown());
2216
+ }).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
2230
2217
  }
2231
2218
  makeEnumSchema(_enum) {
2232
2219
  const enumDef = getEnum(this.schema, _enum);
2233
2220
  invariant(enumDef, `Enum "${_enum}" not found in schema`);
2234
- const schema = z$1.enum(Object.keys(enumDef.values));
2221
+ const schema = z.enum(Object.keys(enumDef.values));
2235
2222
  this.registerSchema(_enum, schema);
2236
2223
  return schema;
2237
2224
  }
2238
2225
  makeTypeDefSchema(type) {
2239
2226
  const typeDef = getTypeDef(this.schema, type);
2240
2227
  invariant(typeDef, `Type definition "${type}" not found in schema`);
2241
- const schema = z$1.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
2228
+ const schema = z.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
2242
2229
  let fieldSchema = this.makeScalarSchema(def.type);
2243
2230
  if (def.array) fieldSchema = fieldSchema.array();
2244
2231
  if (def.optional) fieldSchema = fieldSchema.nullish();
2245
2232
  return [field, fieldSchema];
2246
2233
  })));
2247
- const finalSchema = z$1.any().superRefine((value, ctx) => {
2234
+ const finalSchema = z.any().superRefine((value, ctx) => {
2248
2235
  const parseResult = schema.safeParse(value);
2249
2236
  if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
2250
2237
  });
@@ -2260,17 +2247,17 @@ var ZodSchemaFactory = class {
2260
2247
  if (fieldDef.relation) {
2261
2248
  if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
2262
2249
  const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
2263
- if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z$1.never();
2250
+ if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
2264
2251
  else {
2265
- fieldSchema = z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
2266
- if (fieldDef.array) fieldSchema = z$1.strictObject({
2252
+ fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
2253
+ if (fieldDef.array) fieldSchema = z.strictObject({
2267
2254
  some: fieldSchema.optional(),
2268
2255
  every: fieldSchema.optional(),
2269
2256
  none: fieldSchema.optional()
2270
2257
  });
2271
2258
  else {
2272
2259
  fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
2273
- fieldSchema = z$1.union([fieldSchema, z$1.strictObject({
2260
+ fieldSchema = z.union([fieldSchema, z.strictObject({
2274
2261
  is: fieldSchema.optional(),
2275
2262
  isNot: fieldSchema.optional()
2276
2263
  })]);
@@ -2289,21 +2276,21 @@ var ZodSchemaFactory = class {
2289
2276
  }
2290
2277
  if (unique) {
2291
2278
  const uniqueFields = getUniqueFields(this.schema, model);
2292
- for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z$1.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
2279
+ for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
2293
2280
  invariant(!def.relation, "unique field cannot be a relation");
2294
2281
  let fieldSchema;
2295
2282
  const enumDef = getEnum(this.schema, def.type);
2296
2283
  if (enumDef) if (Object.keys(enumDef.values).length > 0) fieldSchema = this.makeEnumFilterSchema(def.type, !!def.optional, !!def.array, false, void 0);
2297
- else fieldSchema = z$1.never();
2284
+ else fieldSchema = z.never();
2298
2285
  else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
2299
2286
  return [key, fieldSchema];
2300
2287
  }))).optional();
2301
2288
  }
2302
- fields["$expr"] = z$1.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
2303
- fields["AND"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2304
- fields["OR"] = z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
2305
- fields["NOT"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2306
- const baseWhere = z$1.strictObject(fields);
2289
+ fields["$expr"] = z.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
2290
+ fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2291
+ fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
2292
+ fields["NOT"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
2293
+ const baseWhere = z.strictObject(fields);
2307
2294
  let result = baseWhere;
2308
2295
  if (unique) {
2309
2296
  const uniqueFields = getUniqueFields(this.schema, model);
@@ -2329,26 +2316,26 @@ var ZodSchemaFactory = class {
2329
2316
  else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
2330
2317
  else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
2331
2318
  else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(fieldDef.type, !!fieldDef.optional, false, void 0).optional();
2332
- candidates.push(z$1.strictObject(fieldSchemas));
2319
+ candidates.push(z.strictObject(fieldSchemas));
2333
2320
  }
2334
- const recursiveSchema = z$1.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
2335
- if (array) candidates.push(z$1.strictObject({
2321
+ const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
2322
+ if (array) candidates.push(z.strictObject({
2336
2323
  some: recursiveSchema,
2337
2324
  every: recursiveSchema,
2338
2325
  none: recursiveSchema
2339
2326
  }));
2340
- else candidates.push(z$1.strictObject({
2327
+ else candidates.push(z.strictObject({
2341
2328
  is: recursiveSchema,
2342
2329
  isNot: recursiveSchema
2343
2330
  }));
2344
2331
  candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
2345
2332
  if (optional) {
2346
- candidates.push(z$1.null());
2347
- candidates.push(z$1.instanceof(DbNullClass));
2348
- candidates.push(z$1.instanceof(JsonNullClass));
2349
- candidates.push(z$1.instanceof(AnyNullClass));
2333
+ candidates.push(z.null());
2334
+ candidates.push(z.instanceof(DbNullClass));
2335
+ candidates.push(z.instanceof(JsonNullClass));
2336
+ candidates.push(z.instanceof(AnyNullClass));
2350
2337
  }
2351
- const result = z$1.union(candidates);
2338
+ const result = z.union(candidates);
2352
2339
  this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
2353
2340
  optional,
2354
2341
  array,
@@ -2357,7 +2344,7 @@ var ZodSchemaFactory = class {
2357
2344
  return result;
2358
2345
  }
2359
2346
  makeNullableTypedJsonMutationSchema(fieldSchema) {
2360
- return z$1.any().superRefine((value, ctx) => {
2347
+ return z.any().superRefine((value, ctx) => {
2361
2348
  if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
2362
2349
  const parseResult = fieldSchema.safeParse(value);
2363
2350
  if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
@@ -2369,11 +2356,11 @@ var ZodSchemaFactory = class {
2369
2356
  makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
2370
2357
  const enumDef = getEnum(this.schema, enumName);
2371
2358
  invariant(enumDef, `Enum "${enumName}" not found in schema`);
2372
- const baseSchema = z$1.enum(Object.keys(enumDef.values));
2359
+ const baseSchema = z.enum(Object.keys(enumDef.values));
2373
2360
  let schema;
2374
2361
  if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
2375
2362
  else {
2376
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
2363
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
2377
2364
  "equals",
2378
2365
  "in",
2379
2366
  "notIn",
@@ -2407,42 +2394,42 @@ var ZodSchemaFactory = class {
2407
2394
  has: elementSchema.optional(),
2408
2395
  hasEvery: elementSchema.array().optional(),
2409
2396
  hasSome: elementSchema.array().optional(),
2410
- isEmpty: z$1.boolean().optional()
2397
+ isEmpty: z.boolean().optional()
2411
2398
  };
2412
2399
  const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
2413
- return z$1.strictObject(filteredOperators);
2400
+ return z.strictObject(filteredOperators);
2414
2401
  }
2415
2402
  makePrimitiveFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
2416
- return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)).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();
2403
+ return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)).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();
2417
2404
  }
2418
2405
  makeJsonValueSchema() {
2419
- const schema = z$1.union([
2420
- z$1.string(),
2421
- z$1.number(),
2422
- z$1.boolean(),
2423
- z$1.instanceof(JsonNullClass),
2424
- z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()]).array()),
2425
- z$1.record(z$1.string(), z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()])))
2406
+ const schema = z.union([
2407
+ z.string(),
2408
+ z.number(),
2409
+ z.boolean(),
2410
+ z.instanceof(JsonNullClass),
2411
+ z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()]).array()),
2412
+ z.record(z.string(), z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()])))
2426
2413
  ]);
2427
2414
  this.registerSchema("JsonValue", schema);
2428
2415
  return schema;
2429
2416
  }
2430
2417
  makeJsonFilterSchema(optional, allowedFilterKinds) {
2431
- if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z$1.never();
2418
+ if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
2432
2419
  const filterMembers = [
2433
2420
  this.makeJsonValueSchema(),
2434
- z$1.instanceof(DbNullClass),
2435
- z$1.instanceof(AnyNullClass)
2421
+ z.instanceof(DbNullClass),
2422
+ z.instanceof(AnyNullClass)
2436
2423
  ];
2437
- if (optional) filterMembers.push(z$1.null());
2438
- const filterValueSchema = z$1.union(filterMembers);
2439
- const schema = z$1.strictObject({
2440
- path: z$1.string().optional(),
2424
+ if (optional) filterMembers.push(z.null());
2425
+ const filterValueSchema = z.union(filterMembers);
2426
+ const schema = z.strictObject({
2427
+ path: z.string().optional(),
2441
2428
  equals: filterValueSchema.optional(),
2442
2429
  not: filterValueSchema.optional(),
2443
- string_contains: z$1.string().optional(),
2444
- string_starts_with: z$1.string().optional(),
2445
- string_ends_with: z$1.string().optional(),
2430
+ string_contains: z.string().optional(),
2431
+ string_starts_with: z.string().optional(),
2432
+ string_ends_with: z.string().optional(),
2446
2433
  mode: this.makeStringModeSchema().optional(),
2447
2434
  array_contains: filterValueSchema.optional(),
2448
2435
  array_starts_with: filterValueSchema.optional(),
@@ -2455,17 +2442,17 @@ var ZodSchemaFactory = class {
2455
2442
  return schema;
2456
2443
  }
2457
2444
  makeDateTimeValueSchema() {
2458
- const schema = z$1.union([
2459
- z$1.iso.datetime(),
2460
- z$1.iso.date(),
2461
- z$1.date()
2445
+ const schema = z.union([
2446
+ z.iso.datetime(),
2447
+ z.iso.date(),
2448
+ z.date()
2462
2449
  ]);
2463
2450
  this.registerSchema("DateTime", schema);
2464
2451
  return schema;
2465
2452
  }
2466
2453
  makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
2467
2454
  const filterValueSchema = this.makeDateTimeValueSchema();
2468
- const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z$1.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2455
+ const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2469
2456
  "_count",
2470
2457
  "_min",
2471
2458
  "_max"
@@ -2478,12 +2465,12 @@ var ZodSchemaFactory = class {
2478
2465
  return schema;
2479
2466
  }
2480
2467
  makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
2481
- const components = this.makeCommonPrimitiveFilterComponents(z$1.boolean(), optional, () => z$1.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
2468
+ const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
2482
2469
  "_count",
2483
2470
  "_min",
2484
2471
  "_max"
2485
2472
  ] : void 0, allowedFilterKinds);
2486
- const schema = this.createUnionFilterSchema(z$1.boolean(), optional, components, allowedFilterKinds);
2473
+ const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
2487
2474
  this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
2488
2475
  optional,
2489
2476
  allowedFilterKinds,
@@ -2492,8 +2479,8 @@ var ZodSchemaFactory = class {
2492
2479
  return schema;
2493
2480
  }
2494
2481
  makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
2495
- const baseSchema = z$1.instanceof(Uint8Array);
2496
- const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.instanceof(Uint8Array), [
2482
+ const baseSchema = z.instanceof(Uint8Array);
2483
+ const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
2497
2484
  "equals",
2498
2485
  "in",
2499
2486
  "notIn",
@@ -2541,7 +2528,7 @@ var ZodSchemaFactory = class {
2541
2528
  return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
2542
2529
  }
2543
2530
  makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
2544
- const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z$1.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2531
+ const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
2545
2532
  "_count",
2546
2533
  "_avg",
2547
2534
  "_sum",
@@ -2556,15 +2543,15 @@ var ZodSchemaFactory = class {
2556
2543
  return schema;
2557
2544
  }
2558
2545
  makeStringFilterSchema(optional, withAggregations, allowedFilterKinds) {
2559
- const baseComponents = this.makeCommonPrimitiveFilterComponents(z$1.string(), optional, () => z$1.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)), void 0, withAggregations ? [
2546
+ const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)), void 0, withAggregations ? [
2560
2547
  "_count",
2561
2548
  "_min",
2562
2549
  "_max"
2563
2550
  ] : void 0, allowedFilterKinds);
2564
2551
  const stringSpecificOperators = {
2565
- startsWith: z$1.string().optional(),
2566
- endsWith: z$1.string().optional(),
2567
- contains: z$1.string().optional(),
2552
+ startsWith: z.string().optional(),
2553
+ endsWith: z.string().optional(),
2554
+ contains: z.string().optional(),
2568
2555
  ...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
2569
2556
  };
2570
2557
  const filteredStringOperators = this.trimFilterOperators(stringSpecificOperators, allowedFilterKinds);
@@ -2572,7 +2559,7 @@ var ZodSchemaFactory = class {
2572
2559
  ...baseComponents,
2573
2560
  ...filteredStringOperators
2574
2561
  };
2575
- const schema = this.createUnionFilterSchema(z$1.string(), optional, allComponents, allowedFilterKinds);
2562
+ const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
2576
2563
  this.registerSchema(`StringFilter${this.filterSchemaSuffix({
2577
2564
  optional,
2578
2565
  allowedFilterKinds,
@@ -2581,20 +2568,20 @@ var ZodSchemaFactory = class {
2581
2568
  return schema;
2582
2569
  }
2583
2570
  makeStringModeSchema() {
2584
- return z$1.union([z$1.literal("default"), z$1.literal("insensitive")]);
2571
+ return z.union([z.literal("default"), z.literal("insensitive")]);
2585
2572
  }
2586
2573
  makeSelectSchema(model, options) {
2587
2574
  const fields = {};
2588
2575
  for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
2589
2576
  if (!this.shouldIncludeRelations(options)) continue;
2590
2577
  if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
2591
- } else fields[field] = z$1.boolean().optional();
2578
+ } else fields[field] = z.boolean().optional();
2592
2579
  if (this.shouldIncludeRelations(options)) {
2593
2580
  const _countSchema = this.makeCountSelectionSchema(model, options);
2594
- if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
2581
+ if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
2595
2582
  }
2596
2583
  this.addExtResultFields(model, fields);
2597
- const result = z$1.strictObject(fields);
2584
+ const result = z.strictObject(fields);
2598
2585
  this.registerSchema(`${model}Select`, result);
2599
2586
  return result;
2600
2587
  }
@@ -2603,24 +2590,24 @@ var ZodSchemaFactory = class {
2603
2590
  const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
2604
2591
  if (toManyRelations.length > 0) {
2605
2592
  const nextOpts = this.nextOptions(options);
2606
- const schema = z$1.union([z$1.literal(true), z$1.strictObject({ select: z$1.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
2593
+ const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
2607
2594
  ...acc,
2608
- [fieldDef.name]: z$1.union([z$1.boolean(), z$1.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
2595
+ [fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
2609
2596
  }), {})) })]).optional();
2610
2597
  this.registerSchema(`${model}CountSelection`, schema);
2611
2598
  return schema;
2612
- } else return z$1.never();
2599
+ } else return z.never();
2613
2600
  }
2614
2601
  makeRelationSelectIncludeSchema(model, field, options) {
2615
2602
  const fieldDef = requireField(this.schema, model, field);
2616
2603
  const nextOpts = this.nextOptions(options);
2617
- let objSchema = z$1.strictObject({
2618
- ...fieldDef.array || fieldDef.optional ? { where: z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
2619
- select: z$1.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
2620
- include: z$1.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
2621
- omit: z$1.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
2604
+ let objSchema = z.strictObject({
2605
+ ...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
2606
+ select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
2607
+ include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
2608
+ omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
2622
2609
  ...fieldDef.array ? {
2623
- orderBy: z$1.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
2610
+ orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
2624
2611
  skip: this.makeSkipSchema().optional(),
2625
2612
  take: this.makeTakeSchema().optional(),
2626
2613
  cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
@@ -2630,16 +2617,16 @@ var ZodSchemaFactory = class {
2630
2617
  objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
2631
2618
  objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
2632
2619
  objSchema = this.refineForSelectHasTruthyField(objSchema);
2633
- const result = z$1.union([z$1.boolean(), objSchema]);
2620
+ const result = z.union([z.boolean(), objSchema]);
2634
2621
  this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
2635
2622
  return result;
2636
2623
  }
2637
2624
  makeOmitSchema(model) {
2638
2625
  const fields = {};
2639
- for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z$1.boolean().optional();
2640
- else fields[field] = z$1.literal(true).optional();
2626
+ for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
2627
+ else fields[field] = z.literal(true).optional();
2641
2628
  this.addExtResultFields(model, fields);
2642
- const result = z$1.strictObject(fields);
2629
+ const result = z.strictObject(fields);
2643
2630
  this.registerSchema(`${model}OmitInput`, result);
2644
2631
  return result;
2645
2632
  }
@@ -2648,7 +2635,7 @@ var ZodSchemaFactory = class {
2648
2635
  const resultConfig = plugin.result;
2649
2636
  if (resultConfig) {
2650
2637
  const modelConfig = resultConfig[lowerCaseFirst(model)];
2651
- if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z$1.boolean().optional();
2638
+ if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
2652
2639
  }
2653
2640
  }
2654
2641
  }
@@ -2664,26 +2651,26 @@ var ZodSchemaFactory = class {
2664
2651
  }
2665
2652
  if (this.shouldIncludeRelations(options)) {
2666
2653
  const _countSchema = this.makeCountSelectionSchema(model, options);
2667
- if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
2654
+ if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
2668
2655
  }
2669
- const result = z$1.strictObject(fields);
2656
+ const result = z.strictObject(fields);
2670
2657
  this.registerSchema(`${model}Include`, result);
2671
2658
  return result;
2672
2659
  }
2673
2660
  makeOrderBySchema(model, withRelation, WithAggregation, options) {
2674
2661
  const fields = {};
2675
- const sort = z$1.union([z$1.literal("asc"), z$1.literal("desc")]);
2662
+ const sort = z.union([z.literal("asc"), z.literal("desc")]);
2676
2663
  const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
2677
2664
  const nextOpts = this.nextOptions(options);
2678
2665
  for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
2679
- if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z$1.lazy(() => {
2666
+ if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
2680
2667
  let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
2681
2668
  if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
2682
2669
  return relationOrderBy;
2683
2670
  }).optional();
2684
- } else if (fieldDef.optional) fields[field] = z$1.union([sort, z$1.strictObject({
2671
+ } else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
2685
2672
  sort,
2686
- nulls: z$1.union([z$1.literal("first"), z$1.literal("last")])
2673
+ nulls: z.union([z.literal("first"), z.literal("last")])
2687
2674
  })]).optional();
2688
2675
  else fields[field] = sort.optional();
2689
2676
  if (WithAggregation) for (const agg of [
@@ -2692,8 +2679,8 @@ var ZodSchemaFactory = class {
2692
2679
  "_sum",
2693
2680
  "_min",
2694
2681
  "_max"
2695
- ]) fields[agg] = z$1.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
2696
- const schema = refineAtMostOneKey(z$1.strictObject(fields));
2682
+ ]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
2683
+ const schema = refineAtMostOneKey(z.strictObject(fields));
2697
2684
  let schemaId = `${model}OrderBy`;
2698
2685
  if (withRelation) schemaId += "WithRelation";
2699
2686
  if (WithAggregation) schemaId += "WithAggregation";
@@ -2703,7 +2690,7 @@ var ZodSchemaFactory = class {
2703
2690
  }
2704
2691
  makeDistinctSchema(model) {
2705
2692
  const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
2706
- const schema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
2693
+ const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
2707
2694
  this.registerSchema(`${model}DistinctInput`, schema);
2708
2695
  return schema;
2709
2696
  }
@@ -2714,7 +2701,7 @@ var ZodSchemaFactory = class {
2714
2701
  }
2715
2702
  makeCreateSchema(model, options) {
2716
2703
  const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
2717
- const baseSchema = z$1.strictObject({
2704
+ const baseSchema = z.strictObject({
2718
2705
  data: dataSchema,
2719
2706
  select: this.makeSelectSchema(model, options).optional().nullable(),
2720
2707
  include: this.makeIncludeSchema(model, options).optional().nullable(),
@@ -2763,7 +2750,7 @@ var ZodSchemaFactory = class {
2763
2750
  const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
2764
2751
  if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
2765
2752
  }
2766
- let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
2753
+ let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
2767
2754
  if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
2768
2755
  else {
2769
2756
  let allFksOptional = false;
@@ -2780,23 +2767,23 @@ var ZodSchemaFactory = class {
2780
2767
  let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
2781
2768
  if (fieldDef.array) {
2782
2769
  fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
2783
- fieldSchema = z$1.union([fieldSchema, z$1.strictObject({ set: fieldSchema })]).optional();
2770
+ fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
2784
2771
  }
2785
2772
  if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
2786
- if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
2773
+ if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
2787
2774
  else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
2788
2775
  else fieldSchema = fieldSchema.nullable();
2789
2776
  uncheckedVariantFields[field] = fieldSchema;
2790
2777
  if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
2791
2778
  }
2792
2779
  });
2793
- const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
2794
- const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
2795
- const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z$1.union([
2780
+ const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
2781
+ const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
2782
+ const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
2796
2783
  uncheckedCreateSchema,
2797
2784
  checkedCreateSchema,
2798
- ...canBeArray ? [z$1.array(uncheckedCreateSchema)] : [],
2799
- ...canBeArray ? [z$1.array(checkedCreateSchema)] : []
2785
+ ...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
2786
+ ...canBeArray ? [z.array(checkedCreateSchema)] : []
2800
2787
  ]);
2801
2788
  const idParts = [`${model}CreateData`];
2802
2789
  if (canBeArray) idParts.push("Array");
@@ -2821,17 +2808,17 @@ var ZodSchemaFactory = class {
2821
2808
  fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
2822
2809
  fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
2823
2810
  }
2824
- fields["update"] = array ? this.orArray(z$1.strictObject({
2811
+ fields["update"] = array ? this.orArray(z.strictObject({
2825
2812
  where: this.makeWhereSchema(fieldType, true, false, false, options),
2826
2813
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
2827
- }), true).optional() : z$1.union([z$1.strictObject({
2814
+ }), true).optional() : z.union([z.strictObject({
2828
2815
  where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
2829
2816
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
2830
2817
  }), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
2831
2818
  if (canCreateModel) {
2832
2819
  let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
2833
2820
  if (!fieldDef.array) upsertWhere = upsertWhere.optional();
2834
- fields["upsert"] = this.orArray(z$1.strictObject({
2821
+ fields["upsert"] = this.orArray(z.strictObject({
2835
2822
  where: upsertWhere,
2836
2823
  create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
2837
2824
  update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
@@ -2839,14 +2826,14 @@ var ZodSchemaFactory = class {
2839
2826
  }
2840
2827
  if (array) {
2841
2828
  fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
2842
- fields["updateMany"] = this.orArray(z$1.strictObject({
2829
+ fields["updateMany"] = this.orArray(z.strictObject({
2843
2830
  where: this.makeWhereSchema(fieldType, false, true, false, options),
2844
2831
  data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
2845
2832
  }), true).optional();
2846
2833
  fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
2847
2834
  }
2848
2835
  }
2849
- return z$1.strictObject(fields);
2836
+ return z.strictObject(fields);
2850
2837
  }
2851
2838
  makeSetDataSchema(model, canBeArray, options) {
2852
2839
  return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
@@ -2856,23 +2843,23 @@ var ZodSchemaFactory = class {
2856
2843
  }
2857
2844
  makeDisconnectDataSchema(model, canBeArray, options) {
2858
2845
  if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
2859
- else return z$1.union([z$1.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
2846
+ else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
2860
2847
  }
2861
2848
  makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
2862
- 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)]);
2849
+ return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
2863
2850
  }
2864
2851
  makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
2865
2852
  const whereSchema = this.makeWhereSchema(model, true, false, false, options);
2866
2853
  const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
2867
- return this.orArray(z$1.strictObject({
2854
+ return this.orArray(z.strictObject({
2868
2855
  where: whereSchema,
2869
2856
  create: createSchema
2870
2857
  }), canBeArray);
2871
2858
  }
2872
2859
  makeCreateManyPayloadSchema(model, withoutFields, options) {
2873
- const schema = z$1.strictObject({
2860
+ const schema = z.strictObject({
2874
2861
  data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
2875
- skipDuplicates: z$1.boolean().optional()
2862
+ skipDuplicates: z.boolean().optional()
2876
2863
  });
2877
2864
  const idParts = [`${model}CreateManyPayload`];
2878
2865
  if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
@@ -2880,7 +2867,7 @@ var ZodSchemaFactory = class {
2880
2867
  return schema;
2881
2868
  }
2882
2869
  makeUpdateSchema(model, options) {
2883
- const baseSchema = z$1.strictObject({
2870
+ const baseSchema = z.strictObject({
2884
2871
  where: this.makeWhereSchema(model, true, false, false, options),
2885
2872
  data: this.makeUpdateDataSchema(model, [], false, options),
2886
2873
  select: this.makeSelectSchema(model, options).optional().nullable(),
@@ -2895,10 +2882,10 @@ var ZodSchemaFactory = class {
2895
2882
  return schema;
2896
2883
  }
2897
2884
  makeUpdateManySchema(model, options) {
2898
- const result = this.mergePluginArgsSchema(z$1.strictObject({
2885
+ const result = this.mergePluginArgsSchema(z.strictObject({
2899
2886
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
2900
2887
  data: this.makeUpdateDataSchema(model, [], true, options),
2901
- limit: z$1.number().int().nonnegative().optional()
2888
+ limit: z.number().int().nonnegative().optional()
2902
2889
  }), "updateMany");
2903
2890
  this.registerSchema(`${model}UpdateManyArgs`, result);
2904
2891
  return result;
@@ -2914,7 +2901,7 @@ var ZodSchemaFactory = class {
2914
2901
  return schema;
2915
2902
  }
2916
2903
  makeUpsertSchema(model, options) {
2917
- const baseSchema = z$1.strictObject({
2904
+ const baseSchema = z.strictObject({
2918
2905
  where: this.makeWhereSchema(model, true, false, false, options),
2919
2906
  create: this.makeCreateDataSchema(model, false, [], false, options),
2920
2907
  update: this.makeUpdateDataSchema(model, [], false, options),
@@ -2950,27 +2937,27 @@ var ZodSchemaFactory = class {
2950
2937
  const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
2951
2938
  if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
2952
2939
  }
2953
- let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
2940
+ let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
2954
2941
  if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
2955
2942
  checkedVariantFields[field] = fieldSchema;
2956
2943
  if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
2957
2944
  } else {
2958
2945
  let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
2959
- if (this.isNumericField(fieldDef)) fieldSchema = z$1.union([fieldSchema, z$1.object({
2960
- set: this.nullableIf(z$1.number().optional(), !!fieldDef.optional).optional(),
2961
- increment: z$1.number().optional(),
2962
- decrement: z$1.number().optional(),
2963
- multiply: z$1.number().optional(),
2964
- divide: z$1.number().optional()
2946
+ if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
2947
+ set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
2948
+ increment: z.number().optional(),
2949
+ decrement: z.number().optional(),
2950
+ multiply: z.number().optional(),
2951
+ divide: z.number().optional()
2965
2952
  }).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
2966
2953
  if (fieldDef.array) {
2967
2954
  const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
2968
- fieldSchema = z$1.union([arraySchema, z$1.object({
2955
+ fieldSchema = z.union([arraySchema, z.object({
2969
2956
  set: arraySchema.optional(),
2970
- push: z$1.union([fieldSchema, fieldSchema.array()]).optional()
2957
+ push: z.union([fieldSchema, fieldSchema.array()]).optional()
2971
2958
  }).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
2972
2959
  }
2973
- if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
2960
+ if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
2974
2961
  else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
2975
2962
  else fieldSchema = fieldSchema.nullable();
2976
2963
  fieldSchema = fieldSchema.optional();
@@ -2978,9 +2965,9 @@ var ZodSchemaFactory = class {
2978
2965
  if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
2979
2966
  }
2980
2967
  });
2981
- const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
2982
- const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
2983
- const result = !hasRelation ? uncheckedUpdateSchema : z$1.union([uncheckedUpdateSchema, checkedUpdateSchema]);
2968
+ const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
2969
+ const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
2970
+ const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
2984
2971
  const idParts = [`${model}UpdateData`];
2985
2972
  if (withoutRelationFields) idParts.push("WithoutRelation");
2986
2973
  if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
@@ -2988,7 +2975,7 @@ var ZodSchemaFactory = class {
2988
2975
  return result;
2989
2976
  }
2990
2977
  makeDeleteSchema(model, options) {
2991
- const baseSchema = z$1.strictObject({
2978
+ const baseSchema = z.strictObject({
2992
2979
  where: this.makeWhereSchema(model, true, false, false, options),
2993
2980
  select: this.makeSelectSchema(model, options).optional().nullable(),
2994
2981
  include: this.makeIncludeSchema(model, options).optional().nullable(),
@@ -3002,15 +2989,15 @@ var ZodSchemaFactory = class {
3002
2989
  return schema;
3003
2990
  }
3004
2991
  makeDeleteManySchema(model, options) {
3005
- const result = this.mergePluginArgsSchema(z$1.strictObject({
2992
+ const result = this.mergePluginArgsSchema(z.strictObject({
3006
2993
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3007
- limit: z$1.number().int().nonnegative().optional()
2994
+ limit: z.number().int().nonnegative().optional()
3008
2995
  }), "deleteMany").optional();
3009
2996
  this.registerSchema(`${model}DeleteManyArgs`, result);
3010
2997
  return result;
3011
2998
  }
3012
2999
  makeCountSchema(model, options) {
3013
- const result = this.mergePluginArgsSchema(z$1.strictObject({
3000
+ const result = this.mergePluginArgsSchema(z.strictObject({
3014
3001
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3015
3002
  skip: this.makeSkipSchema().optional(),
3016
3003
  take: this.makeTakeSchema().optional(),
@@ -3021,10 +3008,10 @@ var ZodSchemaFactory = class {
3021
3008
  return result;
3022
3009
  }
3023
3010
  makeCountAggregateInputSchema(model) {
3024
- const schema = z$1.union([z$1.literal(true), z$1.strictObject({
3025
- _all: z$1.literal(true).optional(),
3011
+ const schema = z.union([z.literal(true), z.strictObject({
3012
+ _all: z.literal(true).optional(),
3026
3013
  ...this.getModelFields(model).reduce((acc, [field]) => {
3027
- acc[field] = z$1.literal(true).optional();
3014
+ acc[field] = z.literal(true).optional();
3028
3015
  return acc;
3029
3016
  }, {})
3030
3017
  })]);
@@ -3032,7 +3019,7 @@ var ZodSchemaFactory = class {
3032
3019
  return schema;
3033
3020
  }
3034
3021
  makeAggregateSchema(model, options) {
3035
- const result = this.mergePluginArgsSchema(z$1.strictObject({
3022
+ const result = this.mergePluginArgsSchema(z.strictObject({
3036
3023
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3037
3024
  skip: this.makeSkipSchema().optional(),
3038
3025
  take: this.makeTakeSchema().optional(),
@@ -3047,16 +3034,16 @@ var ZodSchemaFactory = class {
3047
3034
  return result;
3048
3035
  }
3049
3036
  makeSumAvgInputSchema(model) {
3050
- const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3051
- if (this.isNumericField(fieldDef)) acc[field] = z$1.literal(true).optional();
3037
+ const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3038
+ if (this.isNumericField(fieldDef)) acc[field] = z.literal(true).optional();
3052
3039
  return acc;
3053
3040
  }, {}));
3054
3041
  this.registerSchema(`${model}SumAvgAggregateInput`, schema);
3055
3042
  return schema;
3056
3043
  }
3057
3044
  makeMinMaxInputSchema(model) {
3058
- const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3059
- if (!fieldDef.relation && !fieldDef.array) acc[field] = z$1.literal(true).optional();
3045
+ const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
3046
+ if (!fieldDef.relation && !fieldDef.array) acc[field] = z.literal(true).optional();
3060
3047
  return acc;
3061
3048
  }, {}));
3062
3049
  this.registerSchema(`${model}MinMaxAggregateInput`, schema);
@@ -3064,8 +3051,8 @@ var ZodSchemaFactory = class {
3064
3051
  }
3065
3052
  makeGroupBySchema(model, options) {
3066
3053
  const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
3067
- const bySchema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
3068
- const baseSchema = z$1.strictObject({
3054
+ const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
3055
+ const baseSchema = z.strictObject({
3069
3056
  where: this.makeWhereSchema(model, false, false, false, options).optional(),
3070
3057
  orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
3071
3058
  by: bySchema,
@@ -3117,7 +3104,7 @@ var ZodSchemaFactory = class {
3117
3104
  if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
3118
3105
  const shape = {};
3119
3106
  for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
3120
- const schema = z$1.object(shape);
3107
+ const schema = z.object(shape);
3121
3108
  this.registerSchema(`${procName}ProcArgs`, schema);
3122
3109
  return schema;
3123
3110
  }
@@ -3125,10 +3112,10 @@ var ZodSchemaFactory = class {
3125
3112
  let schema;
3126
3113
  if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
3127
3114
  else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
3128
- else if (param.type in (this.schema.models ?? {})) schema = z$1.record(z$1.string(), z$1.unknown());
3115
+ else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
3129
3116
  else {
3130
3117
  schema = this.makeScalarSchema(param.type);
3131
- if (schema instanceof z$1.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
3118
+ if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
3132
3119
  }
3133
3120
  if (param.array) schema = schema.array();
3134
3121
  if (param.optional) schema = schema.optional();
@@ -3164,10 +3151,10 @@ var ZodSchemaFactory = class {
3164
3151
  return result;
3165
3152
  }
3166
3153
  makeSkipSchema() {
3167
- return z$1.number().int().nonnegative();
3154
+ return z.number().int().nonnegative();
3168
3155
  }
3169
3156
  makeTakeSchema() {
3170
- return z$1.number().int();
3157
+ return z.number().int();
3171
3158
  }
3172
3159
  refineForSelectIncludeMutuallyExclusive(schema) {
3173
3160
  return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
@@ -3186,7 +3173,7 @@ var ZodSchemaFactory = class {
3186
3173
  return nullable ? schema.nullable() : schema;
3187
3174
  }
3188
3175
  orArray(schema, canBeArray) {
3189
- return canBeArray ? z$1.union([schema, z$1.array(schema)]) : schema;
3176
+ return canBeArray ? z.union([schema, z.array(schema)]) : schema;
3190
3177
  }
3191
3178
  isNumericField(fieldDef) {
3192
3179
  return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
@@ -3242,10 +3229,10 @@ var ZodSchemaFactory = class {
3242
3229
  createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
3243
3230
  if (Object.keys(components).length === 0) {
3244
3231
  if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
3245
- return z$1.never();
3232
+ return z.never();
3246
3233
  }
3247
- if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z$1.union([this.nullableIf(valueSchema, optional), z$1.strictObject(components)]);
3248
- else return z$1.strictObject(components);
3234
+ if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
3235
+ else return z.strictObject(components);
3249
3236
  }
3250
3237
  canCreateModel(model) {
3251
3238
  const modelDef = requireModel(this.schema, model);
@@ -6849,9 +6836,9 @@ var ClientImpl = class ClientImpl {
6849
6836
  validateOptions(baseClient, options) {
6850
6837
  if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
6851
6838
  if (options.diagnostics) {
6852
- const parseResult = z.object({
6853
- slowQueryThresholdMs: z.number().nonnegative().optional(),
6854
- slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
6839
+ const parseResult = z$1.object({
6840
+ slowQueryThresholdMs: z$1.number().nonnegative().optional(),
6841
+ slowQueryMaxRecords: z$1.int().nonnegative().or(z$1.literal(Infinity)).optional()
6855
6842
  }).safeParse(options.diagnostics);
6856
6843
  if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
6857
6844
  }