@zenstackhq/orm 3.8.3 → 3.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -21
- package/dist/index.d.mts +48 -23
- package/dist/index.mjs +188 -188
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/dist/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { t as __exportAll } from "./chunk-CfYAbeIz.mjs";
|
|
|
2
2
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonNull, JsonNullClass } from "./common-types.mjs";
|
|
3
3
|
import { clone, enumerate, invariant, isPlainObject, lowerCaseFirst, upperCaseFirst } from "@zenstackhq/common-helpers";
|
|
4
4
|
import { AliasNode, AndNode, ColumnNode, ColumnUpdateNode, CompiledQuery, DefaultConnectionProvider, DefaultQueryExecutor, DeleteQueryNode, ExpressionWrapper, FromNode, IdentifierNode, InsertQueryNode, Kysely, Log, OperationNodeTransformer, OperationNodeVisitor, PrimitiveValueListNode, ReferenceNode, ReturningNode, SelectAllNode, SelectionNode, SingleConnectionProvider, TableNode, Transaction, UpdateQueryNode, ValueListNode, ValueNode, ValuesNode, WhereNode, createQueryId, expressionBuilder, sql } from "kysely";
|
|
5
|
-
import z
|
|
5
|
+
import z, { ZodObject, ZodType, z as z$1 } from "zod";
|
|
6
6
|
import { fromError } from "zod-validation-error/v4";
|
|
7
7
|
import { P, match } from "ts-pattern";
|
|
8
8
|
import { ExpressionUtils } from "@zenstackhq/schema";
|
|
@@ -2343,7 +2343,7 @@ function createQuerySchemaFactory(clientOrSchema, options) {
|
|
|
2343
2343
|
* @see https://github.com/zenstackhq/zenstack/issues/2631
|
|
2344
2344
|
*/
|
|
2345
2345
|
function coercedDateTimeSchema() {
|
|
2346
|
-
return z.preprocess((val) => {
|
|
2346
|
+
return z$1.preprocess((val) => {
|
|
2347
2347
|
if (typeof val !== "string") return val;
|
|
2348
2348
|
if (/^\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d\d(?::\d\d)?)?$/.test(val)) {
|
|
2349
2349
|
const hasTz = val.endsWith("Z") || /[+-]\d\d(?::\d\d)?$/.test(val);
|
|
@@ -2352,10 +2352,10 @@ function coercedDateTimeSchema() {
|
|
|
2352
2352
|
}
|
|
2353
2353
|
const d = new Date(val);
|
|
2354
2354
|
return isNaN(d.getTime()) ? val : d;
|
|
2355
|
-
}, z.union([
|
|
2356
|
-
z.iso.datetime(),
|
|
2357
|
-
z.iso.date(),
|
|
2358
|
-
z.date()
|
|
2355
|
+
}, z$1.union([
|
|
2356
|
+
z$1.iso.datetime(),
|
|
2357
|
+
z$1.iso.date(),
|
|
2358
|
+
z$1.date()
|
|
2359
2359
|
]));
|
|
2360
2360
|
}
|
|
2361
2361
|
/**
|
|
@@ -2363,7 +2363,7 @@ function coercedDateTimeSchema() {
|
|
|
2363
2363
|
*/
|
|
2364
2364
|
var ZodSchemaFactory = class {
|
|
2365
2365
|
schemaCache = /* @__PURE__ */ new Map();
|
|
2366
|
-
schemaRegistry = z.registry();
|
|
2366
|
+
schemaRegistry = z$1.registry();
|
|
2367
2367
|
allFilterKinds = [...new Set(Object.values(FILTER_PROPERTY_TO_KIND))];
|
|
2368
2368
|
schema;
|
|
2369
2369
|
options;
|
|
@@ -2455,7 +2455,7 @@ var ZodSchemaFactory = class {
|
|
|
2455
2455
|
this.makeGroupBySchema(m);
|
|
2456
2456
|
}
|
|
2457
2457
|
for (const procName of Object.keys(this.schema.procedures ?? {})) if (this.isProcedureAllowed(procName)) this.makeProcedureArgsSchema(procName);
|
|
2458
|
-
return z.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
|
|
2458
|
+
return z$1.toJSONSchema(this.schemaRegistry, { unrepresentable: "any" });
|
|
2459
2459
|
}
|
|
2460
2460
|
get cacheStats() {
|
|
2461
2461
|
return {
|
|
@@ -2484,13 +2484,13 @@ var ZodSchemaFactory = class {
|
|
|
2484
2484
|
fields["omit"] = this.makeOmitSchema(model).optional().nullable();
|
|
2485
2485
|
if (!unique) {
|
|
2486
2486
|
fields["skip"] = this.makeSkipSchema().optional();
|
|
2487
|
-
if (findOne) fields["take"] = z.literal(1).optional();
|
|
2487
|
+
if (findOne) fields["take"] = z$1.literal(1).optional();
|
|
2488
2488
|
else fields["take"] = this.makeTakeSchema().optional();
|
|
2489
2489
|
fields["orderBy"] = this.orArray(this.makeOrderBySchema(model, true, false, options), true).optional();
|
|
2490
2490
|
fields["cursor"] = this.makeCursorSchema(model, options).optional();
|
|
2491
2491
|
fields["distinct"] = this.makeDistinctSchema(model).optional();
|
|
2492
2492
|
}
|
|
2493
|
-
const baseSchema = z.strictObject(fields);
|
|
2493
|
+
const baseSchema = z$1.strictObject(fields);
|
|
2494
2494
|
let result = this.mergePluginArgsSchema(baseSchema, operation);
|
|
2495
2495
|
result = this.refineForSelectIncludeMutuallyExclusive(result);
|
|
2496
2496
|
result = this.refineForSelectOmitMutuallyExclusive(result);
|
|
@@ -2500,7 +2500,7 @@ var ZodSchemaFactory = class {
|
|
|
2500
2500
|
return result;
|
|
2501
2501
|
}
|
|
2502
2502
|
makeExistsSchema(model, options) {
|
|
2503
|
-
const baseSchema = z.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
|
|
2503
|
+
const baseSchema = z$1.strictObject({ where: this.makeWhereSchema(model, false, false, false, options).optional() });
|
|
2504
2504
|
const result = this.mergePluginArgsSchema(baseSchema, "exists").optional();
|
|
2505
2505
|
this.registerSchema(`${model}ExistsArgs`, result);
|
|
2506
2506
|
return result;
|
|
@@ -2508,31 +2508,31 @@ var ZodSchemaFactory = class {
|
|
|
2508
2508
|
makeScalarSchema(type, attributes) {
|
|
2509
2509
|
if (this.schema.typeDefs && type in this.schema.typeDefs) return this.makeTypeDefSchema(type);
|
|
2510
2510
|
else if (this.schema.enums && type in this.schema.enums) return this.makeEnumSchema(type);
|
|
2511
|
-
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", () => {
|
|
2512
|
-
return z.union([
|
|
2513
|
-
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z.number(), attributes) : z.number(),
|
|
2514
|
-
ZodUtils.addDecimalValidation(z.instanceof(Decimal), attributes, this.extraValidationsEnabled),
|
|
2515
|
-
ZodUtils.addDecimalValidation(z.string(), attributes, this.extraValidationsEnabled)
|
|
2511
|
+
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", () => {
|
|
2512
|
+
return z$1.union([
|
|
2513
|
+
this.extraValidationsEnabled ? ZodUtils.addNumberValidation(z$1.number(), attributes) : z$1.number(),
|
|
2514
|
+
ZodUtils.addDecimalValidation(z$1.instanceof(Decimal), attributes, this.extraValidationsEnabled),
|
|
2515
|
+
ZodUtils.addDecimalValidation(z$1.string(), attributes, this.extraValidationsEnabled)
|
|
2516
2516
|
]);
|
|
2517
|
-
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z.unknown());
|
|
2517
|
+
}).with("DateTime", () => this.makeDateTimeValueSchema()).with("Bytes", () => z$1.instanceof(Uint8Array)).with("Json", () => this.makeJsonValueSchema()).otherwise(() => z$1.unknown());
|
|
2518
2518
|
}
|
|
2519
2519
|
makeEnumSchema(_enum) {
|
|
2520
2520
|
const enumDef = getEnum(this.schema, _enum);
|
|
2521
2521
|
invariant(enumDef, `Enum "${_enum}" not found in schema`);
|
|
2522
|
-
const schema = z.enum(Object.keys(enumDef.values));
|
|
2522
|
+
const schema = z$1.enum(Object.keys(enumDef.values));
|
|
2523
2523
|
this.registerSchema(_enum, schema);
|
|
2524
2524
|
return schema;
|
|
2525
2525
|
}
|
|
2526
2526
|
makeTypeDefSchema(type) {
|
|
2527
2527
|
const typeDef = getTypeDef(this.schema, type);
|
|
2528
2528
|
invariant(typeDef, `Type definition "${type}" not found in schema`);
|
|
2529
|
-
const schema = z.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
2530
|
-
let fieldSchema = isTypeDef(this.schema, def.type) ? z.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type);
|
|
2529
|
+
const schema = z$1.looseObject(Object.fromEntries(Object.entries(typeDef.fields).map(([field, def]) => {
|
|
2530
|
+
let fieldSchema = isTypeDef(this.schema, def.type) ? z$1.lazy(() => this.makeTypeDefSchema(def.type)) : this.makeScalarSchema(def.type);
|
|
2531
2531
|
if (def.array) fieldSchema = fieldSchema.array();
|
|
2532
2532
|
if (def.optional) fieldSchema = fieldSchema.nullish();
|
|
2533
2533
|
return [field, fieldSchema];
|
|
2534
2534
|
})));
|
|
2535
|
-
const finalSchema = z.any().superRefine((value, ctx) => {
|
|
2535
|
+
const finalSchema = z$1.any().superRefine((value, ctx) => {
|
|
2536
2536
|
const parseResult = schema.safeParse(value);
|
|
2537
2537
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
2538
2538
|
});
|
|
@@ -2548,17 +2548,17 @@ var ZodSchemaFactory = class {
|
|
|
2548
2548
|
if (fieldDef.relation) {
|
|
2549
2549
|
if (withoutRelationFields || !this.shouldIncludeRelations(options)) continue;
|
|
2550
2550
|
const allowedFilterKinds = this.getEffectiveFilterKinds(model, field);
|
|
2551
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z.never();
|
|
2551
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Relation")) fieldSchema = z$1.never();
|
|
2552
2552
|
else {
|
|
2553
|
-
fieldSchema = z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
|
|
2554
|
-
if (fieldDef.array) fieldSchema = z.strictObject({
|
|
2553
|
+
fieldSchema = z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts).optional());
|
|
2554
|
+
if (fieldDef.array) fieldSchema = z$1.strictObject({
|
|
2555
2555
|
some: fieldSchema.optional(),
|
|
2556
2556
|
every: fieldSchema.optional(),
|
|
2557
2557
|
none: fieldSchema.optional()
|
|
2558
2558
|
});
|
|
2559
2559
|
else {
|
|
2560
2560
|
fieldSchema = this.nullableIf(fieldSchema, !fieldDef.array && !!fieldDef.optional);
|
|
2561
|
-
fieldSchema = z.union([fieldSchema, z.strictObject({
|
|
2561
|
+
fieldSchema = z$1.union([fieldSchema, z$1.strictObject({
|
|
2562
2562
|
is: fieldSchema.optional(),
|
|
2563
2563
|
isNot: fieldSchema.optional()
|
|
2564
2564
|
})]);
|
|
@@ -2577,21 +2577,21 @@ var ZodSchemaFactory = class {
|
|
|
2577
2577
|
}
|
|
2578
2578
|
if (unique) {
|
|
2579
2579
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
2580
|
-
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
|
|
2580
|
+
for (const uniqueField of uniqueFields) if ("defs" in uniqueField) fields[uniqueField.name] = z$1.object(Object.fromEntries(Object.entries(uniqueField.defs).map(([key, def]) => {
|
|
2581
2581
|
invariant(!def.relation, "unique field cannot be a relation");
|
|
2582
2582
|
let fieldSchema;
|
|
2583
2583
|
const enumDef = getEnum(this.schema, def.type);
|
|
2584
2584
|
if (enumDef) if (Object.keys(enumDef.values).length > 0) fieldSchema = this.makeEnumFilterSchema(def.type, !!def.optional, !!def.array, false, void 0);
|
|
2585
|
-
else fieldSchema = z.never();
|
|
2585
|
+
else fieldSchema = z$1.never();
|
|
2586
2586
|
else fieldSchema = this.makePrimitiveFilterSchema(def.type, !!def.optional, false, void 0);
|
|
2587
2587
|
return [key, fieldSchema];
|
|
2588
2588
|
}))).optional();
|
|
2589
2589
|
}
|
|
2590
|
-
fields["$expr"] = z.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
|
|
2591
|
-
fields["AND"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2592
|
-
fields["OR"] = z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
|
|
2593
|
-
fields["NOT"] = this.orArray(z.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2594
|
-
const baseWhere = z.strictObject(fields);
|
|
2590
|
+
fields["$expr"] = z$1.custom((v) => typeof v === "function", { error: "\"$expr\" must be a function" }).optional();
|
|
2591
|
+
fields["AND"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2592
|
+
fields["OR"] = z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)).array().optional();
|
|
2593
|
+
fields["NOT"] = this.orArray(z$1.lazy(() => this.makeWhereSchema(model, false, withoutRelationFields, false, options)), true).optional();
|
|
2594
|
+
const baseWhere = z$1.strictObject(fields);
|
|
2595
2595
|
let result = baseWhere;
|
|
2596
2596
|
if (unique) {
|
|
2597
2597
|
const uniqueFields = getUniqueFields(this.schema, model);
|
|
@@ -2617,26 +2617,26 @@ var ZodSchemaFactory = class {
|
|
|
2617
2617
|
else if (getEnum(this.schema, fieldDef.type)) fieldSchemas[fieldName] = this.makeEnumFilterSchema(fieldDef.type, !!fieldDef.optional, !!fieldDef.array, false, void 0).optional();
|
|
2618
2618
|
else if (fieldDef.array) fieldSchemas[fieldName] = this.makeArrayFilterSchema(fieldDef.type, void 0).optional();
|
|
2619
2619
|
else fieldSchemas[fieldName] = this.makePrimitiveFilterSchema(fieldDef.type, !!fieldDef.optional, false, void 0).optional();
|
|
2620
|
-
candidates.push(z.strictObject(fieldSchemas));
|
|
2620
|
+
candidates.push(z$1.strictObject(fieldSchemas));
|
|
2621
2621
|
}
|
|
2622
|
-
const recursiveSchema = z.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
|
|
2623
|
-
if (array) candidates.push(z.strictObject({
|
|
2622
|
+
const recursiveSchema = z$1.lazy(() => this.makeTypedJsonFilterSchema(type, optional, false, allowedFilterKinds)).optional();
|
|
2623
|
+
if (array) candidates.push(z$1.strictObject({
|
|
2624
2624
|
some: recursiveSchema,
|
|
2625
2625
|
every: recursiveSchema,
|
|
2626
2626
|
none: recursiveSchema
|
|
2627
2627
|
}));
|
|
2628
|
-
else candidates.push(z.strictObject({
|
|
2628
|
+
else candidates.push(z$1.strictObject({
|
|
2629
2629
|
is: recursiveSchema,
|
|
2630
2630
|
isNot: recursiveSchema
|
|
2631
2631
|
}));
|
|
2632
2632
|
candidates.push(this.makeJsonFilterSchema(optional, allowedFilterKinds));
|
|
2633
2633
|
if (optional) {
|
|
2634
|
-
candidates.push(z.null());
|
|
2635
|
-
candidates.push(z.instanceof(DbNullClass));
|
|
2636
|
-
candidates.push(z.instanceof(JsonNullClass));
|
|
2637
|
-
candidates.push(z.instanceof(AnyNullClass));
|
|
2634
|
+
candidates.push(z$1.null());
|
|
2635
|
+
candidates.push(z$1.instanceof(DbNullClass));
|
|
2636
|
+
candidates.push(z$1.instanceof(JsonNullClass));
|
|
2637
|
+
candidates.push(z$1.instanceof(AnyNullClass));
|
|
2638
2638
|
}
|
|
2639
|
-
const result = z.union(candidates);
|
|
2639
|
+
const result = z$1.union(candidates);
|
|
2640
2640
|
this.registerSchema(`${type}Filter${this.filterSchemaSuffix({
|
|
2641
2641
|
optional,
|
|
2642
2642
|
array,
|
|
@@ -2645,7 +2645,7 @@ var ZodSchemaFactory = class {
|
|
|
2645
2645
|
return result;
|
|
2646
2646
|
}
|
|
2647
2647
|
makeNullableTypedJsonMutationSchema(fieldSchema) {
|
|
2648
|
-
return z.any().superRefine((value, ctx) => {
|
|
2648
|
+
return z$1.any().superRefine((value, ctx) => {
|
|
2649
2649
|
if (value instanceof DbNullClass || value instanceof JsonNullClass || value === null || value === void 0) return;
|
|
2650
2650
|
const parseResult = fieldSchema.safeParse(value);
|
|
2651
2651
|
if (!parseResult.success) parseResult.error.issues.forEach((issue) => ctx.addIssue(issue));
|
|
@@ -2657,11 +2657,11 @@ var ZodSchemaFactory = class {
|
|
|
2657
2657
|
makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds) {
|
|
2658
2658
|
const enumDef = getEnum(this.schema, enumName);
|
|
2659
2659
|
invariant(enumDef, `Enum "${enumName}" not found in schema`);
|
|
2660
|
-
const baseSchema = z.enum(Object.keys(enumDef.values));
|
|
2660
|
+
const baseSchema = z$1.enum(Object.keys(enumDef.values));
|
|
2661
2661
|
let schema;
|
|
2662
2662
|
if (array) schema = this.internalMakeArrayFilterSchema(baseSchema, allowedFilterKinds);
|
|
2663
2663
|
else {
|
|
2664
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
|
|
2664
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.lazy(() => this.makeEnumFilterSchema(enumName, optional, array, withAggregations, allowedFilterKinds)), [
|
|
2665
2665
|
"equals",
|
|
2666
2666
|
"in",
|
|
2667
2667
|
"notIn",
|
|
@@ -2695,42 +2695,42 @@ var ZodSchemaFactory = class {
|
|
|
2695
2695
|
has: elementSchema.optional(),
|
|
2696
2696
|
hasEvery: elementSchema.array().optional(),
|
|
2697
2697
|
hasSome: elementSchema.array().optional(),
|
|
2698
|
-
isEmpty: z.boolean().optional()
|
|
2698
|
+
isEmpty: z$1.boolean().optional()
|
|
2699
2699
|
};
|
|
2700
2700
|
const filteredOperators = this.trimFilterOperators(operators, allowedFilterKinds);
|
|
2701
|
-
return z.strictObject(filteredOperators);
|
|
2701
|
+
return z$1.strictObject(filteredOperators);
|
|
2702
2702
|
}
|
|
2703
2703
|
makePrimitiveFilterSchema(type, optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
|
|
2704
|
-
return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)).with(P.union("Int", "Float", "Decimal", "BigInt"), (type) => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(optional, allowedFilterKinds)).with("Unsupported", () => z.never()).exhaustive();
|
|
2704
|
+
return match(type).with("String", () => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)).with(P.union("Int", "Float", "Decimal", "BigInt"), (type) => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)).with("Boolean", () => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)).with("DateTime", () => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Bytes", () => this.makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds)).with("Json", () => this.makeJsonFilterSchema(optional, allowedFilterKinds)).with("Unsupported", () => z$1.never()).exhaustive();
|
|
2705
2705
|
}
|
|
2706
2706
|
makeJsonValueSchema() {
|
|
2707
|
-
const schema = z.union([
|
|
2708
|
-
z.string(),
|
|
2709
|
-
z.number(),
|
|
2710
|
-
z.boolean(),
|
|
2711
|
-
z.instanceof(JsonNullClass),
|
|
2712
|
-
z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()]).array()),
|
|
2713
|
-
z.record(z.string(), z.lazy(() => z.union([this.makeJsonValueSchema(), z.null()])))
|
|
2707
|
+
const schema = z$1.union([
|
|
2708
|
+
z$1.string(),
|
|
2709
|
+
z$1.number(),
|
|
2710
|
+
z$1.boolean(),
|
|
2711
|
+
z$1.instanceof(JsonNullClass),
|
|
2712
|
+
z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()]).array()),
|
|
2713
|
+
z$1.record(z$1.string(), z$1.lazy(() => z$1.union([this.makeJsonValueSchema(), z$1.null()])))
|
|
2714
2714
|
]);
|
|
2715
2715
|
this.registerSchema("JsonValue", schema);
|
|
2716
2716
|
return schema;
|
|
2717
2717
|
}
|
|
2718
2718
|
makeJsonFilterSchema(optional, allowedFilterKinds) {
|
|
2719
|
-
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z.never();
|
|
2719
|
+
if (allowedFilterKinds && !allowedFilterKinds.includes("Json")) return z$1.never();
|
|
2720
2720
|
const filterMembers = [
|
|
2721
2721
|
this.makeJsonValueSchema(),
|
|
2722
|
-
z.instanceof(DbNullClass),
|
|
2723
|
-
z.instanceof(AnyNullClass)
|
|
2722
|
+
z$1.instanceof(DbNullClass),
|
|
2723
|
+
z$1.instanceof(AnyNullClass)
|
|
2724
2724
|
];
|
|
2725
|
-
if (optional) filterMembers.push(z.null());
|
|
2726
|
-
const filterValueSchema = z.union(filterMembers);
|
|
2727
|
-
const schema = z.strictObject({
|
|
2728
|
-
path: z.string().optional(),
|
|
2725
|
+
if (optional) filterMembers.push(z$1.null());
|
|
2726
|
+
const filterValueSchema = z$1.union(filterMembers);
|
|
2727
|
+
const schema = z$1.strictObject({
|
|
2728
|
+
path: z$1.string().optional(),
|
|
2729
2729
|
equals: filterValueSchema.optional(),
|
|
2730
2730
|
not: filterValueSchema.optional(),
|
|
2731
|
-
string_contains: z.string().optional(),
|
|
2732
|
-
string_starts_with: z.string().optional(),
|
|
2733
|
-
string_ends_with: z.string().optional(),
|
|
2731
|
+
string_contains: z$1.string().optional(),
|
|
2732
|
+
string_starts_with: z$1.string().optional(),
|
|
2733
|
+
string_ends_with: z$1.string().optional(),
|
|
2734
2734
|
mode: this.makeStringModeSchema().optional(),
|
|
2735
2735
|
array_contains: filterValueSchema.optional(),
|
|
2736
2736
|
array_starts_with: filterValueSchema.optional(),
|
|
@@ -2749,7 +2749,7 @@ var ZodSchemaFactory = class {
|
|
|
2749
2749
|
}
|
|
2750
2750
|
makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2751
2751
|
const filterValueSchema = this.makeDateTimeValueSchema();
|
|
2752
|
-
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2752
|
+
const schema = this.makeCommonPrimitiveFilterSchema(filterValueSchema, optional, () => z$1.lazy(() => this.makeDateTimeFilterSchema(optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2753
2753
|
"_count",
|
|
2754
2754
|
"_min",
|
|
2755
2755
|
"_max"
|
|
@@ -2762,12 +2762,12 @@ var ZodSchemaFactory = class {
|
|
|
2762
2762
|
return schema;
|
|
2763
2763
|
}
|
|
2764
2764
|
makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2765
|
-
const components = this.makeCommonPrimitiveFilterComponents(z.boolean(), optional, () => z.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
|
|
2765
|
+
const components = this.makeCommonPrimitiveFilterComponents(z$1.boolean(), optional, () => z$1.lazy(() => this.makeBooleanFilterSchema(optional, withAggregations, allowedFilterKinds)), ["equals", "not"], withAggregations ? [
|
|
2766
2766
|
"_count",
|
|
2767
2767
|
"_min",
|
|
2768
2768
|
"_max"
|
|
2769
2769
|
] : void 0, allowedFilterKinds);
|
|
2770
|
-
const schema = this.createUnionFilterSchema(z.boolean(), optional, components, allowedFilterKinds);
|
|
2770
|
+
const schema = this.createUnionFilterSchema(z$1.boolean(), optional, components, allowedFilterKinds);
|
|
2771
2771
|
this.registerSchema(`BooleanFilter${this.filterSchemaSuffix({
|
|
2772
2772
|
optional,
|
|
2773
2773
|
allowedFilterKinds,
|
|
@@ -2776,8 +2776,8 @@ var ZodSchemaFactory = class {
|
|
|
2776
2776
|
return schema;
|
|
2777
2777
|
}
|
|
2778
2778
|
makeBytesFilterSchema(optional, withAggregations, allowedFilterKinds) {
|
|
2779
|
-
const baseSchema = z.instanceof(Uint8Array);
|
|
2780
|
-
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z.instanceof(Uint8Array), [
|
|
2779
|
+
const baseSchema = z$1.instanceof(Uint8Array);
|
|
2780
|
+
const components = this.makeCommonPrimitiveFilterComponents(baseSchema, optional, () => z$1.instanceof(Uint8Array), [
|
|
2781
2781
|
"equals",
|
|
2782
2782
|
"in",
|
|
2783
2783
|
"notIn",
|
|
@@ -2825,7 +2825,7 @@ var ZodSchemaFactory = class {
|
|
|
2825
2825
|
return this.createUnionFilterSchema(baseSchema, optional, components, allowedFilterKinds);
|
|
2826
2826
|
}
|
|
2827
2827
|
makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds) {
|
|
2828
|
-
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2828
|
+
const schema = this.makeCommonPrimitiveFilterSchema(this.makeScalarSchema(type), optional, () => z$1.lazy(() => this.makeNumberFilterSchema(type, optional, withAggregations, allowedFilterKinds)), withAggregations ? [
|
|
2829
2829
|
"_count",
|
|
2830
2830
|
"_avg",
|
|
2831
2831
|
"_sum",
|
|
@@ -2840,15 +2840,15 @@ var ZodSchemaFactory = class {
|
|
|
2840
2840
|
return schema;
|
|
2841
2841
|
}
|
|
2842
2842
|
makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy = false, withFullText = false) {
|
|
2843
|
-
const baseComponents = this.makeCommonPrimitiveFilterComponents(z.string(), optional, () => z.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
|
|
2843
|
+
const baseComponents = this.makeCommonPrimitiveFilterComponents(z$1.string(), optional, () => z$1.lazy(() => this.makeStringFilterSchema(optional, withAggregations, allowedFilterKinds, withFuzzy, withFullText)), void 0, withAggregations ? [
|
|
2844
2844
|
"_count",
|
|
2845
2845
|
"_min",
|
|
2846
2846
|
"_max"
|
|
2847
2847
|
] : void 0, allowedFilterKinds);
|
|
2848
2848
|
const stringSpecificOperators = {
|
|
2849
|
-
startsWith: z.string().optional(),
|
|
2850
|
-
endsWith: z.string().optional(),
|
|
2851
|
-
contains: z.string().optional(),
|
|
2849
|
+
startsWith: z$1.string().optional(),
|
|
2850
|
+
endsWith: z$1.string().optional(),
|
|
2851
|
+
contains: z$1.string().optional(),
|
|
2852
2852
|
...withFuzzy && this.providerSupportsFuzzySearch ? { fuzzy: this.makeFuzzyFilterSchema().optional() } : {},
|
|
2853
2853
|
...withFullText && this.providerSupportsFullTextSearch ? { fts: this.makeFullTextFilterSchema().optional() } : {},
|
|
2854
2854
|
...this.providerSupportsCaseSensitivity ? { mode: this.makeStringModeSchema().optional() } : {}
|
|
@@ -2858,7 +2858,7 @@ var ZodSchemaFactory = class {
|
|
|
2858
2858
|
...baseComponents,
|
|
2859
2859
|
...filteredStringOperators
|
|
2860
2860
|
};
|
|
2861
|
-
const schema = this.createUnionFilterSchema(z.string(), optional, allComponents, allowedFilterKinds);
|
|
2861
|
+
const schema = this.createUnionFilterSchema(z$1.string(), optional, allComponents, allowedFilterKinds);
|
|
2862
2862
|
const featureSuffix = `${withFuzzy ? "Fuzzy" : ""}${withFullText ? "FullText" : ""}`;
|
|
2863
2863
|
this.registerSchema(`StringFilter${this.filterSchemaSuffix({
|
|
2864
2864
|
optional,
|
|
@@ -2868,24 +2868,24 @@ var ZodSchemaFactory = class {
|
|
|
2868
2868
|
return schema;
|
|
2869
2869
|
}
|
|
2870
2870
|
makeStringModeSchema() {
|
|
2871
|
-
return z.union([z.literal("default"), z.literal("insensitive")]);
|
|
2871
|
+
return z$1.union([z$1.literal("default"), z$1.literal("insensitive")]);
|
|
2872
2872
|
}
|
|
2873
2873
|
makeFuzzyFilterSchema() {
|
|
2874
|
-
return z.strictObject({
|
|
2875
|
-
search: z.string().min(1),
|
|
2876
|
-
mode: z.union([
|
|
2877
|
-
z.literal("simple"),
|
|
2878
|
-
z.literal("word"),
|
|
2879
|
-
z.literal("strictWord")
|
|
2874
|
+
return z$1.strictObject({
|
|
2875
|
+
search: z$1.string().min(1),
|
|
2876
|
+
mode: z$1.union([
|
|
2877
|
+
z$1.literal("simple"),
|
|
2878
|
+
z$1.literal("word"),
|
|
2879
|
+
z$1.literal("strictWord")
|
|
2880
2880
|
]).default("simple"),
|
|
2881
|
-
threshold: z.number().min(0).max(1).optional(),
|
|
2882
|
-
unaccent: z.boolean().default(false)
|
|
2881
|
+
threshold: z$1.number().min(0).max(1).optional(),
|
|
2882
|
+
unaccent: z$1.boolean().default(false)
|
|
2883
2883
|
});
|
|
2884
2884
|
}
|
|
2885
2885
|
makeFullTextFilterSchema() {
|
|
2886
|
-
return z.strictObject({
|
|
2887
|
-
search: z.string().min(1),
|
|
2888
|
-
config: z.string().min(1).optional()
|
|
2886
|
+
return z$1.strictObject({
|
|
2887
|
+
search: z$1.string().min(1),
|
|
2888
|
+
config: z$1.string().min(1).optional()
|
|
2889
2889
|
});
|
|
2890
2890
|
}
|
|
2891
2891
|
makeSelectSchema(model, options) {
|
|
@@ -2893,14 +2893,14 @@ var ZodSchemaFactory = class {
|
|
|
2893
2893
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2894
2894
|
if (!this.shouldIncludeRelations(options)) continue;
|
|
2895
2895
|
if (this.isModelAllowed(fieldDef.type)) fields[field] = this.makeRelationSelectIncludeSchema(model, field, options).optional();
|
|
2896
|
-
} else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z.literal(false).optional();
|
|
2897
|
-
else fields[field] = z.boolean().optional();
|
|
2896
|
+
} else if (this.options.allowQueryTimeOmitOverride === false && this.isFieldOmittedByConfig(model, field)) fields[field] = z$1.literal(false).optional();
|
|
2897
|
+
else fields[field] = z$1.boolean().optional();
|
|
2898
2898
|
if (this.shouldIncludeRelations(options)) {
|
|
2899
2899
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2900
|
-
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
2900
|
+
if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
|
|
2901
2901
|
}
|
|
2902
2902
|
this.addExtResultFields(model, fields);
|
|
2903
|
-
const result = z.strictObject(fields);
|
|
2903
|
+
const result = z$1.strictObject(fields);
|
|
2904
2904
|
this.registerSchema(`${model}Select`, result);
|
|
2905
2905
|
return result;
|
|
2906
2906
|
}
|
|
@@ -2909,24 +2909,24 @@ var ZodSchemaFactory = class {
|
|
|
2909
2909
|
const toManyRelations = Object.values(modelDef.fields).filter((def) => def.relation && def.array);
|
|
2910
2910
|
if (toManyRelations.length > 0) {
|
|
2911
2911
|
const nextOpts = this.nextOptions(options);
|
|
2912
|
-
const schema = z.union([z.literal(true), z.strictObject({ select: z.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
2912
|
+
const schema = z$1.union([z$1.literal(true), z$1.strictObject({ select: z$1.strictObject(toManyRelations.reduce((acc, fieldDef) => ({
|
|
2913
2913
|
...acc,
|
|
2914
|
-
[fieldDef.name]: z.union([z.boolean(), z.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
|
|
2914
|
+
[fieldDef.name]: z$1.union([z$1.boolean(), z$1.strictObject({ where: this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts) })]).optional()
|
|
2915
2915
|
}), {})) })]).optional();
|
|
2916
2916
|
this.registerSchema(`${model}CountSelection`, schema);
|
|
2917
2917
|
return schema;
|
|
2918
|
-
} else return z.never();
|
|
2918
|
+
} else return z$1.never();
|
|
2919
2919
|
}
|
|
2920
2920
|
makeRelationSelectIncludeSchema(model, field, options) {
|
|
2921
2921
|
const fieldDef = requireField(this.schema, model, field);
|
|
2922
2922
|
const nextOpts = this.nextOptions(options);
|
|
2923
|
-
let objSchema = z.strictObject({
|
|
2924
|
-
...fieldDef.array || fieldDef.optional ? { where: z.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
|
|
2925
|
-
select: z.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2926
|
-
include: z.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2927
|
-
omit: z.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
|
|
2923
|
+
let objSchema = z$1.strictObject({
|
|
2924
|
+
...fieldDef.array || fieldDef.optional ? { where: z$1.lazy(() => this.makeWhereSchema(fieldDef.type, false, false, false, nextOpts)).optional() } : {},
|
|
2925
|
+
select: z$1.lazy(() => this.makeSelectSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2926
|
+
include: z$1.lazy(() => this.makeIncludeSchema(fieldDef.type, nextOpts)).optional().nullable(),
|
|
2927
|
+
omit: z$1.lazy(() => this.makeOmitSchema(fieldDef.type)).optional().nullable(),
|
|
2928
2928
|
...fieldDef.array ? {
|
|
2929
|
-
orderBy: z.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
|
|
2929
|
+
orderBy: z$1.lazy(() => this.orArray(this.makeOrderBySchema(fieldDef.type, true, false, nextOpts), true)).optional(),
|
|
2930
2930
|
skip: this.makeSkipSchema().optional(),
|
|
2931
2931
|
take: this.makeTakeSchema().optional(),
|
|
2932
2932
|
cursor: this.makeCursorSchema(fieldDef.type, nextOpts).optional(),
|
|
@@ -2936,7 +2936,7 @@ var ZodSchemaFactory = class {
|
|
|
2936
2936
|
objSchema = this.refineForSelectIncludeMutuallyExclusive(objSchema);
|
|
2937
2937
|
objSchema = this.refineForSelectOmitMutuallyExclusive(objSchema);
|
|
2938
2938
|
objSchema = this.refineForSelectHasTruthyField(objSchema);
|
|
2939
|
-
const result = z.union([z.boolean(), objSchema]);
|
|
2939
|
+
const result = z$1.union([z$1.boolean(), objSchema]);
|
|
2940
2940
|
this.registerSchema(`${model}${upperCaseFirst(field)}RelationInput`, result);
|
|
2941
2941
|
return result;
|
|
2942
2942
|
}
|
|
@@ -2951,10 +2951,10 @@ var ZodSchemaFactory = class {
|
|
|
2951
2951
|
}
|
|
2952
2952
|
makeOmitSchema(model) {
|
|
2953
2953
|
const fields = {};
|
|
2954
|
-
for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z.boolean().optional();
|
|
2955
|
-
else fields[field] = z.literal(true).optional();
|
|
2954
|
+
for (const [field, fieldDef] of this.getModelFields(model)) if (!fieldDef.relation) if (this.options.allowQueryTimeOmitOverride !== false) fields[field] = z$1.boolean().optional();
|
|
2955
|
+
else fields[field] = z$1.literal(true).optional();
|
|
2956
2956
|
this.addExtResultFields(model, fields);
|
|
2957
|
-
const result = z.strictObject(fields);
|
|
2957
|
+
const result = z$1.strictObject(fields);
|
|
2958
2958
|
this.registerSchema(`${model}OmitInput`, result);
|
|
2959
2959
|
return result;
|
|
2960
2960
|
}
|
|
@@ -2963,7 +2963,7 @@ var ZodSchemaFactory = class {
|
|
|
2963
2963
|
const resultConfig = plugin.result;
|
|
2964
2964
|
if (resultConfig) {
|
|
2965
2965
|
const modelConfig = resultConfig[lowerCaseFirst(model)];
|
|
2966
|
-
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z.boolean().optional();
|
|
2966
|
+
if (modelConfig) for (const field of Object.keys(modelConfig)) fields[field] = z$1.boolean().optional();
|
|
2967
2967
|
}
|
|
2968
2968
|
}
|
|
2969
2969
|
}
|
|
@@ -2979,26 +2979,26 @@ var ZodSchemaFactory = class {
|
|
|
2979
2979
|
}
|
|
2980
2980
|
if (this.shouldIncludeRelations(options)) {
|
|
2981
2981
|
const _countSchema = this.makeCountSelectionSchema(model, options);
|
|
2982
|
-
if (!(_countSchema instanceof z.ZodNever)) fields["_count"] = _countSchema;
|
|
2982
|
+
if (!(_countSchema instanceof z$1.ZodNever)) fields["_count"] = _countSchema;
|
|
2983
2983
|
}
|
|
2984
|
-
const result = z.strictObject(fields);
|
|
2984
|
+
const result = z$1.strictObject(fields);
|
|
2985
2985
|
this.registerSchema(`${model}Include`, result);
|
|
2986
2986
|
return result;
|
|
2987
2987
|
}
|
|
2988
2988
|
makeOrderBySchema(model, withRelation, WithAggregation, options) {
|
|
2989
2989
|
const fields = {};
|
|
2990
|
-
const sort = z.union([z.literal("asc"), z.literal("desc")]);
|
|
2990
|
+
const sort = z$1.union([z$1.literal("asc"), z$1.literal("desc")]);
|
|
2991
2991
|
const refineAtMostOneKey = (s) => s.refine((v) => Object.keys(v).length <= 1, { message: "Each orderBy element must have at most one key" });
|
|
2992
2992
|
const nextOpts = this.nextOptions(options);
|
|
2993
2993
|
for (const [field, fieldDef] of this.getModelFields(model)) if (fieldDef.relation) {
|
|
2994
|
-
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z.lazy(() => {
|
|
2994
|
+
if (withRelation && this.shouldIncludeRelations(options)) fields[field] = z$1.lazy(() => {
|
|
2995
2995
|
let relationOrderBy = this.makeOrderBySchema(fieldDef.type, withRelation, WithAggregation, nextOpts);
|
|
2996
2996
|
if (fieldDef.array) relationOrderBy = refineAtMostOneKey(relationOrderBy.safeExtend({ _count: sort }));
|
|
2997
2997
|
return relationOrderBy;
|
|
2998
2998
|
}).optional();
|
|
2999
|
-
} else if (fieldDef.optional) fields[field] = z.union([sort, z.strictObject({
|
|
2999
|
+
} else if (fieldDef.optional) fields[field] = z$1.union([sort, z$1.strictObject({
|
|
3000
3000
|
sort,
|
|
3001
|
-
nulls: z.union([z.literal("first"), z.literal("last")]).optional()
|
|
3001
|
+
nulls: z$1.union([z$1.literal("first"), z$1.literal("last")]).optional()
|
|
3002
3002
|
})]).optional();
|
|
3003
3003
|
else fields[field] = sort.optional();
|
|
3004
3004
|
if (WithAggregation) for (const agg of [
|
|
@@ -3007,31 +3007,31 @@ var ZodSchemaFactory = class {
|
|
|
3007
3007
|
"_sum",
|
|
3008
3008
|
"_min",
|
|
3009
3009
|
"_max"
|
|
3010
|
-
]) fields[agg] = z.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
|
|
3010
|
+
]) fields[agg] = z$1.lazy(() => this.makeOrderBySchema(model, true, false, options).optional());
|
|
3011
3011
|
if (this.providerSupportsFuzzySearch) {
|
|
3012
3012
|
const fuzzyFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fuzzy === true).map(([name]) => name);
|
|
3013
|
-
if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z.strictObject({
|
|
3014
|
-
fields: z.array(z.enum(fuzzyFieldNames)).min(1),
|
|
3015
|
-
search: z.string(),
|
|
3016
|
-
mode: z.union([
|
|
3017
|
-
z.literal("simple"),
|
|
3018
|
-
z.literal("word"),
|
|
3019
|
-
z.literal("strictWord")
|
|
3013
|
+
if (fuzzyFieldNames.length > 0) fields["_fuzzyRelevance"] = z$1.strictObject({
|
|
3014
|
+
fields: z$1.array(z$1.enum(fuzzyFieldNames)).min(1),
|
|
3015
|
+
search: z$1.string(),
|
|
3016
|
+
mode: z$1.union([
|
|
3017
|
+
z$1.literal("simple"),
|
|
3018
|
+
z$1.literal("word"),
|
|
3019
|
+
z$1.literal("strictWord")
|
|
3020
3020
|
]).default("simple"),
|
|
3021
|
-
unaccent: z.boolean().default(false),
|
|
3021
|
+
unaccent: z$1.boolean().default(false),
|
|
3022
3022
|
sort
|
|
3023
3023
|
}).optional();
|
|
3024
3024
|
}
|
|
3025
3025
|
if (this.providerSupportsFullTextSearch) {
|
|
3026
3026
|
const fullTextFieldNames = this.getModelFields(model).filter(([, def]) => !def.relation && def.type === "String" && def.fullText === true).map(([name]) => name);
|
|
3027
|
-
if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z.strictObject({
|
|
3028
|
-
fields: z.array(z.enum(fullTextFieldNames)).min(1),
|
|
3029
|
-
search: z.string().min(1),
|
|
3030
|
-
config: z.string().min(1).optional(),
|
|
3027
|
+
if (fullTextFieldNames.length > 0) fields["_ftsRelevance"] = z$1.strictObject({
|
|
3028
|
+
fields: z$1.array(z$1.enum(fullTextFieldNames)).min(1),
|
|
3029
|
+
search: z$1.string().min(1),
|
|
3030
|
+
config: z$1.string().min(1).optional(),
|
|
3031
3031
|
sort
|
|
3032
3032
|
}).optional();
|
|
3033
3033
|
}
|
|
3034
|
-
const schema = refineAtMostOneKey(z.strictObject(fields));
|
|
3034
|
+
const schema = refineAtMostOneKey(z$1.strictObject(fields));
|
|
3035
3035
|
let schemaId = `${model}OrderBy`;
|
|
3036
3036
|
if (withRelation) schemaId += "WithRelation";
|
|
3037
3037
|
if (WithAggregation) schemaId += "WithAggregation";
|
|
@@ -3041,7 +3041,7 @@ var ZodSchemaFactory = class {
|
|
|
3041
3041
|
}
|
|
3042
3042
|
makeDistinctSchema(model) {
|
|
3043
3043
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
|
|
3044
|
-
const schema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
3044
|
+
const schema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
|
|
3045
3045
|
this.registerSchema(`${model}DistinctInput`, schema);
|
|
3046
3046
|
return schema;
|
|
3047
3047
|
}
|
|
@@ -3052,7 +3052,7 @@ var ZodSchemaFactory = class {
|
|
|
3052
3052
|
}
|
|
3053
3053
|
makeCreateSchema(model, options) {
|
|
3054
3054
|
const dataSchema = this.makeCreateDataSchema(model, false, [], false, options);
|
|
3055
|
-
const baseSchema = z.strictObject({
|
|
3055
|
+
const baseSchema = z$1.strictObject({
|
|
3056
3056
|
data: dataSchema,
|
|
3057
3057
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
3058
3058
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3101,7 +3101,7 @@ var ZodSchemaFactory = class {
|
|
|
3101
3101
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
3102
3102
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
3103
3103
|
}
|
|
3104
|
-
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
|
|
3104
|
+
let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "create", nextOpts));
|
|
3105
3105
|
if (fieldDef.optional || fieldDef.array) fieldSchema = fieldSchema.optional();
|
|
3106
3106
|
else {
|
|
3107
3107
|
let allFksOptional = false;
|
|
@@ -3118,23 +3118,23 @@ var ZodSchemaFactory = class {
|
|
|
3118
3118
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
|
|
3119
3119
|
if (fieldDef.array) {
|
|
3120
3120
|
fieldSchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
3121
|
-
fieldSchema = z.union([fieldSchema, z.strictObject({ set: fieldSchema })]).optional();
|
|
3121
|
+
fieldSchema = z$1.union([fieldSchema, z$1.strictObject({ set: fieldSchema })]).optional();
|
|
3122
3122
|
}
|
|
3123
3123
|
if (fieldDef.optional || fieldHasDefaultValue(fieldDef)) fieldSchema = fieldSchema.optional();
|
|
3124
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
3124
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
|
|
3125
3125
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
3126
3126
|
else fieldSchema = fieldSchema.nullable();
|
|
3127
3127
|
uncheckedVariantFields[field] = fieldSchema;
|
|
3128
3128
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
3129
3129
|
}
|
|
3130
3130
|
});
|
|
3131
|
-
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
3132
|
-
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
3133
|
-
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z.union([
|
|
3131
|
+
const uncheckedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
|
|
3132
|
+
const checkedCreateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
|
|
3133
|
+
const result = !hasRelation ? this.orArray(uncheckedCreateSchema, canBeArray) : z$1.union([
|
|
3134
3134
|
uncheckedCreateSchema,
|
|
3135
3135
|
checkedCreateSchema,
|
|
3136
|
-
...canBeArray ? [z.array(uncheckedCreateSchema)] : [],
|
|
3137
|
-
...canBeArray ? [z.array(checkedCreateSchema)] : []
|
|
3136
|
+
...canBeArray ? [z$1.array(uncheckedCreateSchema)] : [],
|
|
3137
|
+
...canBeArray ? [z$1.array(checkedCreateSchema)] : []
|
|
3138
3138
|
]);
|
|
3139
3139
|
const idParts = [`${model}CreateData`];
|
|
3140
3140
|
if (canBeArray) idParts.push("Array");
|
|
@@ -3159,17 +3159,17 @@ var ZodSchemaFactory = class {
|
|
|
3159
3159
|
fields["disconnect"] = this.makeDisconnectDataSchema(fieldType, array, options).optional();
|
|
3160
3160
|
fields["delete"] = this.makeDeleteRelationDataSchema(fieldType, array, true, options).optional();
|
|
3161
3161
|
}
|
|
3162
|
-
fields["update"] = array ? this.orArray(z.strictObject({
|
|
3162
|
+
fields["update"] = array ? this.orArray(z$1.strictObject({
|
|
3163
3163
|
where: this.makeWhereSchema(fieldType, true, false, false, options),
|
|
3164
3164
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3165
|
-
}), true).optional() : z.union([z.strictObject({
|
|
3165
|
+
}), true).optional() : z$1.union([z$1.strictObject({
|
|
3166
3166
|
where: this.makeWhereSchema(fieldType, false, false, false, options).optional(),
|
|
3167
3167
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3168
3168
|
}), this.makeUpdateDataSchema(fieldType, withoutFields, false, options)]).optional();
|
|
3169
3169
|
if (canCreateModel) {
|
|
3170
3170
|
let upsertWhere = this.makeWhereSchema(fieldType, true, false, false, options);
|
|
3171
3171
|
if (!fieldDef.array) upsertWhere = upsertWhere.optional();
|
|
3172
|
-
fields["upsert"] = this.orArray(z.strictObject({
|
|
3172
|
+
fields["upsert"] = this.orArray(z$1.strictObject({
|
|
3173
3173
|
where: upsertWhere,
|
|
3174
3174
|
create: this.makeCreateDataSchema(fieldType, false, withoutFields, false, options),
|
|
3175
3175
|
update: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
@@ -3177,14 +3177,14 @@ var ZodSchemaFactory = class {
|
|
|
3177
3177
|
}
|
|
3178
3178
|
if (array) {
|
|
3179
3179
|
fields["set"] = this.makeSetDataSchema(fieldType, true, options).optional();
|
|
3180
|
-
fields["updateMany"] = this.orArray(z.strictObject({
|
|
3180
|
+
fields["updateMany"] = this.orArray(z$1.strictObject({
|
|
3181
3181
|
where: this.makeWhereSchema(fieldType, false, true, false, options),
|
|
3182
3182
|
data: this.makeUpdateDataSchema(fieldType, withoutFields, false, options)
|
|
3183
3183
|
}), true).optional();
|
|
3184
3184
|
fields["deleteMany"] = this.makeDeleteRelationDataSchema(fieldType, true, false, options).optional();
|
|
3185
3185
|
}
|
|
3186
3186
|
}
|
|
3187
|
-
return z.strictObject(fields);
|
|
3187
|
+
return z$1.strictObject(fields);
|
|
3188
3188
|
}
|
|
3189
3189
|
makeSetDataSchema(model, canBeArray, options) {
|
|
3190
3190
|
return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
@@ -3194,23 +3194,23 @@ var ZodSchemaFactory = class {
|
|
|
3194
3194
|
}
|
|
3195
3195
|
makeDisconnectDataSchema(model, canBeArray, options) {
|
|
3196
3196
|
if (canBeArray) return this.orArray(this.makeWhereSchema(model, true, false, false, options), canBeArray);
|
|
3197
|
-
else return z.union([z.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
|
|
3197
|
+
else return z$1.union([z$1.boolean(), this.makeWhereSchema(model, false, false, false, options)]);
|
|
3198
3198
|
}
|
|
3199
3199
|
makeDeleteRelationDataSchema(model, toManyRelation, uniqueFilter, options) {
|
|
3200
|
-
return toManyRelation ? this.orArray(this.makeWhereSchema(model, uniqueFilter, false, false, options), true) : z.union([z.boolean(), this.makeWhereSchema(model, uniqueFilter, false, false, options)]);
|
|
3200
|
+
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)]);
|
|
3201
3201
|
}
|
|
3202
3202
|
makeConnectOrCreateDataSchema(model, canBeArray, withoutFields, options) {
|
|
3203
3203
|
const whereSchema = this.makeWhereSchema(model, true, false, false, options);
|
|
3204
3204
|
const createSchema = this.makeCreateDataSchema(model, false, withoutFields, false, options);
|
|
3205
|
-
return this.orArray(z.strictObject({
|
|
3205
|
+
return this.orArray(z$1.strictObject({
|
|
3206
3206
|
where: whereSchema,
|
|
3207
3207
|
create: createSchema
|
|
3208
3208
|
}), canBeArray);
|
|
3209
3209
|
}
|
|
3210
3210
|
makeCreateManyPayloadSchema(model, withoutFields, options) {
|
|
3211
|
-
const schema = z.strictObject({
|
|
3211
|
+
const schema = z$1.strictObject({
|
|
3212
3212
|
data: this.makeCreateDataSchema(model, true, withoutFields, true, options),
|
|
3213
|
-
skipDuplicates: z.boolean().optional()
|
|
3213
|
+
skipDuplicates: z$1.boolean().optional()
|
|
3214
3214
|
});
|
|
3215
3215
|
const idParts = [`${model}CreateManyPayload`];
|
|
3216
3216
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -3218,7 +3218,7 @@ var ZodSchemaFactory = class {
|
|
|
3218
3218
|
return schema;
|
|
3219
3219
|
}
|
|
3220
3220
|
makeUpdateSchema(model, options) {
|
|
3221
|
-
const baseSchema = z.strictObject({
|
|
3221
|
+
const baseSchema = z$1.strictObject({
|
|
3222
3222
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3223
3223
|
data: this.makeUpdateDataSchema(model, [], false, options),
|
|
3224
3224
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
@@ -3233,10 +3233,10 @@ var ZodSchemaFactory = class {
|
|
|
3233
3233
|
return schema;
|
|
3234
3234
|
}
|
|
3235
3235
|
makeUpdateManySchema(model, options) {
|
|
3236
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3236
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3237
3237
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3238
3238
|
data: this.makeUpdateDataSchema(model, [], true, options),
|
|
3239
|
-
limit: z.number().int().nonnegative().optional()
|
|
3239
|
+
limit: z$1.number().int().nonnegative().optional()
|
|
3240
3240
|
}), "updateMany");
|
|
3241
3241
|
this.registerSchema(`${model}UpdateManyArgs`, result);
|
|
3242
3242
|
return result;
|
|
@@ -3252,7 +3252,7 @@ var ZodSchemaFactory = class {
|
|
|
3252
3252
|
return schema;
|
|
3253
3253
|
}
|
|
3254
3254
|
makeUpsertSchema(model, options) {
|
|
3255
|
-
const baseSchema = z.strictObject({
|
|
3255
|
+
const baseSchema = z$1.strictObject({
|
|
3256
3256
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3257
3257
|
create: this.makeCreateDataSchema(model, false, [], false, options),
|
|
3258
3258
|
update: this.makeUpdateDataSchema(model, [], false, options),
|
|
@@ -3288,27 +3288,27 @@ var ZodSchemaFactory = class {
|
|
|
3288
3288
|
const oppositeFieldDef = requireField(this.schema, fieldDef.type, oppositeField);
|
|
3289
3289
|
if (oppositeFieldDef.relation?.fields) excludeFields.push(...oppositeFieldDef.relation.fields);
|
|
3290
3290
|
}
|
|
3291
|
-
let fieldSchema = z.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
|
|
3291
|
+
let fieldSchema = z$1.lazy(() => this.makeRelationManipulationSchema(model, field, excludeFields, "update", nextOpts)).optional();
|
|
3292
3292
|
if (fieldDef.optional && !fieldDef.array) fieldSchema = fieldSchema.nullable();
|
|
3293
3293
|
checkedVariantFields[field] = fieldSchema;
|
|
3294
3294
|
if (fieldDef.array || !fieldDef.relation.references) uncheckedVariantFields[field] = fieldSchema;
|
|
3295
3295
|
} else {
|
|
3296
3296
|
let fieldSchema = this.makeScalarSchema(fieldDef.type, fieldDef.attributes);
|
|
3297
|
-
if (this.isNumericField(fieldDef)) fieldSchema = z.union([fieldSchema, z.object({
|
|
3298
|
-
set: this.nullableIf(z.number().optional(), !!fieldDef.optional).optional(),
|
|
3299
|
-
increment: z.number().optional(),
|
|
3300
|
-
decrement: z.number().optional(),
|
|
3301
|
-
multiply: z.number().optional(),
|
|
3302
|
-
divide: z.number().optional()
|
|
3297
|
+
if (this.isNumericField(fieldDef)) fieldSchema = z$1.union([fieldSchema, z$1.object({
|
|
3298
|
+
set: this.nullableIf(z$1.number().optional(), !!fieldDef.optional).optional(),
|
|
3299
|
+
increment: z$1.number().optional(),
|
|
3300
|
+
decrement: z$1.number().optional(),
|
|
3301
|
+
multiply: z$1.number().optional(),
|
|
3302
|
+
divide: z$1.number().optional()
|
|
3303
3303
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"increment\", \"decrement\", \"multiply\", or \"divide\" can be provided")]);
|
|
3304
3304
|
if (fieldDef.array) {
|
|
3305
3305
|
const arraySchema = ZodUtils.addListValidation(fieldSchema.array(), fieldDef.attributes);
|
|
3306
|
-
fieldSchema = z.union([arraySchema, z.object({
|
|
3306
|
+
fieldSchema = z$1.union([arraySchema, z$1.object({
|
|
3307
3307
|
set: arraySchema.optional(),
|
|
3308
|
-
push: z.union([fieldSchema, fieldSchema.array()]).optional()
|
|
3308
|
+
push: z$1.union([fieldSchema, fieldSchema.array()]).optional()
|
|
3309
3309
|
}).refine((v) => Object.keys(v).length === 1, "Only one of \"set\", \"push\" can be provided")]);
|
|
3310
3310
|
}
|
|
3311
|
-
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z.union([fieldSchema, z.instanceof(DbNullClass)]);
|
|
3311
|
+
if (fieldDef.optional) if (fieldDef.type === "Json") fieldSchema = z$1.union([fieldSchema, z$1.instanceof(DbNullClass)]);
|
|
3312
3312
|
else if (this.isTypeDefType(fieldDef.type)) fieldSchema = this.makeNullableTypedJsonMutationSchema(fieldSchema);
|
|
3313
3313
|
else fieldSchema = fieldSchema.nullable();
|
|
3314
3314
|
fieldSchema = fieldSchema.optional();
|
|
@@ -3316,9 +3316,9 @@ var ZodSchemaFactory = class {
|
|
|
3316
3316
|
if (!fieldDef.foreignKeyFor) checkedVariantFields[field] = fieldSchema;
|
|
3317
3317
|
}
|
|
3318
3318
|
});
|
|
3319
|
-
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(uncheckedVariantFields), modelDef.attributes) : z.strictObject(uncheckedVariantFields);
|
|
3320
|
-
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z.strictObject(checkedVariantFields), modelDef.attributes) : z.strictObject(checkedVariantFields);
|
|
3321
|
-
const result = !hasRelation ? uncheckedUpdateSchema : z.union([uncheckedUpdateSchema, checkedUpdateSchema]);
|
|
3319
|
+
const uncheckedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(uncheckedVariantFields), modelDef.attributes) : z$1.strictObject(uncheckedVariantFields);
|
|
3320
|
+
const checkedUpdateSchema = this.extraValidationsEnabled ? ZodUtils.addCustomValidation(z$1.strictObject(checkedVariantFields), modelDef.attributes) : z$1.strictObject(checkedVariantFields);
|
|
3321
|
+
const result = !hasRelation ? uncheckedUpdateSchema : z$1.union([uncheckedUpdateSchema, checkedUpdateSchema]);
|
|
3322
3322
|
const idParts = [`${model}UpdateData`];
|
|
3323
3323
|
if (withoutRelationFields) idParts.push("WithoutRelation");
|
|
3324
3324
|
if (withoutFields.length) idParts.push(`Without${withoutFields.slice().sort().join("")}`);
|
|
@@ -3326,7 +3326,7 @@ var ZodSchemaFactory = class {
|
|
|
3326
3326
|
return result;
|
|
3327
3327
|
}
|
|
3328
3328
|
makeDeleteSchema(model, options) {
|
|
3329
|
-
const baseSchema = z.strictObject({
|
|
3329
|
+
const baseSchema = z$1.strictObject({
|
|
3330
3330
|
where: this.makeWhereSchema(model, true, false, false, options),
|
|
3331
3331
|
select: this.makeSelectSchema(model, options).optional().nullable(),
|
|
3332
3332
|
include: this.makeIncludeSchema(model, options).optional().nullable(),
|
|
@@ -3340,15 +3340,15 @@ var ZodSchemaFactory = class {
|
|
|
3340
3340
|
return schema;
|
|
3341
3341
|
}
|
|
3342
3342
|
makeDeleteManySchema(model, options) {
|
|
3343
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3343
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3344
3344
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3345
|
-
limit: z.number().int().nonnegative().optional()
|
|
3345
|
+
limit: z$1.number().int().nonnegative().optional()
|
|
3346
3346
|
}), "deleteMany").optional();
|
|
3347
3347
|
this.registerSchema(`${model}DeleteManyArgs`, result);
|
|
3348
3348
|
return result;
|
|
3349
3349
|
}
|
|
3350
3350
|
makeCountSchema(model, options) {
|
|
3351
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3351
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3352
3352
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3353
3353
|
skip: this.makeSkipSchema().optional(),
|
|
3354
3354
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3359,10 +3359,10 @@ var ZodSchemaFactory = class {
|
|
|
3359
3359
|
return result;
|
|
3360
3360
|
}
|
|
3361
3361
|
makeCountAggregateInputSchema(model) {
|
|
3362
|
-
const schema = z.union([z.literal(true), z.strictObject({
|
|
3363
|
-
_all: z.literal(true).optional(),
|
|
3362
|
+
const schema = z$1.union([z$1.literal(true), z$1.strictObject({
|
|
3363
|
+
_all: z$1.literal(true).optional(),
|
|
3364
3364
|
...this.getModelFields(model).reduce((acc, [field]) => {
|
|
3365
|
-
acc[field] = z.literal(true).optional();
|
|
3365
|
+
acc[field] = z$1.literal(true).optional();
|
|
3366
3366
|
return acc;
|
|
3367
3367
|
}, {})
|
|
3368
3368
|
})]);
|
|
@@ -3370,7 +3370,7 @@ var ZodSchemaFactory = class {
|
|
|
3370
3370
|
return schema;
|
|
3371
3371
|
}
|
|
3372
3372
|
makeAggregateSchema(model, options) {
|
|
3373
|
-
const result = this.mergePluginArgsSchema(z.strictObject({
|
|
3373
|
+
const result = this.mergePluginArgsSchema(z$1.strictObject({
|
|
3374
3374
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3375
3375
|
skip: this.makeSkipSchema().optional(),
|
|
3376
3376
|
take: this.makeTakeSchema().optional(),
|
|
@@ -3385,16 +3385,16 @@ var ZodSchemaFactory = class {
|
|
|
3385
3385
|
return result;
|
|
3386
3386
|
}
|
|
3387
3387
|
makeSumAvgInputSchema(model) {
|
|
3388
|
-
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3389
|
-
if (this.isNumericField(fieldDef)) acc[field] = z.literal(true).optional();
|
|
3388
|
+
const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3389
|
+
if (this.isNumericField(fieldDef)) acc[field] = z$1.literal(true).optional();
|
|
3390
3390
|
return acc;
|
|
3391
3391
|
}, {}));
|
|
3392
3392
|
this.registerSchema(`${model}SumAvgAggregateInput`, schema);
|
|
3393
3393
|
return schema;
|
|
3394
3394
|
}
|
|
3395
3395
|
makeMinMaxInputSchema(model) {
|
|
3396
|
-
const schema = z.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3397
|
-
if (!fieldDef.relation && !fieldDef.array) acc[field] = z.literal(true).optional();
|
|
3396
|
+
const schema = z$1.strictObject(this.getModelFields(model).reduce((acc, [field, fieldDef]) => {
|
|
3397
|
+
if (!fieldDef.relation && !fieldDef.array) acc[field] = z$1.literal(true).optional();
|
|
3398
3398
|
return acc;
|
|
3399
3399
|
}, {}));
|
|
3400
3400
|
this.registerSchema(`${model}MinMaxAggregateInput`, schema);
|
|
@@ -3402,8 +3402,8 @@ var ZodSchemaFactory = class {
|
|
|
3402
3402
|
}
|
|
3403
3403
|
makeGroupBySchema(model, options) {
|
|
3404
3404
|
const nonRelationFields = this.getModelFields(model).filter(([, def]) => !def.relation).map(([name]) => name);
|
|
3405
|
-
const bySchema = nonRelationFields.length > 0 ? this.orArray(z.enum(nonRelationFields), true) : z.never();
|
|
3406
|
-
const baseSchema = z.strictObject({
|
|
3405
|
+
const bySchema = nonRelationFields.length > 0 ? this.orArray(z$1.enum(nonRelationFields), true) : z$1.never();
|
|
3406
|
+
const baseSchema = z$1.strictObject({
|
|
3407
3407
|
where: this.makeWhereSchema(model, false, false, false, options).optional(),
|
|
3408
3408
|
orderBy: this.orArray(this.makeOrderBySchema(model, false, true, options), true).optional(),
|
|
3409
3409
|
by: bySchema,
|
|
@@ -3455,7 +3455,7 @@ var ZodSchemaFactory = class {
|
|
|
3455
3455
|
if (!procDef) throw createInternalError(`Procedure not found: ${procName}`);
|
|
3456
3456
|
const shape = {};
|
|
3457
3457
|
for (const param of Object.values(procDef.params ?? {})) shape[param.name] = this.makeProcedureParamSchema(param);
|
|
3458
|
-
const schema = z.object(shape);
|
|
3458
|
+
const schema = z$1.object(shape);
|
|
3459
3459
|
this.registerSchema(`${procName}ProcArgs`, schema);
|
|
3460
3460
|
return schema;
|
|
3461
3461
|
}
|
|
@@ -3463,10 +3463,10 @@ var ZodSchemaFactory = class {
|
|
|
3463
3463
|
let schema;
|
|
3464
3464
|
if (isTypeDef(this.schema, param.type)) schema = this.makeTypeDefSchema(param.type);
|
|
3465
3465
|
else if (isEnum(this.schema, param.type)) schema = this.makeEnumSchema(param.type);
|
|
3466
|
-
else if (param.type in (this.schema.models ?? {})) schema = z.record(z.string(), z.unknown());
|
|
3466
|
+
else if (param.type in (this.schema.models ?? {})) schema = z$1.record(z$1.string(), z$1.unknown());
|
|
3467
3467
|
else {
|
|
3468
3468
|
schema = this.makeScalarSchema(param.type);
|
|
3469
|
-
if (schema instanceof z.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
|
|
3469
|
+
if (schema instanceof z$1.ZodUnknown) throw createInternalError(`Unsupported procedure parameter type: ${param.type}`);
|
|
3470
3470
|
}
|
|
3471
3471
|
if (param.array) schema = schema.array();
|
|
3472
3472
|
if (param.optional) schema = schema.optional();
|
|
@@ -3502,10 +3502,10 @@ var ZodSchemaFactory = class {
|
|
|
3502
3502
|
return result;
|
|
3503
3503
|
}
|
|
3504
3504
|
makeSkipSchema() {
|
|
3505
|
-
return z.number().int().nonnegative();
|
|
3505
|
+
return z$1.number().int().nonnegative();
|
|
3506
3506
|
}
|
|
3507
3507
|
makeTakeSchema() {
|
|
3508
|
-
return z.number().int();
|
|
3508
|
+
return z$1.number().int();
|
|
3509
3509
|
}
|
|
3510
3510
|
refineForSelectIncludeMutuallyExclusive(schema) {
|
|
3511
3511
|
return schema.refine((value) => !(value["select"] && value["include"]), "\"select\" and \"include\" cannot be used together");
|
|
@@ -3524,7 +3524,7 @@ var ZodSchemaFactory = class {
|
|
|
3524
3524
|
return nullable ? schema.nullable() : schema;
|
|
3525
3525
|
}
|
|
3526
3526
|
orArray(schema, canBeArray) {
|
|
3527
|
-
return canBeArray ? z.union([schema, z.array(schema)]) : schema;
|
|
3527
|
+
return canBeArray ? z$1.union([schema, z$1.array(schema)]) : schema;
|
|
3528
3528
|
}
|
|
3529
3529
|
isNumericField(fieldDef) {
|
|
3530
3530
|
return NUMERIC_FIELD_TYPES.includes(fieldDef.type) && !fieldDef.array;
|
|
@@ -3586,10 +3586,10 @@ var ZodSchemaFactory = class {
|
|
|
3586
3586
|
createUnionFilterSchema(valueSchema, optional, components, allowedFilterKinds) {
|
|
3587
3587
|
if (Object.keys(components).length === 0) {
|
|
3588
3588
|
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return this.nullableIf(valueSchema, optional);
|
|
3589
|
-
return z.never();
|
|
3589
|
+
return z$1.never();
|
|
3590
3590
|
}
|
|
3591
|
-
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z.union([this.nullableIf(valueSchema, optional), z.strictObject(components)]);
|
|
3592
|
-
else return z.strictObject(components);
|
|
3591
|
+
if (!allowedFilterKinds || allowedFilterKinds.includes("Equality")) return z$1.union([this.nullableIf(valueSchema, optional), z$1.strictObject(components)]);
|
|
3592
|
+
else return z$1.strictObject(components);
|
|
3593
3593
|
}
|
|
3594
3594
|
canCreateModel(model) {
|
|
3595
3595
|
const modelDef = requireModel(this.schema, model);
|
|
@@ -7197,9 +7197,9 @@ var ClientImpl = class ClientImpl {
|
|
|
7197
7197
|
validateOptions(baseClient, options) {
|
|
7198
7198
|
if (!baseClient && !options.skipValidationForComputedFields) this.validateComputedFieldsConfig(options);
|
|
7199
7199
|
if (options.diagnostics) {
|
|
7200
|
-
const parseResult = z
|
|
7201
|
-
slowQueryThresholdMs: z
|
|
7202
|
-
slowQueryMaxRecords: z
|
|
7200
|
+
const parseResult = z.object({
|
|
7201
|
+
slowQueryThresholdMs: z.number().nonnegative().optional(),
|
|
7202
|
+
slowQueryMaxRecords: z.int().nonnegative().or(z.literal(Infinity)).optional()
|
|
7203
7203
|
}).safeParse(options.diagnostics);
|
|
7204
7204
|
if (!parseResult.success) throw createConfigError(`Invalid diagnostics configuration: ${formatError(parseResult.error)}`);
|
|
7205
7205
|
}
|