@zenstackhq/orm 3.0.0-beta.26 → 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.cjs +171 -161
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +171 -161
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.cjs
CHANGED
|
@@ -632,6 +632,7 @@ var import_common_helpers3 = require("@zenstackhq/common-helpers");
|
|
|
632
632
|
var import_decimal = __toESM(require("decimal.js"), 1);
|
|
633
633
|
var import_kysely3 = require("kysely");
|
|
634
634
|
var import_ts_pattern3 = require("ts-pattern");
|
|
635
|
+
var import_zod = __toESM(require("zod"), 1);
|
|
635
636
|
|
|
636
637
|
// src/client/crud/dialects/base-dialect.ts
|
|
637
638
|
var import_common_helpers2 = require("@zenstackhq/common-helpers");
|
|
@@ -1301,6 +1302,10 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
|
|
|
1301
1302
|
static {
|
|
1302
1303
|
__name(this, "PostgresCrudDialect");
|
|
1303
1304
|
}
|
|
1305
|
+
isoDateSchema = import_zod.default.iso.datetime({
|
|
1306
|
+
local: true,
|
|
1307
|
+
offset: true
|
|
1308
|
+
});
|
|
1304
1309
|
constructor(schema, options) {
|
|
1305
1310
|
super(schema, options);
|
|
1306
1311
|
}
|
|
@@ -1349,7 +1354,12 @@ var PostgresCrudDialect = class extends BaseCrudDialect {
|
|
|
1349
1354
|
}
|
|
1350
1355
|
transformOutputDate(value) {
|
|
1351
1356
|
if (typeof value === "string") {
|
|
1352
|
-
|
|
1357
|
+
if (this.isoDateSchema.safeParse(value).success) {
|
|
1358
|
+
const hasOffset = value.endsWith("Z") || /[+-]\d{2}:\d{2}$/.test(value);
|
|
1359
|
+
return new Date(hasOffset ? value : `${value}Z`);
|
|
1360
|
+
} else {
|
|
1361
|
+
return value;
|
|
1362
|
+
}
|
|
1353
1363
|
} else if (value instanceof Date && this.options.fixPostgresTimezone !== false) {
|
|
1354
1364
|
return new Date(value.getTime() - value.getTimezoneOffset() * 60 * 1e3);
|
|
1355
1365
|
} else {
|
|
@@ -3631,7 +3641,7 @@ var import_common_helpers7 = require("@zenstackhq/common-helpers");
|
|
|
3631
3641
|
var import_decimal4 = __toESM(require("decimal.js"), 1);
|
|
3632
3642
|
var import_json_stable_stringify = __toESM(require("json-stable-stringify"), 1);
|
|
3633
3643
|
var import_ts_pattern13 = require("ts-pattern");
|
|
3634
|
-
var
|
|
3644
|
+
var import_zod3 = require("zod");
|
|
3635
3645
|
|
|
3636
3646
|
// src/utils/zod-utils.ts
|
|
3637
3647
|
var import_v4 = require("zod-validation-error/v4");
|
|
@@ -3644,7 +3654,7 @@ __name(formatError, "formatError");
|
|
|
3644
3654
|
var import_common_helpers6 = require("@zenstackhq/common-helpers");
|
|
3645
3655
|
var import_decimal3 = __toESM(require("decimal.js"), 1);
|
|
3646
3656
|
var import_ts_pattern12 = require("ts-pattern");
|
|
3647
|
-
var
|
|
3657
|
+
var import_zod2 = require("zod");
|
|
3648
3658
|
var import_v3 = require("zod/v3");
|
|
3649
3659
|
function getArgValue(expr) {
|
|
3650
3660
|
if (!expr || !schema_exports.ExpressionUtils.isLiteral(expr)) {
|
|
@@ -3753,13 +3763,13 @@ function addBigIntValidation(schema, attributes) {
|
|
|
3753
3763
|
__name(addBigIntValidation, "addBigIntValidation");
|
|
3754
3764
|
function addDecimalValidation(schema, attributes, addExtraValidation) {
|
|
3755
3765
|
let result = schema;
|
|
3756
|
-
if (schema instanceof
|
|
3766
|
+
if (schema instanceof import_zod2.z.ZodString) {
|
|
3757
3767
|
result = schema.superRefine((v, ctx) => {
|
|
3758
3768
|
try {
|
|
3759
3769
|
new import_decimal3.default(v);
|
|
3760
3770
|
} catch (err) {
|
|
3761
3771
|
ctx.addIssue({
|
|
3762
|
-
code:
|
|
3772
|
+
code: import_zod2.z.ZodIssueCode.custom,
|
|
3763
3773
|
message: `Invalid decimal: ${err}`
|
|
3764
3774
|
});
|
|
3765
3775
|
}
|
|
@@ -3767,7 +3777,7 @@ function addDecimalValidation(schema, attributes, addExtraValidation) {
|
|
|
3767
3777
|
}
|
|
3768
3778
|
function refine(schema2, op, value) {
|
|
3769
3779
|
return schema2.superRefine((v, ctx) => {
|
|
3770
|
-
const base =
|
|
3780
|
+
const base = import_zod2.z.number();
|
|
3771
3781
|
const { error } = base[op](value).safeParse(v.toNumber());
|
|
3772
3782
|
error?.issues.forEach((issue) => {
|
|
3773
3783
|
if (op === "gt" || op === "gte") {
|
|
@@ -3972,7 +3982,7 @@ function evalCall(data, expr) {
|
|
|
3972
3982
|
}
|
|
3973
3983
|
(0, import_common_helpers6.invariant)(typeof fieldArg === "string", `"${f}" first argument must be a string`);
|
|
3974
3984
|
const fn = (0, import_ts_pattern12.match)(f).with("isEmail", () => "email").with("isUrl", () => "url").with("isDateTime", () => "datetime").exhaustive();
|
|
3975
|
-
return
|
|
3985
|
+
return import_zod2.z.string()[fn]().safeParse(fieldArg).success;
|
|
3976
3986
|
}).with(import_ts_pattern12.P.union("has", "hasEvery", "hasSome"), (f) => {
|
|
3977
3987
|
(0, import_common_helpers6.invariant)(expr.args?.[1], `${f} requires a search argument`);
|
|
3978
3988
|
if (fieldArg === void 0 || fieldArg === null) {
|
|
@@ -4110,7 +4120,7 @@ var InputValidator = class {
|
|
|
4110
4120
|
if (!options.unique) {
|
|
4111
4121
|
fields["skip"] = this.makeSkipSchema().optional();
|
|
4112
4122
|
if (options.findOne) {
|
|
4113
|
-
fields["take"] =
|
|
4123
|
+
fields["take"] = import_zod3.z.literal(1).optional();
|
|
4114
4124
|
} else {
|
|
4115
4125
|
fields["take"] = this.makeTakeSchema().optional();
|
|
4116
4126
|
}
|
|
@@ -4118,7 +4128,7 @@ var InputValidator = class {
|
|
|
4118
4128
|
fields["cursor"] = this.makeCursorSchema(model).optional();
|
|
4119
4129
|
fields["distinct"] = this.makeDistinctSchema(model).optional();
|
|
4120
4130
|
}
|
|
4121
|
-
let result =
|
|
4131
|
+
let result = import_zod3.z.strictObject(fields);
|
|
4122
4132
|
result = this.refineForSelectIncludeMutuallyExclusive(result);
|
|
4123
4133
|
result = this.refineForSelectOmitMutuallyExclusive(result);
|
|
4124
4134
|
if (!options.unique) {
|
|
@@ -4132,19 +4142,19 @@ var InputValidator = class {
|
|
|
4132
4142
|
} else if (this.schema.enums && type in this.schema.enums) {
|
|
4133
4143
|
return this.makeEnumSchema(type);
|
|
4134
4144
|
} else {
|
|
4135
|
-
return (0, import_ts_pattern13.match)(type).with("String", () => this.extraValidationsEnabled ? addStringValidation(
|
|
4136
|
-
this.extraValidationsEnabled ? addNumberValidation(
|
|
4137
|
-
this.extraValidationsEnabled ? addBigIntValidation(
|
|
4145
|
+
return (0, import_ts_pattern13.match)(type).with("String", () => this.extraValidationsEnabled ? addStringValidation(import_zod3.z.string(), attributes) : import_zod3.z.string()).with("Int", () => this.extraValidationsEnabled ? addNumberValidation(import_zod3.z.number().int(), attributes) : import_zod3.z.number().int()).with("Float", () => this.extraValidationsEnabled ? addNumberValidation(import_zod3.z.number(), attributes) : import_zod3.z.number()).with("Boolean", () => import_zod3.z.boolean()).with("BigInt", () => import_zod3.z.union([
|
|
4146
|
+
this.extraValidationsEnabled ? addNumberValidation(import_zod3.z.number().int(), attributes) : import_zod3.z.number().int(),
|
|
4147
|
+
this.extraValidationsEnabled ? addBigIntValidation(import_zod3.z.bigint(), attributes) : import_zod3.z.bigint()
|
|
4138
4148
|
])).with("Decimal", () => {
|
|
4139
|
-
return
|
|
4140
|
-
this.extraValidationsEnabled ? addNumberValidation(
|
|
4141
|
-
addDecimalValidation(
|
|
4142
|
-
addDecimalValidation(
|
|
4149
|
+
return import_zod3.z.union([
|
|
4150
|
+
this.extraValidationsEnabled ? addNumberValidation(import_zod3.z.number(), attributes) : import_zod3.z.number(),
|
|
4151
|
+
addDecimalValidation(import_zod3.z.instanceof(import_decimal4.default), attributes, this.extraValidationsEnabled),
|
|
4152
|
+
addDecimalValidation(import_zod3.z.string(), attributes, this.extraValidationsEnabled)
|
|
4143
4153
|
]);
|
|
4144
|
-
}).with("DateTime", () =>
|
|
4145
|
-
|
|
4146
|
-
|
|
4147
|
-
])).with("Bytes", () =>
|
|
4154
|
+
}).with("DateTime", () => import_zod3.z.union([
|
|
4155
|
+
import_zod3.z.date(),
|
|
4156
|
+
import_zod3.z.string().datetime()
|
|
4157
|
+
])).with("Bytes", () => import_zod3.z.instanceof(Uint8Array)).otherwise(() => import_zod3.z.unknown());
|
|
4148
4158
|
}
|
|
4149
4159
|
}
|
|
4150
4160
|
makeEnumSchema(type) {
|
|
@@ -4158,7 +4168,7 @@ var InputValidator = class {
|
|
|
4158
4168
|
}
|
|
4159
4169
|
const enumDef = getEnum(this.schema, type);
|
|
4160
4170
|
(0, import_common_helpers7.invariant)(enumDef, `Enum "${type}" not found in schema`);
|
|
4161
|
-
schema =
|
|
4171
|
+
schema = import_zod3.z.enum(Object.keys(enumDef.values));
|
|
4162
4172
|
this.setSchemaCache(key, schema);
|
|
4163
4173
|
return schema;
|
|
4164
4174
|
}
|
|
@@ -4174,7 +4184,7 @@ var InputValidator = class {
|
|
|
4174
4184
|
}
|
|
4175
4185
|
const typeDef = getTypeDef(this.schema, type);
|
|
4176
4186
|
(0, import_common_helpers7.invariant)(typeDef, `Type definition "${type}" not found in schema`);
|
|
4177
|
-
schema =
|
|
4187
|
+
schema = import_zod3.z.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
4178
4188
|
let fieldSchema = this.makePrimitiveSchema(def.type);
|
|
4179
4189
|
if (def.array) {
|
|
4180
4190
|
fieldSchema = fieldSchema.array();
|
|
@@ -4200,21 +4210,21 @@ var InputValidator = class {
|
|
|
4200
4210
|
if (withoutRelationFields) {
|
|
4201
4211
|
continue;
|
|
4202
4212
|
}
|
|
4203
|
-
fieldSchema =
|
|
4213
|
+
fieldSchema = import_zod3.z.lazy(() => this.makeWhereSchema(fieldDef.type, false).optional());
|
|
4204
4214
|
fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
|
|
4205
4215
|
if (fieldDef.array) {
|
|
4206
|
-
fieldSchema =
|
|
4216
|
+
fieldSchema = import_zod3.z.union([
|
|
4207
4217
|
fieldSchema,
|
|
4208
|
-
|
|
4218
|
+
import_zod3.z.strictObject({
|
|
4209
4219
|
some: fieldSchema.optional(),
|
|
4210
4220
|
every: fieldSchema.optional(),
|
|
4211
4221
|
none: fieldSchema.optional()
|
|
4212
4222
|
})
|
|
4213
4223
|
]);
|
|
4214
4224
|
} else {
|
|
4215
|
-
fieldSchema =
|
|
4225
|
+
fieldSchema = import_zod3.z.union([
|
|
4216
4226
|
fieldSchema,
|
|
4217
|
-
|
|
4227
|
+
import_zod3.z.strictObject({
|
|
4218
4228
|
is: fieldSchema.optional(),
|
|
4219
4229
|
isNot: fieldSchema.optional()
|
|
4220
4230
|
})
|
|
@@ -4240,7 +4250,7 @@ var InputValidator = class {
|
|
|
4240
4250
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
4241
4251
|
for (const uniqueField of uniqueFields) {
|
|
4242
4252
|
if ("defs" in uniqueField) {
|
|
4243
|
-
fields[uniqueField.name] =
|
|
4253
|
+
fields[uniqueField.name] = import_zod3.z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
|
|
4244
4254
|
(0, import_common_helpers7.invariant)(!def.relation, "unique field cannot be a relation");
|
|
4245
4255
|
let fieldSchema;
|
|
4246
4256
|
const enumDef = getEnum(this.schema, def.type);
|
|
@@ -4248,7 +4258,7 @@ var InputValidator = class {
|
|
|
4248
4258
|
if (Object.keys(enumDef.values).length > 0) {
|
|
4249
4259
|
fieldSchema = this.makeEnumFilterSchema(enumDef, !!def.optional, false);
|
|
4250
4260
|
} else {
|
|
4251
|
-
fieldSchema =
|
|
4261
|
+
fieldSchema = import_zod3.z.never();
|
|
4252
4262
|
}
|
|
4253
4263
|
} else {
|
|
4254
4264
|
fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false);
|
|
@@ -4261,11 +4271,11 @@ var InputValidator = class {
|
|
|
4261
4271
|
}
|
|
4262
4272
|
}
|
|
4263
4273
|
}
|
|
4264
|
-
fields["$expr"] =
|
|
4265
|
-
fields["AND"] = this.orArray(
|
|
4266
|
-
fields["OR"] =
|
|
4267
|
-
fields["NOT"] = this.orArray(
|
|
4268
|
-
const baseWhere =
|
|
4274
|
+
fields["$expr"] = import_zod3.z.custom((v) => typeof v === "function").optional();
|
|
4275
|
+
fields["AND"] = this.orArray(import_zod3.z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)), true).optional();
|
|
4276
|
+
fields["OR"] = import_zod3.z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)).array().optional();
|
|
4277
|
+
fields["NOT"] = this.orArray(import_zod3.z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields)), true).optional();
|
|
4278
|
+
const baseWhere = import_zod3.z.strictObject(fields);
|
|
4269
4279
|
let result = baseWhere;
|
|
4270
4280
|
if (unique) {
|
|
4271
4281
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
@@ -4285,8 +4295,8 @@ var InputValidator = class {
|
|
|
4285
4295
|
return result;
|
|
4286
4296
|
}
|
|
4287
4297
|
makeEnumFilterSchema(enumDef, optional, withAggregations) {
|
|
4288
|
-
const baseSchema =
|
|
4289
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () =>
|
|
4298
|
+
const baseSchema = import_zod3.z.enum(Object.keys(enumDef.values));
|
|
4299
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => import_zod3.z.lazy(() => this.makeEnumFilterSchema(enumDef, optional, withAggregations)), [
|
|
4290
4300
|
"equals",
|
|
4291
4301
|
"in",
|
|
4292
4302
|
"notIn",
|
|
@@ -4296,41 +4306,41 @@ var InputValidator = class {
|
|
|
4296
4306
|
"_min",
|
|
4297
4307
|
"_max"
|
|
4298
4308
|
] : void 0);
|
|
4299
|
-
return
|
|
4309
|
+
return import_zod3.z.union([
|
|
4300
4310
|
this.nullableIf(baseSchema, optional),
|
|
4301
|
-
|
|
4311
|
+
import_zod3.z.strictObject(components)
|
|
4302
4312
|
]);
|
|
4303
4313
|
}
|
|
4304
4314
|
makeArrayFilterSchema(type) {
|
|
4305
|
-
return
|
|
4315
|
+
return import_zod3.z.strictObject({
|
|
4306
4316
|
equals: this.makePrimitiveSchema(type).array().optional(),
|
|
4307
4317
|
has: this.makePrimitiveSchema(type).optional(),
|
|
4308
4318
|
hasEvery: this.makePrimitiveSchema(type).array().optional(),
|
|
4309
4319
|
hasSome: this.makePrimitiveSchema(type).array().optional(),
|
|
4310
|
-
isEmpty:
|
|
4320
|
+
isEmpty: import_zod3.z.boolean().optional()
|
|
4311
4321
|
});
|
|
4312
4322
|
}
|
|
4313
4323
|
makePrimitiveFilterSchema(type, optional, withAggregations) {
|
|
4314
4324
|
if (this.schema.typeDefs && type in this.schema.typeDefs) {
|
|
4315
4325
|
return this.makeTypeDefFilterSchema(type, optional);
|
|
4316
4326
|
}
|
|
4317
|
-
return (0, import_ts_pattern13.match)(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations)).with(import_ts_pattern13.P.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", () =>
|
|
4327
|
+
return (0, import_ts_pattern13.match)(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations)).with(import_ts_pattern13.P.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", () => import_zod3.z.any()).with("Unsupported", () => import_zod3.z.never()).exhaustive();
|
|
4318
4328
|
}
|
|
4319
4329
|
makeTypeDefFilterSchema(_type, _optional) {
|
|
4320
|
-
return
|
|
4330
|
+
return import_zod3.z.never();
|
|
4321
4331
|
}
|
|
4322
4332
|
makeDateTimeFilterSchema(optional, withAggregations) {
|
|
4323
|
-
return this.makeCommonPrimitiveFilterSchema(
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
]), optional, () =>
|
|
4333
|
+
return this.makeCommonPrimitiveFilterSchema(import_zod3.z.union([
|
|
4334
|
+
import_zod3.z.string().datetime(),
|
|
4335
|
+
import_zod3.z.date()
|
|
4336
|
+
]), optional, () => import_zod3.z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations)), withAggregations ? [
|
|
4327
4337
|
"_count",
|
|
4328
4338
|
"_min",
|
|
4329
4339
|
"_max"
|
|
4330
4340
|
] : void 0);
|
|
4331
4341
|
}
|
|
4332
4342
|
makeBooleanFilterSchema(optional, withAggregations) {
|
|
4333
|
-
const components = this.makeCommonPrimitiveFilterComponents(
|
|
4343
|
+
const components = this.makeCommonPrimitiveFilterComponents(import_zod3.z.boolean(), optional, () => import_zod3.z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations)), [
|
|
4334
4344
|
"equals",
|
|
4335
4345
|
"not"
|
|
4336
4346
|
], withAggregations ? [
|
|
@@ -4338,14 +4348,14 @@ var InputValidator = class {
|
|
|
4338
4348
|
"_min",
|
|
4339
4349
|
"_max"
|
|
4340
4350
|
] : void 0);
|
|
4341
|
-
return
|
|
4342
|
-
this.nullableIf(
|
|
4343
|
-
|
|
4351
|
+
return import_zod3.z.union([
|
|
4352
|
+
this.nullableIf(import_zod3.z.boolean(), optional),
|
|
4353
|
+
import_zod3.z.strictObject(components)
|
|
4344
4354
|
]);
|
|
4345
4355
|
}
|
|
4346
4356
|
makeBytesFilterSchema(optional, withAggregations) {
|
|
4347
|
-
const baseSchema =
|
|
4348
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () =>
|
|
4357
|
+
const baseSchema = import_zod3.z.instanceof(Uint8Array);
|
|
4358
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => import_zod3.z.instanceof(Uint8Array), [
|
|
4349
4359
|
"equals",
|
|
4350
4360
|
"in",
|
|
4351
4361
|
"notIn",
|
|
@@ -4355,9 +4365,9 @@ var InputValidator = class {
|
|
|
4355
4365
|
"_min",
|
|
4356
4366
|
"_max"
|
|
4357
4367
|
] : void 0);
|
|
4358
|
-
return
|
|
4368
|
+
return import_zod3.z.union([
|
|
4359
4369
|
this.nullableIf(baseSchema, optional),
|
|
4360
|
-
|
|
4370
|
+
import_zod3.z.strictObject(components)
|
|
4361
4371
|
]);
|
|
4362
4372
|
}
|
|
4363
4373
|
makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, supportedOperators = void 0, withAggregations = void 0) {
|
|
@@ -4373,7 +4383,7 @@ var InputValidator = class {
|
|
|
4373
4383
|
gte: baseSchema.optional(),
|
|
4374
4384
|
not: makeThis().optional(),
|
|
4375
4385
|
...withAggregations?.includes("_count") ? {
|
|
4376
|
-
_count: this.makeNumberFilterSchema(
|
|
4386
|
+
_count: this.makeNumberFilterSchema(import_zod3.z.number().int(), false, false).optional()
|
|
4377
4387
|
} : {},
|
|
4378
4388
|
...withAggregations?.includes("_avg") ? {
|
|
4379
4389
|
_avg: commonAggSchema()
|
|
@@ -4398,13 +4408,13 @@ var InputValidator = class {
|
|
|
4398
4408
|
return result;
|
|
4399
4409
|
}
|
|
4400
4410
|
makeCommonPrimitiveFilterSchema(baseSchema, optional, makeThis, withAggregations = void 0) {
|
|
4401
|
-
return
|
|
4411
|
+
return import_zod3.z.union([
|
|
4402
4412
|
this.nullableIf(baseSchema, optional),
|
|
4403
|
-
|
|
4413
|
+
import_zod3.z.strictObject(this.makeCommonPrimitiveFilterComponents(baseSchema, optional, makeThis, void 0, withAggregations))
|
|
4404
4414
|
]);
|
|
4405
4415
|
}
|
|
4406
4416
|
makeNumberFilterSchema(baseSchema, optional, withAggregations) {
|
|
4407
|
-
return this.makeCommonPrimitiveFilterSchema(baseSchema, optional, () =>
|
|
4417
|
+
return this.makeCommonPrimitiveFilterSchema(baseSchema, optional, () => import_zod3.z.lazy(() => this.makeNumberFilterSchema(baseSchema, optional, withAggregations)), withAggregations ? [
|
|
4408
4418
|
"_count",
|
|
4409
4419
|
"_avg",
|
|
4410
4420
|
"_sum",
|
|
@@ -4413,17 +4423,17 @@ var InputValidator = class {
|
|
|
4413
4423
|
] : void 0);
|
|
4414
4424
|
}
|
|
4415
4425
|
makeStringFilterSchema(optional, withAggregations) {
|
|
4416
|
-
return
|
|
4417
|
-
this.nullableIf(
|
|
4418
|
-
|
|
4419
|
-
...this.makeCommonPrimitiveFilterComponents(
|
|
4426
|
+
return import_zod3.z.union([
|
|
4427
|
+
this.nullableIf(import_zod3.z.string(), optional),
|
|
4428
|
+
import_zod3.z.strictObject({
|
|
4429
|
+
...this.makeCommonPrimitiveFilterComponents(import_zod3.z.string(), optional, () => import_zod3.z.lazy(() => this.makeStringFilterSchema(optional, withAggregations)), void 0, withAggregations ? [
|
|
4420
4430
|
"_count",
|
|
4421
4431
|
"_min",
|
|
4422
4432
|
"_max"
|
|
4423
4433
|
] : void 0),
|
|
4424
|
-
startsWith:
|
|
4425
|
-
endsWith:
|
|
4426
|
-
contains:
|
|
4434
|
+
startsWith: import_zod3.z.string().optional(),
|
|
4435
|
+
endsWith: import_zod3.z.string().optional(),
|
|
4436
|
+
contains: import_zod3.z.string().optional(),
|
|
4427
4437
|
...this.providerSupportsCaseSensitivity ? {
|
|
4428
4438
|
mode: this.makeStringModeSchema().optional()
|
|
4429
4439
|
} : {}
|
|
@@ -4431,9 +4441,9 @@ var InputValidator = class {
|
|
|
4431
4441
|
]);
|
|
4432
4442
|
}
|
|
4433
4443
|
makeStringModeSchema() {
|
|
4434
|
-
return
|
|
4435
|
-
|
|
4436
|
-
|
|
4444
|
+
return import_zod3.z.union([
|
|
4445
|
+
import_zod3.z.literal("default"),
|
|
4446
|
+
import_zod3.z.literal("insensitive")
|
|
4437
4447
|
]);
|
|
4438
4448
|
}
|
|
4439
4449
|
makeSelectSchema(model) {
|
|
@@ -4444,26 +4454,26 @@ var InputValidator = class {
|
|
|
4444
4454
|
if (fieldDef.relation) {
|
|
4445
4455
|
fields[field] = this.makeRelationSelectIncludeSchema(fieldDef).optional();
|
|
4446
4456
|
} else {
|
|
4447
|
-
fields[field] =
|
|
4457
|
+
fields[field] = import_zod3.z.boolean().optional();
|
|
4448
4458
|
}
|
|
4449
4459
|
}
|
|
4450
4460
|
const _countSchema = this.makeCountSelectionSchema(modelDef);
|
|
4451
4461
|
if (_countSchema) {
|
|
4452
4462
|
fields["_count"] = _countSchema;
|
|
4453
4463
|
}
|
|
4454
|
-
return
|
|
4464
|
+
return import_zod3.z.strictObject(fields);
|
|
4455
4465
|
}
|
|
4456
4466
|
makeCountSelectionSchema(modelDef) {
|
|
4457
4467
|
const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
|
|
4458
4468
|
if (toManyRelations.length > 0) {
|
|
4459
|
-
return
|
|
4460
|
-
|
|
4461
|
-
|
|
4462
|
-
select:
|
|
4469
|
+
return import_zod3.z.union([
|
|
4470
|
+
import_zod3.z.literal(true),
|
|
4471
|
+
import_zod3.z.strictObject({
|
|
4472
|
+
select: import_zod3.z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
4463
4473
|
...acc,
|
|
4464
|
-
[fieldDef.name]:
|
|
4465
|
-
|
|
4466
|
-
|
|
4474
|
+
[fieldDef.name]: import_zod3.z.union([
|
|
4475
|
+
import_zod3.z.boolean(),
|
|
4476
|
+
import_zod3.z.strictObject({
|
|
4467
4477
|
where: this.makeWhereSchema(fieldDef.type, false, false)
|
|
4468
4478
|
})
|
|
4469
4479
|
]).optional()
|
|
@@ -4475,17 +4485,17 @@ var InputValidator = class {
|
|
|
4475
4485
|
}
|
|
4476
4486
|
}
|
|
4477
4487
|
makeRelationSelectIncludeSchema(fieldDef) {
|
|
4478
|
-
let objSchema =
|
|
4488
|
+
let objSchema = import_zod3.z.strictObject({
|
|
4479
4489
|
...fieldDef.array || fieldDef.optional ? {
|
|
4480
4490
|
// to-many relations and optional to-one relations are filterable
|
|
4481
|
-
where:
|
|
4491
|
+
where: import_zod3.z.lazy(() => this.makeWhereSchema(fieldDef.type, false)).optional()
|
|
4482
4492
|
} : {},
|
|
4483
|
-
select:
|
|
4484
|
-
include:
|
|
4485
|
-
omit:
|
|
4493
|
+
select: import_zod3.z.lazy(() => this.makeSelectSchema(fieldDef.type)).optional().nullable(),
|
|
4494
|
+
include: import_zod3.z.lazy(() => this.makeIncludeSchema(fieldDef.type)).optional().nullable(),
|
|
4495
|
+
omit: import_zod3.z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
|
|
4486
4496
|
...fieldDef.array ? {
|
|
4487
4497
|
// to-many relations can be ordered, skipped, taken, and cursor-located
|
|
4488
|
-
orderBy:
|
|
4498
|
+
orderBy: import_zod3.z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false), true)).optional(),
|
|
4489
4499
|
skip: this.makeSkipSchema().optional(),
|
|
4490
4500
|
take: this.makeTakeSchema().optional(),
|
|
4491
4501
|
cursor: this.makeCursorSchema(fieldDef.type).optional(),
|
|
@@ -4494,8 +4504,8 @@ var InputValidator = class {
|
|
|
4494
4504
|
});
|
|
4495
4505
|
objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
|
|
4496
4506
|
objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
|
|
4497
|
-
return
|
|
4498
|
-
|
|
4507
|
+
return import_zod3.z.union([
|
|
4508
|
+
import_zod3.z.boolean(),
|
|
4499
4509
|
objSchema
|
|
4500
4510
|
]);
|
|
4501
4511
|
}
|
|
@@ -4506,13 +4516,13 @@ var InputValidator = class {
|
|
|
4506
4516
|
const fieldDef = requireField(this.schema, model, field);
|
|
4507
4517
|
if (!fieldDef.relation) {
|
|
4508
4518
|
if (this.options.allowQueryTimeOmitOverride !== false) {
|
|
4509
|
-
fields[field] =
|
|
4519
|
+
fields[field] = import_zod3.z.boolean().optional();
|
|
4510
4520
|
} else {
|
|
4511
|
-
fields[field] =
|
|
4521
|
+
fields[field] = import_zod3.z.literal(true).optional();
|
|
4512
4522
|
}
|
|
4513
4523
|
}
|
|
4514
4524
|
}
|
|
4515
|
-
return
|
|
4525
|
+
return import_zod3.z.strictObject(fields);
|
|
4516
4526
|
}
|
|
4517
4527
|
makeIncludeSchema(model) {
|
|
4518
4528
|
const modelDef = requireModel(this.schema, model);
|
|
@@ -4527,20 +4537,20 @@ var InputValidator = class {
|
|
|
4527
4537
|
if (_countSchema) {
|
|
4528
4538
|
fields["_count"] = _countSchema;
|
|
4529
4539
|
}
|
|
4530
|
-
return
|
|
4540
|
+
return import_zod3.z.strictObject(fields);
|
|
4531
4541
|
}
|
|
4532
4542
|
makeOrderBySchema(model, withRelation, WithAggregation) {
|
|
4533
4543
|
const modelDef = requireModel(this.schema, model);
|
|
4534
4544
|
const fields = {};
|
|
4535
|
-
const sort =
|
|
4536
|
-
|
|
4537
|
-
|
|
4545
|
+
const sort = import_zod3.z.union([
|
|
4546
|
+
import_zod3.z.literal("asc"),
|
|
4547
|
+
import_zod3.z.literal("desc")
|
|
4538
4548
|
]);
|
|
4539
4549
|
for (const field of Object.keys(modelDef.fields)) {
|
|
4540
4550
|
const fieldDef = requireField(this.schema, model, field);
|
|
4541
4551
|
if (fieldDef.relation) {
|
|
4542
4552
|
if (withRelation) {
|
|
4543
|
-
fields[field] =
|
|
4553
|
+
fields[field] = import_zod3.z.lazy(() => {
|
|
4544
4554
|
let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation);
|
|
4545
4555
|
if (fieldDef.array) {
|
|
4546
4556
|
relationOrderBy = relationOrderBy.extend({
|
|
@@ -4552,13 +4562,13 @@ var InputValidator = class {
|
|
|
4552
4562
|
}
|
|
4553
4563
|
} else {
|
|
4554
4564
|
if (fieldDef.optional) {
|
|
4555
|
-
fields[field] =
|
|
4565
|
+
fields[field] = import_zod3.z.union([
|
|
4556
4566
|
sort,
|
|
4557
|
-
|
|
4567
|
+
import_zod3.z.strictObject({
|
|
4558
4568
|
sort,
|
|
4559
|
-
nulls:
|
|
4560
|
-
|
|
4561
|
-
|
|
4569
|
+
nulls: import_zod3.z.union([
|
|
4570
|
+
import_zod3.z.literal("first"),
|
|
4571
|
+
import_zod3.z.literal("last")
|
|
4562
4572
|
])
|
|
4563
4573
|
})
|
|
4564
4574
|
]).optional();
|
|
@@ -4576,15 +4586,15 @@ var InputValidator = class {
|
|
|
4576
4586
|
"_max"
|
|
4577
4587
|
];
|
|
4578
4588
|
for (const agg of aggregationFields) {
|
|
4579
|
-
fields[agg] =
|
|
4589
|
+
fields[agg] = import_zod3.z.lazy(() => this.makeOrderBySchema(model, true, false).optional());
|
|
4580
4590
|
}
|
|
4581
4591
|
}
|
|
4582
|
-
return
|
|
4592
|
+
return import_zod3.z.strictObject(fields);
|
|
4583
4593
|
}
|
|
4584
4594
|
makeDistinctSchema(model) {
|
|
4585
4595
|
const modelDef = requireModel(this.schema, model);
|
|
4586
4596
|
const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation);
|
|
4587
|
-
return this.orArray(
|
|
4597
|
+
return this.orArray(import_zod3.z.enum(nonRelationFields), true);
|
|
4588
4598
|
}
|
|
4589
4599
|
makeCursorSchema(model) {
|
|
4590
4600
|
return this.makeWhereSchema(model, true, true).optional();
|
|
@@ -4593,7 +4603,7 @@ var InputValidator = class {
|
|
|
4593
4603
|
// #region Create
|
|
4594
4604
|
makeCreateSchema(model) {
|
|
4595
4605
|
const dataSchema = this.makeCreateDataSchema(model, false);
|
|
4596
|
-
let schema =
|
|
4606
|
+
let schema = import_zod3.z.strictObject({
|
|
4597
4607
|
data: dataSchema,
|
|
4598
4608
|
select: this.makeSelectSchema(model).optional().nullable(),
|
|
4599
4609
|
include: this.makeIncludeSchema(model).optional().nullable(),
|
|
@@ -4643,7 +4653,7 @@ var InputValidator = class {
|
|
|
4643
4653
|
excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
4644
4654
|
}
|
|
4645
4655
|
}
|
|
4646
|
-
let fieldSchema =
|
|
4656
|
+
let fieldSchema = import_zod3.z.lazy(() => this.makeRelationManipulationSchema(fieldDef, excludeFields, "create"));
|
|
4647
4657
|
if (fieldDef.optional || fieldDef.array) {
|
|
4648
4658
|
fieldSchema = fieldSchema.optional();
|
|
4649
4659
|
} else {
|
|
@@ -4669,9 +4679,9 @@ var InputValidator = class {
|
|
|
4669
4679
|
let fieldSchema = this.makePrimitiveSchema(fieldDef.type, fieldDef.attributes);
|
|
4670
4680
|
if (fieldDef.array) {
|
|
4671
4681
|
fieldSchema = addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
4672
|
-
fieldSchema =
|
|
4682
|
+
fieldSchema = import_zod3.z.union([
|
|
4673
4683
|
fieldSchema,
|
|
4674
|
-
|
|
4684
|
+
import_zod3.z.strictObject({
|
|
4675
4685
|
set: fieldSchema
|
|
4676
4686
|
})
|
|
4677
4687
|
]).optional();
|
|
@@ -4688,19 +4698,19 @@ var InputValidator = class {
|
|
|
4688
4698
|
}
|
|
4689
4699
|
}
|
|
4690
4700
|
});
|
|
4691
|
-
const uncheckedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(
|
|
4692
|
-
const checkedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(
|
|
4701
|
+
const uncheckedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(import_zod3.z.strictObject(uncheckedVariantFields), modelDef.attributes) : import_zod3.z.strictObject(uncheckedVariantFields);
|
|
4702
|
+
const checkedCreateSchema = this.extraValidationsEnabled ? addCustomValidation(import_zod3.z.strictObject(checkedVariantFields), modelDef.attributes) : import_zod3.z.strictObject(checkedVariantFields);
|
|
4693
4703
|
if (!hasRelation) {
|
|
4694
4704
|
return this.orArray(uncheckedCreateSchema, canBeArray);
|
|
4695
4705
|
} else {
|
|
4696
|
-
return
|
|
4706
|
+
return import_zod3.z.union([
|
|
4697
4707
|
uncheckedCreateSchema,
|
|
4698
4708
|
checkedCreateSchema,
|
|
4699
4709
|
...canBeArray ? [
|
|
4700
|
-
|
|
4710
|
+
import_zod3.z.array(uncheckedCreateSchema)
|
|
4701
4711
|
] : [],
|
|
4702
4712
|
...canBeArray ? [
|
|
4703
|
-
|
|
4713
|
+
import_zod3.z.array(checkedCreateSchema)
|
|
4704
4714
|
] : []
|
|
4705
4715
|
]);
|
|
4706
4716
|
}
|
|
@@ -4728,11 +4738,11 @@ var InputValidator = class {
|
|
|
4728
4738
|
fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array).optional();
|
|
4729
4739
|
fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true).optional();
|
|
4730
4740
|
}
|
|
4731
|
-
fields["update"] = array ? this.orArray(
|
|
4741
|
+
fields["update"] = array ? this.orArray(import_zod3.z.strictObject({
|
|
4732
4742
|
where: this.makeWhereSchema(fieldType, true).optional(),
|
|
4733
4743
|
data: this.makeUpdateDataSchema(fieldType, withoutFields)
|
|
4734
|
-
}), true).optional() :
|
|
4735
|
-
|
|
4744
|
+
}), true).optional() : import_zod3.z.union([
|
|
4745
|
+
import_zod3.z.strictObject({
|
|
4736
4746
|
where: this.makeWhereSchema(fieldType, true).optional(),
|
|
4737
4747
|
data: this.makeUpdateDataSchema(fieldType, withoutFields)
|
|
4738
4748
|
}),
|
|
@@ -4742,21 +4752,21 @@ var InputValidator = class {
|
|
|
4742
4752
|
if (!fieldDef.array) {
|
|
4743
4753
|
upsertWhere = upsertWhere.optional();
|
|
4744
4754
|
}
|
|
4745
|
-
fields["upsert"] = this.orArray(
|
|
4755
|
+
fields["upsert"] = this.orArray(import_zod3.z.strictObject({
|
|
4746
4756
|
where: upsertWhere,
|
|
4747
4757
|
create: this.makeCreateDataSchema(fieldType, false, withoutFields),
|
|
4748
4758
|
update: this.makeUpdateDataSchema(fieldType, withoutFields)
|
|
4749
4759
|
}), true).optional();
|
|
4750
4760
|
if (array) {
|
|
4751
4761
|
fields["set"] = this.makeSetDataSchema(fieldType, true).optional();
|
|
4752
|
-
fields["updateMany"] = this.orArray(
|
|
4762
|
+
fields["updateMany"] = this.orArray(import_zod3.z.strictObject({
|
|
4753
4763
|
where: this.makeWhereSchema(fieldType, false, true),
|
|
4754
4764
|
data: this.makeUpdateDataSchema(fieldType, withoutFields)
|
|
4755
4765
|
}), true).optional();
|
|
4756
4766
|
fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false).optional();
|
|
4757
4767
|
}
|
|
4758
4768
|
}
|
|
4759
|
-
return
|
|
4769
|
+
return import_zod3.z.strictObject(fields);
|
|
4760
4770
|
}
|
|
4761
4771
|
makeSetDataSchema(model, canBeArray) {
|
|
4762
4772
|
return this.orArray(this.makeWhereSchema(model, true), canBeArray);
|
|
@@ -4768,36 +4778,36 @@ var InputValidator = class {
|
|
|
4768
4778
|
if (canBeArray) {
|
|
4769
4779
|
return this.orArray(this.makeWhereSchema(model, true), canBeArray);
|
|
4770
4780
|
} else {
|
|
4771
|
-
return
|
|
4772
|
-
|
|
4781
|
+
return import_zod3.z.union([
|
|
4782
|
+
import_zod3.z.boolean(),
|
|
4773
4783
|
this.makeWhereSchema(model, false)
|
|
4774
4784
|
]);
|
|
4775
4785
|
}
|
|
4776
4786
|
}
|
|
4777
4787
|
makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter) {
|
|
4778
|
-
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter), true) :
|
|
4779
|
-
|
|
4788
|
+
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter), true) : import_zod3.z.union([
|
|
4789
|
+
import_zod3.z.boolean(),
|
|
4780
4790
|
this.makeWhereSchema(model, uniqueFilter)
|
|
4781
4791
|
]);
|
|
4782
4792
|
}
|
|
4783
4793
|
makeConnectOrCreateDataSchema(model, canBeArray, withoutFields) {
|
|
4784
4794
|
const whereSchema = this.makeWhereSchema(model, true);
|
|
4785
4795
|
const createSchema = this.makeCreateDataSchema(model, false, withoutFields);
|
|
4786
|
-
return this.orArray(
|
|
4796
|
+
return this.orArray(import_zod3.z.strictObject({
|
|
4787
4797
|
where: whereSchema,
|
|
4788
4798
|
create: createSchema
|
|
4789
4799
|
}), canBeArray);
|
|
4790
4800
|
}
|
|
4791
4801
|
makeCreateManyDataSchema(model, withoutFields) {
|
|
4792
|
-
return
|
|
4802
|
+
return import_zod3.z.strictObject({
|
|
4793
4803
|
data: this.makeCreateDataSchema(model, true, withoutFields, true),
|
|
4794
|
-
skipDuplicates:
|
|
4804
|
+
skipDuplicates: import_zod3.z.boolean().optional()
|
|
4795
4805
|
});
|
|
4796
4806
|
}
|
|
4797
4807
|
// #endregion
|
|
4798
4808
|
// #region Update
|
|
4799
4809
|
makeUpdateSchema(model) {
|
|
4800
|
-
let schema =
|
|
4810
|
+
let schema = import_zod3.z.strictObject({
|
|
4801
4811
|
where: this.makeWhereSchema(model, true),
|
|
4802
4812
|
data: this.makeUpdateDataSchema(model),
|
|
4803
4813
|
select: this.makeSelectSchema(model).optional().nullable(),
|
|
@@ -4809,10 +4819,10 @@ var InputValidator = class {
|
|
|
4809
4819
|
return schema;
|
|
4810
4820
|
}
|
|
4811
4821
|
makeUpdateManySchema(model) {
|
|
4812
|
-
return
|
|
4822
|
+
return import_zod3.z.strictObject({
|
|
4813
4823
|
where: this.makeWhereSchema(model, false).optional(),
|
|
4814
4824
|
data: this.makeUpdateDataSchema(model, [], true),
|
|
4815
|
-
limit:
|
|
4825
|
+
limit: import_zod3.z.number().int().nonnegative().optional()
|
|
4816
4826
|
});
|
|
4817
4827
|
}
|
|
4818
4828
|
makeUpdateManyAndReturnSchema(model) {
|
|
@@ -4825,7 +4835,7 @@ var InputValidator = class {
|
|
|
4825
4835
|
return schema;
|
|
4826
4836
|
}
|
|
4827
4837
|
makeUpsertSchema(model) {
|
|
4828
|
-
let schema =
|
|
4838
|
+
let schema = import_zod3.z.strictObject({
|
|
4829
4839
|
where: this.makeWhereSchema(model, true),
|
|
4830
4840
|
create: this.makeCreateDataSchema(model, false),
|
|
4831
4841
|
update: this.makeUpdateDataSchema(model),
|
|
@@ -4860,7 +4870,7 @@ var InputValidator = class {
|
|
|
4860
4870
|
excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
4861
4871
|
}
|
|
4862
4872
|
}
|
|
4863
|
-
let fieldSchema =
|
|
4873
|
+
let fieldSchema = import_zod3.z.lazy(() => this.makeRelationManipulationSchema(fieldDef, excludeFields, "update")).optional();
|
|
4864
4874
|
if (fieldDef.optional && !fieldDef.array) {
|
|
4865
4875
|
fieldSchema = fieldSchema.nullable();
|
|
4866
4876
|
}
|
|
@@ -4871,24 +4881,24 @@ var InputValidator = class {
|
|
|
4871
4881
|
} else {
|
|
4872
4882
|
let fieldSchema = this.makePrimitiveSchema(fieldDef.type, fieldDef.attributes);
|
|
4873
4883
|
if (this.isNumericField(fieldDef)) {
|
|
4874
|
-
fieldSchema =
|
|
4884
|
+
fieldSchema = import_zod3.z.union([
|
|
4875
4885
|
fieldSchema,
|
|
4876
|
-
|
|
4877
|
-
set: this.nullableIf(
|
|
4878
|
-
increment:
|
|
4879
|
-
decrement:
|
|
4880
|
-
multiply:
|
|
4881
|
-
divide:
|
|
4886
|
+
import_zod3.z.object({
|
|
4887
|
+
set: this.nullableIf(import_zod3.z.number().optional(), !!fieldDef.optional).optional(),
|
|
4888
|
+
increment: import_zod3.z.number().optional(),
|
|
4889
|
+
decrement: import_zod3.z.number().optional(),
|
|
4890
|
+
multiply: import_zod3.z.number().optional(),
|
|
4891
|
+
divide: import_zod3.z.number().optional()
|
|
4882
4892
|
}).refine((v) => Object.keys(v).length === 1, 'Only one of "set", "increment", "decrement", "multiply", or "divide" can be provided')
|
|
4883
4893
|
]);
|
|
4884
4894
|
}
|
|
4885
4895
|
if (fieldDef.array) {
|
|
4886
4896
|
const arraySchema = addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
4887
|
-
fieldSchema =
|
|
4897
|
+
fieldSchema = import_zod3.z.union([
|
|
4888
4898
|
arraySchema,
|
|
4889
|
-
|
|
4899
|
+
import_zod3.z.object({
|
|
4890
4900
|
set: arraySchema.optional(),
|
|
4891
|
-
push:
|
|
4901
|
+
push: import_zod3.z.union([
|
|
4892
4902
|
fieldSchema,
|
|
4893
4903
|
fieldSchema.array()
|
|
4894
4904
|
]).optional()
|
|
@@ -4905,12 +4915,12 @@ var InputValidator = class {
|
|
|
4905
4915
|
}
|
|
4906
4916
|
}
|
|
4907
4917
|
});
|
|
4908
|
-
const uncheckedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(
|
|
4909
|
-
const checkedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(
|
|
4918
|
+
const uncheckedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(import_zod3.z.strictObject(uncheckedVariantFields), modelDef.attributes) : import_zod3.z.strictObject(uncheckedVariantFields);
|
|
4919
|
+
const checkedUpdateSchema = this.extraValidationsEnabled ? addCustomValidation(import_zod3.z.strictObject(checkedVariantFields), modelDef.attributes) : import_zod3.z.strictObject(checkedVariantFields);
|
|
4910
4920
|
if (!hasRelation) {
|
|
4911
4921
|
return uncheckedUpdateSchema;
|
|
4912
4922
|
} else {
|
|
4913
|
-
return
|
|
4923
|
+
return import_zod3.z.union([
|
|
4914
4924
|
uncheckedUpdateSchema,
|
|
4915
4925
|
checkedUpdateSchema
|
|
4916
4926
|
]);
|
|
@@ -4919,7 +4929,7 @@ var InputValidator = class {
|
|
|
4919
4929
|
// #endregion
|
|
4920
4930
|
// #region Delete
|
|
4921
4931
|
makeDeleteSchema(model) {
|
|
4922
|
-
let schema =
|
|
4932
|
+
let schema = import_zod3.z.strictObject({
|
|
4923
4933
|
where: this.makeWhereSchema(model, true),
|
|
4924
4934
|
select: this.makeSelectSchema(model).optional().nullable(),
|
|
4925
4935
|
include: this.makeIncludeSchema(model).optional().nullable(),
|
|
@@ -4930,15 +4940,15 @@ var InputValidator = class {
|
|
|
4930
4940
|
return schema;
|
|
4931
4941
|
}
|
|
4932
4942
|
makeDeleteManySchema(model) {
|
|
4933
|
-
return
|
|
4943
|
+
return import_zod3.z.object({
|
|
4934
4944
|
where: this.makeWhereSchema(model, false).optional(),
|
|
4935
|
-
limit:
|
|
4945
|
+
limit: import_zod3.z.number().int().nonnegative().optional()
|
|
4936
4946
|
}).optional();
|
|
4937
4947
|
}
|
|
4938
4948
|
// #endregion
|
|
4939
4949
|
// #region Count
|
|
4940
4950
|
makeCountSchema(model) {
|
|
4941
|
-
return
|
|
4951
|
+
return import_zod3.z.object({
|
|
4942
4952
|
where: this.makeWhereSchema(model, false).optional(),
|
|
4943
4953
|
skip: this.makeSkipSchema().optional(),
|
|
4944
4954
|
take: this.makeTakeSchema().optional(),
|
|
@@ -4948,12 +4958,12 @@ var InputValidator = class {
|
|
|
4948
4958
|
}
|
|
4949
4959
|
makeCountAggregateInputSchema(model) {
|
|
4950
4960
|
const modelDef = requireModel(this.schema, model);
|
|
4951
|
-
return
|
|
4952
|
-
|
|
4953
|
-
|
|
4954
|
-
_all:
|
|
4961
|
+
return import_zod3.z.union([
|
|
4962
|
+
import_zod3.z.literal(true),
|
|
4963
|
+
import_zod3.z.strictObject({
|
|
4964
|
+
_all: import_zod3.z.literal(true).optional(),
|
|
4955
4965
|
...Object.keys(modelDef.fields).reduce((acc, field) => {
|
|
4956
|
-
acc[field] =
|
|
4966
|
+
acc[field] = import_zod3.z.literal(true).optional();
|
|
4957
4967
|
return acc;
|
|
4958
4968
|
}, {})
|
|
4959
4969
|
})
|
|
@@ -4962,7 +4972,7 @@ var InputValidator = class {
|
|
|
4962
4972
|
// #endregion
|
|
4963
4973
|
// #region Aggregate
|
|
4964
4974
|
makeAggregateSchema(model) {
|
|
4965
|
-
return
|
|
4975
|
+
return import_zod3.z.object({
|
|
4966
4976
|
where: this.makeWhereSchema(model, false).optional(),
|
|
4967
4977
|
skip: this.makeSkipSchema().optional(),
|
|
4968
4978
|
take: this.makeTakeSchema().optional(),
|
|
@@ -4976,20 +4986,20 @@ var InputValidator = class {
|
|
|
4976
4986
|
}
|
|
4977
4987
|
makeSumAvgInputSchema(model) {
|
|
4978
4988
|
const modelDef = requireModel(this.schema, model);
|
|
4979
|
-
return
|
|
4989
|
+
return import_zod3.z.strictObject(Object.keys(modelDef.fields).reduce((acc, field) => {
|
|
4980
4990
|
const fieldDef = requireField(this.schema, model, field);
|
|
4981
4991
|
if (this.isNumericField(fieldDef)) {
|
|
4982
|
-
acc[field] =
|
|
4992
|
+
acc[field] = import_zod3.z.literal(true).optional();
|
|
4983
4993
|
}
|
|
4984
4994
|
return acc;
|
|
4985
4995
|
}, {}));
|
|
4986
4996
|
}
|
|
4987
4997
|
makeMinMaxInputSchema(model) {
|
|
4988
4998
|
const modelDef = requireModel(this.schema, model);
|
|
4989
|
-
return
|
|
4999
|
+
return import_zod3.z.strictObject(Object.keys(modelDef.fields).reduce((acc, field) => {
|
|
4990
5000
|
const fieldDef = requireField(this.schema, model, field);
|
|
4991
5001
|
if (!fieldDef.relation && !fieldDef.array) {
|
|
4992
|
-
acc[field] =
|
|
5002
|
+
acc[field] = import_zod3.z.literal(true).optional();
|
|
4993
5003
|
}
|
|
4994
5004
|
return acc;
|
|
4995
5005
|
}, {}));
|
|
@@ -4997,8 +5007,8 @@ var InputValidator = class {
|
|
|
4997
5007
|
makeGroupBySchema(model) {
|
|
4998
5008
|
const modelDef = requireModel(this.schema, model);
|
|
4999
5009
|
const nonRelationFields = Object.keys(modelDef.fields).filter((field) => !modelDef.fields[field]?.relation);
|
|
5000
|
-
const bySchema = nonRelationFields.length > 0 ? this.orArray(
|
|
5001
|
-
let schema =
|
|
5010
|
+
const bySchema = nonRelationFields.length > 0 ? this.orArray(import_zod3.z.enum(nonRelationFields), true) : import_zod3.z.never();
|
|
5011
|
+
let schema = import_zod3.z.strictObject({
|
|
5002
5012
|
where: this.makeWhereSchema(model, false).optional(),
|
|
5003
5013
|
orderBy: this.orArray(this.makeOrderBySchema(model, false, true), true).optional(),
|
|
5004
5014
|
by: bySchema,
|
|
@@ -5065,10 +5075,10 @@ var InputValidator = class {
|
|
|
5065
5075
|
// #endregion
|
|
5066
5076
|
// #region Helpers
|
|
5067
5077
|
makeSkipSchema() {
|
|
5068
|
-
return
|
|
5078
|
+
return import_zod3.z.number().int().nonnegative();
|
|
5069
5079
|
}
|
|
5070
5080
|
makeTakeSchema() {
|
|
5071
|
-
return
|
|
5081
|
+
return import_zod3.z.number().int();
|
|
5072
5082
|
}
|
|
5073
5083
|
refineForSelectIncludeMutuallyExclusive(schema) {
|
|
5074
5084
|
return schema.refine((value) => !(value["select"] && value["include"]), '"select" and "include" cannot be used together');
|
|
@@ -5080,9 +5090,9 @@ var InputValidator = class {
|
|
|
5080
5090
|
return nullable ? schema.nullable() : schema;
|
|
5081
5091
|
}
|
|
5082
5092
|
orArray(schema, canBeArray) {
|
|
5083
|
-
return canBeArray ?
|
|
5093
|
+
return canBeArray ? import_zod3.z.union([
|
|
5084
5094
|
schema,
|
|
5085
|
-
|
|
5095
|
+
import_zod3.z.array(schema)
|
|
5086
5096
|
]) : schema;
|
|
5087
5097
|
}
|
|
5088
5098
|
isNumericField(fieldDef) {
|