@zenstackhq/orm 3.3.3 → 3.4.0-beta.2
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 +381 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1593 -1373
- package/dist/index.d.ts +1593 -1373
- package/dist/index.js +381 -111
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.cts
CHANGED
|
@@ -1,79 +1,10 @@
|
|
|
1
1
|
import * as _zenstackhq_schema from '@zenstackhq/schema';
|
|
2
|
-
import { SchemaDef, GetModels, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField,
|
|
2
|
+
import { SchemaDef, BuiltinType, GetModels, FieldDef, ModelDef, DataSourceProviderType, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, GetModel, ProcedureDef, NonRelationFields, GetEnums, GetEnum, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetTypeDefFieldType, TypeDefFieldIsArray, UpdatedAtInfo, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, IsDelegateModel, Expression as Expression$1, LiteralExpression, ArrayExpression, FieldExpression, MemberExpression, BinaryExpression, UnaryExpression, CallExpression, BindingExpression, ThisExpression, NullExpression } from '@zenstackhq/schema';
|
|
3
3
|
import * as kysely from 'kysely';
|
|
4
|
-
import { OperationNodeVisitor, OperationNode, SelectQueryNode, SelectionNode, ColumnNode, AliasNode, TableNode, FromNode, ReferenceNode, AndNode, OrNode, ValueListNode, ParensNode, JoinNode, RawNode, WhereNode, InsertQueryNode, DeleteQueryNode, ReturningNode, CreateTableNode, AddColumnNode, ColumnDefinitionNode, DropTableNode, OrderByNode, OrderByItemNode, GroupByNode, GroupByItemNode, UpdateQueryNode, ColumnUpdateNode, LimitNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, CheckConstraintNode, DataTypeNode, SelectAllNode, IdentifierNode, SchemableIdentifierNode, ValueNode, PrimitiveValueListNode, OperatorNode, CreateIndexNode, DropIndexNode, ListNode, PrimaryKeyConstraintNode, UniqueConstraintNode, ReferencesNode, WithNode, CommonTableExpressionNode, CommonTableExpressionNameNode, HavingNode, CreateSchemaNode, DropSchemaNode, AlterTableNode, DropColumnNode, RenameColumnNode, AlterColumnNode, ModifyColumnNode, AddConstraintNode, DropConstraintNode, ForeignKeyConstraintNode, CreateViewNode, DropViewNode, GeneratedNode, DefaultValueNode, OnNode, ValuesNode, SelectModifierNode, CreateTypeNode, DropTypeNode, ExplainNode, DefaultInsertValueNode, AggregateFunctionNode, OverNode, PartitionByNode, PartitionByItemNode, SetOperationNode, BinaryOperationNode, UnaryOperationNode, UsingNode, FunctionNode, CaseNode, WhenNode, JSONReferenceNode, JSONPathNode, JSONPathLegNode, JSONOperatorChainNode, TupleNode, MergeQueryNode, MatchedNode, AddIndexNode, CastNode, FetchNode, TopNode, OutputNode, RenameConstraintNode, RefreshMaterializedViewNode, OrActionNode, CollateNode, Kysely,
|
|
4
|
+
import { OperationNodeVisitor, OperationNode, SelectQueryNode, SelectionNode, ColumnNode, AliasNode, TableNode, FromNode, ReferenceNode, AndNode, OrNode, ValueListNode, ParensNode, JoinNode, RawNode, WhereNode, InsertQueryNode, DeleteQueryNode, ReturningNode, CreateTableNode, AddColumnNode, ColumnDefinitionNode, DropTableNode, OrderByNode, OrderByItemNode, GroupByNode, GroupByItemNode, UpdateQueryNode, ColumnUpdateNode, LimitNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, CheckConstraintNode, DataTypeNode, SelectAllNode, IdentifierNode, SchemableIdentifierNode, ValueNode, PrimitiveValueListNode, OperatorNode, CreateIndexNode, DropIndexNode, ListNode, PrimaryKeyConstraintNode, UniqueConstraintNode, ReferencesNode, WithNode, CommonTableExpressionNode, CommonTableExpressionNameNode, HavingNode, CreateSchemaNode, DropSchemaNode, AlterTableNode, DropColumnNode, RenameColumnNode, AlterColumnNode, ModifyColumnNode, AddConstraintNode, DropConstraintNode, ForeignKeyConstraintNode, CreateViewNode, DropViewNode, GeneratedNode, DefaultValueNode, OnNode, ValuesNode, SelectModifierNode, CreateTypeNode, DropTypeNode, ExplainNode, DefaultInsertValueNode, AggregateFunctionNode, OverNode, PartitionByNode, PartitionByItemNode, SetOperationNode, BinaryOperationNode, UnaryOperationNode, UsingNode, FunctionNode, CaseNode, WhenNode, JSONReferenceNode, JSONPathNode, JSONPathLegNode, JSONOperatorChainNode, TupleNode, MergeQueryNode, MatchedNode, AddIndexNode, CastNode, FetchNode, TopNode, OutputNode, RenameConstraintNode, RefreshMaterializedViewNode, OrActionNode, CollateNode, Kysely, ExpressionBuilder, SelectQueryBuilder, Expression, SqlBool, ExpressionWrapper, AliasableExpression, Generated, QueryId, RootOperationNode, QueryResult, UnknownRow, Dialect, KyselyConfig, OperandExpression } from 'kysely';
|
|
5
5
|
import Decimal from 'decimal.js';
|
|
6
6
|
import { z, ZodType } from 'zod';
|
|
7
7
|
|
|
8
|
-
type JsonValue = string | number | boolean | JsonObject | JsonArray;
|
|
9
|
-
type JsonObject = {
|
|
10
|
-
[key: string]: JsonValue | null;
|
|
11
|
-
};
|
|
12
|
-
type JsonArray = ReadonlyArray<JsonValue | null>;
|
|
13
|
-
type JsonNullValues = DbNull | JsonNull | AnyNull;
|
|
14
|
-
declare class DbNullClass {
|
|
15
|
-
private __brand;
|
|
16
|
-
}
|
|
17
|
-
declare const DbNull: DbNullClass;
|
|
18
|
-
type DbNull = typeof DbNull;
|
|
19
|
-
declare class JsonNullClass {
|
|
20
|
-
private __brand;
|
|
21
|
-
}
|
|
22
|
-
declare const JsonNull: JsonNullClass;
|
|
23
|
-
type JsonNull = typeof JsonNull;
|
|
24
|
-
declare class AnyNullClass {
|
|
25
|
-
private __brand;
|
|
26
|
-
}
|
|
27
|
-
declare const AnyNull: AnyNullClass;
|
|
28
|
-
type AnyNull = typeof AnyNull;
|
|
29
|
-
|
|
30
|
-
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
31
|
-
type PartialIf<T, Condition extends boolean> = Condition extends true ? Partial<T> : T;
|
|
32
|
-
type NullableIf<T, Condition extends boolean> = Condition extends true ? T | null : T;
|
|
33
|
-
type _Preserve = Date | Function | Decimal | Uint8Array | JsonObject | JsonValue;
|
|
34
|
-
type _Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
35
|
-
type Simplify<T, D extends number = 6> = D extends 0 ? T : T extends object ? T extends _Preserve ? T : {
|
|
36
|
-
[K in keyof T]: Simplify<T[K], _Depth[D]>;
|
|
37
|
-
} & {} : T;
|
|
38
|
-
type WrapType<T, Optional = false, Array = false> = Array extends true ? Optional extends true ? T[] | null : T[] : Optional extends true ? T | null : T;
|
|
39
|
-
type TypeMap = {
|
|
40
|
-
String: string;
|
|
41
|
-
Boolean: boolean;
|
|
42
|
-
Int: number;
|
|
43
|
-
Float: number;
|
|
44
|
-
BigInt: bigint;
|
|
45
|
-
Decimal: Decimal;
|
|
46
|
-
DateTime: Date;
|
|
47
|
-
Bytes: Uint8Array;
|
|
48
|
-
Json: JsonValue;
|
|
49
|
-
Null: null;
|
|
50
|
-
Object: Record<string, unknown>;
|
|
51
|
-
Any: unknown;
|
|
52
|
-
Unsupported: unknown;
|
|
53
|
-
Void: void;
|
|
54
|
-
Undefined: undefined;
|
|
55
|
-
};
|
|
56
|
-
type MapBaseType$1<T extends string> = T extends keyof TypeMap ? TypeMap[T] : unknown;
|
|
57
|
-
type OrArray<T, IF extends boolean = true> = IF extends true ? T | T[] : T;
|
|
58
|
-
type NonEmptyArray<T> = [T, ...T[]];
|
|
59
|
-
type ValueOfPotentialTuple<T> = T extends unknown[] ? T[number] : T;
|
|
60
|
-
type NoExpand<T> = T extends unknown ? T : never;
|
|
61
|
-
type AtLeast<O extends object, K extends string> = NoExpand<O extends unknown ? (K extends keyof O ? {
|
|
62
|
-
[P in K]: O[P];
|
|
63
|
-
} & O : O) | ({
|
|
64
|
-
[P in keyof O as P extends K ? K : never]-?: O[P];
|
|
65
|
-
} & O) : never>;
|
|
66
|
-
type Without<T, U> = {
|
|
67
|
-
[P in Exclude<keyof T, keyof U>]?: never;
|
|
68
|
-
};
|
|
69
|
-
type XOR<T, U> = T extends object ? (U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : U) : T;
|
|
70
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
71
|
-
type PrependParameter<Param, Func> = Func extends (...args: any[]) => infer R ? (p: Param, ...args: Parameters<Func>) => R : never;
|
|
72
|
-
type OrUndefinedIf<T, Condition extends boolean> = Condition extends true ? T | undefined : T;
|
|
73
|
-
type UnwrapTuplePromises<T extends readonly unknown[]> = {
|
|
74
|
-
[K in keyof T]: Awaited<T[K]>;
|
|
75
|
-
};
|
|
76
|
-
|
|
77
8
|
declare class DefaultOperationNodeVisitor extends OperationNodeVisitor {
|
|
78
9
|
protected defaultVisit(node: OperationNode): void;
|
|
79
10
|
protected visitSelectQuery(node: SelectQueryNode): void;
|
|
@@ -183,6 +114,75 @@ declare namespace kyselyUtils {
|
|
|
183
114
|
export { type kyselyUtils_AnyKysely as AnyKysely, kyselyUtils_DefaultOperationNodeVisitor as DefaultOperationNodeVisitor };
|
|
184
115
|
}
|
|
185
116
|
|
|
117
|
+
type JsonValue = string | number | boolean | JsonObject | JsonArray;
|
|
118
|
+
type JsonObject = {
|
|
119
|
+
[key: string]: JsonValue | null;
|
|
120
|
+
};
|
|
121
|
+
type JsonArray = ReadonlyArray<JsonValue | null>;
|
|
122
|
+
type JsonNullValues = DbNull | JsonNull | AnyNull;
|
|
123
|
+
declare class DbNullClass {
|
|
124
|
+
private __brand;
|
|
125
|
+
}
|
|
126
|
+
declare const DbNull: DbNullClass;
|
|
127
|
+
type DbNull = typeof DbNull;
|
|
128
|
+
declare class JsonNullClass {
|
|
129
|
+
private __brand;
|
|
130
|
+
}
|
|
131
|
+
declare const JsonNull: JsonNullClass;
|
|
132
|
+
type JsonNull = typeof JsonNull;
|
|
133
|
+
declare class AnyNullClass {
|
|
134
|
+
private __brand;
|
|
135
|
+
}
|
|
136
|
+
declare const AnyNull: AnyNullClass;
|
|
137
|
+
type AnyNull = typeof AnyNull;
|
|
138
|
+
|
|
139
|
+
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
140
|
+
type PartialIf<T, Condition extends boolean> = Condition extends true ? Partial<T> : T;
|
|
141
|
+
type NullableIf<T, Condition extends boolean> = Condition extends true ? T | null : T;
|
|
142
|
+
type _Preserve = Date | Function | Decimal | Uint8Array | JsonObject | JsonValue;
|
|
143
|
+
type _Depth = [never, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9];
|
|
144
|
+
type Simplify<T, D extends number = 6> = D extends 0 ? T : T extends object ? T extends _Preserve ? T : {
|
|
145
|
+
[K in keyof T]: Simplify<T[K], _Depth[D]>;
|
|
146
|
+
} & {} : T;
|
|
147
|
+
type WrapType<T, Optional = false, Array = false> = Array extends true ? Optional extends true ? T[] | null : T[] : Optional extends true ? T | null : T;
|
|
148
|
+
type TypeMap = {
|
|
149
|
+
String: string;
|
|
150
|
+
Boolean: boolean;
|
|
151
|
+
Int: number;
|
|
152
|
+
Float: number;
|
|
153
|
+
BigInt: bigint;
|
|
154
|
+
Decimal: Decimal;
|
|
155
|
+
DateTime: Date;
|
|
156
|
+
Bytes: Uint8Array;
|
|
157
|
+
Json: JsonValue;
|
|
158
|
+
Null: null;
|
|
159
|
+
Object: Record<string, unknown>;
|
|
160
|
+
Any: unknown;
|
|
161
|
+
Unsupported: unknown;
|
|
162
|
+
Void: void;
|
|
163
|
+
Undefined: undefined;
|
|
164
|
+
};
|
|
165
|
+
type MapBaseType$1<T extends string> = T extends keyof TypeMap ? TypeMap[T] : unknown;
|
|
166
|
+
type OrArray<T, IF extends boolean = true> = IF extends true ? T | T[] : T;
|
|
167
|
+
type NonEmptyArray<T> = [T, ...T[]];
|
|
168
|
+
type ValueOfPotentialTuple<T> = T extends unknown[] ? T[number] : T;
|
|
169
|
+
type NoExpand<T> = T extends unknown ? T : never;
|
|
170
|
+
type AtLeast<O extends object, K extends string> = NoExpand<O extends unknown ? (K extends keyof O ? {
|
|
171
|
+
[P in K]: O[P];
|
|
172
|
+
} & O : O) | ({
|
|
173
|
+
[P in keyof O as P extends K ? K : never]-?: O[P];
|
|
174
|
+
} & O) : never>;
|
|
175
|
+
type Without<T, U> = {
|
|
176
|
+
[P in Exclude<keyof T, keyof U>]?: never;
|
|
177
|
+
};
|
|
178
|
+
type XOR<T, U> = T extends object ? (U extends object ? (Without<T, U> & U) | (Without<U, T> & T) : U) : T;
|
|
179
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
180
|
+
type PrependParameter<Param, Func> = Func extends (...args: any[]) => infer R ? (p: Param, ...args: Parameters<Func>) => R : never;
|
|
181
|
+
type OrUndefinedIf<T, Condition extends boolean> = Condition extends true ? T | undefined : T;
|
|
182
|
+
type UnwrapTuplePromises<T extends readonly unknown[]> = {
|
|
183
|
+
[K in keyof T]: Awaited<T[K]>;
|
|
184
|
+
};
|
|
185
|
+
|
|
186
186
|
/**
|
|
187
187
|
* Client API methods that are not supported in transactions.
|
|
188
188
|
*/
|
|
@@ -194,1554 +194,1882 @@ declare const LOGICAL_COMBINATORS: readonly ["AND", "OR", "NOT"];
|
|
|
194
194
|
/**
|
|
195
195
|
* Aggregation operators.
|
|
196
196
|
*/
|
|
197
|
-
declare const
|
|
198
|
-
type
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
197
|
+
declare const AggregateOperators: readonly ["_count", "_sum", "_avg", "_min", "_max"];
|
|
198
|
+
type AggregateOperators = (typeof AggregateOperators)[number];
|
|
199
|
+
/**
|
|
200
|
+
* Mapping of filter operators to their corresponding filter kind categories.
|
|
201
|
+
*/
|
|
202
|
+
declare const FILTER_PROPERTY_TO_KIND: {
|
|
203
|
+
readonly equals: "Equality";
|
|
204
|
+
readonly not: "Equality";
|
|
205
|
+
readonly in: "Equality";
|
|
206
|
+
readonly notIn: "Equality";
|
|
207
|
+
readonly lt: "Range";
|
|
208
|
+
readonly lte: "Range";
|
|
209
|
+
readonly gt: "Range";
|
|
210
|
+
readonly gte: "Range";
|
|
211
|
+
readonly between: "Range";
|
|
212
|
+
readonly contains: "Like";
|
|
213
|
+
readonly startsWith: "Like";
|
|
214
|
+
readonly endsWith: "Like";
|
|
215
|
+
readonly mode: "Like";
|
|
216
|
+
readonly is: "Relation";
|
|
217
|
+
readonly isNot: "Relation";
|
|
218
|
+
readonly some: "Relation";
|
|
219
|
+
readonly every: "Relation";
|
|
220
|
+
readonly none: "Relation";
|
|
221
|
+
readonly path: "Json";
|
|
222
|
+
readonly string_contains: "Json";
|
|
223
|
+
readonly string_starts_with: "Json";
|
|
224
|
+
readonly string_ends_with: "Json";
|
|
225
|
+
readonly array_contains: "Json";
|
|
226
|
+
readonly array_starts_with: "Json";
|
|
227
|
+
readonly array_ends_with: "Json";
|
|
228
|
+
readonly has: "List";
|
|
229
|
+
readonly hasEvery: "List";
|
|
230
|
+
readonly hasSome: "List";
|
|
231
|
+
readonly isEmpty: "List";
|
|
206
232
|
};
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
type
|
|
233
|
+
/**
|
|
234
|
+
* Mapping of filter operators to their corresponding filter kind categories.
|
|
235
|
+
*/
|
|
236
|
+
type FilterPropertyToKind = typeof FILTER_PROPERTY_TO_KIND;
|
|
211
237
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
type OptionsLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>> = Model extends keyof Options['omit'] ? Field extends keyof Options['omit'][Model] ? Options['omit'][Model][Field] extends boolean ? Options['omit'][Model][Field] : undefined : undefined : undefined;
|
|
218
|
-
type SchemaLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['omit'] extends true ? true : false;
|
|
219
|
-
type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Select, Omit, Options extends QueryOptions<Schema>> = {
|
|
220
|
-
[Key in keyof Select as Select[Key] extends false | undefined ? never : Key extends '_count' ? Select[Key] extends SelectCount<Schema, Model> ? Key : never : Key extends keyof Omit ? Omit[Key] extends true ? never : Key : Key]: Key extends '_count' ? SelectCountResult<Schema, Model, Select[Key]> : Key extends NonRelationFields<Schema, Model> ? MapModelFieldType<Schema, Model, Key> : Key extends RelationFields<Schema, Model> ? ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Select[Key], Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : never;
|
|
221
|
-
};
|
|
222
|
-
type SelectCountResult<Schema extends SchemaDef, Model extends GetModels<Schema>, C> = C extends true ? {
|
|
223
|
-
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: number;
|
|
224
|
-
} : C extends {
|
|
225
|
-
select: infer S;
|
|
226
|
-
} ? {
|
|
227
|
-
[Key in keyof S]: number;
|
|
228
|
-
} : never;
|
|
229
|
-
type ModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<Args extends {
|
|
230
|
-
select: infer S extends object;
|
|
231
|
-
omit?: infer O extends object;
|
|
232
|
-
} & Record<string, unknown> ? ModelSelectResult<Schema, Model, S, O, Options> : Args extends {
|
|
233
|
-
include: infer I extends object;
|
|
234
|
-
omit?: infer O extends object;
|
|
235
|
-
} & Record<string, unknown> ? // select all non-omitted scalar fields
|
|
236
|
-
DefaultModelResult<Schema, Model, O, Options, false, false> & {
|
|
237
|
-
[Key in keyof I & RelationFields<Schema, Model> as I[Key] extends false | undefined ? never : Key]: ModelResult<Schema, RelationFieldType<Schema, Model, Key>, I[Key], Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>>;
|
|
238
|
-
} & ('_count' extends keyof I ? I['_count'] extends false | undefined ? {} : {
|
|
239
|
-
_count: SelectCountResult<Schema, Model, I['_count']>;
|
|
240
|
-
} : {}) : Args extends {
|
|
241
|
-
omit: infer O;
|
|
242
|
-
} & Record<string, unknown> ? DefaultModelResult<Schema, Model, O, Options, false, false> : DefaultModelResult<Schema, Model, undefined, Options, false, false>, Optional, Array>;
|
|
243
|
-
type SimplifiedResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = Simplify<ModelResult<Schema, Model, Args, Options, Optional, Array>>;
|
|
244
|
-
type SimplifiedPlainResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Simplify<ModelResult<Schema, Model, Args, Options, false, false>>;
|
|
245
|
-
type TypeDefResult<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Partial extends boolean = false> = PartialIf<Optional<{
|
|
246
|
-
[Key in GetTypeDefFields<Schema, TypeDef>]: MapFieldDefType<Schema, GetTypeDefField<Schema, TypeDef, Key>, Partial>;
|
|
247
|
-
}, Partial extends true ? never : keyof {
|
|
248
|
-
[Key in GetTypeDefFields<Schema, TypeDef> as TypeDefFieldIsOptional<Schema, TypeDef, Key> extends true ? Key : never]: true;
|
|
249
|
-
}>, Partial> & Record<string, unknown>;
|
|
250
|
-
type BatchResult = {
|
|
251
|
-
count: number;
|
|
252
|
-
};
|
|
253
|
-
type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ScalarOnly extends boolean = false, WithAggregations extends boolean = false> = {
|
|
254
|
-
[Key in GetModelFields<Schema, Model> as ScalarOnly extends true ? Key extends RelationFields<Schema, Model> ? never : Key : Key]?: Key extends RelationFields<Schema, Model> ? RelationFilter<Schema, Model, Key> : FieldIsArray<Schema, Model, Key> extends true ? ArrayFilter<Schema, GetModelFieldType<Schema, Model, Key>> : GetModelFieldType<Schema, Model, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetModelFieldType<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>, WithAggregations> : GetModelFieldType<Schema, Model, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetModelFieldType<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>> : PrimitiveFilter<GetModelFieldType<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>, WithAggregations>;
|
|
255
|
-
} & {
|
|
256
|
-
$expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
|
|
257
|
-
} & {
|
|
258
|
-
AND?: OrArray<WhereInput<Schema, Model, ScalarOnly>>;
|
|
259
|
-
OR?: WhereInput<Schema, Model, ScalarOnly>[];
|
|
260
|
-
NOT?: OrArray<WhereInput<Schema, Model, ScalarOnly>>;
|
|
261
|
-
};
|
|
262
|
-
type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable extends boolean, WithAggregations extends boolean> = NullableIf<keyof GetEnum<Schema, T>, Nullable> | ({
|
|
263
|
-
/**
|
|
264
|
-
* Checks for equality with the specified enum value.
|
|
265
|
-
*/
|
|
266
|
-
equals?: NullableIf<keyof GetEnum<Schema, T>, Nullable>;
|
|
267
|
-
/**
|
|
268
|
-
* Checks if the enum value is in the specified list of values.
|
|
269
|
-
*/
|
|
270
|
-
in?: (keyof GetEnum<Schema, T>)[];
|
|
271
|
-
/**
|
|
272
|
-
* Checks if the enum value is not in the specified list of values.
|
|
273
|
-
*/
|
|
274
|
-
notIn?: (keyof GetEnum<Schema, T>)[];
|
|
275
|
-
/**
|
|
276
|
-
* Builds a negated filter.
|
|
277
|
-
*/
|
|
278
|
-
not?: EnumFilter<Schema, T, Nullable, WithAggregations>;
|
|
279
|
-
} & (WithAggregations extends true ? {
|
|
280
|
-
/**
|
|
281
|
-
* Filters against the count of records.
|
|
282
|
-
*/
|
|
283
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
238
|
+
declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
239
|
+
protected readonly schema: Schema;
|
|
240
|
+
protected readonly options: ClientOptions<Schema>;
|
|
241
|
+
protected eb: ExpressionBuilder<any, any>;
|
|
242
|
+
constructor(schema: Schema, options: ClientOptions<Schema>);
|
|
284
243
|
/**
|
|
285
|
-
*
|
|
244
|
+
* Whether the dialect supports updating with a limit on the number of updated rows.
|
|
286
245
|
*/
|
|
287
|
-
|
|
246
|
+
abstract get supportsUpdateWithLimit(): boolean;
|
|
288
247
|
/**
|
|
289
|
-
*
|
|
248
|
+
* Whether the dialect supports deleting with a limit on the number of deleted rows.
|
|
290
249
|
*/
|
|
291
|
-
|
|
292
|
-
} : {}));
|
|
293
|
-
type ArrayFilter<Schema extends SchemaDef, Type extends string> = {
|
|
250
|
+
abstract get supportsDeleteWithLimit(): boolean;
|
|
294
251
|
/**
|
|
295
|
-
*
|
|
252
|
+
* Whether the dialect supports DISTINCT ON.
|
|
296
253
|
*/
|
|
297
|
-
|
|
254
|
+
abstract get supportsDistinctOn(): boolean;
|
|
298
255
|
/**
|
|
299
|
-
*
|
|
256
|
+
* Whether the dialect support inserting with `DEFAULT` as field value.
|
|
300
257
|
*/
|
|
301
|
-
|
|
258
|
+
abstract get supportsDefaultAsFieldValue(): boolean;
|
|
302
259
|
/**
|
|
303
|
-
*
|
|
260
|
+
* Whether the dialect supports the RETURNING clause in INSERT/UPDATE/DELETE statements.
|
|
304
261
|
*/
|
|
305
|
-
|
|
262
|
+
abstract get supportsReturning(): boolean;
|
|
306
263
|
/**
|
|
307
|
-
*
|
|
264
|
+
* Whether the dialect supports `INSERT INTO ... DEFAULT VALUES` syntax.
|
|
308
265
|
*/
|
|
309
|
-
|
|
266
|
+
abstract get supportsInsertDefaultValues(): boolean;
|
|
310
267
|
/**
|
|
311
|
-
*
|
|
268
|
+
* How to perform insert ignore operation.
|
|
312
269
|
*/
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
type MapScalarType<Schema extends SchemaDef, Type extends string> = Type extends GetEnums<Schema> ? keyof GetEnum<Schema, Type> : MapBaseType$1<Type>;
|
|
316
|
-
type PrimitiveFilter<T extends string, Nullable extends boolean, WithAggregations extends boolean> = T extends 'String' ? StringFilter<Nullable, WithAggregations> : T extends 'Int' | 'Float' | 'Decimal' | 'BigInt' ? NumberFilter<T, Nullable, WithAggregations> : T extends 'Boolean' ? BooleanFilter<Nullable, WithAggregations> : T extends 'DateTime' ? DateTimeFilter<Nullable, WithAggregations> : T extends 'Bytes' ? BytesFilter<Nullable, WithAggregations> : T extends 'Json' ? JsonFilter : never;
|
|
317
|
-
type CommonPrimitiveFilter<DataType, T extends BuiltinType, Nullable extends boolean, WithAggregations extends boolean> = {
|
|
270
|
+
abstract get insertIgnoreMethod(): 'onConflict' | 'ignore';
|
|
318
271
|
/**
|
|
319
|
-
*
|
|
272
|
+
* Transforms input value before sending to database.
|
|
320
273
|
*/
|
|
321
|
-
|
|
274
|
+
transformInput(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
322
275
|
/**
|
|
323
|
-
*
|
|
276
|
+
* Transforms output value received from database.
|
|
324
277
|
*/
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
* Filters against the count of records.
|
|
375
|
-
*/
|
|
376
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
278
|
+
transformOutput(value: unknown, _type: BuiltinType, _array: boolean): unknown;
|
|
279
|
+
buildSelectModel(model: string, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
280
|
+
buildFilterSortTake(model: string, args: FindArgs<Schema, GetModels<Schema>, any, true>, query: SelectQueryBuilder<any, any, {}>, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
281
|
+
buildFilter(model: string, modelAlias: string, where: boolean | object | undefined): Expression<SqlBool>;
|
|
282
|
+
private buildCursorFilter;
|
|
283
|
+
private isLogicalCombinator;
|
|
284
|
+
protected buildCompositeFilter(model: string, modelAlias: string, key: (typeof LOGICAL_COMBINATORS)[number], payload: any): Expression<SqlBool>;
|
|
285
|
+
private buildRelationFilter;
|
|
286
|
+
private buildToOneRelationFilter;
|
|
287
|
+
private buildToManyRelationFilter;
|
|
288
|
+
private buildArrayFilter;
|
|
289
|
+
buildPrimitiveFilter(fieldRef: Expression<any>, fieldDef: FieldDef, payload: any): any;
|
|
290
|
+
private buildJsonFilter;
|
|
291
|
+
private buildPlainJsonFilter;
|
|
292
|
+
private buildTypedJsonFilter;
|
|
293
|
+
private buildTypedJsonArrayFilter;
|
|
294
|
+
private buildTypeJsonNonArrayFilter;
|
|
295
|
+
private buildJsonValueFilterClause;
|
|
296
|
+
protected buildJsonEqualityFilter(lhs: Expression<any>, rhs: unknown): ExpressionWrapper<any, any, SqlBool>;
|
|
297
|
+
private buildLiteralFilter;
|
|
298
|
+
private buildStandardFilter;
|
|
299
|
+
private buildStringFilter;
|
|
300
|
+
private buildJsonStringFilter;
|
|
301
|
+
private escapeLikePattern;
|
|
302
|
+
private buildStringLike;
|
|
303
|
+
private prepStringCasing;
|
|
304
|
+
private buildNumberFilter;
|
|
305
|
+
private buildBooleanFilter;
|
|
306
|
+
private buildDateTimeFilter;
|
|
307
|
+
private buildBytesFilter;
|
|
308
|
+
private buildEnumFilter;
|
|
309
|
+
buildOrderBy(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, orderBy: OrArray<OrderBy<Schema, GetModels<Schema>, boolean, boolean>> | undefined, negated: boolean, take: number | undefined): SelectQueryBuilder<any, any, any>;
|
|
310
|
+
buildSelectAllFields(model: string, query: SelectQueryBuilder<any, any, any>, omit: Record<string, boolean | undefined> | undefined | null, modelAlias: string): SelectQueryBuilder<any, any, any>;
|
|
311
|
+
shouldOmitField(omit: unknown, model: string, field: string): any;
|
|
312
|
+
protected buildModelSelect(model: GetModels<Schema>, subQueryAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, any, true>, selectAllFields: boolean): SelectQueryBuilder<any, any, {}>;
|
|
313
|
+
buildSelectField(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, field: string): SelectQueryBuilder<any, any, any>;
|
|
314
|
+
buildDelegateJoin(thisModel: string, thisModelAlias: string, otherModelAlias: string, query: SelectQueryBuilder<any, any, any>): SelectQueryBuilder<any, any, any>;
|
|
315
|
+
buildCountJson(model: string, eb: ExpressionBuilder<any, any>, parentAlias: string, payload: any): AliasableExpression<unknown>;
|
|
316
|
+
protected negateSort(sort: SortOrder, negated: boolean): SortOrder;
|
|
317
|
+
true(): Expression<SqlBool>;
|
|
318
|
+
false(): Expression<SqlBool>;
|
|
319
|
+
isTrue(expression: Expression<SqlBool>): boolean;
|
|
320
|
+
isFalse(expression: Expression<SqlBool>): boolean;
|
|
321
|
+
and(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
322
|
+
or(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
323
|
+
not(...args: Expression<SqlBool>[]): ExpressionWrapper<any, any, SqlBool>;
|
|
324
|
+
fieldRef(model: string, field: string, modelAlias?: string, inlineComputedField?: boolean): any;
|
|
325
|
+
protected canJoinWithoutNestedSelect(modelDef: ModelDef, payload: boolean | FindArgs<Schema, GetModels<Schema>, any, true>): boolean;
|
|
326
|
+
abstract get provider(): DataSourceProviderType;
|
|
377
327
|
/**
|
|
378
|
-
*
|
|
328
|
+
* Builds selection for a relation field.
|
|
379
329
|
*/
|
|
380
|
-
|
|
330
|
+
abstract buildRelationSelection(query: SelectQueryBuilder<any, any, any>, model: string, relationField: string, parentAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, any, true>): SelectQueryBuilder<any, any, any>;
|
|
381
331
|
/**
|
|
382
|
-
*
|
|
332
|
+
* Builds skip and take clauses.
|
|
383
333
|
*/
|
|
384
|
-
|
|
385
|
-
} : {}));
|
|
386
|
-
type NumberFilter<T extends 'Int' | 'Float' | 'Decimal' | 'BigInt', Nullable extends boolean, WithAggregations extends boolean> = NullableIf<number | bigint, Nullable> | (CommonPrimitiveFilter<number, T, Nullable, WithAggregations> & (WithAggregations extends true ? {
|
|
334
|
+
abstract buildSkipTake(query: SelectQueryBuilder<any, any, any>, skip: number | undefined, take: number | undefined): SelectQueryBuilder<any, any, any>;
|
|
387
335
|
/**
|
|
388
|
-
*
|
|
336
|
+
* Builds an Kysely expression that returns a JSON object for the given key-value pairs.
|
|
389
337
|
*/
|
|
390
|
-
|
|
338
|
+
abstract buildJsonObject(value: Record<string, Expression<unknown>>): AliasableExpression<unknown>;
|
|
391
339
|
/**
|
|
392
|
-
*
|
|
340
|
+
* Builds an Kysely expression that returns the length of an array.
|
|
393
341
|
*/
|
|
394
|
-
|
|
342
|
+
abstract buildArrayLength(array: Expression<unknown>): AliasableExpression<number>;
|
|
395
343
|
/**
|
|
396
|
-
*
|
|
344
|
+
* Builds an array value expression.
|
|
397
345
|
*/
|
|
398
|
-
|
|
346
|
+
abstract buildArrayValue(values: Expression<unknown>[], elemType: string): AliasableExpression<unknown>;
|
|
399
347
|
/**
|
|
400
|
-
*
|
|
348
|
+
* Builds an expression that checks if an array contains a single value.
|
|
401
349
|
*/
|
|
402
|
-
|
|
350
|
+
abstract buildArrayContains(field: Expression<unknown>, value: Expression<unknown>, elemType?: string): AliasableExpression<SqlBool>;
|
|
403
351
|
/**
|
|
404
|
-
*
|
|
352
|
+
* Builds an expression that checks if an array contains all values from another array.
|
|
405
353
|
*/
|
|
406
|
-
|
|
407
|
-
} : {}));
|
|
408
|
-
type DateTimeFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Date | string, Nullable> | (CommonPrimitiveFilter<Date | string, 'DateTime', Nullable, WithAggregations> & (WithAggregations extends true ? {
|
|
354
|
+
abstract buildArrayHasEvery(field: Expression<unknown>, values: Expression<unknown>): AliasableExpression<SqlBool>;
|
|
409
355
|
/**
|
|
410
|
-
*
|
|
356
|
+
* Builds an expression that checks if an array overlaps with another array.
|
|
411
357
|
*/
|
|
412
|
-
|
|
358
|
+
abstract buildArrayHasSome(field: Expression<unknown>, values: Expression<unknown>): AliasableExpression<SqlBool>;
|
|
413
359
|
/**
|
|
414
|
-
*
|
|
360
|
+
* Casts the given expression to an integer type.
|
|
415
361
|
*/
|
|
416
|
-
|
|
362
|
+
abstract castInt<T extends Expression<any>>(expression: T): T;
|
|
417
363
|
/**
|
|
418
|
-
*
|
|
364
|
+
* Casts the given expression to a text type.
|
|
419
365
|
*/
|
|
420
|
-
|
|
421
|
-
} : {}));
|
|
422
|
-
type BytesFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Uint8Array | Buffer, Nullable> | ({
|
|
366
|
+
abstract castText<T extends Expression<any>>(expression: T): T;
|
|
423
367
|
/**
|
|
424
|
-
*
|
|
368
|
+
* Trims double quotes from the start and end of a text expression.
|
|
425
369
|
*/
|
|
426
|
-
|
|
370
|
+
abstract trimTextQuotes<T extends Expression<string>>(expression: T): T;
|
|
371
|
+
abstract getStringCasingBehavior(): {
|
|
372
|
+
supportsILike: boolean;
|
|
373
|
+
likeCaseSensitive: boolean;
|
|
374
|
+
};
|
|
427
375
|
/**
|
|
428
|
-
*
|
|
376
|
+
* Builds a VALUES table and select all fields from it.
|
|
429
377
|
*/
|
|
430
|
-
|
|
378
|
+
abstract buildValuesTableSelect(fields: FieldDef[], rows: unknown[][]): SelectQueryBuilder<any, any, any>;
|
|
431
379
|
/**
|
|
432
|
-
*
|
|
380
|
+
* Builds a JSON path selection expression.
|
|
433
381
|
*/
|
|
434
|
-
|
|
382
|
+
protected abstract buildJsonPathSelection(receiver: Expression<any>, path: string | undefined): Expression<any>;
|
|
435
383
|
/**
|
|
436
|
-
* Builds a
|
|
384
|
+
* Builds a JSON array filter expression.
|
|
437
385
|
*/
|
|
438
|
-
|
|
439
|
-
} & (WithAggregations extends true ? {
|
|
386
|
+
protected abstract buildJsonArrayFilter(receiver: Expression<any>, operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown): Expression<SqlBool>;
|
|
440
387
|
/**
|
|
441
|
-
*
|
|
388
|
+
* Builds a JSON array exists predicate (returning if any element matches the filter).
|
|
442
389
|
*/
|
|
443
|
-
|
|
390
|
+
protected abstract buildJsonArrayExistsPredicate(receiver: Expression<any>, buildFilter: (elem: Expression<any>) => Expression<SqlBool>): Expression<SqlBool>;
|
|
444
391
|
/**
|
|
445
|
-
*
|
|
392
|
+
* Builds an ORDER BY clause for a field with NULLS FIRST/LAST support.
|
|
446
393
|
*/
|
|
447
|
-
|
|
394
|
+
protected abstract buildOrderByField(query: SelectQueryBuilder<any, any, any>, field: Expression<unknown>, sort: SortOrder, nulls: 'first' | 'last'): SelectQueryBuilder<any, any, any>;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
type ToKyselySchema<Schema extends SchemaDef> = {
|
|
398
|
+
[Model in GetModels<Schema>]: ToKyselyTable<Schema, Model>;
|
|
399
|
+
};
|
|
400
|
+
type ToKysely<Schema extends SchemaDef> = Kysely<ToKyselySchema<Schema>>;
|
|
401
|
+
type ToKyselyTable<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
402
|
+
[Field in ScalarFields<Schema, Model, false> | ForeignKeyFields<Schema, Model> as GetModelField<Schema, Model, Field>['originModel'] extends string ? never : Field]: toKyselyFieldType<Schema, Model, Field>;
|
|
403
|
+
};
|
|
404
|
+
type MapBaseType<T> = T extends 'String' ? string : T extends 'Boolean' ? boolean : T extends 'Int' | 'Float' ? number : T extends 'BigInt' ? bigint : T extends 'Decimal' ? Decimal : T extends 'DateTime' ? string : unknown;
|
|
405
|
+
type WrapNull<T, Null> = Null extends true ? T | null : T;
|
|
406
|
+
type MapType$1<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = WrapNull<MapBaseType<GetModelFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
407
|
+
type toKyselyFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = FieldHasDefault<Schema, Model, Field> extends true ? Generated<MapType$1<Schema, Model, Field>> : MapType$1<Schema, Model, Field>;
|
|
408
|
+
|
|
409
|
+
declare class InputValidator<Schema extends SchemaDef> {
|
|
410
|
+
private readonly client;
|
|
411
|
+
private readonly schemaCache;
|
|
412
|
+
constructor(client: ClientContract<Schema>);
|
|
413
|
+
private get schema();
|
|
414
|
+
private get options();
|
|
415
|
+
private get extraValidationsEnabled();
|
|
416
|
+
validateFindArgs(model: GetModels<Schema>, args: unknown, operation: CoreCrudOperations): FindArgs<Schema, GetModels<Schema>, any, true> | undefined;
|
|
417
|
+
validateExistsArgs(model: GetModels<Schema>, args: unknown): ExistsArgs<Schema, GetModels<Schema>, any> | undefined;
|
|
418
|
+
validateCreateArgs(model: GetModels<Schema>, args: unknown): CreateArgs<Schema, GetModels<Schema>, any>;
|
|
419
|
+
validateCreateManyArgs(model: GetModels<Schema>, args: unknown): CreateManyArgs<Schema, GetModels<Schema>>;
|
|
420
|
+
validateCreateManyAndReturnArgs(model: GetModels<Schema>, args: unknown): CreateManyAndReturnArgs<Schema, GetModels<Schema>, any> | undefined;
|
|
421
|
+
validateUpdateArgs(model: GetModels<Schema>, args: unknown): UpdateArgs<Schema, GetModels<Schema>, any>;
|
|
422
|
+
validateUpdateManyArgs(model: GetModels<Schema>, args: unknown): UpdateManyArgs<Schema, GetModels<Schema>, any>;
|
|
423
|
+
validateUpdateManyAndReturnArgs(model: GetModels<Schema>, args: unknown): UpdateManyAndReturnArgs<Schema, GetModels<Schema>, any>;
|
|
424
|
+
validateUpsertArgs(model: GetModels<Schema>, args: unknown): UpsertArgs<Schema, GetModels<Schema>, any>;
|
|
425
|
+
validateDeleteArgs(model: GetModels<Schema>, args: unknown): DeleteArgs<Schema, GetModels<Schema>, any>;
|
|
426
|
+
validateDeleteManyArgs(model: GetModels<Schema>, args: unknown): DeleteManyArgs<Schema, GetModels<Schema>, any> | undefined;
|
|
427
|
+
validateCountArgs(model: GetModels<Schema>, args: unknown): CountArgs<Schema, GetModels<Schema>, any> | undefined;
|
|
428
|
+
validateAggregateArgs(model: GetModels<Schema>, args: unknown): AggregateArgs<Schema, GetModels<Schema>, any>;
|
|
429
|
+
validateGroupByArgs(model: GetModels<Schema>, args: unknown): GroupByArgs<Schema, GetModels<Schema>, any>;
|
|
430
|
+
validateProcedureInput(proc: string, input: unknown): unknown;
|
|
431
|
+
private validate;
|
|
432
|
+
private mergePluginArgsSchema;
|
|
433
|
+
private getPluginExtQueryArgsSchema;
|
|
434
|
+
private makeFindSchema;
|
|
435
|
+
private makeExistsSchema;
|
|
436
|
+
private makeScalarSchema;
|
|
437
|
+
private makeEnumSchema;
|
|
438
|
+
private makeTypeDefSchema;
|
|
439
|
+
private makeWhereSchema;
|
|
440
|
+
private makeTypedJsonFilterSchema;
|
|
441
|
+
private isTypeDefType;
|
|
442
|
+
private makeEnumFilterSchema;
|
|
443
|
+
private makeArrayFilterSchema;
|
|
444
|
+
private internalMakeArrayFilterSchema;
|
|
445
|
+
private makePrimitiveFilterSchema;
|
|
446
|
+
private makeJsonValueSchema;
|
|
447
|
+
private makeJsonFilterSchema;
|
|
448
|
+
private makeDateTimeFilterSchema;
|
|
449
|
+
private makeBooleanFilterSchema;
|
|
450
|
+
private makeBytesFilterSchema;
|
|
451
|
+
private makeCommonPrimitiveFilterComponents;
|
|
452
|
+
private makeCommonPrimitiveFilterSchema;
|
|
453
|
+
private makeNumberFilterSchema;
|
|
454
|
+
private makeStringFilterSchema;
|
|
455
|
+
private makeStringModeSchema;
|
|
456
|
+
private makeSelectSchema;
|
|
457
|
+
private makeCountSelectionSchema;
|
|
458
|
+
private makeRelationSelectIncludeSchema;
|
|
459
|
+
private makeOmitSchema;
|
|
460
|
+
private makeIncludeSchema;
|
|
461
|
+
private makeOrderBySchema;
|
|
462
|
+
private makeDistinctSchema;
|
|
463
|
+
private makeCursorSchema;
|
|
464
|
+
private makeCreateSchema;
|
|
465
|
+
private makeCreateManySchema;
|
|
466
|
+
private makeCreateManyAndReturnSchema;
|
|
467
|
+
private makeCreateDataSchema;
|
|
468
|
+
private isDelegateDiscriminator;
|
|
469
|
+
private makeRelationManipulationSchema;
|
|
470
|
+
private makeSetDataSchema;
|
|
471
|
+
private makeConnectDataSchema;
|
|
472
|
+
private makeDisconnectDataSchema;
|
|
473
|
+
private makeDeleteRelationDataSchema;
|
|
474
|
+
private makeConnectOrCreateDataSchema;
|
|
475
|
+
private makeCreateManyDataSchema;
|
|
476
|
+
private makeUpdateSchema;
|
|
477
|
+
private makeUpdateManySchema;
|
|
478
|
+
private makeUpdateManyAndReturnSchema;
|
|
479
|
+
private makeUpsertSchema;
|
|
480
|
+
private makeUpdateDataSchema;
|
|
481
|
+
private makeDeleteSchema;
|
|
482
|
+
private makeDeleteManySchema;
|
|
483
|
+
makeCountSchema(model: string): z.ZodOptional<z.ZodObject<z.core.$ZodLooseShape, z.core.$strict>>;
|
|
484
|
+
private makeCountAggregateInputSchema;
|
|
485
|
+
makeAggregateSchema(model: string): z.ZodOptional<z.ZodObject<z.core.$ZodLooseShape, z.core.$strict>>;
|
|
486
|
+
makeSumAvgInputSchema(model: string): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
487
|
+
makeMinMaxInputSchema(model: string): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
488
|
+
private makeGroupBySchema;
|
|
489
|
+
private onlyAggregationFields;
|
|
490
|
+
private makeHavingSchema;
|
|
491
|
+
private makeProcedureParamSchema;
|
|
492
|
+
getCache(cacheKey: string): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | undefined;
|
|
493
|
+
setCache(cacheKey: string, schema: ZodType): Map<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
494
|
+
private printCacheStats;
|
|
495
|
+
private makeSkipSchema;
|
|
496
|
+
private makeTakeSchema;
|
|
497
|
+
private refineForSelectIncludeMutuallyExclusive;
|
|
498
|
+
private refineForSelectOmitMutuallyExclusive;
|
|
499
|
+
private nullableIf;
|
|
500
|
+
private orArray;
|
|
501
|
+
private isNumericField;
|
|
502
|
+
private get providerSupportsCaseSensitivity();
|
|
448
503
|
/**
|
|
449
|
-
*
|
|
504
|
+
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
505
|
+
* Respects the precedence: field-level > model-level $all > global $all.
|
|
450
506
|
*/
|
|
451
|
-
|
|
452
|
-
} : {}));
|
|
453
|
-
type BooleanFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<boolean, Nullable> | ({
|
|
507
|
+
private getEffectiveFilterKinds;
|
|
454
508
|
/**
|
|
455
|
-
*
|
|
509
|
+
* Computes the effective set of filter kinds based on inclusion and exclusion lists.
|
|
456
510
|
*/
|
|
457
|
-
|
|
511
|
+
private computeFilterKinds;
|
|
458
512
|
/**
|
|
459
|
-
*
|
|
513
|
+
* Filters operators based on allowed filter kinds.
|
|
460
514
|
*/
|
|
461
|
-
|
|
462
|
-
|
|
515
|
+
private trimFilterOperators;
|
|
516
|
+
private createUnionFilterSchema;
|
|
463
517
|
/**
|
|
464
|
-
*
|
|
518
|
+
* Checks if a model is included in the slicing configuration.
|
|
519
|
+
* Returns true if the model is allowed, false if it's excluded.
|
|
465
520
|
*/
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
type
|
|
521
|
+
private isModelAllowed;
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
526
|
+
*/
|
|
527
|
+
declare const CoreCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists"];
|
|
528
|
+
/**
|
|
529
|
+
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
530
|
+
*/
|
|
531
|
+
type CoreCrudOperations = (typeof CoreCrudOperations)[number];
|
|
532
|
+
/**
|
|
533
|
+
* List of core read operations. It excludes the 'orThrow' variants.
|
|
534
|
+
*/
|
|
535
|
+
declare const CoreReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists"];
|
|
536
|
+
/**
|
|
537
|
+
* List of core read operations. It excludes the 'orThrow' variants.
|
|
538
|
+
*/
|
|
539
|
+
type CoreReadOperations = (typeof CoreReadOperations)[number];
|
|
540
|
+
/**
|
|
541
|
+
* List of core write operations.
|
|
542
|
+
*/
|
|
543
|
+
declare const CoreWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
544
|
+
/**
|
|
545
|
+
* List of core write operations.
|
|
546
|
+
*/
|
|
547
|
+
type CoreWriteOperations = (typeof CoreWriteOperations)[number];
|
|
548
|
+
/**
|
|
549
|
+
* List of core create operations.
|
|
550
|
+
*/
|
|
551
|
+
declare const CoreCreateOperations: readonly ["create", "createMany", "createManyAndReturn", "upsert"];
|
|
552
|
+
/**
|
|
553
|
+
* List of core create operations.
|
|
554
|
+
*/
|
|
555
|
+
type CoreCreateOperations = (typeof CoreCreateOperations)[number];
|
|
556
|
+
/**
|
|
557
|
+
* List of core update operations.
|
|
558
|
+
*/
|
|
559
|
+
declare const CoreUpdateOperations: readonly ["update", "updateMany", "updateManyAndReturn", "upsert"];
|
|
560
|
+
/**
|
|
561
|
+
* List of core update operations.
|
|
562
|
+
*/
|
|
563
|
+
type CoreUpdateOperations = (typeof CoreUpdateOperations)[number];
|
|
564
|
+
/**
|
|
565
|
+
* List of core delete operations.
|
|
566
|
+
*/
|
|
567
|
+
declare const CoreDeleteOperations: readonly ["delete", "deleteMany"];
|
|
568
|
+
/**
|
|
569
|
+
* List of core delete operations.
|
|
570
|
+
*/
|
|
571
|
+
type CoreDeleteOperations = (typeof CoreDeleteOperations)[number];
|
|
572
|
+
/**
|
|
573
|
+
* List of all CRUD operations, including 'orThrow' variants.
|
|
574
|
+
*/
|
|
575
|
+
declare const AllCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
576
|
+
/**
|
|
577
|
+
* List of all CRUD operations, including 'orThrow' variants.
|
|
578
|
+
*/
|
|
579
|
+
type AllCrudOperations = (typeof AllCrudOperations)[number];
|
|
580
|
+
/**
|
|
581
|
+
* List of all read operations, including 'orThrow' variants.
|
|
582
|
+
*/
|
|
583
|
+
declare const AllReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
584
|
+
/**
|
|
585
|
+
* List of all read operations, including 'orThrow' variants.
|
|
586
|
+
*/
|
|
587
|
+
type AllReadOperations = (typeof AllReadOperations)[number];
|
|
588
|
+
|
|
589
|
+
type AllowedExtQueryArgKeys = CoreCrudOperations | '$create' | '$read' | '$update' | '$delete' | '$all';
|
|
590
|
+
/**
|
|
591
|
+
* Base shape of plugin-extended query args.
|
|
592
|
+
*/
|
|
593
|
+
type ExtQueryArgsBase = {
|
|
594
|
+
[K in AllowedExtQueryArgKeys]?: object;
|
|
595
|
+
};
|
|
596
|
+
/**
|
|
597
|
+
* Base type for plugin-extended client members (methods and properties).
|
|
598
|
+
* Member names should start with '$' to avoid model name conflicts.
|
|
599
|
+
*/
|
|
600
|
+
type ExtClientMembersBase = Record<string, unknown>;
|
|
601
|
+
/**
|
|
602
|
+
* ZenStack runtime plugin.
|
|
603
|
+
*/
|
|
604
|
+
interface RuntimePlugin<Schema extends SchemaDef, ExtQueryArgs extends ExtQueryArgsBase, ExtClientMembers extends Record<string, unknown>> {
|
|
477
605
|
/**
|
|
478
|
-
*
|
|
606
|
+
* Plugin ID.
|
|
479
607
|
*/
|
|
480
|
-
|
|
608
|
+
id: string;
|
|
481
609
|
/**
|
|
482
|
-
*
|
|
610
|
+
* Plugin display name.
|
|
483
611
|
*/
|
|
484
|
-
|
|
612
|
+
name?: string;
|
|
485
613
|
/**
|
|
486
|
-
*
|
|
614
|
+
* Plugin description.
|
|
487
615
|
*/
|
|
488
|
-
|
|
616
|
+
description?: string;
|
|
489
617
|
/**
|
|
490
|
-
*
|
|
618
|
+
* Custom function implementations.
|
|
619
|
+
* @private
|
|
491
620
|
*/
|
|
492
|
-
|
|
621
|
+
functions?: Record<string, ZModelFunction<Schema>>;
|
|
493
622
|
/**
|
|
494
|
-
*
|
|
623
|
+
* Intercepts an ORM query.
|
|
495
624
|
*/
|
|
496
|
-
|
|
625
|
+
onQuery?: OnQueryCallback<Schema>;
|
|
497
626
|
/**
|
|
498
|
-
*
|
|
627
|
+
* Intercepts a procedure invocation.
|
|
499
628
|
*/
|
|
500
|
-
|
|
629
|
+
onProcedure?: OnProcedureCallback<Schema>;
|
|
501
630
|
/**
|
|
502
|
-
*
|
|
631
|
+
* Intercepts an entity mutation.
|
|
503
632
|
*/
|
|
504
|
-
|
|
633
|
+
onEntityMutation?: EntityMutationHooksDef<Schema>;
|
|
505
634
|
/**
|
|
506
|
-
*
|
|
635
|
+
* Intercepts a Kysely query.
|
|
507
636
|
*/
|
|
508
|
-
|
|
637
|
+
onKyselyQuery?: OnKyselyQueryCallback<Schema>;
|
|
509
638
|
/**
|
|
510
|
-
*
|
|
639
|
+
* Extended query args configuration.
|
|
511
640
|
*/
|
|
512
|
-
|
|
641
|
+
queryArgs?: {
|
|
642
|
+
[K in keyof ExtQueryArgs]: ZodType<ExtQueryArgs[K]>;
|
|
643
|
+
};
|
|
513
644
|
/**
|
|
514
|
-
*
|
|
645
|
+
* Extended client members (methods and properties).
|
|
515
646
|
*/
|
|
516
|
-
|
|
517
|
-
}
|
|
518
|
-
type
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
type NonArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
|
|
526
|
-
is?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
527
|
-
isNot?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
528
|
-
} | TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
529
|
-
type TypedJsonFieldsFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
|
|
530
|
-
[Key in GetTypeDefFields<Schema, TypeDefName>]?: GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsArray<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>> : TypeDefFieldIsArray<Schema, TypeDefName, Key> extends true ? ArrayFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>> : GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false> : PrimitiveFilter<GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false>;
|
|
531
|
-
};
|
|
532
|
-
type SortOrder = 'asc' | 'desc';
|
|
533
|
-
type NullsOrder = 'first' | 'last';
|
|
534
|
-
type OrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>, WithRelation extends boolean, WithAggregation extends boolean> = {
|
|
535
|
-
[Key in NonRelationFields<Schema, Model>]?: ModelFieldIsOptional<Schema, Model, Key> extends true ? SortOrder | {
|
|
536
|
-
/**
|
|
537
|
-
* Sort order
|
|
538
|
-
*/
|
|
539
|
-
sort: SortOrder;
|
|
540
|
-
/**
|
|
541
|
-
* Treatment of null values
|
|
542
|
-
*/
|
|
543
|
-
nulls?: NullsOrder;
|
|
544
|
-
} : SortOrder;
|
|
545
|
-
} & (WithRelation extends true ? {
|
|
546
|
-
[Key in RelationFields<Schema, Model>]?: FieldIsArray<Schema, Model, Key> extends true ? {
|
|
547
|
-
/**
|
|
548
|
-
* Sorts by the count of related records.
|
|
549
|
-
*/
|
|
550
|
-
_count?: SortOrder;
|
|
551
|
-
} : OrderBy<Schema, RelationFieldType<Schema, Model, Key>, WithRelation, WithAggregation>;
|
|
552
|
-
} : {}) & (WithAggregation extends true ? {
|
|
647
|
+
client?: ExtClientMembers;
|
|
648
|
+
}
|
|
649
|
+
type AnyPlugin = RuntimePlugin<any, any, any>;
|
|
650
|
+
/**
|
|
651
|
+
* Defines a ZenStack runtime plugin.
|
|
652
|
+
*/
|
|
653
|
+
declare function definePlugin<Schema extends SchemaDef, const ExtQueryArgs extends ExtQueryArgsBase = {}, const ExtClientMembers extends Record<string, unknown> = {}>(plugin: RuntimePlugin<Schema, ExtQueryArgs, ExtClientMembers>): RuntimePlugin<any, ExtQueryArgs, ExtClientMembers>;
|
|
654
|
+
type OnProcedureCallback<Schema extends SchemaDef> = (ctx: OnProcedureHookContext<Schema>) => Promise<unknown>;
|
|
655
|
+
type OnProcedureHookContext<Schema extends SchemaDef> = {
|
|
553
656
|
/**
|
|
554
|
-
*
|
|
657
|
+
* The procedure name.
|
|
555
658
|
*/
|
|
556
|
-
|
|
659
|
+
name: string;
|
|
557
660
|
/**
|
|
558
|
-
*
|
|
661
|
+
* Whether the procedure is a mutation.
|
|
559
662
|
*/
|
|
560
|
-
|
|
663
|
+
mutation: boolean;
|
|
561
664
|
/**
|
|
562
|
-
*
|
|
665
|
+
* Procedure invocation input (envelope).
|
|
666
|
+
*
|
|
667
|
+
* The canonical shape is `{ args?: Record<string, unknown> }`.
|
|
668
|
+
* When a procedure has required params, `args` is required.
|
|
563
669
|
*/
|
|
564
|
-
|
|
565
|
-
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
670
|
+
input: unknown;
|
|
566
671
|
/**
|
|
567
|
-
*
|
|
672
|
+
* Continues the invocation. The input passed here is forwarded to the next handler.
|
|
568
673
|
*/
|
|
569
|
-
|
|
674
|
+
proceed: (input: unknown) => Promise<unknown>;
|
|
570
675
|
/**
|
|
571
|
-
*
|
|
676
|
+
* The ZenStack client that is invoking the procedure.
|
|
572
677
|
*/
|
|
573
|
-
|
|
574
|
-
}) : {});
|
|
575
|
-
type WhereUniqueInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = AtLeast<{
|
|
576
|
-
[Key in keyof GetModel<Schema, Model>['uniqueFields']]?: GetModel<Schema, Model>['uniqueFields'][Key] extends Pick<FieldDef, 'type'> ? MapFieldDefType<Schema, GetModel<Schema, Model>['uniqueFields'][Key]> : {
|
|
577
|
-
[Key1 in keyof GetModel<Schema, Model>['uniqueFields'][Key]]: GetModel<Schema, Model>['uniqueFields'][Key][Key1] extends Pick<FieldDef, 'type'> ? MapFieldDefType<Schema, GetModel<Schema, Model>['uniqueFields'][Key][Key1]> : never;
|
|
578
|
-
};
|
|
579
|
-
} & WhereInput<Schema, Model>, Extract<keyof GetModel<Schema, Model>['uniqueFields'], string>>;
|
|
580
|
-
type OmitInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
581
|
-
[Key in NonRelationFields<Schema, Model>]?: boolean;
|
|
678
|
+
client: ClientContract<Schema>;
|
|
582
679
|
};
|
|
583
|
-
type
|
|
584
|
-
|
|
585
|
-
* Explicitly select fields and relations to be returned by the query.
|
|
586
|
-
*/
|
|
587
|
-
select?: SelectInput<Schema, Model, AllowCount, AllowRelation> | null;
|
|
680
|
+
type OnQueryCallback<Schema extends SchemaDef> = (ctx: OnQueryHookContext<Schema>) => Promise<unknown>;
|
|
681
|
+
type OnQueryHookContext<Schema extends SchemaDef> = {
|
|
588
682
|
/**
|
|
589
|
-
*
|
|
683
|
+
* The model that is being queried.
|
|
590
684
|
*/
|
|
591
|
-
|
|
685
|
+
model: GetModels<Schema>;
|
|
592
686
|
/**
|
|
593
|
-
*
|
|
687
|
+
* The operation that is being performed.
|
|
594
688
|
*/
|
|
595
|
-
|
|
596
|
-
};
|
|
597
|
-
type SelectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean = true, AllowRelation extends boolean = true> = {
|
|
598
|
-
[Key in NonRelationFields<Schema, Model>]?: boolean;
|
|
599
|
-
} & (AllowRelation extends true ? IncludeInput<Schema, Model, AllowCount> : {});
|
|
600
|
-
type SelectCount<Schema extends SchemaDef, Model extends GetModels<Schema>> = boolean | {
|
|
689
|
+
operation: AllCrudOperations;
|
|
601
690
|
/**
|
|
602
|
-
*
|
|
691
|
+
* The query arguments.
|
|
603
692
|
*/
|
|
604
|
-
|
|
605
|
-
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]?: boolean | {
|
|
606
|
-
where: WhereInput<Schema, RelationFieldType<Schema, Model, Key>, false>;
|
|
607
|
-
};
|
|
608
|
-
};
|
|
609
|
-
};
|
|
610
|
-
type IncludeInput<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean = true> = {
|
|
611
|
-
[Key in RelationFields<Schema, Model>]?: boolean | FindArgs<Schema, RelationFieldType<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>, FieldIsArray<Schema, Model, Key> extends true ? true : ModelFieldIsOptional<Schema, Model, Key> extends true ? true : false>;
|
|
612
|
-
} & (AllowCount extends true ? HasToManyRelations<Schema, Model> extends true ? {
|
|
613
|
-
_count?: SelectCount<Schema, Model>;
|
|
614
|
-
} : {} : {});
|
|
615
|
-
type Subset<T, U> = {
|
|
616
|
-
[key in keyof T]: key extends keyof U ? T[key] : never;
|
|
617
|
-
};
|
|
618
|
-
type SelectSubset<T, U> = {
|
|
619
|
-
[key in keyof T]: key extends keyof U ? T[key] : never;
|
|
620
|
-
} & (T extends {
|
|
621
|
-
select: any;
|
|
622
|
-
include: any;
|
|
623
|
-
} ? 'Please either choose `select` or `include`.' : T extends {
|
|
624
|
-
select: any;
|
|
625
|
-
omit: any;
|
|
626
|
-
} ? 'Please either choose `select` or `omit`.' : {});
|
|
627
|
-
type ToManyRelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = {
|
|
628
|
-
every?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
629
|
-
some?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
630
|
-
none?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
631
|
-
};
|
|
632
|
-
type ToOneRelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>> & {
|
|
693
|
+
args: Record<string, unknown> | undefined;
|
|
633
694
|
/**
|
|
634
|
-
*
|
|
695
|
+
* The function to proceed with the original query.
|
|
696
|
+
* It takes the same arguments as the operation method.
|
|
697
|
+
*
|
|
698
|
+
* @param args The query arguments.
|
|
635
699
|
*/
|
|
636
|
-
|
|
700
|
+
proceed: (args: Record<string, unknown> | undefined) => Promise<unknown>;
|
|
637
701
|
/**
|
|
638
|
-
*
|
|
702
|
+
* The ZenStack client that is performing the operation.
|
|
639
703
|
*/
|
|
640
|
-
|
|
641
|
-
}, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
642
|
-
type RelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? ToManyRelationFilter<Schema, Model, Field> : ToOneRelationFilter<Schema, Model, Field>;
|
|
643
|
-
type MapModelFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = MapFieldDefType<Schema, GetModelField<Schema, Model, Field>>;
|
|
644
|
-
type MapFieldDefType<Schema extends SchemaDef, T extends Pick<FieldDef, 'type' | 'optional' | 'array'>, Partial extends boolean = false> = WrapType<T['type'] extends GetEnums<Schema> ? keyof GetEnum<Schema, T['type']> : T['type'] extends GetTypeDefs<Schema> ? TypeDefResult<Schema, T['type'], Partial> & Record<string, unknown> : MapBaseType$1<T['type']>, T['optional'], T['array']>;
|
|
645
|
-
type OptionalFieldsForCreate<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
646
|
-
[Key in GetModelFields<Schema, Model> as ModelFieldIsOptional<Schema, Model, Key> extends true ? Key : FieldHasDefault<Schema, Model, Key> extends true ? Key : FieldIsArray<Schema, Model, Key> extends true ? Key : GetModelField<Schema, Model, Key>['updatedAt'] extends (true | UpdatedAtInfo) ? Key : never]: GetModelField<Schema, Model, Key>;
|
|
704
|
+
client: ClientContract<Schema>;
|
|
647
705
|
};
|
|
648
|
-
type
|
|
649
|
-
type OppositeRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>> = FT extends GetModels<Schema> ? GetRelation<Schema, Model, Field> extends RelationInfo ? GetRelation<Schema, Model, Field>['opposite'] extends GetModelFields<Schema, FT> ? Schema['models'][FT]['fields'][GetRelation<Schema, Model, Field>['opposite']]['relation'] : never : never : never;
|
|
650
|
-
type OppositeRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Opposite = OppositeRelation<Schema, Model, Field>> = Opposite extends RelationInfo ? (Opposite['fields'] extends readonly string[] ? Opposite['fields'] : []) : [];
|
|
651
|
-
type OppositeRelationAndFK<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>, Relation = GetModelField<Schema, Model, Field>['relation'], Opposite = Relation extends RelationInfo ? Relation['opposite'] : never> = FT extends GetModels<Schema> ? Opposite extends GetModelFields<Schema, FT> ? Opposite | OppositeRelationFields<Schema, Model, Field>[number] : never : never;
|
|
652
|
-
type FilterArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
706
|
+
type EntityMutationHooksDef<Schema extends SchemaDef> = {
|
|
653
707
|
/**
|
|
654
|
-
*
|
|
708
|
+
* Called before entities are mutated.
|
|
655
709
|
*/
|
|
656
|
-
|
|
657
|
-
};
|
|
658
|
-
type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
710
|
+
beforeEntityMutation?: BeforeEntityMutationCallback<Schema>;
|
|
659
711
|
/**
|
|
660
|
-
*
|
|
712
|
+
* Called after entities are mutated.
|
|
661
713
|
*/
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* Number of records to take
|
|
665
|
-
*/
|
|
666
|
-
take?: number;
|
|
667
|
-
/**
|
|
668
|
-
* Order by clauses
|
|
669
|
-
*/
|
|
670
|
-
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
714
|
+
afterEntityMutation?: AfterEntityMutationCallback<Schema>;
|
|
671
715
|
/**
|
|
672
|
-
*
|
|
716
|
+
* Whether to run after-mutation hooks within the transaction that performs the mutation.
|
|
717
|
+
*
|
|
718
|
+
* If set to `true`, if the mutation already runs inside a transaction, the callbacks are
|
|
719
|
+
* executed immediately after the mutation within the transaction boundary. If the mutation
|
|
720
|
+
* is not running inside a transaction, a new transaction is created to run both the mutation
|
|
721
|
+
* and the callbacks.
|
|
722
|
+
*
|
|
723
|
+
* If set to `false`, the callbacks are executed after the mutation transaction is committed.
|
|
724
|
+
*
|
|
725
|
+
* Defaults to `false`.
|
|
673
726
|
*/
|
|
674
|
-
|
|
727
|
+
runAfterMutationWithinTransaction?: boolean;
|
|
675
728
|
};
|
|
676
|
-
type
|
|
677
|
-
/**
|
|
678
|
-
* Distinct fields. Only supported by providers that natively support SQL "DISTINCT ON".
|
|
679
|
-
*/
|
|
680
|
-
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
681
|
-
} : {}) : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection>;
|
|
682
|
-
type FindManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
|
|
683
|
-
type FindFirstArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
|
|
684
|
-
type ExistsArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FilterArgs<Schema, Model>;
|
|
685
|
-
type FindUniqueArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
686
|
-
where: WhereUniqueInput<Schema, Model>;
|
|
687
|
-
} & SelectIncludeOmit<Schema, Model, true>;
|
|
688
|
-
type CreateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
689
|
-
data: CreateInput<Schema, Model>;
|
|
690
|
-
} & SelectIncludeOmit<Schema, Model, true>;
|
|
691
|
-
type CreateManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = CreateManyInput<Schema, Model>;
|
|
692
|
-
type CreateManyAndReturnArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = CreateManyInput<Schema, Model> & Omit<SelectIncludeOmit<Schema, Model, false, false>, 'include'>;
|
|
693
|
-
type OptionalWrap<Schema extends SchemaDef, Model extends GetModels<Schema>, T extends object> = Optional<T, keyof T & OptionalFieldsForCreate<Schema, Model>>;
|
|
694
|
-
type CreateScalarPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
695
|
-
[Key in ScalarFields<Schema, Model, false> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]: ScalarCreatePayload<Schema, Model, Key>;
|
|
696
|
-
}>;
|
|
697
|
-
type ScalarCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends ScalarFields<Schema, Model, false>> = ScalarFieldMutationPayload<Schema, Model, Field> | (FieldIsArray<Schema, Model, Field> extends true ? {
|
|
698
|
-
set?: MapModelFieldType<Schema, Model, Field>;
|
|
699
|
-
} : never);
|
|
700
|
-
type ScalarFieldMutationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = IsJsonField<Schema, Model, Field> extends true ? ModelFieldIsOptional<Schema, Model, Field> extends true ? JsonValue | JsonNull | DbNull : JsonValue | JsonNull : MapModelFieldType<Schema, Model, Field>;
|
|
701
|
-
type IsJsonField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelFieldType<Schema, Model, Field> extends 'Json' ? true : false;
|
|
702
|
-
type CreateFKPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
703
|
-
[Key in ForeignKeyFields<Schema, Model>]: MapModelFieldType<Schema, Model, Key>;
|
|
704
|
-
}>;
|
|
705
|
-
type CreateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
|
|
706
|
-
/**
|
|
707
|
-
* Connects or create a related record.
|
|
708
|
-
*/
|
|
709
|
-
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
|
|
710
|
-
/**
|
|
711
|
-
* Creates a related record.
|
|
712
|
-
*/
|
|
713
|
-
create?: NestedCreateInput<Schema, Model, Field>;
|
|
729
|
+
type MutationHooksArgs<Schema extends SchemaDef> = {
|
|
714
730
|
/**
|
|
715
|
-
*
|
|
731
|
+
* The model that is being mutated.
|
|
716
732
|
*/
|
|
717
|
-
|
|
733
|
+
model: GetModels<Schema>;
|
|
718
734
|
/**
|
|
719
|
-
*
|
|
735
|
+
* The mutation action that is being performed.
|
|
720
736
|
*/
|
|
721
|
-
|
|
722
|
-
}, (FieldIsArray<Schema, Model, Field> extends true ? never : 'createMany') | (FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' : never)>;
|
|
723
|
-
type CreateRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
724
|
-
[Key in RelationFields<Schema, Model>]: CreateRelationFieldPayload<Schema, Model, Key>;
|
|
725
|
-
}>;
|
|
726
|
-
type CreateWithFKInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = CreateScalarPayload<Schema, Model> & CreateFKPayload<Schema, Model> & CreateWithNonOwnedRelationPayload<Schema, Model>;
|
|
727
|
-
type CreateWithRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = CreateScalarPayload<Schema, Model> & CreateRelationPayload<Schema, Model>;
|
|
728
|
-
type CreateWithNonOwnedRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
729
|
-
[Key in NonOwnedRelationFields<Schema, Model>]: CreateRelationFieldPayload<Schema, Model, Key>;
|
|
730
|
-
}>;
|
|
731
|
-
type ConnectOrCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
|
|
737
|
+
action: 'create' | 'update' | 'delete';
|
|
732
738
|
/**
|
|
733
|
-
* The
|
|
739
|
+
* The mutation data. Only available for create and update actions.
|
|
734
740
|
*/
|
|
735
|
-
|
|
741
|
+
queryNode: OperationNode;
|
|
736
742
|
/**
|
|
737
|
-
*
|
|
743
|
+
* A query ID that uniquely identifies the mutation operation. You can use it to correlate
|
|
744
|
+
* data between the before and after mutation hooks.
|
|
738
745
|
*/
|
|
739
|
-
|
|
746
|
+
queryId: QueryId;
|
|
740
747
|
};
|
|
741
|
-
type
|
|
748
|
+
type BeforeEntityMutationCallback<Schema extends SchemaDef> = (args: PluginBeforeEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
749
|
+
type AfterEntityMutationCallback<Schema extends SchemaDef> = (args: PluginAfterEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
750
|
+
type PluginBeforeEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
742
751
|
/**
|
|
743
|
-
* The
|
|
752
|
+
* Loads the entities that are about to be mutated. The db operation that loads the entities is executed
|
|
753
|
+
* within the same transaction context as the mutation.
|
|
744
754
|
*/
|
|
745
|
-
|
|
755
|
+
loadBeforeMutationEntities(): Promise<Record<string, unknown>[] | undefined>;
|
|
746
756
|
/**
|
|
747
|
-
*
|
|
757
|
+
* The ZenStack client you can use to perform additional operations. The database operations initiated
|
|
758
|
+
* from this client are executed within the same transaction as the mutation if the mutation is running
|
|
759
|
+
* inside a transaction.
|
|
760
|
+
*
|
|
761
|
+
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
748
762
|
*/
|
|
749
|
-
|
|
763
|
+
client: ClientContract<Schema>;
|
|
750
764
|
};
|
|
751
|
-
type
|
|
752
|
-
type NestedCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<CreateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>, FieldIsArray<Schema, Model, Field>>;
|
|
753
|
-
type NestedCreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = CreateManyInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
754
|
-
type UpdateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
755
|
-
/**
|
|
756
|
-
* The data to update the record with.
|
|
757
|
-
*/
|
|
758
|
-
data: UpdateInput<Schema, Model>;
|
|
759
|
-
/**
|
|
760
|
-
* The unique filter to find the record to update.
|
|
761
|
-
*/
|
|
762
|
-
where: WhereUniqueInput<Schema, Model>;
|
|
763
|
-
} & SelectIncludeOmit<Schema, Model, true>;
|
|
764
|
-
type UpdateManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = UpdateManyPayload<Schema, Model>;
|
|
765
|
-
type UpdateManyAndReturnArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = UpdateManyPayload<Schema, Model> & Omit<SelectIncludeOmit<Schema, Model, false, false>, 'include'>;
|
|
766
|
-
type UpdateManyPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
|
|
765
|
+
type PluginAfterEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
767
766
|
/**
|
|
768
|
-
*
|
|
767
|
+
* Loads the entities that have been mutated.
|
|
769
768
|
*/
|
|
770
|
-
|
|
769
|
+
loadAfterMutationEntities(): Promise<Record<string, unknown>[] | undefined>;
|
|
771
770
|
/**
|
|
772
|
-
* The
|
|
771
|
+
* The entities before mutation. Only available if `beforeEntityMutation` hook is provided and
|
|
772
|
+
* the `loadBeforeMutationEntities` function is called in that hook.
|
|
773
773
|
*/
|
|
774
|
-
|
|
774
|
+
beforeMutationEntities?: Record<string, unknown>[];
|
|
775
775
|
/**
|
|
776
|
-
*
|
|
776
|
+
* The ZenStack client you can use to perform additional operations.
|
|
777
|
+
* See {@link EntityMutationHooksDef.runAfterMutationWithinTransaction} for detailed transaction behavior.
|
|
778
|
+
*
|
|
779
|
+
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
777
780
|
*/
|
|
778
|
-
|
|
781
|
+
client: ClientContract<Schema>;
|
|
779
782
|
};
|
|
780
|
-
type
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
* The unique filter to find the record to update.
|
|
791
|
-
*/
|
|
792
|
-
where: WhereUniqueInput<Schema, Model>;
|
|
793
|
-
} & SelectIncludeOmit<Schema, Model, true>;
|
|
794
|
-
type UpdateScalarInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{
|
|
795
|
-
[Key in NonRelationFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]?: ScalarUpdatePayload<Schema, Model, Key>;
|
|
796
|
-
}, Without>;
|
|
797
|
-
type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> = ScalarFieldMutationPayload<Schema, Model, Field> | (Field extends NumericFields<Schema, Model> ? {
|
|
798
|
-
/**
|
|
799
|
-
* Sets the field to the specified value.
|
|
800
|
-
*/
|
|
801
|
-
set?: NullableIf<number, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
802
|
-
/**
|
|
803
|
-
* Increments the field by the specified value.
|
|
804
|
-
*/
|
|
805
|
-
increment?: number;
|
|
783
|
+
type OnKyselyQueryArgs<Schema extends SchemaDef> = {
|
|
784
|
+
schema: SchemaDef;
|
|
785
|
+
client: ClientContract<Schema>;
|
|
786
|
+
query: RootOperationNode;
|
|
787
|
+
proceed: ProceedKyselyQueryFunction;
|
|
788
|
+
};
|
|
789
|
+
type ProceedKyselyQueryFunction = (query: RootOperationNode) => Promise<QueryResult<any>>;
|
|
790
|
+
type OnKyselyQueryCallback<Schema extends SchemaDef> = (args: OnKyselyQueryArgs<Schema>) => Promise<QueryResult<UnknownRow>>;
|
|
791
|
+
|
|
792
|
+
type ZModelFunctionContext<Schema extends SchemaDef> = {
|
|
806
793
|
/**
|
|
807
|
-
*
|
|
794
|
+
* ZenStack client instance
|
|
808
795
|
*/
|
|
809
|
-
|
|
796
|
+
client: ClientContract<Schema>;
|
|
810
797
|
/**
|
|
811
|
-
*
|
|
798
|
+
* Database dialect
|
|
812
799
|
*/
|
|
813
|
-
|
|
800
|
+
dialect: BaseCrudDialect<Schema>;
|
|
814
801
|
/**
|
|
815
|
-
*
|
|
802
|
+
* The containing model name
|
|
816
803
|
*/
|
|
817
|
-
|
|
818
|
-
} : never) | (FieldIsArray<Schema, Model, Field> extends true ? {
|
|
804
|
+
model: GetModels<Schema>;
|
|
819
805
|
/**
|
|
820
|
-
*
|
|
806
|
+
* The alias name that can be used to refer to the containing model
|
|
821
807
|
*/
|
|
822
|
-
|
|
808
|
+
modelAlias: string;
|
|
823
809
|
/**
|
|
824
|
-
*
|
|
810
|
+
* The CRUD operation being performed
|
|
825
811
|
*/
|
|
826
|
-
|
|
827
|
-
}
|
|
828
|
-
type
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
type
|
|
812
|
+
operation: CRUD_EXT;
|
|
813
|
+
};
|
|
814
|
+
type ZModelFunction<Schema extends SchemaDef> = (eb: ExpressionBuilder<ToKyselySchema<Schema>, keyof ToKyselySchema<Schema>>, args: Expression<any>[], context: ZModelFunctionContext<Schema>) => Expression<unknown>;
|
|
815
|
+
/**
|
|
816
|
+
* Options for slicing ORM client's capabilities by including/excluding certain models, operations,
|
|
817
|
+
* filters, etc.
|
|
818
|
+
*/
|
|
819
|
+
type SlicingOptions<Schema extends SchemaDef> = {
|
|
834
820
|
/**
|
|
835
|
-
*
|
|
821
|
+
* Models to include in the client. If not specified, all models are included by default.
|
|
836
822
|
*/
|
|
837
|
-
|
|
823
|
+
includedModels?: readonly GetModels<Schema>[];
|
|
838
824
|
/**
|
|
839
|
-
*
|
|
825
|
+
* Models to exclude from the client. Exclusion takes precedence over inclusion.
|
|
840
826
|
*/
|
|
841
|
-
|
|
827
|
+
excludedModels?: readonly GetModels<Schema>[];
|
|
842
828
|
/**
|
|
843
|
-
*
|
|
829
|
+
* Model slicing options.
|
|
844
830
|
*/
|
|
845
|
-
|
|
831
|
+
models?: {
|
|
832
|
+
[Model in GetModels<Schema>]?: ModelSlicingOptions<Schema, Model>;
|
|
833
|
+
} & {
|
|
834
|
+
/**
|
|
835
|
+
* Slicing options that apply to all models. Model-specific options will override these general
|
|
836
|
+
* options if both are specified.
|
|
837
|
+
*/
|
|
838
|
+
$all?: ModelSlicingOptions<Schema, GetModels<Schema>>;
|
|
839
|
+
};
|
|
846
840
|
/**
|
|
847
|
-
*
|
|
841
|
+
* Procedures to include in the client. If not specified, all procedures are included by default.
|
|
848
842
|
*/
|
|
849
|
-
|
|
843
|
+
includedProcedures?: readonly GetProcedureNames<Schema>[];
|
|
850
844
|
/**
|
|
851
|
-
*
|
|
845
|
+
* Procedures to exclude from the client. Exclusion takes precedence over inclusion.
|
|
852
846
|
*/
|
|
853
|
-
|
|
847
|
+
excludedProcedures?: readonly GetProcedureNames<Schema>[];
|
|
848
|
+
};
|
|
849
|
+
/**
|
|
850
|
+
* Kinds of filter operations.
|
|
851
|
+
*/
|
|
852
|
+
type FilterKind = FilterPropertyToKind[keyof FilterPropertyToKind];
|
|
853
|
+
/**
|
|
854
|
+
* Model slicing options.
|
|
855
|
+
*/
|
|
856
|
+
type ModelSlicingOptions<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
854
857
|
/**
|
|
855
|
-
*
|
|
858
|
+
* ORM query operations to include for the model. If not specified, all operations are included
|
|
859
|
+
* by default.
|
|
856
860
|
*/
|
|
857
|
-
|
|
861
|
+
includedOperations?: readonly AllCrudOperations[];
|
|
858
862
|
/**
|
|
859
|
-
*
|
|
863
|
+
* ORM query operations to exclude for the model. Exclusion takes precedence over inclusion.
|
|
860
864
|
*/
|
|
861
|
-
|
|
865
|
+
excludedOperations?: readonly AllCrudOperations[];
|
|
862
866
|
/**
|
|
863
|
-
*
|
|
867
|
+
* Field-level slicing options.
|
|
864
868
|
*/
|
|
865
|
-
|
|
869
|
+
fields?: {
|
|
870
|
+
[Field in GetModelFields<Schema, Model>]?: FieldSlicingOptions;
|
|
871
|
+
} & {
|
|
872
|
+
/**
|
|
873
|
+
* Field slicing options that apply to all fields. Field-specific options will override these
|
|
874
|
+
* general options if both are specified.
|
|
875
|
+
*/
|
|
876
|
+
$all?: FieldSlicingOptions;
|
|
877
|
+
};
|
|
878
|
+
};
|
|
879
|
+
/**
|
|
880
|
+
* Field slicing options.
|
|
881
|
+
*/
|
|
882
|
+
type FieldSlicingOptions = {
|
|
866
883
|
/**
|
|
867
|
-
*
|
|
884
|
+
* Filter kinds to include for the field. If not specified, all filter kinds are included by default.
|
|
868
885
|
*/
|
|
869
|
-
|
|
886
|
+
includedFilterKinds?: readonly FilterKind[];
|
|
870
887
|
/**
|
|
871
|
-
*
|
|
888
|
+
* Filter kinds to exclude for the field. Exclusion takes precedence over inclusion.
|
|
872
889
|
*/
|
|
873
|
-
|
|
890
|
+
excludedFilterKinds?: readonly FilterKind[];
|
|
891
|
+
};
|
|
892
|
+
/**
|
|
893
|
+
* Partial ORM client options that defines customizable behaviors.
|
|
894
|
+
*/
|
|
895
|
+
type QueryOptions<Schema extends SchemaDef> = {
|
|
874
896
|
/**
|
|
875
|
-
*
|
|
897
|
+
* Options for omitting fields in ORM query results.
|
|
876
898
|
*/
|
|
877
|
-
|
|
878
|
-
}, FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' | 'upsert' : never>;
|
|
879
|
-
type ToOneRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
|
|
899
|
+
omit?: OmitConfig<Schema>;
|
|
880
900
|
/**
|
|
881
|
-
*
|
|
901
|
+
* Whether to allow overriding omit settings at query time. Defaults to `true`. When set to `false`, a
|
|
902
|
+
* query-time `omit` clause that sets the field to `false` (not omitting) will trigger a validation error.
|
|
882
903
|
*/
|
|
883
|
-
|
|
904
|
+
allowQueryTimeOmitOverride?: boolean;
|
|
884
905
|
/**
|
|
885
|
-
*
|
|
906
|
+
* Options for slicing ORM client's capabilities by including/excluding certain models, operations, filters, etc.
|
|
886
907
|
*/
|
|
887
|
-
|
|
908
|
+
slicing?: SlicingOptions<Schema>;
|
|
909
|
+
};
|
|
910
|
+
/**
|
|
911
|
+
* ZenStack client options.
|
|
912
|
+
*/
|
|
913
|
+
type ClientOptions<Schema extends SchemaDef> = QueryOptions<Schema> & {
|
|
888
914
|
/**
|
|
889
|
-
*
|
|
915
|
+
* Kysely dialect.
|
|
890
916
|
*/
|
|
891
|
-
|
|
917
|
+
dialect: Dialect;
|
|
892
918
|
/**
|
|
893
|
-
*
|
|
919
|
+
* Custom function definitions.
|
|
920
|
+
*
|
|
921
|
+
* @private
|
|
894
922
|
*/
|
|
895
|
-
|
|
923
|
+
functions?: Record<string, ZModelFunction<Schema>>;
|
|
896
924
|
/**
|
|
897
|
-
*
|
|
925
|
+
* Plugins.
|
|
898
926
|
*/
|
|
899
|
-
|
|
900
|
-
} & (ModelFieldIsOptional<Schema, Model, Field> extends true ? {
|
|
927
|
+
plugins?: AnyPlugin[];
|
|
901
928
|
/**
|
|
902
|
-
*
|
|
929
|
+
* Logging configuration.
|
|
903
930
|
*/
|
|
904
|
-
|
|
931
|
+
log?: KyselyConfig['log'];
|
|
905
932
|
/**
|
|
906
|
-
*
|
|
933
|
+
* Whether to automatically fix timezone for `DateTime` fields returned by node-pg. Defaults
|
|
934
|
+
* to `true`.
|
|
935
|
+
*
|
|
936
|
+
* Node-pg has a terrible quirk that it interprets the date value as local timezone (as a
|
|
937
|
+
* `Date` object) although for `DateTime` field the data in DB is stored in UTC.
|
|
938
|
+
* @see https://github.com/brianc/node-postgres/issues/429
|
|
907
939
|
*/
|
|
908
|
-
|
|
909
|
-
} : {}), FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'connectOrCreate' | 'upsert' : never>;
|
|
910
|
-
type DeleteArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
940
|
+
fixPostgresTimezone?: boolean;
|
|
911
941
|
/**
|
|
912
|
-
*
|
|
942
|
+
* Whether to enable input validations expressed with attributes like `@email`, `@regex`,
|
|
943
|
+
* `@@validate`, etc. Defaults to `true`.
|
|
913
944
|
*/
|
|
914
|
-
|
|
915
|
-
} &
|
|
916
|
-
type DeleteManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
945
|
+
validateInput?: boolean;
|
|
946
|
+
} & (HasComputedFields<Schema> extends true ? {
|
|
917
947
|
/**
|
|
918
|
-
*
|
|
948
|
+
* Computed field definitions.
|
|
919
949
|
*/
|
|
920
|
-
|
|
950
|
+
computedFields: ComputedFieldsOptions<Schema>;
|
|
951
|
+
} : {}) & (HasProcedures<Schema> extends true ? {
|
|
921
952
|
/**
|
|
922
|
-
*
|
|
953
|
+
* Custom procedure definitions.
|
|
923
954
|
*/
|
|
924
|
-
|
|
955
|
+
procedures: ProceduresOptions<Schema>;
|
|
956
|
+
} : {});
|
|
957
|
+
/**
|
|
958
|
+
* Config for omitting fields in ORM query results.
|
|
959
|
+
*/
|
|
960
|
+
type OmitConfig<Schema extends SchemaDef> = {
|
|
961
|
+
[Model in GetModels<Schema>]?: {
|
|
962
|
+
[Field in GetModelFields<Schema, Model> as Field extends ScalarFields<Schema, Model> ? Field : never]?: boolean;
|
|
963
|
+
};
|
|
925
964
|
};
|
|
926
|
-
type
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
select?: CountAggregateInput<Schema, Model> | true;
|
|
965
|
+
type ComputedFieldsOptions<Schema extends SchemaDef> = {
|
|
966
|
+
[Model in GetModels<Schema> as 'computedFields' extends keyof GetModel<Schema, Model> ? Model : never]: {
|
|
967
|
+
[Field in keyof Schema['models'][Model]['computedFields']]: PrependParameter<ExpressionBuilder<ToKyselySchema<Schema>, Model>, Schema['models'][Model]['computedFields'][Field]>;
|
|
968
|
+
};
|
|
931
969
|
};
|
|
932
|
-
type
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
970
|
+
type HasComputedFields<Schema extends SchemaDef> = string extends GetModels<Schema> ? false : keyof ComputedFieldsOptions<Schema> extends never ? false : true;
|
|
971
|
+
type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
|
|
972
|
+
procedures: Record<string, ProcedureDef>;
|
|
973
|
+
} ? {
|
|
974
|
+
[Key in GetProcedureNames<Schema>]: ProcedureHandlerFunc<Schema, Key>;
|
|
975
|
+
} : {};
|
|
976
|
+
type HasProcedures<Schema extends SchemaDef> = Schema extends {
|
|
977
|
+
procedures: Record<string, ProcedureDef>;
|
|
978
|
+
} ? true : false;
|
|
979
|
+
/**
|
|
980
|
+
* Extracts QueryOptions from an object with '$options' property.
|
|
981
|
+
*/
|
|
982
|
+
type GetQueryOptions<T extends {
|
|
983
|
+
$options: any;
|
|
984
|
+
}> = T['$options'];
|
|
985
|
+
|
|
986
|
+
type IsNever<T> = [T] extends [never] ? true : false;
|
|
987
|
+
/**
|
|
988
|
+
* Filters models based on slicing configuration.
|
|
989
|
+
*/
|
|
990
|
+
type GetSlicedModels<Schema extends SchemaDef, Options extends QueryOptions<Schema>> = Options['slicing'] extends infer S ? S extends SlicingOptions<Schema> ? S['includedModels'] extends readonly GetModels<Schema>[] ? Exclude<Extract<S['includedModels'][number], GetModels<Schema>>, S['excludedModels'] extends readonly GetModels<Schema>[] ? S['excludedModels'][number] : never> : Exclude<GetModels<Schema>, S['excludedModels'] extends readonly GetModels<Schema>[] ? S['excludedModels'][number] : never> : GetModels<Schema> : GetModels<Schema>;
|
|
991
|
+
/**
|
|
992
|
+
* Filters query operations based on slicing configuration for a specific model.
|
|
993
|
+
*/
|
|
994
|
+
type GetSlicedOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = Options['slicing'] extends infer Slicing ? Slicing extends SlicingOptions<Schema> ? GetIncludedOperations<Slicing, Model> extends infer IO ? GetExcludedOperations<Slicing, Model> extends infer EO ? IO extends '_none_' ? never : IsNever<IO> extends false ? Exclude<IO, EO> : Exclude<AllCrudOperations, EO> : AllCrudOperations : AllCrudOperations : AllCrudOperations : AllCrudOperations;
|
|
995
|
+
type GetIncludedOperations<Slicing extends SlicingOptions<any>, Model extends string> = 'models' extends keyof Slicing ? Slicing extends {
|
|
996
|
+
models: infer Config;
|
|
997
|
+
} ? Model extends keyof Config ? 'includedOperations' extends keyof Config[Model] ? Config[Model] extends {
|
|
998
|
+
includedOperations: readonly [];
|
|
999
|
+
} ? '_none_' : Config[Model] extends {
|
|
1000
|
+
includedOperations: readonly (infer IO)[];
|
|
1001
|
+
} ? IO : never : GetAllIncludedOperations<Slicing> : GetAllIncludedOperations<Slicing> : AllCrudOperations : AllCrudOperations;
|
|
1002
|
+
type GetAllIncludedOperations<Slicing extends SlicingOptions<any>> = 'models' extends keyof Slicing ? Slicing extends {
|
|
1003
|
+
models: infer Config;
|
|
1004
|
+
} ? '$all' extends keyof Config ? Config['$all'] extends {
|
|
1005
|
+
includedOperations: readonly [];
|
|
1006
|
+
} ? '_none_' : Config['$all'] extends {
|
|
1007
|
+
includedOperations: readonly (infer IO)[];
|
|
1008
|
+
} ? IO : AllCrudOperations : AllCrudOperations : AllCrudOperations : AllCrudOperations;
|
|
1009
|
+
type GetExcludedOperations<Slicing extends SlicingOptions<any>, Model extends string> = 'models' extends keyof Slicing ? Slicing extends {
|
|
1010
|
+
models: infer Config;
|
|
1011
|
+
} ? Model extends keyof Config ? Config[Model] extends {
|
|
1012
|
+
excludedOperations: readonly (infer EO)[];
|
|
1013
|
+
} ? EO : GetAllExcludedOperations<Slicing> : GetAllExcludedOperations<Slicing> : never : never;
|
|
1014
|
+
type GetAllExcludedOperations<Slicing extends SlicingOptions<any>> = 'models' extends keyof Slicing ? Slicing extends {
|
|
1015
|
+
models: infer M;
|
|
1016
|
+
} ? '$all' extends keyof M ? M['$all'] extends {
|
|
1017
|
+
excludedOperations: readonly (infer EO)[];
|
|
1018
|
+
} ? EO : never : never : never : never;
|
|
1019
|
+
/**
|
|
1020
|
+
* Filters procedures based on slicing configuration.
|
|
1021
|
+
*/
|
|
1022
|
+
type GetSlicedProcedures<Schema extends SchemaDef, Options extends QueryOptions<Schema>> = Options['slicing'] extends infer S ? S extends SlicingOptions<Schema> ? S['includedProcedures'] extends readonly (infer IncludedProc)[] ? Exclude<Extract<IncludedProc, GetProcedureNames<Schema>>, S['excludedProcedures'] extends readonly (infer ExcludedProc)[] ? Extract<ExcludedProc, GetProcedureNames<Schema>> : never> : Exclude<GetProcedureNames<Schema>, S['excludedProcedures'] extends readonly (infer ExcludedProc)[] ? Extract<ExcludedProc, GetProcedureNames<Schema>> : never> : GetProcedureNames<Schema> : GetProcedureNames<Schema>;
|
|
1023
|
+
/**
|
|
1024
|
+
* Filters filter kinds for a specific field, considering field-level slicing configuration with $all fallback.
|
|
1025
|
+
*/
|
|
1026
|
+
type GetSlicedFilterKindsForField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends string, Options extends QueryOptions<Schema>> = Options extends {
|
|
1027
|
+
slicing: infer S;
|
|
1028
|
+
} ? S extends SlicingOptions<Schema> ? GetFieldIncludedFilterKinds<S, Model, Field> extends infer IFK ? GetFieldExcludedFilterKinds<S, Model, Field> extends infer EFK ? '_none_' extends IFK ? never : IsNever<IFK> extends true ? IsNever<EFK> extends true ? FilterKind : Exclude<FilterKind, EFK> : Exclude<IFK, EFK> : FilterKind : FilterKind : FilterKind : FilterKind;
|
|
1029
|
+
type GetIncludedFilterKindsFromModelConfig<ModelConfig, Field extends string> = ModelConfig extends {
|
|
1030
|
+
includedFilterKinds: readonly [];
|
|
1031
|
+
} ? '_none_' : 'fields' extends keyof ModelConfig ? ModelConfig['fields'] extends infer FieldsConfig ? Field extends keyof FieldsConfig ? 'includedFilterKinds' extends keyof FieldsConfig[Field] ? FieldsConfig[Field] extends {
|
|
1032
|
+
includedFilterKinds: readonly [];
|
|
1033
|
+
} ? '_none_' : FieldsConfig[Field] extends {
|
|
1034
|
+
includedFilterKinds: readonly (infer IFK)[];
|
|
1035
|
+
} ? IFK : never : GetAllFieldsIncludedFilterKinds<FieldsConfig> : GetAllFieldsIncludedFilterKinds<FieldsConfig> : never : never;
|
|
1036
|
+
type GetFieldIncludedFilterKinds<S extends SlicingOptions<any>, Model extends string, Field extends string> = S extends {
|
|
1037
|
+
models?: infer Config;
|
|
1038
|
+
} ? Model extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config[Model], Field> : '$all' extends keyof Config ? GetIncludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1039
|
+
type GetAllFieldsIncludedFilterKinds<FieldsConfig> = '$all' extends keyof FieldsConfig ? FieldsConfig['$all'] extends {
|
|
1040
|
+
includedFilterKinds: readonly [];
|
|
1041
|
+
} ? '_none_' : FieldsConfig['$all'] extends {
|
|
1042
|
+
includedFilterKinds: readonly (infer IFK)[];
|
|
1043
|
+
} ? IFK : never : never;
|
|
1044
|
+
type GetExcludedFilterKindsFromModelConfig<ModelConfig, Field extends string> = 'fields' extends keyof ModelConfig ? ModelConfig['fields'] extends infer FieldsConfig ? Field extends keyof FieldsConfig ? FieldsConfig[Field] extends {
|
|
1045
|
+
excludedFilterKinds: readonly (infer EFK)[];
|
|
1046
|
+
} ? EFK : GetAllFieldsExcludedFilterKinds<FieldsConfig> : GetAllFieldsExcludedFilterKinds<FieldsConfig> : never : never;
|
|
1047
|
+
type GetFieldExcludedFilterKinds<S extends SlicingOptions<any>, Model extends string, Field extends string> = S extends {
|
|
1048
|
+
models?: infer Config;
|
|
1049
|
+
} ? Model extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config[Model], Field> : '$all' extends keyof Config ? GetExcludedFilterKindsFromModelConfig<Config['$all'], Field> : never : never;
|
|
1050
|
+
type GetAllFieldsExcludedFilterKinds<FieldsConfig> = '$all' extends keyof FieldsConfig ? FieldsConfig['$all'] extends {
|
|
1051
|
+
excludedFilterKinds: readonly (infer EFK)[];
|
|
1052
|
+
} ? EFK : never : never;
|
|
1053
|
+
|
|
1054
|
+
type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Omit = undefined, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<{
|
|
1055
|
+
[Key in NonRelationFields<Schema, Model> as ShouldOmitField<Schema, Model, Options, Key, Omit> extends true ? never : Key]: MapModelFieldType<Schema, Model, Key>;
|
|
1056
|
+
}, Optional, Array>;
|
|
1057
|
+
type ShouldOmitField<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Field extends GetModelFields<Schema, Model>, Omit> = QueryLevelOmit<Schema, Model, Field, Omit> extends boolean ? QueryLevelOmit<Schema, Model, Field, Omit> : OptionsLevelOmit<Schema, Model, Field, Options> extends boolean ? OptionsLevelOmit<Schema, Model, Field, Options> : SchemaLevelOmit<Schema, Model, Field>;
|
|
1058
|
+
type QueryLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Omit> = Field extends keyof Omit ? (Omit[Field] extends boolean ? Omit[Field] : undefined) : undefined;
|
|
1059
|
+
type OptionsLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>> = Model extends keyof Options['omit'] ? Field extends keyof Options['omit'][Model] ? Options['omit'][Model][Field] extends boolean ? Options['omit'][Model][Field] : undefined : undefined : undefined;
|
|
1060
|
+
type SchemaLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['omit'] extends true ? true : false;
|
|
1061
|
+
type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Select, Omit, Options extends QueryOptions<Schema>> = {
|
|
1062
|
+
[Key in keyof Select as Select[Key] extends false | undefined ? never : Key extends '_count' ? Select[Key] extends SelectCount<Schema, Model, Options> ? Key : never : Key extends keyof Omit ? Omit[Key] extends true ? never : Key : Key]: Key extends '_count' ? SelectCountResult<Schema, Model, Select[Key]> : Key extends NonRelationFields<Schema, Model> ? MapModelFieldType<Schema, Model, Key> : Key extends RelationFields<Schema, Model> ? ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Select[Key], Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : never;
|
|
936
1063
|
};
|
|
937
|
-
type
|
|
1064
|
+
type SelectCountResult<Schema extends SchemaDef, Model extends GetModels<Schema>, C> = C extends true ? {
|
|
1065
|
+
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: number;
|
|
1066
|
+
} : C extends {
|
|
938
1067
|
select: infer S;
|
|
939
|
-
} ?
|
|
1068
|
+
} ? {
|
|
940
1069
|
[Key in keyof S]: number;
|
|
941
|
-
} :
|
|
942
|
-
type
|
|
1070
|
+
} : never;
|
|
1071
|
+
type ModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<Args extends {
|
|
1072
|
+
select: infer S extends object;
|
|
1073
|
+
omit?: infer O extends object;
|
|
1074
|
+
} & Record<string, unknown> ? ModelSelectResult<Schema, Model, S, O, Options> : Args extends {
|
|
1075
|
+
include: infer I extends object;
|
|
1076
|
+
omit?: infer O extends object;
|
|
1077
|
+
} & Record<string, unknown> ? // select all non-omitted scalar fields
|
|
1078
|
+
DefaultModelResult<Schema, Model, O, Options, false, false> & {
|
|
1079
|
+
[Key in keyof I & RelationFields<Schema, Model> as I[Key] extends false | undefined ? never : Key]: ModelResult<Schema, RelationFieldType<Schema, Model, Key>, I[Key], Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>>;
|
|
1080
|
+
} & ('_count' extends keyof I ? I['_count'] extends false | undefined ? {} : {
|
|
1081
|
+
_count: SelectCountResult<Schema, Model, I['_count']>;
|
|
1082
|
+
} : {}) : Args extends {
|
|
1083
|
+
omit: infer O;
|
|
1084
|
+
} & Record<string, unknown> ? DefaultModelResult<Schema, Model, O, Options, false, false> : DefaultModelResult<Schema, Model, undefined, Options, false, false>, Optional, Array>;
|
|
1085
|
+
type SimplifiedResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = Simplify<ModelResult<Schema, Model, Args, Options, Optional, Array>>;
|
|
1086
|
+
type SimplifiedPlainResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Simplify<ModelResult<Schema, Model, Args, Options, false, false>>;
|
|
1087
|
+
type TypeDefResult<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Partial extends boolean = false> = PartialIf<Optional<{
|
|
1088
|
+
[Key in GetTypeDefFields<Schema, TypeDef>]: MapFieldDefType<Schema, GetTypeDefField<Schema, TypeDef, Key>, Partial>;
|
|
1089
|
+
}, Partial extends true ? never : keyof {
|
|
1090
|
+
[Key in GetTypeDefFields<Schema, TypeDef> as TypeDefFieldIsOptional<Schema, TypeDef, Key> extends true ? Key : never]: true;
|
|
1091
|
+
}>, Partial> & Record<string, unknown>;
|
|
1092
|
+
type BatchResult = {
|
|
1093
|
+
count: number;
|
|
1094
|
+
};
|
|
1095
|
+
type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ScalarOnly extends boolean = false, WithAggregations extends boolean = false> = {
|
|
1096
|
+
[Key in GetModelFields<Schema, Model> as ScalarOnly extends true ? Key extends RelationFields<Schema, Model> ? never : Key : Key]?: FieldFilter<Schema, Model, Key, Options, WithAggregations>;
|
|
1097
|
+
} & {
|
|
1098
|
+
$expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
|
|
1099
|
+
} & {
|
|
1100
|
+
AND?: OrArray<WhereInput<Schema, Model, Options, ScalarOnly>>;
|
|
1101
|
+
OR?: WhereInput<Schema, Model, Options, ScalarOnly>[];
|
|
1102
|
+
NOT?: OrArray<WhereInput<Schema, Model, Options, ScalarOnly>>;
|
|
1103
|
+
};
|
|
1104
|
+
type FieldFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>, WithAggregations extends boolean, AllowedKinds extends FilterKind = GetSlicedFilterKindsForField<Schema, Model, Field, Options>> = Field extends RelationFields<Schema, Model> ? RelationFilter<Schema, Model, Field, Options, AllowedKinds> : FieldIsArray<Schema, Model, Field> extends true ? ArrayFilter<Schema, GetModelFieldType<Schema, Model, Field>, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends GetEnums<Schema> ? EnumFilter<Schema, GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetModelFieldType<Schema, Model, Field>, FieldIsArray<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, AllowedKinds> : PrimitiveFilter<GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds>;
|
|
1105
|
+
type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<keyof GetEnum<Schema, T>, Nullable> : never) | (('Equality' extends AllowedKinds ? {
|
|
943
1106
|
/**
|
|
944
|
-
*
|
|
1107
|
+
* Checks for equality with the specified enum value.
|
|
945
1108
|
*/
|
|
946
|
-
|
|
1109
|
+
equals?: NullableIf<keyof GetEnum<Schema, T>, Nullable>;
|
|
947
1110
|
/**
|
|
948
|
-
*
|
|
1111
|
+
* Checks if the enum value is in the specified list of values.
|
|
949
1112
|
*/
|
|
950
|
-
|
|
1113
|
+
in?: (keyof GetEnum<Schema, T>)[];
|
|
951
1114
|
/**
|
|
952
|
-
*
|
|
1115
|
+
* Checks if the enum value is not in the specified list of values.
|
|
953
1116
|
*/
|
|
954
|
-
|
|
1117
|
+
notIn?: (keyof GetEnum<Schema, T>)[];
|
|
1118
|
+
} : {}) & {
|
|
955
1119
|
/**
|
|
956
|
-
*
|
|
1120
|
+
* Builds a negated filter.
|
|
957
1121
|
*/
|
|
958
|
-
|
|
959
|
-
} & {
|
|
1122
|
+
not?: EnumFilter<Schema, T, Nullable, WithAggregations, AllowedKinds>;
|
|
1123
|
+
} & (WithAggregations extends true ? {
|
|
960
1124
|
/**
|
|
961
|
-
*
|
|
1125
|
+
* Filters against the count of records.
|
|
962
1126
|
*/
|
|
963
|
-
_count?:
|
|
1127
|
+
_count?: NumberFilter<'Int', false, false, AllowedKinds>;
|
|
964
1128
|
/**
|
|
965
|
-
*
|
|
1129
|
+
* Filters against the minimum value.
|
|
966
1130
|
*/
|
|
967
|
-
_min?:
|
|
1131
|
+
_min?: EnumFilter<Schema, T, false, false, AllowedKinds>;
|
|
968
1132
|
/**
|
|
969
|
-
*
|
|
1133
|
+
* Filters against the maximum value.
|
|
970
1134
|
*/
|
|
971
|
-
_max?:
|
|
972
|
-
}
|
|
1135
|
+
_max?: EnumFilter<Schema, T, false, false, AllowedKinds>;
|
|
1136
|
+
} : {}));
|
|
1137
|
+
type ArrayFilter<Schema extends SchemaDef, Type extends string, AllowedKinds extends FilterKind> = ('Equality' extends AllowedKinds ? {
|
|
973
1138
|
/**
|
|
974
|
-
*
|
|
1139
|
+
* Checks if the array equals the specified array.
|
|
975
1140
|
*/
|
|
976
|
-
|
|
1141
|
+
equals?: MapScalarType<Schema, Type>[] | null;
|
|
1142
|
+
} : {}) & ('List' extends AllowedKinds ? {
|
|
977
1143
|
/**
|
|
978
|
-
*
|
|
1144
|
+
* Checks if the array contains all elements of the specified array.
|
|
979
1145
|
*/
|
|
980
|
-
|
|
981
|
-
});
|
|
982
|
-
type NumericFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
983
|
-
[Key in GetModelFields<Schema, Model> as GetModelFieldType<Schema, Model, Key> extends 'Int' | 'Float' | 'BigInt' | 'Decimal' ? FieldIsArray<Schema, Model, Key> extends true ? never : Key : never]: GetModelField<Schema, Model, Key>;
|
|
984
|
-
};
|
|
985
|
-
type SumAvgInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ValueType> = {
|
|
986
|
-
[Key in NumericFields<Schema, Model>]?: ValueType;
|
|
987
|
-
};
|
|
988
|
-
type MinMaxInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ValueType> = {
|
|
989
|
-
[Key in GetModelFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? never : FieldIsRelation<Schema, Model, Key> extends true ? never : Key]?: ValueType;
|
|
990
|
-
};
|
|
991
|
-
type AggregateResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Args> = (Args extends {
|
|
992
|
-
_count: infer Count;
|
|
993
|
-
} ? {
|
|
1146
|
+
has?: MapScalarType<Schema, Type> | null;
|
|
994
1147
|
/**
|
|
995
|
-
*
|
|
1148
|
+
* Checks if the array contains any of the elements of the specified array.
|
|
996
1149
|
*/
|
|
997
|
-
|
|
998
|
-
} : {}) & (Args extends {
|
|
999
|
-
_sum: infer Sum;
|
|
1000
|
-
} ? {
|
|
1150
|
+
hasEvery?: MapScalarType<Schema, Type>[];
|
|
1001
1151
|
/**
|
|
1002
|
-
*
|
|
1152
|
+
* Checks if the array contains some of the elements of the specified array.
|
|
1003
1153
|
*/
|
|
1004
|
-
|
|
1005
|
-
} : {}) & (Args extends {
|
|
1006
|
-
_avg: infer Avg;
|
|
1007
|
-
} ? {
|
|
1154
|
+
hasSome?: MapScalarType<Schema, Type>[];
|
|
1008
1155
|
/**
|
|
1009
|
-
*
|
|
1156
|
+
* Checks if the array is empty.
|
|
1010
1157
|
*/
|
|
1011
|
-
|
|
1012
|
-
} : {})
|
|
1013
|
-
|
|
1014
|
-
|
|
1158
|
+
isEmpty?: boolean;
|
|
1159
|
+
} : {});
|
|
1160
|
+
type MapScalarType<Schema extends SchemaDef, Type extends string> = Type extends GetEnums<Schema> ? keyof GetEnum<Schema, Type> : MapBaseType$1<Type>;
|
|
1161
|
+
type PrimitiveFilter<T extends string, Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind> = T extends 'String' ? StringFilter<Nullable, WithAggregations, AllowedKinds> : T extends 'Int' | 'Float' | 'Decimal' | 'BigInt' ? NumberFilter<T, Nullable, WithAggregations, AllowedKinds> : T extends 'Boolean' ? BooleanFilter<Nullable, WithAggregations, AllowedKinds> : T extends 'DateTime' ? DateTimeFilter<Nullable, WithAggregations, AllowedKinds> : T extends 'Bytes' ? BytesFilter<Nullable, WithAggregations, AllowedKinds> : T extends 'Json' ? JsonFilter<AllowedKinds> : never;
|
|
1162
|
+
type CommonPrimitiveFilter<DataType, T extends BuiltinType, Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind> = ('Equality' extends AllowedKinds ? {
|
|
1015
1163
|
/**
|
|
1016
|
-
*
|
|
1164
|
+
* Checks for equality with the specified value.
|
|
1017
1165
|
*/
|
|
1018
|
-
|
|
1019
|
-
} : {}) & (Args extends {
|
|
1020
|
-
_max: infer Max;
|
|
1021
|
-
} ? {
|
|
1166
|
+
equals?: NullableIf<DataType, Nullable>;
|
|
1022
1167
|
/**
|
|
1023
|
-
*
|
|
1168
|
+
* Checks if the value is in the specified list of values.
|
|
1024
1169
|
*/
|
|
1025
|
-
|
|
1026
|
-
} : {});
|
|
1027
|
-
type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
|
|
1028
|
-
[Key in keyof Input]: number;
|
|
1029
|
-
} : never;
|
|
1030
|
-
type GroupByHaving<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<WhereInput<Schema, Model, true, true>, '$expr'>;
|
|
1031
|
-
type GroupByArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1170
|
+
in?: DataType[];
|
|
1032
1171
|
/**
|
|
1033
|
-
*
|
|
1172
|
+
* Checks if the value is not in the specified list of values.
|
|
1034
1173
|
*/
|
|
1035
|
-
|
|
1174
|
+
notIn?: DataType[];
|
|
1175
|
+
} : {}) & ('Range' extends AllowedKinds ? {
|
|
1036
1176
|
/**
|
|
1037
|
-
*
|
|
1177
|
+
* Checks if the value is less than the specified value.
|
|
1038
1178
|
*/
|
|
1039
|
-
|
|
1179
|
+
lt?: DataType;
|
|
1040
1180
|
/**
|
|
1041
|
-
*
|
|
1181
|
+
* Checks if the value is less than or equal to the specified value.
|
|
1042
1182
|
*/
|
|
1043
|
-
|
|
1183
|
+
lte?: DataType;
|
|
1044
1184
|
/**
|
|
1045
|
-
*
|
|
1185
|
+
* Checks if the value is greater than the specified value.
|
|
1046
1186
|
*/
|
|
1047
|
-
|
|
1187
|
+
gt?: DataType;
|
|
1048
1188
|
/**
|
|
1049
|
-
*
|
|
1189
|
+
* Checks if the value is greater than or equal to the specified value.
|
|
1050
1190
|
*/
|
|
1051
|
-
|
|
1191
|
+
gte?: DataType;
|
|
1052
1192
|
/**
|
|
1053
|
-
*
|
|
1193
|
+
* Checks if the value is between the specified values (inclusive).
|
|
1054
1194
|
*/
|
|
1055
|
-
|
|
1195
|
+
between?: [start: DataType, end: DataType];
|
|
1196
|
+
} : {}) & {
|
|
1056
1197
|
/**
|
|
1057
|
-
*
|
|
1198
|
+
* Builds a negated filter.
|
|
1058
1199
|
*/
|
|
1059
|
-
|
|
1200
|
+
not?: PrimitiveFilter<T, Nullable, WithAggregations, AllowedKinds>;
|
|
1201
|
+
};
|
|
1202
|
+
type StringFilter<Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind = FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<string, Nullable> : never) | (CommonPrimitiveFilter<string, 'String', Nullable, WithAggregations, AllowedKinds> & ('Like' extends AllowedKinds ? {
|
|
1060
1203
|
/**
|
|
1061
|
-
*
|
|
1204
|
+
* Checks if the string contains the specified substring.
|
|
1062
1205
|
*/
|
|
1063
|
-
|
|
1206
|
+
contains?: string;
|
|
1064
1207
|
/**
|
|
1065
|
-
*
|
|
1208
|
+
* Checks if the string starts with the specified substring.
|
|
1066
1209
|
*/
|
|
1067
|
-
|
|
1068
|
-
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1210
|
+
startsWith?: string;
|
|
1069
1211
|
/**
|
|
1070
|
-
*
|
|
1212
|
+
* Checks if the string ends with the specified substring.
|
|
1071
1213
|
*/
|
|
1072
|
-
|
|
1214
|
+
endsWith?: string;
|
|
1073
1215
|
/**
|
|
1074
|
-
*
|
|
1216
|
+
* Specifies the string comparison mode. Not effective for "sqlite" provider
|
|
1075
1217
|
*/
|
|
1076
|
-
|
|
1077
|
-
})
|
|
1078
|
-
type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args extends {
|
|
1079
|
-
by: unknown;
|
|
1080
|
-
}> = Array<{
|
|
1081
|
-
[Key in NonRelationFields<Schema, Model> as Key extends ValueOfPotentialTuple<Args['by']> ? Key : never]: MapModelFieldType<Schema, Model, Key>;
|
|
1082
|
-
} & (Args extends {
|
|
1083
|
-
_count: infer Count;
|
|
1084
|
-
} ? {
|
|
1218
|
+
mode?: 'default' | 'insensitive';
|
|
1219
|
+
} : {}) & (WithAggregations extends true ? {
|
|
1085
1220
|
/**
|
|
1086
|
-
*
|
|
1221
|
+
* Filters against the count of records.
|
|
1087
1222
|
*/
|
|
1088
|
-
_count
|
|
1089
|
-
} : {}) & (Args extends {
|
|
1090
|
-
_avg: infer Avg;
|
|
1091
|
-
} ? {
|
|
1223
|
+
_count?: NumberFilter<'Int', false, false, AllowedKinds>;
|
|
1092
1224
|
/**
|
|
1093
|
-
*
|
|
1225
|
+
* Filters against the minimum value.
|
|
1094
1226
|
*/
|
|
1095
|
-
|
|
1096
|
-
} : {}) & (Args extends {
|
|
1097
|
-
_sum: infer Sum;
|
|
1098
|
-
} ? {
|
|
1227
|
+
_min?: StringFilter<false, false, AllowedKinds>;
|
|
1099
1228
|
/**
|
|
1100
|
-
*
|
|
1229
|
+
* Filters against the maximum value.
|
|
1101
1230
|
*/
|
|
1102
|
-
|
|
1103
|
-
} : {})
|
|
1104
|
-
|
|
1105
|
-
} ? {
|
|
1231
|
+
_max?: StringFilter<false, false, AllowedKinds>;
|
|
1232
|
+
} : {}));
|
|
1233
|
+
type NumberFilter<T extends 'Int' | 'Float' | 'Decimal' | 'BigInt', Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind = FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<number | bigint, Nullable> : never) | (CommonPrimitiveFilter<number, T, Nullable, WithAggregations, AllowedKinds> & (WithAggregations extends true ? {
|
|
1106
1234
|
/**
|
|
1107
|
-
*
|
|
1235
|
+
* Filters against the count of records.
|
|
1108
1236
|
*/
|
|
1109
|
-
|
|
1110
|
-
} : {}) & (Args extends {
|
|
1111
|
-
_max: infer Max;
|
|
1112
|
-
} ? {
|
|
1237
|
+
_count?: NumberFilter<'Int', false, false, AllowedKinds>;
|
|
1113
1238
|
/**
|
|
1114
|
-
*
|
|
1239
|
+
* Filters against the average value.
|
|
1115
1240
|
*/
|
|
1116
|
-
|
|
1117
|
-
} : {})>;
|
|
1118
|
-
type ConnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>> : WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1119
|
-
type ConnectOrCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<ConnectOrCreatePayload<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>> : ConnectOrCreatePayload<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1120
|
-
type DisconnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>, true> : boolean | WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1121
|
-
type SetRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>>;
|
|
1122
|
-
type NestedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<{
|
|
1241
|
+
_avg?: NumberFilter<T, false, false, AllowedKinds>;
|
|
1123
1242
|
/**
|
|
1124
|
-
*
|
|
1243
|
+
* Filters against the sum value.
|
|
1125
1244
|
*/
|
|
1126
|
-
|
|
1245
|
+
_sum?: NumberFilter<T, false, false, AllowedKinds>;
|
|
1127
1246
|
/**
|
|
1128
|
-
*
|
|
1247
|
+
* Filters against the minimum value.
|
|
1129
1248
|
*/
|
|
1130
|
-
|
|
1131
|
-
}, true> : XOR<{
|
|
1249
|
+
_min?: NumberFilter<T, false, false, AllowedKinds>;
|
|
1132
1250
|
/**
|
|
1133
|
-
*
|
|
1251
|
+
* Filters against the maximum value.
|
|
1134
1252
|
*/
|
|
1135
|
-
|
|
1253
|
+
_max?: NumberFilter<T, false, false, AllowedKinds>;
|
|
1254
|
+
} : {}));
|
|
1255
|
+
type DateTimeFilter<Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind = FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<Date | string, Nullable> : never) | (CommonPrimitiveFilter<Date | string, 'DateTime', Nullable, WithAggregations, AllowedKinds> & (WithAggregations extends true ? {
|
|
1136
1256
|
/**
|
|
1137
|
-
*
|
|
1257
|
+
* Filters against the count of records.
|
|
1138
1258
|
*/
|
|
1139
|
-
|
|
1140
|
-
}, UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
1141
|
-
type NestedUpsertInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<{
|
|
1259
|
+
_count?: NumberFilter<'Int', false, false, AllowedKinds>;
|
|
1142
1260
|
/**
|
|
1143
|
-
*
|
|
1261
|
+
* Filters against the minimum value.
|
|
1144
1262
|
*/
|
|
1145
|
-
|
|
1263
|
+
_min?: DateTimeFilter<false, false, AllowedKinds>;
|
|
1146
1264
|
/**
|
|
1147
|
-
*
|
|
1265
|
+
* Filters against the maximum value.
|
|
1148
1266
|
*/
|
|
1149
|
-
|
|
1267
|
+
_max?: DateTimeFilter<false, false, AllowedKinds>;
|
|
1268
|
+
} : {}));
|
|
1269
|
+
type BytesFilter<Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind = FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<Uint8Array | Buffer, Nullable> : never) | (('Equality' extends AllowedKinds ? {
|
|
1150
1270
|
/**
|
|
1151
|
-
*
|
|
1271
|
+
* Checks for equality with the specified value.
|
|
1152
1272
|
*/
|
|
1153
|
-
|
|
1154
|
-
}, FieldIsArray<Schema, Model, Field>>;
|
|
1155
|
-
type NestedUpdateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<UpdateManyPayload<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
1156
|
-
type NestedDeleteInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>, true> : boolean | WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1157
|
-
type NestedDeleteManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, true>>;
|
|
1158
|
-
type GetProcedureNames<Schema extends SchemaDef> = Schema extends {
|
|
1159
|
-
procedures: Record<string, ProcedureDef>;
|
|
1160
|
-
} ? keyof Schema['procedures'] : never;
|
|
1161
|
-
type GetProcedureParams<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
1162
|
-
procedures: Record<string, ProcedureDef>;
|
|
1163
|
-
} ? Schema['procedures'][ProcName]['params'] : never;
|
|
1164
|
-
type GetProcedure<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
1165
|
-
procedures: Record<string, ProcedureDef>;
|
|
1166
|
-
} ? Schema['procedures'][ProcName] : never;
|
|
1167
|
-
type _OptionalProcedureParamNames<Params> = keyof {
|
|
1168
|
-
[K in keyof Params as Params[K] extends {
|
|
1169
|
-
optional: true;
|
|
1170
|
-
} ? K : never]: K;
|
|
1171
|
-
};
|
|
1172
|
-
type _RequiredProcedureParamNames<Params> = keyof {
|
|
1173
|
-
[K in keyof Params as Params[K] extends {
|
|
1174
|
-
optional: true;
|
|
1175
|
-
} ? never : K]: K;
|
|
1176
|
-
};
|
|
1177
|
-
type _HasRequiredProcedureParams<Params> = _RequiredProcedureParamNames<Params> extends never ? false : true;
|
|
1178
|
-
type MapProcedureArgsObject<Schema extends SchemaDef, Params> = Simplify<Optional<{
|
|
1179
|
-
[K in keyof Params]: MapProcedureParam<Schema, Params[K]>;
|
|
1180
|
-
}, _OptionalProcedureParamNames<Params>>>;
|
|
1181
|
-
type ProcedureEnvelope<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>, Params = GetProcedureParams<Schema, ProcName>> = keyof Params extends never ? {
|
|
1182
|
-
args?: Record<string, never>;
|
|
1183
|
-
} : _HasRequiredProcedureParams<Params> extends true ? {
|
|
1184
|
-
args: MapProcedureArgsObject<Schema, Params>;
|
|
1185
|
-
} : {
|
|
1186
|
-
args?: MapProcedureArgsObject<Schema, Params>;
|
|
1187
|
-
};
|
|
1188
|
-
type ProcedureHandlerCtx<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = {
|
|
1189
|
-
client: ClientContract<Schema>;
|
|
1190
|
-
} & ProcedureEnvelope<Schema, ProcName>;
|
|
1191
|
-
/**
|
|
1192
|
-
* Shape of a procedure's runtime function.
|
|
1193
|
-
*/
|
|
1194
|
-
type ProcedureFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (...args: _HasRequiredProcedureParams<GetProcedureParams<Schema, ProcName>> extends true ? [input: ProcedureEnvelope<Schema, ProcName>] : [input?: ProcedureEnvelope<Schema, ProcName>]) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
1195
|
-
/**
|
|
1196
|
-
* Signature for procedure handlers configured via client options.
|
|
1197
|
-
*/
|
|
1198
|
-
type ProcedureHandlerFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (ctx: ProcedureHandlerCtx<Schema, ProcName>) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
1199
|
-
type MapProcedureReturn<Schema extends SchemaDef, Proc> = Proc extends {
|
|
1200
|
-
returnType: infer R;
|
|
1201
|
-
} ? Proc extends {
|
|
1202
|
-
returnArray: true;
|
|
1203
|
-
} ? Array<MapType<Schema, R & string>> : MapType<Schema, R & string> : never;
|
|
1204
|
-
type MapProcedureParam<Schema extends SchemaDef, P> = P extends {
|
|
1205
|
-
type: infer U;
|
|
1206
|
-
} ? OrUndefinedIf<P extends {
|
|
1207
|
-
array: true;
|
|
1208
|
-
} ? Array<MapType<Schema, U & string>> : MapType<Schema, U & string>, P extends {
|
|
1209
|
-
optional: true;
|
|
1210
|
-
} ? true : false> : never;
|
|
1211
|
-
type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
1212
|
-
[Key in RelationFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends {
|
|
1213
|
-
references: readonly unknown[];
|
|
1214
|
-
} ? never : Key]: true;
|
|
1215
|
-
};
|
|
1216
|
-
type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
1217
|
-
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: true;
|
|
1218
|
-
} extends never ? false : true;
|
|
1219
|
-
type EnumValue<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = GetEnum<Schema, Enum>[keyof GetEnum<Schema, Enum>];
|
|
1220
|
-
type MapType<Schema extends SchemaDef, T extends string> = T extends keyof TypeMap ? TypeMap[T] : T extends GetModels<Schema> ? ModelResult<Schema, T> : T extends GetTypeDefs<Schema> ? TypeDefResult<Schema, T> : T extends GetEnums<Schema> ? EnumValue<Schema, T> : unknown;
|
|
1221
|
-
type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
1222
|
-
|
|
1223
|
-
declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
1224
|
-
protected readonly schema: Schema;
|
|
1225
|
-
protected readonly options: ClientOptions<Schema>;
|
|
1226
|
-
protected eb: ExpressionBuilder<any, any>;
|
|
1227
|
-
constructor(schema: Schema, options: ClientOptions<Schema>);
|
|
1273
|
+
equals?: NullableIf<Uint8Array, Nullable>;
|
|
1228
1274
|
/**
|
|
1229
|
-
*
|
|
1275
|
+
* Checks if the value is in the specified list of values.
|
|
1230
1276
|
*/
|
|
1231
|
-
|
|
1277
|
+
in?: Uint8Array[];
|
|
1232
1278
|
/**
|
|
1233
|
-
*
|
|
1279
|
+
* Checks if the value is not in the specified list of values.
|
|
1234
1280
|
*/
|
|
1235
|
-
|
|
1281
|
+
notIn?: Uint8Array[];
|
|
1282
|
+
} : {}) & {
|
|
1236
1283
|
/**
|
|
1237
|
-
*
|
|
1284
|
+
* Builds a negated filter.
|
|
1238
1285
|
*/
|
|
1239
|
-
|
|
1286
|
+
not?: BytesFilter<Nullable, WithAggregations, AllowedKinds>;
|
|
1287
|
+
} & (WithAggregations extends true ? {
|
|
1240
1288
|
/**
|
|
1241
|
-
*
|
|
1289
|
+
* Filters against the count of records.
|
|
1242
1290
|
*/
|
|
1243
|
-
|
|
1291
|
+
_count?: NumberFilter<'Int', false, false, AllowedKinds>;
|
|
1244
1292
|
/**
|
|
1245
|
-
*
|
|
1293
|
+
* Filters against the minimum value.
|
|
1246
1294
|
*/
|
|
1247
|
-
|
|
1295
|
+
_min?: BytesFilter<false, false, AllowedKinds>;
|
|
1248
1296
|
/**
|
|
1249
|
-
*
|
|
1297
|
+
* Filters against the maximum value.
|
|
1250
1298
|
*/
|
|
1251
|
-
|
|
1299
|
+
_max?: BytesFilter<false, false, AllowedKinds>;
|
|
1300
|
+
} : {}));
|
|
1301
|
+
type BooleanFilter<Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind = FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<boolean, Nullable> : never) | (('Equality' extends AllowedKinds ? {
|
|
1252
1302
|
/**
|
|
1253
|
-
*
|
|
1303
|
+
* Checks for equality with the specified value.
|
|
1254
1304
|
*/
|
|
1255
|
-
|
|
1305
|
+
equals?: NullableIf<boolean, Nullable>;
|
|
1306
|
+
} : {}) & {
|
|
1256
1307
|
/**
|
|
1257
|
-
*
|
|
1308
|
+
* Builds a negated filter.
|
|
1258
1309
|
*/
|
|
1259
|
-
|
|
1310
|
+
not?: BooleanFilter<Nullable, WithAggregations, AllowedKinds>;
|
|
1311
|
+
} & (WithAggregations extends true ? {
|
|
1260
1312
|
/**
|
|
1261
|
-
*
|
|
1313
|
+
* Filters against the count of records.
|
|
1262
1314
|
*/
|
|
1263
|
-
|
|
1264
|
-
buildSelectModel(model: string, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
1265
|
-
buildFilterSortTake(model: string, args: FindArgs<Schema, GetModels<Schema>, true>, query: SelectQueryBuilder<any, any, {}>, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
1266
|
-
buildFilter(model: string, modelAlias: string, where: boolean | object | undefined): Expression<SqlBool>;
|
|
1267
|
-
private buildCursorFilter;
|
|
1268
|
-
private isLogicalCombinator;
|
|
1269
|
-
protected buildCompositeFilter(model: string, modelAlias: string, key: (typeof LOGICAL_COMBINATORS)[number], payload: any): Expression<SqlBool>;
|
|
1270
|
-
private buildRelationFilter;
|
|
1271
|
-
private buildToOneRelationFilter;
|
|
1272
|
-
private buildToManyRelationFilter;
|
|
1273
|
-
private buildArrayFilter;
|
|
1274
|
-
buildPrimitiveFilter(fieldRef: Expression<any>, fieldDef: FieldDef, payload: any): any;
|
|
1275
|
-
private buildJsonFilter;
|
|
1276
|
-
private buildPlainJsonFilter;
|
|
1277
|
-
private buildTypedJsonFilter;
|
|
1278
|
-
private buildTypedJsonArrayFilter;
|
|
1279
|
-
private buildTypeJsonNonArrayFilter;
|
|
1280
|
-
private buildJsonValueFilterClause;
|
|
1281
|
-
protected buildJsonEqualityFilter(lhs: Expression<any>, rhs: unknown): ExpressionWrapper<any, any, SqlBool>;
|
|
1282
|
-
private buildLiteralFilter;
|
|
1283
|
-
private buildStandardFilter;
|
|
1284
|
-
private buildStringFilter;
|
|
1285
|
-
private buildJsonStringFilter;
|
|
1286
|
-
private escapeLikePattern;
|
|
1287
|
-
private buildStringLike;
|
|
1288
|
-
private prepStringCasing;
|
|
1289
|
-
private buildNumberFilter;
|
|
1290
|
-
private buildBooleanFilter;
|
|
1291
|
-
private buildDateTimeFilter;
|
|
1292
|
-
private buildBytesFilter;
|
|
1293
|
-
private buildEnumFilter;
|
|
1294
|
-
buildOrderBy(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, orderBy: OrArray<OrderBy<Schema, GetModels<Schema>, boolean, boolean>> | undefined, negated: boolean, take: number | undefined): SelectQueryBuilder<any, any, any>;
|
|
1295
|
-
buildSelectAllFields(model: string, query: SelectQueryBuilder<any, any, any>, omit: Record<string, boolean | undefined> | undefined | null, modelAlias: string): SelectQueryBuilder<any, any, any>;
|
|
1296
|
-
shouldOmitField(omit: unknown, model: string, field: string): any;
|
|
1297
|
-
protected buildModelSelect(model: GetModels<Schema>, subQueryAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, true>, selectAllFields: boolean): SelectQueryBuilder<any, any, {}>;
|
|
1298
|
-
buildSelectField(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, field: string): SelectQueryBuilder<any, any, any>;
|
|
1299
|
-
buildDelegateJoin(thisModel: string, thisModelAlias: string, otherModelAlias: string, query: SelectQueryBuilder<any, any, any>): SelectQueryBuilder<any, any, any>;
|
|
1300
|
-
buildCountJson(model: string, eb: ExpressionBuilder<any, any>, parentAlias: string, payload: any): AliasableExpression<unknown>;
|
|
1301
|
-
protected negateSort(sort: SortOrder, negated: boolean): SortOrder;
|
|
1302
|
-
true(): Expression<SqlBool>;
|
|
1303
|
-
false(): Expression<SqlBool>;
|
|
1304
|
-
isTrue(expression: Expression<SqlBool>): boolean;
|
|
1305
|
-
isFalse(expression: Expression<SqlBool>): boolean;
|
|
1306
|
-
and(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
1307
|
-
or(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
1308
|
-
not(...args: Expression<SqlBool>[]): ExpressionWrapper<any, any, SqlBool>;
|
|
1309
|
-
fieldRef(model: string, field: string, modelAlias?: string, inlineComputedField?: boolean): any;
|
|
1310
|
-
protected canJoinWithoutNestedSelect(modelDef: ModelDef, payload: boolean | FindArgs<Schema, GetModels<Schema>, true>): boolean;
|
|
1311
|
-
abstract get provider(): DataSourceProviderType;
|
|
1315
|
+
_count?: NumberFilter<'Int', false, false, AllowedKinds>;
|
|
1312
1316
|
/**
|
|
1313
|
-
*
|
|
1317
|
+
* Filters against the minimum value.
|
|
1314
1318
|
*/
|
|
1315
|
-
|
|
1319
|
+
_min?: BooleanFilter<false, false, AllowedKinds>;
|
|
1316
1320
|
/**
|
|
1317
|
-
*
|
|
1321
|
+
* Filters against the maximum value.
|
|
1318
1322
|
*/
|
|
1319
|
-
|
|
1323
|
+
_max?: BooleanFilter<false, false, AllowedKinds>;
|
|
1324
|
+
} : {}));
|
|
1325
|
+
type JsonFilter<AllowedKinds extends FilterKind = FilterKind> = ('Equality' extends AllowedKinds ? {
|
|
1320
1326
|
/**
|
|
1321
|
-
*
|
|
1327
|
+
* Checks for equality with the specified value.
|
|
1322
1328
|
*/
|
|
1323
|
-
|
|
1329
|
+
equals?: JsonValue | JsonNullValues;
|
|
1324
1330
|
/**
|
|
1325
|
-
* Builds
|
|
1331
|
+
* Builds a negated filter.
|
|
1326
1332
|
*/
|
|
1327
|
-
|
|
1333
|
+
not?: JsonValue | JsonNullValues;
|
|
1334
|
+
} : {}) & ('Json' extends AllowedKinds ? {
|
|
1328
1335
|
/**
|
|
1329
|
-
*
|
|
1336
|
+
* JSON path to select the value to filter on. If omitted, the whole JSON value is used.
|
|
1330
1337
|
*/
|
|
1331
|
-
|
|
1338
|
+
path?: string;
|
|
1332
1339
|
/**
|
|
1333
|
-
*
|
|
1340
|
+
* Checks if the value is a string and contains the specified substring.
|
|
1334
1341
|
*/
|
|
1335
|
-
|
|
1342
|
+
string_contains?: string;
|
|
1336
1343
|
/**
|
|
1337
|
-
*
|
|
1344
|
+
* Checks if the value is a string and starts with the specified substring.
|
|
1338
1345
|
*/
|
|
1339
|
-
|
|
1346
|
+
string_starts_with?: string;
|
|
1340
1347
|
/**
|
|
1341
|
-
*
|
|
1348
|
+
* Checks if the value is a string and ends with the specified substring.
|
|
1342
1349
|
*/
|
|
1343
|
-
|
|
1350
|
+
string_ends_with?: string;
|
|
1344
1351
|
/**
|
|
1345
|
-
*
|
|
1352
|
+
* String comparison mode. Not effective for "sqlite" provider
|
|
1346
1353
|
*/
|
|
1347
|
-
|
|
1354
|
+
mode?: 'default' | 'insensitive';
|
|
1348
1355
|
/**
|
|
1349
|
-
*
|
|
1356
|
+
* Checks if the value is an array and contains the specified value.
|
|
1350
1357
|
*/
|
|
1351
|
-
|
|
1358
|
+
array_contains?: JsonValue;
|
|
1352
1359
|
/**
|
|
1353
|
-
*
|
|
1360
|
+
* Checks if the value is an array and starts with the specified value.
|
|
1354
1361
|
*/
|
|
1355
|
-
|
|
1356
|
-
abstract getStringCasingBehavior(): {
|
|
1357
|
-
supportsILike: boolean;
|
|
1358
|
-
likeCaseSensitive: boolean;
|
|
1359
|
-
};
|
|
1362
|
+
array_starts_with?: JsonValue;
|
|
1360
1363
|
/**
|
|
1361
|
-
*
|
|
1364
|
+
* Checks if the value is an array and ends with the specified value.
|
|
1362
1365
|
*/
|
|
1363
|
-
|
|
1366
|
+
array_ends_with?: JsonValue;
|
|
1367
|
+
} : {});
|
|
1368
|
+
type TypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean, AllowedKinds extends FilterKind> = XOR<JsonFilter<AllowedKinds>, TypedJsonTypedFilter<Schema, TypeDefName, Array, Optional, AllowedKinds>>;
|
|
1369
|
+
type TypedJsonTypedFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean, AllowedKinds extends FilterKind> = 'Json' extends AllowedKinds ? (Array extends true ? ArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds> : NonArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds>) | (Optional extends true ? null : never) : {};
|
|
1370
|
+
type ArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, AllowedKinds extends FilterKind> = {
|
|
1371
|
+
some?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1372
|
+
every?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1373
|
+
none?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1374
|
+
};
|
|
1375
|
+
type NonArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, AllowedKinds extends FilterKind> = {
|
|
1376
|
+
is?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1377
|
+
isNot?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1378
|
+
} | TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1379
|
+
type TypedJsonFieldsFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, AllowedKinds extends FilterKind> = {
|
|
1380
|
+
[Key in GetTypeDefFields<Schema, TypeDefName>]?: GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsArray<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, AllowedKinds> : TypeDefFieldIsArray<Schema, TypeDefName, Key> extends true ? ArrayFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, AllowedKinds> : GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false, AllowedKinds> : PrimitiveFilter<GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false, AllowedKinds>;
|
|
1381
|
+
};
|
|
1382
|
+
type SortOrder = 'asc' | 'desc';
|
|
1383
|
+
type NullsOrder = 'first' | 'last';
|
|
1384
|
+
type OrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>, WithRelation extends boolean, WithAggregation extends boolean> = {
|
|
1385
|
+
[Key in NonRelationFields<Schema, Model>]?: ModelFieldIsOptional<Schema, Model, Key> extends true ? SortOrder | {
|
|
1386
|
+
/**
|
|
1387
|
+
* Sort order
|
|
1388
|
+
*/
|
|
1389
|
+
sort: SortOrder;
|
|
1390
|
+
/**
|
|
1391
|
+
* Treatment of null values
|
|
1392
|
+
*/
|
|
1393
|
+
nulls?: NullsOrder;
|
|
1394
|
+
} : SortOrder;
|
|
1395
|
+
} & (WithRelation extends true ? {
|
|
1396
|
+
[Key in RelationFields<Schema, Model>]?: FieldIsArray<Schema, Model, Key> extends true ? {
|
|
1397
|
+
/**
|
|
1398
|
+
* Sorts by the count of related records.
|
|
1399
|
+
*/
|
|
1400
|
+
_count?: SortOrder;
|
|
1401
|
+
} : OrderBy<Schema, RelationFieldType<Schema, Model, Key>, WithRelation, WithAggregation>;
|
|
1402
|
+
} : {}) & (WithAggregation extends true ? {
|
|
1364
1403
|
/**
|
|
1365
|
-
*
|
|
1404
|
+
* Sorts by the count of records.
|
|
1366
1405
|
*/
|
|
1367
|
-
|
|
1406
|
+
_count?: OrderBy<Schema, Model, false, false>;
|
|
1368
1407
|
/**
|
|
1369
|
-
*
|
|
1408
|
+
* Sorts by the minimum value.
|
|
1370
1409
|
*/
|
|
1371
|
-
|
|
1410
|
+
_min?: MinMaxInput<Schema, Model, SortOrder>;
|
|
1372
1411
|
/**
|
|
1373
|
-
*
|
|
1412
|
+
* Sorts by the maximum value.
|
|
1374
1413
|
*/
|
|
1375
|
-
|
|
1414
|
+
_max?: MinMaxInput<Schema, Model, SortOrder>;
|
|
1415
|
+
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1376
1416
|
/**
|
|
1377
|
-
*
|
|
1417
|
+
* Sorts by the average value.
|
|
1378
1418
|
*/
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
validateCreateManyArgs(model: GetModels<Schema>, args: unknown): CreateManyArgs<Schema, GetModels<Schema>>;
|
|
1393
|
-
validateCreateManyAndReturnArgs(model: GetModels<Schema>, args: unknown): CreateManyAndReturnArgs<Schema, GetModels<Schema>> | undefined;
|
|
1394
|
-
validateUpdateArgs(model: GetModels<Schema>, args: unknown): UpdateArgs<Schema, GetModels<Schema>>;
|
|
1395
|
-
validateUpdateManyArgs(model: GetModels<Schema>, args: unknown): UpdateManyArgs<Schema, GetModels<Schema>>;
|
|
1396
|
-
validateUpdateManyAndReturnArgs(model: GetModels<Schema>, args: unknown): UpdateManyAndReturnArgs<Schema, GetModels<Schema>>;
|
|
1397
|
-
validateUpsertArgs(model: GetModels<Schema>, args: unknown): UpsertArgs<Schema, GetModels<Schema>>;
|
|
1398
|
-
validateDeleteArgs(model: GetModels<Schema>, args: unknown): DeleteArgs<Schema, GetModels<Schema>>;
|
|
1399
|
-
validateDeleteManyArgs(model: GetModels<Schema>, args: unknown): DeleteManyArgs<Schema, GetModels<Schema>> | undefined;
|
|
1400
|
-
validateCountArgs(model: GetModels<Schema>, args: unknown): CountArgs<Schema, GetModels<Schema>> | undefined;
|
|
1401
|
-
validateAggregateArgs(model: GetModels<Schema>, args: unknown): AggregateArgs<Schema, GetModels<Schema>>;
|
|
1402
|
-
validateGroupByArgs(model: GetModels<Schema>, args: unknown): GroupByArgs<Schema, GetModels<Schema>>;
|
|
1403
|
-
validateProcedureInput(proc: string, input: unknown): unknown;
|
|
1404
|
-
private validate;
|
|
1405
|
-
private mergePluginArgsSchema;
|
|
1406
|
-
private getPluginExtQueryArgsSchema;
|
|
1407
|
-
private makeFindSchema;
|
|
1408
|
-
private makeExistsSchema;
|
|
1409
|
-
private makeScalarSchema;
|
|
1410
|
-
private makeEnumSchema;
|
|
1411
|
-
private makeTypeDefSchema;
|
|
1412
|
-
private makeWhereSchema;
|
|
1413
|
-
private makeTypedJsonFilterSchema;
|
|
1414
|
-
private isTypeDefType;
|
|
1415
|
-
private makeEnumFilterSchema;
|
|
1416
|
-
private makeArrayFilterSchema;
|
|
1417
|
-
private internalMakeArrayFilterSchema;
|
|
1418
|
-
private makePrimitiveFilterSchema;
|
|
1419
|
-
private makeJsonValueSchema;
|
|
1420
|
-
private makeJsonFilterSchema;
|
|
1421
|
-
private makeDateTimeFilterSchema;
|
|
1422
|
-
private makeBooleanFilterSchema;
|
|
1423
|
-
private makeBytesFilterSchema;
|
|
1424
|
-
private makeCommonPrimitiveFilterComponents;
|
|
1425
|
-
private makeCommonPrimitiveFilterSchema;
|
|
1426
|
-
private makeNumberFilterSchema;
|
|
1427
|
-
private makeStringFilterSchema;
|
|
1428
|
-
private makeStringModeSchema;
|
|
1429
|
-
private makeSelectSchema;
|
|
1430
|
-
private makeCountSelectionSchema;
|
|
1431
|
-
private makeRelationSelectIncludeSchema;
|
|
1432
|
-
private makeOmitSchema;
|
|
1433
|
-
private makeIncludeSchema;
|
|
1434
|
-
private makeOrderBySchema;
|
|
1435
|
-
private makeDistinctSchema;
|
|
1436
|
-
private makeCursorSchema;
|
|
1437
|
-
private makeCreateSchema;
|
|
1438
|
-
private makeCreateManySchema;
|
|
1439
|
-
private makeCreateManyAndReturnSchema;
|
|
1440
|
-
private makeCreateDataSchema;
|
|
1441
|
-
private isDelegateDiscriminator;
|
|
1442
|
-
private makeRelationManipulationSchema;
|
|
1443
|
-
private makeSetDataSchema;
|
|
1444
|
-
private makeConnectDataSchema;
|
|
1445
|
-
private makeDisconnectDataSchema;
|
|
1446
|
-
private makeDeleteRelationDataSchema;
|
|
1447
|
-
private makeConnectOrCreateDataSchema;
|
|
1448
|
-
private makeCreateManyDataSchema;
|
|
1449
|
-
private makeUpdateSchema;
|
|
1450
|
-
private makeUpdateManySchema;
|
|
1451
|
-
private makeUpdateManyAndReturnSchema;
|
|
1452
|
-
private makeUpsertSchema;
|
|
1453
|
-
private makeUpdateDataSchema;
|
|
1454
|
-
private makeDeleteSchema;
|
|
1455
|
-
private makeDeleteManySchema;
|
|
1456
|
-
makeCountSchema(model: string): z.ZodOptional<z.ZodObject<z.core.$ZodLooseShape, z.core.$strict>>;
|
|
1457
|
-
private makeCountAggregateInputSchema;
|
|
1458
|
-
makeAggregateSchema(model: string): z.ZodOptional<z.ZodObject<z.core.$ZodLooseShape, z.core.$strict>>;
|
|
1459
|
-
makeSumAvgInputSchema(model: string): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
1460
|
-
makeMinMaxInputSchema(model: string): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
1461
|
-
private makeGroupBySchema;
|
|
1462
|
-
private onlyAggregationFields;
|
|
1463
|
-
private makeHavingSchema;
|
|
1464
|
-
private makeProcedureParamSchema;
|
|
1465
|
-
getCache(cacheKey: string): z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>> | undefined;
|
|
1466
|
-
setCache(cacheKey: string, schema: ZodType): Map<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
1467
|
-
private printCacheStats;
|
|
1468
|
-
private makeSkipSchema;
|
|
1469
|
-
private makeTakeSchema;
|
|
1470
|
-
private refineForSelectIncludeMutuallyExclusive;
|
|
1471
|
-
private refineForSelectOmitMutuallyExclusive;
|
|
1472
|
-
private nullableIf;
|
|
1473
|
-
private orArray;
|
|
1474
|
-
private isNumericField;
|
|
1475
|
-
private get providerSupportsCaseSensitivity();
|
|
1476
|
-
}
|
|
1477
|
-
|
|
1478
|
-
/**
|
|
1479
|
-
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1480
|
-
*/
|
|
1481
|
-
declare const CoreCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists"];
|
|
1482
|
-
/**
|
|
1483
|
-
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1484
|
-
*/
|
|
1485
|
-
type CoreCrudOperations = (typeof CoreCrudOperations)[number];
|
|
1486
|
-
/**
|
|
1487
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1488
|
-
*/
|
|
1489
|
-
declare const CoreReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists"];
|
|
1490
|
-
/**
|
|
1491
|
-
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1492
|
-
*/
|
|
1493
|
-
type CoreReadOperations = (typeof CoreReadOperations)[number];
|
|
1494
|
-
/**
|
|
1495
|
-
* List of core write operations.
|
|
1496
|
-
*/
|
|
1497
|
-
declare const CoreWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
1498
|
-
/**
|
|
1499
|
-
* List of core write operations.
|
|
1500
|
-
*/
|
|
1501
|
-
type CoreWriteOperations = (typeof CoreWriteOperations)[number];
|
|
1502
|
-
/**
|
|
1503
|
-
* List of core create operations.
|
|
1504
|
-
*/
|
|
1505
|
-
declare const CoreCreateOperations: readonly ["create", "createMany", "createManyAndReturn", "upsert"];
|
|
1506
|
-
/**
|
|
1507
|
-
* List of core create operations.
|
|
1508
|
-
*/
|
|
1509
|
-
type CoreCreateOperations = (typeof CoreCreateOperations)[number];
|
|
1510
|
-
/**
|
|
1511
|
-
* List of core update operations.
|
|
1512
|
-
*/
|
|
1513
|
-
declare const CoreUpdateOperations: readonly ["update", "updateMany", "updateManyAndReturn", "upsert"];
|
|
1514
|
-
/**
|
|
1515
|
-
* List of core update operations.
|
|
1516
|
-
*/
|
|
1517
|
-
type CoreUpdateOperations = (typeof CoreUpdateOperations)[number];
|
|
1518
|
-
/**
|
|
1519
|
-
* List of core delete operations.
|
|
1520
|
-
*/
|
|
1521
|
-
declare const CoreDeleteOperations: readonly ["delete", "deleteMany"];
|
|
1522
|
-
/**
|
|
1523
|
-
* List of core delete operations.
|
|
1524
|
-
*/
|
|
1525
|
-
type CoreDeleteOperations = (typeof CoreDeleteOperations)[number];
|
|
1526
|
-
/**
|
|
1527
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
1528
|
-
*/
|
|
1529
|
-
declare const AllCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1530
|
-
/**
|
|
1531
|
-
* List of all CRUD operations, including 'orThrow' variants.
|
|
1532
|
-
*/
|
|
1533
|
-
type AllCrudOperations = (typeof AllCrudOperations)[number];
|
|
1534
|
-
/**
|
|
1535
|
-
* List of all read operations, including 'orThrow' variants.
|
|
1536
|
-
*/
|
|
1537
|
-
declare const AllReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1538
|
-
/**
|
|
1539
|
-
* List of all read operations, including 'orThrow' variants.
|
|
1540
|
-
*/
|
|
1541
|
-
type AllReadOperations = (typeof AllReadOperations)[number];
|
|
1542
|
-
|
|
1543
|
-
type AllowedExtQueryArgKeys = CoreCrudOperations | '$create' | '$read' | '$update' | '$delete' | '$all';
|
|
1544
|
-
/**
|
|
1545
|
-
* Base shape of plugin-extended query args.
|
|
1546
|
-
*/
|
|
1547
|
-
type ExtQueryArgsBase = {
|
|
1548
|
-
[K in AllowedExtQueryArgKeys]?: object;
|
|
1419
|
+
_avg?: SumAvgInput<Schema, Model, SortOrder>;
|
|
1420
|
+
/**
|
|
1421
|
+
* Sorts by the sum value.
|
|
1422
|
+
*/
|
|
1423
|
+
_sum?: SumAvgInput<Schema, Model, SortOrder>;
|
|
1424
|
+
}) : {});
|
|
1425
|
+
type WhereUniqueInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = AtLeast<{
|
|
1426
|
+
[Key in keyof GetModel<Schema, Model>['uniqueFields']]?: GetModel<Schema, Model>['uniqueFields'][Key] extends Pick<FieldDef, 'type'> ? MapFieldDefType<Schema, GetModel<Schema, Model>['uniqueFields'][Key]> : {
|
|
1427
|
+
[Key1 in keyof GetModel<Schema, Model>['uniqueFields'][Key]]: GetModel<Schema, Model>['uniqueFields'][Key][Key1] extends Pick<FieldDef, 'type'> ? MapFieldDefType<Schema, GetModel<Schema, Model>['uniqueFields'][Key][Key1]> : never;
|
|
1428
|
+
};
|
|
1429
|
+
} & WhereInput<Schema, Model, Options>, Extract<keyof GetModel<Schema, Model>['uniqueFields'], string>>;
|
|
1430
|
+
type OmitInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1431
|
+
[Key in NonRelationFields<Schema, Model>]?: boolean;
|
|
1549
1432
|
};
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
/**
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1433
|
+
type SelectIncludeOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean, Options extends QueryOptions<Schema> = QueryOptions<Schema>, AllowRelation extends boolean = true> = {
|
|
1434
|
+
/**
|
|
1435
|
+
* Explicitly select fields and relations to be returned by the query.
|
|
1436
|
+
*/
|
|
1437
|
+
select?: SelectInput<Schema, Model, Options, AllowCount, AllowRelation> | null;
|
|
1438
|
+
/**
|
|
1439
|
+
* Explicitly omit fields from the query result.
|
|
1440
|
+
*/
|
|
1441
|
+
omit?: OmitInput<Schema, Model> | null;
|
|
1442
|
+
} & (AllowRelation extends true ? {
|
|
1443
|
+
/**
|
|
1444
|
+
* Specifies relations to be included in the query result. All scalar fields are included.
|
|
1445
|
+
*/
|
|
1446
|
+
include?: IncludeInput<Schema, Model, Options, AllowCount> | null;
|
|
1447
|
+
} : {});
|
|
1448
|
+
type SelectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, AllowCount extends boolean = true, AllowRelation extends boolean = true> = {
|
|
1449
|
+
[Key in NonRelationFields<Schema, Model>]?: boolean;
|
|
1450
|
+
} & (AllowRelation extends true ? IncludeInput<Schema, Model, Options, AllowCount> : {});
|
|
1451
|
+
type SelectCount<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = boolean | {
|
|
1452
|
+
/**
|
|
1453
|
+
* Selects specific relations to count.
|
|
1454
|
+
*/
|
|
1455
|
+
select: {
|
|
1456
|
+
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]?: boolean | {
|
|
1457
|
+
where: WhereInput<Schema, RelationFieldType<Schema, Model, Key>, Options, false>;
|
|
1458
|
+
};
|
|
1459
|
+
};
|
|
1460
|
+
};
|
|
1461
|
+
type IncludeInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, AllowCount extends boolean = true> = {
|
|
1462
|
+
[Key in RelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]?: boolean | FindArgs<Schema, RelationFieldType<Schema, Model, Key>, Options, FieldIsArray<Schema, Model, Key>, FieldIsArray<Schema, Model, Key> extends true ? true : ModelFieldIsOptional<Schema, Model, Key> extends true ? true : false>;
|
|
1463
|
+
} & (AllowCount extends true ? HasToManyRelations<Schema, Model> extends true ? {
|
|
1464
|
+
_count?: SelectCount<Schema, Model, Options>;
|
|
1465
|
+
} : {} : {});
|
|
1466
|
+
type Subset<T, U> = {
|
|
1467
|
+
[key in keyof T]: key extends keyof U ? T[key] : never;
|
|
1468
|
+
};
|
|
1469
|
+
type SelectSubset<T, U> = {
|
|
1470
|
+
[key in keyof T]: key extends keyof U ? T[key] : never;
|
|
1471
|
+
} & (T extends {
|
|
1472
|
+
select: any;
|
|
1473
|
+
include: any;
|
|
1474
|
+
} ? 'Please either choose `select` or `include`.' : T extends {
|
|
1475
|
+
select: any;
|
|
1476
|
+
omit: any;
|
|
1477
|
+
} ? 'Please either choose `select` or `omit`.' : {});
|
|
1478
|
+
type ToManyRelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = {
|
|
1479
|
+
every?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1480
|
+
some?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1481
|
+
none?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1482
|
+
};
|
|
1483
|
+
type ToOneRelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options> & {
|
|
1484
|
+
/**
|
|
1485
|
+
* Checks if the related record matches the specified filter.
|
|
1486
|
+
*/
|
|
1487
|
+
is?: NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
1488
|
+
/**
|
|
1489
|
+
* Checks if the related record does not match the specified filter.
|
|
1490
|
+
*/
|
|
1491
|
+
isNot?: NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
1492
|
+
}, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
1493
|
+
type RelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>, AllowedKinds extends FilterKind> = 'Relation' extends AllowedKinds ? FieldIsArray<Schema, Model, Field> extends true ? ToManyRelationFilter<Schema, Model, Field, Options> : ToOneRelationFilter<Schema, Model, Field, Options> : never;
|
|
1494
|
+
type MapModelFieldType<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = MapFieldDefType<Schema, GetModelField<Schema, Model, Field>>;
|
|
1495
|
+
type MapFieldDefType<Schema extends SchemaDef, T extends Pick<FieldDef, 'type' | 'optional' | 'array'>, Partial extends boolean = false> = WrapType<T['type'] extends GetEnums<Schema> ? keyof GetEnum<Schema, T['type']> : T['type'] extends GetTypeDefs<Schema> ? TypeDefResult<Schema, T['type'], Partial> & Record<string, unknown> : MapBaseType$1<T['type']>, T['optional'], T['array']>;
|
|
1496
|
+
type OptionalFieldsForCreate<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
1497
|
+
[Key in GetModelFields<Schema, Model> as ModelFieldIsOptional<Schema, Model, Key> extends true ? Key : FieldHasDefault<Schema, Model, Key> extends true ? Key : FieldIsArray<Schema, Model, Key> extends true ? Key : GetModelField<Schema, Model, Key>['updatedAt'] extends true | UpdatedAtInfo ? Key : never]: GetModelField<Schema, Model, Key>;
|
|
1498
|
+
};
|
|
1499
|
+
type GetRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'];
|
|
1500
|
+
type OppositeRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>> = FT extends GetModels<Schema> ? GetRelation<Schema, Model, Field> extends RelationInfo ? GetRelation<Schema, Model, Field>['opposite'] extends GetModelFields<Schema, FT> ? Schema['models'][FT]['fields'][GetRelation<Schema, Model, Field>['opposite']]['relation'] : never : never : never;
|
|
1501
|
+
type OppositeRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Opposite = OppositeRelation<Schema, Model, Field>> = Opposite extends RelationInfo ? (Opposite['fields'] extends readonly string[] ? Opposite['fields'] : []) : [];
|
|
1502
|
+
type OppositeRelationAndFK<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>, Relation = GetModelField<Schema, Model, Field>['relation'], Opposite = Relation extends RelationInfo ? Relation['opposite'] : never> = FT extends GetModels<Schema> ? Opposite extends GetModelFields<Schema, FT> ? Opposite | OppositeRelationFields<Schema, Model, Field>[number] : never : never;
|
|
1503
|
+
type FilterArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = {
|
|
1504
|
+
/**
|
|
1505
|
+
* Filter conditions
|
|
1506
|
+
*/
|
|
1507
|
+
where?: WhereInput<Schema, Model, Options>;
|
|
1508
|
+
};
|
|
1509
|
+
type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = {
|
|
1510
|
+
/**
|
|
1511
|
+
* Number of records to skip
|
|
1512
|
+
*/
|
|
1513
|
+
skip?: number;
|
|
1514
|
+
/**
|
|
1515
|
+
* Number of records to take
|
|
1516
|
+
*/
|
|
1517
|
+
take?: number;
|
|
1518
|
+
/**
|
|
1519
|
+
* Order by clauses
|
|
1520
|
+
*/
|
|
1521
|
+
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
1522
|
+
/**
|
|
1523
|
+
* Cursor for pagination
|
|
1524
|
+
*/
|
|
1525
|
+
cursor?: WhereUniqueInput<Schema, Model, Options>;
|
|
1526
|
+
};
|
|
1527
|
+
type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Collection extends boolean, AllowFilter extends boolean = true> = (Collection extends true ? SortAndTakeArgs<Schema, Model, Options> & (ProviderSupportsDistinct<Schema> extends true ? {
|
|
1528
|
+
/**
|
|
1529
|
+
* Distinct fields. Only supported by providers that natively support SQL "DISTINCT ON".
|
|
1530
|
+
*/
|
|
1531
|
+
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
1532
|
+
} : {}) : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model, Options> : {}) & SelectIncludeOmit<Schema, Model, Collection, Options>;
|
|
1533
|
+
type FindManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = FindArgs<Schema, Model, Options, true>;
|
|
1534
|
+
type FindFirstArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = FindArgs<Schema, Model, Options, true>;
|
|
1535
|
+
type ExistsArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = FilterArgs<Schema, Model, Options>;
|
|
1536
|
+
type FindUniqueArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1537
|
+
where: WhereUniqueInput<Schema, Model, Options>;
|
|
1538
|
+
} & SelectIncludeOmit<Schema, Model, true, Options>;
|
|
1539
|
+
type CreateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1540
|
+
data: CreateInput<Schema, Model, Options>;
|
|
1541
|
+
} & SelectIncludeOmit<Schema, Model, true, Options>;
|
|
1542
|
+
type CreateManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = CreateManyInput<Schema, Model>;
|
|
1543
|
+
type CreateManyAndReturnArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = CreateManyInput<Schema, Model> & SelectIncludeOmit<Schema, Model, false, Options, false>;
|
|
1544
|
+
type OptionalWrap<Schema extends SchemaDef, Model extends GetModels<Schema>, T extends object> = Optional<T, keyof T & OptionalFieldsForCreate<Schema, Model>>;
|
|
1545
|
+
type CreateScalarPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
1546
|
+
[Key in ScalarFields<Schema, Model, false> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]: ScalarCreatePayload<Schema, Model, Key>;
|
|
1547
|
+
}>;
|
|
1548
|
+
type ScalarCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends ScalarFields<Schema, Model, false>> = ScalarFieldMutationPayload<Schema, Model, Field> | (FieldIsArray<Schema, Model, Field> extends true ? {
|
|
1549
|
+
set?: MapModelFieldType<Schema, Model, Field>;
|
|
1550
|
+
} : never);
|
|
1551
|
+
type ScalarFieldMutationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = IsJsonField<Schema, Model, Field> extends true ? ModelFieldIsOptional<Schema, Model, Field> extends true ? JsonValue | JsonNull | DbNull : JsonValue | JsonNull : MapModelFieldType<Schema, Model, Field>;
|
|
1552
|
+
type IsJsonField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelFieldType<Schema, Model, Field> extends 'Json' ? true : false;
|
|
1553
|
+
type CreateFKPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
1554
|
+
[Key in ForeignKeyFields<Schema, Model>]: MapModelFieldType<Schema, Model, Key>;
|
|
1555
|
+
}>;
|
|
1556
|
+
type CreateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = Omit<{
|
|
1557
|
+
/**
|
|
1558
|
+
* Connects or create a related record.
|
|
1559
|
+
*/
|
|
1560
|
+
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field, Options>;
|
|
1561
|
+
/**
|
|
1562
|
+
* Creates a related record.
|
|
1563
|
+
*/
|
|
1564
|
+
create?: NestedCreateInput<Schema, Model, Field, Options>;
|
|
1565
|
+
/**
|
|
1566
|
+
* Creates a batch of related records.
|
|
1567
|
+
*/
|
|
1568
|
+
createMany?: NestedCreateManyInput<Schema, Model, Field>;
|
|
1569
|
+
/**
|
|
1570
|
+
* Connects an existing record.
|
|
1571
|
+
*/
|
|
1572
|
+
connect?: ConnectInput<Schema, Model, Field, Options>;
|
|
1573
|
+
}, (FieldIsArray<Schema, Model, Field> extends true ? never : 'createMany') | (FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' : never)>;
|
|
1574
|
+
type CreateRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = OptionalWrap<Schema, Model, {
|
|
1575
|
+
[Key in RelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]: CreateRelationFieldPayload<Schema, Model, Key, Options>;
|
|
1576
|
+
}>;
|
|
1577
|
+
type CreateWithFKInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = CreateScalarPayload<Schema, Model> & CreateFKPayload<Schema, Model> & CreateWithNonOwnedRelationPayload<Schema, Model, Options>;
|
|
1578
|
+
type CreateWithRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = CreateScalarPayload<Schema, Model> & CreateRelationPayload<Schema, Model, Options>;
|
|
1579
|
+
type CreateWithNonOwnedRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = OptionalWrap<Schema, Model, {
|
|
1580
|
+
[Key in NonOwnedRelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]: CreateRelationFieldPayload<Schema, Model, Key, Options>;
|
|
1581
|
+
}>;
|
|
1582
|
+
type ConnectOrCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = {
|
|
1583
|
+
/**
|
|
1584
|
+
* The unique filter to find an existing record to connect.
|
|
1585
|
+
*/
|
|
1586
|
+
where: WhereUniqueInput<Schema, Model, Options>;
|
|
1587
|
+
/**
|
|
1588
|
+
* The data to create a new record if no existing record is found.
|
|
1589
|
+
*/
|
|
1590
|
+
create: CreateInput<Schema, Model, Options, Without>;
|
|
1591
|
+
};
|
|
1592
|
+
type CreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
|
|
1593
|
+
/**
|
|
1594
|
+
* The data for the records to create.
|
|
1595
|
+
*/
|
|
1596
|
+
data: OrArray<Omit<CreateScalarPayload<Schema, Model>, Without> & Omit<CreateFKPayload<Schema, Model>, Without>>;
|
|
1597
|
+
/**
|
|
1598
|
+
* Specifies whether to skip creating records that would violate unique constraints.
|
|
1599
|
+
*/
|
|
1600
|
+
skipDuplicates?: boolean;
|
|
1601
|
+
};
|
|
1602
|
+
type CreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = XOR<Omit<CreateWithFKInput<Schema, Model, Options>, Without>, Omit<CreateWithRelationInput<Schema, Model, Options>, Without>>;
|
|
1603
|
+
type NestedCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = OrArray<CreateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>, FieldIsArray<Schema, Model, Field>>;
|
|
1604
|
+
type NestedCreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = CreateManyInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1605
|
+
type UpdateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1606
|
+
/**
|
|
1607
|
+
* The data to update the record with.
|
|
1608
|
+
*/
|
|
1609
|
+
data: UpdateInput<Schema, Model, Options>;
|
|
1610
|
+
/**
|
|
1611
|
+
* The unique filter to find the record to update.
|
|
1612
|
+
*/
|
|
1613
|
+
where: WhereUniqueInput<Schema, Model, Options>;
|
|
1614
|
+
} & SelectIncludeOmit<Schema, Model, true, Options>;
|
|
1615
|
+
type UpdateManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = UpdateManyPayload<Schema, Model, Options>;
|
|
1616
|
+
type UpdateManyAndReturnArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = UpdateManyPayload<Schema, Model, Options> & SelectIncludeOmit<Schema, Model, false, Options, false>;
|
|
1617
|
+
type UpdateManyPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Without extends string = never> = {
|
|
1618
|
+
/**
|
|
1619
|
+
* The data to update the records with.
|
|
1620
|
+
*/
|
|
1621
|
+
data: OrArray<UpdateScalarInput<Schema, Model, Without>>;
|
|
1622
|
+
/**
|
|
1623
|
+
* The filter to select records to update.
|
|
1624
|
+
*/
|
|
1625
|
+
where?: WhereInput<Schema, Model, Options>;
|
|
1626
|
+
/**
|
|
1627
|
+
* Limit the number of records to update.
|
|
1628
|
+
*/
|
|
1629
|
+
limit?: number;
|
|
1630
|
+
};
|
|
1631
|
+
type UpsertArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1632
|
+
/**
|
|
1633
|
+
* The data to create the record if it doesn't exist.
|
|
1634
|
+
*/
|
|
1635
|
+
create: CreateInput<Schema, Model, Options>;
|
|
1636
|
+
/**
|
|
1637
|
+
* The data to update the record with if it exists.
|
|
1638
|
+
*/
|
|
1639
|
+
update: UpdateInput<Schema, Model, Options>;
|
|
1640
|
+
/**
|
|
1641
|
+
* The unique filter to find the record to update.
|
|
1642
|
+
*/
|
|
1643
|
+
where: WhereUniqueInput<Schema, Model, Options>;
|
|
1644
|
+
} & SelectIncludeOmit<Schema, Model, true, Options>;
|
|
1645
|
+
type UpdateScalarInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{
|
|
1646
|
+
[Key in NonRelationFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]?: ScalarUpdatePayload<Schema, Model, Key>;
|
|
1647
|
+
}, Without>;
|
|
1648
|
+
type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> = ScalarFieldMutationPayload<Schema, Model, Field> | (Field extends NumericFields<Schema, Model> ? {
|
|
1649
|
+
/**
|
|
1650
|
+
* Sets the field to the specified value.
|
|
1651
|
+
*/
|
|
1652
|
+
set?: NullableIf<number, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
1653
|
+
/**
|
|
1654
|
+
* Increments the field by the specified value.
|
|
1655
|
+
*/
|
|
1656
|
+
increment?: number;
|
|
1657
|
+
/**
|
|
1658
|
+
* Decrements the field by the specified value.
|
|
1659
|
+
*/
|
|
1660
|
+
decrement?: number;
|
|
1559
1661
|
/**
|
|
1560
|
-
*
|
|
1662
|
+
* Multiplies the field by the specified value.
|
|
1561
1663
|
*/
|
|
1562
|
-
|
|
1664
|
+
multiply?: number;
|
|
1563
1665
|
/**
|
|
1564
|
-
*
|
|
1666
|
+
* Divides the field by the specified value.
|
|
1565
1667
|
*/
|
|
1566
|
-
|
|
1668
|
+
divide?: number;
|
|
1669
|
+
} : never) | (FieldIsArray<Schema, Model, Field> extends true ? {
|
|
1567
1670
|
/**
|
|
1568
|
-
*
|
|
1671
|
+
* Sets the field to the specified array.
|
|
1569
1672
|
*/
|
|
1570
|
-
|
|
1673
|
+
set?: MapModelFieldType<Schema, Model, Field>[];
|
|
1571
1674
|
/**
|
|
1572
|
-
*
|
|
1573
|
-
* @private
|
|
1675
|
+
* Appends the specified values to the array field.
|
|
1574
1676
|
*/
|
|
1575
|
-
|
|
1677
|
+
push?: OrArray<MapModelFieldType<Schema, Model, Field>, true>;
|
|
1678
|
+
} : never);
|
|
1679
|
+
type UpdateRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = Omit<{
|
|
1680
|
+
[Key in RelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]?: UpdateRelationFieldPayload<Schema, Model, Key, Options>;
|
|
1681
|
+
}, Without>;
|
|
1682
|
+
type UpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = UpdateScalarInput<Schema, Model, Without> & UpdateRelationInput<Schema, Model, Options, Without>;
|
|
1683
|
+
type UpdateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? ToManyRelationUpdateInput<Schema, Model, Field, Options> : ToOneRelationUpdateInput<Schema, Model, Field, Options>;
|
|
1684
|
+
type ToManyRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = Omit<{
|
|
1576
1685
|
/**
|
|
1577
|
-
*
|
|
1686
|
+
* Creates related records.
|
|
1578
1687
|
*/
|
|
1579
|
-
|
|
1688
|
+
create?: NestedCreateInput<Schema, Model, Field, Options>;
|
|
1580
1689
|
/**
|
|
1581
|
-
*
|
|
1690
|
+
* Creates a batch of related records.
|
|
1582
1691
|
*/
|
|
1583
|
-
|
|
1692
|
+
createMany?: NestedCreateManyInput<Schema, Model, Field>;
|
|
1584
1693
|
/**
|
|
1585
|
-
*
|
|
1694
|
+
* Connects existing records.
|
|
1586
1695
|
*/
|
|
1587
|
-
|
|
1696
|
+
connect?: ConnectInput<Schema, Model, Field, Options>;
|
|
1588
1697
|
/**
|
|
1589
|
-
*
|
|
1698
|
+
* Connects or create related records.
|
|
1590
1699
|
*/
|
|
1591
|
-
|
|
1700
|
+
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field, Options>;
|
|
1592
1701
|
/**
|
|
1593
|
-
*
|
|
1702
|
+
* Disconnects related records.
|
|
1594
1703
|
*/
|
|
1595
|
-
|
|
1596
|
-
[K in keyof ExtQueryArgs]: ZodType<ExtQueryArgs[K]>;
|
|
1597
|
-
};
|
|
1704
|
+
disconnect?: DisconnectInput<Schema, Model, Field, Options>;
|
|
1598
1705
|
/**
|
|
1599
|
-
*
|
|
1706
|
+
* Updates related records.
|
|
1600
1707
|
*/
|
|
1601
|
-
|
|
1602
|
-
}
|
|
1603
|
-
type AnyPlugin = RuntimePlugin<any, any, any>;
|
|
1604
|
-
/**
|
|
1605
|
-
* Defines a ZenStack runtime plugin.
|
|
1606
|
-
*/
|
|
1607
|
-
declare function definePlugin<Schema extends SchemaDef, const ExtQueryArgs extends ExtQueryArgsBase = {}, const ExtClientMembers extends Record<string, unknown> = {}>(plugin: RuntimePlugin<Schema, ExtQueryArgs, ExtClientMembers>): RuntimePlugin<any, ExtQueryArgs, ExtClientMembers>;
|
|
1608
|
-
type OnProcedureCallback<Schema extends SchemaDef> = (ctx: OnProcedureHookContext<Schema>) => Promise<unknown>;
|
|
1609
|
-
type OnProcedureHookContext<Schema extends SchemaDef> = {
|
|
1708
|
+
update?: NestedUpdateInput<Schema, Model, Field, Options>;
|
|
1610
1709
|
/**
|
|
1611
|
-
*
|
|
1710
|
+
* Upserts related records.
|
|
1612
1711
|
*/
|
|
1613
|
-
|
|
1712
|
+
upsert?: NestedUpsertInput<Schema, Model, Field, Options>;
|
|
1614
1713
|
/**
|
|
1615
|
-
*
|
|
1714
|
+
* Updates a batch of related records.
|
|
1616
1715
|
*/
|
|
1617
|
-
|
|
1716
|
+
updateMany?: NestedUpdateManyInput<Schema, Model, Field, Options>;
|
|
1618
1717
|
/**
|
|
1619
|
-
*
|
|
1620
|
-
*
|
|
1621
|
-
* The canonical shape is `{ args?: Record<string, unknown> }`.
|
|
1622
|
-
* When a procedure has required params, `args` is required.
|
|
1718
|
+
* Deletes related records.
|
|
1623
1719
|
*/
|
|
1624
|
-
|
|
1720
|
+
delete?: NestedDeleteInput<Schema, Model, Field, Options>;
|
|
1625
1721
|
/**
|
|
1626
|
-
*
|
|
1722
|
+
* Deletes a batch of related records.
|
|
1627
1723
|
*/
|
|
1628
|
-
|
|
1724
|
+
deleteMany?: NestedDeleteManyInput<Schema, Model, Field, Options>;
|
|
1629
1725
|
/**
|
|
1630
|
-
*
|
|
1726
|
+
* Sets the related records to the specified ones.
|
|
1631
1727
|
*/
|
|
1632
|
-
|
|
1728
|
+
set?: SetRelationInput<Schema, Model, Field, Options>;
|
|
1729
|
+
}, FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' | 'upsert' : never>;
|
|
1730
|
+
type ToOneRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = Omit<{
|
|
1731
|
+
/**
|
|
1732
|
+
* Creates a related record.
|
|
1733
|
+
*/
|
|
1734
|
+
create?: NestedCreateInput<Schema, Model, Field, Options>;
|
|
1735
|
+
/**
|
|
1736
|
+
* Connects an existing record.
|
|
1737
|
+
*/
|
|
1738
|
+
connect?: ConnectInput<Schema, Model, Field, Options>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Connects or create a related record.
|
|
1741
|
+
*/
|
|
1742
|
+
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field, Options>;
|
|
1743
|
+
/**
|
|
1744
|
+
* Updates the related record.
|
|
1745
|
+
*/
|
|
1746
|
+
update?: NestedUpdateInput<Schema, Model, Field, Options>;
|
|
1747
|
+
/**
|
|
1748
|
+
* Upserts the related record.
|
|
1749
|
+
*/
|
|
1750
|
+
upsert?: NestedUpsertInput<Schema, Model, Field, Options>;
|
|
1751
|
+
} & (ModelFieldIsOptional<Schema, Model, Field> extends true ? {
|
|
1752
|
+
/**
|
|
1753
|
+
* Disconnects the related record.
|
|
1754
|
+
*/
|
|
1755
|
+
disconnect?: DisconnectInput<Schema, Model, Field, Options>;
|
|
1756
|
+
/**
|
|
1757
|
+
* Deletes the related record.
|
|
1758
|
+
*/
|
|
1759
|
+
delete?: NestedDeleteInput<Schema, Model, Field, Options>;
|
|
1760
|
+
} : {}), FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'connectOrCreate' | 'upsert' : never>;
|
|
1761
|
+
type DeleteArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1762
|
+
/**
|
|
1763
|
+
* The unique filter to find the record to delete.
|
|
1764
|
+
*/
|
|
1765
|
+
where: WhereUniqueInput<Schema, Model, Options>;
|
|
1766
|
+
} & SelectIncludeOmit<Schema, Model, true, Options>;
|
|
1767
|
+
type DeleteManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1768
|
+
/**
|
|
1769
|
+
* Filter to select records to delete.
|
|
1770
|
+
*/
|
|
1771
|
+
where?: WhereInput<Schema, Model, Options>;
|
|
1772
|
+
/**
|
|
1773
|
+
* Limits the number of records to delete.
|
|
1774
|
+
*/
|
|
1775
|
+
limit?: number;
|
|
1633
1776
|
};
|
|
1634
|
-
type
|
|
1635
|
-
type OnQueryHookContext<Schema extends SchemaDef> = {
|
|
1777
|
+
type CountArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Omit<FindArgs<Schema, Model, Options, true>, 'select' | 'include' | 'distinct' | 'omit'> & {
|
|
1636
1778
|
/**
|
|
1637
|
-
*
|
|
1779
|
+
* Selects fields to count
|
|
1638
1780
|
*/
|
|
1639
|
-
|
|
1781
|
+
select?: CountAggregateInput<Schema, Model> | true;
|
|
1782
|
+
};
|
|
1783
|
+
type CountAggregateInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1784
|
+
[Key in NonRelationFields<Schema, Model>]?: true;
|
|
1785
|
+
} & {
|
|
1786
|
+
_all?: true;
|
|
1787
|
+
};
|
|
1788
|
+
type CountResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Args> = Args extends {
|
|
1789
|
+
select: infer S;
|
|
1790
|
+
} ? S extends true ? number : {
|
|
1791
|
+
[Key in keyof S]: number;
|
|
1792
|
+
} : number;
|
|
1793
|
+
type AggregateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1640
1794
|
/**
|
|
1641
|
-
*
|
|
1795
|
+
* Filter conditions
|
|
1642
1796
|
*/
|
|
1643
|
-
|
|
1797
|
+
where?: WhereInput<Schema, Model, Options>;
|
|
1644
1798
|
/**
|
|
1645
|
-
*
|
|
1799
|
+
* Number of records to skip for the aggregation
|
|
1646
1800
|
*/
|
|
1647
|
-
|
|
1801
|
+
skip?: number;
|
|
1648
1802
|
/**
|
|
1649
|
-
*
|
|
1650
|
-
* It takes the same arguments as the operation method.
|
|
1651
|
-
*
|
|
1652
|
-
* @param args The query arguments.
|
|
1803
|
+
* Number of records to take for the aggregation
|
|
1653
1804
|
*/
|
|
1654
|
-
|
|
1805
|
+
take?: number;
|
|
1655
1806
|
/**
|
|
1656
|
-
*
|
|
1807
|
+
* Order by clauses
|
|
1657
1808
|
*/
|
|
1658
|
-
|
|
1809
|
+
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
1810
|
+
} & {
|
|
1811
|
+
/**
|
|
1812
|
+
* Performs count aggregation.
|
|
1813
|
+
*/
|
|
1814
|
+
_count?: true | CountAggregateInput<Schema, Model>;
|
|
1815
|
+
/**
|
|
1816
|
+
* Performs minimum value aggregation.
|
|
1817
|
+
*/
|
|
1818
|
+
_min?: MinMaxInput<Schema, Model, true>;
|
|
1819
|
+
/**
|
|
1820
|
+
* Performs maximum value aggregation.
|
|
1821
|
+
*/
|
|
1822
|
+
_max?: MinMaxInput<Schema, Model, true>;
|
|
1823
|
+
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1824
|
+
/**
|
|
1825
|
+
* Performs average value aggregation.
|
|
1826
|
+
*/
|
|
1827
|
+
_avg?: SumAvgInput<Schema, Model, true>;
|
|
1828
|
+
/**
|
|
1829
|
+
* Performs sum value aggregation.
|
|
1830
|
+
*/
|
|
1831
|
+
_sum?: SumAvgInput<Schema, Model, true>;
|
|
1832
|
+
});
|
|
1833
|
+
type NumericFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
1834
|
+
[Key in GetModelFields<Schema, Model> as GetModelFieldType<Schema, Model, Key> extends 'Int' | 'Float' | 'BigInt' | 'Decimal' ? FieldIsArray<Schema, Model, Key> extends true ? never : Key : never]: GetModelField<Schema, Model, Key>;
|
|
1659
1835
|
};
|
|
1660
|
-
type
|
|
1836
|
+
type SumAvgInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ValueType> = {
|
|
1837
|
+
[Key in NumericFields<Schema, Model>]?: ValueType;
|
|
1838
|
+
};
|
|
1839
|
+
type MinMaxInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ValueType> = {
|
|
1840
|
+
[Key in GetModelFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? never : FieldIsRelation<Schema, Model, Key> extends true ? never : Key]?: ValueType;
|
|
1841
|
+
};
|
|
1842
|
+
type AggregateResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Args> = (Args extends {
|
|
1843
|
+
_count: infer Count;
|
|
1844
|
+
} ? {
|
|
1845
|
+
/**
|
|
1846
|
+
* Count aggregation result
|
|
1847
|
+
*/
|
|
1848
|
+
_count: AggCommonOutput<Count>;
|
|
1849
|
+
} : {}) & (Args extends {
|
|
1850
|
+
_sum: infer Sum;
|
|
1851
|
+
} ? {
|
|
1852
|
+
/**
|
|
1853
|
+
* Sum aggregation result
|
|
1854
|
+
*/
|
|
1855
|
+
_sum: AggCommonOutput<Sum>;
|
|
1856
|
+
} : {}) & (Args extends {
|
|
1857
|
+
_avg: infer Avg;
|
|
1858
|
+
} ? {
|
|
1859
|
+
/**
|
|
1860
|
+
* Average aggregation result
|
|
1861
|
+
*/
|
|
1862
|
+
_avg: AggCommonOutput<Avg>;
|
|
1863
|
+
} : {}) & (Args extends {
|
|
1864
|
+
_min: infer Min;
|
|
1865
|
+
} ? {
|
|
1866
|
+
/**
|
|
1867
|
+
* Minimum aggregation result
|
|
1868
|
+
*/
|
|
1869
|
+
_min: AggCommonOutput<Min>;
|
|
1870
|
+
} : {}) & (Args extends {
|
|
1871
|
+
_max: infer Max;
|
|
1872
|
+
} ? {
|
|
1873
|
+
/**
|
|
1874
|
+
* Maximum aggregation result
|
|
1875
|
+
*/
|
|
1876
|
+
_max: AggCommonOutput<Max>;
|
|
1877
|
+
} : {});
|
|
1878
|
+
type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
|
|
1879
|
+
[Key in keyof Input]: number;
|
|
1880
|
+
} : never;
|
|
1881
|
+
type GroupByHaving<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Omit<WhereInput<Schema, Model, Options, true, true>, '$expr'>;
|
|
1882
|
+
type GroupByArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = {
|
|
1883
|
+
/**
|
|
1884
|
+
* Filter conditions
|
|
1885
|
+
*/
|
|
1886
|
+
where?: WhereInput<Schema, Model, Options>;
|
|
1887
|
+
/**
|
|
1888
|
+
* Order by clauses
|
|
1889
|
+
*/
|
|
1890
|
+
orderBy?: OrArray<OrderBy<Schema, Model, false, true>>;
|
|
1891
|
+
/**
|
|
1892
|
+
* Fields to group by
|
|
1893
|
+
*/
|
|
1894
|
+
by: NonRelationFields<Schema, Model> | NonEmptyArray<NonRelationFields<Schema, Model>>;
|
|
1895
|
+
/**
|
|
1896
|
+
* Filter conditions for the grouped records
|
|
1897
|
+
*/
|
|
1898
|
+
having?: GroupByHaving<Schema, Model, Options>;
|
|
1899
|
+
/**
|
|
1900
|
+
* Number of records to take for grouping
|
|
1901
|
+
*/
|
|
1902
|
+
take?: number;
|
|
1903
|
+
/**
|
|
1904
|
+
* Number of records to skip for grouping
|
|
1905
|
+
*/
|
|
1906
|
+
skip?: number;
|
|
1907
|
+
/**
|
|
1908
|
+
* Performs count aggregation.
|
|
1909
|
+
*/
|
|
1910
|
+
_count?: true | CountAggregateInput<Schema, Model>;
|
|
1911
|
+
/**
|
|
1912
|
+
* Performs minimum value aggregation.
|
|
1913
|
+
*/
|
|
1914
|
+
_min?: MinMaxInput<Schema, Model, true>;
|
|
1915
|
+
/**
|
|
1916
|
+
* Performs maximum value aggregation.
|
|
1917
|
+
*/
|
|
1918
|
+
_max?: MinMaxInput<Schema, Model, true>;
|
|
1919
|
+
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1920
|
+
/**
|
|
1921
|
+
* Performs average value aggregation.
|
|
1922
|
+
*/
|
|
1923
|
+
_avg?: SumAvgInput<Schema, Model, true>;
|
|
1924
|
+
/**
|
|
1925
|
+
* Performs sum value aggregation.
|
|
1926
|
+
*/
|
|
1927
|
+
_sum?: SumAvgInput<Schema, Model, true>;
|
|
1928
|
+
});
|
|
1929
|
+
type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args extends {
|
|
1930
|
+
by: unknown;
|
|
1931
|
+
}> = Array<{
|
|
1932
|
+
[Key in NonRelationFields<Schema, Model> as Key extends ValueOfPotentialTuple<Args['by']> ? Key : never]: MapModelFieldType<Schema, Model, Key>;
|
|
1933
|
+
} & (Args extends {
|
|
1934
|
+
_count: infer Count;
|
|
1935
|
+
} ? {
|
|
1661
1936
|
/**
|
|
1662
|
-
*
|
|
1937
|
+
* Count aggregation result
|
|
1663
1938
|
*/
|
|
1664
|
-
|
|
1939
|
+
_count: AggCommonOutput<Count>;
|
|
1940
|
+
} : {}) & (Args extends {
|
|
1941
|
+
_avg: infer Avg;
|
|
1942
|
+
} ? {
|
|
1665
1943
|
/**
|
|
1666
|
-
*
|
|
1944
|
+
* Average aggregation result
|
|
1667
1945
|
*/
|
|
1668
|
-
|
|
1946
|
+
_avg: AggCommonOutput<Avg>;
|
|
1947
|
+
} : {}) & (Args extends {
|
|
1948
|
+
_sum: infer Sum;
|
|
1949
|
+
} ? {
|
|
1669
1950
|
/**
|
|
1670
|
-
*
|
|
1671
|
-
*
|
|
1672
|
-
* If set to `true`, if the mutation already runs inside a transaction, the callbacks are
|
|
1673
|
-
* executed immediately after the mutation within the transaction boundary. If the mutation
|
|
1674
|
-
* is not running inside a transaction, a new transaction is created to run both the mutation
|
|
1675
|
-
* and the callbacks.
|
|
1676
|
-
*
|
|
1677
|
-
* If set to `false`, the callbacks are executed after the mutation transaction is committed.
|
|
1678
|
-
*
|
|
1679
|
-
* Defaults to `false`.
|
|
1951
|
+
* Sum aggregation result
|
|
1680
1952
|
*/
|
|
1681
|
-
|
|
1682
|
-
}
|
|
1683
|
-
|
|
1953
|
+
_sum: AggCommonOutput<Sum>;
|
|
1954
|
+
} : {}) & (Args extends {
|
|
1955
|
+
_min: infer Min;
|
|
1956
|
+
} ? {
|
|
1684
1957
|
/**
|
|
1685
|
-
*
|
|
1958
|
+
* Minimum aggregation result
|
|
1686
1959
|
*/
|
|
1687
|
-
|
|
1960
|
+
_min: AggCommonOutput<Min>;
|
|
1961
|
+
} : {}) & (Args extends {
|
|
1962
|
+
_max: infer Max;
|
|
1963
|
+
} ? {
|
|
1688
1964
|
/**
|
|
1689
|
-
*
|
|
1965
|
+
* Maximum aggregation result
|
|
1690
1966
|
*/
|
|
1691
|
-
|
|
1967
|
+
_max: AggCommonOutput<Max>;
|
|
1968
|
+
} : {})>;
|
|
1969
|
+
type ConnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>> : WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1970
|
+
type ConnectOrCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<ConnectOrCreatePayload<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>> : ConnectOrCreatePayload<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1971
|
+
type DisconnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>, true> : boolean | WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1972
|
+
type SetRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>>;
|
|
1973
|
+
type NestedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<{
|
|
1692
1974
|
/**
|
|
1693
|
-
*
|
|
1975
|
+
* Unique filter to select the record to update.
|
|
1694
1976
|
*/
|
|
1695
|
-
|
|
1977
|
+
where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1696
1978
|
/**
|
|
1697
|
-
*
|
|
1698
|
-
* data between the before and after mutation hooks.
|
|
1979
|
+
* The data to update the record with.
|
|
1699
1980
|
*/
|
|
1700
|
-
|
|
1701
|
-
}
|
|
1702
|
-
type BeforeEntityMutationCallback<Schema extends SchemaDef> = (args: PluginBeforeEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
1703
|
-
type AfterEntityMutationCallback<Schema extends SchemaDef> = (args: PluginAfterEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
1704
|
-
type PluginBeforeEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
1981
|
+
data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1982
|
+
}, true> : XOR<{
|
|
1705
1983
|
/**
|
|
1706
|
-
*
|
|
1707
|
-
* within the same transaction context as the mutation.
|
|
1984
|
+
* Filter to select the record to update.
|
|
1708
1985
|
*/
|
|
1709
|
-
|
|
1986
|
+
where?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1710
1987
|
/**
|
|
1711
|
-
* The
|
|
1712
|
-
* from this client are executed within the same transaction as the mutation if the mutation is running
|
|
1713
|
-
* inside a transaction.
|
|
1714
|
-
*
|
|
1715
|
-
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
1988
|
+
* The data to update the record with.
|
|
1716
1989
|
*/
|
|
1717
|
-
|
|
1718
|
-
}
|
|
1719
|
-
type
|
|
1990
|
+
data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1991
|
+
}, UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
1992
|
+
type NestedUpsertInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = OrArray<{
|
|
1720
1993
|
/**
|
|
1721
|
-
*
|
|
1994
|
+
* Unique filter to select the record to update.
|
|
1722
1995
|
*/
|
|
1723
|
-
|
|
1996
|
+
where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1724
1997
|
/**
|
|
1725
|
-
* The
|
|
1726
|
-
* the `loadBeforeMutationEntities` function is called in that hook.
|
|
1998
|
+
* The data to create the record if it doesn't exist.
|
|
1727
1999
|
*/
|
|
1728
|
-
|
|
2000
|
+
create: CreateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1729
2001
|
/**
|
|
1730
|
-
* The
|
|
1731
|
-
* See {@link EntityMutationHooksDef.runAfterMutationWithinTransaction} for detailed transaction behavior.
|
|
1732
|
-
*
|
|
1733
|
-
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
2002
|
+
* The data to update the record with if it exists.
|
|
1734
2003
|
*/
|
|
1735
|
-
|
|
2004
|
+
update: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
2005
|
+
}, FieldIsArray<Schema, Model, Field>>;
|
|
2006
|
+
type NestedUpdateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = OrArray<UpdateManyPayload<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
2007
|
+
type NestedDeleteInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>, true> : boolean | WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
2008
|
+
type NestedDeleteManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = OrArray<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options, true>>;
|
|
2009
|
+
type GetProcedureNames<Schema extends SchemaDef> = Schema extends {
|
|
2010
|
+
procedures: Record<string, ProcedureDef>;
|
|
2011
|
+
} ? keyof Schema['procedures'] : never;
|
|
2012
|
+
type GetProcedureParams<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
2013
|
+
procedures: Record<string, ProcedureDef>;
|
|
2014
|
+
} ? Schema['procedures'][ProcName]['params'] : never;
|
|
2015
|
+
type GetProcedure<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
2016
|
+
procedures: Record<string, ProcedureDef>;
|
|
2017
|
+
} ? Schema['procedures'][ProcName] : never;
|
|
2018
|
+
type _OptionalProcedureParamNames<Params> = keyof {
|
|
2019
|
+
[K in keyof Params as Params[K] extends {
|
|
2020
|
+
optional: true;
|
|
2021
|
+
} ? K : never]: K;
|
|
1736
2022
|
};
|
|
1737
|
-
type
|
|
1738
|
-
|
|
2023
|
+
type _RequiredProcedureParamNames<Params> = keyof {
|
|
2024
|
+
[K in keyof Params as Params[K] extends {
|
|
2025
|
+
optional: true;
|
|
2026
|
+
} ? never : K]: K;
|
|
2027
|
+
};
|
|
2028
|
+
type _HasRequiredProcedureParams<Params> = _RequiredProcedureParamNames<Params> extends never ? false : true;
|
|
2029
|
+
type MapProcedureArgsObject<Schema extends SchemaDef, Params> = Simplify<Optional<{
|
|
2030
|
+
[K in keyof Params]: MapProcedureParam<Schema, Params[K]>;
|
|
2031
|
+
}, _OptionalProcedureParamNames<Params>>>;
|
|
2032
|
+
type ProcedureEnvelope<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>, Params = GetProcedureParams<Schema, ProcName>> = keyof Params extends never ? {
|
|
2033
|
+
args?: Record<string, never>;
|
|
2034
|
+
} : _HasRequiredProcedureParams<Params> extends true ? {
|
|
2035
|
+
args: MapProcedureArgsObject<Schema, Params>;
|
|
2036
|
+
} : {
|
|
2037
|
+
args?: MapProcedureArgsObject<Schema, Params>;
|
|
2038
|
+
};
|
|
2039
|
+
type ProcedureHandlerCtx<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = {
|
|
1739
2040
|
client: ClientContract<Schema>;
|
|
1740
|
-
|
|
1741
|
-
|
|
2041
|
+
} & ProcedureEnvelope<Schema, ProcName>;
|
|
2042
|
+
/**
|
|
2043
|
+
* Shape of a procedure's runtime function.
|
|
2044
|
+
*/
|
|
2045
|
+
type ProcedureFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (...args: _HasRequiredProcedureParams<GetProcedureParams<Schema, ProcName>> extends true ? [input: ProcedureEnvelope<Schema, ProcName>] : [input?: ProcedureEnvelope<Schema, ProcName>]) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
2046
|
+
/**
|
|
2047
|
+
* Signature for procedure handlers configured via client options.
|
|
2048
|
+
*/
|
|
2049
|
+
type ProcedureHandlerFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (ctx: ProcedureHandlerCtx<Schema, ProcName>) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
2050
|
+
type MapProcedureReturn<Schema extends SchemaDef, Proc> = Proc extends {
|
|
2051
|
+
returnType: infer R;
|
|
2052
|
+
} ? Proc extends {
|
|
2053
|
+
returnArray: true;
|
|
2054
|
+
} ? Array<MapType<Schema, R & string>> : MapType<Schema, R & string> : never;
|
|
2055
|
+
type MapProcedureParam<Schema extends SchemaDef, P> = P extends {
|
|
2056
|
+
type: infer U;
|
|
2057
|
+
} ? OrUndefinedIf<P extends {
|
|
2058
|
+
array: true;
|
|
2059
|
+
} ? Array<MapType<Schema, U & string>> : MapType<Schema, U & string>, P extends {
|
|
2060
|
+
optional: true;
|
|
2061
|
+
} ? true : false> : never;
|
|
2062
|
+
type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
2063
|
+
[Key in RelationFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends {
|
|
2064
|
+
references: readonly unknown[];
|
|
2065
|
+
} ? never : Key]: true;
|
|
1742
2066
|
};
|
|
1743
|
-
type
|
|
1744
|
-
|
|
2067
|
+
type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
2068
|
+
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: true;
|
|
2069
|
+
} extends never ? false : true;
|
|
2070
|
+
type EnumValue<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = GetEnum<Schema, Enum>[keyof GetEnum<Schema, Enum>];
|
|
2071
|
+
type MapType<Schema extends SchemaDef, T extends string> = T extends keyof TypeMap ? TypeMap[T] : T extends GetModels<Schema> ? ModelResult<Schema, T> : T extends GetTypeDefs<Schema> ? TypeDefResult<Schema, T> : T extends GetEnums<Schema> ? EnumValue<Schema, T> : unknown;
|
|
2072
|
+
type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
1745
2073
|
|
|
1746
2074
|
/**
|
|
1747
2075
|
* A promise that only executes when it's awaited or .then() is called.
|
|
@@ -1884,18 +2212,18 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
1884
2212
|
*/
|
|
1885
2213
|
$pushSchema(): Promise<void>;
|
|
1886
2214
|
} & {
|
|
1887
|
-
[Key in
|
|
1888
|
-
} & ProcedureOperations<Schema> & ExtClientMembers;
|
|
2215
|
+
[Key in GetSlicedModels<Schema, Options> as Uncapitalize<Key>]: ModelOperations<Schema, Key, Options, ExtQueryArgs>;
|
|
2216
|
+
} & ProcedureOperations<Schema, Options> & ExtClientMembers;
|
|
1889
2217
|
/**
|
|
1890
2218
|
* The contract for a client in a transaction.
|
|
1891
2219
|
*/
|
|
1892
2220
|
type TransactionClientContract<Schema extends SchemaDef, Options extends ClientOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase, ExtClientMembers extends ExtClientMembersBase> = Omit<ClientContract<Schema, Options, ExtQueryArgs, ExtClientMembers>, TransactionUnsupportedMethods>;
|
|
1893
|
-
type ProcedureOperations<Schema extends SchemaDef> = Schema['procedures'] extends Record<string, ProcedureDef> ? {
|
|
2221
|
+
type ProcedureOperations<Schema extends SchemaDef, Options extends ClientOptions<Schema> = ClientOptions<Schema>> = Schema['procedures'] extends Record<string, ProcedureDef> ? {
|
|
1894
2222
|
/**
|
|
1895
2223
|
* Custom procedures.
|
|
1896
2224
|
*/
|
|
1897
2225
|
$procs: {
|
|
1898
|
-
[Key in
|
|
2226
|
+
[Key in GetSlicedProcedures<Schema, Options>]: ProcedureFunc<Schema, Key>;
|
|
1899
2227
|
};
|
|
1900
2228
|
} : {};
|
|
1901
2229
|
/**
|
|
@@ -1920,6 +2248,9 @@ type CRUD_EXT = CRUD | 'post-update';
|
|
|
1920
2248
|
* Extended CRUD operations including 'post-update'.
|
|
1921
2249
|
*/
|
|
1922
2250
|
declare const CRUD_EXT: readonly ["create", "read", "update", "delete", "post-update"];
|
|
2251
|
+
type SliceOperations<T extends Record<string, unknown>, Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>> = Omit<{
|
|
2252
|
+
[Key in keyof T as Key extends GetSlicedOperations<Schema, Model, Options> ? Key : never]: T[Key];
|
|
2253
|
+
}, IsDelegateModel<Schema, Model> extends true ? OperationsIneligibleForDelegateModels : never>;
|
|
1923
2254
|
type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, ExtQueryArgs> = CommonModelOperations<Schema, Model, Options, ExtQueryArgs> & (Schema['provider']['type'] extends 'mysql' ? {} : {
|
|
1924
2255
|
/**
|
|
1925
2256
|
* Creates multiple entities and returns them.
|
|
@@ -1939,7 +2270,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
1939
2270
|
* });
|
|
1940
2271
|
* ```
|
|
1941
2272
|
*/
|
|
1942
|
-
createManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'createManyAndReturn'>>(args?: SelectSubset<T, CreateManyAndReturnArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'createManyAndReturn'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
2273
|
+
createManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'createManyAndReturn'>>(args?: SelectSubset<T, CreateManyAndReturnArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'createManyAndReturn'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
1943
2274
|
/**
|
|
1944
2275
|
* Updates multiple entities and returns them.
|
|
1945
2276
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -1962,7 +2293,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
1962
2293
|
* });
|
|
1963
2294
|
* ```
|
|
1964
2295
|
*/
|
|
1965
|
-
updateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'updateManyAndReturn'>>(args: Subset<T, UpdateManyAndReturnArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'updateManyAndReturn'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
2296
|
+
updateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'updateManyAndReturn'>>(args: Subset<T, UpdateManyAndReturnArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'updateManyAndReturn'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
1966
2297
|
});
|
|
1967
2298
|
type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, ExtQueryArgs> = {
|
|
1968
2299
|
/**
|
|
@@ -2046,35 +2377,35 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2046
2377
|
* }); // result: `{ _count: { posts: number } }`
|
|
2047
2378
|
* ```
|
|
2048
2379
|
*/
|
|
2049
|
-
findMany<T extends FindManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findMany'>>(args?: SelectSubset<T, FindManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findMany'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
2380
|
+
findMany<T extends FindManyArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findMany'>>(args?: SelectSubset<T, FindManyArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findMany'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
2050
2381
|
/**
|
|
2051
2382
|
* Returns a uniquely identified entity.
|
|
2052
2383
|
* @param args - query args
|
|
2053
2384
|
* @returns a single entity or null if not found
|
|
2054
2385
|
* @see {@link findMany}
|
|
2055
2386
|
*/
|
|
2056
|
-
findUnique<T extends FindUniqueArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
|
|
2387
|
+
findUnique<T extends FindUniqueArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
|
|
2057
2388
|
/**
|
|
2058
2389
|
* Returns a uniquely identified entity or throws `NotFoundError` if not found.
|
|
2059
2390
|
* @param args - query args
|
|
2060
2391
|
* @returns a single entity
|
|
2061
2392
|
* @see {@link findMany}
|
|
2062
2393
|
*/
|
|
2063
|
-
findUniqueOrThrow<T extends FindUniqueArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2394
|
+
findUniqueOrThrow<T extends FindUniqueArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findUnique'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2064
2395
|
/**
|
|
2065
2396
|
* Returns the first entity.
|
|
2066
2397
|
* @param args - query args
|
|
2067
2398
|
* @returns a single entity or null if not found
|
|
2068
2399
|
* @see {@link findMany}
|
|
2069
2400
|
*/
|
|
2070
|
-
findFirst<T extends FindFirstArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
|
|
2401
|
+
findFirst<T extends FindFirstArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
|
|
2071
2402
|
/**
|
|
2072
2403
|
* Returns the first entity or throws `NotFoundError` if not found.
|
|
2073
2404
|
* @param args - query args
|
|
2074
2405
|
* @returns a single entity
|
|
2075
2406
|
* @see {@link findMany}
|
|
2076
2407
|
*/
|
|
2077
|
-
findFirstOrThrow<T extends FindFirstArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2408
|
+
findFirstOrThrow<T extends FindFirstArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'findFirst'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2078
2409
|
/**
|
|
2079
2410
|
* Creates a new entity.
|
|
2080
2411
|
* @param args - create args
|
|
@@ -2127,7 +2458,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2127
2458
|
* });
|
|
2128
2459
|
* ```
|
|
2129
2460
|
*/
|
|
2130
|
-
create<T extends CreateArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'create'>>(args: SelectSubset<T, CreateArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'create'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2461
|
+
create<T extends CreateArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'create'>>(args: SelectSubset<T, CreateArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'create'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2131
2462
|
/**
|
|
2132
2463
|
* Creates multiple entities. Only scalar fields are allowed.
|
|
2133
2464
|
* @param args - create args
|
|
@@ -2271,7 +2602,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2271
2602
|
* });
|
|
2272
2603
|
* ```
|
|
2273
2604
|
*/
|
|
2274
|
-
update<T extends UpdateArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'update'>>(args: SelectSubset<T, UpdateArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'update'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2605
|
+
update<T extends UpdateArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'update'>>(args: SelectSubset<T, UpdateArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'update'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2275
2606
|
/**
|
|
2276
2607
|
* Updates multiple entities.
|
|
2277
2608
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2292,7 +2623,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2292
2623
|
* limit: 10
|
|
2293
2624
|
* });
|
|
2294
2625
|
*/
|
|
2295
|
-
updateMany<T extends UpdateManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'updateMany'>>(args: Subset<T, UpdateManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'updateMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2626
|
+
updateMany<T extends UpdateManyArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'updateMany'>>(args: Subset<T, UpdateManyArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'updateMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2296
2627
|
/**
|
|
2297
2628
|
* Creates or updates an entity.
|
|
2298
2629
|
* @param args - upsert args
|
|
@@ -2313,7 +2644,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2313
2644
|
* });
|
|
2314
2645
|
* ```
|
|
2315
2646
|
*/
|
|
2316
|
-
upsert<T extends UpsertArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'upsert'>>(args: SelectSubset<T, UpsertArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'upsert'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2647
|
+
upsert<T extends UpsertArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'upsert'>>(args: SelectSubset<T, UpsertArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'upsert'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2317
2648
|
/**
|
|
2318
2649
|
* Deletes a uniquely identifiable entity.
|
|
2319
2650
|
* @param args - delete args
|
|
@@ -2333,7 +2664,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2333
2664
|
* }); // result: `{ id: string; email: string }`
|
|
2334
2665
|
* ```
|
|
2335
2666
|
*/
|
|
2336
|
-
delete<T extends DeleteArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'delete'>>(args: SelectSubset<T, DeleteArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'delete'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2667
|
+
delete<T extends DeleteArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'delete'>>(args: SelectSubset<T, DeleteArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'delete'>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2337
2668
|
/**
|
|
2338
2669
|
* Deletes multiple entities.
|
|
2339
2670
|
* @param args - delete args
|
|
@@ -2353,7 +2684,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2353
2684
|
* });
|
|
2354
2685
|
* ```
|
|
2355
2686
|
*/
|
|
2356
|
-
deleteMany<T extends DeleteManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'deleteMany'>>(args?: Subset<T, DeleteManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'deleteMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2687
|
+
deleteMany<T extends DeleteManyArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'deleteMany'>>(args?: Subset<T, DeleteManyArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'deleteMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2357
2688
|
/**
|
|
2358
2689
|
* Counts rows or field values.
|
|
2359
2690
|
* @param args - count args
|
|
@@ -2372,7 +2703,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2372
2703
|
* select: { _all: true, email: true }
|
|
2373
2704
|
* }); // result: `{ _all: number, email: number }`
|
|
2374
2705
|
*/
|
|
2375
|
-
count<T extends CountArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'count'>>(args?: Subset<T, CountArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'count'>>): ZenStackPromise<Schema, Simplify<CountResult<Schema, Model, T>>>;
|
|
2706
|
+
count<T extends CountArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'count'>>(args?: Subset<T, CountArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'count'>>): ZenStackPromise<Schema, Simplify<CountResult<Schema, Model, T>>>;
|
|
2376
2707
|
/**
|
|
2377
2708
|
* Aggregates rows.
|
|
2378
2709
|
* @param args - aggregation args
|
|
@@ -2390,7 +2721,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2390
2721
|
* _max: { age: true }
|
|
2391
2722
|
* }); // result: `{ _count: number, _avg: { age: number }, ... }`
|
|
2392
2723
|
*/
|
|
2393
|
-
aggregate<T extends AggregateArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'aggregate'>>(args: Subset<T, AggregateArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'aggregate'>>): ZenStackPromise<Schema, Simplify<AggregateResult<Schema, Model, T>>>;
|
|
2724
|
+
aggregate<T extends AggregateArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'aggregate'>>(args: Subset<T, AggregateArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'aggregate'>>): ZenStackPromise<Schema, Simplify<AggregateResult<Schema, Model, T>>>;
|
|
2394
2725
|
/**
|
|
2395
2726
|
* Groups rows by columns.
|
|
2396
2727
|
* @param args - groupBy args
|
|
@@ -2424,7 +2755,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2424
2755
|
* having: { country: 'US', age: { _avg: { gte: 18 } } }
|
|
2425
2756
|
* });
|
|
2426
2757
|
*/
|
|
2427
|
-
groupBy<T extends GroupByArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'groupBy'>>(args: Subset<T, GroupByArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'groupBy'>>): ZenStackPromise<Schema, Simplify<GroupByResult<Schema, Model, T>>>;
|
|
2758
|
+
groupBy<T extends GroupByArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'groupBy'>>(args: Subset<T, GroupByArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'groupBy'>>): ZenStackPromise<Schema, Simplify<GroupByResult<Schema, Model, T>>>;
|
|
2428
2759
|
/**
|
|
2429
2760
|
* Checks if an entity exists.
|
|
2430
2761
|
* @param args - exists args
|
|
@@ -2442,10 +2773,10 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2442
2773
|
* where: { posts: { some: { published: true } } },
|
|
2443
2774
|
* }); // result: `boolean`
|
|
2444
2775
|
*/
|
|
2445
|
-
exists<T extends ExistsArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'exists'>>(args?: Subset<T, ExistsArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'exists'>>): ZenStackPromise<Schema, boolean>;
|
|
2776
|
+
exists<T extends ExistsArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'exists'>>(args?: Subset<T, ExistsArgs<Schema, Model, Options> & ExtractExtQueryArgs<ExtQueryArgs, 'exists'>>): ZenStackPromise<Schema, boolean>;
|
|
2446
2777
|
};
|
|
2447
2778
|
type OperationsIneligibleForDelegateModels = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert';
|
|
2448
|
-
type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends
|
|
2779
|
+
type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>, ExtQueryArgs = {}> = SliceOperations<AllModelOperations<Schema, Model, Options, ExtQueryArgs>, Schema, Model, Options>;
|
|
2449
2780
|
/**
|
|
2450
2781
|
* Type for auth context that includes both scalar and relation fields.
|
|
2451
2782
|
* Relations are recursively included to allow nested auth data like { user: { profile: { ... } } }
|
|
@@ -2455,117 +2786,6 @@ type AuthModelType<Schema extends SchemaDef, Model extends GetModels<Schema>> =
|
|
|
2455
2786
|
};
|
|
2456
2787
|
type AuthType<Schema extends SchemaDef> = Schema['authType'] extends GetModels<Schema> ? AuthModelType<Schema, Schema['authType']> : Schema['authType'] extends GetTypeDefs<Schema> ? TypeDefResult<Schema, Schema['authType'], true> : Record<string, unknown>;
|
|
2457
2788
|
|
|
2458
|
-
type ZModelFunctionContext<Schema extends SchemaDef> = {
|
|
2459
|
-
/**
|
|
2460
|
-
* ZenStack client instance
|
|
2461
|
-
*/
|
|
2462
|
-
client: ClientContract<Schema>;
|
|
2463
|
-
/**
|
|
2464
|
-
* Database dialect
|
|
2465
|
-
*/
|
|
2466
|
-
dialect: BaseCrudDialect<Schema>;
|
|
2467
|
-
/**
|
|
2468
|
-
* The containing model name
|
|
2469
|
-
*/
|
|
2470
|
-
model: GetModels<Schema>;
|
|
2471
|
-
/**
|
|
2472
|
-
* The alias name that can be used to refer to the containing model
|
|
2473
|
-
*/
|
|
2474
|
-
modelAlias: string;
|
|
2475
|
-
/**
|
|
2476
|
-
* The CRUD operation being performed
|
|
2477
|
-
*/
|
|
2478
|
-
operation: CRUD_EXT;
|
|
2479
|
-
};
|
|
2480
|
-
type ZModelFunction<Schema extends SchemaDef> = (eb: ExpressionBuilder<ToKyselySchema<Schema>, keyof ToKyselySchema<Schema>>, args: Expression<any>[], context: ZModelFunctionContext<Schema>) => Expression<unknown>;
|
|
2481
|
-
/**
|
|
2482
|
-
* ZenStack client options.
|
|
2483
|
-
*/
|
|
2484
|
-
type ClientOptions<Schema extends SchemaDef> = {
|
|
2485
|
-
/**
|
|
2486
|
-
* Kysely dialect.
|
|
2487
|
-
*/
|
|
2488
|
-
dialect: Dialect;
|
|
2489
|
-
/**
|
|
2490
|
-
* Custom function definitions.
|
|
2491
|
-
*
|
|
2492
|
-
* @private
|
|
2493
|
-
*/
|
|
2494
|
-
functions?: Record<string, ZModelFunction<Schema>>;
|
|
2495
|
-
/**
|
|
2496
|
-
* Plugins.
|
|
2497
|
-
*/
|
|
2498
|
-
plugins?: AnyPlugin[];
|
|
2499
|
-
/**
|
|
2500
|
-
* Logging configuration.
|
|
2501
|
-
*/
|
|
2502
|
-
log?: KyselyConfig['log'];
|
|
2503
|
-
/**
|
|
2504
|
-
* Whether to automatically fix timezone for `DateTime` fields returned by node-pg. Defaults
|
|
2505
|
-
* to `true`.
|
|
2506
|
-
*
|
|
2507
|
-
* Node-pg has a terrible quirk that it interprets the date value as local timezone (as a
|
|
2508
|
-
* `Date` object) although for `DateTime` field the data in DB is stored in UTC.
|
|
2509
|
-
* @see https://github.com/brianc/node-postgres/issues/429
|
|
2510
|
-
*/
|
|
2511
|
-
fixPostgresTimezone?: boolean;
|
|
2512
|
-
/**
|
|
2513
|
-
* Whether to enable input validations expressed with attributes like `@email`, `@regex`,
|
|
2514
|
-
* `@@validate`, etc. Defaults to `true`.
|
|
2515
|
-
*/
|
|
2516
|
-
validateInput?: boolean;
|
|
2517
|
-
/**
|
|
2518
|
-
* Options for omitting fields in ORM query results.
|
|
2519
|
-
*/
|
|
2520
|
-
omit?: OmitConfig<Schema>;
|
|
2521
|
-
/**
|
|
2522
|
-
* Whether to allow overriding omit settings at query time. Defaults to `true`. When set to
|
|
2523
|
-
* `false`, an `omit` clause that sets field to `false` (not omitting) will trigger a validation
|
|
2524
|
-
* error.
|
|
2525
|
-
*/
|
|
2526
|
-
allowQueryTimeOmitOverride?: boolean;
|
|
2527
|
-
} & (HasComputedFields<Schema> extends true ? {
|
|
2528
|
-
/**
|
|
2529
|
-
* Computed field definitions.
|
|
2530
|
-
*/
|
|
2531
|
-
computedFields: ComputedFieldsOptions<Schema>;
|
|
2532
|
-
} : {}) & (HasProcedures<Schema> extends true ? {
|
|
2533
|
-
/**
|
|
2534
|
-
* Custom procedure definitions.
|
|
2535
|
-
*/
|
|
2536
|
-
procedures: ProceduresOptions<Schema>;
|
|
2537
|
-
} : {});
|
|
2538
|
-
/**
|
|
2539
|
-
* Config for omitting fields in ORM query results.
|
|
2540
|
-
*/
|
|
2541
|
-
type OmitConfig<Schema extends SchemaDef> = {
|
|
2542
|
-
[Model in GetModels<Schema>]?: {
|
|
2543
|
-
[Field in GetModelFields<Schema, Model> as Field extends ScalarFields<Schema, Model> ? Field : never]?: boolean;
|
|
2544
|
-
};
|
|
2545
|
-
};
|
|
2546
|
-
type ComputedFieldsOptions<Schema extends SchemaDef> = {
|
|
2547
|
-
[Model in GetModels<Schema> as 'computedFields' extends keyof GetModel<Schema, Model> ? Model : never]: {
|
|
2548
|
-
[Field in keyof Schema['models'][Model]['computedFields']]: PrependParameter<ExpressionBuilder<ToKyselySchema<Schema>, Model>, Schema['models'][Model]['computedFields'][Field]>;
|
|
2549
|
-
};
|
|
2550
|
-
};
|
|
2551
|
-
type HasComputedFields<Schema extends SchemaDef> = string extends GetModels<Schema> ? false : keyof ComputedFieldsOptions<Schema> extends never ? false : true;
|
|
2552
|
-
type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
|
|
2553
|
-
procedures: Record<string, ProcedureDef>;
|
|
2554
|
-
} ? {
|
|
2555
|
-
[Key in GetProcedureNames<Schema>]: ProcedureHandlerFunc<Schema, Key>;
|
|
2556
|
-
} : {};
|
|
2557
|
-
type HasProcedures<Schema extends SchemaDef> = Schema extends {
|
|
2558
|
-
procedures: Record<string, ProcedureDef>;
|
|
2559
|
-
} ? true : false;
|
|
2560
|
-
/**
|
|
2561
|
-
* Subset of client options relevant to query operations.
|
|
2562
|
-
*/
|
|
2563
|
-
type QueryOptions<Schema extends SchemaDef> = Pick<ClientOptions<Schema>, 'omit'>;
|
|
2564
|
-
/**
|
|
2565
|
-
* Extract QueryOptions from ClientOptions
|
|
2566
|
-
*/
|
|
2567
|
-
type ToQueryOptions<T extends ClientOptions<any>> = Pick<T, 'omit'>;
|
|
2568
|
-
|
|
2569
2789
|
/**
|
|
2570
2790
|
* ZenStack ORM client.
|
|
2571
2791
|
*/
|
|
@@ -2718,7 +2938,7 @@ declare function extractIdFields(entity: any, schema: SchemaDef, model: string):
|
|
|
2718
2938
|
};
|
|
2719
2939
|
declare function getDiscriminatorField(schema: SchemaDef, model: string): string | undefined;
|
|
2720
2940
|
declare function getDelegateDescendantModels(schema: SchemaDef, model: string, collected?: Set<ModelDef>): ModelDef[];
|
|
2721
|
-
declare function aggregate(eb: ExpressionBuilder<any, any>, expr: Expression<any>, op:
|
|
2941
|
+
declare function aggregate(eb: ExpressionBuilder<any, any>, expr: Expression<any>, op: AggregateOperators): kysely.AggregateFunctionBuilder<any, any, string | number | bigint>;
|
|
2722
2942
|
/**
|
|
2723
2943
|
* Strips alias from the node if it exists.
|
|
2724
2944
|
*/
|
|
@@ -2810,4 +3030,4 @@ declare namespace schemaUtils {
|
|
|
2810
3030
|
export { schemaUtils_ExpressionVisitor as ExpressionVisitor, schemaUtils_MatchingExpressionVisitor as MatchingExpressionVisitor, type schemaUtils_VisitResult as VisitResult };
|
|
2811
3031
|
}
|
|
2812
3032
|
|
|
2813
|
-
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, AllCrudOperations, type AllModelOperations, AllReadOperations, AnyNull, AnyNullClass, type AnyPlugin, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type ExistsArgs, type ExtClientMembersBase, type ExtQueryArgsBase, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GetProcedure, type GetProcedureNames, type GetProcedureParams, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, InputValidator, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, type ModelOperations, type ModelResult, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitConfig, type OmitInput, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OnProcedureHookContext, type OperationsIneligibleForDelegateModels, type OrderBy, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureEnvelope, type ProcedureFunc, type ProcedureHandlerFunc, type ProcedureOperations, type ProceduresOptions, type ProceedKyselyQueryFunction, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SortOrder, type StringFilter, type Subset, type ToKysely, type
|
|
3033
|
+
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, AllCrudOperations, type AllModelOperations, AllReadOperations, AnyNull, AnyNullClass, type AnyPlugin, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type ExistsArgs, type ExtClientMembersBase, type ExtQueryArgsBase, type FilterKind, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GetAllIncludedOperations, type GetIncludedOperations, type GetProcedure, type GetProcedureNames, type GetProcedureParams, type GetQueryOptions, type GetSlicedFilterKindsForField, type GetSlicedModels, type GetSlicedOperations, type GetSlicedProcedures, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, InputValidator, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, type ModelOperations, type ModelResult, type ModelSlicingOptions, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitConfig, type OmitInput, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OnProcedureHookContext, type OperationsIneligibleForDelegateModels, type OrderBy, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureEnvelope, type ProcedureFunc, type ProcedureHandlerFunc, type ProcedureOperations, type ProceduresOptions, type ProceedKyselyQueryFunction, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SlicingOptions, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, definePlugin, getCrudDialect };
|