@zenstackhq/orm 3.7.0-beta.1 → 3.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +386 -71
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +340 -42
- package/dist/index.d.mts +340 -42
- package/dist/index.mjs +385 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AnyNull, AnyNullClass, DbNull, DbNullClass, JsonArray, JsonNull, JsonNullClass, JsonNullValues, JsonObject, JsonValue } from "./common-types.mjs";
|
|
2
2
|
import * as _$kysely from "kysely";
|
|
3
|
-
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";
|
|
4
4
|
import { ZodType, z } from "zod";
|
|
5
5
|
import * as _$_zenstackhq_schema0 from "@zenstackhq/schema";
|
|
6
|
-
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";
|
|
6
|
+
import { ArrayExpression, BinaryExpression, BindingExpression, BuiltinType, CallExpression, DataSourceProviderType, Expression as Expression$1, FieldDef, FieldExpression, FieldHasDefault, FieldIsArray, FieldIsDelegateDiscriminator, FieldIsRelation, FieldType, ForeignKeyFields, GetEnum, GetEnums, GetModel, GetModelDelegateMapValue, 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";
|
|
7
7
|
import Decimal from "decimal.js";
|
|
8
8
|
|
|
9
9
|
//#region src/utils/kysely-utils.d.ts
|
|
@@ -109,6 +109,9 @@ declare class DefaultOperationNodeVisitor extends OperationNodeVisitor {
|
|
|
109
109
|
protected visitRefreshMaterializedView(node: RefreshMaterializedViewNode): void;
|
|
110
110
|
protected visitOrAction(node: OrActionNode): void;
|
|
111
111
|
protected visitCollate(node: CollateNode): void;
|
|
112
|
+
protected visitAlterType(node: AlterTypeNode): void;
|
|
113
|
+
protected visitAddValue(node: AddValueNode): void;
|
|
114
|
+
protected visitRenameValue(node: RenameValueNode): void;
|
|
112
115
|
}
|
|
113
116
|
type AnyKysely = Kysely<any>;
|
|
114
117
|
//#endregion
|
|
@@ -129,7 +132,7 @@ type TypeMap = {
|
|
|
129
132
|
Decimal: Decimal;
|
|
130
133
|
DateTime: Date;
|
|
131
134
|
Bytes: Uint8Array;
|
|
132
|
-
Json: JsonValue;
|
|
135
|
+
Json: JsonValue | null;
|
|
133
136
|
Null: null;
|
|
134
137
|
Object: Record<string, unknown>;
|
|
135
138
|
Any: unknown;
|
|
@@ -192,6 +195,8 @@ declare const FILTER_PROPERTY_TO_KIND: {
|
|
|
192
195
|
readonly array_contains: "Json";
|
|
193
196
|
readonly array_starts_with: "Json";
|
|
194
197
|
readonly array_ends_with: "Json";
|
|
198
|
+
readonly fuzzy: "Fuzzy";
|
|
199
|
+
readonly fts: "FullText";
|
|
195
200
|
readonly has: "List";
|
|
196
201
|
readonly hasEvery: "List";
|
|
197
202
|
readonly hasSome: "List";
|
|
@@ -734,8 +739,13 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
734
739
|
abstract get insertIgnoreMethod(): 'onConflict' | 'ignore';
|
|
735
740
|
/**
|
|
736
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).
|
|
737
747
|
*/
|
|
738
|
-
transformInput(value: unknown, _type: BuiltinType, _forArrayField: boolean): unknown;
|
|
748
|
+
transformInput(value: unknown, _type: BuiltinType, _forArrayField: boolean, _fieldDef?: FieldDef): unknown;
|
|
739
749
|
/**
|
|
740
750
|
* Transforms output value received from database.
|
|
741
751
|
*/
|
|
@@ -771,6 +781,11 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
771
781
|
private buildBytesFilter;
|
|
772
782
|
private buildEnumFilter;
|
|
773
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;
|
|
774
789
|
buildSelectAllFields(model: string, query: SelectQueryBuilder<any, any, any>, omit: Record<string, boolean | undefined> | undefined | null, modelAlias: string): SelectQueryBuilder<any, any, any>;
|
|
775
790
|
shouldOmitField(omit: unknown, model: string, field: string): any;
|
|
776
791
|
protected buildModelSelect(model: GetModels<Schema>, subQueryAlias: string, payload: true | FindArgs<Schema, GetModels<Schema>, any, true>, selectAllFields: boolean): SelectQueryBuilder<any, any, {}>;
|
|
@@ -866,7 +881,44 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
866
881
|
* Builds an ORDER BY clause for a field with NULLS FIRST/LAST support.
|
|
867
882
|
*/
|
|
868
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>;
|
|
869
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
|
+
};
|
|
870
922
|
//#endregion
|
|
871
923
|
//#region src/client/crud/validator/validator.d.ts
|
|
872
924
|
type InputValidatorOptions = {
|
|
@@ -1057,9 +1109,9 @@ type QueryLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, F
|
|
|
1057
1109
|
type OptionsLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>> = Uncapitalize<Model> extends keyof Options['omit'] ? Field extends keyof Options['omit'][Uncapitalize<Model>] ? Options['omit'][Uncapitalize<Model>][Field] extends boolean ? Options['omit'][Uncapitalize<Model>][Field] : undefined : undefined : undefined;
|
|
1058
1110
|
type SchemaLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['omit'] extends true ? true : false;
|
|
1059
1111
|
type FlatModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Omit, Options extends QueryOptions<Schema>> = { [Key in NonRelationFields<Schema, Model> as ShouldOmitField<Schema, Model, Options, Key, Omit> extends true ? never : Key]: MapModelFieldType<Schema, Model, Key> };
|
|
1060
|
-
type DelegateUnionResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, SubModel extends GetModels<Schema>, Omit = undefined, Depth extends readonly 0[] = []> = Depth['length'] extends 10 ? SubModel extends string ? FlatModelResult<Schema, SubModel, Omit, Options> & { [K in GetModelDiscriminator<Schema, Model>]: SubModel } : never : SubModel extends string ? IsDelegateModel<Schema, SubModel> extends true ? // sub-model is itself a delegate — recurse into its own sub-models so all
|
|
1061
|
-
DelegateUnionResult<Schema, SubModel, Options, GetSubModels<Schema, SubModel>, Omit, [...Depth, 0]> & { [K in GetModelDiscriminator<Schema, Model>]: SubModel } : // leaf model — produce a flat scalar result and fix the discriminator
|
|
1062
|
-
FlatModelResult<Schema, SubModel, Omit, Options> & { [K in GetModelDiscriminator<Schema, Model>]: SubModel } : never;
|
|
1112
|
+
type DelegateUnionResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, SubModel extends GetModels<Schema>, Omit = undefined, Depth extends readonly 0[] = []> = Depth['length'] extends 10 ? SubModel extends string ? FlatModelResult<Schema, SubModel, Omit, Options> & { [K in GetModelDiscriminator<Schema, Model>]: GetModelDelegateMapValue<Schema, SubModel> } : never : SubModel extends string ? IsDelegateModel<Schema, SubModel> extends true ? // sub-model is itself a delegate — recurse into its own sub-models so all
|
|
1113
|
+
DelegateUnionResult<Schema, SubModel, Options, GetSubModels<Schema, SubModel>, Omit, [...Depth, 0]> & { [K in GetModelDiscriminator<Schema, Model>]: GetModelDelegateMapValue<Schema, SubModel> } : // leaf model — produce a flat scalar result and fix the discriminator
|
|
1114
|
+
FlatModelResult<Schema, SubModel, Omit, Options> & { [K in GetModelDiscriminator<Schema, Model>]: GetModelDelegateMapValue<Schema, SubModel> } : never;
|
|
1063
1115
|
type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Select, Omit, Options extends QueryOptions<Schema>, ExtResult extends ExtResultBase<Schema> = {}> = { [Key in keyof Select as Select[Key] extends false | undefined ? never : Key extends keyof ExtractExtResult<ExtResult, Model & string> ? never : Key extends '_count' ? Select[Key] extends SelectCount<Schema, Model, Options> ? Key : never : Key extends keyof Omit ? Omit[Key] extends true ? never : Key : Key]: Key extends '_count' ? SelectCountResult<Schema, Model, Select[Key]> : Key extends NonRelationFields<Schema, Model> ? MapModelFieldType<Schema, Model, Key> : Key extends RelationFields<Schema, Model> ? ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Select[Key], Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>, ExtResult> : never };
|
|
1064
1116
|
type SelectCountResult<Schema extends SchemaDef, Model extends GetModels<Schema>, C> = C extends true ? { [Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: number } : C extends {
|
|
1065
1117
|
select: infer S;
|
|
@@ -1089,7 +1141,43 @@ type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Optio
|
|
|
1089
1141
|
OR?: WhereInput<Schema, Model, Options, ScalarOnly>[];
|
|
1090
1142
|
NOT?: OrArray<WhereInput<Schema, Model, Options, ScalarOnly>>;
|
|
1091
1143
|
};
|
|
1092
|
-
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;
|
|
1093
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 ? {
|
|
1094
1182
|
/**
|
|
1095
1183
|
* Checks for equality with the specified enum value.
|
|
@@ -1367,6 +1455,142 @@ type NonArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTy
|
|
|
1367
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> };
|
|
1368
1456
|
type SortOrder = 'asc' | 'desc';
|
|
1369
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
|
+
};
|
|
1370
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 | {
|
|
1371
1595
|
/**
|
|
1372
1596
|
* Sort order
|
|
@@ -1477,7 +1701,7 @@ type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>,
|
|
|
1477
1701
|
/**
|
|
1478
1702
|
* Order by clauses
|
|
1479
1703
|
*/
|
|
1480
|
-
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> : {})>;
|
|
1481
1705
|
/**
|
|
1482
1706
|
* Cursor for pagination
|
|
1483
1707
|
*/
|
|
@@ -1921,6 +2145,62 @@ type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Ar
|
|
|
1921
2145
|
*/
|
|
1922
2146
|
_max: AggCommonOutput<Max>;
|
|
1923
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];
|
|
1924
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>;
|
|
1925
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>>;
|
|
1926
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>;
|
|
@@ -2015,6 +2295,8 @@ type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2015
2295
|
type EnumValue<Schema extends SchemaDef, Enum extends GetEnums<Schema>> = GetEnum<Schema, Enum>[keyof GetEnum<Schema, Enum>];
|
|
2016
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;
|
|
2017
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;
|
|
2018
2300
|
/**
|
|
2019
2301
|
* Extracts extended query args for a specific operation.
|
|
2020
2302
|
*/
|
|
@@ -2094,13 +2376,9 @@ interface Diagnostics {
|
|
|
2094
2376
|
/**
|
|
2095
2377
|
* A promise that only executes when it's awaited or .then() is called.
|
|
2096
2378
|
*/
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
* Callable to get a plain promise.
|
|
2101
|
-
*/
|
|
2102
|
-
cb: (txClient?: ClientContract<Schema>) => Promise<T>;
|
|
2103
|
-
};
|
|
2379
|
+
interface ZenStackPromise<T> extends Promise<T> {
|
|
2380
|
+
[Symbol.toStringTag]: 'ZenStackPromise';
|
|
2381
|
+
}
|
|
2104
2382
|
//#endregion
|
|
2105
2383
|
//#region src/client/contract.d.ts
|
|
2106
2384
|
type TransactionUnsupportedMethods = (typeof TRANSACTION_UNSUPPORTED_METHODS)[number];
|
|
@@ -2114,6 +2392,19 @@ declare enum TransactionIsolationLevel {
|
|
|
2114
2392
|
Serializable = "serializable",
|
|
2115
2393
|
Snapshot = "snapshot"
|
|
2116
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;
|
|
2117
2408
|
/**
|
|
2118
2409
|
* ZenStack client interface.
|
|
2119
2410
|
*/
|
|
@@ -2125,7 +2416,9 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2125
2416
|
/**
|
|
2126
2417
|
* The client options.
|
|
2127
2418
|
*/
|
|
2128
|
-
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;
|
|
2129
2422
|
/**
|
|
2130
2423
|
* Executes a prepared raw query and returns the number of affected rows.
|
|
2131
2424
|
* @example
|
|
@@ -2133,7 +2426,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2133
2426
|
* const result = await db.$executeRaw`UPDATE User SET cool = ${true} WHERE email = ${'user@email.com'};`
|
|
2134
2427
|
* ```
|
|
2135
2428
|
*/
|
|
2136
|
-
$executeRaw(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<
|
|
2429
|
+
$executeRaw(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<number>;
|
|
2137
2430
|
/**
|
|
2138
2431
|
* Executes a raw query and returns the number of affected rows.
|
|
2139
2432
|
* This method is susceptible to SQL injections.
|
|
@@ -2142,7 +2435,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2142
2435
|
* const result = await db.$executeRawUnsafe('UPDATE User SET cool = $1 WHERE email = $2 ;', true, 'user@email.com')
|
|
2143
2436
|
* ```
|
|
2144
2437
|
*/
|
|
2145
|
-
$executeRawUnsafe(query: string, ...values: any[]): ZenStackPromise<
|
|
2438
|
+
$executeRawUnsafe(query: string, ...values: any[]): ZenStackPromise<number>;
|
|
2146
2439
|
/**
|
|
2147
2440
|
* Performs a prepared raw query and returns the `SELECT` data.
|
|
2148
2441
|
* @example
|
|
@@ -2150,7 +2443,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2150
2443
|
* const result = await db.$queryRaw`SELECT * FROM User WHERE id = ${1} OR email = ${'user@email.com'};`
|
|
2151
2444
|
* ```
|
|
2152
2445
|
*/
|
|
2153
|
-
$queryRaw<T = unknown>(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<
|
|
2446
|
+
$queryRaw<T = unknown>(query: TemplateStringsArray, ...values: any[]): ZenStackPromise<T>;
|
|
2154
2447
|
/**
|
|
2155
2448
|
* Performs a raw query and returns the `SELECT` data.
|
|
2156
2449
|
* This method is susceptible to SQL injections.
|
|
@@ -2159,7 +2452,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2159
2452
|
* const result = await db.$queryRawUnsafe('SELECT * FROM User WHERE id = $1 OR email = $2;', 1, 'user@email.com')
|
|
2160
2453
|
* ```
|
|
2161
2454
|
*/
|
|
2162
|
-
$queryRawUnsafe<T = unknown>(query: string, ...values: any[]): ZenStackPromise<
|
|
2455
|
+
$queryRawUnsafe<T = unknown>(query: string, ...values: any[]): ZenStackPromise<T>;
|
|
2163
2456
|
/**
|
|
2164
2457
|
* The current user identity. If the client is not bound to any user context, returns `undefined`.
|
|
2165
2458
|
*/
|
|
@@ -2226,7 +2519,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
|
|
|
2226
2519
|
* db.post.create({ data: { title: 'Hello World', authorId: 1 } }),
|
|
2227
2520
|
* ]);
|
|
2228
2521
|
*/
|
|
2229
|
-
$transaction<P extends ZenStackPromise<
|
|
2522
|
+
$transaction<P extends ZenStackPromise<any>[]>(arg: [...P], options?: {
|
|
2230
2523
|
isolationLevel?: TransactionIsolationLevel;
|
|
2231
2524
|
}): Promise<UnwrapTuplePromises<P>>;
|
|
2232
2525
|
/**
|
|
@@ -2319,7 +2612,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2319
2612
|
* });
|
|
2320
2613
|
* ```
|
|
2321
2614
|
*/
|
|
2322
|
-
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>>;
|
|
2323
2616
|
/**
|
|
2324
2617
|
* Updates multiple entities and returns them.
|
|
2325
2618
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2342,7 +2635,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
|
|
|
2342
2635
|
* });
|
|
2343
2636
|
* ```
|
|
2344
2637
|
*/
|
|
2345
|
-
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>>;
|
|
2346
2639
|
});
|
|
2347
2640
|
type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, ExtQueryArgs extends ExtQueryArgsBase, ExtResult extends ExtResultBase<Schema> = {}> = {
|
|
2348
2641
|
/**
|
|
@@ -2426,35 +2719,35 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2426
2719
|
* }); // result: `{ _count: { posts: number } }`
|
|
2427
2720
|
* ```
|
|
2428
2721
|
*/
|
|
2429
|
-
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>>;
|
|
2430
2723
|
/**
|
|
2431
2724
|
* Returns a uniquely identified entity.
|
|
2432
2725
|
* @param args - query args
|
|
2433
2726
|
* @returns a single entity or null if not found
|
|
2434
2727
|
* @see {@link findMany}
|
|
2435
2728
|
*/
|
|
2436
|
-
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>>;
|
|
2437
2730
|
/**
|
|
2438
2731
|
* Returns a uniquely identified entity or throws `NotFoundError` if not found.
|
|
2439
2732
|
* @param args - query args
|
|
2440
2733
|
* @returns a single entity
|
|
2441
2734
|
* @see {@link findMany}
|
|
2442
2735
|
*/
|
|
2443
|
-
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>>;
|
|
2444
2737
|
/**
|
|
2445
2738
|
* Returns the first entity.
|
|
2446
2739
|
* @param args - query args
|
|
2447
2740
|
* @returns a single entity or null if not found
|
|
2448
2741
|
* @see {@link findMany}
|
|
2449
2742
|
*/
|
|
2450
|
-
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>>;
|
|
2451
2744
|
/**
|
|
2452
2745
|
* Returns the first entity or throws `NotFoundError` if not found.
|
|
2453
2746
|
* @param args - query args
|
|
2454
2747
|
* @returns a single entity
|
|
2455
2748
|
* @see {@link findMany}
|
|
2456
2749
|
*/
|
|
2457
|
-
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>>;
|
|
2458
2751
|
/**
|
|
2459
2752
|
* Creates a new entity.
|
|
2460
2753
|
* @param args - create args
|
|
@@ -2507,7 +2800,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2507
2800
|
* });
|
|
2508
2801
|
* ```
|
|
2509
2802
|
*/
|
|
2510
|
-
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>>;
|
|
2511
2804
|
/**
|
|
2512
2805
|
* Creates multiple entities. Only scalar fields are allowed.
|
|
2513
2806
|
* @param args - create args
|
|
@@ -2533,7 +2826,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2533
2826
|
* });
|
|
2534
2827
|
* ```
|
|
2535
2828
|
*/
|
|
2536
|
-
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>>;
|
|
2537
2830
|
/**
|
|
2538
2831
|
* Updates a uniquely identified entity.
|
|
2539
2832
|
* @param args - update args. See {@link findMany} for how to control
|
|
@@ -2651,7 +2944,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2651
2944
|
* });
|
|
2652
2945
|
* ```
|
|
2653
2946
|
*/
|
|
2654
|
-
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>>;
|
|
2655
2948
|
/**
|
|
2656
2949
|
* Updates multiple entities.
|
|
2657
2950
|
* @param args - update args. Only scalar fields are allowed for data.
|
|
@@ -2672,7 +2965,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2672
2965
|
* limit: 10
|
|
2673
2966
|
* });
|
|
2674
2967
|
*/
|
|
2675
|
-
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>>;
|
|
2676
2969
|
/**
|
|
2677
2970
|
* Creates or updates an entity.
|
|
2678
2971
|
* @param args - upsert args
|
|
@@ -2693,7 +2986,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2693
2986
|
* });
|
|
2694
2987
|
* ```
|
|
2695
2988
|
*/
|
|
2696
|
-
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>>;
|
|
2697
2990
|
/**
|
|
2698
2991
|
* Deletes a uniquely identifiable entity.
|
|
2699
2992
|
* @param args - delete args
|
|
@@ -2713,7 +3006,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2713
3006
|
* }); // result: `{ id: string; email: string }`
|
|
2714
3007
|
* ```
|
|
2715
3008
|
*/
|
|
2716
|
-
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>>;
|
|
2717
3010
|
/**
|
|
2718
3011
|
* Deletes multiple entities.
|
|
2719
3012
|
* @param args - delete args
|
|
@@ -2733,7 +3026,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2733
3026
|
* });
|
|
2734
3027
|
* ```
|
|
2735
3028
|
*/
|
|
2736
|
-
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>>;
|
|
2737
3030
|
/**
|
|
2738
3031
|
* Counts rows or field values.
|
|
2739
3032
|
* @param args - count args
|
|
@@ -2752,7 +3045,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2752
3045
|
* select: { _all: true, email: true }
|
|
2753
3046
|
* }); // result: `{ _all: number, email: number }`
|
|
2754
3047
|
*/
|
|
2755
|
-
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>>>;
|
|
2756
3049
|
/**
|
|
2757
3050
|
* Aggregates rows.
|
|
2758
3051
|
* @param args - aggregation args
|
|
@@ -2770,7 +3063,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2770
3063
|
* _max: { age: true }
|
|
2771
3064
|
* }); // result: `{ _count: number, _avg: { age: number }, ... }`
|
|
2772
3065
|
*/
|
|
2773
|
-
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>>>;
|
|
2774
3067
|
/**
|
|
2775
3068
|
* Groups rows by columns.
|
|
2776
3069
|
* @param args - groupBy args
|
|
@@ -2804,7 +3097,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2804
3097
|
* having: { country: 'US', age: { _avg: { gte: 18 } } }
|
|
2805
3098
|
* });
|
|
2806
3099
|
*/
|
|
2807
|
-
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>>>;
|
|
2808
3101
|
/**
|
|
2809
3102
|
* Checks if an entity exists.
|
|
2810
3103
|
* @param args - exists args
|
|
@@ -2822,7 +3115,7 @@ type CommonModelOperations<Schema extends SchemaDef, Model extends GetModels<Sch
|
|
|
2822
3115
|
* where: { posts: { some: { published: true } } },
|
|
2823
3116
|
* }); // result: `boolean`
|
|
2824
3117
|
*/
|
|
2825
|
-
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>>;
|
|
2826
3119
|
};
|
|
2827
3120
|
type OperationsRequiringCreate = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert';
|
|
2828
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>;
|
|
@@ -2927,6 +3220,8 @@ declare class ZodSchemaFactory<Schema extends SchemaDef, Options extends ClientO
|
|
|
2927
3220
|
private makeNumberFilterSchema;
|
|
2928
3221
|
private makeStringFilterSchema;
|
|
2929
3222
|
private makeStringModeSchema;
|
|
3223
|
+
private makeFuzzyFilterSchema;
|
|
3224
|
+
private makeFullTextFilterSchema;
|
|
2930
3225
|
private makeSelectSchema;
|
|
2931
3226
|
private makeCountSelectionSchema;
|
|
2932
3227
|
private makeRelationSelectIncludeSchema;
|
|
@@ -2979,6 +3274,8 @@ declare class ZodSchemaFactory<Schema extends SchemaDef, Options extends ClientO
|
|
|
2979
3274
|
private orArray;
|
|
2980
3275
|
private isNumericField;
|
|
2981
3276
|
private get providerSupportsCaseSensitivity();
|
|
3277
|
+
private get providerSupportsFullTextSearch();
|
|
3278
|
+
private get providerSupportsFuzzySearch();
|
|
2982
3279
|
/**
|
|
2983
3280
|
* Gets the effective set of allowed FilterKind values for a specific model and field.
|
|
2984
3281
|
* Respects the precedence: model[field] > model.$all > $all[field] > $all.$all.
|
|
@@ -3090,7 +3387,7 @@ declare class ORMError extends Error {
|
|
|
3090
3387
|
sqlParams?: readonly unknown[];
|
|
3091
3388
|
}
|
|
3092
3389
|
declare namespace query_utils_d_exports {
|
|
3093
|
-
export { TEMP_ALIAS_PREFIX, aggregate, buildJoinPairs, ensureArray, extractFieldName, extractIdFields, extractModelName, fieldHasDefaultValue, flattenCompoundUniqueFilters, getDelegateDescendantModels, getDiscriminatorField, getEnum, getField, getIdFields, getIdValues, getManyToManyRelation, getModel, getModelFields, getRelationForeignKeyFieldPairs, getTypeDef, getUniqueFields, hasModel, isEnum, isForeignKeyField, isInheritedField, isRelationField, isScalarField, isTypeDef, isUnsupportedField, makeDefaultOrderBy, requireField, requireIdFields, requireModel, requireTypeDef, stripAlias, tmpAlias };
|
|
3390
|
+
export { TEMP_ALIAS_PREFIX, aggregate, buildJoinPairs, ensureArray, extractFieldName, extractIdFields, extractModelName, fieldHasDefaultValue, flattenCompoundUniqueFilters, getDelegateDescendantModels, getDelegateDiscriminatorValue, getDiscriminatorField, getEnum, getField, getIdFields, getIdValues, getManyToManyRelation, getModel, getModelFields, getRelationForeignKeyFieldPairs, getTypeDef, getUniqueFields, hasModel, isEnum, isForeignKeyField, isInheritedField, isRelationField, isScalarField, isTypeDef, isUnsupportedField, makeDefaultOrderBy, requireField, requireIdFields, requireModel, requireTypeDef, stripAlias, tmpAlias };
|
|
3094
3391
|
}
|
|
3095
3392
|
declare function hasModel(schema: SchemaDef, model: string): boolean;
|
|
3096
3393
|
declare function getModel(schema: SchemaDef, model: string): ModelDef | undefined;
|
|
@@ -3159,6 +3456,7 @@ declare function extractIdFields(entity: any, schema: SchemaDef, model: string):
|
|
|
3159
3456
|
[k: string]: unknown;
|
|
3160
3457
|
};
|
|
3161
3458
|
declare function getDiscriminatorField(schema: SchemaDef, model: string): string | undefined;
|
|
3459
|
+
declare function getDelegateDiscriminatorValue(schema: SchemaDef, model: string): string;
|
|
3162
3460
|
declare function getDelegateDescendantModels(schema: SchemaDef, model: string, collected?: Set<ModelDef>): ModelDef[];
|
|
3163
3461
|
declare function aggregate(eb: ExpressionBuilder<any, any>, expr: Expression<any>, op: AggregateOperators): _$kysely.AggregateFunctionBuilder<any, any, string | number | bigint>;
|
|
3164
3462
|
/**
|
|
@@ -3213,5 +3511,5 @@ declare class MatchingExpressionVisitor extends ExpressionVisitor {
|
|
|
3213
3511
|
};
|
|
3214
3512
|
}
|
|
3215
3513
|
//#endregion
|
|
3216
|
-
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, 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, UncheckedCreateInput, UncheckedUpdateInput, UpdateArgs, UpdateInput, UpdateManyAndReturnArgs, UpdateManyArgs, UpsertArgs, WhereInput, WhereUniqueInput, ZModelFunction, ZModelFunctionContext, ZenStackClient, type ZenStackPromise, type ZodSchemaFactory, createQuerySchemaFactory, definePlugin, getCrudDialect };
|
|
3514
|
+
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 };
|
|
3217
3515
|
//# sourceMappingURL=index.d.mts.map
|