@zenstackhq/orm 3.0.0-beta.26 → 3.0.0-beta.28
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 +624 -209
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +573 -33
- package/dist/index.d.ts +573 -33
- package/dist/index.js +618 -209
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import Decimal from 'decimal.js';
|
|
2
2
|
import * as _zenstackhq_schema from '@zenstackhq/schema';
|
|
3
|
-
import { SchemaDef, BuiltinType, GetModels, FieldDef, ModelDef, DataSourceProviderType, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, GetModel, ProcedureDef,
|
|
3
|
+
import { SchemaDef, BuiltinType, GetModels, FieldDef, ModelDef, DataSourceProviderType, ScalarFields, ForeignKeyFields, GetModelFields, FieldHasDefault, GetModelFieldType, ModelFieldIsOptional, GetModelField, GetModel, ProcedureDef, NonRelationFields, GetEnums, GetEnum, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, GetTypeDefFieldType, TypeDefFieldIsArray, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, IsDelegateModel, Expression as Expression$1, LiteralExpression, ArrayExpression, FieldExpression, MemberExpression, BinaryExpression, UnaryExpression, CallExpression, ThisExpression, NullExpression } from '@zenstackhq/schema';
|
|
4
4
|
import * as kysely from 'kysely';
|
|
5
5
|
import { OperationNodeVisitor, OperationNode, SelectQueryNode, SelectionNode, ColumnNode, AliasNode, TableNode, FromNode, ReferenceNode, AndNode, OrNode, ValueListNode, ParensNode, JoinNode, RawNode, WhereNode, InsertQueryNode, DeleteQueryNode, ReturningNode, CreateTableNode, AddColumnNode, ColumnDefinitionNode, DropTableNode, OrderByNode, OrderByItemNode, GroupByNode, GroupByItemNode, UpdateQueryNode, ColumnUpdateNode, LimitNode, OffsetNode, OnConflictNode, OnDuplicateKeyNode, CheckConstraintNode, DataTypeNode, SelectAllNode, IdentifierNode, SchemableIdentifierNode, ValueNode, PrimitiveValueListNode, OperatorNode, CreateIndexNode, DropIndexNode, ListNode, PrimaryKeyConstraintNode, UniqueConstraintNode, ReferencesNode, WithNode, CommonTableExpressionNode, CommonTableExpressionNameNode, HavingNode, CreateSchemaNode, DropSchemaNode, AlterTableNode, DropColumnNode, RenameColumnNode, AlterColumnNode, ModifyColumnNode, AddConstraintNode, DropConstraintNode, ForeignKeyConstraintNode, CreateViewNode, DropViewNode, GeneratedNode, DefaultValueNode, OnNode, ValuesNode, SelectModifierNode, CreateTypeNode, DropTypeNode, ExplainNode, DefaultInsertValueNode, AggregateFunctionNode, OverNode, PartitionByNode, PartitionByItemNode, SetOperationNode, BinaryOperationNode, UnaryOperationNode, UsingNode, FunctionNode, CaseNode, WhenNode, JSONReferenceNode, JSONPathNode, JSONPathLegNode, JSONOperatorChainNode, TupleNode, MergeQueryNode, MatchedNode, AddIndexNode, CastNode, FetchNode, TopNode, OutputNode, RenameConstraintNode, RefreshMaterializedViewNode, OrActionNode, CollateNode, Kysely, ExpressionBuilder, SelectQueryBuilder, Expression, SqlBool, ExpressionWrapper, Generated, QueryId, RootOperationNode, QueryResult, UnknownRow, Dialect, KyselyConfig, OperandExpression } from 'kysely';
|
|
6
6
|
|
|
@@ -113,6 +113,28 @@ declare namespace kyselyUtils {
|
|
|
113
113
|
export { type kyselyUtils_AnyKysely as AnyKysely, kyselyUtils_DefaultOperationNodeVisitor as DefaultOperationNodeVisitor };
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
+
type JsonValue = string | number | boolean | JsonObject | JsonArray;
|
|
117
|
+
type JsonObject = {
|
|
118
|
+
[key: string]: JsonValue | null;
|
|
119
|
+
};
|
|
120
|
+
type JsonArray = ReadonlyArray<JsonValue | null>;
|
|
121
|
+
type JsonNullValues = DbNull | JsonNull | AnyNull;
|
|
122
|
+
declare class DbNullClass {
|
|
123
|
+
private __brand;
|
|
124
|
+
}
|
|
125
|
+
declare const DbNull: DbNullClass;
|
|
126
|
+
type DbNull = typeof DbNull;
|
|
127
|
+
declare class JsonNullClass {
|
|
128
|
+
private __brand;
|
|
129
|
+
}
|
|
130
|
+
declare const JsonNull: JsonNullClass;
|
|
131
|
+
type JsonNull = typeof JsonNull;
|
|
132
|
+
declare class AnyNullClass {
|
|
133
|
+
private __brand;
|
|
134
|
+
}
|
|
135
|
+
declare const AnyNull: AnyNullClass;
|
|
136
|
+
type AnyNull = typeof AnyNull;
|
|
137
|
+
|
|
116
138
|
type Optional<T extends object, K extends keyof T = keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
117
139
|
type PartialIf<T, Condition extends boolean> = Condition extends true ? Partial<T> : T;
|
|
118
140
|
type NullableIf<T, Condition extends boolean> = Condition extends true ? T | null : T;
|
|
@@ -134,11 +156,6 @@ type TypeMap = {
|
|
|
134
156
|
Json: JsonValue;
|
|
135
157
|
};
|
|
136
158
|
type MapBaseType$1<T extends string> = T extends keyof TypeMap ? TypeMap[T] : unknown;
|
|
137
|
-
type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
138
|
-
type JsonObject = {
|
|
139
|
-
[key: string]: JsonValue;
|
|
140
|
-
};
|
|
141
|
-
type JsonArray = Array<JsonValue>;
|
|
142
159
|
type OrArray<T, IF extends boolean = true> = IF extends true ? T | T[] : T;
|
|
143
160
|
type NonEmptyArray<T> = [T, ...T[]];
|
|
144
161
|
type ValueOfPotentialTuple<T> = T extends unknown[] ? T[number] : T;
|
|
@@ -190,10 +207,19 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
190
207
|
private buildToOneRelationFilter;
|
|
191
208
|
private buildToManyRelationFilter;
|
|
192
209
|
private buildArrayFilter;
|
|
193
|
-
buildPrimitiveFilter(fieldRef: Expression<any>, fieldDef: FieldDef, payload: any):
|
|
210
|
+
buildPrimitiveFilter(fieldRef: Expression<any>, fieldDef: FieldDef, payload: any): any;
|
|
211
|
+
private buildJsonFilter;
|
|
212
|
+
private buildPlainJsonFilter;
|
|
213
|
+
private buildTypedJsonFilter;
|
|
214
|
+
private buildTypedJsonArrayFilter;
|
|
215
|
+
private buildTypeJsonNonArrayFilter;
|
|
216
|
+
private buildJsonValueFilterClause;
|
|
194
217
|
private buildLiteralFilter;
|
|
195
218
|
private buildStandardFilter;
|
|
196
219
|
private buildStringFilter;
|
|
220
|
+
private buildJsonStringFilter;
|
|
221
|
+
private escapeLikePattern;
|
|
222
|
+
private buildStringLike;
|
|
197
223
|
private prepStringCasing;
|
|
198
224
|
private buildNumberFilter;
|
|
199
225
|
private buildBooleanFilter;
|
|
@@ -262,6 +288,18 @@ declare abstract class BaseCrudDialect<Schema extends SchemaDef> {
|
|
|
262
288
|
supportsILike: boolean;
|
|
263
289
|
likeCaseSensitive: boolean;
|
|
264
290
|
};
|
|
291
|
+
/**
|
|
292
|
+
* Builds a JSON path selection expression.
|
|
293
|
+
*/
|
|
294
|
+
protected abstract buildJsonPathSelection(receiver: Expression<any>, path: string | undefined): Expression<any>;
|
|
295
|
+
/**
|
|
296
|
+
* Builds a JSON array filter expression.
|
|
297
|
+
*/
|
|
298
|
+
protected abstract buildJsonArrayFilter(receiver: Expression<any>, operation: 'array_contains' | 'array_starts_with' | 'array_ends_with', value: unknown): Expression<SqlBool>;
|
|
299
|
+
/**
|
|
300
|
+
* Builds a JSON array exists predicate (returning if any element matches the filter).
|
|
301
|
+
*/
|
|
302
|
+
protected abstract buildJsonArrayExistsPredicate(receiver: Expression<any>, buildFilter: (elem: Expression<any>) => Expression<SqlBool>): Expression<SqlBool>;
|
|
265
303
|
}
|
|
266
304
|
|
|
267
305
|
type ToKyselySchema<Schema extends SchemaDef> = {
|
|
@@ -525,16 +563,13 @@ type HasProcedures<Schema extends SchemaDef> = Schema extends {
|
|
|
525
563
|
procedures: Record<string, ProcedureDef>;
|
|
526
564
|
} ? true : false;
|
|
527
565
|
|
|
528
|
-
type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>, Omit = undefined, Optional = false, Array = false> = WrapType<
|
|
566
|
+
type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>, Omit = undefined, Optional = false, Array = false> = WrapType<{
|
|
529
567
|
[Key in NonRelationFields<Schema, Model> as ShouldOmitField<Schema, Model, Options, Key, Omit> extends true ? never : Key]: MapModelFieldType<Schema, Model, Key>;
|
|
530
568
|
}, Optional, Array>;
|
|
531
569
|
type ShouldOmitField<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>, Field extends GetModelFields<Schema, Model>, Omit> = QueryLevelOmit<Schema, Model, Field, Omit> extends boolean ? QueryLevelOmit<Schema, Model, Field, Omit> : OptionsLevelOmit<Schema, Model, Field, Options> extends boolean ? OptionsLevelOmit<Schema, Model, Field, Options> : SchemaLevelOmit<Schema, Model, Field>;
|
|
532
570
|
type QueryLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Omit> = Field extends keyof Omit ? (Omit[Field] extends boolean ? Omit[Field] : undefined) : undefined;
|
|
533
571
|
type OptionsLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends ClientOptions<Schema>> = Model extends keyof Options['omit'] ? Field extends keyof Options['omit'][Model] ? Options['omit'][Model][Field] extends boolean ? Options['omit'][Model][Field] : undefined : undefined : undefined;
|
|
534
572
|
type SchemaLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['omit'] extends true ? true : false;
|
|
535
|
-
type DelegateUnionResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>, SubModel extends GetModels<Schema>, Omit = undefined> = SubModel extends string ? DefaultModelResult<Schema, SubModel, Options, Omit> & {
|
|
536
|
-
[K in GetModelDiscriminator<Schema, Model>]: SubModel;
|
|
537
|
-
} : never;
|
|
538
573
|
type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>, Select, Omit> = {
|
|
539
574
|
[Key in keyof Select as Select[Key] extends false | undefined ? never : Key extends keyof Omit ? Omit[Key] extends true ? never : Key : Key extends '_count' ? Select[Key] extends SelectCount<Schema, Model> ? Key : never : Key]: Key extends '_count' ? SelectCountResult<Schema, Model, Select[Key]> : Key extends NonRelationFields<Schema, Model> ? MapModelFieldType<Schema, Model, Key> : Key extends RelationFields<Schema, Model> ? Select[Key] extends FindArgs<Schema, RelationFieldType<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> ? 'select' extends keyof Select[Key] ? ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Options, Pick<Select[Key], 'select'>, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Options, Pick<Select[Key], 'include' | 'omit'>, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : DefaultModelResult<Schema, RelationFieldType<Schema, Model, Key>, Options, Omit, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : never;
|
|
540
575
|
};
|
|
@@ -566,7 +601,7 @@ type BatchResult = {
|
|
|
566
601
|
count: number;
|
|
567
602
|
};
|
|
568
603
|
type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, ScalarOnly extends boolean = false, WithAggregations extends boolean = false> = {
|
|
569
|
-
[Key in GetModelFields<Schema, Model> as ScalarOnly extends true ? Key extends RelationFields<Schema, Model> ? never : Key : Key]?: Key extends RelationFields<Schema, Model> ? RelationFilter<Schema, Model, Key> : FieldIsArray<Schema, Model, Key> extends true ? ArrayFilter<Schema, GetModelFieldType<Schema, Model, Key>> : GetModelFieldType<Schema, Model, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetModelFieldType<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>, WithAggregations> : PrimitiveFilter<GetModelFieldType<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>, WithAggregations>;
|
|
604
|
+
[Key in GetModelFields<Schema, Model> as ScalarOnly extends true ? Key extends RelationFields<Schema, Model> ? never : Key : Key]?: Key extends RelationFields<Schema, Model> ? RelationFilter<Schema, Model, Key> : FieldIsArray<Schema, Model, Key> extends true ? ArrayFilter<Schema, GetModelFieldType<Schema, Model, Key>> : GetModelFieldType<Schema, Model, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetModelFieldType<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>, WithAggregations> : GetModelFieldType<Schema, Model, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetModelFieldType<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>> : PrimitiveFilter<GetModelFieldType<Schema, Model, Key>, ModelFieldIsOptional<Schema, Model, Key>, WithAggregations>;
|
|
570
605
|
} & {
|
|
571
606
|
$expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
|
|
572
607
|
} & {
|
|
@@ -575,94 +610,312 @@ type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Scala
|
|
|
575
610
|
NOT?: OrArray<WhereInput<Schema, Model, ScalarOnly>>;
|
|
576
611
|
};
|
|
577
612
|
type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable extends boolean, WithAggregations extends boolean> = NullableIf<keyof GetEnum<Schema, T>, Nullable> | ({
|
|
613
|
+
/**
|
|
614
|
+
* Checks for equality with the specified enum value.
|
|
615
|
+
*/
|
|
578
616
|
equals?: NullableIf<keyof GetEnum<Schema, T>, Nullable>;
|
|
617
|
+
/**
|
|
618
|
+
* Checks if the enum value is in the specified list of values.
|
|
619
|
+
*/
|
|
579
620
|
in?: (keyof GetEnum<Schema, T>)[];
|
|
621
|
+
/**
|
|
622
|
+
* Checks if the enum value is not in the specified list of values.
|
|
623
|
+
*/
|
|
580
624
|
notIn?: (keyof GetEnum<Schema, T>)[];
|
|
625
|
+
/**
|
|
626
|
+
* Builds a negated filter.
|
|
627
|
+
*/
|
|
581
628
|
not?: EnumFilter<Schema, T, Nullable, WithAggregations>;
|
|
582
629
|
} & (WithAggregations extends true ? {
|
|
630
|
+
/**
|
|
631
|
+
* Filters against the count of records.
|
|
632
|
+
*/
|
|
583
633
|
_count?: NumberFilter<'Int', false, false>;
|
|
634
|
+
/**
|
|
635
|
+
* Filters against the minimum value.
|
|
636
|
+
*/
|
|
584
637
|
_min?: EnumFilter<Schema, T, false, false>;
|
|
638
|
+
/**
|
|
639
|
+
* Filters against the maximum value.
|
|
640
|
+
*/
|
|
585
641
|
_max?: EnumFilter<Schema, T, false, false>;
|
|
586
642
|
} : {}));
|
|
587
|
-
type ArrayFilter<Schema extends SchemaDef,
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
643
|
+
type ArrayFilter<Schema extends SchemaDef, Type extends string> = {
|
|
644
|
+
/**
|
|
645
|
+
* Checks if the array equals the specified array.
|
|
646
|
+
*/
|
|
647
|
+
equals?: MapScalarType<Schema, Type>[] | null;
|
|
648
|
+
/**
|
|
649
|
+
* Checks if the array contains all elements of the specified array.
|
|
650
|
+
*/
|
|
651
|
+
has?: MapScalarType<Schema, Type> | null;
|
|
652
|
+
/**
|
|
653
|
+
* Checks if the array contains any of the elements of the specified array.
|
|
654
|
+
*/
|
|
655
|
+
hasEvery?: MapScalarType<Schema, Type>[];
|
|
656
|
+
/**
|
|
657
|
+
* Checks if the array contains some of the elements of the specified array.
|
|
658
|
+
*/
|
|
659
|
+
hasSome?: MapScalarType<Schema, Type>[];
|
|
660
|
+
/**
|
|
661
|
+
* Checks if the array is empty.
|
|
662
|
+
*/
|
|
592
663
|
isEmpty?: boolean;
|
|
593
664
|
};
|
|
594
|
-
type MapScalarType<Schema extends SchemaDef,
|
|
595
|
-
type PrimitiveFilter<T extends string, Nullable extends boolean, WithAggregations extends boolean> = T extends 'String' ? StringFilter<Nullable, WithAggregations> : T extends 'Int' | 'Float' | 'Decimal' | 'BigInt' ? NumberFilter<T, Nullable, WithAggregations> : T extends 'Boolean' ? BooleanFilter<Nullable, WithAggregations> : T extends 'DateTime' ? DateTimeFilter<Nullable, WithAggregations> : T extends 'Bytes' ? BytesFilter<Nullable, WithAggregations> : T extends 'Json' ?
|
|
665
|
+
type MapScalarType<Schema extends SchemaDef, Type extends string> = Type extends GetEnums<Schema> ? keyof GetEnum<Schema, Type> : MapBaseType$1<Type>;
|
|
666
|
+
type PrimitiveFilter<T extends string, Nullable extends boolean, WithAggregations extends boolean> = T extends 'String' ? StringFilter<Nullable, WithAggregations> : T extends 'Int' | 'Float' | 'Decimal' | 'BigInt' ? NumberFilter<T, Nullable, WithAggregations> : T extends 'Boolean' ? BooleanFilter<Nullable, WithAggregations> : T extends 'DateTime' ? DateTimeFilter<Nullable, WithAggregations> : T extends 'Bytes' ? BytesFilter<Nullable, WithAggregations> : T extends 'Json' ? JsonFilter : never;
|
|
596
667
|
type CommonPrimitiveFilter<DataType, T extends BuiltinType, Nullable extends boolean, WithAggregations extends boolean> = {
|
|
668
|
+
/**
|
|
669
|
+
* Checks for equality with the specified value.
|
|
670
|
+
*/
|
|
597
671
|
equals?: NullableIf<DataType, Nullable>;
|
|
672
|
+
/**
|
|
673
|
+
* Checks if the value is in the specified list of values.
|
|
674
|
+
*/
|
|
598
675
|
in?: DataType[];
|
|
676
|
+
/**
|
|
677
|
+
* Checks if the value is not in the specified list of values.
|
|
678
|
+
*/
|
|
599
679
|
notIn?: DataType[];
|
|
680
|
+
/**
|
|
681
|
+
* Checks if the value is less than the specified value.
|
|
682
|
+
*/
|
|
600
683
|
lt?: DataType;
|
|
684
|
+
/**
|
|
685
|
+
* Checks if the value is less than or equal to the specified value.
|
|
686
|
+
*/
|
|
601
687
|
lte?: DataType;
|
|
688
|
+
/**
|
|
689
|
+
* Checks if the value is greater than the specified value.
|
|
690
|
+
*/
|
|
602
691
|
gt?: DataType;
|
|
692
|
+
/**
|
|
693
|
+
* Checks if the value is greater than or equal to the specified value.
|
|
694
|
+
*/
|
|
603
695
|
gte?: DataType;
|
|
696
|
+
/**
|
|
697
|
+
* Builds a negated filter.
|
|
698
|
+
*/
|
|
604
699
|
not?: PrimitiveFilter<T, Nullable, WithAggregations>;
|
|
605
700
|
};
|
|
606
701
|
type StringFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<string, Nullable> | (CommonPrimitiveFilter<string, 'String', Nullable, WithAggregations> & {
|
|
702
|
+
/**
|
|
703
|
+
* Checks if the string contains the specified substring.
|
|
704
|
+
*/
|
|
607
705
|
contains?: string;
|
|
706
|
+
/**
|
|
707
|
+
* Checks if the string starts with the specified substring.
|
|
708
|
+
*/
|
|
608
709
|
startsWith?: string;
|
|
710
|
+
/**
|
|
711
|
+
* Checks if the string ends with the specified substring.
|
|
712
|
+
*/
|
|
609
713
|
endsWith?: string;
|
|
610
714
|
/**
|
|
611
|
-
* Not effective for "sqlite" provider
|
|
715
|
+
* Specifies the string comparison mode. Not effective for "sqlite" provider
|
|
612
716
|
*/
|
|
613
717
|
mode?: 'default' | 'insensitive';
|
|
614
718
|
} & (WithAggregations extends true ? {
|
|
719
|
+
/**
|
|
720
|
+
* Filters against the count of records.
|
|
721
|
+
*/
|
|
615
722
|
_count?: NumberFilter<'Int', false, false>;
|
|
723
|
+
/**
|
|
724
|
+
* Filters against the minimum value.
|
|
725
|
+
*/
|
|
616
726
|
_min?: StringFilter<false, false>;
|
|
727
|
+
/**
|
|
728
|
+
* Filters against the maximum value.
|
|
729
|
+
*/
|
|
617
730
|
_max?: StringFilter<false, false>;
|
|
618
731
|
} : {}));
|
|
619
732
|
type NumberFilter<T extends 'Int' | 'Float' | 'Decimal' | 'BigInt', Nullable extends boolean, WithAggregations extends boolean> = NullableIf<number | bigint, Nullable> | (CommonPrimitiveFilter<number, T, Nullable, WithAggregations> & (WithAggregations extends true ? {
|
|
733
|
+
/**
|
|
734
|
+
* Filters against the count of records.
|
|
735
|
+
*/
|
|
620
736
|
_count?: NumberFilter<'Int', false, false>;
|
|
737
|
+
/**
|
|
738
|
+
* Filters against the average value.
|
|
739
|
+
*/
|
|
621
740
|
_avg?: NumberFilter<T, false, false>;
|
|
741
|
+
/**
|
|
742
|
+
* Filters against the sum value.
|
|
743
|
+
*/
|
|
622
744
|
_sum?: NumberFilter<T, false, false>;
|
|
745
|
+
/**
|
|
746
|
+
* Filters against the minimum value.
|
|
747
|
+
*/
|
|
623
748
|
_min?: NumberFilter<T, false, false>;
|
|
749
|
+
/**
|
|
750
|
+
* Filters against the maximum value.
|
|
751
|
+
*/
|
|
624
752
|
_max?: NumberFilter<T, false, false>;
|
|
625
753
|
} : {}));
|
|
626
754
|
type DateTimeFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Date | string, Nullable> | (CommonPrimitiveFilter<Date | string, 'DateTime', Nullable, WithAggregations> & (WithAggregations extends true ? {
|
|
755
|
+
/**
|
|
756
|
+
* Filters against the count of records.
|
|
757
|
+
*/
|
|
627
758
|
_count?: NumberFilter<'Int', false, false>;
|
|
759
|
+
/**
|
|
760
|
+
* Filters against the minimum value.
|
|
761
|
+
*/
|
|
628
762
|
_min?: DateTimeFilter<false, false>;
|
|
763
|
+
/**
|
|
764
|
+
* Filters against the maximum value.
|
|
765
|
+
*/
|
|
629
766
|
_max?: DateTimeFilter<false, false>;
|
|
630
767
|
} : {}));
|
|
631
768
|
type BytesFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Uint8Array | Buffer, Nullable> | ({
|
|
769
|
+
/**
|
|
770
|
+
* Checks for equality with the specified value.
|
|
771
|
+
*/
|
|
632
772
|
equals?: NullableIf<Uint8Array, Nullable>;
|
|
773
|
+
/**
|
|
774
|
+
* Checks if the value is in the specified list of values.
|
|
775
|
+
*/
|
|
633
776
|
in?: Uint8Array[];
|
|
777
|
+
/**
|
|
778
|
+
* Checks if the value is not in the specified list of values.
|
|
779
|
+
*/
|
|
634
780
|
notIn?: Uint8Array[];
|
|
781
|
+
/**
|
|
782
|
+
* Builds a negated filter.
|
|
783
|
+
*/
|
|
635
784
|
not?: BytesFilter<Nullable, WithAggregations>;
|
|
636
785
|
} & (WithAggregations extends true ? {
|
|
786
|
+
/**
|
|
787
|
+
* Filters against the count of records.
|
|
788
|
+
*/
|
|
637
789
|
_count?: NumberFilter<'Int', false, false>;
|
|
790
|
+
/**
|
|
791
|
+
* Filters against the minimum value.
|
|
792
|
+
*/
|
|
638
793
|
_min?: BytesFilter<false, false>;
|
|
794
|
+
/**
|
|
795
|
+
* Filters against the maximum value.
|
|
796
|
+
*/
|
|
639
797
|
_max?: BytesFilter<false, false>;
|
|
640
798
|
} : {}));
|
|
641
799
|
type BooleanFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<boolean, Nullable> | ({
|
|
800
|
+
/**
|
|
801
|
+
* Checks for equality with the specified value.
|
|
802
|
+
*/
|
|
642
803
|
equals?: NullableIf<boolean, Nullable>;
|
|
804
|
+
/**
|
|
805
|
+
* Builds a negated filter.
|
|
806
|
+
*/
|
|
643
807
|
not?: BooleanFilter<Nullable, WithAggregations>;
|
|
644
808
|
} & (WithAggregations extends true ? {
|
|
809
|
+
/**
|
|
810
|
+
* Filters against the count of records.
|
|
811
|
+
*/
|
|
645
812
|
_count?: NumberFilter<'Int', false, false>;
|
|
813
|
+
/**
|
|
814
|
+
* Filters against the minimum value.
|
|
815
|
+
*/
|
|
646
816
|
_min?: BooleanFilter<false, false>;
|
|
817
|
+
/**
|
|
818
|
+
* Filters against the maximum value.
|
|
819
|
+
*/
|
|
647
820
|
_max?: BooleanFilter<false, false>;
|
|
648
821
|
} : {}));
|
|
822
|
+
type JsonFilter = {
|
|
823
|
+
/**
|
|
824
|
+
* JSON path to select the value to filter on. If omitted, the whole JSON value is used.
|
|
825
|
+
*/
|
|
826
|
+
path?: string;
|
|
827
|
+
/**
|
|
828
|
+
* Checks for equality with the specified value.
|
|
829
|
+
*/
|
|
830
|
+
equals?: JsonValue | JsonNullValues;
|
|
831
|
+
/**
|
|
832
|
+
* Builds a negated filter.
|
|
833
|
+
*/
|
|
834
|
+
not?: JsonValue | JsonNullValues;
|
|
835
|
+
/**
|
|
836
|
+
* Checks if the value is a string and contains the specified substring.
|
|
837
|
+
*/
|
|
838
|
+
string_contains?: string;
|
|
839
|
+
/**
|
|
840
|
+
* Checks if the value is a string and starts with the specified substring.
|
|
841
|
+
*/
|
|
842
|
+
string_starts_with?: string;
|
|
843
|
+
/**
|
|
844
|
+
* Checks if the value is a string and ends with the specified substring.
|
|
845
|
+
*/
|
|
846
|
+
string_ends_with?: string;
|
|
847
|
+
/**
|
|
848
|
+
* String comparison mode. Not effective for "sqlite" provider
|
|
849
|
+
*/
|
|
850
|
+
mode?: 'default' | 'insensitive';
|
|
851
|
+
/**
|
|
852
|
+
* Checks if the value is an array and contains the specified value.
|
|
853
|
+
*/
|
|
854
|
+
array_contains?: JsonValue;
|
|
855
|
+
/**
|
|
856
|
+
* Checks if the value is an array and starts with the specified value.
|
|
857
|
+
*/
|
|
858
|
+
array_starts_with?: JsonValue;
|
|
859
|
+
/**
|
|
860
|
+
* Checks if the value is an array and ends with the specified value.
|
|
861
|
+
*/
|
|
862
|
+
array_ends_with?: JsonValue;
|
|
863
|
+
};
|
|
864
|
+
type TypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean> = XOR<JsonFilter, TypedJsonTypedFilter<Schema, TypeDefName, Array, Optional>>;
|
|
865
|
+
type TypedJsonTypedFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean> = (Array extends true ? ArrayTypedJsonFilter<Schema, TypeDefName> : NonArrayTypedJsonFilter<Schema, TypeDefName>) | (Optional extends true ? null : never);
|
|
866
|
+
type ArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
|
|
867
|
+
some?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
868
|
+
every?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
869
|
+
none?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
870
|
+
};
|
|
871
|
+
type NonArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
|
|
872
|
+
is?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
873
|
+
isNot?: TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
874
|
+
} | TypedJsonFieldsFilter<Schema, TypeDefName>;
|
|
875
|
+
type TypedJsonFieldsFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
|
|
876
|
+
[Key in GetTypeDefFields<Schema, TypeDefName>]?: GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetTypeDefs<Schema> ? TypedJsonFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsArray<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>> : TypeDefFieldIsArray<Schema, TypeDefName, Key> extends true ? ArrayFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>> : GetTypeDefFieldType<Schema, TypeDefName, Key> extends GetEnums<Schema> ? EnumFilter<Schema, GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false> : PrimitiveFilter<GetTypeDefFieldType<Schema, TypeDefName, Key>, TypeDefFieldIsOptional<Schema, TypeDefName, Key>, false>;
|
|
877
|
+
};
|
|
649
878
|
type SortOrder = 'asc' | 'desc';
|
|
650
879
|
type NullsOrder = 'first' | 'last';
|
|
651
880
|
type OrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>, WithRelation extends boolean, WithAggregation extends boolean> = {
|
|
652
881
|
[Key in NonRelationFields<Schema, Model>]?: ModelFieldIsOptional<Schema, Model, Key> extends true ? SortOrder | {
|
|
882
|
+
/**
|
|
883
|
+
* Sort order
|
|
884
|
+
*/
|
|
653
885
|
sort: SortOrder;
|
|
886
|
+
/**
|
|
887
|
+
* Treatment of null values
|
|
888
|
+
*/
|
|
654
889
|
nulls?: NullsOrder;
|
|
655
890
|
} : SortOrder;
|
|
656
891
|
} & (WithRelation extends true ? {
|
|
657
892
|
[Key in RelationFields<Schema, Model>]?: FieldIsArray<Schema, Model, Key> extends true ? {
|
|
893
|
+
/**
|
|
894
|
+
* Sorts by the count of related records.
|
|
895
|
+
*/
|
|
658
896
|
_count?: SortOrder;
|
|
659
897
|
} : OrderBy<Schema, RelationFieldType<Schema, Model, Key>, WithRelation, WithAggregation>;
|
|
660
898
|
} : {}) & (WithAggregation extends true ? {
|
|
899
|
+
/**
|
|
900
|
+
* Sorts by the count of records.
|
|
901
|
+
*/
|
|
661
902
|
_count?: OrderBy<Schema, Model, false, false>;
|
|
903
|
+
/**
|
|
904
|
+
* Sorts by the minimum value.
|
|
905
|
+
*/
|
|
662
906
|
_min?: MinMaxInput<Schema, Model, SortOrder>;
|
|
907
|
+
/**
|
|
908
|
+
* Sorts by the maximum value.
|
|
909
|
+
*/
|
|
663
910
|
_max?: MinMaxInput<Schema, Model, SortOrder>;
|
|
664
911
|
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
912
|
+
/**
|
|
913
|
+
* Sorts by the average value.
|
|
914
|
+
*/
|
|
665
915
|
_avg?: SumAvgInput<Schema, Model, SortOrder>;
|
|
916
|
+
/**
|
|
917
|
+
* Sorts by the sum value.
|
|
918
|
+
*/
|
|
666
919
|
_sum?: SumAvgInput<Schema, Model, SortOrder>;
|
|
667
920
|
}) : {});
|
|
668
921
|
type WhereUniqueInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = AtLeast<{
|
|
@@ -674,14 +927,26 @@ type OmitInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
|
674
927
|
[Key in NonRelationFields<Schema, Model>]?: boolean;
|
|
675
928
|
};
|
|
676
929
|
type SelectIncludeOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean, AllowRelation extends boolean = true> = {
|
|
930
|
+
/**
|
|
931
|
+
* Explicitly select fields and relations to be returned by the query.
|
|
932
|
+
*/
|
|
677
933
|
select?: SelectInput<Schema, Model, AllowCount, AllowRelation> | null;
|
|
934
|
+
/**
|
|
935
|
+
* Specifies relations to be included in the query result. All scalar fields are included.
|
|
936
|
+
*/
|
|
678
937
|
include?: IncludeInput<Schema, Model, AllowCount> | null;
|
|
938
|
+
/**
|
|
939
|
+
* Explicitly omit fields from the query result.
|
|
940
|
+
*/
|
|
679
941
|
omit?: OmitInput<Schema, Model> | null;
|
|
680
942
|
};
|
|
681
943
|
type SelectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean = true, AllowRelation extends boolean = true> = {
|
|
682
944
|
[Key in NonRelationFields<Schema, Model>]?: boolean;
|
|
683
945
|
} & (AllowRelation extends true ? IncludeInput<Schema, Model, AllowCount> : {});
|
|
684
946
|
type SelectCount<Schema extends SchemaDef, Model extends GetModels<Schema>> = boolean | {
|
|
947
|
+
/**
|
|
948
|
+
* Selects specific relations to count.
|
|
949
|
+
*/
|
|
685
950
|
select: {
|
|
686
951
|
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]?: boolean | {
|
|
687
952
|
where: WhereInput<Schema, RelationFieldType<Schema, Model, Key>, false>;
|
|
@@ -711,7 +976,13 @@ type ToManyRelationFilter<Schema extends SchemaDef, Model extends GetModels<Sche
|
|
|
711
976
|
none?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
712
977
|
};
|
|
713
978
|
type ToOneRelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>> & {
|
|
979
|
+
/**
|
|
980
|
+
* Checks if the related record matches the specified filter.
|
|
981
|
+
*/
|
|
714
982
|
is?: NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
983
|
+
/**
|
|
984
|
+
* Checks if the related record does not match the specified filter.
|
|
985
|
+
*/
|
|
715
986
|
isNot?: NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
716
987
|
}, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
717
988
|
type RelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? ToManyRelationFilter<Schema, Model, Field> : ToOneRelationFilter<Schema, Model, Field>;
|
|
@@ -722,20 +993,38 @@ type OptionalFieldsForCreate<Schema extends SchemaDef, Model extends GetModels<S
|
|
|
722
993
|
};
|
|
723
994
|
type GetRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'];
|
|
724
995
|
type OppositeRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>> = FT extends GetModels<Schema> ? GetRelation<Schema, Model, Field> extends RelationInfo ? GetRelation<Schema, Model, Field>['opposite'] extends GetModelFields<Schema, FT> ? Schema['models'][FT]['fields'][GetRelation<Schema, Model, Field>['opposite']]['relation'] : never : never : never;
|
|
725
|
-
type OppositeRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Opposite = OppositeRelation<Schema, Model, Field>> = Opposite extends RelationInfo ? (Opposite['fields'] extends string[] ? Opposite['fields'] : []) : [];
|
|
996
|
+
type OppositeRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Opposite = OppositeRelation<Schema, Model, Field>> = Opposite extends RelationInfo ? (Opposite['fields'] extends readonly string[] ? Opposite['fields'] : []) : [];
|
|
726
997
|
type OppositeRelationAndFK<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, FT = FieldType<Schema, Model, Field>, Relation = GetModelField<Schema, Model, Field>['relation'], Opposite = Relation extends RelationInfo ? Relation['opposite'] : never> = FT extends GetModels<Schema> ? Opposite extends GetModelFields<Schema, FT> ? Opposite | OppositeRelationFields<Schema, Model, Field>[number] : never : never;
|
|
727
998
|
type FilterArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
999
|
+
/**
|
|
1000
|
+
* Filter conditions
|
|
1001
|
+
*/
|
|
728
1002
|
where?: WhereInput<Schema, Model>;
|
|
729
1003
|
};
|
|
730
1004
|
type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1005
|
+
/**
|
|
1006
|
+
* Number of records to skip
|
|
1007
|
+
*/
|
|
731
1008
|
skip?: number;
|
|
1009
|
+
/**
|
|
1010
|
+
* Number of records to take
|
|
1011
|
+
*/
|
|
732
1012
|
take?: number;
|
|
1013
|
+
/**
|
|
1014
|
+
* Order by clauses
|
|
1015
|
+
*/
|
|
733
1016
|
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
1017
|
+
/**
|
|
1018
|
+
* Cursor for pagination
|
|
1019
|
+
*/
|
|
734
1020
|
cursor?: WhereUniqueInput<Schema, Model>;
|
|
735
1021
|
};
|
|
736
|
-
type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Collection extends boolean, AllowFilter extends boolean = true> =
|
|
1022
|
+
type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Collection extends boolean, AllowFilter extends boolean = true> = (Collection extends true ? SortAndTakeArgs<Schema, Model> & {
|
|
1023
|
+
/**
|
|
1024
|
+
* Distinct fields
|
|
1025
|
+
*/
|
|
737
1026
|
distinct?: OrArray<NonRelationFields<Schema, Model>>;
|
|
738
|
-
} : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection
|
|
1027
|
+
} : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection>;
|
|
739
1028
|
type FindManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
|
|
740
1029
|
type FindFirstArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
|
|
741
1030
|
type FindUniqueArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
@@ -750,16 +1039,30 @@ type OptionalWrap<Schema extends SchemaDef, Model extends GetModels<Schema>, T e
|
|
|
750
1039
|
type CreateScalarPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
751
1040
|
[Key in ScalarFields<Schema, Model, false> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]: ScalarCreatePayload<Schema, Model, Key>;
|
|
752
1041
|
}>;
|
|
753
|
-
type ScalarCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends ScalarFields<Schema, Model, false>> =
|
|
1042
|
+
type ScalarCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends ScalarFields<Schema, Model, false>> = ScalarFieldMutationPayload<Schema, Model, Field> | (FieldIsArray<Schema, Model, Field> extends true ? {
|
|
754
1043
|
set?: MapModelFieldType<Schema, Model, Field>;
|
|
755
|
-
} : never)
|
|
1044
|
+
} : never);
|
|
1045
|
+
type ScalarFieldMutationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = IsJsonField<Schema, Model, Field> extends true ? ModelFieldIsOptional<Schema, Model, Field> extends true ? JsonValue | JsonNull | DbNull : JsonValue | JsonNull : MapModelFieldType<Schema, Model, Field>;
|
|
1046
|
+
type IsJsonField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelFieldType<Schema, Model, Field> extends 'Json' ? true : false;
|
|
756
1047
|
type CreateFKPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
757
1048
|
[Key in ForeignKeyFields<Schema, Model>]: MapModelFieldType<Schema, Model, Key>;
|
|
758
1049
|
}>;
|
|
759
1050
|
type CreateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
|
|
1051
|
+
/**
|
|
1052
|
+
* Connects or create a related record.
|
|
1053
|
+
*/
|
|
760
1054
|
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
|
|
1055
|
+
/**
|
|
1056
|
+
* Creates a related record.
|
|
1057
|
+
*/
|
|
761
1058
|
create?: NestedCreateInput<Schema, Model, Field>;
|
|
1059
|
+
/**
|
|
1060
|
+
* Creates a batch of related records.
|
|
1061
|
+
*/
|
|
762
1062
|
createMany?: NestedCreateManyInput<Schema, Model, Field>;
|
|
1063
|
+
/**
|
|
1064
|
+
* Connects an existing record.
|
|
1065
|
+
*/
|
|
763
1066
|
connect?: ConnectInput<Schema, Model, Field>;
|
|
764
1067
|
}, (FieldIsArray<Schema, Model, Field> extends true ? never : 'createMany') | (FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' : never)>;
|
|
765
1068
|
type CreateRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
|
|
@@ -771,43 +1074,100 @@ type CreateWithNonOwnedRelationPayload<Schema extends SchemaDef, Model extends G
|
|
|
771
1074
|
[Key in NonOwnedRelationFields<Schema, Model>]: CreateRelationFieldPayload<Schema, Model, Key>;
|
|
772
1075
|
}>;
|
|
773
1076
|
type ConnectOrCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
|
|
1077
|
+
/**
|
|
1078
|
+
* The unique filter to find an existing record to connect.
|
|
1079
|
+
*/
|
|
774
1080
|
where: WhereUniqueInput<Schema, Model>;
|
|
1081
|
+
/**
|
|
1082
|
+
* The data to create a new record if no existing record is found.
|
|
1083
|
+
*/
|
|
775
1084
|
create: CreateInput<Schema, Model, Without>;
|
|
776
1085
|
};
|
|
777
1086
|
type CreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
|
|
1087
|
+
/**
|
|
1088
|
+
* The data for the records to create.
|
|
1089
|
+
*/
|
|
778
1090
|
data: OrArray<Omit<CreateScalarPayload<Schema, Model>, Without> & Omit<CreateFKPayload<Schema, Model>, Without>>;
|
|
1091
|
+
/**
|
|
1092
|
+
* Specifies whether to skip creating records that would violate unique constraints.
|
|
1093
|
+
*/
|
|
779
1094
|
skipDuplicates?: boolean;
|
|
780
1095
|
};
|
|
781
1096
|
type CreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = XOR<Omit<CreateWithFKInput<Schema, Model>, Without>, Omit<CreateWithRelationInput<Schema, Model>, Without>>;
|
|
782
1097
|
type NestedCreateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<CreateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>, FieldIsArray<Schema, Model, Field>>;
|
|
783
1098
|
type NestedCreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = CreateManyInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
784
1099
|
type UpdateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1100
|
+
/**
|
|
1101
|
+
* The data to update the record with.
|
|
1102
|
+
*/
|
|
785
1103
|
data: UpdateInput<Schema, Model>;
|
|
1104
|
+
/**
|
|
1105
|
+
* The unique filter to find the record to update.
|
|
1106
|
+
*/
|
|
786
1107
|
where: WhereUniqueInput<Schema, Model>;
|
|
787
1108
|
} & SelectIncludeOmit<Schema, Model, true>;
|
|
788
1109
|
type UpdateManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = UpdateManyPayload<Schema, Model>;
|
|
789
1110
|
type UpdateManyAndReturnArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = UpdateManyPayload<Schema, Model> & Omit<SelectIncludeOmit<Schema, Model, false, false>, 'include'>;
|
|
790
1111
|
type UpdateManyPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
|
|
1112
|
+
/**
|
|
1113
|
+
* The data to update the records with.
|
|
1114
|
+
*/
|
|
791
1115
|
data: OrArray<UpdateScalarInput<Schema, Model, Without>>;
|
|
1116
|
+
/**
|
|
1117
|
+
* The filter to select records to update.
|
|
1118
|
+
*/
|
|
792
1119
|
where?: WhereInput<Schema, Model>;
|
|
1120
|
+
/**
|
|
1121
|
+
* Limit the number of records to update.
|
|
1122
|
+
*/
|
|
793
1123
|
limit?: number;
|
|
794
1124
|
};
|
|
795
1125
|
type UpsertArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1126
|
+
/**
|
|
1127
|
+
* The data to create the record if it doesn't exist.
|
|
1128
|
+
*/
|
|
796
1129
|
create: CreateInput<Schema, Model>;
|
|
1130
|
+
/**
|
|
1131
|
+
* The data to update the record with if it exists.
|
|
1132
|
+
*/
|
|
797
1133
|
update: UpdateInput<Schema, Model>;
|
|
1134
|
+
/**
|
|
1135
|
+
* The unique filter to find the record to update.
|
|
1136
|
+
*/
|
|
798
1137
|
where: WhereUniqueInput<Schema, Model>;
|
|
799
1138
|
} & SelectIncludeOmit<Schema, Model, true>;
|
|
800
1139
|
type UpdateScalarInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{
|
|
801
1140
|
[Key in NonRelationFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]?: ScalarUpdatePayload<Schema, Model, Key>;
|
|
802
1141
|
}, Without>;
|
|
803
|
-
type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> =
|
|
1142
|
+
type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> = ScalarFieldMutationPayload<Schema, Model, Field> | (Field extends NumericFields<Schema, Model> ? {
|
|
1143
|
+
/**
|
|
1144
|
+
* Sets the field to the specified value.
|
|
1145
|
+
*/
|
|
804
1146
|
set?: NullableIf<number, ModelFieldIsOptional<Schema, Model, Field>>;
|
|
1147
|
+
/**
|
|
1148
|
+
* Increments the field by the specified value.
|
|
1149
|
+
*/
|
|
805
1150
|
increment?: number;
|
|
1151
|
+
/**
|
|
1152
|
+
* Decrements the field by the specified value.
|
|
1153
|
+
*/
|
|
806
1154
|
decrement?: number;
|
|
1155
|
+
/**
|
|
1156
|
+
* Multiplies the field by the specified value.
|
|
1157
|
+
*/
|
|
807
1158
|
multiply?: number;
|
|
1159
|
+
/**
|
|
1160
|
+
* Divides the field by the specified value.
|
|
1161
|
+
*/
|
|
808
1162
|
divide?: number;
|
|
809
1163
|
} : never) | (FieldIsArray<Schema, Model, Field> extends true ? {
|
|
1164
|
+
/**
|
|
1165
|
+
* Sets the field to the specified array.
|
|
1166
|
+
*/
|
|
810
1167
|
set?: MapModelFieldType<Schema, Model, Field>[];
|
|
1168
|
+
/**
|
|
1169
|
+
* Appends the specified values to the array field.
|
|
1170
|
+
*/
|
|
811
1171
|
push?: OrArray<MapModelFieldType<Schema, Model, Field>, true>;
|
|
812
1172
|
} : never);
|
|
813
1173
|
type UpdateRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{
|
|
@@ -816,36 +1176,102 @@ type UpdateRelationInput<Schema extends SchemaDef, Model extends GetModels<Schem
|
|
|
816
1176
|
type UpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = UpdateScalarInput<Schema, Model, Without> & UpdateRelationInput<Schema, Model, Without>;
|
|
817
1177
|
type UpdateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? ToManyRelationUpdateInput<Schema, Model, Field> : ToOneRelationUpdateInput<Schema, Model, Field>;
|
|
818
1178
|
type ToManyRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
|
|
1179
|
+
/**
|
|
1180
|
+
* Creates related records.
|
|
1181
|
+
*/
|
|
819
1182
|
create?: NestedCreateInput<Schema, Model, Field>;
|
|
1183
|
+
/**
|
|
1184
|
+
* Creates a batch of related records.
|
|
1185
|
+
*/
|
|
820
1186
|
createMany?: NestedCreateManyInput<Schema, Model, Field>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Connects existing records.
|
|
1189
|
+
*/
|
|
821
1190
|
connect?: ConnectInput<Schema, Model, Field>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Connects or create related records.
|
|
1193
|
+
*/
|
|
822
1194
|
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
|
|
1195
|
+
/**
|
|
1196
|
+
* Disconnects related records.
|
|
1197
|
+
*/
|
|
823
1198
|
disconnect?: DisconnectInput<Schema, Model, Field>;
|
|
1199
|
+
/**
|
|
1200
|
+
* Updates related records.
|
|
1201
|
+
*/
|
|
824
1202
|
update?: NestedUpdateInput<Schema, Model, Field>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Upserts related records.
|
|
1205
|
+
*/
|
|
825
1206
|
upsert?: NestedUpsertInput<Schema, Model, Field>;
|
|
1207
|
+
/**
|
|
1208
|
+
* Updates a batch of related records.
|
|
1209
|
+
*/
|
|
826
1210
|
updateMany?: NestedUpdateManyInput<Schema, Model, Field>;
|
|
1211
|
+
/**
|
|
1212
|
+
* Deletes related records.
|
|
1213
|
+
*/
|
|
827
1214
|
delete?: NestedDeleteInput<Schema, Model, Field>;
|
|
1215
|
+
/**
|
|
1216
|
+
* Deletes a batch of related records.
|
|
1217
|
+
*/
|
|
828
1218
|
deleteMany?: NestedDeleteManyInput<Schema, Model, Field>;
|
|
1219
|
+
/**
|
|
1220
|
+
* Sets the related records to the specified ones.
|
|
1221
|
+
*/
|
|
829
1222
|
set?: SetRelationInput<Schema, Model, Field>;
|
|
830
1223
|
}, FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' | 'upsert' : never>;
|
|
831
1224
|
type ToOneRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
|
|
1225
|
+
/**
|
|
1226
|
+
* Creates a related record.
|
|
1227
|
+
*/
|
|
832
1228
|
create?: NestedCreateInput<Schema, Model, Field>;
|
|
1229
|
+
/**
|
|
1230
|
+
* Connects an existing record.
|
|
1231
|
+
*/
|
|
833
1232
|
connect?: ConnectInput<Schema, Model, Field>;
|
|
1233
|
+
/**
|
|
1234
|
+
* Connects or create a related record.
|
|
1235
|
+
*/
|
|
834
1236
|
connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
|
|
1237
|
+
/**
|
|
1238
|
+
* Updates the related record.
|
|
1239
|
+
*/
|
|
835
1240
|
update?: NestedUpdateInput<Schema, Model, Field>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Upserts the related record.
|
|
1243
|
+
*/
|
|
836
1244
|
upsert?: NestedUpsertInput<Schema, Model, Field>;
|
|
837
1245
|
} & (ModelFieldIsOptional<Schema, Model, Field> extends true ? {
|
|
1246
|
+
/**
|
|
1247
|
+
* Disconnects the related record.
|
|
1248
|
+
*/
|
|
838
1249
|
disconnect?: DisconnectInput<Schema, Model, Field>;
|
|
1250
|
+
/**
|
|
1251
|
+
* Deletes the related record.
|
|
1252
|
+
*/
|
|
839
1253
|
delete?: NestedDeleteInput<Schema, Model, Field>;
|
|
840
1254
|
} : {}), FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'connectOrCreate' | 'upsert' : never>;
|
|
841
1255
|
type DeleteArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1256
|
+
/**
|
|
1257
|
+
* The unique filter to find the record to delete.
|
|
1258
|
+
*/
|
|
842
1259
|
where: WhereUniqueInput<Schema, Model>;
|
|
843
1260
|
} & SelectIncludeOmit<Schema, Model, true>;
|
|
844
1261
|
type DeleteManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1262
|
+
/**
|
|
1263
|
+
* Filter to select records to delete.
|
|
1264
|
+
*/
|
|
845
1265
|
where?: WhereInput<Schema, Model>;
|
|
1266
|
+
/**
|
|
1267
|
+
* Limits the number of records to delete.
|
|
1268
|
+
*/
|
|
846
1269
|
limit?: number;
|
|
847
1270
|
};
|
|
848
1271
|
type CountArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<FindArgs<Schema, Model, true>, 'select' | 'include' | 'distinct' | 'omit'> & {
|
|
1272
|
+
/**
|
|
1273
|
+
* Selects fields to count
|
|
1274
|
+
*/
|
|
849
1275
|
select?: CountAggregateInput<Schema, Model> | true;
|
|
850
1276
|
};
|
|
851
1277
|
type CountAggregateInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
@@ -859,16 +1285,43 @@ type CountResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Arg
|
|
|
859
1285
|
[Key in keyof S]: number;
|
|
860
1286
|
} : number;
|
|
861
1287
|
type AggregateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1288
|
+
/**
|
|
1289
|
+
* Filter conditions
|
|
1290
|
+
*/
|
|
862
1291
|
where?: WhereInput<Schema, Model>;
|
|
1292
|
+
/**
|
|
1293
|
+
* Number of records to skip for the aggregation
|
|
1294
|
+
*/
|
|
863
1295
|
skip?: number;
|
|
1296
|
+
/**
|
|
1297
|
+
* Number of records to take for the aggregation
|
|
1298
|
+
*/
|
|
864
1299
|
take?: number;
|
|
1300
|
+
/**
|
|
1301
|
+
* Order by clauses
|
|
1302
|
+
*/
|
|
865
1303
|
orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
|
|
866
1304
|
} & {
|
|
1305
|
+
/**
|
|
1306
|
+
* Performs count aggregation.
|
|
1307
|
+
*/
|
|
867
1308
|
_count?: true | CountAggregateInput<Schema, Model>;
|
|
1309
|
+
/**
|
|
1310
|
+
* Performs minimum value aggregation.
|
|
1311
|
+
*/
|
|
868
1312
|
_min?: MinMaxInput<Schema, Model, true>;
|
|
1313
|
+
/**
|
|
1314
|
+
* Performs maximum value aggregation.
|
|
1315
|
+
*/
|
|
869
1316
|
_max?: MinMaxInput<Schema, Model, true>;
|
|
870
1317
|
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1318
|
+
/**
|
|
1319
|
+
* Performs average value aggregation.
|
|
1320
|
+
*/
|
|
871
1321
|
_avg?: SumAvgInput<Schema, Model, true>;
|
|
1322
|
+
/**
|
|
1323
|
+
* Performs sum value aggregation.
|
|
1324
|
+
*/
|
|
872
1325
|
_sum?: SumAvgInput<Schema, Model, true>;
|
|
873
1326
|
});
|
|
874
1327
|
type NumericFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
@@ -883,22 +1336,37 @@ type MinMaxInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Valu
|
|
|
883
1336
|
type AggregateResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Args> = (Args extends {
|
|
884
1337
|
_count: infer Count;
|
|
885
1338
|
} ? {
|
|
1339
|
+
/**
|
|
1340
|
+
* Count aggregation result
|
|
1341
|
+
*/
|
|
886
1342
|
_count: AggCommonOutput<Count>;
|
|
887
1343
|
} : {}) & (Args extends {
|
|
888
1344
|
_sum: infer Sum;
|
|
889
1345
|
} ? {
|
|
1346
|
+
/**
|
|
1347
|
+
* Sum aggregation result
|
|
1348
|
+
*/
|
|
890
1349
|
_sum: AggCommonOutput<Sum>;
|
|
891
1350
|
} : {}) & (Args extends {
|
|
892
1351
|
_avg: infer Avg;
|
|
893
1352
|
} ? {
|
|
1353
|
+
/**
|
|
1354
|
+
* Average aggregation result
|
|
1355
|
+
*/
|
|
894
1356
|
_avg: AggCommonOutput<Avg>;
|
|
895
1357
|
} : {}) & (Args extends {
|
|
896
1358
|
_min: infer Min;
|
|
897
1359
|
} ? {
|
|
1360
|
+
/**
|
|
1361
|
+
* Minimum aggregation result
|
|
1362
|
+
*/
|
|
898
1363
|
_min: AggCommonOutput<Min>;
|
|
899
1364
|
} : {}) & (Args extends {
|
|
900
1365
|
_max: infer Max;
|
|
901
1366
|
} ? {
|
|
1367
|
+
/**
|
|
1368
|
+
* Maximum aggregation result
|
|
1369
|
+
*/
|
|
902
1370
|
_max: AggCommonOutput<Max>;
|
|
903
1371
|
} : {});
|
|
904
1372
|
type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
|
|
@@ -906,17 +1374,50 @@ type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
|
|
|
906
1374
|
} : never;
|
|
907
1375
|
type GroupByHaving<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<WhereInput<Schema, Model, true, true>, '$expr'>;
|
|
908
1376
|
type GroupByArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
|
|
1377
|
+
/**
|
|
1378
|
+
* Filter conditions
|
|
1379
|
+
*/
|
|
909
1380
|
where?: WhereInput<Schema, Model>;
|
|
1381
|
+
/**
|
|
1382
|
+
* Order by clauses
|
|
1383
|
+
*/
|
|
910
1384
|
orderBy?: OrArray<OrderBy<Schema, Model, false, true>>;
|
|
1385
|
+
/**
|
|
1386
|
+
* Fields to group by
|
|
1387
|
+
*/
|
|
911
1388
|
by: NonRelationFields<Schema, Model> | NonEmptyArray<NonRelationFields<Schema, Model>>;
|
|
1389
|
+
/**
|
|
1390
|
+
* Filter conditions for the grouped records
|
|
1391
|
+
*/
|
|
912
1392
|
having?: GroupByHaving<Schema, Model>;
|
|
1393
|
+
/**
|
|
1394
|
+
* Number of records to take for grouping
|
|
1395
|
+
*/
|
|
913
1396
|
take?: number;
|
|
1397
|
+
/**
|
|
1398
|
+
* Number of records to skip for grouping
|
|
1399
|
+
*/
|
|
914
1400
|
skip?: number;
|
|
1401
|
+
/**
|
|
1402
|
+
* Performs count aggregation.
|
|
1403
|
+
*/
|
|
915
1404
|
_count?: true | CountAggregateInput<Schema, Model>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Performs minimum value aggregation.
|
|
1407
|
+
*/
|
|
916
1408
|
_min?: MinMaxInput<Schema, Model, true>;
|
|
1409
|
+
/**
|
|
1410
|
+
* Performs maximum value aggregation.
|
|
1411
|
+
*/
|
|
917
1412
|
_max?: MinMaxInput<Schema, Model, true>;
|
|
918
1413
|
} & (NumericFields<Schema, Model> extends never ? {} : {
|
|
1414
|
+
/**
|
|
1415
|
+
* Performs average value aggregation.
|
|
1416
|
+
*/
|
|
919
1417
|
_avg?: SumAvgInput<Schema, Model, true>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Performs sum value aggregation.
|
|
1420
|
+
*/
|
|
920
1421
|
_sum?: SumAvgInput<Schema, Model, true>;
|
|
921
1422
|
});
|
|
922
1423
|
type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args extends {
|
|
@@ -926,22 +1427,37 @@ type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Ar
|
|
|
926
1427
|
} & (Args extends {
|
|
927
1428
|
_count: infer Count;
|
|
928
1429
|
} ? {
|
|
1430
|
+
/**
|
|
1431
|
+
* Count aggregation result
|
|
1432
|
+
*/
|
|
929
1433
|
_count: AggCommonOutput<Count>;
|
|
930
1434
|
} : {}) & (Args extends {
|
|
931
1435
|
_avg: infer Avg;
|
|
932
1436
|
} ? {
|
|
1437
|
+
/**
|
|
1438
|
+
* Average aggregation result
|
|
1439
|
+
*/
|
|
933
1440
|
_avg: AggCommonOutput<Avg>;
|
|
934
1441
|
} : {}) & (Args extends {
|
|
935
1442
|
_sum: infer Sum;
|
|
936
1443
|
} ? {
|
|
1444
|
+
/**
|
|
1445
|
+
* Sum aggregation result
|
|
1446
|
+
*/
|
|
937
1447
|
_sum: AggCommonOutput<Sum>;
|
|
938
1448
|
} : {}) & (Args extends {
|
|
939
1449
|
_min: infer Min;
|
|
940
1450
|
} ? {
|
|
1451
|
+
/**
|
|
1452
|
+
* Minimum aggregation result
|
|
1453
|
+
*/
|
|
941
1454
|
_min: AggCommonOutput<Min>;
|
|
942
1455
|
} : {}) & (Args extends {
|
|
943
1456
|
_max: infer Max;
|
|
944
1457
|
} ? {
|
|
1458
|
+
/**
|
|
1459
|
+
* Maximum aggregation result
|
|
1460
|
+
*/
|
|
945
1461
|
_max: AggCommonOutput<Max>;
|
|
946
1462
|
} : {})>;
|
|
947
1463
|
type ConnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>> : WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
@@ -949,15 +1465,36 @@ type ConnectOrCreateInput<Schema extends SchemaDef, Model extends GetModels<Sche
|
|
|
949
1465
|
type DisconnectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>, true> : boolean | WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
950
1466
|
type SetRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>>;
|
|
951
1467
|
type NestedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<{
|
|
1468
|
+
/**
|
|
1469
|
+
* Unique filter to select the record to update.
|
|
1470
|
+
*/
|
|
952
1471
|
where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1472
|
+
/**
|
|
1473
|
+
* The data to update the record with.
|
|
1474
|
+
*/
|
|
953
1475
|
data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
954
1476
|
}, true> : XOR<{
|
|
955
|
-
|
|
1477
|
+
/**
|
|
1478
|
+
* Filter to select the record to update.
|
|
1479
|
+
*/
|
|
1480
|
+
where?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1481
|
+
/**
|
|
1482
|
+
* The data to update the record with.
|
|
1483
|
+
*/
|
|
956
1484
|
data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
957
1485
|
}, UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
958
1486
|
type NestedUpsertInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<{
|
|
1487
|
+
/**
|
|
1488
|
+
* Unique filter to select the record to update.
|
|
1489
|
+
*/
|
|
959
1490
|
where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
|
|
1491
|
+
/**
|
|
1492
|
+
* The data to create the record if it doesn't exist.
|
|
1493
|
+
*/
|
|
960
1494
|
create: CreateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
1495
|
+
/**
|
|
1496
|
+
* The data to update the record with if it exists.
|
|
1497
|
+
*/
|
|
961
1498
|
update: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
|
|
962
1499
|
}, FieldIsArray<Schema, Model, Field>>;
|
|
963
1500
|
type NestedUpdateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<UpdateManyPayload<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>>;
|
|
@@ -965,13 +1502,12 @@ type NestedDeleteInput<Schema extends SchemaDef, Model extends GetModels<Schema>
|
|
|
965
1502
|
type NestedDeleteManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, true>>;
|
|
966
1503
|
type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
967
1504
|
[Key in RelationFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends {
|
|
968
|
-
references: unknown[];
|
|
1505
|
+
references: readonly unknown[];
|
|
969
1506
|
} ? never : Key]: true;
|
|
970
1507
|
};
|
|
971
1508
|
type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
|
|
972
1509
|
[Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: true;
|
|
973
1510
|
} extends never ? false : true;
|
|
974
|
-
type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
|
|
975
1511
|
|
|
976
1512
|
/**
|
|
977
1513
|
* A promise that only executes when it's awaited or .then() is called.
|
|
@@ -1769,10 +2305,11 @@ declare function hasModel(schema: SchemaDef, model: string): boolean;
|
|
|
1769
2305
|
declare function getModel(schema: SchemaDef, model: string): ModelDef | undefined;
|
|
1770
2306
|
declare function getTypeDef(schema: SchemaDef, type: string): _zenstackhq_schema.TypeDefDef | undefined;
|
|
1771
2307
|
declare function requireModel(schema: SchemaDef, model: string): ModelDef;
|
|
2308
|
+
declare function requireTypeDef(schema: SchemaDef, type: string): _zenstackhq_schema.TypeDefDef;
|
|
1772
2309
|
declare function getField(schema: SchemaDef, model: string, field: string): FieldDef | undefined;
|
|
1773
2310
|
declare function requireField(schema: SchemaDef, modelOrType: string, field: string): FieldDef;
|
|
1774
|
-
declare function getIdFields<Schema extends SchemaDef>(schema: SchemaDef, model: GetModels<Schema>): string[] | undefined;
|
|
1775
|
-
declare function requireIdFields(schema: SchemaDef, model: string): string[];
|
|
2311
|
+
declare function getIdFields<Schema extends SchemaDef>(schema: SchemaDef, model: GetModels<Schema>): readonly string[] | undefined;
|
|
2312
|
+
declare function requireIdFields(schema: SchemaDef, model: string): readonly string[];
|
|
1776
2313
|
declare function getRelationForeignKeyFieldPairs(schema: SchemaDef, model: string, relationField: string): {
|
|
1777
2314
|
keyPairs: {
|
|
1778
2315
|
fk: string;
|
|
@@ -1795,6 +2332,7 @@ declare function getIdValues(schema: SchemaDef, model: string, data: any): Recor
|
|
|
1795
2332
|
declare function fieldHasDefaultValue(fieldDef: FieldDef): boolean | undefined;
|
|
1796
2333
|
declare function isEnum(schema: SchemaDef, type: string): boolean;
|
|
1797
2334
|
declare function getEnum(schema: SchemaDef, type: string): _zenstackhq_schema.EnumDef | undefined;
|
|
2335
|
+
declare function isTypeDef(schema: SchemaDef, type: string): boolean;
|
|
1798
2336
|
declare function buildJoinPairs(schema: SchemaDef, model: string, modelAlias: string, relationField: string, relationModelAlias: string): [string, string][];
|
|
1799
2337
|
declare function makeDefaultOrderBy<Schema extends SchemaDef>(schema: SchemaDef, model: string): OrderBy<Schema, GetModels<Schema>, true, false>[];
|
|
1800
2338
|
declare function getManyToManyRelation(schema: SchemaDef, model: string, field: string): {
|
|
@@ -1861,13 +2399,15 @@ declare const queryUtils_isForeignKeyField: typeof isForeignKeyField;
|
|
|
1861
2399
|
declare const queryUtils_isInheritedField: typeof isInheritedField;
|
|
1862
2400
|
declare const queryUtils_isRelationField: typeof isRelationField;
|
|
1863
2401
|
declare const queryUtils_isScalarField: typeof isScalarField;
|
|
2402
|
+
declare const queryUtils_isTypeDef: typeof isTypeDef;
|
|
1864
2403
|
declare const queryUtils_makeDefaultOrderBy: typeof makeDefaultOrderBy;
|
|
1865
2404
|
declare const queryUtils_requireField: typeof requireField;
|
|
1866
2405
|
declare const queryUtils_requireIdFields: typeof requireIdFields;
|
|
1867
2406
|
declare const queryUtils_requireModel: typeof requireModel;
|
|
2407
|
+
declare const queryUtils_requireTypeDef: typeof requireTypeDef;
|
|
1868
2408
|
declare const queryUtils_stripAlias: typeof stripAlias;
|
|
1869
2409
|
declare namespace queryUtils {
|
|
1870
|
-
export { queryUtils_aggregate as aggregate, queryUtils_buildJoinPairs as buildJoinPairs, queryUtils_ensureArray as ensureArray, queryUtils_extractFieldName as extractFieldName, queryUtils_extractIdFields as extractIdFields, queryUtils_extractModelName as extractModelName, queryUtils_fieldHasDefaultValue as fieldHasDefaultValue, queryUtils_flattenCompoundUniqueFilters as flattenCompoundUniqueFilters, queryUtils_getDelegateDescendantModels as getDelegateDescendantModels, queryUtils_getDiscriminatorField as getDiscriminatorField, queryUtils_getEnum as getEnum, queryUtils_getField as getField, queryUtils_getIdFields as getIdFields, queryUtils_getIdValues as getIdValues, queryUtils_getManyToManyRelation as getManyToManyRelation, queryUtils_getModel as getModel, queryUtils_getRelationForeignKeyFieldPairs as getRelationForeignKeyFieldPairs, queryUtils_getTypeDef as getTypeDef, queryUtils_getUniqueFields as getUniqueFields, queryUtils_hasModel as hasModel, queryUtils_isEnum as isEnum, queryUtils_isForeignKeyField as isForeignKeyField, queryUtils_isInheritedField as isInheritedField, queryUtils_isRelationField as isRelationField, queryUtils_isScalarField as isScalarField, queryUtils_makeDefaultOrderBy as makeDefaultOrderBy, queryUtils_requireField as requireField, queryUtils_requireIdFields as requireIdFields, queryUtils_requireModel as requireModel, queryUtils_stripAlias as stripAlias };
|
|
2410
|
+
export { queryUtils_aggregate as aggregate, queryUtils_buildJoinPairs as buildJoinPairs, queryUtils_ensureArray as ensureArray, queryUtils_extractFieldName as extractFieldName, queryUtils_extractIdFields as extractIdFields, queryUtils_extractModelName as extractModelName, queryUtils_fieldHasDefaultValue as fieldHasDefaultValue, queryUtils_flattenCompoundUniqueFilters as flattenCompoundUniqueFilters, queryUtils_getDelegateDescendantModels as getDelegateDescendantModels, queryUtils_getDiscriminatorField as getDiscriminatorField, queryUtils_getEnum as getEnum, queryUtils_getField as getField, queryUtils_getIdFields as getIdFields, queryUtils_getIdValues as getIdValues, queryUtils_getManyToManyRelation as getManyToManyRelation, queryUtils_getModel as getModel, queryUtils_getRelationForeignKeyFieldPairs as getRelationForeignKeyFieldPairs, queryUtils_getTypeDef as getTypeDef, queryUtils_getUniqueFields as getUniqueFields, queryUtils_hasModel as hasModel, queryUtils_isEnum as isEnum, queryUtils_isForeignKeyField as isForeignKeyField, queryUtils_isInheritedField as isInheritedField, queryUtils_isRelationField as isRelationField, queryUtils_isScalarField as isScalarField, queryUtils_isTypeDef as isTypeDef, queryUtils_makeDefaultOrderBy as makeDefaultOrderBy, queryUtils_requireField as requireField, queryUtils_requireIdFields as requireIdFields, queryUtils_requireModel as requireModel, queryUtils_requireTypeDef as requireTypeDef, queryUtils_stripAlias as stripAlias };
|
|
1871
2411
|
}
|
|
1872
2412
|
|
|
1873
2413
|
type VisitResult = void | {
|
|
@@ -1904,4 +2444,4 @@ declare namespace schemaUtils {
|
|
|
1904
2444
|
export { schemaUtils_ExpressionVisitor as ExpressionVisitor, schemaUtils_MatchingExpressionVisitor as MatchingExpressionVisitor, type schemaUtils_VisitResult as VisitResult };
|
|
1905
2445
|
}
|
|
1906
2446
|
|
|
1907
|
-
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, type AllModelOperations, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type CoreCrudOperation as CrudOperation, type DateTimeFilter, type DefaultModelResult, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, type JsonArray, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, type ModelOperations, type ModelResult, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitInput, type OmitOptions, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OperationsIneligibleForDelegateModels, type OrderBy, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureFunc, type Procedures, type ProceduresOptions, type ProceedKyselyQueryFunction, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedModelResult, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, definePlugin, getCrudDialect };
|
|
2447
|
+
export { type AfterEntityMutationCallback, type AggregateArgs, type AggregateResult, type AllModelOperations, AnyNull, AnyNullClass, type AuthType, BaseCrudDialect, type BatchResult, type BeforeEntityMutationCallback, type BooleanFilter, type BytesFilter, CRUD, CRUD_EXT, type ClientConstructor, type ClientContract, type ClientOptions, type ComputedFieldsOptions, type CountArgs, type CountResult, type CreateArgs, type CreateInput, type CreateManyAndReturnArgs, type CreateManyArgs, type CreateManyInput, type CoreCrudOperation as CrudOperation, type DateTimeFilter, DbNull, DbNullClass, type DefaultModelResult, type DeleteArgs, type DeleteManyArgs, type EntityMutationHooksDef, type FindArgs, type FindFirstArgs, type FindManyArgs, type FindUniqueArgs, type GroupByArgs, type GroupByResult, type HasComputedFields, type HasProcedures, type IncludeInput, type JsonArray, type JsonFilter, JsonNull, JsonNullClass, type JsonNullValues, type JsonObject, type JsonValue, kyselyUtils as KyselyUtils, type ModelOperations, type ModelResult, type NullsOrder, type NumberFilter, ORMError, ORMErrorReason, type OmitInput, type OmitOptions, type OnKyselyQueryArgs, type OnKyselyQueryCallback, type OperationsIneligibleForDelegateModels, type OrderBy, type PluginAfterEntityMutationArgs, type PluginBeforeEntityMutationArgs, type ProcedureFunc, type Procedures, type ProceduresOptions, type ProceedKyselyQueryFunction, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedModelResult, type SortOrder, type StringFilter, type Subset, type ToKysely, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, definePlugin, getCrudDialect };
|