@zenstackhq/orm 3.2.1 → 3.3.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 +245 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1149 -1077
- package/dist/index.d.ts +1149 -1077
- package/dist/index.js +237 -93
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,78 @@
|
|
|
1
1
|
import * as _zenstackhq_schema from '@zenstackhq/schema';
|
|
2
|
-
import { SchemaDef,
|
|
2
|
+
import { SchemaDef, GetModels, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, NonRelationFields, FieldDef, GetEnums, GetEnum, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetModel, BuiltinType, GetTypeDefFieldType, TypeDefFieldIsArray, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, ProcedureDef, ModelDef, DataSourceProviderType, IsDelegateModel, Expression as Expression$1, LiteralExpression, ArrayExpression, FieldExpression, MemberExpression, BinaryExpression, UnaryExpression, CallExpression, 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, Generated, ExpressionBuilder, OperandExpression, SqlBool, SelectQueryBuilder, Expression, ExpressionWrapper, QueryId, RootOperationNode, QueryResult, UnknownRow, Dialect, KyselyConfig } from 'kysely';
|
|
5
5
|
import Decimal from 'decimal.js';
|
|
6
|
-
import { z } from 'zod';
|
|
6
|
+
import { z, ZodType } from 'zod';
|
|
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
|
+
};
|
|
7
76
|
|
|
8
77
|
declare class DefaultOperationNodeVisitor extends OperationNodeVisitor {
|
|
9
78
|
protected defaultVisit(node: OperationNode): void;
|
|
@@ -114,75 +183,6 @@ declare namespace kyselyUtils {
|
|
|
114
183
|
export { type kyselyUtils_AnyKysely as AnyKysely, kyselyUtils_DefaultOperationNodeVisitor as DefaultOperationNodeVisitor };
|
|
115
184
|
}
|
|
116
185
|
|
|
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
|
*/
|
|
@@ -197,118 +197,6 @@ declare const LOGICAL_COMBINATORS: readonly ["AND", "OR", "NOT"];
|
|
|
197
197
|
declare const AGGREGATE_OPERATORS: readonly ["_count", "_sum", "_avg", "_min", "_max"];
|
|
198
198
|
type AGGREGATE_OPERATORS = (typeof AGGREGATE_OPERATORS)[number];
|
|
199
199
|
|
|
200
|
-
declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
201
|
-
protected readonly schema: Schema;
|
|
202
|
-
protected readonly options: ClientOptions<Schema>;
|
|
203
|
-
protected eb: ExpressionBuilder<any, any>;
|
|
204
|
-
constructor(schema: Schema, options: ClientOptions<Schema>);
|
|
205
|
-
transformPrimitive(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
206
|
-
transformOutput(value: unknown, _type: BuiltinType, _array: boolean): unknown;
|
|
207
|
-
buildSelectModel(model: string, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
208
|
-
buildFilterSortTake(model: string, args: FindArgs<Schema, GetModels<Schema>, true>, query: SelectQueryBuilder<any, any, {}>, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
209
|
-
buildFilter(model: string, modelAlias: string, where: boolean | object | undefined): Expression<SqlBool>;
|
|
210
|
-
private buildCursorFilter;
|
|
211
|
-
private isLogicalCombinator;
|
|
212
|
-
protected buildCompositeFilter(model: string, modelAlias: string, key: (typeof LOGICAL_COMBINATORS)[number], payload: any): Expression<SqlBool>;
|
|
213
|
-
private buildRelationFilter;
|
|
214
|
-
private buildToOneRelationFilter;
|
|
215
|
-
private buildToManyRelationFilter;
|
|
216
|
-
private buildArrayFilter;
|
|
217
|
-
buildPrimitiveFilter(fieldRef: Expression<any>, fieldDef: FieldDef, payload: any): any;
|
|
218
|
-
private buildJsonFilter;
|
|
219
|
-
private buildPlainJsonFilter;
|
|
220
|
-
private buildTypedJsonFilter;
|
|
221
|
-
private buildTypedJsonArrayFilter;
|
|
222
|
-
private buildTypeJsonNonArrayFilter;
|
|
223
|
-
private buildJsonValueFilterClause;
|
|
224
|
-
private buildLiteralFilter;
|
|
225
|
-
private buildStandardFilter;
|
|
226
|
-
private buildStringFilter;
|
|
227
|
-
private buildJsonStringFilter;
|
|
228
|
-
private escapeLikePattern;
|
|
229
|
-
private buildStringLike;
|
|
230
|
-
private prepStringCasing;
|
|
231
|
-
private buildNumberFilter;
|
|
232
|
-
private buildBooleanFilter;
|
|
233
|
-
private buildDateTimeFilter;
|
|
234
|
-
private buildBytesFilter;
|
|
235
|
-
private buildEnumFilter;
|
|
236
|
-
buildOrderBy(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, orderBy: OrArray<OrderBy<Schema, GetModels<Schema>, boolean, boolean>> | undefined, negated: boolean): SelectQueryBuilder<any, any, any>;
|
|
237
|
-
buildSelectAllFields(model: string, query: SelectQueryBuilder<any, any, any>, omit: Record<string, boolean | undefined> | undefined | null, modelAlias: string): SelectQueryBuilder<any, any, any>;
|
|
238
|
-
shouldOmitField(omit: unknown, model: string, field: string): any;
|
|
239
|
-
protected buildModelSelect(model: GetModels<Schema>, subQueryAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, true>, selectAllFields: boolean): SelectQueryBuilder<any, any, {}>;
|
|
240
|
-
buildSelectField(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, field: string): SelectQueryBuilder<any, any, any>;
|
|
241
|
-
buildDelegateJoin(thisModel: string, thisModelAlias: string, otherModelAlias: string, query: SelectQueryBuilder<any, any, any>): SelectQueryBuilder<any, any, any>;
|
|
242
|
-
buildCountJson(model: string, eb: ExpressionBuilder<any, any>, parentAlias: string, payload: any): ExpressionWrapper<any, any, unknown>;
|
|
243
|
-
private negateSort;
|
|
244
|
-
true(): Expression<SqlBool>;
|
|
245
|
-
false(): Expression<SqlBool>;
|
|
246
|
-
isTrue(expression: Expression<SqlBool>): boolean;
|
|
247
|
-
isFalse(expression: Expression<SqlBool>): boolean;
|
|
248
|
-
and(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
249
|
-
or(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
250
|
-
not(...args: Expression<SqlBool>[]): ExpressionWrapper<any, any, SqlBool>;
|
|
251
|
-
fieldRef(model: string, field: string, modelAlias?: string, inlineComputedField?: boolean): any;
|
|
252
|
-
protected canJoinWithoutNestedSelect(modelDef: ModelDef, payload: boolean | FindArgs<Schema, GetModels<Schema>, true>): boolean;
|
|
253
|
-
abstract get provider(): DataSourceProviderType;
|
|
254
|
-
/**
|
|
255
|
-
* Builds selection for a relation field.
|
|
256
|
-
*/
|
|
257
|
-
abstract buildRelationSelection(query: SelectQueryBuilder<any, any, any>, model: string, relationField: string, parentAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, true>): SelectQueryBuilder<any, any, any>;
|
|
258
|
-
/**
|
|
259
|
-
* Builds skip and take clauses.
|
|
260
|
-
*/
|
|
261
|
-
abstract buildSkipTake(query: SelectQueryBuilder<any, any, any>, skip: number | undefined, take: number | undefined): SelectQueryBuilder<any, any, any>;
|
|
262
|
-
/**
|
|
263
|
-
* Builds an Kysely expression that returns a JSON object for the given key-value pairs.
|
|
264
|
-
*/
|
|
265
|
-
abstract buildJsonObject(value: Record<string, Expression<unknown>>): ExpressionWrapper<any, any, unknown>;
|
|
266
|
-
/**
|
|
267
|
-
* Builds an Kysely expression that returns the length of an array.
|
|
268
|
-
*/
|
|
269
|
-
abstract buildArrayLength(array: Expression<unknown>): ExpressionWrapper<any, any, number>;
|
|
270
|
-
/**
|
|
271
|
-
* Builds an array literal SQL string for the given values.
|
|
272
|
-
*/
|
|
273
|
-
abstract buildArrayLiteralSQL(values: unknown[]): string;
|
|
274
|
-
/**
|
|
275
|
-
* Whether the dialect supports updating with a limit on the number of updated rows.
|
|
276
|
-
*/
|
|
277
|
-
abstract get supportsUpdateWithLimit(): boolean;
|
|
278
|
-
/**
|
|
279
|
-
* Whether the dialect supports deleting with a limit on the number of deleted rows.
|
|
280
|
-
*/
|
|
281
|
-
abstract get supportsDeleteWithLimit(): boolean;
|
|
282
|
-
/**
|
|
283
|
-
* Whether the dialect supports DISTINCT ON.
|
|
284
|
-
*/
|
|
285
|
-
abstract get supportsDistinctOn(): boolean;
|
|
286
|
-
/**
|
|
287
|
-
* Whether the dialect support inserting with `DEFAULT` as field value.
|
|
288
|
-
*/
|
|
289
|
-
abstract get supportInsertWithDefault(): boolean;
|
|
290
|
-
/**
|
|
291
|
-
* Gets the SQL column type for the given field definition.
|
|
292
|
-
*/
|
|
293
|
-
abstract getFieldSqlType(fieldDef: FieldDef): string;
|
|
294
|
-
abstract getStringCasingBehavior(): {
|
|
295
|
-
supportsILike: boolean;
|
|
296
|
-
likeCaseSensitive: boolean;
|
|
297
|
-
};
|
|
298
|
-
/**
|
|
299
|
-
* Builds a JSON path selection expression.
|
|
300
|
-
*/
|
|
301
|
-
protected abstract buildJsonPathSelection(receiver: Expression<any>, path: string | undefined): Expression<any>;
|
|
302
|
-
/**
|
|
303
|
-
* Builds a JSON array filter expression.
|
|
304
|
-
*/
|
|
305
|
-
protected abstract buildJsonArrayFilter(receiver: Expression<any>, operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown): Expression<SqlBool>;
|
|
306
|
-
/**
|
|
307
|
-
* Builds a JSON array exists predicate (returning if any element matches the filter).
|
|
308
|
-
*/
|
|
309
|
-
protected abstract buildJsonArrayExistsPredicate(receiver: Expression<any>, buildFilter: (elem: Expression<any>) => Expression<SqlBool>): Expression<SqlBool>;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
200
|
type ToKyselySchema<Schema extends SchemaDef> = {
|
|
313
201
|
[Model in GetModels<Schema>]: ToKyselyTable<Schema, Model>;
|
|
314
202
|
};
|
|
@@ -321,478 +209,256 @@ type WrapNull<T, Null> = Null extends true ? T | null : T;
|
|
|
321
209
|
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>>;
|
|
322
210
|
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>;
|
|
323
211
|
|
|
324
|
-
|
|
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
|
-
|
|
375
|
-
private makeCountSelectionSchema;
|
|
376
|
-
private makeRelationSelectIncludeSchema;
|
|
377
|
-
private makeOmitSchema;
|
|
378
|
-
private makeIncludeSchema;
|
|
379
|
-
private makeOrderBySchema;
|
|
380
|
-
private makeDistinctSchema;
|
|
381
|
-
private makeCursorSchema;
|
|
382
|
-
private makeCreateSchema;
|
|
383
|
-
private makeCreateManySchema;
|
|
384
|
-
private makeCreateManyAndReturnSchema;
|
|
385
|
-
private makeCreateDataSchema;
|
|
386
|
-
private isDelegateDiscriminator;
|
|
387
|
-
private makeRelationManipulationSchema;
|
|
388
|
-
private makeSetDataSchema;
|
|
389
|
-
private makeConnectDataSchema;
|
|
390
|
-
private makeDisconnectDataSchema;
|
|
391
|
-
private makeDeleteRelationDataSchema;
|
|
392
|
-
private makeConnectOrCreateDataSchema;
|
|
393
|
-
private makeCreateManyDataSchema;
|
|
394
|
-
private makeUpdateSchema;
|
|
395
|
-
private makeUpdateManySchema;
|
|
396
|
-
private makeUpdateManyAndReturnSchema;
|
|
397
|
-
private makeUpsertSchema;
|
|
398
|
-
private makeUpdateDataSchema;
|
|
399
|
-
private makeDeleteSchema;
|
|
400
|
-
private makeDeleteManySchema;
|
|
401
|
-
makeCountSchema(model: GetModels<Schema>): z.ZodOptional<z.ZodObject<{
|
|
402
|
-
where: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
403
|
-
skip: z.ZodOptional<z.ZodNumber>;
|
|
404
|
-
take: z.ZodOptional<z.ZodNumber>;
|
|
405
|
-
orderBy: z.ZodOptional<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>> | z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>, z.ZodArray<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>>]>>;
|
|
406
|
-
select: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
407
|
-
_all: z.ZodOptional<z.ZodLiteral<true>>;
|
|
408
|
-
}, z.core.$strict>]>>;
|
|
409
|
-
}, z.core.$strip>>;
|
|
410
|
-
private makeCountAggregateInputSchema;
|
|
411
|
-
makeAggregateSchema(model: GetModels<Schema>): z.ZodOptional<z.ZodObject<{
|
|
412
|
-
where: z.ZodOptional<z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>;
|
|
413
|
-
skip: z.ZodOptional<z.ZodNumber>;
|
|
414
|
-
take: z.ZodOptional<z.ZodNumber>;
|
|
415
|
-
orderBy: z.ZodOptional<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>> | z.ZodOptional<z.ZodUnion<readonly [z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>, z.ZodArray<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>>]>>;
|
|
416
|
-
_count: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<true>, z.ZodObject<{
|
|
417
|
-
_all: z.ZodOptional<z.ZodLiteral<true>>;
|
|
418
|
-
}, z.core.$strict>]>>;
|
|
419
|
-
_avg: z.ZodOptional<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>>;
|
|
420
|
-
_sum: z.ZodOptional<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>>;
|
|
421
|
-
_min: z.ZodOptional<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>>;
|
|
422
|
-
_max: z.ZodOptional<z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>>;
|
|
423
|
-
}, z.core.$strip>>;
|
|
424
|
-
makeSumAvgInputSchema(model: GetModels<Schema>): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
425
|
-
makeMinMaxInputSchema(model: GetModels<Schema>): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
426
|
-
private makeGroupBySchema;
|
|
427
|
-
private onlyAggregationFields;
|
|
428
|
-
private makeHavingSchema;
|
|
429
|
-
private makeSkipSchema;
|
|
430
|
-
private makeTakeSchema;
|
|
431
|
-
private refineForSelectIncludeMutuallyExclusive;
|
|
432
|
-
private refineForSelectOmitMutuallyExclusive;
|
|
433
|
-
private nullableIf;
|
|
434
|
-
private orArray;
|
|
435
|
-
private isNumericField;
|
|
436
|
-
private get providerSupportsCaseSensitivity();
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
type CoreCrudOperation = 'findMany' | 'findUnique' | 'findFirst' | 'create' | 'createMany' | 'createManyAndReturn' | 'update' | 'updateMany' | 'updateManyAndReturn' | 'upsert' | 'delete' | 'deleteMany' | 'count' | 'aggregate' | 'groupBy' | 'exists';
|
|
440
|
-
type AllCrudOperation = CoreCrudOperation | 'findUniqueOrThrow' | 'findFirstOrThrow';
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* ZenStack runtime plugin.
|
|
444
|
-
*/
|
|
445
|
-
interface RuntimePlugin<Schema extends SchemaDef = SchemaDef> {
|
|
212
|
+
type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Omit = undefined, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<{
|
|
213
|
+
[Key in NonRelationFields<Schema, Model> as ShouldOmitField<Schema, Model, Options, Key, Omit> extends true ? never : Key]: MapModelFieldType<Schema, Model, Key>;
|
|
214
|
+
}, Optional, Array>;
|
|
215
|
+
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>;
|
|
216
|
+
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;
|
|
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> | ({
|
|
446
263
|
/**
|
|
447
|
-
*
|
|
264
|
+
* Checks for equality with the specified enum value.
|
|
448
265
|
*/
|
|
449
|
-
|
|
266
|
+
equals?: NullableIf<keyof GetEnum<Schema, T>, Nullable>;
|
|
450
267
|
/**
|
|
451
|
-
*
|
|
268
|
+
* Checks if the enum value is in the specified list of values.
|
|
452
269
|
*/
|
|
453
|
-
|
|
270
|
+
in?: (keyof GetEnum<Schema, T>)[];
|
|
454
271
|
/**
|
|
455
|
-
*
|
|
272
|
+
* Checks if the enum value is not in the specified list of values.
|
|
456
273
|
*/
|
|
457
|
-
|
|
274
|
+
notIn?: (keyof GetEnum<Schema, T>)[];
|
|
458
275
|
/**
|
|
459
|
-
*
|
|
460
|
-
* @private
|
|
276
|
+
* Builds a negated filter.
|
|
461
277
|
*/
|
|
462
|
-
|
|
278
|
+
not?: EnumFilter<Schema, T, Nullable, WithAggregations>;
|
|
279
|
+
} & (WithAggregations extends true ? {
|
|
463
280
|
/**
|
|
464
|
-
*
|
|
281
|
+
* Filters against the count of records.
|
|
465
282
|
*/
|
|
466
|
-
|
|
283
|
+
_count?: NumberFilter<'Int', false, false>;
|
|
467
284
|
/**
|
|
468
|
-
*
|
|
285
|
+
* Filters against the minimum value.
|
|
469
286
|
*/
|
|
470
|
-
|
|
287
|
+
_min?: EnumFilter<Schema, T, false, false>;
|
|
471
288
|
/**
|
|
472
|
-
*
|
|
289
|
+
* Filters against the maximum value.
|
|
473
290
|
*/
|
|
474
|
-
|
|
291
|
+
_max?: EnumFilter<Schema, T, false, false>;
|
|
292
|
+
} : {}));
|
|
293
|
+
type ArrayFilter<Schema extends SchemaDef, Type extends string> = {
|
|
475
294
|
/**
|
|
476
|
-
*
|
|
295
|
+
* Checks if the array equals the specified array.
|
|
477
296
|
*/
|
|
478
|
-
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* Defines a ZenStack runtime plugin.
|
|
482
|
-
*/
|
|
483
|
-
declare function definePlugin<Schema extends SchemaDef>(plugin: RuntimePlugin<Schema>): RuntimePlugin<Schema>;
|
|
484
|
-
|
|
485
|
-
type OnProcedureCallback<Schema extends SchemaDef> = (ctx: OnProcedureHookContext<Schema>) => Promise<unknown>;
|
|
486
|
-
type OnProcedureHookContext<Schema extends SchemaDef> = {
|
|
297
|
+
equals?: MapScalarType<Schema, Type>[] | null;
|
|
487
298
|
/**
|
|
488
|
-
*
|
|
299
|
+
* Checks if the array contains all elements of the specified array.
|
|
489
300
|
*/
|
|
490
|
-
|
|
301
|
+
has?: MapScalarType<Schema, Type> | null;
|
|
491
302
|
/**
|
|
492
|
-
*
|
|
303
|
+
* Checks if the array contains any of the elements of the specified array.
|
|
493
304
|
*/
|
|
494
|
-
|
|
305
|
+
hasEvery?: MapScalarType<Schema, Type>[];
|
|
495
306
|
/**
|
|
496
|
-
*
|
|
497
|
-
*
|
|
498
|
-
* The canonical shape is `{ args?: Record<string, unknown> }`.
|
|
499
|
-
* When a procedure has required params, `args` is required.
|
|
307
|
+
* Checks if the array contains some of the elements of the specified array.
|
|
500
308
|
*/
|
|
501
|
-
|
|
309
|
+
hasSome?: MapScalarType<Schema, Type>[];
|
|
502
310
|
/**
|
|
503
|
-
*
|
|
311
|
+
* Checks if the array is empty.
|
|
504
312
|
*/
|
|
505
|
-
|
|
313
|
+
isEmpty?: boolean;
|
|
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> = {
|
|
506
318
|
/**
|
|
507
|
-
*
|
|
319
|
+
* Checks for equality with the specified value.
|
|
508
320
|
*/
|
|
509
|
-
|
|
510
|
-
};
|
|
511
|
-
type OnQueryCallback<Schema extends SchemaDef> = (ctx: OnQueryHookContext<Schema>) => Promise<unknown>;
|
|
512
|
-
type OnQueryHookContext<Schema extends SchemaDef> = {
|
|
321
|
+
equals?: NullableIf<DataType, Nullable>;
|
|
513
322
|
/**
|
|
514
|
-
*
|
|
323
|
+
* Checks if the value is in the specified list of values.
|
|
515
324
|
*/
|
|
516
|
-
|
|
325
|
+
in?: DataType[];
|
|
517
326
|
/**
|
|
518
|
-
*
|
|
327
|
+
* Checks if the value is not in the specified list of values.
|
|
519
328
|
*/
|
|
520
|
-
|
|
329
|
+
notIn?: DataType[];
|
|
521
330
|
/**
|
|
522
|
-
*
|
|
331
|
+
* Checks if the value is less than the specified value.
|
|
523
332
|
*/
|
|
524
|
-
|
|
333
|
+
lt?: DataType;
|
|
525
334
|
/**
|
|
526
|
-
*
|
|
527
|
-
* It takes the same arguments as the operation method.
|
|
528
|
-
*
|
|
529
|
-
* @param args The query arguments.
|
|
335
|
+
* Checks if the value is less than or equal to the specified value.
|
|
530
336
|
*/
|
|
531
|
-
|
|
337
|
+
lte?: DataType;
|
|
532
338
|
/**
|
|
533
|
-
*
|
|
339
|
+
* Checks if the value is greater than the specified value.
|
|
534
340
|
*/
|
|
535
|
-
|
|
536
|
-
};
|
|
537
|
-
type EntityMutationHooksDef<Schema extends SchemaDef> = {
|
|
341
|
+
gt?: DataType;
|
|
538
342
|
/**
|
|
539
|
-
*
|
|
343
|
+
* Checks if the value is greater than or equal to the specified value.
|
|
540
344
|
*/
|
|
541
|
-
|
|
345
|
+
gte?: DataType;
|
|
542
346
|
/**
|
|
543
|
-
*
|
|
347
|
+
* Checks if the value is between the specified values (inclusive).
|
|
544
348
|
*/
|
|
545
|
-
|
|
349
|
+
between?: [start: DataType, end: DataType];
|
|
546
350
|
/**
|
|
547
|
-
*
|
|
548
|
-
*
|
|
549
|
-
* If set to `true`, if the mutation already runs inside a transaction, the callbacks are
|
|
550
|
-
* executed immediately after the mutation within the transaction boundary. If the mutation
|
|
551
|
-
* is not running inside a transaction, a new transaction is created to run both the mutation
|
|
552
|
-
* and the callbacks.
|
|
553
|
-
*
|
|
554
|
-
* If set to `false`, the callbacks are executed after the mutation transaction is committed.
|
|
555
|
-
*
|
|
556
|
-
* Defaults to `false`.
|
|
351
|
+
* Builds a negated filter.
|
|
557
352
|
*/
|
|
558
|
-
|
|
353
|
+
not?: PrimitiveFilter<T, Nullable, WithAggregations>;
|
|
559
354
|
};
|
|
560
|
-
type
|
|
355
|
+
type StringFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<string, Nullable> | (CommonPrimitiveFilter<string, 'String', Nullable, WithAggregations> & {
|
|
561
356
|
/**
|
|
562
|
-
*
|
|
357
|
+
* Checks if the string contains the specified substring.
|
|
563
358
|
*/
|
|
564
|
-
|
|
565
|
-
/**
|
|
566
|
-
* The mutation action that is being performed.
|
|
567
|
-
*/
|
|
568
|
-
action: 'create' | 'update' | 'delete';
|
|
569
|
-
/**
|
|
570
|
-
* The mutation data. Only available for create and update actions.
|
|
571
|
-
*/
|
|
572
|
-
queryNode: OperationNode;
|
|
573
|
-
/**
|
|
574
|
-
* A query ID that uniquely identifies the mutation operation. You can use it to correlate
|
|
575
|
-
* data between the before and after mutation hooks.
|
|
576
|
-
*/
|
|
577
|
-
queryId: QueryId;
|
|
578
|
-
};
|
|
579
|
-
type BeforeEntityMutationCallback<Schema extends SchemaDef> = (args: PluginBeforeEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
580
|
-
type AfterEntityMutationCallback<Schema extends SchemaDef> = (args: PluginAfterEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
581
|
-
type PluginBeforeEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
359
|
+
contains?: string;
|
|
582
360
|
/**
|
|
583
|
-
*
|
|
584
|
-
* within the same transaction context as the mutation.
|
|
361
|
+
* Checks if the string starts with the specified substring.
|
|
585
362
|
*/
|
|
586
|
-
|
|
363
|
+
startsWith?: string;
|
|
587
364
|
/**
|
|
588
|
-
*
|
|
589
|
-
* from this client are executed within the same transaction as the mutation if the mutation is running
|
|
590
|
-
* inside a transaction.
|
|
591
|
-
*
|
|
592
|
-
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
365
|
+
* Checks if the string ends with the specified substring.
|
|
593
366
|
*/
|
|
594
|
-
|
|
595
|
-
};
|
|
596
|
-
type PluginAfterEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
367
|
+
endsWith?: string;
|
|
597
368
|
/**
|
|
598
|
-
*
|
|
369
|
+
* Specifies the string comparison mode. Not effective for "sqlite" provider
|
|
599
370
|
*/
|
|
600
|
-
|
|
371
|
+
mode?: 'default' | 'insensitive';
|
|
372
|
+
} & (WithAggregations extends true ? {
|
|
601
373
|
/**
|
|
602
|
-
*
|
|
603
|
-
* See {@link EntityMutationHooksDef.runAfterMutationWithinTransaction} for detailed transaction behavior.
|
|
604
|
-
*
|
|
605
|
-
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
374
|
+
* Filters against the count of records.
|
|
606
375
|
*/
|
|
607
|
-
|
|
608
|
-
};
|
|
609
|
-
type OnKyselyQueryArgs<Schema extends SchemaDef> = {
|
|
610
|
-
schema: SchemaDef;
|
|
611
|
-
client: ClientContract<Schema>;
|
|
612
|
-
query: RootOperationNode;
|
|
613
|
-
proceed: ProceedKyselyQueryFunction;
|
|
614
|
-
};
|
|
615
|
-
type ProceedKyselyQueryFunction = (query: RootOperationNode) => Promise<QueryResult<any>>;
|
|
616
|
-
type OnKyselyQueryCallback<Schema extends SchemaDef> = (args: OnKyselyQueryArgs<Schema>) => Promise<QueryResult<UnknownRow>>;
|
|
617
|
-
|
|
618
|
-
type ZModelFunctionContext<Schema extends SchemaDef> = {
|
|
376
|
+
_count?: NumberFilter<'Int', false, false>;
|
|
619
377
|
/**
|
|
620
|
-
*
|
|
378
|
+
* Filters against the minimum value.
|
|
621
379
|
*/
|
|
622
|
-
|
|
380
|
+
_min?: StringFilter<false, false>;
|
|
623
381
|
/**
|
|
624
|
-
*
|
|
382
|
+
* Filters against the maximum value.
|
|
625
383
|
*/
|
|
626
|
-
|
|
384
|
+
_max?: StringFilter<false, false>;
|
|
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 ? {
|
|
627
387
|
/**
|
|
628
|
-
*
|
|
388
|
+
* Filters against the count of records.
|
|
629
389
|
*/
|
|
630
|
-
|
|
390
|
+
_count?: NumberFilter<'Int', false, false>;
|
|
631
391
|
/**
|
|
632
|
-
*
|
|
392
|
+
* Filters against the average value.
|
|
633
393
|
*/
|
|
634
|
-
|
|
394
|
+
_avg?: NumberFilter<T, false, false>;
|
|
635
395
|
/**
|
|
636
|
-
*
|
|
396
|
+
* Filters against the sum value.
|
|
637
397
|
*/
|
|
638
|
-
|
|
639
|
-
};
|
|
640
|
-
type ZModelFunction<Schema extends SchemaDef> = (eb: ExpressionBuilder<ToKyselySchema<Schema>, keyof ToKyselySchema<Schema>>, args: Expression<any>[], context: ZModelFunctionContext<Schema>) => Expression<unknown>;
|
|
641
|
-
/**
|
|
642
|
-
* ZenStack client options.
|
|
643
|
-
*/
|
|
644
|
-
type ClientOptions<Schema extends SchemaDef> = {
|
|
398
|
+
_sum?: NumberFilter<T, false, false>;
|
|
645
399
|
/**
|
|
646
|
-
*
|
|
400
|
+
* Filters against the minimum value.
|
|
647
401
|
*/
|
|
648
|
-
|
|
402
|
+
_min?: NumberFilter<T, false, false>;
|
|
649
403
|
/**
|
|
650
|
-
*
|
|
651
|
-
*
|
|
652
|
-
* @private
|
|
404
|
+
* Filters against the maximum value.
|
|
653
405
|
*/
|
|
654
|
-
|
|
406
|
+
_max?: NumberFilter<T, false, false>;
|
|
407
|
+
} : {}));
|
|
408
|
+
type DateTimeFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Date | string, Nullable> | (CommonPrimitiveFilter<Date | string, 'DateTime', Nullable, WithAggregations> & (WithAggregations extends true ? {
|
|
655
409
|
/**
|
|
656
|
-
*
|
|
410
|
+
* Filters against the count of records.
|
|
657
411
|
*/
|
|
658
|
-
|
|
412
|
+
_count?: NumberFilter<'Int', false, false>;
|
|
659
413
|
/**
|
|
660
|
-
*
|
|
414
|
+
* Filters against the minimum value.
|
|
661
415
|
*/
|
|
662
|
-
|
|
416
|
+
_min?: DateTimeFilter<false, false>;
|
|
663
417
|
/**
|
|
664
|
-
*
|
|
665
|
-
* to `true`.
|
|
666
|
-
*
|
|
667
|
-
* Node-pg has a terrible quirk that it interprets the date value as local timezone (as a
|
|
668
|
-
* `Date` object) although for `DateTime` field the data in DB is stored in UTC.
|
|
669
|
-
* @see https://github.com/brianc/node-postgres/issues/429
|
|
418
|
+
* Filters against the maximum value.
|
|
670
419
|
*/
|
|
671
|
-
|
|
420
|
+
_max?: DateTimeFilter<false, false>;
|
|
421
|
+
} : {}));
|
|
422
|
+
type BytesFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Uint8Array | Buffer, Nullable> | ({
|
|
672
423
|
/**
|
|
673
|
-
*
|
|
674
|
-
* `@@validate`, etc. Defaults to `true`.
|
|
424
|
+
* Checks for equality with the specified value.
|
|
675
425
|
*/
|
|
676
|
-
|
|
426
|
+
equals?: NullableIf<Uint8Array, Nullable>;
|
|
677
427
|
/**
|
|
678
|
-
*
|
|
428
|
+
* Checks if the value is in the specified list of values.
|
|
679
429
|
*/
|
|
680
|
-
|
|
430
|
+
in?: Uint8Array[];
|
|
681
431
|
/**
|
|
682
|
-
*
|
|
683
|
-
* `false`, an `omit` clause that sets field to `false` (not omitting) will trigger a validation
|
|
684
|
-
* error.
|
|
432
|
+
* Checks if the value is not in the specified list of values.
|
|
685
433
|
*/
|
|
686
|
-
|
|
687
|
-
} & (HasComputedFields<Schema> extends true ? {
|
|
434
|
+
notIn?: Uint8Array[];
|
|
688
435
|
/**
|
|
689
|
-
*
|
|
436
|
+
* Builds a negated filter.
|
|
690
437
|
*/
|
|
691
|
-
|
|
692
|
-
}
|
|
438
|
+
not?: BytesFilter<Nullable, WithAggregations>;
|
|
439
|
+
} & (WithAggregations extends true ? {
|
|
693
440
|
/**
|
|
694
|
-
*
|
|
441
|
+
* Filters against the count of records.
|
|
695
442
|
*/
|
|
696
|
-
|
|
697
|
-
} : {});
|
|
698
|
-
/**
|
|
699
|
-
* Options for omitting fields in ORM query results.
|
|
700
|
-
*/
|
|
701
|
-
type OmitOptions<Schema extends SchemaDef> = {
|
|
702
|
-
[Model in GetModels<Schema>]?: {
|
|
703
|
-
[Field in GetModelFields<Schema, Model> as Field extends ScalarFields<Schema, Model> ? Field : never]?: boolean;
|
|
704
|
-
};
|
|
705
|
-
};
|
|
706
|
-
type ComputedFieldsOptions<Schema extends SchemaDef> = {
|
|
707
|
-
[Model in GetModels<Schema> as 'computedFields' extends keyof GetModel<Schema, Model> ? Model : never]: {
|
|
708
|
-
[Field in keyof Schema['models'][Model]['computedFields']]: PrependParameter<ExpressionBuilder<ToKyselySchema<Schema>, Model>, Schema['models'][Model]['computedFields'][Field]>;
|
|
709
|
-
};
|
|
710
|
-
};
|
|
711
|
-
type HasComputedFields<Schema extends SchemaDef> = string extends GetModels<Schema> ? false : keyof ComputedFieldsOptions<Schema> extends never ? false : true;
|
|
712
|
-
type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
|
|
713
|
-
procedures: Record<string, ProcedureDef>;
|
|
714
|
-
} ? {
|
|
715
|
-
[Key in GetProcedureNames<Schema>]: ProcedureHandlerFunc<Schema, Key>;
|
|
716
|
-
} : {};
|
|
717
|
-
type HasProcedures<Schema extends SchemaDef> = Schema extends {
|
|
718
|
-
procedures: Record<string, ProcedureDef>;
|
|
719
|
-
} ? true : false;
|
|
720
|
-
/**
|
|
721
|
-
* Subset of client options relevant to query operations.
|
|
722
|
-
*/
|
|
723
|
-
type QueryOptions<Schema extends SchemaDef> = Pick<ClientOptions<Schema>, 'omit'>;
|
|
724
|
-
/**
|
|
725
|
-
* Extract QueryOptions from ClientOptions
|
|
726
|
-
*/
|
|
727
|
-
type ToQueryOptions<T extends ClientOptions<any>> = Pick<T, 'omit'>;
|
|
728
|
-
|
|
729
|
-
type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Omit = undefined, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<{
|
|
730
|
-
[Key in NonRelationFields<Schema, Model> as ShouldOmitField<Schema, Model, Options, Key, Omit> extends true ? never : Key]: MapModelFieldType<Schema, Model, Key>;
|
|
731
|
-
}, Optional, Array>;
|
|
732
|
-
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>;
|
|
733
|
-
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;
|
|
734
|
-
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;
|
|
735
|
-
type SchemaLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['omit'] extends true ? true : false;
|
|
736
|
-
type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Select, Omit, Options extends QueryOptions<Schema>> = {
|
|
737
|
-
[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;
|
|
738
|
-
};
|
|
739
|
-
type SelectCountResult<Schema extends SchemaDef, Model extends GetModels<Schema>, C> = C extends true ? {
|
|
740
|
-
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: number;
|
|
741
|
-
} : C extends {
|
|
742
|
-
select: infer S;
|
|
743
|
-
} ? {
|
|
744
|
-
[Key in keyof S]: number;
|
|
745
|
-
} : never;
|
|
746
|
-
type ModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<Args extends {
|
|
747
|
-
select: infer S extends object;
|
|
748
|
-
omit?: infer O extends object;
|
|
749
|
-
} & Record<string, unknown> ? ModelSelectResult<Schema, Model, S, O, Options> : Args extends {
|
|
750
|
-
include: infer I extends object;
|
|
751
|
-
omit?: infer O extends object;
|
|
752
|
-
} & Record<string, unknown> ? // select all non-omitted scalar fields
|
|
753
|
-
DefaultModelResult<Schema, Model, O, Options, false, false> & {
|
|
754
|
-
[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>>;
|
|
755
|
-
} & ('_count' extends keyof I ? I['_count'] extends false | undefined ? {} : {
|
|
756
|
-
_count: SelectCountResult<Schema, Model, I['_count']>;
|
|
757
|
-
} : {}) : Args extends {
|
|
758
|
-
omit: infer O;
|
|
759
|
-
} & Record<string, unknown> ? DefaultModelResult<Schema, Model, O, Options, false, false> : DefaultModelResult<Schema, Model, undefined, Options, false, false>, Optional, Array>;
|
|
760
|
-
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>>;
|
|
761
|
-
type SimplifiedPlainResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Simplify<ModelResult<Schema, Model, Args, Options, false, false>>;
|
|
762
|
-
type TypeDefResult<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Partial extends boolean = false> = PartialIf<Optional<{
|
|
763
|
-
[Key in GetTypeDefFields<Schema, TypeDef>]: MapFieldDefType<Schema, GetTypeDefField<Schema, TypeDef, Key>, Partial>;
|
|
764
|
-
}, Partial extends true ? never : keyof {
|
|
765
|
-
[Key in GetTypeDefFields<Schema, TypeDef> as TypeDefFieldIsOptional<Schema, TypeDef, Key> extends true ? Key : never]: true;
|
|
766
|
-
}>, Partial> & Record<string, unknown>;
|
|
767
|
-
type BatchResult = {
|
|
768
|
-
count: number;
|
|
769
|
-
};
|
|
770
|
-
type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ScalarOnly extends boolean = false, WithAggregations extends boolean = false> = {
|
|
771
|
-
[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>;
|
|
772
|
-
} & {
|
|
773
|
-
$expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
|
|
774
|
-
} & {
|
|
775
|
-
AND?: OrArray<WhereInput<Schema, Model, ScalarOnly>>;
|
|
776
|
-
OR?: WhereInput<Schema, Model, ScalarOnly>[];
|
|
777
|
-
NOT?: OrArray<WhereInput<Schema, Model, ScalarOnly>>;
|
|
778
|
-
};
|
|
779
|
-
type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable extends boolean, WithAggregations extends boolean> = NullableIf<keyof GetEnum<Schema, T>, Nullable> | ({
|
|
443
|
+
_count?: NumberFilter<'Int', false, false>;
|
|
780
444
|
/**
|
|
781
|
-
*
|
|
445
|
+
* Filters against the minimum value.
|
|
782
446
|
*/
|
|
783
|
-
|
|
447
|
+
_min?: BytesFilter<false, false>;
|
|
784
448
|
/**
|
|
785
|
-
*
|
|
449
|
+
* Filters against the maximum value.
|
|
786
450
|
*/
|
|
787
|
-
|
|
451
|
+
_max?: BytesFilter<false, false>;
|
|
452
|
+
} : {}));
|
|
453
|
+
type BooleanFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<boolean, Nullable> | ({
|
|
788
454
|
/**
|
|
789
|
-
* Checks
|
|
455
|
+
* Checks for equality with the specified value.
|
|
790
456
|
*/
|
|
791
|
-
|
|
457
|
+
equals?: NullableIf<boolean, Nullable>;
|
|
792
458
|
/**
|
|
793
459
|
* Builds a negated filter.
|
|
794
460
|
*/
|
|
795
|
-
not?:
|
|
461
|
+
not?: BooleanFilter<Nullable, WithAggregations>;
|
|
796
462
|
} & (WithAggregations extends true ? {
|
|
797
463
|
/**
|
|
798
464
|
* Filters against the count of records.
|
|
@@ -801,204 +467,25 @@ type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable e
|
|
|
801
467
|
/**
|
|
802
468
|
* Filters against the minimum value.
|
|
803
469
|
*/
|
|
804
|
-
_min?:
|
|
470
|
+
_min?: BooleanFilter<false, false>;
|
|
805
471
|
/**
|
|
806
472
|
* Filters against the maximum value.
|
|
807
473
|
*/
|
|
808
|
-
_max?:
|
|
474
|
+
_max?: BooleanFilter<false, false>;
|
|
809
475
|
} : {}));
|
|
810
|
-
type
|
|
476
|
+
type JsonFilter = {
|
|
811
477
|
/**
|
|
812
|
-
*
|
|
478
|
+
* JSON path to select the value to filter on. If omitted, the whole JSON value is used.
|
|
813
479
|
*/
|
|
814
|
-
|
|
480
|
+
path?: string;
|
|
815
481
|
/**
|
|
816
|
-
* Checks
|
|
482
|
+
* Checks for equality with the specified value.
|
|
817
483
|
*/
|
|
818
|
-
|
|
484
|
+
equals?: JsonValue | JsonNullValues;
|
|
819
485
|
/**
|
|
820
|
-
*
|
|
486
|
+
* Builds a negated filter.
|
|
821
487
|
*/
|
|
822
|
-
|
|
823
|
-
/**
|
|
824
|
-
* Checks if the array contains some of the elements of the specified array.
|
|
825
|
-
*/
|
|
826
|
-
hasSome?: MapScalarType<Schema, Type>[];
|
|
827
|
-
/**
|
|
828
|
-
* Checks if the array is empty.
|
|
829
|
-
*/
|
|
830
|
-
isEmpty?: boolean;
|
|
831
|
-
};
|
|
832
|
-
type MapScalarType<Schema extends SchemaDef, Type extends string> = Type extends GetEnums<Schema> ? keyof GetEnum<Schema, Type> : MapBaseType$1<Type>;
|
|
833
|
-
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;
|
|
834
|
-
type CommonPrimitiveFilter<DataType, T extends BuiltinType, Nullable extends boolean, WithAggregations extends boolean> = {
|
|
835
|
-
/**
|
|
836
|
-
* Checks for equality with the specified value.
|
|
837
|
-
*/
|
|
838
|
-
equals?: NullableIf<DataType, Nullable>;
|
|
839
|
-
/**
|
|
840
|
-
* Checks if the value is in the specified list of values.
|
|
841
|
-
*/
|
|
842
|
-
in?: DataType[];
|
|
843
|
-
/**
|
|
844
|
-
* Checks if the value is not in the specified list of values.
|
|
845
|
-
*/
|
|
846
|
-
notIn?: DataType[];
|
|
847
|
-
/**
|
|
848
|
-
* Checks if the value is less than the specified value.
|
|
849
|
-
*/
|
|
850
|
-
lt?: DataType;
|
|
851
|
-
/**
|
|
852
|
-
* Checks if the value is less than or equal to the specified value.
|
|
853
|
-
*/
|
|
854
|
-
lte?: DataType;
|
|
855
|
-
/**
|
|
856
|
-
* Checks if the value is greater than the specified value.
|
|
857
|
-
*/
|
|
858
|
-
gt?: DataType;
|
|
859
|
-
/**
|
|
860
|
-
* Checks if the value is greater than or equal to the specified value.
|
|
861
|
-
*/
|
|
862
|
-
gte?: DataType;
|
|
863
|
-
/**
|
|
864
|
-
* Builds a negated filter.
|
|
865
|
-
*/
|
|
866
|
-
not?: PrimitiveFilter<T, Nullable, WithAggregations>;
|
|
867
|
-
};
|
|
868
|
-
type StringFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<string, Nullable> | (CommonPrimitiveFilter<string, 'String', Nullable, WithAggregations> & {
|
|
869
|
-
/**
|
|
870
|
-
* Checks if the string contains the specified substring.
|
|
871
|
-
*/
|
|
872
|
-
contains?: string;
|
|
873
|
-
/**
|
|
874
|
-
* Checks if the string starts with the specified substring.
|
|
875
|
-
*/
|
|
876
|
-
startsWith?: string;
|
|
877
|
-
/**
|
|
878
|
-
* Checks if the string ends with the specified substring.
|
|
879
|
-
*/
|
|
880
|
-
endsWith?: string;
|
|
881
|
-
/**
|
|
882
|
-
* Specifies the string comparison mode. Not effective for "sqlite" provider
|
|
883
|
-
*/
|
|
884
|
-
mode?: 'default' | 'insensitive';
|
|
885
|
-
} & (WithAggregations extends true ? {
|
|
886
|
-
/**
|
|
887
|
-
* Filters against the count of records.
|
|
888
|
-
*/
|
|
889
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
890
|
-
/**
|
|
891
|
-
* Filters against the minimum value.
|
|
892
|
-
*/
|
|
893
|
-
_min?: StringFilter<false, false>;
|
|
894
|
-
/**
|
|
895
|
-
* Filters against the maximum value.
|
|
896
|
-
*/
|
|
897
|
-
_max?: StringFilter<false, false>;
|
|
898
|
-
} : {}));
|
|
899
|
-
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 ? {
|
|
900
|
-
/**
|
|
901
|
-
* Filters against the count of records.
|
|
902
|
-
*/
|
|
903
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
904
|
-
/**
|
|
905
|
-
* Filters against the average value.
|
|
906
|
-
*/
|
|
907
|
-
_avg?: NumberFilter<T, false, false>;
|
|
908
|
-
/**
|
|
909
|
-
* Filters against the sum value.
|
|
910
|
-
*/
|
|
911
|
-
_sum?: NumberFilter<T, false, false>;
|
|
912
|
-
/**
|
|
913
|
-
* Filters against the minimum value.
|
|
914
|
-
*/
|
|
915
|
-
_min?: NumberFilter<T, false, false>;
|
|
916
|
-
/**
|
|
917
|
-
* Filters against the maximum value.
|
|
918
|
-
*/
|
|
919
|
-
_max?: NumberFilter<T, false, false>;
|
|
920
|
-
} : {}));
|
|
921
|
-
type DateTimeFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Date | string, Nullable> | (CommonPrimitiveFilter<Date | string, 'DateTime', Nullable, WithAggregations> & (WithAggregations extends true ? {
|
|
922
|
-
/**
|
|
923
|
-
* Filters against the count of records.
|
|
924
|
-
*/
|
|
925
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
926
|
-
/**
|
|
927
|
-
* Filters against the minimum value.
|
|
928
|
-
*/
|
|
929
|
-
_min?: DateTimeFilter<false, false>;
|
|
930
|
-
/**
|
|
931
|
-
* Filters against the maximum value.
|
|
932
|
-
*/
|
|
933
|
-
_max?: DateTimeFilter<false, false>;
|
|
934
|
-
} : {}));
|
|
935
|
-
type BytesFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Uint8Array | Buffer, Nullable> | ({
|
|
936
|
-
/**
|
|
937
|
-
* Checks for equality with the specified value.
|
|
938
|
-
*/
|
|
939
|
-
equals?: NullableIf<Uint8Array, Nullable>;
|
|
940
|
-
/**
|
|
941
|
-
* Checks if the value is in the specified list of values.
|
|
942
|
-
*/
|
|
943
|
-
in?: Uint8Array[];
|
|
944
|
-
/**
|
|
945
|
-
* Checks if the value is not in the specified list of values.
|
|
946
|
-
*/
|
|
947
|
-
notIn?: Uint8Array[];
|
|
948
|
-
/**
|
|
949
|
-
* Builds a negated filter.
|
|
950
|
-
*/
|
|
951
|
-
not?: BytesFilter<Nullable, WithAggregations>;
|
|
952
|
-
} & (WithAggregations extends true ? {
|
|
953
|
-
/**
|
|
954
|
-
* Filters against the count of records.
|
|
955
|
-
*/
|
|
956
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
957
|
-
/**
|
|
958
|
-
* Filters against the minimum value.
|
|
959
|
-
*/
|
|
960
|
-
_min?: BytesFilter<false, false>;
|
|
961
|
-
/**
|
|
962
|
-
* Filters against the maximum value.
|
|
963
|
-
*/
|
|
964
|
-
_max?: BytesFilter<false, false>;
|
|
965
|
-
} : {}));
|
|
966
|
-
type BooleanFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<boolean, Nullable> | ({
|
|
967
|
-
/**
|
|
968
|
-
* Checks for equality with the specified value.
|
|
969
|
-
*/
|
|
970
|
-
equals?: NullableIf<boolean, Nullable>;
|
|
971
|
-
/**
|
|
972
|
-
* Builds a negated filter.
|
|
973
|
-
*/
|
|
974
|
-
not?: BooleanFilter<Nullable, WithAggregations>;
|
|
975
|
-
} & (WithAggregations extends true ? {
|
|
976
|
-
/**
|
|
977
|
-
* Filters against the count of records.
|
|
978
|
-
*/
|
|
979
|
-
_count?: NumberFilter<'Int', false, false>;
|
|
980
|
-
/**
|
|
981
|
-
* Filters against the minimum value.
|
|
982
|
-
*/
|
|
983
|
-
_min?: BooleanFilter<false, false>;
|
|
984
|
-
/**
|
|
985
|
-
* Filters against the maximum value.
|
|
986
|
-
*/
|
|
987
|
-
_max?: BooleanFilter<false, false>;
|
|
988
|
-
} : {}));
|
|
989
|
-
type JsonFilter = {
|
|
990
|
-
/**
|
|
991
|
-
* JSON path to select the value to filter on. If omitted, the whole JSON value is used.
|
|
992
|
-
*/
|
|
993
|
-
path?: string;
|
|
994
|
-
/**
|
|
995
|
-
* Checks for equality with the specified value.
|
|
996
|
-
*/
|
|
997
|
-
equals?: JsonValue | JsonNullValues;
|
|
998
|
-
/**
|
|
999
|
-
* Builds a negated filter.
|
|
1000
|
-
*/
|
|
1001
|
-
not?: JsonValue | JsonNullValues;
|
|
488
|
+
not?: JsonValue | JsonNullValues;
|
|
1002
489
|
/**
|
|
1003
490
|
* Checks if the value is a string and contains the specified substring.
|
|
1004
491
|
*/
|
|
@@ -1373,364 +860,834 @@ type ToManyRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels
|
|
|
1373
860
|
*/
|
|
1374
861
|
upsert?: NestedUpsertInput<Schema, Model, Field>;
|
|
1375
862
|
/**
|
|
1376
|
-
* Updates a batch of related records.
|
|
863
|
+
* Updates a batch of related records.
|
|
864
|
+
*/
|
|
865
|
+
updateMany?: NestedUpdateManyInput<Schema, Model, Field>;
|
|
866
|
+
/**
|
|
867
|
+
* Deletes related records.
|
|
868
|
+
*/
|
|
869
|
+
delete?: NestedDeleteInput<Schema, Model, Field>;
|
|
870
|
+
/**
|
|
871
|
+
* Deletes a batch of related records.
|
|
872
|
+
*/
|
|
873
|
+
deleteMany?: NestedDeleteManyInput<Schema, Model, Field>;
|
|
874
|
+
/**
|
|
875
|
+
* Sets the related records to the specified ones.
|
|
876
|
+
*/
|
|
877
|
+
set?: SetRelationInput<Schema, Model, Field>;
|
|
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<{
|
|
880
|
+
/**
|
|
881
|
+
* Creates a related record.
|
|
882
|
+
*/
|
|
883
|
+
create?: NestedCreateInput<Schema, Model, Field>;
|
|
884
|
+
/**
|
|
885
|
+
* Connects an existing record.
|
|
886
|
+
*/
|
|
887
|
+
connect?: ConnectInput<Schema, Model, Field>;
|
|
888
|
+
/**
|
|
889
|
+
* Connects or create a related record.
|
|
890
|
+
*/
|
|
891
|
+
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
|
|
892
|
+
/**
|
|
893
|
+
* Updates the related record.
|
|
894
|
+
*/
|
|
895
|
+
update?: NestedUpdateInput<Schema, Model, Field>;
|
|
896
|
+
/**
|
|
897
|
+
* Upserts the related record.
|
|
898
|
+
*/
|
|
899
|
+
upsert?: NestedUpsertInput<Schema, Model, Field>;
|
|
900
|
+
} & (ModelFieldIsOptional<Schema, Model, Field> extends true ? {
|
|
901
|
+
/**
|
|
902
|
+
* Disconnects the related record.
|
|
903
|
+
*/
|
|
904
|
+
disconnect?: DisconnectInput<Schema, Model, Field>;
|
|
905
|
+
/**
|
|
906
|
+
* Deletes the related record.
|
|
907
|
+
*/
|
|
908
|
+
delete?: NestedDeleteInput<Schema, Model, Field>;
|
|
909
|
+
} : {}), FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'connectOrCreate' | 'upsert' : never>;
|
|
910
|
+
type DeleteArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
911
|
+
/**
|
|
912
|
+
* The unique filter to find the record to delete.
|
|
913
|
+
*/
|
|
914
|
+
where: WhereUniqueInput<Schema, Model>;
|
|
915
|
+
} & SelectIncludeOmit<Schema, Model, true>;
|
|
916
|
+
type DeleteManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
917
|
+
/**
|
|
918
|
+
* Filter to select records to delete.
|
|
919
|
+
*/
|
|
920
|
+
where?: WhereInput<Schema, Model>;
|
|
921
|
+
/**
|
|
922
|
+
* Limits the number of records to delete.
|
|
923
|
+
*/
|
|
924
|
+
limit?: number;
|
|
925
|
+
};
|
|
926
|
+
type CountArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<FindArgs<Schema, Model, true>, 'select' | 'include' | 'distinct' | 'omit'> & {
|
|
927
|
+
/**
|
|
928
|
+
* Selects fields to count
|
|
929
|
+
*/
|
|
930
|
+
select?: CountAggregateInput<Schema, Model> | true;
|
|
931
|
+
};
|
|
932
|
+
type CountAggregateInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
933
|
+
[Key in NonRelationFields<Schema, Model>]?: true;
|
|
934
|
+
} & {
|
|
935
|
+
_all?: true;
|
|
936
|
+
};
|
|
937
|
+
type CountResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Args> = Args extends {
|
|
938
|
+
select: infer S;
|
|
939
|
+
} ? S extends true ? number : {
|
|
940
|
+
[Key in keyof S]: number;
|
|
941
|
+
} : number;
|
|
942
|
+
type AggregateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
943
|
+
/**
|
|
944
|
+
* Filter conditions
|
|
945
|
+
*/
|
|
946
|
+
where?: WhereInput<Schema, Model>;
|
|
947
|
+
/**
|
|
948
|
+
* Number of records to skip for the aggregation
|
|
949
|
+
*/
|
|
950
|
+
skip?: number;
|
|
951
|
+
/**
|
|
952
|
+
* Number of records to take for the aggregation
|
|
953
|
+
*/
|
|
954
|
+
take?: number;
|
|
955
|
+
/**
|
|
956
|
+
* Order by clauses
|
|
957
|
+
*/
|
|
958
|
+
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
959
|
+
} & {
|
|
960
|
+
/**
|
|
961
|
+
* Performs count aggregation.
|
|
962
|
+
*/
|
|
963
|
+
_count?: true | CountAggregateInput<Schema, Model>;
|
|
964
|
+
/**
|
|
965
|
+
* Performs minimum value aggregation.
|
|
966
|
+
*/
|
|
967
|
+
_min?: MinMaxInput<Schema, Model, true>;
|
|
968
|
+
/**
|
|
969
|
+
* Performs maximum value aggregation.
|
|
970
|
+
*/
|
|
971
|
+
_max?: MinMaxInput<Schema, Model, true>;
|
|
972
|
+
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
973
|
+
/**
|
|
974
|
+
* Performs average value aggregation.
|
|
975
|
+
*/
|
|
976
|
+
_avg?: SumAvgInput<Schema, Model, true>;
|
|
977
|
+
/**
|
|
978
|
+
* Performs sum value aggregation.
|
|
979
|
+
*/
|
|
980
|
+
_sum?: SumAvgInput<Schema, Model, true>;
|
|
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
|
+
} ? {
|
|
994
|
+
/**
|
|
995
|
+
* Count aggregation result
|
|
996
|
+
*/
|
|
997
|
+
_count: AggCommonOutput<Count>;
|
|
998
|
+
} : {}) & (Args extends {
|
|
999
|
+
_sum: infer Sum;
|
|
1000
|
+
} ? {
|
|
1001
|
+
/**
|
|
1002
|
+
* Sum aggregation result
|
|
1003
|
+
*/
|
|
1004
|
+
_sum: AggCommonOutput<Sum>;
|
|
1005
|
+
} : {}) & (Args extends {
|
|
1006
|
+
_avg: infer Avg;
|
|
1007
|
+
} ? {
|
|
1008
|
+
/**
|
|
1009
|
+
* Average aggregation result
|
|
1010
|
+
*/
|
|
1011
|
+
_avg: AggCommonOutput<Avg>;
|
|
1012
|
+
} : {}) & (Args extends {
|
|
1013
|
+
_min: infer Min;
|
|
1014
|
+
} ? {
|
|
1015
|
+
/**
|
|
1016
|
+
* Minimum aggregation result
|
|
1017
|
+
*/
|
|
1018
|
+
_min: AggCommonOutput<Min>;
|
|
1019
|
+
} : {}) & (Args extends {
|
|
1020
|
+
_max: infer Max;
|
|
1021
|
+
} ? {
|
|
1022
|
+
/**
|
|
1023
|
+
* Maximum aggregation result
|
|
1024
|
+
*/
|
|
1025
|
+
_max: AggCommonOutput<Max>;
|
|
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>> = {
|
|
1032
|
+
/**
|
|
1033
|
+
* Filter conditions
|
|
1034
|
+
*/
|
|
1035
|
+
where?: WhereInput<Schema, Model>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Order by clauses
|
|
1038
|
+
*/
|
|
1039
|
+
orderBy?: OrArray<OrderBy<Schema, Model, false, true>>;
|
|
1040
|
+
/**
|
|
1041
|
+
* Fields to group by
|
|
1042
|
+
*/
|
|
1043
|
+
by: NonRelationFields<Schema, Model> | NonEmptyArray<NonRelationFields<Schema, Model>>;
|
|
1044
|
+
/**
|
|
1045
|
+
* Filter conditions for the grouped records
|
|
1046
|
+
*/
|
|
1047
|
+
having?: GroupByHaving<Schema, Model>;
|
|
1048
|
+
/**
|
|
1049
|
+
* Number of records to take for grouping
|
|
1050
|
+
*/
|
|
1051
|
+
take?: number;
|
|
1052
|
+
/**
|
|
1053
|
+
* Number of records to skip for grouping
|
|
1054
|
+
*/
|
|
1055
|
+
skip?: number;
|
|
1056
|
+
/**
|
|
1057
|
+
* Performs count aggregation.
|
|
1058
|
+
*/
|
|
1059
|
+
_count?: true | CountAggregateInput<Schema, Model>;
|
|
1060
|
+
/**
|
|
1061
|
+
* Performs minimum value aggregation.
|
|
1062
|
+
*/
|
|
1063
|
+
_min?: MinMaxInput<Schema, Model, true>;
|
|
1064
|
+
/**
|
|
1065
|
+
* Performs maximum value aggregation.
|
|
1066
|
+
*/
|
|
1067
|
+
_max?: MinMaxInput<Schema, Model, true>;
|
|
1068
|
+
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1069
|
+
/**
|
|
1070
|
+
* Performs average value aggregation.
|
|
1071
|
+
*/
|
|
1072
|
+
_avg?: SumAvgInput<Schema, Model, true>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Performs sum value aggregation.
|
|
1075
|
+
*/
|
|
1076
|
+
_sum?: SumAvgInput<Schema, Model, true>;
|
|
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
|
+
} ? {
|
|
1085
|
+
/**
|
|
1086
|
+
* Count aggregation result
|
|
1087
|
+
*/
|
|
1088
|
+
_count: AggCommonOutput<Count>;
|
|
1089
|
+
} : {}) & (Args extends {
|
|
1090
|
+
_avg: infer Avg;
|
|
1091
|
+
} ? {
|
|
1092
|
+
/**
|
|
1093
|
+
* Average aggregation result
|
|
1094
|
+
*/
|
|
1095
|
+
_avg: AggCommonOutput<Avg>;
|
|
1096
|
+
} : {}) & (Args extends {
|
|
1097
|
+
_sum: infer Sum;
|
|
1098
|
+
} ? {
|
|
1099
|
+
/**
|
|
1100
|
+
* Sum aggregation result
|
|
1101
|
+
*/
|
|
1102
|
+
_sum: AggCommonOutput<Sum>;
|
|
1103
|
+
} : {}) & (Args extends {
|
|
1104
|
+
_min: infer Min;
|
|
1105
|
+
} ? {
|
|
1106
|
+
/**
|
|
1107
|
+
* Minimum aggregation result
|
|
1108
|
+
*/
|
|
1109
|
+
_min: AggCommonOutput<Min>;
|
|
1110
|
+
} : {}) & (Args extends {
|
|
1111
|
+
_max: infer Max;
|
|
1112
|
+
} ? {
|
|
1113
|
+
/**
|
|
1114
|
+
* Maximum aggregation result
|
|
1115
|
+
*/
|
|
1116
|
+
_max: AggCommonOutput<Max>;
|
|
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<{
|
|
1123
|
+
/**
|
|
1124
|
+
* Unique filter to select the record to update.
|
|
1125
|
+
*/
|
|
1126
|
+
where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1127
|
+
/**
|
|
1128
|
+
* The data to update the record with.
|
|
1129
|
+
*/
|
|
1130
|
+
data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1131
|
+
}, true> : XOR<{
|
|
1132
|
+
/**
|
|
1133
|
+
* Filter to select the record to update.
|
|
1134
|
+
*/
|
|
1135
|
+
where?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1136
|
+
/**
|
|
1137
|
+
* The data to update the record with.
|
|
1138
|
+
*/
|
|
1139
|
+
data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
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<{
|
|
1142
|
+
/**
|
|
1143
|
+
* Unique filter to select the record to update.
|
|
1144
|
+
*/
|
|
1145
|
+
where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1146
|
+
/**
|
|
1147
|
+
* The data to create the record if it doesn't exist.
|
|
1148
|
+
*/
|
|
1149
|
+
create: CreateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1150
|
+
/**
|
|
1151
|
+
* The data to update the record with if it exists.
|
|
1152
|
+
*/
|
|
1153
|
+
update: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
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
|
+
|
|
1222
|
+
declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
1223
|
+
protected readonly schema: Schema;
|
|
1224
|
+
protected readonly options: ClientOptions<Schema>;
|
|
1225
|
+
protected eb: ExpressionBuilder<any, any>;
|
|
1226
|
+
constructor(schema: Schema, options: ClientOptions<Schema>);
|
|
1227
|
+
transformPrimitive(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
1228
|
+
transformOutput(value: unknown, _type: BuiltinType, _array: boolean): unknown;
|
|
1229
|
+
buildSelectModel(model: string, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
1230
|
+
buildFilterSortTake(model: string, args: FindArgs<Schema, GetModels<Schema>, true>, query: SelectQueryBuilder<any, any, {}>, modelAlias: string): SelectQueryBuilder<any, any, {}>;
|
|
1231
|
+
buildFilter(model: string, modelAlias: string, where: boolean | object | undefined): Expression<SqlBool>;
|
|
1232
|
+
private buildCursorFilter;
|
|
1233
|
+
private isLogicalCombinator;
|
|
1234
|
+
protected buildCompositeFilter(model: string, modelAlias: string, key: (typeof LOGICAL_COMBINATORS)[number], payload: any): Expression<SqlBool>;
|
|
1235
|
+
private buildRelationFilter;
|
|
1236
|
+
private buildToOneRelationFilter;
|
|
1237
|
+
private buildToManyRelationFilter;
|
|
1238
|
+
private buildArrayFilter;
|
|
1239
|
+
buildPrimitiveFilter(fieldRef: Expression<any>, fieldDef: FieldDef, payload: any): any;
|
|
1240
|
+
private buildJsonFilter;
|
|
1241
|
+
private buildPlainJsonFilter;
|
|
1242
|
+
private buildTypedJsonFilter;
|
|
1243
|
+
private buildTypedJsonArrayFilter;
|
|
1244
|
+
private buildTypeJsonNonArrayFilter;
|
|
1245
|
+
private buildJsonValueFilterClause;
|
|
1246
|
+
private buildLiteralFilter;
|
|
1247
|
+
private buildStandardFilter;
|
|
1248
|
+
private buildStringFilter;
|
|
1249
|
+
private buildJsonStringFilter;
|
|
1250
|
+
private escapeLikePattern;
|
|
1251
|
+
private buildStringLike;
|
|
1252
|
+
private prepStringCasing;
|
|
1253
|
+
private buildNumberFilter;
|
|
1254
|
+
private buildBooleanFilter;
|
|
1255
|
+
private buildDateTimeFilter;
|
|
1256
|
+
private buildBytesFilter;
|
|
1257
|
+
private buildEnumFilter;
|
|
1258
|
+
buildOrderBy(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, orderBy: OrArray<OrderBy<Schema, GetModels<Schema>, boolean, boolean>> | undefined, negated: boolean): SelectQueryBuilder<any, any, any>;
|
|
1259
|
+
buildSelectAllFields(model: string, query: SelectQueryBuilder<any, any, any>, omit: Record<string, boolean | undefined> | undefined | null, modelAlias: string): SelectQueryBuilder<any, any, any>;
|
|
1260
|
+
shouldOmitField(omit: unknown, model: string, field: string): any;
|
|
1261
|
+
protected buildModelSelect(model: GetModels<Schema>, subQueryAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, true>, selectAllFields: boolean): SelectQueryBuilder<any, any, {}>;
|
|
1262
|
+
buildSelectField(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, field: string): SelectQueryBuilder<any, any, any>;
|
|
1263
|
+
buildDelegateJoin(thisModel: string, thisModelAlias: string, otherModelAlias: string, query: SelectQueryBuilder<any, any, any>): SelectQueryBuilder<any, any, any>;
|
|
1264
|
+
buildCountJson(model: string, eb: ExpressionBuilder<any, any>, parentAlias: string, payload: any): ExpressionWrapper<any, any, unknown>;
|
|
1265
|
+
private negateSort;
|
|
1266
|
+
true(): Expression<SqlBool>;
|
|
1267
|
+
false(): Expression<SqlBool>;
|
|
1268
|
+
isTrue(expression: Expression<SqlBool>): boolean;
|
|
1269
|
+
isFalse(expression: Expression<SqlBool>): boolean;
|
|
1270
|
+
and(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
1271
|
+
or(...args: Expression<SqlBool>[]): Expression<SqlBool>;
|
|
1272
|
+
not(...args: Expression<SqlBool>[]): ExpressionWrapper<any, any, SqlBool>;
|
|
1273
|
+
fieldRef(model: string, field: string, modelAlias?: string, inlineComputedField?: boolean): any;
|
|
1274
|
+
protected canJoinWithoutNestedSelect(modelDef: ModelDef, payload: boolean | FindArgs<Schema, GetModels<Schema>, true>): boolean;
|
|
1275
|
+
abstract get provider(): DataSourceProviderType;
|
|
1276
|
+
/**
|
|
1277
|
+
* Builds selection for a relation field.
|
|
1278
|
+
*/
|
|
1279
|
+
abstract buildRelationSelection(query: SelectQueryBuilder<any, any, any>, model: string, relationField: string, parentAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, true>): SelectQueryBuilder<any, any, any>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Builds skip and take clauses.
|
|
1282
|
+
*/
|
|
1283
|
+
abstract buildSkipTake(query: SelectQueryBuilder<any, any, any>, skip: number | undefined, take: number | undefined): SelectQueryBuilder<any, any, any>;
|
|
1284
|
+
/**
|
|
1285
|
+
* Builds an Kysely expression that returns a JSON object for the given key-value pairs.
|
|
1286
|
+
*/
|
|
1287
|
+
abstract buildJsonObject(value: Record<string, Expression<unknown>>): ExpressionWrapper<any, any, unknown>;
|
|
1288
|
+
/**
|
|
1289
|
+
* Builds an Kysely expression that returns the length of an array.
|
|
1290
|
+
*/
|
|
1291
|
+
abstract buildArrayLength(array: Expression<unknown>): ExpressionWrapper<any, any, number>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Builds an array literal SQL string for the given values.
|
|
1294
|
+
*/
|
|
1295
|
+
abstract buildArrayLiteralSQL(values: unknown[]): string;
|
|
1296
|
+
/**
|
|
1297
|
+
* Whether the dialect supports updating with a limit on the number of updated rows.
|
|
1298
|
+
*/
|
|
1299
|
+
abstract get supportsUpdateWithLimit(): boolean;
|
|
1300
|
+
/**
|
|
1301
|
+
* Whether the dialect supports deleting with a limit on the number of deleted rows.
|
|
1302
|
+
*/
|
|
1303
|
+
abstract get supportsDeleteWithLimit(): boolean;
|
|
1304
|
+
/**
|
|
1305
|
+
* Whether the dialect supports DISTINCT ON.
|
|
1306
|
+
*/
|
|
1307
|
+
abstract get supportsDistinctOn(): boolean;
|
|
1308
|
+
/**
|
|
1309
|
+
* Whether the dialect support inserting with `DEFAULT` as field value.
|
|
1310
|
+
*/
|
|
1311
|
+
abstract get supportInsertWithDefault(): boolean;
|
|
1312
|
+
/**
|
|
1313
|
+
* Gets the SQL column type for the given field definition.
|
|
1314
|
+
*/
|
|
1315
|
+
abstract getFieldSqlType(fieldDef: FieldDef): string;
|
|
1316
|
+
abstract getStringCasingBehavior(): {
|
|
1317
|
+
supportsILike: boolean;
|
|
1318
|
+
likeCaseSensitive: boolean;
|
|
1319
|
+
};
|
|
1320
|
+
/**
|
|
1321
|
+
* Builds a JSON path selection expression.
|
|
1322
|
+
*/
|
|
1323
|
+
protected abstract buildJsonPathSelection(receiver: Expression<any>, path: string | undefined): Expression<any>;
|
|
1324
|
+
/**
|
|
1325
|
+
* Builds a JSON array filter expression.
|
|
1326
|
+
*/
|
|
1327
|
+
protected abstract buildJsonArrayFilter(receiver: Expression<any>, operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown): Expression<SqlBool>;
|
|
1328
|
+
/**
|
|
1329
|
+
* Builds a JSON array exists predicate (returning if any element matches the filter).
|
|
1330
|
+
*/
|
|
1331
|
+
protected abstract buildJsonArrayExistsPredicate(receiver: Expression<any>, buildFilter: (elem: Expression<any>) => Expression<SqlBool>): Expression<SqlBool>;
|
|
1332
|
+
}
|
|
1333
|
+
|
|
1334
|
+
declare class InputValidator<Schema extends SchemaDef> {
|
|
1335
|
+
private readonly client;
|
|
1336
|
+
private readonly schemaCache;
|
|
1337
|
+
constructor(client: ClientContract<Schema>);
|
|
1338
|
+
private get schema();
|
|
1339
|
+
private get options();
|
|
1340
|
+
private get extraValidationsEnabled();
|
|
1341
|
+
validateProcedureInput(proc: string, input: unknown): unknown;
|
|
1342
|
+
private makeProcedureParamSchema;
|
|
1343
|
+
validateFindArgs(model: GetModels<Schema>, args: unknown, operation: CoreCrudOperations): FindArgs<Schema, GetModels<Schema>, true> | undefined;
|
|
1344
|
+
validateExistsArgs(model: GetModels<Schema>, args: unknown): ExistsArgs<Schema, GetModels<Schema>> | undefined;
|
|
1345
|
+
validateCreateArgs(model: GetModels<Schema>, args: unknown): CreateArgs<Schema, GetModels<Schema>>;
|
|
1346
|
+
validateCreateManyArgs(model: GetModels<Schema>, args: unknown): CreateManyArgs<Schema, GetModels<Schema>>;
|
|
1347
|
+
validateCreateManyAndReturnArgs(model: GetModels<Schema>, args: unknown): CreateManyAndReturnArgs<Schema, GetModels<Schema>> | undefined;
|
|
1348
|
+
validateUpdateArgs(model: GetModels<Schema>, args: unknown): UpdateArgs<Schema, GetModels<Schema>>;
|
|
1349
|
+
validateUpdateManyArgs(model: GetModels<Schema>, args: unknown): UpdateManyArgs<Schema, GetModels<Schema>>;
|
|
1350
|
+
validateUpdateManyAndReturnArgs(model: GetModels<Schema>, args: unknown): UpdateManyAndReturnArgs<Schema, GetModels<Schema>>;
|
|
1351
|
+
validateUpsertArgs(model: GetModels<Schema>, args: unknown): UpsertArgs<Schema, GetModels<Schema>>;
|
|
1352
|
+
validateDeleteArgs(model: GetModels<Schema>, args: unknown): DeleteArgs<Schema, GetModels<Schema>>;
|
|
1353
|
+
validateDeleteManyArgs(model: GetModels<Schema>, args: unknown): DeleteManyArgs<Schema, GetModels<Schema>> | undefined;
|
|
1354
|
+
validateCountArgs(model: GetModels<Schema>, args: unknown): CountArgs<Schema, GetModels<Schema>> | undefined;
|
|
1355
|
+
validateAggregateArgs(model: GetModels<Schema>, args: unknown): AggregateArgs<Schema, GetModels<Schema>>;
|
|
1356
|
+
validateGroupByArgs(model: GetModels<Schema>, args: unknown): GroupByArgs<Schema, GetModels<Schema>>;
|
|
1357
|
+
private getSchemaCache;
|
|
1358
|
+
private setSchemaCache;
|
|
1359
|
+
private validate;
|
|
1360
|
+
private mergePluginArgsSchema;
|
|
1361
|
+
private getPluginExtQueryArgsSchema;
|
|
1362
|
+
private makeFindSchema;
|
|
1363
|
+
private makeExistsSchema;
|
|
1364
|
+
private makeScalarSchema;
|
|
1365
|
+
private makeEnumSchema;
|
|
1366
|
+
private makeTypeDefSchema;
|
|
1367
|
+
private makeWhereSchema;
|
|
1368
|
+
private makeTypedJsonFilterSchema;
|
|
1369
|
+
private isTypeDefType;
|
|
1370
|
+
private makeEnumFilterSchema;
|
|
1371
|
+
private makeArrayFilterSchema;
|
|
1372
|
+
private internalMakeArrayFilterSchema;
|
|
1373
|
+
private makePrimitiveFilterSchema;
|
|
1374
|
+
private makeJsonValueSchema;
|
|
1375
|
+
private makeJsonFilterSchema;
|
|
1376
|
+
private makeDateTimeFilterSchema;
|
|
1377
|
+
private makeBooleanFilterSchema;
|
|
1378
|
+
private makeBytesFilterSchema;
|
|
1379
|
+
private makeCommonPrimitiveFilterComponents;
|
|
1380
|
+
private makeCommonPrimitiveFilterSchema;
|
|
1381
|
+
private makeNumberFilterSchema;
|
|
1382
|
+
private makeStringFilterSchema;
|
|
1383
|
+
private makeStringModeSchema;
|
|
1384
|
+
private makeSelectSchema;
|
|
1385
|
+
private makeCountSelectionSchema;
|
|
1386
|
+
private makeRelationSelectIncludeSchema;
|
|
1387
|
+
private makeOmitSchema;
|
|
1388
|
+
private makeIncludeSchema;
|
|
1389
|
+
private makeOrderBySchema;
|
|
1390
|
+
private makeDistinctSchema;
|
|
1391
|
+
private makeCursorSchema;
|
|
1392
|
+
private makeCreateSchema;
|
|
1393
|
+
private makeCreateManySchema;
|
|
1394
|
+
private makeCreateManyAndReturnSchema;
|
|
1395
|
+
private makeCreateDataSchema;
|
|
1396
|
+
private isDelegateDiscriminator;
|
|
1397
|
+
private makeRelationManipulationSchema;
|
|
1398
|
+
private makeSetDataSchema;
|
|
1399
|
+
private makeConnectDataSchema;
|
|
1400
|
+
private makeDisconnectDataSchema;
|
|
1401
|
+
private makeDeleteRelationDataSchema;
|
|
1402
|
+
private makeConnectOrCreateDataSchema;
|
|
1403
|
+
private makeCreateManyDataSchema;
|
|
1404
|
+
private makeUpdateSchema;
|
|
1405
|
+
private makeUpdateManySchema;
|
|
1406
|
+
private makeUpdateManyAndReturnSchema;
|
|
1407
|
+
private makeUpsertSchema;
|
|
1408
|
+
private makeUpdateDataSchema;
|
|
1409
|
+
private makeDeleteSchema;
|
|
1410
|
+
private makeDeleteManySchema;
|
|
1411
|
+
makeCountSchema(model: GetModels<Schema>): z.ZodOptional<z.ZodObject<z.core.$ZodLooseShape, z.core.$strict>>;
|
|
1412
|
+
private makeCountAggregateInputSchema;
|
|
1413
|
+
makeAggregateSchema(model: GetModels<Schema>): z.ZodOptional<z.ZodObject<z.core.$ZodLooseShape, z.core.$strict>>;
|
|
1414
|
+
makeSumAvgInputSchema(model: GetModels<Schema>): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
1415
|
+
makeMinMaxInputSchema(model: GetModels<Schema>): z.ZodObject<Record<string, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>, z.core.$strict>;
|
|
1416
|
+
private makeGroupBySchema;
|
|
1417
|
+
private onlyAggregationFields;
|
|
1418
|
+
private makeHavingSchema;
|
|
1419
|
+
private makeSkipSchema;
|
|
1420
|
+
private makeTakeSchema;
|
|
1421
|
+
private refineForSelectIncludeMutuallyExclusive;
|
|
1422
|
+
private refineForSelectOmitMutuallyExclusive;
|
|
1423
|
+
private nullableIf;
|
|
1424
|
+
private orArray;
|
|
1425
|
+
private isNumericField;
|
|
1426
|
+
private get providerSupportsCaseSensitivity();
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
/**
|
|
1430
|
+
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1431
|
+
*/
|
|
1432
|
+
declare const CoreCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists"];
|
|
1433
|
+
/**
|
|
1434
|
+
* List of core CRUD operations. It excludes the 'orThrow' variants.
|
|
1435
|
+
*/
|
|
1436
|
+
type CoreCrudOperations = (typeof CoreCrudOperations)[number];
|
|
1437
|
+
/**
|
|
1438
|
+
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1439
|
+
*/
|
|
1440
|
+
declare const CoreReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists"];
|
|
1441
|
+
/**
|
|
1442
|
+
* List of core read operations. It excludes the 'orThrow' variants.
|
|
1443
|
+
*/
|
|
1444
|
+
type CoreReadOperations = (typeof CoreReadOperations)[number];
|
|
1445
|
+
/**
|
|
1446
|
+
* List of core write operations.
|
|
1447
|
+
*/
|
|
1448
|
+
declare const CoreWriteOperations: readonly ["create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany"];
|
|
1449
|
+
/**
|
|
1450
|
+
* List of core write operations.
|
|
1451
|
+
*/
|
|
1452
|
+
type CoreWriteOperations = (typeof CoreWriteOperations)[number];
|
|
1453
|
+
/**
|
|
1454
|
+
* List of core create operations.
|
|
1455
|
+
*/
|
|
1456
|
+
declare const CoreCreateOperations: readonly ["create", "createMany", "createManyAndReturn", "upsert"];
|
|
1457
|
+
/**
|
|
1458
|
+
* List of core create operations.
|
|
1459
|
+
*/
|
|
1460
|
+
type CoreCreateOperations = (typeof CoreCreateOperations)[number];
|
|
1461
|
+
/**
|
|
1462
|
+
* List of core update operations.
|
|
1463
|
+
*/
|
|
1464
|
+
declare const CoreUpdateOperations: readonly ["update", "updateMany", "updateManyAndReturn", "upsert"];
|
|
1465
|
+
/**
|
|
1466
|
+
* List of core update operations.
|
|
1467
|
+
*/
|
|
1468
|
+
type CoreUpdateOperations = (typeof CoreUpdateOperations)[number];
|
|
1469
|
+
/**
|
|
1470
|
+
* List of core delete operations.
|
|
1471
|
+
*/
|
|
1472
|
+
declare const CoreDeleteOperations: readonly ["delete", "deleteMany"];
|
|
1473
|
+
/**
|
|
1474
|
+
* List of core delete operations.
|
|
1475
|
+
*/
|
|
1476
|
+
type CoreDeleteOperations = (typeof CoreDeleteOperations)[number];
|
|
1477
|
+
/**
|
|
1478
|
+
* List of all CRUD operations, including 'orThrow' variants.
|
|
1479
|
+
*/
|
|
1480
|
+
declare const AllCrudOperations: readonly ["findMany", "findUnique", "findFirst", "create", "createMany", "createManyAndReturn", "update", "updateMany", "updateManyAndReturn", "upsert", "delete", "deleteMany", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1481
|
+
/**
|
|
1482
|
+
* List of all CRUD operations, including 'orThrow' variants.
|
|
1483
|
+
*/
|
|
1484
|
+
type AllCrudOperations = (typeof AllCrudOperations)[number];
|
|
1485
|
+
/**
|
|
1486
|
+
* List of all read operations, including 'orThrow' variants.
|
|
1487
|
+
*/
|
|
1488
|
+
declare const AllReadOperations: readonly ["findMany", "findUnique", "findFirst", "count", "aggregate", "groupBy", "exists", "findUniqueOrThrow", "findFirstOrThrow"];
|
|
1489
|
+
/**
|
|
1490
|
+
* List of all read operations, including 'orThrow' variants.
|
|
1491
|
+
*/
|
|
1492
|
+
type AllReadOperations = (typeof AllReadOperations)[number];
|
|
1493
|
+
|
|
1494
|
+
type AllowedExtQueryArgKeys = CoreCrudOperations | '$create' | '$read' | '$update' | '$delete' | '$all';
|
|
1495
|
+
/**
|
|
1496
|
+
* Base shape of plugin-extended query args.
|
|
1497
|
+
*/
|
|
1498
|
+
type ExtQueryArgsBase = {
|
|
1499
|
+
[K in AllowedExtQueryArgKeys]?: object;
|
|
1500
|
+
};
|
|
1501
|
+
/**
|
|
1502
|
+
* Base type for plugin-extended client members (methods and properties).
|
|
1503
|
+
* Member names should start with '$' to avoid model name conflicts.
|
|
1504
|
+
*/
|
|
1505
|
+
type ExtClientMembersBase = Record<string, unknown>;
|
|
1506
|
+
/**
|
|
1507
|
+
* ZenStack runtime plugin.
|
|
1508
|
+
*/
|
|
1509
|
+
interface RuntimePlugin<Schema extends SchemaDef, ExtQueryArgs extends ExtQueryArgsBase, ExtClientMembers extends Record<string, unknown>> {
|
|
1510
|
+
/**
|
|
1511
|
+
* Plugin ID.
|
|
1377
1512
|
*/
|
|
1378
|
-
|
|
1513
|
+
id: string;
|
|
1379
1514
|
/**
|
|
1380
|
-
*
|
|
1515
|
+
* Plugin display name.
|
|
1381
1516
|
*/
|
|
1382
|
-
|
|
1517
|
+
name?: string;
|
|
1383
1518
|
/**
|
|
1384
|
-
*
|
|
1519
|
+
* Plugin description.
|
|
1385
1520
|
*/
|
|
1386
|
-
|
|
1521
|
+
description?: string;
|
|
1387
1522
|
/**
|
|
1388
|
-
*
|
|
1523
|
+
* Custom function implementations.
|
|
1524
|
+
* @private
|
|
1389
1525
|
*/
|
|
1390
|
-
|
|
1391
|
-
}, FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' | 'upsert' : never>;
|
|
1392
|
-
type ToOneRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
|
|
1526
|
+
functions?: Record<string, ZModelFunction<Schema>>;
|
|
1393
1527
|
/**
|
|
1394
|
-
*
|
|
1528
|
+
* Intercepts an ORM query.
|
|
1395
1529
|
*/
|
|
1396
|
-
|
|
1530
|
+
onQuery?: OnQueryCallback<Schema>;
|
|
1397
1531
|
/**
|
|
1398
|
-
*
|
|
1532
|
+
* Intercepts a procedure invocation.
|
|
1399
1533
|
*/
|
|
1400
|
-
|
|
1534
|
+
onProcedure?: OnProcedureCallback<Schema>;
|
|
1401
1535
|
/**
|
|
1402
|
-
*
|
|
1536
|
+
* Intercepts an entity mutation.
|
|
1403
1537
|
*/
|
|
1404
|
-
|
|
1538
|
+
onEntityMutation?: EntityMutationHooksDef<Schema>;
|
|
1405
1539
|
/**
|
|
1406
|
-
*
|
|
1540
|
+
* Intercepts a Kysely query.
|
|
1407
1541
|
*/
|
|
1408
|
-
|
|
1542
|
+
onKyselyQuery?: OnKyselyQueryCallback<Schema>;
|
|
1409
1543
|
/**
|
|
1410
|
-
*
|
|
1544
|
+
* Extended query args configuration.
|
|
1411
1545
|
*/
|
|
1412
|
-
|
|
1413
|
-
|
|
1546
|
+
queryArgs?: {
|
|
1547
|
+
[K in keyof ExtQueryArgs]: ZodType<ExtQueryArgs[K]>;
|
|
1548
|
+
};
|
|
1414
1549
|
/**
|
|
1415
|
-
*
|
|
1550
|
+
* Extended client members (methods and properties).
|
|
1416
1551
|
*/
|
|
1417
|
-
|
|
1552
|
+
client?: ExtClientMembers;
|
|
1553
|
+
}
|
|
1554
|
+
type AnyPlugin = RuntimePlugin<any, any, any>;
|
|
1555
|
+
/**
|
|
1556
|
+
* Defines a ZenStack runtime plugin.
|
|
1557
|
+
*/
|
|
1558
|
+
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>;
|
|
1559
|
+
type OnProcedureCallback<Schema extends SchemaDef> = (ctx: OnProcedureHookContext<Schema>) => Promise<unknown>;
|
|
1560
|
+
type OnProcedureHookContext<Schema extends SchemaDef> = {
|
|
1418
1561
|
/**
|
|
1419
|
-
*
|
|
1562
|
+
* The procedure name.
|
|
1420
1563
|
*/
|
|
1421
|
-
|
|
1422
|
-
} : {}), FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'connectOrCreate' | 'upsert' : never>;
|
|
1423
|
-
type DeleteArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1564
|
+
name: string;
|
|
1424
1565
|
/**
|
|
1425
|
-
*
|
|
1566
|
+
* Whether the procedure is a mutation.
|
|
1426
1567
|
*/
|
|
1427
|
-
|
|
1428
|
-
} & SelectIncludeOmit<Schema, Model, true>;
|
|
1429
|
-
type DeleteManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1568
|
+
mutation: boolean;
|
|
1430
1569
|
/**
|
|
1431
|
-
*
|
|
1570
|
+
* Procedure invocation input (envelope).
|
|
1571
|
+
*
|
|
1572
|
+
* The canonical shape is `{ args?: Record<string, unknown> }`.
|
|
1573
|
+
* When a procedure has required params, `args` is required.
|
|
1432
1574
|
*/
|
|
1433
|
-
|
|
1575
|
+
input: unknown;
|
|
1434
1576
|
/**
|
|
1435
|
-
*
|
|
1577
|
+
* Continues the invocation. The input passed here is forwarded to the next handler.
|
|
1436
1578
|
*/
|
|
1437
|
-
|
|
1438
|
-
};
|
|
1439
|
-
type CountArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<FindArgs<Schema, Model, true>, 'select' | 'include' | 'distinct' | 'omit'> & {
|
|
1579
|
+
proceed: (input: unknown) => Promise<unknown>;
|
|
1440
1580
|
/**
|
|
1441
|
-
*
|
|
1581
|
+
* The ZenStack client that is invoking the procedure.
|
|
1442
1582
|
*/
|
|
1443
|
-
|
|
1444
|
-
};
|
|
1445
|
-
type CountAggregateInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1446
|
-
[Key in NonRelationFields<Schema, Model>]?: true;
|
|
1447
|
-
} & {
|
|
1448
|
-
_all?: true;
|
|
1583
|
+
client: ClientContract<Schema>;
|
|
1449
1584
|
};
|
|
1450
|
-
type
|
|
1451
|
-
|
|
1452
|
-
} ? S extends true ? number : {
|
|
1453
|
-
[Key in keyof S]: number;
|
|
1454
|
-
} : number;
|
|
1455
|
-
type AggregateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1456
|
-
/**
|
|
1457
|
-
* Filter conditions
|
|
1458
|
-
*/
|
|
1459
|
-
where?: WhereInput<Schema, Model>;
|
|
1460
|
-
/**
|
|
1461
|
-
* Number of records to skip for the aggregation
|
|
1462
|
-
*/
|
|
1463
|
-
skip?: number;
|
|
1464
|
-
/**
|
|
1465
|
-
* Number of records to take for the aggregation
|
|
1466
|
-
*/
|
|
1467
|
-
take?: number;
|
|
1468
|
-
/**
|
|
1469
|
-
* Order by clauses
|
|
1470
|
-
*/
|
|
1471
|
-
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
1472
|
-
} & {
|
|
1585
|
+
type OnQueryCallback<Schema extends SchemaDef> = (ctx: OnQueryHookContext<Schema>) => Promise<unknown>;
|
|
1586
|
+
type OnQueryHookContext<Schema extends SchemaDef> = {
|
|
1473
1587
|
/**
|
|
1474
|
-
*
|
|
1588
|
+
* The model that is being queried.
|
|
1475
1589
|
*/
|
|
1476
|
-
|
|
1590
|
+
model: GetModels<Schema>;
|
|
1477
1591
|
/**
|
|
1478
|
-
*
|
|
1592
|
+
* The operation that is being performed.
|
|
1479
1593
|
*/
|
|
1480
|
-
|
|
1594
|
+
operation: AllCrudOperations;
|
|
1481
1595
|
/**
|
|
1482
|
-
*
|
|
1596
|
+
* The query arguments.
|
|
1483
1597
|
*/
|
|
1484
|
-
|
|
1485
|
-
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1598
|
+
args: Record<string, unknown> | undefined;
|
|
1486
1599
|
/**
|
|
1487
|
-
*
|
|
1600
|
+
* The function to proceed with the original query.
|
|
1601
|
+
* It takes the same arguments as the operation method.
|
|
1602
|
+
*
|
|
1603
|
+
* @param args The query arguments.
|
|
1488
1604
|
*/
|
|
1489
|
-
|
|
1605
|
+
proceed: (args: Record<string, unknown> | undefined) => Promise<unknown>;
|
|
1490
1606
|
/**
|
|
1491
|
-
*
|
|
1607
|
+
* The ZenStack client that is performing the operation.
|
|
1492
1608
|
*/
|
|
1493
|
-
|
|
1494
|
-
});
|
|
1495
|
-
type NumericFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
1496
|
-
[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>;
|
|
1497
|
-
};
|
|
1498
|
-
type SumAvgInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ValueType> = {
|
|
1499
|
-
[Key in NumericFields<Schema, Model>]?: ValueType;
|
|
1500
|
-
};
|
|
1501
|
-
type MinMaxInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ValueType> = {
|
|
1502
|
-
[Key in GetModelFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? never : FieldIsRelation<Schema, Model, Key> extends true ? never : Key]?: ValueType;
|
|
1609
|
+
client: ClientContract<Schema>;
|
|
1503
1610
|
};
|
|
1504
|
-
type
|
|
1505
|
-
_count: infer Count;
|
|
1506
|
-
} ? {
|
|
1507
|
-
/**
|
|
1508
|
-
* Count aggregation result
|
|
1509
|
-
*/
|
|
1510
|
-
_count: AggCommonOutput<Count>;
|
|
1511
|
-
} : {}) & (Args extends {
|
|
1512
|
-
_sum: infer Sum;
|
|
1513
|
-
} ? {
|
|
1514
|
-
/**
|
|
1515
|
-
* Sum aggregation result
|
|
1516
|
-
*/
|
|
1517
|
-
_sum: AggCommonOutput<Sum>;
|
|
1518
|
-
} : {}) & (Args extends {
|
|
1519
|
-
_avg: infer Avg;
|
|
1520
|
-
} ? {
|
|
1521
|
-
/**
|
|
1522
|
-
* Average aggregation result
|
|
1523
|
-
*/
|
|
1524
|
-
_avg: AggCommonOutput<Avg>;
|
|
1525
|
-
} : {}) & (Args extends {
|
|
1526
|
-
_min: infer Min;
|
|
1527
|
-
} ? {
|
|
1528
|
-
/**
|
|
1529
|
-
* Minimum aggregation result
|
|
1530
|
-
*/
|
|
1531
|
-
_min: AggCommonOutput<Min>;
|
|
1532
|
-
} : {}) & (Args extends {
|
|
1533
|
-
_max: infer Max;
|
|
1534
|
-
} ? {
|
|
1535
|
-
/**
|
|
1536
|
-
* Maximum aggregation result
|
|
1537
|
-
*/
|
|
1538
|
-
_max: AggCommonOutput<Max>;
|
|
1539
|
-
} : {});
|
|
1540
|
-
type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
|
|
1541
|
-
[Key in keyof Input]: number;
|
|
1542
|
-
} : never;
|
|
1543
|
-
type GroupByHaving<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<WhereInput<Schema, Model, true, true>, '$expr'>;
|
|
1544
|
-
type GroupByArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1545
|
-
/**
|
|
1546
|
-
* Filter conditions
|
|
1547
|
-
*/
|
|
1548
|
-
where?: WhereInput<Schema, Model>;
|
|
1549
|
-
/**
|
|
1550
|
-
* Order by clauses
|
|
1551
|
-
*/
|
|
1552
|
-
orderBy?: OrArray<OrderBy<Schema, Model, false, true>>;
|
|
1553
|
-
/**
|
|
1554
|
-
* Fields to group by
|
|
1555
|
-
*/
|
|
1556
|
-
by: NonRelationFields<Schema, Model> | NonEmptyArray<NonRelationFields<Schema, Model>>;
|
|
1557
|
-
/**
|
|
1558
|
-
* Filter conditions for the grouped records
|
|
1559
|
-
*/
|
|
1560
|
-
having?: GroupByHaving<Schema, Model>;
|
|
1561
|
-
/**
|
|
1562
|
-
* Number of records to take for grouping
|
|
1563
|
-
*/
|
|
1564
|
-
take?: number;
|
|
1565
|
-
/**
|
|
1566
|
-
* Number of records to skip for grouping
|
|
1567
|
-
*/
|
|
1568
|
-
skip?: number;
|
|
1569
|
-
/**
|
|
1570
|
-
* Performs count aggregation.
|
|
1571
|
-
*/
|
|
1572
|
-
_count?: true | CountAggregateInput<Schema, Model>;
|
|
1573
|
-
/**
|
|
1574
|
-
* Performs minimum value aggregation.
|
|
1575
|
-
*/
|
|
1576
|
-
_min?: MinMaxInput<Schema, Model, true>;
|
|
1577
|
-
/**
|
|
1578
|
-
* Performs maximum value aggregation.
|
|
1579
|
-
*/
|
|
1580
|
-
_max?: MinMaxInput<Schema, Model, true>;
|
|
1581
|
-
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1582
|
-
/**
|
|
1583
|
-
* Performs average value aggregation.
|
|
1584
|
-
*/
|
|
1585
|
-
_avg?: SumAvgInput<Schema, Model, true>;
|
|
1586
|
-
/**
|
|
1587
|
-
* Performs sum value aggregation.
|
|
1588
|
-
*/
|
|
1589
|
-
_sum?: SumAvgInput<Schema, Model, true>;
|
|
1590
|
-
});
|
|
1591
|
-
type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args extends {
|
|
1592
|
-
by: unknown;
|
|
1593
|
-
}> = Array<{
|
|
1594
|
-
[Key in NonRelationFields<Schema, Model> as Key extends ValueOfPotentialTuple<Args['by']> ? Key : never]: MapModelFieldType<Schema, Model, Key>;
|
|
1595
|
-
} & (Args extends {
|
|
1596
|
-
_count: infer Count;
|
|
1597
|
-
} ? {
|
|
1598
|
-
/**
|
|
1599
|
-
* Count aggregation result
|
|
1600
|
-
*/
|
|
1601
|
-
_count: AggCommonOutput<Count>;
|
|
1602
|
-
} : {}) & (Args extends {
|
|
1603
|
-
_avg: infer Avg;
|
|
1604
|
-
} ? {
|
|
1611
|
+
type EntityMutationHooksDef<Schema extends SchemaDef> = {
|
|
1605
1612
|
/**
|
|
1606
|
-
*
|
|
1613
|
+
* Called before entities are mutated.
|
|
1607
1614
|
*/
|
|
1608
|
-
|
|
1609
|
-
} : {}) & (Args extends {
|
|
1610
|
-
_sum: infer Sum;
|
|
1611
|
-
} ? {
|
|
1615
|
+
beforeEntityMutation?: BeforeEntityMutationCallback<Schema>;
|
|
1612
1616
|
/**
|
|
1613
|
-
*
|
|
1614
|
-
*/
|
|
1615
|
-
|
|
1616
|
-
} : {}) & (Args extends {
|
|
1617
|
-
_min: infer Min;
|
|
1618
|
-
} ? {
|
|
1617
|
+
* Called after entities are mutated.
|
|
1618
|
+
*/
|
|
1619
|
+
afterEntityMutation?: AfterEntityMutationCallback<Schema>;
|
|
1619
1620
|
/**
|
|
1620
|
-
*
|
|
1621
|
+
* Whether to run after-mutation hooks within the transaction that performs the mutation.
|
|
1622
|
+
*
|
|
1623
|
+
* If set to `true`, if the mutation already runs inside a transaction, the callbacks are
|
|
1624
|
+
* executed immediately after the mutation within the transaction boundary. If the mutation
|
|
1625
|
+
* is not running inside a transaction, a new transaction is created to run both the mutation
|
|
1626
|
+
* and the callbacks.
|
|
1627
|
+
*
|
|
1628
|
+
* If set to `false`, the callbacks are executed after the mutation transaction is committed.
|
|
1629
|
+
*
|
|
1630
|
+
* Defaults to `false`.
|
|
1621
1631
|
*/
|
|
1622
|
-
|
|
1623
|
-
}
|
|
1624
|
-
|
|
1625
|
-
} ? {
|
|
1632
|
+
runAfterMutationWithinTransaction?: boolean;
|
|
1633
|
+
};
|
|
1634
|
+
type MutationHooksArgs<Schema extends SchemaDef> = {
|
|
1626
1635
|
/**
|
|
1627
|
-
*
|
|
1636
|
+
* The model that is being mutated.
|
|
1628
1637
|
*/
|
|
1629
|
-
|
|
1630
|
-
} : {})>;
|
|
1631
|
-
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>>;
|
|
1632
|
-
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>>;
|
|
1633
|
-
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>>;
|
|
1634
|
-
type SetRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>>;
|
|
1635
|
-
type NestedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<{
|
|
1638
|
+
model: GetModels<Schema>;
|
|
1636
1639
|
/**
|
|
1637
|
-
*
|
|
1640
|
+
* The mutation action that is being performed.
|
|
1638
1641
|
*/
|
|
1639
|
-
|
|
1642
|
+
action: 'create' | 'update' | 'delete';
|
|
1640
1643
|
/**
|
|
1641
|
-
* The data
|
|
1644
|
+
* The mutation data. Only available for create and update actions.
|
|
1642
1645
|
*/
|
|
1643
|
-
|
|
1644
|
-
}, true> : XOR<{
|
|
1646
|
+
queryNode: OperationNode;
|
|
1645
1647
|
/**
|
|
1646
|
-
*
|
|
1648
|
+
* A query ID that uniquely identifies the mutation operation. You can use it to correlate
|
|
1649
|
+
* data between the before and after mutation hooks.
|
|
1647
1650
|
*/
|
|
1648
|
-
|
|
1651
|
+
queryId: QueryId;
|
|
1652
|
+
};
|
|
1653
|
+
type BeforeEntityMutationCallback<Schema extends SchemaDef> = (args: PluginBeforeEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
1654
|
+
type AfterEntityMutationCallback<Schema extends SchemaDef> = (args: PluginAfterEntityMutationArgs<Schema>) => MaybePromise<void>;
|
|
1655
|
+
type PluginBeforeEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
1649
1656
|
/**
|
|
1650
|
-
*
|
|
1657
|
+
* Loads the entities that are about to be mutated. The db operation that loads the entities is executed
|
|
1658
|
+
* within the same transaction context as the mutation.
|
|
1651
1659
|
*/
|
|
1652
|
-
|
|
1653
|
-
}, UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
1654
|
-
type NestedUpsertInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<{
|
|
1660
|
+
loadBeforeMutationEntities(): Promise<Record<string, unknown>[] | undefined>;
|
|
1655
1661
|
/**
|
|
1656
|
-
*
|
|
1662
|
+
* The ZenStack client you can use to perform additional operations. The database operations initiated
|
|
1663
|
+
* from this client are executed within the same transaction as the mutation if the mutation is running
|
|
1664
|
+
* inside a transaction.
|
|
1665
|
+
*
|
|
1666
|
+
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
1657
1667
|
*/
|
|
1658
|
-
|
|
1668
|
+
client: ClientContract<Schema>;
|
|
1669
|
+
};
|
|
1670
|
+
type PluginAfterEntityMutationArgs<Schema extends SchemaDef> = MutationHooksArgs<Schema> & {
|
|
1659
1671
|
/**
|
|
1660
|
-
*
|
|
1672
|
+
* Loads the entities that have been mutated.
|
|
1661
1673
|
*/
|
|
1662
|
-
|
|
1674
|
+
loadAfterMutationEntities(): Promise<Record<string, unknown>[] | undefined>;
|
|
1663
1675
|
/**
|
|
1664
|
-
* The
|
|
1676
|
+
* The ZenStack client you can use to perform additional operations.
|
|
1677
|
+
* See {@link EntityMutationHooksDef.runAfterMutationWithinTransaction} for detailed transaction behavior.
|
|
1678
|
+
*
|
|
1679
|
+
* Mutations initiated from this client will NOT trigger entity mutation hooks to avoid infinite loops.
|
|
1665
1680
|
*/
|
|
1666
|
-
|
|
1667
|
-
}, FieldIsArray<Schema, Model, Field>>;
|
|
1668
|
-
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>>>;
|
|
1669
|
-
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>>;
|
|
1670
|
-
type NestedDeleteManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, true>>;
|
|
1671
|
-
type GetProcedureNames<Schema extends SchemaDef> = Schema extends {
|
|
1672
|
-
procedures: Record<string, ProcedureDef>;
|
|
1673
|
-
} ? keyof Schema['procedures'] : never;
|
|
1674
|
-
type GetProcedureParams<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
1675
|
-
procedures: Record<string, ProcedureDef>;
|
|
1676
|
-
} ? Schema['procedures'][ProcName]['params'] : never;
|
|
1677
|
-
type GetProcedure<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = Schema extends {
|
|
1678
|
-
procedures: Record<string, ProcedureDef>;
|
|
1679
|
-
} ? Schema['procedures'][ProcName] : never;
|
|
1680
|
-
type _OptionalProcedureParamNames<Params> = keyof {
|
|
1681
|
-
[K in keyof Params as Params[K] extends {
|
|
1682
|
-
optional: true;
|
|
1683
|
-
} ? K : never]: K;
|
|
1684
|
-
};
|
|
1685
|
-
type _RequiredProcedureParamNames<Params> = keyof {
|
|
1686
|
-
[K in keyof Params as Params[K] extends {
|
|
1687
|
-
optional: true;
|
|
1688
|
-
} ? never : K]: K;
|
|
1689
|
-
};
|
|
1690
|
-
type _HasRequiredProcedureParams<Params> = _RequiredProcedureParamNames<Params> extends never ? false : true;
|
|
1691
|
-
type MapProcedureArgsObject<Schema extends SchemaDef, Params> = Simplify<Optional<{
|
|
1692
|
-
[K in keyof Params]: MapProcedureParam<Schema, Params[K]>;
|
|
1693
|
-
}, _OptionalProcedureParamNames<Params>>>;
|
|
1694
|
-
type ProcedureEnvelope<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>, Params = GetProcedureParams<Schema, ProcName>> = keyof Params extends never ? {
|
|
1695
|
-
args?: Record<string, never>;
|
|
1696
|
-
} : _HasRequiredProcedureParams<Params> extends true ? {
|
|
1697
|
-
args: MapProcedureArgsObject<Schema, Params>;
|
|
1698
|
-
} : {
|
|
1699
|
-
args?: MapProcedureArgsObject<Schema, Params>;
|
|
1681
|
+
client: ClientContract<Schema>;
|
|
1700
1682
|
};
|
|
1701
|
-
type
|
|
1683
|
+
type OnKyselyQueryArgs<Schema extends SchemaDef> = {
|
|
1684
|
+
schema: SchemaDef;
|
|
1702
1685
|
client: ClientContract<Schema>;
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
* Shape of a procedure's runtime function.
|
|
1706
|
-
*/
|
|
1707
|
-
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>>>;
|
|
1708
|
-
/**
|
|
1709
|
-
* Signature for procedure handlers configured via client options.
|
|
1710
|
-
*/
|
|
1711
|
-
type ProcedureHandlerFunc<Schema extends SchemaDef, ProcName extends GetProcedureNames<Schema>> = (ctx: ProcedureHandlerCtx<Schema, ProcName>) => MaybePromise<MapProcedureReturn<Schema, GetProcedure<Schema, ProcName>>>;
|
|
1712
|
-
type MapProcedureReturn<Schema extends SchemaDef, Proc> = Proc extends {
|
|
1713
|
-
returnType: infer R;
|
|
1714
|
-
} ? Proc extends {
|
|
1715
|
-
returnArray: true;
|
|
1716
|
-
} ? Array<MapType<Schema, R & string>> : MapType<Schema, R & string> : never;
|
|
1717
|
-
type MapProcedureParam<Schema extends SchemaDef, P> = P extends {
|
|
1718
|
-
type: infer U;
|
|
1719
|
-
} ? OrUndefinedIf<P extends {
|
|
1720
|
-
array: true;
|
|
1721
|
-
} ? Array<MapType<Schema, U & string>> : MapType<Schema, U & string>, P extends {
|
|
1722
|
-
optional: true;
|
|
1723
|
-
} ? true : false> : never;
|
|
1724
|
-
type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
1725
|
-
[Key in RelationFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends {
|
|
1726
|
-
references: readonly unknown[];
|
|
1727
|
-
} ? never : Key]: true;
|
|
1686
|
+
query: RootOperationNode;
|
|
1687
|
+
proceed: ProceedKyselyQueryFunction;
|
|
1728
1688
|
};
|
|
1729
|
-
type
|
|
1730
|
-
|
|
1731
|
-
} extends never ? false : true;
|
|
1732
|
-
type EnumValue<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = GetEnum<Schema, Enum>[keyof GetEnum<Schema, Enum>];
|
|
1733
|
-
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;
|
|
1689
|
+
type ProceedKyselyQueryFunction = (query: RootOperationNode) => Promise<QueryResult<any>>;
|
|
1690
|
+
type OnKyselyQueryCallback<Schema extends SchemaDef> = (args: OnKyselyQueryArgs<Schema>) => Promise<QueryResult<UnknownRow>>;
|
|
1734
1691
|
|
|
1735
1692
|
/**
|
|
1736
1693
|
* A promise that only executes when it's awaited or .then() is called.
|
|
@@ -1744,6 +1701,10 @@ type ZenStackPromise<Schema extends SchemaDef, T> = Promise<T> & {
|
|
|
1744
1701
|
};
|
|
1745
1702
|
|
|
1746
1703
|
type TransactionUnsupportedMethods = (typeof TRANSACTION_UNSUPPORTED_METHODS)[number];
|
|
1704
|
+
/**
|
|
1705
|
+
* Extracts extended query args for a specific operation.
|
|
1706
|
+
*/
|
|
1707
|
+
type ExtractExtQueryArgs<ExtQueryArgs, Operation extends CoreCrudOperations> = (Operation extends keyof ExtQueryArgs ? ExtQueryArgs[Operation] : {}) & ('$create' extends keyof ExtQueryArgs ? Operation extends CoreCreateOperations ? ExtQueryArgs['$create'] : {} : {}) & ('$read' extends keyof ExtQueryArgs ? (Operation extends CoreReadOperations ? ExtQueryArgs['$read'] : {}) : {}) & ('$update' extends keyof ExtQueryArgs ? Operation extends CoreUpdateOperations ? ExtQueryArgs['$update'] : {} : {}) & ('$delete' extends keyof ExtQueryArgs ? Operation extends CoreDeleteOperations ? ExtQueryArgs['$delete'] : {} : {}) & ('$all' extends keyof ExtQueryArgs ? ExtQueryArgs['$all'] : {});
|
|
1747
1708
|
/**
|
|
1748
1709
|
* Transaction isolation levels.
|
|
1749
1710
|
*/
|
|
@@ -1757,7 +1718,7 @@ declare enum TransactionIsolationLevel {
|
|
|
1757
1718
|
/**
|
|
1758
1719
|
* ZenStack client interface.
|
|
1759
1720
|
*/
|
|
1760
|
-
type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Schema> = ClientOptions<Schema
|
|
1721
|
+
type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Schema> = ClientOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtClientMembers extends ExtClientMembersBase = {}> = {
|
|
1761
1722
|
/**
|
|
1762
1723
|
* The schema definition.
|
|
1763
1724
|
*/
|
|
@@ -1807,7 +1768,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
1807
1768
|
/**
|
|
1808
1769
|
* Sets the current user identity.
|
|
1809
1770
|
*/
|
|
1810
|
-
$setAuth(auth: AuthType<Schema> | undefined): ClientContract<Schema, Options>;
|
|
1771
|
+
$setAuth(auth: AuthType<Schema> | undefined): ClientContract<Schema, Options, ExtQueryArgs, ExtClientMembers>;
|
|
1811
1772
|
/**
|
|
1812
1773
|
* Returns a new client with new options applied.
|
|
1813
1774
|
* @example
|
|
@@ -1815,14 +1776,14 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
1815
1776
|
* const dbNoValidation = db.$setOptions({ ...db.$options, validateInput: false });
|
|
1816
1777
|
* ```
|
|
1817
1778
|
*/
|
|
1818
|
-
$setOptions<
|
|
1779
|
+
$setOptions<NewOptions extends ClientOptions<Schema>>(options: NewOptions): ClientContract<Schema, NewOptions, ExtQueryArgs, ExtClientMembers>;
|
|
1819
1780
|
/**
|
|
1820
1781
|
* Returns a new client enabling/disabling input validations expressed with attributes like
|
|
1821
1782
|
* `@email`, `@regex`, `@@validate`, etc.
|
|
1822
1783
|
*
|
|
1823
|
-
* @deprecated Use
|
|
1784
|
+
* @deprecated Use {@link $setOptions} instead.
|
|
1824
1785
|
*/
|
|
1825
|
-
$setInputValidation(enable: boolean): ClientContract<Schema, Options>;
|
|
1786
|
+
$setInputValidation(enable: boolean): ClientContract<Schema, Options, ExtQueryArgs, ExtClientMembers>;
|
|
1826
1787
|
/**
|
|
1827
1788
|
* The Kysely query builder instance.
|
|
1828
1789
|
*/
|
|
@@ -1834,7 +1795,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
1834
1795
|
/**
|
|
1835
1796
|
* Starts an interactive transaction.
|
|
1836
1797
|
*/
|
|
1837
|
-
$transaction<T>(callback: (tx:
|
|
1798
|
+
$transaction<T>(callback: (tx: TransactionClientContract<Schema, Options, ExtQueryArgs, ExtClientMembers>) => Promise<T>, options?: {
|
|
1838
1799
|
isolationLevel?: TransactionIsolationLevel;
|
|
1839
1800
|
}): Promise<T>;
|
|
1840
1801
|
/**
|
|
@@ -1846,11 +1807,11 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
1846
1807
|
/**
|
|
1847
1808
|
* Returns a new client with the specified plugin installed.
|
|
1848
1809
|
*/
|
|
1849
|
-
$use(plugin: RuntimePlugin<
|
|
1810
|
+
$use<PluginSchema extends SchemaDef = Schema, PluginExtQueryArgs extends ExtQueryArgsBase = {}, PluginExtClientMembers extends ExtClientMembersBase = {}>(plugin: RuntimePlugin<PluginSchema, PluginExtQueryArgs, PluginExtClientMembers>): ClientContract<Schema, Options, ExtQueryArgs & PluginExtQueryArgs, ExtClientMembers & PluginExtClientMembers>;
|
|
1850
1811
|
/**
|
|
1851
1812
|
* Returns a new client with the specified plugin removed.
|
|
1852
1813
|
*/
|
|
1853
|
-
$unuse(pluginId: string): ClientContract<Schema, Options>;
|
|
1814
|
+
$unuse(pluginId: string): ClientContract<Schema, Options, ExtQueryArgs, ExtClientMembers>;
|
|
1854
1815
|
/**
|
|
1855
1816
|
* Returns a new client with all plugins removed.
|
|
1856
1817
|
*/
|
|
@@ -1869,12 +1830,12 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
1869
1830
|
*/
|
|
1870
1831
|
$pushSchema(): Promise<void>;
|
|
1871
1832
|
} & {
|
|
1872
|
-
[Key in GetModels<Schema> as Uncapitalize<Key>]: ModelOperations<Schema, Key, ToQueryOptions<Options
|
|
1873
|
-
} & ProcedureOperations<Schema
|
|
1833
|
+
[Key in GetModels<Schema> as Uncapitalize<Key>]: ModelOperations<Schema, Key, ToQueryOptions<Options>, ExtQueryArgs>;
|
|
1834
|
+
} & ProcedureOperations<Schema> & ExtClientMembers;
|
|
1874
1835
|
/**
|
|
1875
1836
|
* The contract for a client in a transaction.
|
|
1876
1837
|
*/
|
|
1877
|
-
type TransactionClientContract<Schema extends SchemaDef, Options extends ClientOptions<Schema
|
|
1838
|
+
type TransactionClientContract<Schema extends SchemaDef, Options extends ClientOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase, ExtClientMembers extends ExtClientMembersBase> = Omit<ClientContract<Schema, Options, ExtQueryArgs, ExtClientMembers>, TransactionUnsupportedMethods>;
|
|
1878
1839
|
type ProcedureOperations<Schema extends SchemaDef> = Schema['procedures'] extends Record<string, ProcedureDef> ? {
|
|
1879
1840
|
/**
|
|
1880
1841
|
* Custom procedures.
|
|
@@ -1905,7 +1866,7 @@ type CRUD_EXT = CRUD | 'post-update';
|
|
|
1905
1866
|
* Extended CRUD operations including 'post-update'.
|
|
1906
1867
|
*/
|
|
1907
1868
|
declare const CRUD_EXT: readonly ["create", "read", "update", "delete", "post-update"];
|
|
1908
|
-
type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema
|
|
1869
|
+
type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, ExtQueryArgs> = {
|
|
1909
1870
|
/**
|
|
1910
1871
|
* Returns a list of entities.
|
|
1911
1872
|
* @param args - query args
|
|
@@ -1987,35 +1948,35 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
1987
1948
|
* }); // result: `{ _count: { posts: number } }`
|
|
1988
1949
|
* ```
|
|
1989
1950
|
*/
|
|
1990
|
-
findMany<T extends FindManyArgs<Schema, Model>>(args?: SelectSubset<T, FindManyArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
1951
|
+
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>[]>;
|
|
1991
1952
|
/**
|
|
1992
1953
|
* Returns a uniquely identified entity.
|
|
1993
1954
|
* @param args - query args
|
|
1994
1955
|
* @returns a single entity or null if not found
|
|
1995
1956
|
* @see {@link findMany}
|
|
1996
1957
|
*/
|
|
1997
|
-
findUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
|
|
1958
|
+
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>;
|
|
1998
1959
|
/**
|
|
1999
1960
|
* Returns a uniquely identified entity or throws `NotFoundError` if not found.
|
|
2000
1961
|
* @param args - query args
|
|
2001
1962
|
* @returns a single entity
|
|
2002
1963
|
* @see {@link findMany}
|
|
2003
1964
|
*/
|
|
2004
|
-
findUniqueOrThrow<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
1965
|
+
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>>;
|
|
2005
1966
|
/**
|
|
2006
1967
|
* Returns the first entity.
|
|
2007
1968
|
* @param args - query args
|
|
2008
1969
|
* @returns a single entity or null if not found
|
|
2009
1970
|
* @see {@link findMany}
|
|
2010
1971
|
*/
|
|
2011
|
-
findFirst<T extends FindFirstArgs<Schema, Model>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
|
|
1972
|
+
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>;
|
|
2012
1973
|
/**
|
|
2013
1974
|
* Returns the first entity or throws `NotFoundError` if not found.
|
|
2014
1975
|
* @param args - query args
|
|
2015
1976
|
* @returns a single entity
|
|
2016
1977
|
* @see {@link findMany}
|
|
2017
1978
|
*/
|
|
2018
|
-
findFirstOrThrow<T extends FindFirstArgs<Schema, Model>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
1979
|
+
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>>;
|
|
2019
1980
|
/**
|
|
2020
1981
|
* Creates a new entity.
|
|
2021
1982
|
* @param args - create args
|
|
@@ -2068,7 +2029,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2068
2029
|
* });
|
|
2069
2030
|
* ```
|
|
2070
2031
|
*/
|
|
2071
|
-
create<T extends CreateArgs<Schema, Model>>(args: SelectSubset<T, CreateArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2032
|
+
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>>;
|
|
2072
2033
|
/**
|
|
2073
2034
|
* Creates multiple entities. Only scalar fields are allowed.
|
|
2074
2035
|
* @param args - create args
|
|
@@ -2094,7 +2055,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2094
2055
|
* });
|
|
2095
2056
|
* ```
|
|
2096
2057
|
*/
|
|
2097
|
-
createMany<T extends CreateManyArgs<Schema, Model>>(args?: SelectSubset<T, CreateManyArgs<Schema, Model>>): ZenStackPromise<Schema, BatchResult>;
|
|
2058
|
+
createMany<T extends CreateManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'createMany'>>(args?: SelectSubset<T, CreateManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'createMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2098
2059
|
/**
|
|
2099
2060
|
* Creates multiple entities and returns them.
|
|
2100
2061
|
* @param args - create args. See {@link createMany} for input. Use
|
|
@@ -2113,7 +2074,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2113
2074
|
* });
|
|
2114
2075
|
* ```
|
|
2115
2076
|
*/
|
|
2116
|
-
createManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(args?: SelectSubset<T, CreateManyAndReturnArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
2077
|
+
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>[]>;
|
|
2117
2078
|
/**
|
|
2118
2079
|
* Updates a uniquely identified entity.
|
|
2119
2080
|
* @param args - update args. See {@link findMany} for how to control
|
|
@@ -2231,7 +2192,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2231
2192
|
* });
|
|
2232
2193
|
* ```
|
|
2233
2194
|
*/
|
|
2234
|
-
update<T extends UpdateArgs<Schema, Model>>(args: SelectSubset<T, UpdateArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2195
|
+
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>>;
|
|
2235
2196
|
/**
|
|
2236
2197
|
* Updates multiple entities.
|
|
2237
2198
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2252,7 +2213,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2252
2213
|
* limit: 10
|
|
2253
2214
|
* });
|
|
2254
2215
|
*/
|
|
2255
|
-
updateMany<T extends UpdateManyArgs<Schema, Model>>(args: Subset<T, UpdateManyArgs<Schema, Model>>): ZenStackPromise<Schema, BatchResult>;
|
|
2216
|
+
updateMany<T extends UpdateManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'updateMany'>>(args: Subset<T, UpdateManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'updateMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2256
2217
|
/**
|
|
2257
2218
|
* Updates multiple entities and returns them.
|
|
2258
2219
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2275,7 +2236,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2275
2236
|
* });
|
|
2276
2237
|
* ```
|
|
2277
2238
|
*/
|
|
2278
|
-
updateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(args: Subset<T, UpdateManyAndReturnArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
|
|
2239
|
+
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>[]>;
|
|
2279
2240
|
/**
|
|
2280
2241
|
* Creates or updates an entity.
|
|
2281
2242
|
* @param args - upsert args
|
|
@@ -2296,7 +2257,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2296
2257
|
* });
|
|
2297
2258
|
* ```
|
|
2298
2259
|
*/
|
|
2299
|
-
upsert<T extends UpsertArgs<Schema, Model>>(args: SelectSubset<T, UpsertArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2260
|
+
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>>;
|
|
2300
2261
|
/**
|
|
2301
2262
|
* Deletes a uniquely identifiable entity.
|
|
2302
2263
|
* @param args - delete args
|
|
@@ -2316,7 +2277,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2316
2277
|
* }); // result: `{ id: string; email: string }`
|
|
2317
2278
|
* ```
|
|
2318
2279
|
*/
|
|
2319
|
-
delete<T extends DeleteArgs<Schema, Model>>(args: SelectSubset<T, DeleteArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
|
|
2280
|
+
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>>;
|
|
2320
2281
|
/**
|
|
2321
2282
|
* Deletes multiple entities.
|
|
2322
2283
|
* @param args - delete args
|
|
@@ -2336,7 +2297,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2336
2297
|
* });
|
|
2337
2298
|
* ```
|
|
2338
2299
|
*/
|
|
2339
|
-
deleteMany<T extends DeleteManyArgs<Schema, Model>>(args?: Subset<T, DeleteManyArgs<Schema, Model>>): ZenStackPromise<Schema, BatchResult>;
|
|
2300
|
+
deleteMany<T extends DeleteManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'deleteMany'>>(args?: Subset<T, DeleteManyArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'deleteMany'>>): ZenStackPromise<Schema, BatchResult>;
|
|
2340
2301
|
/**
|
|
2341
2302
|
* Counts rows or field values.
|
|
2342
2303
|
* @param args - count args
|
|
@@ -2355,7 +2316,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2355
2316
|
* select: { _all: true, email: true }
|
|
2356
2317
|
* }); // result: `{ _all: number, email: number }`
|
|
2357
2318
|
*/
|
|
2358
|
-
count<T extends CountArgs<Schema, Model>>(args?: Subset<T, CountArgs<Schema, Model>>): ZenStackPromise<Schema, Simplify<CountResult<Schema, Model, T>>>;
|
|
2319
|
+
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>>>;
|
|
2359
2320
|
/**
|
|
2360
2321
|
* Aggregates rows.
|
|
2361
2322
|
* @param args - aggregation args
|
|
@@ -2373,7 +2334,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2373
2334
|
* _max: { age: true }
|
|
2374
2335
|
* }); // result: `{ _count: number, _avg: { age: number }, ... }`
|
|
2375
2336
|
*/
|
|
2376
|
-
aggregate<T extends AggregateArgs<Schema, Model>>(args: Subset<T, AggregateArgs<Schema, Model>>): ZenStackPromise<Schema, Simplify<AggregateResult<Schema, Model, T>>>;
|
|
2337
|
+
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>>>;
|
|
2377
2338
|
/**
|
|
2378
2339
|
* Groups rows by columns.
|
|
2379
2340
|
* @param args - groupBy args
|
|
@@ -2407,7 +2368,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2407
2368
|
* having: { country: 'US', age: { _avg: { gte: 18 } } }
|
|
2408
2369
|
* });
|
|
2409
2370
|
*/
|
|
2410
|
-
groupBy<T extends GroupByArgs<Schema, Model>>(args: Subset<T, GroupByArgs<Schema, Model>>): ZenStackPromise<Schema, Simplify<GroupByResult<Schema, Model, T>>>;
|
|
2371
|
+
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>>>;
|
|
2411
2372
|
/**
|
|
2412
2373
|
* Checks if an entity exists.
|
|
2413
2374
|
* @param args - exists args
|
|
@@ -2425,10 +2386,10 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2425
2386
|
* where: { posts: { some: { published: true } } },
|
|
2426
2387
|
* }); // result: `boolean`
|
|
2427
2388
|
*/
|
|
2428
|
-
exists<T extends ExistsArgs<Schema, Model>>(args?: Subset<T, ExistsArgs<Schema, Model>>): ZenStackPromise<Schema, boolean>;
|
|
2389
|
+
exists<T extends ExistsArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'exists'>>(args?: Subset<T, ExistsArgs<Schema, Model> & ExtractExtQueryArgs<ExtQueryArgs, 'exists'>>): ZenStackPromise<Schema, boolean>;
|
|
2429
2390
|
};
|
|
2430
2391
|
type OperationsIneligibleForDelegateModels = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert';
|
|
2431
|
-
type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema
|
|
2392
|
+
type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ExtQueryArgs = {}> = Omit<AllModelOperations<Schema, Model, Options, ExtQueryArgs>, IsDelegateModel<Schema, Model> extends true ? OperationsIneligibleForDelegateModels : never>;
|
|
2432
2393
|
/**
|
|
2433
2394
|
* Type for auth context that includes both scalar and relation fields.
|
|
2434
2395
|
* Relations are recursively included to allow nested auth data like { user: { profile: { ... } } }
|
|
@@ -2438,6 +2399,117 @@ type AuthModelType<Schema extends SchemaDef, Model extends GetModels<Schema>> =
|
|
|
2438
2399
|
};
|
|
2439
2400
|
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>;
|
|
2440
2401
|
|
|
2402
|
+
type ZModelFunctionContext<Schema extends SchemaDef> = {
|
|
2403
|
+
/**
|
|
2404
|
+
* ZenStack client instance
|
|
2405
|
+
*/
|
|
2406
|
+
client: ClientContract<Schema>;
|
|
2407
|
+
/**
|
|
2408
|
+
* Database dialect
|
|
2409
|
+
*/
|
|
2410
|
+
dialect: BaseCrudDialect<Schema>;
|
|
2411
|
+
/**
|
|
2412
|
+
* The containing model name
|
|
2413
|
+
*/
|
|
2414
|
+
model: GetModels<Schema>;
|
|
2415
|
+
/**
|
|
2416
|
+
* The alias name that can be used to refer to the containing model
|
|
2417
|
+
*/
|
|
2418
|
+
modelAlias: string;
|
|
2419
|
+
/**
|
|
2420
|
+
* The CRUD operation being performed
|
|
2421
|
+
*/
|
|
2422
|
+
operation: CRUD_EXT;
|
|
2423
|
+
};
|
|
2424
|
+
type ZModelFunction<Schema extends SchemaDef> = (eb: ExpressionBuilder<ToKyselySchema<Schema>, keyof ToKyselySchema<Schema>>, args: Expression<any>[], context: ZModelFunctionContext<Schema>) => Expression<unknown>;
|
|
2425
|
+
/**
|
|
2426
|
+
* ZenStack client options.
|
|
2427
|
+
*/
|
|
2428
|
+
type ClientOptions<Schema extends SchemaDef> = {
|
|
2429
|
+
/**
|
|
2430
|
+
* Kysely dialect.
|
|
2431
|
+
*/
|
|
2432
|
+
dialect: Dialect;
|
|
2433
|
+
/**
|
|
2434
|
+
* Custom function definitions.
|
|
2435
|
+
*
|
|
2436
|
+
* @private
|
|
2437
|
+
*/
|
|
2438
|
+
functions?: Record<string, ZModelFunction<Schema>>;
|
|
2439
|
+
/**
|
|
2440
|
+
* Plugins.
|
|
2441
|
+
*/
|
|
2442
|
+
plugins?: AnyPlugin[];
|
|
2443
|
+
/**
|
|
2444
|
+
* Logging configuration.
|
|
2445
|
+
*/
|
|
2446
|
+
log?: KyselyConfig['log'];
|
|
2447
|
+
/**
|
|
2448
|
+
* Whether to automatically fix timezone for `DateTime` fields returned by node-pg. Defaults
|
|
2449
|
+
* to `true`.
|
|
2450
|
+
*
|
|
2451
|
+
* Node-pg has a terrible quirk that it interprets the date value as local timezone (as a
|
|
2452
|
+
* `Date` object) although for `DateTime` field the data in DB is stored in UTC.
|
|
2453
|
+
* @see https://github.com/brianc/node-postgres/issues/429
|
|
2454
|
+
*/
|
|
2455
|
+
fixPostgresTimezone?: boolean;
|
|
2456
|
+
/**
|
|
2457
|
+
* Whether to enable input validations expressed with attributes like `@email`, `@regex`,
|
|
2458
|
+
* `@@validate`, etc. Defaults to `true`.
|
|
2459
|
+
*/
|
|
2460
|
+
validateInput?: boolean;
|
|
2461
|
+
/**
|
|
2462
|
+
* Options for omitting fields in ORM query results.
|
|
2463
|
+
*/
|
|
2464
|
+
omit?: OmitConfig<Schema>;
|
|
2465
|
+
/**
|
|
2466
|
+
* Whether to allow overriding omit settings at query time. Defaults to `true`. When set to
|
|
2467
|
+
* `false`, an `omit` clause that sets field to `false` (not omitting) will trigger a validation
|
|
2468
|
+
* error.
|
|
2469
|
+
*/
|
|
2470
|
+
allowQueryTimeOmitOverride?: boolean;
|
|
2471
|
+
} & (HasComputedFields<Schema> extends true ? {
|
|
2472
|
+
/**
|
|
2473
|
+
* Computed field definitions.
|
|
2474
|
+
*/
|
|
2475
|
+
computedFields: ComputedFieldsOptions<Schema>;
|
|
2476
|
+
} : {}) & (HasProcedures<Schema> extends true ? {
|
|
2477
|
+
/**
|
|
2478
|
+
* Custom procedure definitions.
|
|
2479
|
+
*/
|
|
2480
|
+
procedures: ProceduresOptions<Schema>;
|
|
2481
|
+
} : {});
|
|
2482
|
+
/**
|
|
2483
|
+
* Config for omitting fields in ORM query results.
|
|
2484
|
+
*/
|
|
2485
|
+
type OmitConfig<Schema extends SchemaDef> = {
|
|
2486
|
+
[Model in GetModels<Schema>]?: {
|
|
2487
|
+
[Field in GetModelFields<Schema, Model> as Field extends ScalarFields<Schema, Model> ? Field : never]?: boolean;
|
|
2488
|
+
};
|
|
2489
|
+
};
|
|
2490
|
+
type ComputedFieldsOptions<Schema extends SchemaDef> = {
|
|
2491
|
+
[Model in GetModels<Schema> as 'computedFields' extends keyof GetModel<Schema, Model> ? Model : never]: {
|
|
2492
|
+
[Field in keyof Schema['models'][Model]['computedFields']]: PrependParameter<ExpressionBuilder<ToKyselySchema<Schema>, Model>, Schema['models'][Model]['computedFields'][Field]>;
|
|
2493
|
+
};
|
|
2494
|
+
};
|
|
2495
|
+
type HasComputedFields<Schema extends SchemaDef> = string extends GetModels<Schema> ? false : keyof ComputedFieldsOptions<Schema> extends never ? false : true;
|
|
2496
|
+
type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
|
|
2497
|
+
procedures: Record<string, ProcedureDef>;
|
|
2498
|
+
} ? {
|
|
2499
|
+
[Key in GetProcedureNames<Schema>]: ProcedureHandlerFunc<Schema, Key>;
|
|
2500
|
+
} : {};
|
|
2501
|
+
type HasProcedures<Schema extends SchemaDef> = Schema extends {
|
|
2502
|
+
procedures: Record<string, ProcedureDef>;
|
|
2503
|
+
} ? true : false;
|
|
2504
|
+
/**
|
|
2505
|
+
* Subset of client options relevant to query operations.
|
|
2506
|
+
*/
|
|
2507
|
+
type QueryOptions<Schema extends SchemaDef> = Pick<ClientOptions<Schema>, 'omit'>;
|
|
2508
|
+
/**
|
|
2509
|
+
* Extract QueryOptions from ClientOptions
|
|
2510
|
+
*/
|
|
2511
|
+
type ToQueryOptions<T extends ClientOptions<any>> = Pick<T, 'omit'>;
|
|
2512
|
+
|
|
2441
2513
|
/**
|
|
2442
2514
|
* ZenStack ORM client.
|
|
2443
2515
|
*/
|
|
@@ -2670,4 +2742,4 @@ declare namespace schemaUtils {
|
|
|
2670
2742
|
export { schemaUtils_ExpressionVisitor as ExpressionVisitor, schemaUtils_MatchingExpressionVisitor as MatchingExpressionVisitor, type schemaUtils_VisitResult as VisitResult };
|
|
2671
2743
|
}
|
|
2672
2744
|
|
|
2673
|
-
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, type AllModelOperations, AnyNull, AnyNullClass, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type
|
|
2745
|
+
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 ToQueryOptions, 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 };
|