@zenstackhq/orm 3.6.3-beta.1 → 3.6.4
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.d.mts +2 -2
- package/dist/index.mjs +162 -162
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
2
2
|
import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
3
3
|
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
|
|
4
|
+
import z, { ZodObject, ZodType, z as z$1 } from "zod";
|
|
5
5
|
import { fromError } from "zod-validation-error/v4";
|
|
6
6
|
import { P, match } from "ts-pattern";
|
|
7
7
|
import { ExpressionUtils } from "@zenstackhq/schema";
|
|
@@ -2075,7 +2075,7 @@ function createQuerySchemaFactory(clientOrSchema, options) {
|
|
|
2075
2075
|
*/
|
|
2076
2076
|
var ZodSchemaFactory = class {
|
|
2077
2077
|
schemaCache = /* @__PURE__ */ new Map();
|
|
2078
|
-
schemaRegistry = z.registry();
|
|
2078
|
+
schemaRegistry = z$1.registry();
|
|
2079
2079
|
allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
|
|
2080
2080
|
schema;
|
|
2081
2081
|
options;
|
|
@@ -2167,7 +2167,7 @@ var ZodSchemaFactory = class {
|
|
|
2167
2167
|
this.makeGroupBySchema(m);
|
|
2168
2168
|
}
|
|
2169
2169
|
for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
|
|
2170
|
-
return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
|
|
2170
|
+
return z$1.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
|
|
2171
2171
|
}
|
|
2172
2172
|
get cacheStats() {
|
|
2173
2173
|
return {
|
|
@@ -2196,13 +2196,13 @@ var ZodSchemaFactory = class {
|
|
|
2196
2196
|
fields["omit"] = this.makeOmitSchema(model).optional().nullable();
|
|
2197
2197
|
if (!unique) {
|
|
2198
2198
|
fields["skip"] = this.makeSkipSchema().optional();
|
|
2199
|
-
if (findOne) fields["take"] = z.literal(1).optional();
|
|
2199
|
+
if (findOne) fields["take"] = z$1.literal(1).optional();
|
|
2200
2200
|
else fields["take"] = this.makeTakeSchema().optional();
|
|
2201
2201
|
fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
|
|
2202
2202
|
fields["cursor"] = this.makeCursorSchema(model, options).optional();
|
|
2203
2203
|
fields["distinct"] = this.makeDistinctSchema(model).optional();
|
|
2204
2204
|
}
|
|
2205
|
-
const baseSchema = z.strictObject(fields);
|
|
2205
|
+
const baseSchema = z$1.strictObject(fields);
|
|
2206
2206
|
let result = this.mergePluginArgsSchema(baseSchema, operation);
|
|
2207
2207
|
result = this.refineForSelectIncludeMutuallyExclusive(result);
|
|
2208
2208
|
result = this.refineForSelectOmitMutuallyExclusive(result);
|
|
@@ -2212,7 +2212,7 @@ var ZodSchemaFactory = class {
|
|
|
2212
2212
|
return result;
|
|
2213
2213
|
}
|
|
2214
2214
|
makeExistsSchema(model, options) {
|
|
2215
|
-
const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
|
|
2215
|
+
const baseSchema = z$1.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
|
|
2216
2216
|
const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
|
|
2217
2217
|
this.registerSchema(`${model}ExistsArgs`, result);
|
|
2218
2218
|
return result;
|
|
@@ -2220,31 +2220,31 @@ var ZodSchemaFactory = class {
|
|
|
2220
2220
|
makeScalarSchema(type, attributes) {
|
|
2221
2221
|
if (this.schema.typeDefs && type in this.schema.typeDefs) return this.makeTypeDefSchema(type);
|
|
2222
2222
|
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.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", () => {
|
|
2224
|
-
return z.union([
|
|
2225
|
-
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number(),
|
|
2226
|
-
ZodUtils.addDecimalValidation(z.instanceof(Decimal), attributes, this.extraValidationsEnabled),
|
|
2227
|
-
ZodUtils.addDecimalValidation(z.string(), attributes, this.extraValidationsEnabled)
|
|
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)
|
|
2228
2228
|
]);
|
|
2229
|
-
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
|
|
2229
|
+
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z$1.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z$1.unknown());
|
|
2230
2230
|
}
|
|
2231
2231
|
makeEnumSchema(_enum) {
|
|
2232
2232
|
const enumDef = getEnum(this.schema, _enum);
|
|
2233
2233
|
invariant(enumDef, `Enum "${_enum}" not found in schema`);
|
|
2234
|
-
const schema = z.enum(Object.keys(enumDef.values));
|
|
2234
|
+
const schema = z$1.enum(Object.keys(enumDef.values));
|
|
2235
2235
|
this.registerSchema(_enum, schema);
|
|
2236
2236
|
return schema;
|
|
2237
2237
|
}
|
|
2238
2238
|
makeTypeDefSchema(type) {
|
|
2239
2239
|
const typeDef = getTypeDef(this.schema, type);
|
|
2240
2240
|
invariant(typeDef, `Type definition "${type}" not found in schema`);
|
|
2241
|
-
const schema = z.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
2241
|
+
const schema = z$1.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
2242
2242
|
let fieldSchema = this.makeScalarSchema(def.type);
|
|
2243
2243
|
if (def.array) fieldSchema = fieldSchema.array();
|
|
2244
2244
|
if (def.optional) fieldSchema = fieldSchema.nullish();
|
|
2245
2245
|
return [field, fieldSchema];
|
|
2246
2246
|
})));
|
|
2247
|
-
const finalSchema = z.any().superRefine((value, ctx) => {
|
|
2247
|
+
const finalSchema = z$1.any().superRefine((value, ctx) => {
|
|
2248
2248
|
const parseResult = schema.safeParse(value);
|
|
2249
2249
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
2250
2250
|
});
|
|
@@ -2260,17 +2260,17 @@ var ZodSchemaFactory = class {
|
|
|
2260
2260
|
if (fieldDef.relation) {
|
|
2261
2261
|
if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
|
|
2262
2262
|
const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
|
|
2263
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
|
|
2263
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z$1.never();
|
|
2264
2264
|
else {
|
|
2265
|
-
fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
|
|
2266
|
-
if (fieldDef.array) fieldSchema = z.strictObject({
|
|
2265
|
+
fieldSchema = z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
|
|
2266
|
+
if (fieldDef.array) fieldSchema = z$1.strictObject({
|
|
2267
2267
|
some: fieldSchema.optional(),
|
|
2268
2268
|
every: fieldSchema.optional(),
|
|
2269
2269
|
none: fieldSchema.optional()
|
|
2270
2270
|
});
|
|
2271
2271
|
else {
|
|
2272
2272
|
fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
|
|
2273
|
-
fieldSchema = z.union([fieldSchema, z.strictObject({
|
|
2273
|
+
fieldSchema = z$1.union([fieldSchema, z$1.strictObject({
|
|
2274
2274
|
is: fieldSchema.optional(),
|
|
2275
2275
|
isNot: fieldSchema.optional()
|
|
2276
2276
|
})]);
|
|
@@ -2289,21 +2289,21 @@ var ZodSchemaFactory = class {
|
|
|
2289
2289
|
}
|
|
2290
2290
|
if (unique) {
|
|
2291
2291
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
2292
|
-
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
|
|
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]) => {
|
|
2293
2293
|
invariant(!def.relation, "unique field cannot be a relation");
|
|
2294
2294
|
let fieldSchema;
|
|
2295
2295
|
const enumDef = getEnum(this.schema, def.type);
|
|
2296
2296
|
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.never();
|
|
2297
|
+
else fieldSchema = z$1.never();
|
|
2298
2298
|
else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
|
|
2299
2299
|
return [key, fieldSchema];
|
|
2300
2300
|
}))).optional();
|
|
2301
2301
|
}
|
|
2302
|
-
fields["$expr"] = z.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
|
|
2303
|
-
fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2304
|
-
fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
|
|
2305
|
-
fields["NOT"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2306
|
-
const baseWhere = z.strictObject(fields);
|
|
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);
|
|
2307
2307
|
let result = baseWhere;
|
|
2308
2308
|
if (unique) {
|
|
2309
2309
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
@@ -2329,26 +2329,26 @@ var ZodSchemaFactory = class {
|
|
|
2329
2329
|
else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
|
|
2330
2330
|
else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
|
|
2331
2331
|
else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(fieldDef.type, !!fieldDef.optional, false, void 0).optional();
|
|
2332
|
-
candidates.push(z.strictObject(fieldSchemas));
|
|
2332
|
+
candidates.push(z$1.strictObject(fieldSchemas));
|
|
2333
2333
|
}
|
|
2334
|
-
const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
|
|
2335
|
-
if (array) candidates.push(z.strictObject({
|
|
2334
|
+
const recursiveSchema = z$1.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
|
|
2335
|
+
if (array) candidates.push(z$1.strictObject({
|
|
2336
2336
|
some: recursiveSchema,
|
|
2337
2337
|
every: recursiveSchema,
|
|
2338
2338
|
none: recursiveSchema
|
|
2339
2339
|
}));
|
|
2340
|
-
else candidates.push(z.strictObject({
|
|
2340
|
+
else candidates.push(z$1.strictObject({
|
|
2341
2341
|
is: recursiveSchema,
|
|
2342
2342
|
isNot: recursiveSchema
|
|
2343
2343
|
}));
|
|
2344
2344
|
candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
|
|
2345
2345
|
if (optional) {
|
|
2346
|
-
candidates.push(z.null());
|
|
2347
|
-
candidates.push(z.instanceof(DbNullClass));
|
|
2348
|
-
candidates.push(z.instanceof(JsonNullClass));
|
|
2349
|
-
candidates.push(z.instanceof(AnyNullClass));
|
|
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));
|
|
2350
2350
|
}
|
|
2351
|
-
const result = z.union(candidates);
|
|
2351
|
+
const result = z$1.union(candidates);
|
|
2352
2352
|
this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
|
|
2353
2353
|
optional,
|
|
2354
2354
|
array,
|
|
@@ -2357,7 +2357,7 @@ var ZodSchemaFactory = class {
|
|
|
2357
2357
|
return result;
|
|
2358
2358
|
}
|
|
2359
2359
|
makeNullableTypedJsonMutationSchema(fieldSchema) {
|
|
2360
|
-
return z.any().superRefine((value, ctx) => {
|
|
2360
|
+
return z$1.any().superRefine((value, ctx) => {
|
|
2361
2361
|
if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
|
|
2362
2362
|
const parseResult = fieldSchema.safeParse(value);
|
|
2363
2363
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
@@ -2369,11 +2369,11 @@ var ZodSchemaFactory = class {
|
|
|
2369
2369
|
makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
|
|
2370
2370
|
const enumDef = getEnum(this.schema, enumName);
|
|
2371
2371
|
invariant(enumDef, `Enum "${enumName}" not found in schema`);
|
|
2372
|
-
const baseSchema = z.enum(Object.keys(enumDef.values));
|
|
2372
|
+
const baseSchema = z$1.enum(Object.keys(enumDef.values));
|
|
2373
2373
|
let schema;
|
|
2374
2374
|
if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
|
|
2375
2375
|
else {
|
|
2376
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
|
|
2376
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
|
|
2377
2377
|
"equals",
|
|
2378
2378
|
"in",
|
|
2379
2379
|
"notIn",
|
|
@@ -2407,42 +2407,42 @@ var ZodSchemaFactory = class {
|
|
|
2407
2407
|
has: elementSchema.optional(),
|
|
2408
2408
|
hasEvery: elementSchema.array().optional(),
|
|
2409
2409
|
hasSome: elementSchema.array().optional(),
|
|
2410
|
-
isEmpty: z.boolean().optional()
|
|
2410
|
+
isEmpty: z$1.boolean().optional()
|
|
2411
2411
|
};
|
|
2412
2412
|
const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
|
|
2413
|
-
return z.strictObject(filteredOperators);
|
|
2413
|
+
return z$1.strictObject(filteredOperators);
|
|
2414
2414
|
}
|
|
2415
2415
|
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.never()).exhaustive();
|
|
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();
|
|
2417
2417
|
}
|
|
2418
2418
|
makeJsonValueSchema() {
|
|
2419
|
-
const schema = z.union([
|
|
2420
|
-
z.string(),
|
|
2421
|
-
z.number(),
|
|
2422
|
-
z.boolean(),
|
|
2423
|
-
z.instanceof(JsonNullClass),
|
|
2424
|
-
z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()]).array()),
|
|
2425
|
-
z.record(z.string(), z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()])))
|
|
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()])))
|
|
2426
2426
|
]);
|
|
2427
2427
|
this.registerSchema("JsonValue", schema);
|
|
2428
2428
|
return schema;
|
|
2429
2429
|
}
|
|
2430
2430
|
makeJsonFilterSchema(optional, allowedFilterKinds) {
|
|
2431
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
|
|
2431
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z$1.never();
|
|
2432
2432
|
const filterMembers = [
|
|
2433
2433
|
this.makeJsonValueSchema(),
|
|
2434
|
-
z.instanceof(DbNullClass),
|
|
2435
|
-
z.instanceof(AnyNullClass)
|
|
2434
|
+
z$1.instanceof(DbNullClass),
|
|
2435
|
+
z$1.instanceof(AnyNullClass)
|
|
2436
2436
|
];
|
|
2437
|
-
if (optional) filterMembers.push(z.null());
|
|
2438
|
-
const filterValueSchema = z.union(filterMembers);
|
|
2439
|
-
const schema = z.strictObject({
|
|
2440
|
-
path: z.string().optional(),
|
|
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(),
|
|
2441
2441
|
equals: filterValueSchema.optional(),
|
|
2442
2442
|
not: filterValueSchema.optional(),
|
|
2443
|
-
string_contains: z.string().optional(),
|
|
2444
|
-
string_starts_with: z.string().optional(),
|
|
2445
|
-
string_ends_with: z.string().optional(),
|
|
2443
|
+
string_contains: z$1.string().optional(),
|
|
2444
|
+
string_starts_with: z$1.string().optional(),
|
|
2445
|
+
string_ends_with: z$1.string().optional(),
|
|
2446
2446
|
mode: this.makeStringModeSchema().optional(),
|
|
2447
2447
|
array_contains: filterValueSchema.optional(),
|
|
2448
2448
|
array_starts_with: filterValueSchema.optional(),
|
|
@@ -2455,17 +2455,17 @@ var ZodSchemaFactory = class {
|
|
|
2455
2455
|
return schema;
|
|
2456
2456
|
}
|
|
2457
2457
|
makeDateTimeValueSchema() {
|
|
2458
|
-
const schema = z.union([
|
|
2459
|
-
z.iso.datetime(),
|
|
2460
|
-
z.iso.date(),
|
|
2461
|
-
z.date()
|
|
2458
|
+
const schema = z$1.union([
|
|
2459
|
+
z$1.iso.datetime(),
|
|
2460
|
+
z$1.iso.date(),
|
|
2461
|
+
z$1.date()
|
|
2462
2462
|
]);
|
|
2463
2463
|
this.registerSchema("DateTime", schema);
|
|
2464
2464
|
return schema;
|
|
2465
2465
|
}
|
|
2466
2466
|
makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2467
2467
|
const filterValueSchema = this.makeDateTimeValueSchema();
|
|
2468
|
-
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2468
|
+
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z$1.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2469
2469
|
"_count",
|
|
2470
2470
|
"_min",
|
|
2471
2471
|
"_max"
|
|
@@ -2478,12 +2478,12 @@ var ZodSchemaFactory = class {
|
|
|
2478
2478
|
return schema;
|
|
2479
2479
|
}
|
|
2480
2480
|
makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2481
|
-
const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
|
|
2481
|
+
const components = this.makeCommonPrimitiveFilterComponents(z$1.boolean(), optional, () => z$1.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
|
|
2482
2482
|
"_count",
|
|
2483
2483
|
"_min",
|
|
2484
2484
|
"_max"
|
|
2485
2485
|
] : void 0, allowedFilterKinds);
|
|
2486
|
-
const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
|
|
2486
|
+
const schema = this.createUnionFilterSchema(z$1.boolean(), optional, components, allowedFilterKinds);
|
|
2487
2487
|
this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
|
|
2488
2488
|
optional,
|
|
2489
2489
|
allowedFilterKinds,
|
|
@@ -2492,8 +2492,8 @@ var ZodSchemaFactory = class {
|
|
|
2492
2492
|
return schema;
|
|
2493
2493
|
}
|
|
2494
2494
|
makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2495
|
-
const baseSchema = z.instanceof(Uint8Array);
|
|
2496
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
|
|
2495
|
+
const baseSchema = z$1.instanceof(Uint8Array);
|
|
2496
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.instanceof(Uint8Array), [
|
|
2497
2497
|
"equals",
|
|
2498
2498
|
"in",
|
|
2499
2499
|
"notIn",
|
|
@@ -2541,7 +2541,7 @@ var ZodSchemaFactory = class {
|
|
|
2541
2541
|
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
2542
2542
|
}
|
|
2543
2543
|
makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
|
|
2544
|
-
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2544
|
+
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z$1.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2545
2545
|
"_count",
|
|
2546
2546
|
"_avg",
|
|
2547
2547
|
"_sum",
|
|
@@ -2556,15 +2556,15 @@ var ZodSchemaFactory = class {
|
|
|
2556
2556
|
return schema;
|
|
2557
2557
|
}
|
|
2558
2558
|
makeStringFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2559
|
-
const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)), void 0, withAggregations ? [
|
|
2559
|
+
const baseComponents = this.makeCommonPrimitiveFilterComponents(z$1.string(), optional, () => z$1.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds)), void 0, withAggregations ? [
|
|
2560
2560
|
"_count",
|
|
2561
2561
|
"_min",
|
|
2562
2562
|
"_max"
|
|
2563
2563
|
] : void 0, allowedFilterKinds);
|
|
2564
2564
|
const stringSpecificOperators = {
|
|
2565
|
-
startsWith: z.string().optional(),
|
|
2566
|
-
endsWith: z.string().optional(),
|
|
2567
|
-
contains: z.string().optional(),
|
|
2565
|
+
startsWith: z$1.string().optional(),
|
|
2566
|
+
endsWith: z$1.string().optional(),
|
|
2567
|
+
contains: z$1.string().optional(),
|
|
2568
2568
|
...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
|
|
2569
2569
|
};
|
|
2570
2570
|
const filteredStringOperators = this.trimFilterOperators(stringSpecificOperators, allowedFilterKinds);
|
|
@@ -2572,7 +2572,7 @@ var ZodSchemaFactory = class {
|
|
|
2572
2572
|
...baseComponents,
|
|
2573
2573
|
...filteredStringOperators
|
|
2574
2574
|
};
|
|
2575
|
-
const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
|
|
2575
|
+
const schema = this.createUnionFilterSchema(z$1.string(), optional, allComponents, allowedFilterKinds);
|
|
2576
2576
|
this.registerSchema(`StringFilter${this.filterSchemaSuffix({
|
|
2577
2577
|
optional,
|
|
2578
2578
|
allowedFilterKinds,
|
|
@@ -2581,20 +2581,20 @@ var ZodSchemaFactory = class {
|
|
|
2581
2581
|
return schema;
|
|
2582
2582
|
}
|
|
2583
2583
|
makeStringModeSchema() {
|
|
2584
|
-
return z.union([z.literal("default"), z.literal("insensitive")]);
|
|
2584
|
+
return z$1.union([z$1.literal("default"), z$1.literal("insensitive")]);
|
|
2585
2585
|
}
|
|
2586
2586
|
makeSelectSchema(model, options) {
|
|
2587
2587
|
const fields = {};
|
|
2588
2588
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2589
2589
|
if (!this.shouldIncludeRelations(options)) continue;
|
|
2590
2590
|
if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
|
|
2591
|
-
} else fields[field] = z.boolean().optional();
|
|
2591
|
+
} else fields[field] = z$1.boolean().optional();
|
|
2592
2592
|
if (this.shouldIncludeRelations(options)) {
|
|
2593
2593
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2594
|
-
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
2594
|
+
if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
|
|
2595
2595
|
}
|
|
2596
2596
|
this.addExtResultFields(model, fields);
|
|
2597
|
-
const result = z.strictObject(fields);
|
|
2597
|
+
const result = z$1.strictObject(fields);
|
|
2598
2598
|
this.registerSchema(`${model}Select`, result);
|
|
2599
2599
|
return result;
|
|
2600
2600
|
}
|
|
@@ -2603,24 +2603,24 @@ var ZodSchemaFactory = class {
|
|
|
2603
2603
|
const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
|
|
2604
2604
|
if (toManyRelations.length > 0) {
|
|
2605
2605
|
const nextOpts = this.nextOptions(options);
|
|
2606
|
-
const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
2606
|
+
const schema = z$1.union([z$1.literal(true), z$1.strictObject({ select: z$1.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
2607
2607
|
...acc,
|
|
2608
|
-
[fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
|
|
2608
|
+
[fieldDef.name]: z$1.union([z$1.boolean(), z$1.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
|
|
2609
2609
|
}), {})) })]).optional();
|
|
2610
2610
|
this.registerSchema(`${model}CountSelection`, schema);
|
|
2611
2611
|
return schema;
|
|
2612
|
-
} else return z.never();
|
|
2612
|
+
} else return z$1.never();
|
|
2613
2613
|
}
|
|
2614
2614
|
makeRelationSelectIncludeSchema(model, field, options) {
|
|
2615
2615
|
const fieldDef = requireField(this.schema, model, field);
|
|
2616
2616
|
const nextOpts = this.nextOptions(options);
|
|
2617
|
-
let objSchema = z.strictObject({
|
|
2618
|
-
...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
|
|
2619
|
-
select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2620
|
-
include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2621
|
-
omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
|
|
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(),
|
|
2622
2622
|
...fieldDef.array ? {
|
|
2623
|
-
orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
|
|
2623
|
+
orderBy: z$1.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
|
|
2624
2624
|
skip: this.makeSkipSchema().optional(),
|
|
2625
2625
|
take: this.makeTakeSchema().optional(),
|
|
2626
2626
|
cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
|
|
@@ -2630,16 +2630,16 @@ var ZodSchemaFactory = class {
|
|
|
2630
2630
|
objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
|
|
2631
2631
|
objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
|
|
2632
2632
|
objSchema = this.refineForSelectHasTruthyField(objSchema);
|
|
2633
|
-
const result = z.union([z.boolean(), objSchema]);
|
|
2633
|
+
const result = z$1.union([z$1.boolean(), objSchema]);
|
|
2634
2634
|
this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
|
|
2635
2635
|
return result;
|
|
2636
2636
|
}
|
|
2637
2637
|
makeOmitSchema(model) {
|
|
2638
2638
|
const fields = {};
|
|
2639
|
-
for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
|
|
2640
|
-
else fields[field] = z.literal(true).optional();
|
|
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();
|
|
2641
2641
|
this.addExtResultFields(model, fields);
|
|
2642
|
-
const result = z.strictObject(fields);
|
|
2642
|
+
const result = z$1.strictObject(fields);
|
|
2643
2643
|
this.registerSchema(`${model}OmitInput`, result);
|
|
2644
2644
|
return result;
|
|
2645
2645
|
}
|
|
@@ -2648,7 +2648,7 @@ var ZodSchemaFactory = class {
|
|
|
2648
2648
|
const resultConfig = plugin.result;
|
|
2649
2649
|
if (resultConfig) {
|
|
2650
2650
|
const modelConfig = resultConfig[lowerCaseFirst(model)];
|
|
2651
|
-
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
|
|
2651
|
+
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z$1.boolean().optional();
|
|
2652
2652
|
}
|
|
2653
2653
|
}
|
|
2654
2654
|
}
|
|
@@ -2664,26 +2664,26 @@ var ZodSchemaFactory = class {
|
|
|
2664
2664
|
}
|
|
2665
2665
|
if (this.shouldIncludeRelations(options)) {
|
|
2666
2666
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2667
|
-
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
2667
|
+
if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
|
|
2668
2668
|
}
|
|
2669
|
-
const result = z.strictObject(fields);
|
|
2669
|
+
const result = z$1.strictObject(fields);
|
|
2670
2670
|
this.registerSchema(`${model}Include`, result);
|
|
2671
2671
|
return result;
|
|
2672
2672
|
}
|
|
2673
2673
|
makeOrderBySchema(model, withRelation, WithAggregation, options) {
|
|
2674
2674
|
const fields = {};
|
|
2675
|
-
const sort = z.union([z.literal("asc"), z.literal("desc")]);
|
|
2675
|
+
const sort = z$1.union([z$1.literal("asc"), z$1.literal("desc")]);
|
|
2676
2676
|
const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
|
|
2677
2677
|
const nextOpts = this.nextOptions(options);
|
|
2678
2678
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2679
|
-
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
|
|
2679
|
+
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z$1.lazy(() => {
|
|
2680
2680
|
let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
|
|
2681
2681
|
if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
|
|
2682
2682
|
return relationOrderBy;
|
|
2683
2683
|
}).optional();
|
|
2684
|
-
} else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
|
|
2684
|
+
} else if (fieldDef.optional) fields[field] = z$1.union([sort, z$1.strictObject({
|
|
2685
2685
|
sort,
|
|
2686
|
-
nulls: z.union([z.literal("first"), z.literal("last")])
|
|
2686
|
+
nulls: z$1.union([z$1.literal("first"), z$1.literal("last")])
|
|
2687
2687
|
})]).optional();
|
|
2688
2688
|
else fields[field] = sort.optional();
|
|
2689
2689
|
if (WithAggregation) for (const agg of [
|
|
@@ -2692,8 +2692,8 @@ var ZodSchemaFactory = class {
|
|
|
2692
2692
|
"_sum",
|
|
2693
2693
|
"_min",
|
|
2694
2694
|
"_max"
|
|
2695
|
-
]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
|
|
2696
|
-
const schema = refineAtMostOneKey(z.strictObject(fields));
|
|
2695
|
+
]) fields[agg] = z$1.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
|
|
2696
|
+
const schema = refineAtMostOneKey(z$1.strictObject(fields));
|
|
2697
2697
|
let schemaId = `${model}OrderBy`;
|
|
2698
2698
|
if (withRelation) schemaId += "WithRelation";
|
|
2699
2699
|
if (WithAggregation) schemaId += "WithAggregation";
|
|
@@ -2703,7 +2703,7 @@ var ZodSchemaFactory = class {
|
|
|
2703
2703
|
}
|
|
2704
2704
|
makeDistinctSchema(model) {
|
|
2705
2705
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
|
|
2706
|
-
const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
2706
|
+
const schema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
|
|
2707
2707
|
this.registerSchema(`${model}DistinctInput`, schema);
|
|
2708
2708
|
return schema;
|
|
2709
2709
|
}
|
|
@@ -2714,7 +2714,7 @@ var ZodSchemaFactory = class {
|
|
|
2714
2714
|
}
|
|
2715
2715
|
makeCreateSchema(model, options) {
|
|
2716
2716
|
const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
|
|
2717
|
-
const baseSchema = z.strictObject({
|
|
2717
|
+
const baseSchema = z$1.strictObject({
|
|
2718
2718
|
data: dataSchema,
|
|
2719
2719
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
2720
2720
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -2763,7 +2763,7 @@ var ZodSchemaFactory = class {
|
|
|
2763
2763
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
2764
2764
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
2765
2765
|
}
|
|
2766
|
-
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
|
|
2766
|
+
let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
|
|
2767
2767
|
if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
|
|
2768
2768
|
else {
|
|
2769
2769
|
let allFksOptional = false;
|
|
@@ -2780,23 +2780,23 @@ var ZodSchemaFactory = class {
|
|
|
2780
2780
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
|
|
2781
2781
|
if (fieldDef.array) {
|
|
2782
2782
|
fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
2783
|
-
fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
|
|
2783
|
+
fieldSchema = z$1.union([fieldSchema, z$1.strictObject({ set: fieldSchema })]).optional();
|
|
2784
2784
|
}
|
|
2785
2785
|
if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
|
|
2786
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
2786
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
|
|
2787
2787
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
2788
2788
|
else fieldSchema = fieldSchema.nullable();
|
|
2789
2789
|
uncheckedVariantFields[field] = fieldSchema;
|
|
2790
2790
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
2791
2791
|
}
|
|
2792
2792
|
});
|
|
2793
|
-
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
2794
|
-
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
2795
|
-
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
|
|
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([
|
|
2796
2796
|
uncheckedCreateSchema,
|
|
2797
2797
|
checkedCreateSchema,
|
|
2798
|
-
...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
|
|
2799
|
-
...canBeArray ? [z.array(checkedCreateSchema)] : []
|
|
2798
|
+
...canBeArray ? [z$1.array(uncheckedCreateSchema)] : [],
|
|
2799
|
+
...canBeArray ? [z$1.array(checkedCreateSchema)] : []
|
|
2800
2800
|
]);
|
|
2801
2801
|
const idParts = [`${model}CreateData`];
|
|
2802
2802
|
if (canBeArray) idParts.push("Array");
|
|
@@ -2821,17 +2821,17 @@ var ZodSchemaFactory = class {
|
|
|
2821
2821
|
fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
|
|
2822
2822
|
fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
|
|
2823
2823
|
}
|
|
2824
|
-
fields["update"] = array ? this.orArray(z.strictObject({
|
|
2824
|
+
fields["update"] = array ? this.orArray(z$1.strictObject({
|
|
2825
2825
|
where: this.makeWhereSchema(fieldType, true, false, false, options),
|
|
2826
2826
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
2827
|
-
}), true).optional() : z.union([z.strictObject({
|
|
2827
|
+
}), true).optional() : z$1.union([z$1.strictObject({
|
|
2828
2828
|
where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
|
|
2829
2829
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
2830
2830
|
}), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
|
|
2831
2831
|
if (canCreateModel) {
|
|
2832
2832
|
let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
|
|
2833
2833
|
if (!fieldDef.array) upsertWhere = upsertWhere.optional();
|
|
2834
|
-
fields["upsert"] = this.orArray(z.strictObject({
|
|
2834
|
+
fields["upsert"] = this.orArray(z$1.strictObject({
|
|
2835
2835
|
where: upsertWhere,
|
|
2836
2836
|
create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
|
|
2837
2837
|
update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
@@ -2839,14 +2839,14 @@ var ZodSchemaFactory = class {
|
|
|
2839
2839
|
}
|
|
2840
2840
|
if (array) {
|
|
2841
2841
|
fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
|
|
2842
|
-
fields["updateMany"] = this.orArray(z.strictObject({
|
|
2842
|
+
fields["updateMany"] = this.orArray(z$1.strictObject({
|
|
2843
2843
|
where: this.makeWhereSchema(fieldType, false, true, false, options),
|
|
2844
2844
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
2845
2845
|
}), true).optional();
|
|
2846
2846
|
fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
|
|
2847
2847
|
}
|
|
2848
2848
|
}
|
|
2849
|
-
return z.strictObject(fields);
|
|
2849
|
+
return z$1.strictObject(fields);
|
|
2850
2850
|
}
|
|
2851
2851
|
makeSetDataSchema(model, canBeArray, options) {
|
|
2852
2852
|
return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
@@ -2856,23 +2856,23 @@ var ZodSchemaFactory = class {
|
|
|
2856
2856
|
}
|
|
2857
2857
|
makeDisconnectDataSchema(model, canBeArray, options) {
|
|
2858
2858
|
if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
2859
|
-
else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
|
|
2859
|
+
else return z$1.union([z$1.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
|
|
2860
2860
|
}
|
|
2861
2861
|
makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
|
|
2862
|
-
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, 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)]);
|
|
2863
2863
|
}
|
|
2864
2864
|
makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
|
|
2865
2865
|
const whereSchema = this.makeWhereSchema(model, true, false, false, options);
|
|
2866
2866
|
const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
|
|
2867
|
-
return this.orArray(z.strictObject({
|
|
2867
|
+
return this.orArray(z$1.strictObject({
|
|
2868
2868
|
where: whereSchema,
|
|
2869
2869
|
create: createSchema
|
|
2870
2870
|
}), canBeArray);
|
|
2871
2871
|
}
|
|
2872
2872
|
makeCreateManyPayloadSchema(model, withoutFields, options) {
|
|
2873
|
-
const schema = z.strictObject({
|
|
2873
|
+
const schema = z$1.strictObject({
|
|
2874
2874
|
data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
|
|
2875
|
-
skipDuplicates: z.boolean().optional()
|
|
2875
|
+
skipDuplicates: z$1.boolean().optional()
|
|
2876
2876
|
});
|
|
2877
2877
|
const idParts = [`${model}CreateManyPayload`];
|
|
2878
2878
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -2880,7 +2880,7 @@ var ZodSchemaFactory = class {
|
|
|
2880
2880
|
return schema;
|
|
2881
2881
|
}
|
|
2882
2882
|
makeUpdateSchema(model, options) {
|
|
2883
|
-
const baseSchema = z.strictObject({
|
|
2883
|
+
const baseSchema = z$1.strictObject({
|
|
2884
2884
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
2885
2885
|
data: this.makeUpdateDataSchema(model, [], false, options),
|
|
2886
2886
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
@@ -2895,10 +2895,10 @@ var ZodSchemaFactory = class {
|
|
|
2895
2895
|
return schema;
|
|
2896
2896
|
}
|
|
2897
2897
|
makeUpdateManySchema(model, options) {
|
|
2898
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
2898
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
2899
2899
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
2900
2900
|
data: this.makeUpdateDataSchema(model, [], true, options),
|
|
2901
|
-
limit: z.number().int().nonnegative().optional()
|
|
2901
|
+
limit: z$1.number().int().nonnegative().optional()
|
|
2902
2902
|
}), "updateMany");
|
|
2903
2903
|
this.registerSchema(`${model}UpdateManyArgs`, result);
|
|
2904
2904
|
return result;
|
|
@@ -2914,7 +2914,7 @@ var ZodSchemaFactory = class {
|
|
|
2914
2914
|
return schema;
|
|
2915
2915
|
}
|
|
2916
2916
|
makeUpsertSchema(model, options) {
|
|
2917
|
-
const baseSchema = z.strictObject({
|
|
2917
|
+
const baseSchema = z$1.strictObject({
|
|
2918
2918
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
2919
2919
|
create: this.makeCreateDataSchema(model, false, [], false, options),
|
|
2920
2920
|
update: this.makeUpdateDataSchema(model, [], false, options),
|
|
@@ -2950,27 +2950,27 @@ var ZodSchemaFactory = class {
|
|
|
2950
2950
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
2951
2951
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
2952
2952
|
}
|
|
2953
|
-
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
|
|
2953
|
+
let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
|
|
2954
2954
|
if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
|
|
2955
2955
|
checkedVariantFields[field] = fieldSchema;
|
|
2956
2956
|
if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
|
|
2957
2957
|
} else {
|
|
2958
2958
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
|
|
2959
|
-
if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
|
|
2960
|
-
set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
|
|
2961
|
-
increment: z.number().optional(),
|
|
2962
|
-
decrement: z.number().optional(),
|
|
2963
|
-
multiply: z.number().optional(),
|
|
2964
|
-
divide: z.number().optional()
|
|
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()
|
|
2965
2965
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
|
|
2966
2966
|
if (fieldDef.array) {
|
|
2967
2967
|
const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
2968
|
-
fieldSchema = z.union([arraySchema, z.object({
|
|
2968
|
+
fieldSchema = z$1.union([arraySchema, z$1.object({
|
|
2969
2969
|
set: arraySchema.optional(),
|
|
2970
|
-
push: z.union([fieldSchema, fieldSchema.array()]).optional()
|
|
2970
|
+
push: z$1.union([fieldSchema, fieldSchema.array()]).optional()
|
|
2971
2971
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
|
|
2972
2972
|
}
|
|
2973
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
2973
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
|
|
2974
2974
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
2975
2975
|
else fieldSchema = fieldSchema.nullable();
|
|
2976
2976
|
fieldSchema = fieldSchema.optional();
|
|
@@ -2978,9 +2978,9 @@ var ZodSchemaFactory = class {
|
|
|
2978
2978
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
2979
2979
|
}
|
|
2980
2980
|
});
|
|
2981
|
-
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
2982
|
-
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
2983
|
-
const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
|
|
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]);
|
|
2984
2984
|
const idParts = [`${model}UpdateData`];
|
|
2985
2985
|
if (withoutRelationFields) idParts.push("WithoutRelation");
|
|
2986
2986
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -2988,7 +2988,7 @@ var ZodSchemaFactory = class {
|
|
|
2988
2988
|
return result;
|
|
2989
2989
|
}
|
|
2990
2990
|
makeDeleteSchema(model, options) {
|
|
2991
|
-
const baseSchema = z.strictObject({
|
|
2991
|
+
const baseSchema = z$1.strictObject({
|
|
2992
2992
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
2993
2993
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
2994
2994
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3002,15 +3002,15 @@ var ZodSchemaFactory = class {
|
|
|
3002
3002
|
return schema;
|
|
3003
3003
|
}
|
|
3004
3004
|
makeDeleteManySchema(model, options) {
|
|
3005
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3005
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3006
3006
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3007
|
-
limit: z.number().int().nonnegative().optional()
|
|
3007
|
+
limit: z$1.number().int().nonnegative().optional()
|
|
3008
3008
|
}), "deleteMany").optional();
|
|
3009
3009
|
this.registerSchema(`${model}DeleteManyArgs`, result);
|
|
3010
3010
|
return result;
|
|
3011
3011
|
}
|
|
3012
3012
|
makeCountSchema(model, options) {
|
|
3013
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3013
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3014
3014
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3015
3015
|
skip: this.makeSkipSchema().optional(),
|
|
3016
3016
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3021,10 +3021,10 @@ var ZodSchemaFactory = class {
|
|
|
3021
3021
|
return result;
|
|
3022
3022
|
}
|
|
3023
3023
|
makeCountAggregateInputSchema(model) {
|
|
3024
|
-
const schema = z.union([z.literal(true), z.strictObject({
|
|
3025
|
-
_all: z.literal(true).optional(),
|
|
3024
|
+
const schema = z$1.union([z$1.literal(true), z$1.strictObject({
|
|
3025
|
+
_all: z$1.literal(true).optional(),
|
|
3026
3026
|
...this.getModelFields(model).reduce((acc, [field]) => {
|
|
3027
|
-
acc[field] = z.literal(true).optional();
|
|
3027
|
+
acc[field] = z$1.literal(true).optional();
|
|
3028
3028
|
return acc;
|
|
3029
3029
|
}, {})
|
|
3030
3030
|
})]);
|
|
@@ -3032,7 +3032,7 @@ var ZodSchemaFactory = class {
|
|
|
3032
3032
|
return schema;
|
|
3033
3033
|
}
|
|
3034
3034
|
makeAggregateSchema(model, options) {
|
|
3035
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3035
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3036
3036
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3037
3037
|
skip: this.makeSkipSchema().optional(),
|
|
3038
3038
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3047,16 +3047,16 @@ var ZodSchemaFactory = class {
|
|
|
3047
3047
|
return result;
|
|
3048
3048
|
}
|
|
3049
3049
|
makeSumAvgInputSchema(model) {
|
|
3050
|
-
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3051
|
-
if (this.isNumericField(fieldDef)) acc[field] = z.literal(true).optional();
|
|
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();
|
|
3052
3052
|
return acc;
|
|
3053
3053
|
}, {}));
|
|
3054
3054
|
this.registerSchema(`${model}SumAvgAggregateInput`, schema);
|
|
3055
3055
|
return schema;
|
|
3056
3056
|
}
|
|
3057
3057
|
makeMinMaxInputSchema(model) {
|
|
3058
|
-
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3059
|
-
if (!fieldDef.relation && !fieldDef.array) acc[field] = z.literal(true).optional();
|
|
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();
|
|
3060
3060
|
return acc;
|
|
3061
3061
|
}, {}));
|
|
3062
3062
|
this.registerSchema(`${model}MinMaxAggregateInput`, schema);
|
|
@@ -3064,8 +3064,8 @@ var ZodSchemaFactory = class {
|
|
|
3064
3064
|
}
|
|
3065
3065
|
makeGroupBySchema(model, options) {
|
|
3066
3066
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
|
|
3067
|
-
const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
3068
|
-
const baseSchema = z.strictObject({
|
|
3067
|
+
const bySchema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
|
|
3068
|
+
const baseSchema = z$1.strictObject({
|
|
3069
3069
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3070
3070
|
orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
|
|
3071
3071
|
by: bySchema,
|
|
@@ -3117,7 +3117,7 @@ var ZodSchemaFactory = class {
|
|
|
3117
3117
|
if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
|
|
3118
3118
|
const shape = {};
|
|
3119
3119
|
for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
|
|
3120
|
-
const schema = z.object(shape);
|
|
3120
|
+
const schema = z$1.object(shape);
|
|
3121
3121
|
this.registerSchema(`${procName}ProcArgs`, schema);
|
|
3122
3122
|
return schema;
|
|
3123
3123
|
}
|
|
@@ -3125,10 +3125,10 @@ var ZodSchemaFactory = class {
|
|
|
3125
3125
|
let schema;
|
|
3126
3126
|
if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
|
|
3127
3127
|
else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
|
|
3128
|
-
else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
|
|
3128
|
+
else if (param.type in (this.schema.models ?? {})) schema = z$1.record(z$1.string(), z$1.unknown());
|
|
3129
3129
|
else {
|
|
3130
3130
|
schema = this.makeScalarSchema(param.type);
|
|
3131
|
-
if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
|
|
3131
|
+
if (schema instanceof z$1.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
|
|
3132
3132
|
}
|
|
3133
3133
|
if (param.array) schema = schema.array();
|
|
3134
3134
|
if (param.optional) schema = schema.optional();
|
|
@@ -3164,10 +3164,10 @@ var ZodSchemaFactory = class {
|
|
|
3164
3164
|
return result;
|
|
3165
3165
|
}
|
|
3166
3166
|
makeSkipSchema() {
|
|
3167
|
-
return z.number().int().nonnegative();
|
|
3167
|
+
return z$1.number().int().nonnegative();
|
|
3168
3168
|
}
|
|
3169
3169
|
makeTakeSchema() {
|
|
3170
|
-
return z.number().int();
|
|
3170
|
+
return z$1.number().int();
|
|
3171
3171
|
}
|
|
3172
3172
|
refineForSelectIncludeMutuallyExclusive(schema) {
|
|
3173
3173
|
return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
|
|
@@ -3186,7 +3186,7 @@ var ZodSchemaFactory = class {
|
|
|
3186
3186
|
return nullable ? schema.nullable() : schema;
|
|
3187
3187
|
}
|
|
3188
3188
|
orArray(schema, canBeArray) {
|
|
3189
|
-
return canBeArray ? z.union([schema, z.array(schema)]) : schema;
|
|
3189
|
+
return canBeArray ? z$1.union([schema, z$1.array(schema)]) : schema;
|
|
3190
3190
|
}
|
|
3191
3191
|
isNumericField(fieldDef) {
|
|
3192
3192
|
return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
|
|
@@ -3242,10 +3242,10 @@ var ZodSchemaFactory = class {
|
|
|
3242
3242
|
createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
|
|
3243
3243
|
if (Object.keys(components).length === 0) {
|
|
3244
3244
|
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
|
|
3245
|
-
return z.never();
|
|
3245
|
+
return z$1.never();
|
|
3246
3246
|
}
|
|
3247
|
-
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
|
|
3248
|
-
else return z.strictObject(components);
|
|
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);
|
|
3249
3249
|
}
|
|
3250
3250
|
canCreateModel(model) {
|
|
3251
3251
|
const modelDef = requireModel(this.schema, model);
|
|
@@ -6849,9 +6849,9 @@ var ClientImpl = class ClientImpl {
|
|
|
6849
6849
|
validateOptions(baseClient, options) {
|
|
6850
6850
|
if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
|
|
6851
6851
|
if (options.diagnostics) {
|
|
6852
|
-
const parseResult = z
|
|
6853
|
-
slowQueryThresholdMs: z
|
|
6854
|
-
slowQueryMaxRecords: z
|
|
6852
|
+
const parseResult = z.object({
|
|
6853
|
+
slowQueryThresholdMs: z.number().nonnegative().optional(),
|
|
6854
|
+
slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
|
|
6855
6855
|
}).safeParse(options.diagnostics);
|
|
6856
6856
|
if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
|
|
6857
6857
|
}
|