@zenstackhq/orm 3.6.4 → 3.7.0
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/common-types.cjs +23 -0
- package/dist/common-types.cjs.map +1 -0
- package/dist/common-types.d.cts +25 -0
- package/dist/common-types.d.mts +25 -0
- package/dist/common-types.mjs +17 -0
- package/dist/common-types.mjs.map +1 -0
- package/dist/index.cjs +408 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +364 -69
- package/dist/index.d.mts +366 -71
- package/dist/index.mjs +534 -239
- package/dist/index.mjs.map +1 -1
- package/package.json +21 -10
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonArray, JsonNull, JsonNullClass, JsonNullValues, JsonObject, JsonValue } from "./common-types.cjs";
|
|
1
2
|
import * as _$kysely from "kysely";
|
|
2
|
-
import { AddColumnNode, AddConstraintNode, AddIndexNode, AggregateFunctionNode, AliasNode, AliasableExpression, AlterColumnNode, AlterTableNode, AndNode, BinaryOperationNode, CaseNode, CastNode, CheckConstraintNode, CollateNode, ColumnDefinitionNode, ColumnNode, ColumnUpdateNode, CommonTableExpressionNameNode, CommonTableExpressionNode, CreateIndexNode, CreateSchemaNode, CreateTableNode, CreateTypeNode, CreateViewNode, DataTypeNode, DefaultInsertValueNode, DefaultValueNode, DeleteQueryNode, Dialect, DropColumnNode, DropConstraintNode, DropIndexNode, DropSchemaNode, DropTableNode, DropTypeNode, DropViewNode, ExplainNode, Expression, ExpressionBuilder, ExpressionWrapper, FetchNode, ForeignKeyConstraintNode, FromNode, FunctionNode, Generated, GeneratedNode, GroupByItemNode, GroupByNode, HavingNode, IdentifierNode, InsertQueryNode, JSONOperatorChainNode, JSONPathLegNode, JSONPathNode, JSONReferenceNode, JoinNode, Kysely, KyselyConfig, LimitNode, ListNode, MatchedNode, MergeQueryNode, ModifyColumnNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, OnNode, OperandExpression, OperationNode, OperationNodeVisitor, OperatorNode, OrActionNode, OrNode, OrderByItemNode, OrderByNode, OutputNode, OverNode, ParensNode, PartitionByItemNode, PartitionByNode, PrimaryKeyConstraintNode, PrimitiveValueListNode, QueryId, QueryResult, RawNode, ReferenceNode, ReferencesNode, RefreshMaterializedViewNode, RenameColumnNode, RenameConstraintNode, ReturningNode, RootOperationNode, SchemableIdentifierNode, SelectAllNode, SelectModifierNode, SelectQueryBuilder, SelectQueryNode, SelectionNode, SetOperationNode, SqlBool, TableNode, TopNode, TupleNode, UnaryOperationNode, UniqueConstraintNode, UnknownRow, UpdateQueryNode, UsingNode, ValueListNode, ValueNode, ValuesNode, WhenNode, WhereNode, WithNode } from "kysely";
|
|
3
|
+
import { AddColumnNode, AddConstraintNode, AddIndexNode, AddValueNode, AggregateFunctionNode, AliasNode, AliasableExpression, AlterColumnNode, AlterTableNode, AlterTypeNode, AndNode, BinaryOperationNode, CaseNode, CastNode, CheckConstraintNode, CollateNode, ColumnDefinitionNode, ColumnNode, ColumnUpdateNode, CommonTableExpressionNameNode, CommonTableExpressionNode, CreateIndexNode, CreateSchemaNode, CreateTableNode, CreateTypeNode, CreateViewNode, DataTypeNode, DefaultInsertValueNode, DefaultValueNode, DeleteQueryNode, Dialect, DropColumnNode, DropConstraintNode, DropIndexNode, DropSchemaNode, DropTableNode, DropTypeNode, DropViewNode, ExplainNode, Expression, ExpressionBuilder, ExpressionWrapper, FetchNode, ForeignKeyConstraintNode, FromNode, FunctionNode, Generated, GeneratedNode, GroupByItemNode, GroupByNode, HavingNode, IdentifierNode, InsertQueryNode, JSONOperatorChainNode, JSONPathLegNode, JSONPathNode, JSONReferenceNode, JoinNode, Kysely, KyselyConfig, LimitNode, ListNode, MatchedNode, MergeQueryNode, ModifyColumnNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, OnNode, OperandExpression, OperationNode, OperationNodeVisitor, OperatorNode, OrActionNode, OrNode, OrderByItemNode, OrderByNode, OutputNode, OverNode, ParensNode, PartitionByItemNode, PartitionByNode, PrimaryKeyConstraintNode, PrimitiveValueListNode, QueryId, QueryResult, RawNode, ReferenceNode, ReferencesNode, RefreshMaterializedViewNode, RenameColumnNode, RenameConstraintNode, RenameValueNode, ReturningNode, RootOperationNode, SchemableIdentifierNode, SelectAllNode, SelectModifierNode, SelectQueryBuilder, SelectQueryNode, SelectionNode, SetOperationNode, SqlBool, TableNode, TopNode, TupleNode, UnaryOperationNode, UniqueConstraintNode, UnknownRow, UpdateQueryNode, UsingNode, ValueListNode, ValueNode, ValuesNode, WhenNode, WhereNode, WithNode } from "kysely";
|
|
3
4
|
import * as _$_zenstackhq_schema0 from "@zenstackhq/schema";
|
|
4
5
|
import { ArrayExpression, BinaryExpression, BindingExpression, BuiltinType, CallExpression, DataSourceProviderType, Expression as Expression$1, FieldDef, FieldExpression, FieldHasDefault, FieldIsArray, FieldIsDelegateDiscriminator, FieldIsRelation, FieldType, ForeignKeyFields, GetEnum, GetEnums, GetModel, GetModelDiscriminator, GetModelField, GetModelFieldType, GetModelFields, GetModels, GetSubModels, GetTypeDefField, GetTypeDefFieldType, GetTypeDefFields, GetTypeDefs, IsDelegateModel, LiteralExpression, MemberExpression, ModelDef, ModelFieldIsOptional, NonRelationFields, NullExpression, ProcedureDef, RelationFieldType, RelationFields, RelationInfo, ScalarFields, SchemaDef, ThisExpression, TypeDefFieldIsArray, TypeDefFieldIsOptional, UnaryExpression, UpdatedAtInfo } from "@zenstackhq/schema";
|
|
5
6
|
import { ZodType, z } from "zod";
|
|
@@ -108,32 +109,12 @@ declare class DefaultOperationNodeVisitor extends OperationNodeVisitor {
|
|
|
108
109
|
protected visitRefreshMaterializedView(node: RefreshMaterializedViewNode): void;
|
|
109
110
|
protected visitOrAction(node: OrActionNode): void;
|
|
110
111
|
protected visitCollate(node: CollateNode): void;
|
|
112
|
+
protected visitAlterType(node: AlterTypeNode): void;
|
|
113
|
+
protected visitAddValue(node: AddValueNode): void;
|
|
114
|
+
protected visitRenameValue(node: RenameValueNode): void;
|
|
111
115
|
}
|
|
112
116
|
type AnyKysely = Kysely<any>;
|
|
113
117
|
//#endregion
|
|
114
|
-
//#region src/common-types.d.ts
|
|
115
|
-
type JsonValue = string | number | boolean | JsonObject | JsonArray;
|
|
116
|
-
type JsonObject = {
|
|
117
|
-
[key: string]: JsonValue | null;
|
|
118
|
-
};
|
|
119
|
-
type JsonArray = Array<JsonValue | null>;
|
|
120
|
-
type JsonNullValues = DbNull | JsonNull | AnyNull;
|
|
121
|
-
declare class DbNullClass {
|
|
122
|
-
private __brand;
|
|
123
|
-
}
|
|
124
|
-
declare const DbNull: DbNullClass;
|
|
125
|
-
type DbNull = typeof DbNull;
|
|
126
|
-
declare class JsonNullClass {
|
|
127
|
-
private __brand;
|
|
128
|
-
}
|
|
129
|
-
declare const JsonNull: JsonNullClass;
|
|
130
|
-
type JsonNull = typeof JsonNull;
|
|
131
|
-
declare class AnyNullClass {
|
|
132
|
-
private __brand;
|
|
133
|
-
}
|
|
134
|
-
declare const AnyNull: AnyNullClass;
|
|
135
|
-
type AnyNull = typeof AnyNull;
|
|
136
|
-
//#endregion
|
|
137
118
|
//#region src/utils/type-utils.d.ts
|
|
138
119
|
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
139
120
|
type PartialIf<T, Condition extends boolean> = Condition extends true ? Partial<T> : T;
|
|
@@ -151,7 +132,7 @@ type TypeMap = {
|
|
|
151
132
|
Decimal: Decimal;
|
|
152
133
|
DateTime: Date;
|
|
153
134
|
Bytes: Uint8Array;
|
|
154
|
-
Json: JsonValue;
|
|
135
|
+
Json: JsonValue | null;
|
|
155
136
|
Null: null;
|
|
156
137
|
Object: Record<string, unknown>;
|
|
157
138
|
Any: unknown;
|
|
@@ -214,6 +195,8 @@ declare const FILTER_PROPERTY_TO_KIND: {
|
|
|
214
195
|
readonly array_contains: "Json";
|
|
215
196
|
readonly array_starts_with: "Json";
|
|
216
197
|
readonly array_ends_with: "Json";
|
|
198
|
+
readonly fuzzy: "Fuzzy";
|
|
199
|
+
readonly fts: "FullText";
|
|
217
200
|
readonly has: "List";
|
|
218
201
|
readonly hasEvery: "List";
|
|
219
202
|
readonly hasSome: "List";
|
|
@@ -326,7 +309,7 @@ interface RuntimePlugin<Schema extends SchemaDef, ExtQueryArgs extends ExtQueryA
|
|
|
326
309
|
*/
|
|
327
310
|
result?: ExtResult;
|
|
328
311
|
}
|
|
329
|
-
type AnyPlugin = RuntimePlugin<
|
|
312
|
+
type AnyPlugin = RuntimePlugin<SchemaDef, any, any, any>;
|
|
330
313
|
/**
|
|
331
314
|
* Defines a ZenStack runtime plugin based on type of the given schema.
|
|
332
315
|
*
|
|
@@ -756,8 +739,13 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
756
739
|
abstract get insertIgnoreMethod(): 'onConflict' | 'ignore';
|
|
757
740
|
/**
|
|
758
741
|
* Transforms input value before sending to database.
|
|
742
|
+
*
|
|
743
|
+
* `fieldDef` is optional so existing callers that don't have it stay
|
|
744
|
+
* source-compatible. Dialects can use it to inspect `@db.*` native-type
|
|
745
|
+
* attributes (e.g. to format `@db.Time` values as `HH:MM:SS` rather than
|
|
746
|
+
* full ISO timestamps).
|
|
759
747
|
*/
|
|
760
|
-
transformInput(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
748
|
+
transformInput(value: unknown, _type: BuiltinType, _forArrayField: boolean, _fieldDef?: FieldDef): unknown;
|
|
761
749
|
/**
|
|
762
750
|
* Transforms output value received from database.
|
|
763
751
|
*/
|
|
@@ -793,6 +781,11 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
793
781
|
private buildBytesFilter;
|
|
794
782
|
private buildEnumFilter;
|
|
795
783
|
buildOrderBy(query: SelectQueryBuilder<any, any, any>, model: string, modelAlias: string, orderBy: OrArray<OrderBy<Schema, GetModels<Schema>, boolean, boolean>> | undefined, negated: boolean, take: number | undefined): SelectQueryBuilder<any, any, any>;
|
|
784
|
+
private applyRelationOrderBy;
|
|
785
|
+
private applyScalarOrderBy;
|
|
786
|
+
private applyAggregationOrderBy;
|
|
787
|
+
private applyFuzzyRelevanceOrderBy;
|
|
788
|
+
private applyFtsRelevanceOrderBy;
|
|
796
789
|
buildSelectAllFields(model: string, query: SelectQueryBuilder<any, any, any>, omit: Record<string, boolean | undefined> | undefined | null, modelAlias: string): SelectQueryBuilder<any, any, any>;
|
|
797
790
|
shouldOmitField(omit: unknown, model: string, field: string): any;
|
|
798
791
|
protected buildModelSelect(model: GetModels<Schema>, subQueryAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, any, true>, selectAllFields: boolean): SelectQueryBuilder<any, any, {}>;
|
|
@@ -888,7 +881,44 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
888
881
|
* Builds an ORDER BY clause for a field with NULLS FIRST/LAST support.
|
|
889
882
|
*/
|
|
890
883
|
protected abstract buildOrderByField(query: SelectQueryBuilder<any, any, any>, field: Expression<unknown>, sort: SortOrder, nulls: 'first' | 'last'): SelectQueryBuilder<any, any, any>;
|
|
884
|
+
/**
|
|
885
|
+
* Builds a fuzzy search filter for a string field using PostgreSQL `pg_trgm`.
|
|
886
|
+
* The selected SQL form (operator vs. function, with/without `unaccent`) depends
|
|
887
|
+
* on the resolved options.
|
|
888
|
+
*/
|
|
889
|
+
abstract buildFuzzyFilter(fieldRef: Expression<any>, options: FuzzyFilterOptions): Expression<SqlBool>;
|
|
890
|
+
/**
|
|
891
|
+
* Builds an ORDER BY clause that sorts by fuzzy relevance to a search term.
|
|
892
|
+
*/
|
|
893
|
+
abstract buildFuzzyRelevanceOrderBy(query: SelectQueryBuilder<any, any, any>, fieldRefs: Expression<any>[], search: string, sort: SortOrder, mode: FuzzyFilterOptions['mode'], unaccent: boolean): SelectQueryBuilder<any, any, any>;
|
|
894
|
+
/**
|
|
895
|
+
* Validate the user-provided fuzzy filter payload and apply defaults so dialects
|
|
896
|
+
* always receive a fully-resolved {@link FuzzyFilterOptions} value.
|
|
897
|
+
*/
|
|
898
|
+
protected normalizeFuzzyOptions(value: unknown): FuzzyFilterOptions;
|
|
899
|
+
/**
|
|
900
|
+
* Builds a full-text-search filter for a string field. Receives the raw
|
|
901
|
+
* user-supplied filter payload — dialects validate/normalize it themselves
|
|
902
|
+
* (the shape is provider-specific; only Postgres supports this filter).
|
|
903
|
+
*/
|
|
904
|
+
abstract buildFullTextFilter(fieldRef: Expression<any>, payload: unknown): Expression<SqlBool>;
|
|
905
|
+
/**
|
|
906
|
+
* Builds an ORDER BY clause that sorts by full-text-search relevance to a search term.
|
|
907
|
+
*/
|
|
908
|
+
abstract buildFtsRelevanceOrderBy(query: SelectQueryBuilder<any, any, any>, fieldRefs: Expression<any>[], search: string, config: string | undefined, sort: SortOrder): SelectQueryBuilder<any, any, any>;
|
|
891
909
|
}
|
|
910
|
+
/**
|
|
911
|
+
* Resolved options for a fuzzy filter passed to a dialect. `mode` and `unaccent`
|
|
912
|
+
* are always populated (defaults: `mode='simple'`, `unaccent=false`, applied by
|
|
913
|
+
* `normalizeFuzzyOptions`); `threshold` is optional and switches the SQL from
|
|
914
|
+
* operator form (`%`, `<%`, `<<%`) to function form (`similarity() > threshold`).
|
|
915
|
+
*/
|
|
916
|
+
type FuzzyFilterOptions = {
|
|
917
|
+
search: string;
|
|
918
|
+
mode: 'simple' | 'word' | 'strictWord';
|
|
919
|
+
threshold?: number;
|
|
920
|
+
unaccent: boolean;
|
|
921
|
+
};
|
|
892
922
|
//#endregion
|
|
893
923
|
//#region src/client/crud/validator/validator.d.ts
|
|
894
924
|
type InputValidatorOptions = {
|
|
@@ -1111,7 +1141,43 @@ type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Optio
|
|
|
1111
1141
|
OR?: WhereInput<Schema, Model, Options, ScalarOnly>[];
|
|
1112
1142
|
NOT?: OrArray<WhereInput<Schema, Model, Options, ScalarOnly>>;
|
|
1113
1143
|
};
|
|
1114
|
-
type FieldFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>, WithAggregations extends boolean, AllowedKinds extends FilterKind = GetSlicedFilterKindsForField<Schema, Model, Field, Options>> = Field extends RelationFields<Schema, Model> ? RelationFilter<Schema, Model, Field, Options, AllowedKinds> : FieldIsArray<Schema, Model, Field> extends true ? ArrayFilter<Schema, GetModelFieldType<Schema, Model, Field>, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends GetEnums<Schema> ? EnumFilter<Schema, GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetModelFieldType<Schema, Model, Field>, FieldIsArray<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, AllowedKinds> : PrimitiveFilter<GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds>;
|
|
1144
|
+
type FieldFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>, WithAggregations extends boolean, AllowedKinds extends FilterKind = GetSlicedFilterKindsForField<Schema, Model, Field, Options>> = Field extends RelationFields<Schema, Model> ? RelationFilter<Schema, Model, Field, Options, AllowedKinds> : FieldIsArray<Schema, Model, Field> extends true ? ArrayFilter<Schema, GetModelFieldType<Schema, Model, Field>, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends GetEnums<Schema> ? EnumFilter<Schema, GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetModelFieldType<Schema, Model, Field>, FieldIsArray<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, AllowedKinds> : GetModelFieldType<Schema, Model, Field> extends 'String' ? AddFullTextFilterIfSupported<Schema, Model, Field, AllowedKinds, AddFuzzyFilterIfSupported<Schema, Model, Field, AllowedKinds, PrimitiveFilter<GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds>>> : PrimitiveFilter<GetModelFieldType<Schema, Model, Field>, ModelFieldIsOptional<Schema, Model, Field>, WithAggregations, AllowedKinds>;
|
|
1145
|
+
/**
|
|
1146
|
+
* Conditionally augments a string-field filter with the `fuzzy` operator when:
|
|
1147
|
+
* 1. The `Fuzzy` filter kind is allowed for this field, AND
|
|
1148
|
+
* 2. The schema's provider supports fuzzy search (postgres only), AND
|
|
1149
|
+
* 3. The field is annotated with `@fuzzy` in the ZModel schema.
|
|
1150
|
+
*
|
|
1151
|
+
* Caller is responsible for only invoking this on String-typed fields
|
|
1152
|
+
* (the gate lives in `FieldFilter`).
|
|
1153
|
+
*/
|
|
1154
|
+
type AddFuzzyFilterIfSupported<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, AllowedKinds extends FilterKind, Base> = 'Fuzzy' extends AllowedKinds ? ProviderSupportsFuzzy<Schema> extends true ? GetModelField<Schema, Model, Field>['fuzzy'] extends true ? Base & {
|
|
1155
|
+
/**
|
|
1156
|
+
* Performs a fuzzy search on the string field. Only available when
|
|
1157
|
+
* the schema's provider is `postgresql` (requires `pg_trgm` extension)
|
|
1158
|
+
* and the field is annotated with `@fuzzy` in the ZModel schema.
|
|
1159
|
+
* See {@link FuzzyFilterPayload} for the full options reference.
|
|
1160
|
+
*/
|
|
1161
|
+
fuzzy?: FuzzyFilterPayload;
|
|
1162
|
+
} : Base : Base : Base;
|
|
1163
|
+
/**
|
|
1164
|
+
* Conditionally augments a string-field filter with the `fts` operator when:
|
|
1165
|
+
* 1. The `FullText` filter kind is allowed for this field, AND
|
|
1166
|
+
* 2. The schema's provider supports full-text search (postgres only), AND
|
|
1167
|
+
* 3. The field is annotated with `@fullText` in the ZModel schema.
|
|
1168
|
+
*
|
|
1169
|
+
* Caller is responsible for only invoking this on String-typed fields
|
|
1170
|
+
* (the gate lives in `FieldFilter`).
|
|
1171
|
+
*/
|
|
1172
|
+
type AddFullTextFilterIfSupported<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, AllowedKinds extends FilterKind, Base> = 'FullText' extends AllowedKinds ? ProviderSupportsFullText<Schema> extends true ? GetModelField<Schema, Model, Field>['fullText'] extends true ? Base & {
|
|
1173
|
+
/**
|
|
1174
|
+
* Performs a full-text search on the string field. Only available when
|
|
1175
|
+
* the schema's provider is `postgresql` and the field is annotated with
|
|
1176
|
+
* `@fullText` in the ZModel schema.
|
|
1177
|
+
* See {@link FullTextFilterPayload} for the full options reference.
|
|
1178
|
+
*/
|
|
1179
|
+
fts?: FullTextFilterPayload;
|
|
1180
|
+
} : Base : Base : Base;
|
|
1115
1181
|
type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable extends boolean, WithAggregations extends boolean, AllowedKinds extends FilterKind> = ('Equality' extends AllowedKinds ? NullableIf<keyof GetEnum<Schema, T>, Nullable> : never) | (('Equality' extends AllowedKinds ? {
|
|
1116
1182
|
/**
|
|
1117
1183
|
* Checks for equality with the specified enum value.
|
|
@@ -1375,8 +1441,8 @@ type JsonFilter<AllowedKinds extends FilterKind = FilterKind> = ('Equality' exte
|
|
|
1375
1441
|
*/
|
|
1376
1442
|
array_ends_with?: JsonValue;
|
|
1377
1443
|
} : {});
|
|
1378
|
-
type TypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean, AllowedKinds extends FilterKind> =
|
|
1379
|
-
type TypedJsonTypedFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean,
|
|
1444
|
+
type TypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean, AllowedKinds extends FilterKind> = (JsonFilter<AllowedKinds> & { [Key in GetTypeDefFields<Schema, TypeDefName>]?: never }) | (TypedJsonTypedFilter<Schema, TypeDefName, Array, AllowedKinds> & { [Key in keyof JsonFilter<AllowedKinds>]?: never }) | (Optional extends true ? null | JsonNullValues : never);
|
|
1445
|
+
type TypedJsonTypedFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, AllowedKinds extends FilterKind> = 'Json' extends AllowedKinds ? Array extends true ? ArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds> : NonArrayTypedJsonFilter<Schema, TypeDefName, AllowedKinds> : {};
|
|
1380
1446
|
type ArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, AllowedKinds extends FilterKind> = {
|
|
1381
1447
|
some?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
1382
1448
|
every?: TypedJsonFieldsFilter<Schema, TypeDefName, AllowedKinds>;
|
|
@@ -1389,6 +1455,142 @@ type NonArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTy
|
|
|
1389
1455
|
type TypedJsonFieldsFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, AllowedKinds extends FilterKind> = { [Key in GetTypeDefFields<Schema, TypeDefName>]?: GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsArray<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, AllowedKinds> : TypeDefFieldIsArray<Schema, TypeDefName, Key> extends true ? ArrayFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, AllowedKinds> : GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false, AllowedKinds> : PrimitiveFilter<GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false, AllowedKinds> };
|
|
1390
1456
|
type SortOrder = 'asc' | 'desc';
|
|
1391
1457
|
type NullsOrder = 'first' | 'last';
|
|
1458
|
+
type StringFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = { [Key in NonRelationFields<Schema, Model>]: MapModelFieldType<Schema, Model, Key> extends string | null ? Key : never }[NonRelationFields<Schema, Model>];
|
|
1459
|
+
/**
|
|
1460
|
+
* String fields that have been annotated with `@fuzzy` and are therefore eligible
|
|
1461
|
+
* for `_fuzzyRelevance` ordering.
|
|
1462
|
+
*/
|
|
1463
|
+
type FuzzyFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = { [Key in StringFields<Schema, Model>]: GetModelField<Schema, Model, Key>['fuzzy'] extends true ? Key : never }[StringFields<Schema, Model>];
|
|
1464
|
+
/**
|
|
1465
|
+
* Payload for the `fuzzy` string filter operator. Performs a fuzzy search using
|
|
1466
|
+
* PostgreSQL `pg_trgm` (only available when the schema's provider is `postgresql`).
|
|
1467
|
+
* Not supported on MySQL or SQLite (throws `NotSupported` at runtime).
|
|
1468
|
+
*
|
|
1469
|
+
* Modes:
|
|
1470
|
+
* - `'simple'` (default): trigram similarity on the whole value (operator `%`,
|
|
1471
|
+
* function `similarity()`).
|
|
1472
|
+
* - `'word'`: word similarity — checks if the search term is approximately
|
|
1473
|
+
* contained as a word inside the value (operator `<%`,
|
|
1474
|
+
* function `word_similarity()`).
|
|
1475
|
+
* - `'strictWord'`: stricter variant of `'word'` (operator `<<%`,
|
|
1476
|
+
* function `strict_word_similarity()`).
|
|
1477
|
+
*
|
|
1478
|
+
* When `threshold` is provided the function form is used
|
|
1479
|
+
* (`similarity() > threshold`) instead of the operator form, so the
|
|
1480
|
+
* `pg_trgm.*_threshold` session settings are bypassed.
|
|
1481
|
+
*
|
|
1482
|
+
* `unaccent` is opt-in (defaults to `false`) — set it to `true` to make the
|
|
1483
|
+
* comparison accent-insensitive. Enabling it requires the `unaccent` extension
|
|
1484
|
+
* to be installed on the database.
|
|
1485
|
+
*/
|
|
1486
|
+
type FuzzyFilterPayload = {
|
|
1487
|
+
/**
|
|
1488
|
+
* Search term to match against (must be a non-empty string).
|
|
1489
|
+
*/
|
|
1490
|
+
search: string;
|
|
1491
|
+
/**
|
|
1492
|
+
* Matching mode. Defaults to `'simple'`.
|
|
1493
|
+
*/
|
|
1494
|
+
mode?: 'simple' | 'word' | 'strictWord';
|
|
1495
|
+
/**
|
|
1496
|
+
* Optional similarity threshold in `[0, 1]`. When provided, the function
|
|
1497
|
+
* form is used and matches require `similarity > threshold`.
|
|
1498
|
+
*/
|
|
1499
|
+
threshold?: number;
|
|
1500
|
+
/**
|
|
1501
|
+
* Whether to apply `unaccent()` to both sides. Defaults to `false`.
|
|
1502
|
+
* Set to `true` to enable accent-insensitive matching (requires the
|
|
1503
|
+
* `unaccent` extension on PostgreSQL).
|
|
1504
|
+
*/
|
|
1505
|
+
unaccent?: boolean;
|
|
1506
|
+
};
|
|
1507
|
+
type FuzzyRelevanceOrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1508
|
+
/**
|
|
1509
|
+
* Sorts by fuzzy search relevance using PostgreSQL `pg_trgm` similarity functions.
|
|
1510
|
+
* Not supported on MySQL or SQLite (throws `NotSupported` at runtime).
|
|
1511
|
+
* Cannot be combined with cursor-based pagination.
|
|
1512
|
+
*/
|
|
1513
|
+
_fuzzyRelevance?: {
|
|
1514
|
+
/**
|
|
1515
|
+
* String fields annotated with `@fuzzy` to compute relevance against (must be non-empty).
|
|
1516
|
+
*
|
|
1517
|
+
* When multiple fields are provided, the row's relevance score is the
|
|
1518
|
+
* greatest per-field similarity, i.e. `GREATEST(similarity(field1, search), similarity(field2, search), ...)`.
|
|
1519
|
+
*/
|
|
1520
|
+
fields: [FuzzyFields<Schema, Model>, ...FuzzyFields<Schema, Model>[]];
|
|
1521
|
+
/**
|
|
1522
|
+
* The search term to compute relevance for.
|
|
1523
|
+
*/
|
|
1524
|
+
search: string;
|
|
1525
|
+
/**
|
|
1526
|
+
* Fuzzy matching mode used to compute relevance.
|
|
1527
|
+
*/
|
|
1528
|
+
mode?: 'simple' | 'word' | 'strictWord';
|
|
1529
|
+
/**
|
|
1530
|
+
* Whether to remove accents before computing relevance.
|
|
1531
|
+
*/
|
|
1532
|
+
unaccent?: boolean;
|
|
1533
|
+
/**
|
|
1534
|
+
* Sort direction.
|
|
1535
|
+
*/
|
|
1536
|
+
sort: SortOrder;
|
|
1537
|
+
};
|
|
1538
|
+
};
|
|
1539
|
+
/**
|
|
1540
|
+
* String fields that have been annotated with `@fullText` and are therefore eligible
|
|
1541
|
+
* for `_ftsRelevance` ordering.
|
|
1542
|
+
*/
|
|
1543
|
+
type FullTextFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = { [Key in StringFields<Schema, Model>]: GetModelField<Schema, Model, Key>['fullText'] extends true ? Key : never }[StringFields<Schema, Model>];
|
|
1544
|
+
/**
|
|
1545
|
+
* Payload for the `fts` string filter operator. Performs full-text search using
|
|
1546
|
+
* PostgreSQL `to_tsvector` / `to_tsquery` (postgresql provider only).
|
|
1547
|
+
*
|
|
1548
|
+
* Query syntax follows `to_tsquery`: callers write raw `&` (AND), `|` (OR),
|
|
1549
|
+
* `!` (NOT), `<->` (FOLLOWED BY). Malformed queries throw at SQL execution time.
|
|
1550
|
+
*/
|
|
1551
|
+
type FullTextFilterPayload = {
|
|
1552
|
+
/**
|
|
1553
|
+
* Search query in `to_tsquery` syntax (must be a non-empty string).
|
|
1554
|
+
*/
|
|
1555
|
+
search: string;
|
|
1556
|
+
/**
|
|
1557
|
+
* Postgres text-search configuration (e.g. `'english'`, `'simple'`). When
|
|
1558
|
+
* omitted, the database's `default_text_search_config` setting is used —
|
|
1559
|
+
* the SQL is emitted as `to_tsvector(field) @@ to_tsquery(query)` without
|
|
1560
|
+
* an explicit regconfig argument.
|
|
1561
|
+
*/
|
|
1562
|
+
config?: string;
|
|
1563
|
+
};
|
|
1564
|
+
type FtsRelevanceOrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1565
|
+
/**
|
|
1566
|
+
* Sorts by full-text-search relevance using PostgreSQL `ts_rank`.
|
|
1567
|
+
*/
|
|
1568
|
+
_ftsRelevance?: {
|
|
1569
|
+
/**
|
|
1570
|
+
* String fields annotated with `@fullText` to compute relevance against (must be non-empty).
|
|
1571
|
+
*
|
|
1572
|
+
* When multiple fields are provided, the fields are concatenated with a
|
|
1573
|
+
* space separator and a single `ts_rank` is computed over the combined
|
|
1574
|
+
* document — i.e. `ts_rank(to_tsvector(concat_ws(' ', f1, f2, ...)), q)`.
|
|
1575
|
+
* This means an AND query (e.g. `'cat & dog'`) matches rows where the
|
|
1576
|
+
* terms appear across different fields, not just within the same field.
|
|
1577
|
+
*/
|
|
1578
|
+
fields: [FullTextFields<Schema, Model>, ...FullTextFields<Schema, Model>[]];
|
|
1579
|
+
/**
|
|
1580
|
+
* The search term to compute relevance for (in `to_tsquery` syntax).
|
|
1581
|
+
*/
|
|
1582
|
+
search: string;
|
|
1583
|
+
/**
|
|
1584
|
+
* Postgres text-search configuration. When omitted, the database's
|
|
1585
|
+
* `default_text_search_config` setting is used.
|
|
1586
|
+
*/
|
|
1587
|
+
config?: string;
|
|
1588
|
+
/**
|
|
1589
|
+
* Sort direction.
|
|
1590
|
+
*/
|
|
1591
|
+
sort: SortOrder;
|
|
1592
|
+
};
|
|
1593
|
+
};
|
|
1392
1594
|
type OrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>, WithRelation extends boolean, WithAggregation extends boolean> = { [Key in NonRelationFields<Schema, Model>]?: ModelFieldIsOptional<Schema, Model, Key> extends true ? SortOrder | {
|
|
1393
1595
|
/**
|
|
1394
1596
|
* Sort order
|
|
@@ -1499,7 +1701,7 @@ type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>,
|
|
|
1499
1701
|
/**
|
|
1500
1702
|
* Order by clauses
|
|
1501
1703
|
*/
|
|
1502
|
-
orderBy?: OrArray<OrderBy<Schema, Model, true, false
|
|
1704
|
+
orderBy?: OrArray<OrderBy<Schema, Model, true, false> & (ProviderSupportsFuzzy<Schema> extends true ? FuzzyRelevanceOrderBy<Schema, Model> : {}) & (ProviderSupportsFullText<Schema> extends true ? FtsRelevanceOrderBy<Schema, Model> : {})>;
|
|
1503
1705
|
/**
|
|
1504
1706
|
* Cursor for pagination
|
|
1505
1707
|
*/
|
|
@@ -1551,8 +1753,16 @@ type CreateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModel
|
|
|
1551
1753
|
connect?: ConnectInput<Schema, Model, Field, Options>;
|
|
1552
1754
|
}, (FieldIsArray<Schema, Model, Field> extends true ? never : 'createMany') | (RelationModelAllowsCreate<Schema, Model, Field> extends true ? never : 'create' | 'createMany' | 'connectOrCreate')>;
|
|
1553
1755
|
type CreateRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = OptionalWrap<Schema, Model, { [Key in RelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]: CreateRelationFieldPayload<Schema, Model, Key, Options> }>;
|
|
1554
|
-
|
|
1555
|
-
|
|
1756
|
+
/**
|
|
1757
|
+
* Create input type that uses FK scalar fields (e.g., `authorId`) instead of
|
|
1758
|
+
* relation objects.
|
|
1759
|
+
*/
|
|
1760
|
+
type UncheckedCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = CreateScalarPayload<Schema, Model> & CreateFKPayload<Schema, Model> & CreateWithNonOwnedRelationPayload<Schema, Model, Options>;
|
|
1761
|
+
/**
|
|
1762
|
+
* Create input type that uses relation objects (e.g., `author: { connect: … }`)
|
|
1763
|
+
* instead of FK scalar fields.
|
|
1764
|
+
*/
|
|
1765
|
+
type CheckedCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = CreateScalarPayload<Schema, Model> & CreateRelationPayload<Schema, Model, Options>;
|
|
1556
1766
|
type CreateWithNonOwnedRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = OptionalWrap<Schema, Model, { [Key in NonOwnedRelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]: CreateRelationFieldPayload<Schema, Model, Key, Options> }>;
|
|
1557
1767
|
type ConnectOrCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = {
|
|
1558
1768
|
/**
|
|
@@ -1574,7 +1784,7 @@ type CreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>,
|
|
|
1574
1784
|
*/
|
|
1575
1785
|
skipDuplicates?: boolean;
|
|
1576
1786
|
};
|
|
1577
|
-
type CreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = XOR<Omit<
|
|
1787
|
+
type CreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = XOR<Omit<UncheckedCreateInput<Schema, Model, Options>, Without>, Omit<CheckedCreateInput<Schema, Model, Options>, Without>>;
|
|
1578
1788
|
type NestedCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = OrArray<CreateInput<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>, FieldIsArray<Schema, Model, Field>>;
|
|
1579
1789
|
type NestedCreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = CreateManyInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1580
1790
|
type UpdateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase<Schema> = {}> = {
|
|
@@ -1593,7 +1803,7 @@ type UpdateManyPayload<Schema extends SchemaDef, Model extends GetModels<Schema>
|
|
|
1593
1803
|
/**
|
|
1594
1804
|
* The data to update the records with.
|
|
1595
1805
|
*/
|
|
1596
|
-
data: OrArray<UpdateScalarInput<Schema, Model, Without>>;
|
|
1806
|
+
data: OrArray<UpdateScalarInput<Schema, Model, Without> & UpdateFKPayload<Schema, Model, Without>>;
|
|
1597
1807
|
/**
|
|
1598
1808
|
* The filter to select records to update.
|
|
1599
1809
|
*/
|
|
@@ -1617,7 +1827,8 @@ type UpsertArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Optio
|
|
|
1617
1827
|
*/
|
|
1618
1828
|
where: WhereUniqueInput<Schema, Model, Options>;
|
|
1619
1829
|
} & SelectIncludeOmit<Schema, Model, true, Options, true, ExtResult> & ExtractExtQueryArgs<ExtQueryArgs, 'upsert'>;
|
|
1620
|
-
type UpdateScalarInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{ [Key in NonRelationFields<Schema, Model
|
|
1830
|
+
type UpdateScalarInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{ [Key in Exclude<NonRelationFields<Schema, Model>, ForeignKeyFields<Schema, Model>> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]?: ScalarUpdatePayload<Schema, Model, Key> }, Without>;
|
|
1831
|
+
type UpdateFKPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{ [Key in ForeignKeyFields<Schema, Model>]?: MapModelFieldType<Schema, Model, Key> }, Without>;
|
|
1621
1832
|
type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> = ScalarFieldMutationPayload<Schema, Model, Field> | (Field extends NumericFields<Schema, Model> ? {
|
|
1622
1833
|
/**
|
|
1623
1834
|
* Sets the field to the specified value.
|
|
@@ -1650,7 +1861,18 @@ type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schem
|
|
|
1650
1861
|
push?: OrArray<MapModelFieldType<Schema, Model, Field>, true>;
|
|
1651
1862
|
} : never);
|
|
1652
1863
|
type UpdateRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = Omit<{ [Key in RelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]?: UpdateRelationFieldPayload<Schema, Model, Key, Options> }, Without>;
|
|
1653
|
-
type
|
|
1864
|
+
type UpdateNonOwnedRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = { [Key in NonOwnedRelationFields<Schema, Model> as RelationFieldType<Schema, Model, Key> extends GetSlicedModels<Schema, Options> ? Key : never]?: UpdateRelationFieldPayload<Schema, Model, Key, Options> };
|
|
1865
|
+
/**
|
|
1866
|
+
* Update input type that uses FK scalar fields (e.g., `authorId`) instead of
|
|
1867
|
+
* relation objects.
|
|
1868
|
+
*/
|
|
1869
|
+
type UncheckedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = UpdateScalarInput<Schema, Model> & UpdateFKPayload<Schema, Model> & UpdateNonOwnedRelationInput<Schema, Model, Options>;
|
|
1870
|
+
/**
|
|
1871
|
+
* Update input type that uses relation objects (e.g., `author: { connect: … }`)
|
|
1872
|
+
* instead of FK scalar fields.
|
|
1873
|
+
*/
|
|
1874
|
+
type CheckedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = UpdateScalarInput<Schema, Model> & UpdateRelationInput<Schema, Model, Options>;
|
|
1875
|
+
type UpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Without extends string = never> = XOR<Omit<UncheckedUpdateInput<Schema, Model, Options>, Without>, Omit<CheckedUpdateInput<Schema, Model, Options>, Without>>;
|
|
1654
1876
|
type UpdateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? ToManyRelationUpdateInput<Schema, Model, Field, Options> : ToOneRelationUpdateInput<Schema, Model, Field, Options>;
|
|
1655
1877
|
type ToManyRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = Omit<{
|
|
1656
1878
|
/**
|
|
@@ -1923,6 +2145,62 @@ type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Ar
|
|
|
1923
2145
|
*/
|
|
1924
2146
|
_max: AggCommonOutput<Max>;
|
|
1925
2147
|
} : {})>;
|
|
2148
|
+
/**
|
|
2149
|
+
* Maps each CRUD operation name to its argument type for a given model.
|
|
2150
|
+
*/
|
|
2151
|
+
type CrudArgsMap<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase<Schema> = {}> = {
|
|
2152
|
+
findMany: FindManyArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2153
|
+
findUnique: FindUniqueArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2154
|
+
findUniqueOrThrow: FindUniqueArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2155
|
+
findFirst: FindFirstArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2156
|
+
findFirstOrThrow: FindFirstArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2157
|
+
create: CreateArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2158
|
+
createMany: CreateManyArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2159
|
+
createManyAndReturn: CreateManyAndReturnArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2160
|
+
update: UpdateArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2161
|
+
updateMany: UpdateManyArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2162
|
+
updateManyAndReturn: UpdateManyAndReturnArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2163
|
+
upsert: UpsertArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2164
|
+
delete: DeleteArgs<Schema, Model, Options, ExtQueryArgs, ExtResult>;
|
|
2165
|
+
deleteMany: DeleteManyArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2166
|
+
count: CountArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2167
|
+
aggregate: AggregateArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2168
|
+
groupBy: GroupByArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2169
|
+
exists: ExistsArgs<Schema, Model, Options, ExtQueryArgs>;
|
|
2170
|
+
};
|
|
2171
|
+
/**
|
|
2172
|
+
* Maps a CRUD operation name to its argument type for a given model.
|
|
2173
|
+
*/
|
|
2174
|
+
type CrudArgsType<Schema extends SchemaDef, Model extends GetModels<Schema>, Op extends AllCrudOperations, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase<Schema> = {}> = CrudArgsMap<Schema, Model, Options, ExtQueryArgs, ExtResult>[Op];
|
|
2175
|
+
/**
|
|
2176
|
+
* Maps each CRUD operation name to its return type for a given model + args.
|
|
2177
|
+
*/
|
|
2178
|
+
type CrudReturnMap<Schema extends SchemaDef, Model extends GetModels<Schema>, Args, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ExtResult extends ExtResultBase<Schema> = {}> = {
|
|
2179
|
+
findMany: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>[];
|
|
2180
|
+
findUnique: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult> | null;
|
|
2181
|
+
findUniqueOrThrow: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>;
|
|
2182
|
+
findFirst: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult> | null;
|
|
2183
|
+
findFirstOrThrow: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>;
|
|
2184
|
+
create: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>;
|
|
2185
|
+
createMany: BatchResult;
|
|
2186
|
+
createManyAndReturn: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>[];
|
|
2187
|
+
update: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>;
|
|
2188
|
+
updateMany: BatchResult;
|
|
2189
|
+
updateManyAndReturn: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>[];
|
|
2190
|
+
upsert: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>;
|
|
2191
|
+
delete: SimplifiedPlainResult<Schema, Model, Args, Options, ExtResult>;
|
|
2192
|
+
deleteMany: BatchResult;
|
|
2193
|
+
count: CountResult<Schema, Model, Args>;
|
|
2194
|
+
aggregate: AggregateResult<Schema, Model, Args>;
|
|
2195
|
+
groupBy: Args extends {
|
|
2196
|
+
by: unknown;
|
|
2197
|
+
} ? GroupByResult<Schema, Model, Args> : never;
|
|
2198
|
+
exists: boolean;
|
|
2199
|
+
};
|
|
2200
|
+
/**
|
|
2201
|
+
* Maps a CRUD operation name to its return type for a given model + args.
|
|
2202
|
+
*/
|
|
2203
|
+
type CrudReturnType<Schema extends SchemaDef, Model extends GetModels<Schema>, Op extends AllCrudOperations, Args, Options extends QueryOptions<Schema> = QueryOptions<Schema>, ExtResult extends ExtResultBase<Schema> = {}> = CrudReturnMap<Schema, Model, Args, Options, ExtResult>[Op];
|
|
1926
2204
|
type ConnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>> : WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
1927
2205
|
type ConnectOrCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<ConnectOrCreatePayload<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>> : ConnectOrCreatePayload<Schema, RelationFieldType<Schema, Model, Field>, Options, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1928
2206
|
type DisconnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>, Options extends QueryOptions<Schema>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>, Options>, true> : boolean | WhereInput<Schema, RelationFieldType<Schema, Model, Field>, Options>;
|
|
@@ -2017,6 +2295,8 @@ type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2017
2295
|
type EnumValue<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = GetEnum<Schema, Enum>[keyof GetEnum<Schema, Enum>];
|
|
2018
2296
|
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;
|
|
2019
2297
|
type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
2298
|
+
type ProviderSupportsFuzzy<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
2299
|
+
type ProviderSupportsFullText<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
2020
2300
|
/**
|
|
2021
2301
|
* Extracts extended query args for a specific operation.
|
|
2022
2302
|
*/
|
|
@@ -2096,13 +2376,9 @@ interface Diagnostics {
|
|
|
2096
2376
|
/**
|
|
2097
2377
|
* A promise that only executes when it's awaited or .then() is called.
|
|
2098
2378
|
*/
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
* Callable to get a plain promise.
|
|
2103
|
-
*/
|
|
2104
|
-
cb: (txClient?: ClientContract<Schema>) => Promise<T>;
|
|
2105
|
-
};
|
|
2379
|
+
interface ZenStackPromise<T> extends Promise<T> {
|
|
2380
|
+
[Symbol.toStringTag]: 'ZenStackPromise';
|
|
2381
|
+
}
|
|
2106
2382
|
//#endregion
|
|
2107
2383
|
//#region src/client/contract.d.ts
|
|
2108
2384
|
type TransactionUnsupportedMethods = (typeof TRANSACTION_UNSUPPORTED_METHODS)[number];
|
|
@@ -2116,6 +2392,19 @@ declare enum TransactionIsolationLevel {
|
|
|
2116
2392
|
Serializable = "serializable",
|
|
2117
2393
|
Snapshot = "snapshot"
|
|
2118
2394
|
}
|
|
2395
|
+
/**
|
|
2396
|
+
* Symbol used as a type-only key on `ClientContract` to brand the `ExtQueryArgs`
|
|
2397
|
+
* generic slot. Hidden from member-access autocomplete since symbol keys are
|
|
2398
|
+
* not surfaced. Consumed by `InferExtQueryArgs` to recover the slot.
|
|
2399
|
+
* @internal
|
|
2400
|
+
*/
|
|
2401
|
+
declare const ExtQueryArgsMarker: unique symbol;
|
|
2402
|
+
/**
|
|
2403
|
+
* Symbol used as a type-only key on `ClientContract` to brand the `ExtResult`
|
|
2404
|
+
* generic slot. Consumed by `InferExtResult` to recover the slot.
|
|
2405
|
+
* @internal
|
|
2406
|
+
*/
|
|
2407
|
+
declare const ExtResultMarker: unique symbol;
|
|
2119
2408
|
/**
|
|
2120
2409
|
* ZenStack client interface.
|
|
2121
2410
|
*/
|
|
@@ -2127,7 +2416,9 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2127
2416
|
/**
|
|
2128
2417
|
* The client options.
|
|
2129
2418
|
*/
|
|
2130
|
-
readonly $options: Options;
|
|
2419
|
+
readonly $options: Options; /** @internal type-only brand carrying the `ExtQueryArgs` slot for inference. */
|
|
2420
|
+
readonly [ExtQueryArgsMarker]?: ExtQueryArgs; /** @internal type-only brand carrying the `ExtResult` slot for inference. */
|
|
2421
|
+
readonly [ExtResultMarker]?: ExtResult;
|
|
2131
2422
|
/**
|
|
2132
2423
|
* Executes a prepared raw query and returns the number of affected rows.
|
|
2133
2424
|
* @example
|
|
@@ -2135,7 +2426,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2135
2426
|
* const result = await db.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};`
|
|
2136
2427
|
* ```
|
|
2137
2428
|
*/
|
|
2138
|
-
$executeRaw(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<
|
|
2429
|
+
$executeRaw(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<number>;
|
|
2139
2430
|
/**
|
|
2140
2431
|
* Executes a raw query and returns the number of affected rows.
|
|
2141
2432
|
* This method is susceptible to SQL injections.
|
|
@@ -2144,7 +2435,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2144
2435
|
* const result = await db.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
|
|
2145
2436
|
* ```
|
|
2146
2437
|
*/
|
|
2147
|
-
$executeRawUnsafe(query: string, ...values: any[]): ZenStackPromise<
|
|
2438
|
+
$executeRawUnsafe(query: string, ...values: any[]): ZenStackPromise<number>;
|
|
2148
2439
|
/**
|
|
2149
2440
|
* Performs a prepared raw query and returns the `SELECT` data.
|
|
2150
2441
|
* @example
|
|
@@ -2152,7 +2443,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2152
2443
|
* const result = await db.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};`
|
|
2153
2444
|
* ```
|
|
2154
2445
|
*/
|
|
2155
|
-
$queryRaw<T = unknown>(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<
|
|
2446
|
+
$queryRaw<T = unknown>(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<T>;
|
|
2156
2447
|
/**
|
|
2157
2448
|
* Performs a raw query and returns the `SELECT` data.
|
|
2158
2449
|
* This method is susceptible to SQL injections.
|
|
@@ -2161,7 +2452,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2161
2452
|
* const result = await db.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
|
|
2162
2453
|
* ```
|
|
2163
2454
|
*/
|
|
2164
|
-
$queryRawUnsafe<T = unknown>(query: string, ...values: any[]): ZenStackPromise<
|
|
2455
|
+
$queryRawUnsafe<T = unknown>(query: string, ...values: any[]): ZenStackPromise<T>;
|
|
2165
2456
|
/**
|
|
2166
2457
|
* The current user identity. If the client is not bound to any user context, returns `undefined`.
|
|
2167
2458
|
*/
|
|
@@ -2228,7 +2519,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2228
2519
|
* db.post.create({ data: { title: 'Hello World', authorId: 1 } }),
|
|
2229
2520
|
* ]);
|
|
2230
2521
|
*/
|
|
2231
|
-
$transaction<P extends ZenStackPromise<
|
|
2522
|
+
$transaction<P extends ZenStackPromise<any>[]>(arg: [...P], options?: {
|
|
2232
2523
|
isolationLevel?: TransactionIsolationLevel;
|
|
2233
2524
|
}): Promise<UnwrapTuplePromises<P>>;
|
|
2234
2525
|
/**
|
|
@@ -2321,7 +2612,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2321
2612
|
* });
|
|
2322
2613
|
* ```
|
|
2323
2614
|
*/
|
|
2324
|
-
createManyAndReturn<T extends
|
|
2615
|
+
createManyAndReturn<T extends CrudArgsType<Schema, Model, 'createManyAndReturn', Options, ExtQueryArgs, ExtResult>>(args?: SelectSubset<T, CrudArgsType<Schema, Model, 'createManyAndReturn', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'createManyAndReturn', T, Options, ExtResult>>;
|
|
2325
2616
|
/**
|
|
2326
2617
|
* Updates multiple entities and returns them.
|
|
2327
2618
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2344,7 +2635,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2344
2635
|
* });
|
|
2345
2636
|
* ```
|
|
2346
2637
|
*/
|
|
2347
|
-
updateManyAndReturn<T extends
|
|
2638
|
+
updateManyAndReturn<T extends CrudArgsType<Schema, Model, 'updateManyAndReturn', Options, ExtQueryArgs, ExtResult>>(args: Subset<T, CrudArgsType<Schema, Model, 'updateManyAndReturn', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'updateManyAndReturn', T, Options, ExtResult>>;
|
|
2348
2639
|
});
|
|
2349
2640
|
type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase, ExtResult extends ExtResultBase<Schema> = {}> = {
|
|
2350
2641
|
/**
|
|
@@ -2428,35 +2719,35 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2428
2719
|
* }); // result: `{ _count: { posts: number } }`
|
|
2429
2720
|
* ```
|
|
2430
2721
|
*/
|
|
2431
|
-
findMany<T extends
|
|
2722
|
+
findMany<T extends CrudArgsType<Schema, Model, 'findMany', Options, ExtQueryArgs, ExtResult>>(args?: SelectSubset<T, CrudArgsType<Schema, Model, 'findMany', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'findMany', T, Options, ExtResult>>;
|
|
2432
2723
|
/**
|
|
2433
2724
|
* Returns a uniquely identified entity.
|
|
2434
2725
|
* @param args - query args
|
|
2435
2726
|
* @returns a single entity or null if not found
|
|
2436
2727
|
* @see {@link findMany}
|
|
2437
2728
|
*/
|
|
2438
|
-
findUnique<T extends
|
|
2729
|
+
findUnique<T extends CrudArgsType<Schema, Model, 'findUnique', Options, ExtQueryArgs, ExtResult>>(args: SelectSubset<T, CrudArgsType<Schema, Model, 'findUnique', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'findUnique', T, Options, ExtResult>>;
|
|
2439
2730
|
/**
|
|
2440
2731
|
* Returns a uniquely identified entity or throws `NotFoundError` if not found.
|
|
2441
2732
|
* @param args - query args
|
|
2442
2733
|
* @returns a single entity
|
|
2443
2734
|
* @see {@link findMany}
|
|
2444
2735
|
*/
|
|
2445
|
-
findUniqueOrThrow<T extends
|
|
2736
|
+
findUniqueOrThrow<T extends CrudArgsType<Schema, Model, 'findUniqueOrThrow', Options, ExtQueryArgs, ExtResult>>(args: SelectSubset<T, CrudArgsType<Schema, Model, 'findUniqueOrThrow', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'findUniqueOrThrow', T, Options, ExtResult>>;
|
|
2446
2737
|
/**
|
|
2447
2738
|
* Returns the first entity.
|
|
2448
2739
|
* @param args - query args
|
|
2449
2740
|
* @returns a single entity or null if not found
|
|
2450
2741
|
* @see {@link findMany}
|
|
2451
2742
|
*/
|
|
2452
|
-
findFirst<T extends
|
|
2743
|
+
findFirst<T extends CrudArgsType<Schema, Model, 'findFirst', Options, ExtQueryArgs, ExtResult>>(args?: SelectSubset<T, CrudArgsType<Schema, Model, 'findFirst', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'findFirst', T, Options, ExtResult>>;
|
|
2453
2744
|
/**
|
|
2454
2745
|
* Returns the first entity or throws `NotFoundError` if not found.
|
|
2455
2746
|
* @param args - query args
|
|
2456
2747
|
* @returns a single entity
|
|
2457
2748
|
* @see {@link findMany}
|
|
2458
2749
|
*/
|
|
2459
|
-
findFirstOrThrow<T extends
|
|
2750
|
+
findFirstOrThrow<T extends CrudArgsType<Schema, Model, 'findFirstOrThrow', Options, ExtQueryArgs, ExtResult>>(args?: SelectSubset<T, CrudArgsType<Schema, Model, 'findFirstOrThrow', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'findFirstOrThrow', T, Options, ExtResult>>;
|
|
2460
2751
|
/**
|
|
2461
2752
|
* Creates a new entity.
|
|
2462
2753
|
* @param args - create args
|
|
@@ -2509,7 +2800,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2509
2800
|
* });
|
|
2510
2801
|
* ```
|
|
2511
2802
|
*/
|
|
2512
|
-
create<T extends
|
|
2803
|
+
create<T extends CrudArgsType<Schema, Model, 'create', Options, ExtQueryArgs, ExtResult>>(args: SelectSubset<T, CrudArgsType<Schema, Model, 'create', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'create', T, Options, ExtResult>>;
|
|
2513
2804
|
/**
|
|
2514
2805
|
* Creates multiple entities. Only scalar fields are allowed.
|
|
2515
2806
|
* @param args - create args
|
|
@@ -2535,7 +2826,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2535
2826
|
* });
|
|
2536
2827
|
* ```
|
|
2537
2828
|
*/
|
|
2538
|
-
createMany<T extends
|
|
2829
|
+
createMany<T extends CrudArgsType<Schema, Model, 'createMany', Options, ExtQueryArgs, ExtResult>>(args?: SelectSubset<T, CrudArgsType<Schema, Model, 'createMany', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'createMany', T, Options, ExtResult>>;
|
|
2539
2830
|
/**
|
|
2540
2831
|
* Updates a uniquely identified entity.
|
|
2541
2832
|
* @param args - update args. See {@link findMany} for how to control
|
|
@@ -2653,7 +2944,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2653
2944
|
* });
|
|
2654
2945
|
* ```
|
|
2655
2946
|
*/
|
|
2656
|
-
update<T extends
|
|
2947
|
+
update<T extends CrudArgsType<Schema, Model, 'update', Options, ExtQueryArgs, ExtResult>>(args: SelectSubset<T, CrudArgsType<Schema, Model, 'update', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'update', T, Options, ExtResult>>;
|
|
2657
2948
|
/**
|
|
2658
2949
|
* Updates multiple entities.
|
|
2659
2950
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2674,7 +2965,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2674
2965
|
* limit: 10
|
|
2675
2966
|
* });
|
|
2676
2967
|
*/
|
|
2677
|
-
updateMany<T extends
|
|
2968
|
+
updateMany<T extends CrudArgsType<Schema, Model, 'updateMany', Options, ExtQueryArgs, ExtResult>>(args: Subset<T, CrudArgsType<Schema, Model, 'updateMany', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'updateMany', T, Options, ExtResult>>;
|
|
2678
2969
|
/**
|
|
2679
2970
|
* Creates or updates an entity.
|
|
2680
2971
|
* @param args - upsert args
|
|
@@ -2695,7 +2986,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2695
2986
|
* });
|
|
2696
2987
|
* ```
|
|
2697
2988
|
*/
|
|
2698
|
-
upsert<T extends
|
|
2989
|
+
upsert<T extends CrudArgsType<Schema, Model, 'upsert', Options, ExtQueryArgs, ExtResult>>(args: SelectSubset<T, CrudArgsType<Schema, Model, 'upsert', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'upsert', T, Options, ExtResult>>;
|
|
2699
2990
|
/**
|
|
2700
2991
|
* Deletes a uniquely identifiable entity.
|
|
2701
2992
|
* @param args - delete args
|
|
@@ -2715,7 +3006,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2715
3006
|
* }); // result: `{ id: string; email: string }`
|
|
2716
3007
|
* ```
|
|
2717
3008
|
*/
|
|
2718
|
-
delete<T extends
|
|
3009
|
+
delete<T extends CrudArgsType<Schema, Model, 'delete', Options, ExtQueryArgs, ExtResult>>(args: SelectSubset<T, CrudArgsType<Schema, Model, 'delete', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'delete', T, Options, ExtResult>>;
|
|
2719
3010
|
/**
|
|
2720
3011
|
* Deletes multiple entities.
|
|
2721
3012
|
* @param args - delete args
|
|
@@ -2735,7 +3026,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2735
3026
|
* });
|
|
2736
3027
|
* ```
|
|
2737
3028
|
*/
|
|
2738
|
-
deleteMany<T extends
|
|
3029
|
+
deleteMany<T extends CrudArgsType<Schema, Model, 'deleteMany', Options, ExtQueryArgs, ExtResult>>(args?: Subset<T, CrudArgsType<Schema, Model, 'deleteMany', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'deleteMany', T, Options, ExtResult>>;
|
|
2739
3030
|
/**
|
|
2740
3031
|
* Counts rows or field values.
|
|
2741
3032
|
* @param args - count args
|
|
@@ -2754,7 +3045,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2754
3045
|
* select: { _all: true, email: true }
|
|
2755
3046
|
* }); // result: `{ _all: number, email: number }`
|
|
2756
3047
|
*/
|
|
2757
|
-
count<T extends
|
|
3048
|
+
count<T extends CrudArgsType<Schema, Model, 'count', Options, ExtQueryArgs, ExtResult>>(args?: Subset<T, CrudArgsType<Schema, Model, 'count', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<Simplify<CrudReturnType<Schema, Model, 'count', T, Options, ExtResult>>>;
|
|
2758
3049
|
/**
|
|
2759
3050
|
* Aggregates rows.
|
|
2760
3051
|
* @param args - aggregation args
|
|
@@ -2772,7 +3063,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2772
3063
|
* _max: { age: true }
|
|
2773
3064
|
* }); // result: `{ _count: number, _avg: { age: number }, ... }`
|
|
2774
3065
|
*/
|
|
2775
|
-
aggregate<T extends
|
|
3066
|
+
aggregate<T extends CrudArgsType<Schema, Model, 'aggregate', Options, ExtQueryArgs, ExtResult>>(args: Subset<T, CrudArgsType<Schema, Model, 'aggregate', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<Simplify<CrudReturnType<Schema, Model, 'aggregate', T, Options, ExtResult>>>;
|
|
2776
3067
|
/**
|
|
2777
3068
|
* Groups rows by columns.
|
|
2778
3069
|
* @param args - groupBy args
|
|
@@ -2806,7 +3097,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2806
3097
|
* having: { country: 'US', age: { _avg: { gte: 18 } } }
|
|
2807
3098
|
* });
|
|
2808
3099
|
*/
|
|
2809
|
-
groupBy<T extends
|
|
3100
|
+
groupBy<T extends CrudArgsType<Schema, Model, 'groupBy', Options, ExtQueryArgs, ExtResult>>(args: Subset<T, CrudArgsType<Schema, Model, 'groupBy', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<Simplify<CrudReturnType<Schema, Model, 'groupBy', T, Options, ExtResult>>>;
|
|
2810
3101
|
/**
|
|
2811
3102
|
* Checks if an entity exists.
|
|
2812
3103
|
* @param args - exists args
|
|
@@ -2824,7 +3115,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2824
3115
|
* where: { posts: { some: { published: true } } },
|
|
2825
3116
|
* }); // result: `boolean`
|
|
2826
3117
|
*/
|
|
2827
|
-
exists<T extends
|
|
3118
|
+
exists<T extends CrudArgsType<Schema, Model, 'exists', Options, ExtQueryArgs, ExtResult>>(args?: Subset<T, CrudArgsType<Schema, Model, 'exists', Options, ExtQueryArgs, ExtResult>>): ZenStackPromise<CrudReturnType<Schema, Model, 'exists', T, Options, ExtResult>>;
|
|
2828
3119
|
};
|
|
2829
3120
|
type OperationsRequiringCreate = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert';
|
|
2830
3121
|
type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase = {}, ExtResult extends ExtResultBase<Schema> = {}> = SliceOperations<AllModelOperations<Schema, Model, Options, ExtQueryArgs, ExtResult>, Schema, Model, Options>;
|
|
@@ -2929,6 +3220,8 @@ declare class ZodSchemaFactory<Schema extends SchemaDef, Options extends ClientO
|
|
|
2929
3220
|
private makeNumberFilterSchema;
|
|
2930
3221
|
private makeStringFilterSchema;
|
|
2931
3222
|
private makeStringModeSchema;
|
|
3223
|
+
private makeFuzzyFilterSchema;
|
|
3224
|
+
private makeFullTextFilterSchema;
|
|
2932
3225
|
private makeSelectSchema;
|
|
2933
3226
|
private makeCountSelectionSchema;
|
|
2934
3227
|
private makeRelationSelectIncludeSchema;
|
|
@@ -2981,6 +3274,8 @@ declare class ZodSchemaFactory<Schema extends SchemaDef, Options extends ClientO
|
|
|
2981
3274
|
private orArray;
|
|
2982
3275
|
private isNumericField;
|
|
2983
3276
|
private get providerSupportsCaseSensitivity();
|
|
3277
|
+
private get providerSupportsFullTextSearch();
|
|
3278
|
+
private get providerSupportsFuzzySearch();
|
|
2984
3279
|
/**
|
|
2985
3280
|
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
2986
3281
|
* Respects the precedence: model[field] > model.$all > $all[field] > $all.$all.
|
|
@@ -3215,5 +3510,5 @@ declare class MatchingExpressionVisitor extends ExpressionVisitor {
|
|
|
3215
3510
|
};
|
|
3216
3511
|
}
|
|
3217
3512
|
//#endregion
|
|
3218
|
-
export { AfterEntityMutationCallback, AggregateArgs, AggregateResult, AllCrudOperations, AllModelOperations, AllReadOperations, AllWriteOperations, AnyNull, AnyNullClass, AnyPlugin, AuthType, BaseCrudDialect, BatchResult, BeforeEntityMutationCallback, BooleanFilter, BytesFilter, CRUD, CRUD_EXT, ClientConstructor, ClientContract, ClientOptions, ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, CountArgs, CountResult, CreateArgs, CreateInput, CreateManyAndReturnArgs, CreateManyArgs, CreateManyInput, DateTimeFilter, DbNull, DbNullClass, DefaultModelResult, DeleteArgs, DeleteManyArgs, EntityMutationHooksDef, ExistsArgs, ExtClientMembersBase, ExtQueryArgsBase, ExtResultBase, ExtResultInferenceArgs, ExtResultSelectOmitFields, ExtractExtResult, FilterKind, FindArgs, FindFirstArgs, FindManyArgs, FindUniqueArgs, GetAllIncludedOperations, GetIncludedOperations, GetProcedure, GetProcedureNames, GetProcedureParams, GetQueryOptions, GetSlicedFilterKindsForField, GetSlicedModels, GetSlicedOperations, GetSlicedProcedures, GroupByArgs, GroupByResult, HasComputedFields, HasProcedures, IncludeInput, InputValidator, JsonArray, JsonFilter, JsonNull, JsonNullClass, JsonNullValues, JsonObject, JsonValue, kysely_utils_d_exports as KyselyUtils, MapModelFieldType, ModelAllowsCreate, ModelHasRequiredUnsupportedField, ModelOperations, ModelResult, ModelSlicingOptions, NullsOrder, NumberFilter, ORMError, ORMErrorReason, OmitConfig, OmitInput, OnKyselyQueryArgs, OnKyselyQueryCallback, OnProcedureHookContext, OperationsRequiringCreate, OrderBy, PluginAfterEntityMutationArgs, PluginBeforeEntityMutationArgs, ProcedureEnvelope, ProcedureFunc, ProcedureHandlerFunc, ProcedureOperations, ProceduresOptions, ProceedKyselyQueryFunction, QueryOptions, query_utils_d_exports as QueryUtils, RejectedByPolicyReason, RuntimePlugin, schema_utils_d_exports as SchemaUtils, SelectAwareExtResult, SelectIncludeOmit, SelectInput, SelectSubset, SimplifiedPlainResult, SimplifiedResult, SlicingOptions, SortOrder, StringFilter, Subset, type ToKysely, TransactionClientContract, TransactionIsolationLevel, TypeDefResult, TypedJsonFilter, UpdateArgs, UpdateInput, UpdateManyAndReturnArgs, UpdateManyArgs, UpsertArgs, WhereInput, WhereUniqueInput, ZModelFunction, ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZodSchemaFactory, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
|
3513
|
+
export { AfterEntityMutationCallback, AggregateArgs, AggregateResult, AllCrudOperations, AllModelOperations, AllReadOperations, AllWriteOperations, AnyNull, AnyNullClass, AnyPlugin, AuthType, BaseCrudDialect, BatchResult, BeforeEntityMutationCallback, BooleanFilter, BytesFilter, CRUD, CRUD_EXT, CheckedCreateInput, CheckedUpdateInput, ClientConstructor, ClientContract, ClientOptions, ComputedFieldsOptions, CoreCreateOperations, CoreCrudOperations, CoreDeleteOperations, CoreReadOperations, CoreUpdateOperations, CoreWriteOperations, CountArgs, CountResult, CreateArgs, CreateInput, CreateManyAndReturnArgs, CreateManyArgs, CreateManyInput, CrudArgsMap, CrudArgsType, CrudReturnMap, CrudReturnType, DateTimeFilter, DbNull, DbNullClass, DefaultModelResult, DeleteArgs, DeleteManyArgs, EntityMutationHooksDef, ExistsArgs, ExtClientMembersBase, ExtQueryArgsBase, ExtQueryArgsMarker, ExtResultBase, ExtResultInferenceArgs, ExtResultMarker, ExtResultSelectOmitFields, ExtractExtResult, FilterKind, FindArgs, FindFirstArgs, FindManyArgs, FindUniqueArgs, FtsRelevanceOrderBy, FullTextFilterPayload, FuzzyFilterPayload, FuzzyRelevanceOrderBy, GetAllIncludedOperations, GetIncludedOperations, GetProcedure, GetProcedureNames, GetProcedureParams, GetQueryOptions, GetSlicedFilterKindsForField, GetSlicedModels, GetSlicedOperations, GetSlicedProcedures, GroupByArgs, GroupByResult, HasComputedFields, HasProcedures, IncludeInput, InputValidator, JsonArray, JsonFilter, JsonNull, JsonNullClass, JsonNullValues, JsonObject, JsonValue, kysely_utils_d_exports as KyselyUtils, MapModelFieldType, ModelAllowsCreate, ModelHasRequiredUnsupportedField, ModelOperations, ModelResult, ModelSlicingOptions, NullsOrder, NumberFilter, ORMError, ORMErrorReason, OmitConfig, OmitInput, OnKyselyQueryArgs, OnKyselyQueryCallback, OnProcedureHookContext, OperationsRequiringCreate, OrderBy, PluginAfterEntityMutationArgs, PluginBeforeEntityMutationArgs, ProcedureEnvelope, ProcedureFunc, ProcedureHandlerFunc, ProcedureOperations, ProceduresOptions, ProceedKyselyQueryFunction, QueryOptions, query_utils_d_exports as QueryUtils, RejectedByPolicyReason, RuntimePlugin, schema_utils_d_exports as SchemaUtils, SelectAwareExtResult, SelectIncludeOmit, SelectInput, SelectSubset, SimplifiedPlainResult, SimplifiedResult, SlicingOptions, SortOrder, StringFilter, Subset, type ToKysely, TransactionClientContract, TransactionIsolationLevel, TypeDefResult, TypedJsonFilter, UncheckedCreateInput, UncheckedUpdateInput, UpdateArgs, UpdateInput, UpdateManyAndReturnArgs, UpdateManyArgs, UpsertArgs, WhereInput, WhereUniqueInput, ZModelFunction, ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZodSchemaFactory, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
|
3219
3514
|
//# sourceMappingURL=index.d.cts.map
|