@zenstackhq/orm 3.0.0-beta.27 → 3.0.0-beta.29

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.d.cts 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, IsDelegateModel, GetModelDiscriminator, GetSubModels, NonRelationFields, GetEnums, GetEnum, GetTypeDefs, GetTypeDefFields, GetTypeDefField, TypeDefFieldIsOptional, RelationFields, FieldIsArray, RelationFieldType, FieldIsRelation, FieldIsDelegateDiscriminator, FieldType, RelationInfo, FieldIsDelegateRelation, Expression as Expression$1, LiteralExpression, ArrayExpression, FieldExpression, MemberExpression, BinaryExpression, UnaryExpression, CallExpression, ThisExpression, NullExpression } from '@zenstackhq/schema';
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): Expression<SqlBool>;
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> = {
@@ -524,19 +562,24 @@ type ProceduresOptions<Schema extends SchemaDef> = Schema extends {
524
562
  type HasProcedures<Schema extends SchemaDef> = Schema extends {
525
563
  procedures: Record<string, ProcedureDef>;
526
564
  } ? true : false;
565
+ /**
566
+ * Subset of client options relevant to query operations.
567
+ */
568
+ type QueryOptions<Schema extends SchemaDef> = Pick<ClientOptions<Schema>, 'omit'>;
569
+ /**
570
+ * Extract QueryOptions from ClientOptions
571
+ */
572
+ type ToQueryOptions<T extends ClientOptions<any>> = Pick<T, 'omit'>;
527
573
 
528
- type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>, Omit = undefined, Optional = false, Array = false> = WrapType<IsDelegateModel<Schema, Model> extends true ? DelegateUnionResult<Schema, Model, Options, GetSubModels<Schema, Model>, Omit> : {
574
+ type DefaultModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Omit = undefined, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<{
529
575
  [Key in NonRelationFields<Schema, Model> as ShouldOmitField<Schema, Model, Options, Key, Omit> extends true ? never : Key]: MapModelFieldType<Schema, Model, Key>;
530
576
  }, Optional, Array>;
531
- 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>;
577
+ type ShouldOmitField<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>, Field extends GetModelFields<Schema, Model>, Omit> = QueryLevelOmit<Schema, Model, Field, Omit> extends boolean ? QueryLevelOmit<Schema, Model, Field, Omit> : OptionsLevelOmit<Schema, Model, Field, Options> extends boolean ? OptionsLevelOmit<Schema, Model, Field, Options> : SchemaLevelOmit<Schema, Model, Field>;
532
578
  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
- 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;
579
+ type OptionsLevelOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>, Options extends QueryOptions<Schema>> = Model extends keyof Options['omit'] ? Field extends keyof Options['omit'][Model] ? Options['omit'][Model][Field] extends boolean ? Options['omit'][Model][Field] : undefined : undefined : undefined;
534
580
  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
- type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>, Select, Omit> = {
539
- [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;
581
+ type ModelSelectResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Select, Omit, Options extends QueryOptions<Schema>> = {
582
+ [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>, Pick<Select[Key], 'select'>, Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Pick<Select[Key], 'include' | 'omit'>, Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : DefaultModelResult<Schema, RelationFieldType<Schema, Model, Key>, Omit, Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : never;
540
583
  };
541
584
  type SelectCountResult<Schema extends SchemaDef, Model extends GetModels<Schema>, C> = C extends true ? {
542
585
  [Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: number;
@@ -545,18 +588,19 @@ type SelectCountResult<Schema extends SchemaDef, Model extends GetModels<Schema>
545
588
  } ? {
546
589
  [Key in keyof S]: number;
547
590
  } : never;
548
- type ModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>, Args = {}, Optional = false, Array = false> = WrapType<Args extends {
591
+ type ModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = WrapType<Args extends {
549
592
  select: infer S;
550
593
  omit?: infer O;
551
- } ? ModelSelectResult<Schema, Model, Options, S, O> : Args extends {
594
+ } ? ModelSelectResult<Schema, Model, S, O, Options> : Args extends {
552
595
  include: infer I;
553
596
  omit?: infer O;
554
- } ? DefaultModelResult<Schema, Model, Options, O> & {
555
- [Key in keyof I & RelationFields<Schema, Model> as I[Key] extends false | undefined ? never : Key]: I[Key] extends FindArgs<Schema, RelationFieldType<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> ? ModelResult<Schema, RelationFieldType<Schema, Model, Key>, Options, I[Key], ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : DefaultModelResult<Schema, RelationFieldType<Schema, Model, Key>, Options, undefined, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>>;
597
+ } ? DefaultModelResult<Schema, Model, O, Options, false, false> & {
598
+ [Key in keyof I & RelationFields<Schema, Model> as I[Key] extends false | undefined ? never : Key]: I[Key] extends FindArgs<Schema, RelationFieldType<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> ? ModelResult<Schema, RelationFieldType<Schema, Model, Key>, I[Key], Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>> : DefaultModelResult<Schema, RelationFieldType<Schema, Model, Key>, undefined, Options, ModelFieldIsOptional<Schema, Model, Key>, FieldIsArray<Schema, Model, Key>>;
556
599
  } : Args extends {
557
600
  omit: infer O;
558
- } ? DefaultModelResult<Schema, Model, Options, O> : DefaultModelResult<Schema, Model, Options>, Optional, Array>;
559
- type SimplifiedModelResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>, Args = {}, Optional = false, Array = false> = Simplify<ModelResult<Schema, Model, Options, Args, Optional, Array>>;
601
+ } ? DefaultModelResult<Schema, Model, O, Options, false, false> : DefaultModelResult<Schema, Model, undefined, Options, false, false>, Optional, Array>;
602
+ type SimplifiedResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>, Optional = false, Array = false> = Simplify<ModelResult<Schema, Model, Args, Options, Optional, Array>>;
603
+ type SimplifiedPlainResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args = {}, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Simplify<ModelResult<Schema, Model, Args, Options, false, false>>;
560
604
  type TypeDefResult<Schema extends SchemaDef, TypeDef extends GetTypeDefs<Schema>, Partial extends boolean = false> = PartialIf<Optional<{
561
605
  [Key in GetTypeDefFields<Schema, TypeDef>]: MapFieldDefType<Schema, GetTypeDefField<Schema, TypeDef, Key>, Partial>;
562
606
  }, Partial extends true ? never : keyof {
@@ -566,7 +610,7 @@ type BatchResult = {
566
610
  count: number;
567
611
  };
568
612
  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>;
613
+ [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
614
  } & {
571
615
  $expr?: (eb: ExpressionBuilder<ToKyselySchema<Schema>, Model>) => OperandExpression<SqlBool>;
572
616
  } & {
@@ -575,94 +619,312 @@ type WhereInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Scala
575
619
  NOT?: OrArray<WhereInput<Schema, Model, ScalarOnly>>;
576
620
  };
577
621
  type EnumFilter<Schema extends SchemaDef, T extends GetEnums<Schema>, Nullable extends boolean, WithAggregations extends boolean> = NullableIf<keyof GetEnum<Schema, T>, Nullable> | ({
622
+ /**
623
+ * Checks for equality with the specified enum value.
624
+ */
578
625
  equals?: NullableIf<keyof GetEnum<Schema, T>, Nullable>;
626
+ /**
627
+ * Checks if the enum value is in the specified list of values.
628
+ */
579
629
  in?: (keyof GetEnum<Schema, T>)[];
630
+ /**
631
+ * Checks if the enum value is not in the specified list of values.
632
+ */
580
633
  notIn?: (keyof GetEnum<Schema, T>)[];
634
+ /**
635
+ * Builds a negated filter.
636
+ */
581
637
  not?: EnumFilter<Schema, T, Nullable, WithAggregations>;
582
638
  } & (WithAggregations extends true ? {
639
+ /**
640
+ * Filters against the count of records.
641
+ */
583
642
  _count?: NumberFilter<'Int', false, false>;
643
+ /**
644
+ * Filters against the minimum value.
645
+ */
584
646
  _min?: EnumFilter<Schema, T, false, false>;
647
+ /**
648
+ * Filters against the maximum value.
649
+ */
585
650
  _max?: EnumFilter<Schema, T, false, false>;
586
651
  } : {}));
587
- type ArrayFilter<Schema extends SchemaDef, T extends string> = {
588
- equals?: MapScalarType<Schema, T>[] | null;
589
- has?: MapScalarType<Schema, T> | null;
590
- hasEvery?: MapScalarType<Schema, T>[];
591
- hasSome?: MapScalarType<Schema, T>[];
652
+ type ArrayFilter<Schema extends SchemaDef, Type extends string> = {
653
+ /**
654
+ * Checks if the array equals the specified array.
655
+ */
656
+ equals?: MapScalarType<Schema, Type>[] | null;
657
+ /**
658
+ * Checks if the array contains all elements of the specified array.
659
+ */
660
+ has?: MapScalarType<Schema, Type> | null;
661
+ /**
662
+ * Checks if the array contains any of the elements of the specified array.
663
+ */
664
+ hasEvery?: MapScalarType<Schema, Type>[];
665
+ /**
666
+ * Checks if the array contains some of the elements of the specified array.
667
+ */
668
+ hasSome?: MapScalarType<Schema, Type>[];
669
+ /**
670
+ * Checks if the array is empty.
671
+ */
592
672
  isEmpty?: boolean;
593
673
  };
594
- type MapScalarType<Schema extends SchemaDef, T extends string> = T extends GetEnums<Schema> ? keyof GetEnum<Schema, T> : MapBaseType$1<T>;
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' ? 'Not implemented yet' : never;
674
+ type MapScalarType<Schema extends SchemaDef, Type extends string> = Type extends GetEnums<Schema> ? keyof GetEnum<Schema, Type> : MapBaseType$1<Type>;
675
+ 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
676
  type CommonPrimitiveFilter<DataType, T extends BuiltinType, Nullable extends boolean, WithAggregations extends boolean> = {
677
+ /**
678
+ * Checks for equality with the specified value.
679
+ */
597
680
  equals?: NullableIf<DataType, Nullable>;
681
+ /**
682
+ * Checks if the value is in the specified list of values.
683
+ */
598
684
  in?: DataType[];
685
+ /**
686
+ * Checks if the value is not in the specified list of values.
687
+ */
599
688
  notIn?: DataType[];
689
+ /**
690
+ * Checks if the value is less than the specified value.
691
+ */
600
692
  lt?: DataType;
693
+ /**
694
+ * Checks if the value is less than or equal to the specified value.
695
+ */
601
696
  lte?: DataType;
697
+ /**
698
+ * Checks if the value is greater than the specified value.
699
+ */
602
700
  gt?: DataType;
701
+ /**
702
+ * Checks if the value is greater than or equal to the specified value.
703
+ */
603
704
  gte?: DataType;
705
+ /**
706
+ * Builds a negated filter.
707
+ */
604
708
  not?: PrimitiveFilter<T, Nullable, WithAggregations>;
605
709
  };
606
710
  type StringFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<string, Nullable> | (CommonPrimitiveFilter<string, 'String', Nullable, WithAggregations> & {
711
+ /**
712
+ * Checks if the string contains the specified substring.
713
+ */
607
714
  contains?: string;
715
+ /**
716
+ * Checks if the string starts with the specified substring.
717
+ */
608
718
  startsWith?: string;
719
+ /**
720
+ * Checks if the string ends with the specified substring.
721
+ */
609
722
  endsWith?: string;
610
723
  /**
611
- * Not effective for "sqlite" provider
724
+ * Specifies the string comparison mode. Not effective for "sqlite" provider
612
725
  */
613
726
  mode?: 'default' | 'insensitive';
614
727
  } & (WithAggregations extends true ? {
728
+ /**
729
+ * Filters against the count of records.
730
+ */
615
731
  _count?: NumberFilter<'Int', false, false>;
732
+ /**
733
+ * Filters against the minimum value.
734
+ */
616
735
  _min?: StringFilter<false, false>;
736
+ /**
737
+ * Filters against the maximum value.
738
+ */
617
739
  _max?: StringFilter<false, false>;
618
740
  } : {}));
619
741
  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 ? {
742
+ /**
743
+ * Filters against the count of records.
744
+ */
620
745
  _count?: NumberFilter<'Int', false, false>;
746
+ /**
747
+ * Filters against the average value.
748
+ */
621
749
  _avg?: NumberFilter<T, false, false>;
750
+ /**
751
+ * Filters against the sum value.
752
+ */
622
753
  _sum?: NumberFilter<T, false, false>;
754
+ /**
755
+ * Filters against the minimum value.
756
+ */
623
757
  _min?: NumberFilter<T, false, false>;
758
+ /**
759
+ * Filters against the maximum value.
760
+ */
624
761
  _max?: NumberFilter<T, false, false>;
625
762
  } : {}));
626
763
  type DateTimeFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Date | string, Nullable> | (CommonPrimitiveFilter<Date | string, 'DateTime', Nullable, WithAggregations> & (WithAggregations extends true ? {
764
+ /**
765
+ * Filters against the count of records.
766
+ */
627
767
  _count?: NumberFilter<'Int', false, false>;
768
+ /**
769
+ * Filters against the minimum value.
770
+ */
628
771
  _min?: DateTimeFilter<false, false>;
772
+ /**
773
+ * Filters against the maximum value.
774
+ */
629
775
  _max?: DateTimeFilter<false, false>;
630
776
  } : {}));
631
777
  type BytesFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<Uint8Array | Buffer, Nullable> | ({
778
+ /**
779
+ * Checks for equality with the specified value.
780
+ */
632
781
  equals?: NullableIf<Uint8Array, Nullable>;
782
+ /**
783
+ * Checks if the value is in the specified list of values.
784
+ */
633
785
  in?: Uint8Array[];
786
+ /**
787
+ * Checks if the value is not in the specified list of values.
788
+ */
634
789
  notIn?: Uint8Array[];
790
+ /**
791
+ * Builds a negated filter.
792
+ */
635
793
  not?: BytesFilter<Nullable, WithAggregations>;
636
794
  } & (WithAggregations extends true ? {
795
+ /**
796
+ * Filters against the count of records.
797
+ */
637
798
  _count?: NumberFilter<'Int', false, false>;
799
+ /**
800
+ * Filters against the minimum value.
801
+ */
638
802
  _min?: BytesFilter<false, false>;
803
+ /**
804
+ * Filters against the maximum value.
805
+ */
639
806
  _max?: BytesFilter<false, false>;
640
807
  } : {}));
641
808
  type BooleanFilter<Nullable extends boolean, WithAggregations extends boolean> = NullableIf<boolean, Nullable> | ({
809
+ /**
810
+ * Checks for equality with the specified value.
811
+ */
642
812
  equals?: NullableIf<boolean, Nullable>;
813
+ /**
814
+ * Builds a negated filter.
815
+ */
643
816
  not?: BooleanFilter<Nullable, WithAggregations>;
644
817
  } & (WithAggregations extends true ? {
818
+ /**
819
+ * Filters against the count of records.
820
+ */
645
821
  _count?: NumberFilter<'Int', false, false>;
822
+ /**
823
+ * Filters against the minimum value.
824
+ */
646
825
  _min?: BooleanFilter<false, false>;
826
+ /**
827
+ * Filters against the maximum value.
828
+ */
647
829
  _max?: BooleanFilter<false, false>;
648
830
  } : {}));
831
+ type JsonFilter = {
832
+ /**
833
+ * JSON path to select the value to filter on. If omitted, the whole JSON value is used.
834
+ */
835
+ path?: string;
836
+ /**
837
+ * Checks for equality with the specified value.
838
+ */
839
+ equals?: JsonValue | JsonNullValues;
840
+ /**
841
+ * Builds a negated filter.
842
+ */
843
+ not?: JsonValue | JsonNullValues;
844
+ /**
845
+ * Checks if the value is a string and contains the specified substring.
846
+ */
847
+ string_contains?: string;
848
+ /**
849
+ * Checks if the value is a string and starts with the specified substring.
850
+ */
851
+ string_starts_with?: string;
852
+ /**
853
+ * Checks if the value is a string and ends with the specified substring.
854
+ */
855
+ string_ends_with?: string;
856
+ /**
857
+ * String comparison mode. Not effective for "sqlite" provider
858
+ */
859
+ mode?: 'default' | 'insensitive';
860
+ /**
861
+ * Checks if the value is an array and contains the specified value.
862
+ */
863
+ array_contains?: JsonValue;
864
+ /**
865
+ * Checks if the value is an array and starts with the specified value.
866
+ */
867
+ array_starts_with?: JsonValue;
868
+ /**
869
+ * Checks if the value is an array and ends with the specified value.
870
+ */
871
+ array_ends_with?: JsonValue;
872
+ };
873
+ type TypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>, Array extends boolean, Optional extends boolean> = XOR<JsonFilter, TypedJsonTypedFilter<Schema, TypeDefName, Array, Optional>>;
874
+ 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);
875
+ type ArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
876
+ some?: TypedJsonFieldsFilter<Schema, TypeDefName>;
877
+ every?: TypedJsonFieldsFilter<Schema, TypeDefName>;
878
+ none?: TypedJsonFieldsFilter<Schema, TypeDefName>;
879
+ };
880
+ type NonArrayTypedJsonFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
881
+ is?: TypedJsonFieldsFilter<Schema, TypeDefName>;
882
+ isNot?: TypedJsonFieldsFilter<Schema, TypeDefName>;
883
+ } | TypedJsonFieldsFilter<Schema, TypeDefName>;
884
+ type TypedJsonFieldsFilter<Schema extends SchemaDef, TypeDefName extends GetTypeDefs<Schema>> = {
885
+ [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>;
886
+ };
649
887
  type SortOrder = 'asc' | 'desc';
650
888
  type NullsOrder = 'first' | 'last';
651
889
  type OrderBy<Schema extends SchemaDef, Model extends GetModels<Schema>, WithRelation extends boolean, WithAggregation extends boolean> = {
652
890
  [Key in NonRelationFields<Schema, Model>]?: ModelFieldIsOptional<Schema, Model, Key> extends true ? SortOrder | {
891
+ /**
892
+ * Sort order
893
+ */
653
894
  sort: SortOrder;
895
+ /**
896
+ * Treatment of null values
897
+ */
654
898
  nulls?: NullsOrder;
655
899
  } : SortOrder;
656
900
  } & (WithRelation extends true ? {
657
901
  [Key in RelationFields<Schema, Model>]?: FieldIsArray<Schema, Model, Key> extends true ? {
902
+ /**
903
+ * Sorts by the count of related records.
904
+ */
658
905
  _count?: SortOrder;
659
906
  } : OrderBy<Schema, RelationFieldType<Schema, Model, Key>, WithRelation, WithAggregation>;
660
907
  } : {}) & (WithAggregation extends true ? {
908
+ /**
909
+ * Sorts by the count of records.
910
+ */
661
911
  _count?: OrderBy<Schema, Model, false, false>;
912
+ /**
913
+ * Sorts by the minimum value.
914
+ */
662
915
  _min?: MinMaxInput<Schema, Model, SortOrder>;
916
+ /**
917
+ * Sorts by the maximum value.
918
+ */
663
919
  _max?: MinMaxInput<Schema, Model, SortOrder>;
664
920
  } & (NumericFields<Schema, Model> extends never ? {} : {
921
+ /**
922
+ * Sorts by the average value.
923
+ */
665
924
  _avg?: SumAvgInput<Schema, Model, SortOrder>;
925
+ /**
926
+ * Sorts by the sum value.
927
+ */
666
928
  _sum?: SumAvgInput<Schema, Model, SortOrder>;
667
929
  }) : {});
668
930
  type WhereUniqueInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = AtLeast<{
@@ -674,14 +936,26 @@ type OmitInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
674
936
  [Key in NonRelationFields<Schema, Model>]?: boolean;
675
937
  };
676
938
  type SelectIncludeOmit<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean, AllowRelation extends boolean = true> = {
939
+ /**
940
+ * Explicitly select fields and relations to be returned by the query.
941
+ */
677
942
  select?: SelectInput<Schema, Model, AllowCount, AllowRelation> | null;
943
+ /**
944
+ * Specifies relations to be included in the query result. All scalar fields are included.
945
+ */
678
946
  include?: IncludeInput<Schema, Model, AllowCount> | null;
947
+ /**
948
+ * Explicitly omit fields from the query result.
949
+ */
679
950
  omit?: OmitInput<Schema, Model> | null;
680
951
  };
681
952
  type SelectInput<Schema extends SchemaDef, Model extends GetModels<Schema>, AllowCount extends boolean = true, AllowRelation extends boolean = true> = {
682
953
  [Key in NonRelationFields<Schema, Model>]?: boolean;
683
954
  } & (AllowRelation extends true ? IncludeInput<Schema, Model, AllowCount> : {});
684
955
  type SelectCount<Schema extends SchemaDef, Model extends GetModels<Schema>> = boolean | {
956
+ /**
957
+ * Selects specific relations to count.
958
+ */
685
959
  select: {
686
960
  [Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]?: boolean | {
687
961
  where: WhereInput<Schema, RelationFieldType<Schema, Model, Key>, false>;
@@ -711,7 +985,13 @@ type ToManyRelationFilter<Schema extends SchemaDef, Model extends GetModels<Sche
711
985
  none?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
712
986
  };
713
987
  type ToOneRelationFilter<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>> & {
988
+ /**
989
+ * Checks if the related record matches the specified filter.
990
+ */
714
991
  is?: NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>>;
992
+ /**
993
+ * Checks if the related record does not match the specified filter.
994
+ */
715
995
  isNot?: NullableIf<WhereInput<Schema, RelationFieldType<Schema, Model, Field>>, ModelFieldIsOptional<Schema, Model, Field>>;
716
996
  }, ModelFieldIsOptional<Schema, Model, Field>>;
717
997
  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 +1002,38 @@ type OptionalFieldsForCreate<Schema extends SchemaDef, Model extends GetModels<S
722
1002
  };
723
1003
  type GetRelation<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelField<Schema, Model, Field>['relation'];
724
1004
  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'] : []) : [];
1005
+ 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
1006
  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
1007
  type FilterArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1008
+ /**
1009
+ * Filter conditions
1010
+ */
728
1011
  where?: WhereInput<Schema, Model>;
729
1012
  };
730
1013
  type SortAndTakeArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1014
+ /**
1015
+ * Number of records to skip
1016
+ */
731
1017
  skip?: number;
1018
+ /**
1019
+ * Number of records to take
1020
+ */
732
1021
  take?: number;
1022
+ /**
1023
+ * Order by clauses
1024
+ */
733
1025
  orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
1026
+ /**
1027
+ * Cursor for pagination
1028
+ */
734
1029
  cursor?: WhereUniqueInput<Schema, Model>;
735
1030
  };
736
- type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Collection extends boolean, AllowFilter extends boolean = true> = ProviderSupportsDistinct<Schema> extends true ? (Collection extends true ? SortAndTakeArgs<Schema, Model> & {
1031
+ type FindArgs<Schema extends SchemaDef, Model extends GetModels<Schema>, Collection extends boolean, AllowFilter extends boolean = true> = (Collection extends true ? SortAndTakeArgs<Schema, Model> & {
1032
+ /**
1033
+ * Distinct fields
1034
+ */
737
1035
  distinct?: OrArray<NonRelationFields<Schema, Model>>;
738
- } : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection> : (Collection extends true ? SortAndTakeArgs<Schema, Model> : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection>;
1036
+ } : {}) & (AllowFilter extends true ? FilterArgs<Schema, Model> : {}) & SelectIncludeOmit<Schema, Model, Collection>;
739
1037
  type FindManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
740
1038
  type FindFirstArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = FindArgs<Schema, Model, true>;
741
1039
  type FindUniqueArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
@@ -750,16 +1048,30 @@ type OptionalWrap<Schema extends SchemaDef, Model extends GetModels<Schema>, T e
750
1048
  type CreateScalarPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
751
1049
  [Key in ScalarFields<Schema, Model, false> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]: ScalarCreatePayload<Schema, Model, Key>;
752
1050
  }>;
753
- type ScalarCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends ScalarFields<Schema, Model, false>> = Simplify<MapModelFieldType<Schema, Model, Field> | (FieldIsArray<Schema, Model, Field> extends true ? {
1051
+ 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
1052
  set?: MapModelFieldType<Schema, Model, Field>;
755
- } : never)>;
1053
+ } : never);
1054
+ 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>;
1055
+ type IsJsonField<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends GetModelFields<Schema, Model>> = GetModelFieldType<Schema, Model, Field> extends 'Json' ? true : false;
756
1056
  type CreateFKPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
757
1057
  [Key in ForeignKeyFields<Schema, Model>]: MapModelFieldType<Schema, Model, Key>;
758
1058
  }>;
759
1059
  type CreateRelationFieldPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
1060
+ /**
1061
+ * Connects or create a related record.
1062
+ */
760
1063
  connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
1064
+ /**
1065
+ * Creates a related record.
1066
+ */
761
1067
  create?: NestedCreateInput<Schema, Model, Field>;
1068
+ /**
1069
+ * Creates a batch of related records.
1070
+ */
762
1071
  createMany?: NestedCreateManyInput<Schema, Model, Field>;
1072
+ /**
1073
+ * Connects an existing record.
1074
+ */
763
1075
  connect?: ConnectInput<Schema, Model, Field>;
764
1076
  }, (FieldIsArray<Schema, Model, Field> extends true ? never : 'createMany') | (FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' : never)>;
765
1077
  type CreateRelationPayload<Schema extends SchemaDef, Model extends GetModels<Schema>> = OptionalWrap<Schema, Model, {
@@ -771,43 +1083,100 @@ type CreateWithNonOwnedRelationPayload<Schema extends SchemaDef, Model extends G
771
1083
  [Key in NonOwnedRelationFields<Schema, Model>]: CreateRelationFieldPayload<Schema, Model, Key>;
772
1084
  }>;
773
1085
  type ConnectOrCreatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
1086
+ /**
1087
+ * The unique filter to find an existing record to connect.
1088
+ */
774
1089
  where: WhereUniqueInput<Schema, Model>;
1090
+ /**
1091
+ * The data to create a new record if no existing record is found.
1092
+ */
775
1093
  create: CreateInput<Schema, Model, Without>;
776
1094
  };
777
1095
  type CreateManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
1096
+ /**
1097
+ * The data for the records to create.
1098
+ */
778
1099
  data: OrArray<Omit<CreateScalarPayload<Schema, Model>, Without> & Omit<CreateFKPayload<Schema, Model>, Without>>;
1100
+ /**
1101
+ * Specifies whether to skip creating records that would violate unique constraints.
1102
+ */
779
1103
  skipDuplicates?: boolean;
780
1104
  };
781
1105
  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
1106
  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
1107
  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
1108
  type UpdateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1109
+ /**
1110
+ * The data to update the record with.
1111
+ */
785
1112
  data: UpdateInput<Schema, Model>;
1113
+ /**
1114
+ * The unique filter to find the record to update.
1115
+ */
786
1116
  where: WhereUniqueInput<Schema, Model>;
787
1117
  } & SelectIncludeOmit<Schema, Model, true>;
788
1118
  type UpdateManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = UpdateManyPayload<Schema, Model>;
789
1119
  type UpdateManyAndReturnArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = UpdateManyPayload<Schema, Model> & Omit<SelectIncludeOmit<Schema, Model, false, false>, 'include'>;
790
1120
  type UpdateManyPayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = {
1121
+ /**
1122
+ * The data to update the records with.
1123
+ */
791
1124
  data: OrArray<UpdateScalarInput<Schema, Model, Without>>;
1125
+ /**
1126
+ * The filter to select records to update.
1127
+ */
792
1128
  where?: WhereInput<Schema, Model>;
1129
+ /**
1130
+ * Limit the number of records to update.
1131
+ */
793
1132
  limit?: number;
794
1133
  };
795
1134
  type UpsertArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1135
+ /**
1136
+ * The data to create the record if it doesn't exist.
1137
+ */
796
1138
  create: CreateInput<Schema, Model>;
1139
+ /**
1140
+ * The data to update the record with if it exists.
1141
+ */
797
1142
  update: UpdateInput<Schema, Model>;
1143
+ /**
1144
+ * The unique filter to find the record to update.
1145
+ */
798
1146
  where: WhereUniqueInput<Schema, Model>;
799
1147
  } & SelectIncludeOmit<Schema, Model, true>;
800
1148
  type UpdateScalarInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{
801
1149
  [Key in NonRelationFields<Schema, Model> as FieldIsDelegateDiscriminator<Schema, Model, Key> extends true ? never : Key]?: ScalarUpdatePayload<Schema, Model, Key>;
802
1150
  }, Without>;
803
- type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> = MapModelFieldType<Schema, Model, Field> | (Field extends NumericFields<Schema, Model> ? {
1151
+ type ScalarUpdatePayload<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends NonRelationFields<Schema, Model>> = ScalarFieldMutationPayload<Schema, Model, Field> | (Field extends NumericFields<Schema, Model> ? {
1152
+ /**
1153
+ * Sets the field to the specified value.
1154
+ */
804
1155
  set?: NullableIf<number, ModelFieldIsOptional<Schema, Model, Field>>;
1156
+ /**
1157
+ * Increments the field by the specified value.
1158
+ */
805
1159
  increment?: number;
1160
+ /**
1161
+ * Decrements the field by the specified value.
1162
+ */
806
1163
  decrement?: number;
1164
+ /**
1165
+ * Multiplies the field by the specified value.
1166
+ */
807
1167
  multiply?: number;
1168
+ /**
1169
+ * Divides the field by the specified value.
1170
+ */
808
1171
  divide?: number;
809
1172
  } : never) | (FieldIsArray<Schema, Model, Field> extends true ? {
1173
+ /**
1174
+ * Sets the field to the specified array.
1175
+ */
810
1176
  set?: MapModelFieldType<Schema, Model, Field>[];
1177
+ /**
1178
+ * Appends the specified values to the array field.
1179
+ */
811
1180
  push?: OrArray<MapModelFieldType<Schema, Model, Field>, true>;
812
1181
  } : never);
813
1182
  type UpdateRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = Omit<{
@@ -816,36 +1185,102 @@ type UpdateRelationInput<Schema extends SchemaDef, Model extends GetModels<Schem
816
1185
  type UpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Without extends string = never> = UpdateScalarInput<Schema, Model, Without> & UpdateRelationInput<Schema, Model, Without>;
817
1186
  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
1187
  type ToManyRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
1188
+ /**
1189
+ * Creates related records.
1190
+ */
819
1191
  create?: NestedCreateInput<Schema, Model, Field>;
1192
+ /**
1193
+ * Creates a batch of related records.
1194
+ */
820
1195
  createMany?: NestedCreateManyInput<Schema, Model, Field>;
1196
+ /**
1197
+ * Connects existing records.
1198
+ */
821
1199
  connect?: ConnectInput<Schema, Model, Field>;
1200
+ /**
1201
+ * Connects or create related records.
1202
+ */
822
1203
  connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
1204
+ /**
1205
+ * Disconnects related records.
1206
+ */
823
1207
  disconnect?: DisconnectInput<Schema, Model, Field>;
1208
+ /**
1209
+ * Updates related records.
1210
+ */
824
1211
  update?: NestedUpdateInput<Schema, Model, Field>;
1212
+ /**
1213
+ * Upserts related records.
1214
+ */
825
1215
  upsert?: NestedUpsertInput<Schema, Model, Field>;
1216
+ /**
1217
+ * Updates a batch of related records.
1218
+ */
826
1219
  updateMany?: NestedUpdateManyInput<Schema, Model, Field>;
1220
+ /**
1221
+ * Deletes related records.
1222
+ */
827
1223
  delete?: NestedDeleteInput<Schema, Model, Field>;
1224
+ /**
1225
+ * Deletes a batch of related records.
1226
+ */
828
1227
  deleteMany?: NestedDeleteManyInput<Schema, Model, Field>;
1228
+ /**
1229
+ * Sets the related records to the specified ones.
1230
+ */
829
1231
  set?: SetRelationInput<Schema, Model, Field>;
830
1232
  }, FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'createMany' | 'connectOrCreate' | 'upsert' : never>;
831
1233
  type ToOneRelationUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = Omit<{
1234
+ /**
1235
+ * Creates a related record.
1236
+ */
832
1237
  create?: NestedCreateInput<Schema, Model, Field>;
1238
+ /**
1239
+ * Connects an existing record.
1240
+ */
833
1241
  connect?: ConnectInput<Schema, Model, Field>;
1242
+ /**
1243
+ * Connects or create a related record.
1244
+ */
834
1245
  connectOrCreate?: ConnectOrCreateInput<Schema, Model, Field>;
1246
+ /**
1247
+ * Updates the related record.
1248
+ */
835
1249
  update?: NestedUpdateInput<Schema, Model, Field>;
1250
+ /**
1251
+ * Upserts the related record.
1252
+ */
836
1253
  upsert?: NestedUpsertInput<Schema, Model, Field>;
837
1254
  } & (ModelFieldIsOptional<Schema, Model, Field> extends true ? {
1255
+ /**
1256
+ * Disconnects the related record.
1257
+ */
838
1258
  disconnect?: DisconnectInput<Schema, Model, Field>;
1259
+ /**
1260
+ * Deletes the related record.
1261
+ */
839
1262
  delete?: NestedDeleteInput<Schema, Model, Field>;
840
1263
  } : {}), FieldIsDelegateRelation<Schema, Model, Field> extends true ? 'create' | 'connectOrCreate' | 'upsert' : never>;
841
1264
  type DeleteArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1265
+ /**
1266
+ * The unique filter to find the record to delete.
1267
+ */
842
1268
  where: WhereUniqueInput<Schema, Model>;
843
1269
  } & SelectIncludeOmit<Schema, Model, true>;
844
1270
  type DeleteManyArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1271
+ /**
1272
+ * Filter to select records to delete.
1273
+ */
845
1274
  where?: WhereInput<Schema, Model>;
1275
+ /**
1276
+ * Limits the number of records to delete.
1277
+ */
846
1278
  limit?: number;
847
1279
  };
848
1280
  type CountArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<FindArgs<Schema, Model, true>, 'select' | 'include' | 'distinct' | 'omit'> & {
1281
+ /**
1282
+ * Selects fields to count
1283
+ */
849
1284
  select?: CountAggregateInput<Schema, Model> | true;
850
1285
  };
851
1286
  type CountAggregateInput<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
@@ -859,16 +1294,43 @@ type CountResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Arg
859
1294
  [Key in keyof S]: number;
860
1295
  } : number;
861
1296
  type AggregateArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1297
+ /**
1298
+ * Filter conditions
1299
+ */
862
1300
  where?: WhereInput<Schema, Model>;
1301
+ /**
1302
+ * Number of records to skip for the aggregation
1303
+ */
863
1304
  skip?: number;
1305
+ /**
1306
+ * Number of records to take for the aggregation
1307
+ */
864
1308
  take?: number;
1309
+ /**
1310
+ * Order by clauses
1311
+ */
865
1312
  orderBy?: OrArray<OrderBy<Schema, Model, true, false>>;
866
1313
  } & {
1314
+ /**
1315
+ * Performs count aggregation.
1316
+ */
867
1317
  _count?: true | CountAggregateInput<Schema, Model>;
1318
+ /**
1319
+ * Performs minimum value aggregation.
1320
+ */
868
1321
  _min?: MinMaxInput<Schema, Model, true>;
1322
+ /**
1323
+ * Performs maximum value aggregation.
1324
+ */
869
1325
  _max?: MinMaxInput<Schema, Model, true>;
870
1326
  } & (NumericFields<Schema, Model> extends never ? {} : {
1327
+ /**
1328
+ * Performs average value aggregation.
1329
+ */
871
1330
  _avg?: SumAvgInput<Schema, Model, true>;
1331
+ /**
1332
+ * Performs sum value aggregation.
1333
+ */
872
1334
  _sum?: SumAvgInput<Schema, Model, true>;
873
1335
  });
874
1336
  type NumericFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
@@ -883,22 +1345,37 @@ type MinMaxInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Valu
883
1345
  type AggregateResult<Schema extends SchemaDef, _Model extends GetModels<Schema>, Args> = (Args extends {
884
1346
  _count: infer Count;
885
1347
  } ? {
1348
+ /**
1349
+ * Count aggregation result
1350
+ */
886
1351
  _count: AggCommonOutput<Count>;
887
1352
  } : {}) & (Args extends {
888
1353
  _sum: infer Sum;
889
1354
  } ? {
1355
+ /**
1356
+ * Sum aggregation result
1357
+ */
890
1358
  _sum: AggCommonOutput<Sum>;
891
1359
  } : {}) & (Args extends {
892
1360
  _avg: infer Avg;
893
1361
  } ? {
1362
+ /**
1363
+ * Average aggregation result
1364
+ */
894
1365
  _avg: AggCommonOutput<Avg>;
895
1366
  } : {}) & (Args extends {
896
1367
  _min: infer Min;
897
1368
  } ? {
1369
+ /**
1370
+ * Minimum aggregation result
1371
+ */
898
1372
  _min: AggCommonOutput<Min>;
899
1373
  } : {}) & (Args extends {
900
1374
  _max: infer Max;
901
1375
  } ? {
1376
+ /**
1377
+ * Maximum aggregation result
1378
+ */
902
1379
  _max: AggCommonOutput<Max>;
903
1380
  } : {});
904
1381
  type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
@@ -906,17 +1383,50 @@ type AggCommonOutput<Input> = Input extends true ? number : Input extends {} ? {
906
1383
  } : never;
907
1384
  type GroupByHaving<Schema extends SchemaDef, Model extends GetModels<Schema>> = Omit<WhereInput<Schema, Model, true, true>, '$expr'>;
908
1385
  type GroupByArgs<Schema extends SchemaDef, Model extends GetModels<Schema>> = {
1386
+ /**
1387
+ * Filter conditions
1388
+ */
909
1389
  where?: WhereInput<Schema, Model>;
1390
+ /**
1391
+ * Order by clauses
1392
+ */
910
1393
  orderBy?: OrArray<OrderBy<Schema, Model, false, true>>;
1394
+ /**
1395
+ * Fields to group by
1396
+ */
911
1397
  by: NonRelationFields<Schema, Model> | NonEmptyArray<NonRelationFields<Schema, Model>>;
1398
+ /**
1399
+ * Filter conditions for the grouped records
1400
+ */
912
1401
  having?: GroupByHaving<Schema, Model>;
1402
+ /**
1403
+ * Number of records to take for grouping
1404
+ */
913
1405
  take?: number;
1406
+ /**
1407
+ * Number of records to skip for grouping
1408
+ */
914
1409
  skip?: number;
1410
+ /**
1411
+ * Performs count aggregation.
1412
+ */
915
1413
  _count?: true | CountAggregateInput<Schema, Model>;
1414
+ /**
1415
+ * Performs minimum value aggregation.
1416
+ */
916
1417
  _min?: MinMaxInput<Schema, Model, true>;
1418
+ /**
1419
+ * Performs maximum value aggregation.
1420
+ */
917
1421
  _max?: MinMaxInput<Schema, Model, true>;
918
1422
  } & (NumericFields<Schema, Model> extends never ? {} : {
1423
+ /**
1424
+ * Performs average value aggregation.
1425
+ */
919
1426
  _avg?: SumAvgInput<Schema, Model, true>;
1427
+ /**
1428
+ * Performs sum value aggregation.
1429
+ */
920
1430
  _sum?: SumAvgInput<Schema, Model, true>;
921
1431
  });
922
1432
  type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Args extends {
@@ -926,22 +1436,37 @@ type GroupByResult<Schema extends SchemaDef, Model extends GetModels<Schema>, Ar
926
1436
  } & (Args extends {
927
1437
  _count: infer Count;
928
1438
  } ? {
1439
+ /**
1440
+ * Count aggregation result
1441
+ */
929
1442
  _count: AggCommonOutput<Count>;
930
1443
  } : {}) & (Args extends {
931
1444
  _avg: infer Avg;
932
1445
  } ? {
1446
+ /**
1447
+ * Average aggregation result
1448
+ */
933
1449
  _avg: AggCommonOutput<Avg>;
934
1450
  } : {}) & (Args extends {
935
1451
  _sum: infer Sum;
936
1452
  } ? {
1453
+ /**
1454
+ * Sum aggregation result
1455
+ */
937
1456
  _sum: AggCommonOutput<Sum>;
938
1457
  } : {}) & (Args extends {
939
1458
  _min: infer Min;
940
1459
  } ? {
1460
+ /**
1461
+ * Minimum aggregation result
1462
+ */
941
1463
  _min: AggCommonOutput<Min>;
942
1464
  } : {}) & (Args extends {
943
1465
  _max: infer Max;
944
1466
  } ? {
1467
+ /**
1468
+ * Maximum aggregation result
1469
+ */
945
1470
  _max: AggCommonOutput<Max>;
946
1471
  } : {})>;
947
1472
  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 +1474,36 @@ type ConnectOrCreateInput<Schema extends SchemaDef, Model extends GetModels<Sche
949
1474
  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
1475
  type SetRelationInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>>;
951
1476
  type NestedUpdateInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = FieldIsArray<Schema, Model, Field> extends true ? OrArray<{
1477
+ /**
1478
+ * Unique filter to select the record to update.
1479
+ */
952
1480
  where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
1481
+ /**
1482
+ * The data to update the record with.
1483
+ */
953
1484
  data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
954
1485
  }, true> : XOR<{
955
- where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
1486
+ /**
1487
+ * Filter to select the record to update.
1488
+ */
1489
+ where?: WhereInput<Schema, RelationFieldType<Schema, Model, Field>>;
1490
+ /**
1491
+ * The data to update the record with.
1492
+ */
956
1493
  data: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
957
1494
  }, UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>>;
958
1495
  type NestedUpsertInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<{
1496
+ /**
1497
+ * Unique filter to select the record to update.
1498
+ */
959
1499
  where: WhereUniqueInput<Schema, RelationFieldType<Schema, Model, Field>>;
1500
+ /**
1501
+ * The data to create the record if it doesn't exist.
1502
+ */
960
1503
  create: CreateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
1504
+ /**
1505
+ * The data to update the record with if it exists.
1506
+ */
961
1507
  update: UpdateInput<Schema, RelationFieldType<Schema, Model, Field>, OppositeRelationAndFK<Schema, Model, Field>>;
962
1508
  }, FieldIsArray<Schema, Model, Field>>;
963
1509
  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 +1511,12 @@ type NestedDeleteInput<Schema extends SchemaDef, Model extends GetModels<Schema>
965
1511
  type NestedDeleteManyInput<Schema extends SchemaDef, Model extends GetModels<Schema>, Field extends RelationFields<Schema, Model>> = OrArray<WhereInput<Schema, RelationFieldType<Schema, Model, Field>, true>>;
966
1512
  type NonOwnedRelationFields<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
967
1513
  [Key in RelationFields<Schema, Model> as GetModelField<Schema, Model, Key>['relation'] extends {
968
- references: unknown[];
1514
+ references: readonly unknown[];
969
1515
  } ? never : Key]: true;
970
1516
  };
971
1517
  type HasToManyRelations<Schema extends SchemaDef, Model extends GetModels<Schema>> = keyof {
972
1518
  [Key in RelationFields<Schema, Model> as FieldIsArray<Schema, Model, Key> extends true ? Key : never]: true;
973
1519
  } extends never ? false : true;
974
- type ProviderSupportsDistinct<Schema extends SchemaDef> = Schema['provider']['type'] extends 'postgresql' ? true : false;
975
1520
 
976
1521
  /**
977
1522
  * A promise that only executes when it's awaited or .then() is called.
@@ -1110,7 +1655,7 @@ type ClientContract<Schema extends SchemaDef, Options extends ClientOptions<Sche
1110
1655
  */
1111
1656
  $pushSchema(): Promise<void>;
1112
1657
  } & {
1113
- [Key in GetModels<Schema> as Uncapitalize<Key>]: ModelOperations<Schema, Key, Options>;
1658
+ [Key in GetModels<Schema> as Uncapitalize<Key>]: ModelOperations<Schema, Key, ToQueryOptions<Options>>;
1114
1659
  } & Procedures<Schema>;
1115
1660
  /**
1116
1661
  * The contract for a client in a transaction.
@@ -1161,7 +1706,7 @@ type CRUD_EXT = CRUD | 'post-update';
1161
1706
  * Extended CRUD operations including 'post-update'.
1162
1707
  */
1163
1708
  declare const CRUD_EXT: readonly ["create", "read", "update", "delete", "post-update"];
1164
- type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema>> = {
1709
+ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema>> = {
1165
1710
  /**
1166
1711
  * Returns a list of entities.
1167
1712
  * @param args - query args
@@ -1243,35 +1788,35 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1243
1788
  * }); // result: `{ _count: { posts: number } }`
1244
1789
  * ```
1245
1790
  */
1246
- findMany<T extends FindManyArgs<Schema, Model>>(args?: SelectSubset<T, FindManyArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>[]>;
1791
+ findMany<T extends FindManyArgs<Schema, Model>>(args?: SelectSubset<T, FindManyArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
1247
1792
  /**
1248
1793
  * Returns a uniquely identified entity.
1249
1794
  * @param args - query args
1250
1795
  * @returns a single entity or null if not found
1251
1796
  * @see {@link findMany}
1252
1797
  */
1253
- findUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T> | null>;
1798
+ findUnique<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
1254
1799
  /**
1255
1800
  * Returns a uniquely identified entity or throws `NotFoundError` if not found.
1256
1801
  * @param args - query args
1257
1802
  * @returns a single entity
1258
1803
  * @see {@link findMany}
1259
1804
  */
1260
- findUniqueOrThrow<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>>;
1805
+ findUniqueOrThrow<T extends FindUniqueArgs<Schema, Model>>(args: SelectSubset<T, FindUniqueArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
1261
1806
  /**
1262
1807
  * Returns the first entity.
1263
1808
  * @param args - query args
1264
1809
  * @returns a single entity or null if not found
1265
1810
  * @see {@link findMany}
1266
1811
  */
1267
- findFirst<T extends FindFirstArgs<Schema, Model>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T> | null>;
1812
+ findFirst<T extends FindFirstArgs<Schema, Model>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options> | null>;
1268
1813
  /**
1269
1814
  * Returns the first entity or throws `NotFoundError` if not found.
1270
1815
  * @param args - query args
1271
1816
  * @returns a single entity
1272
1817
  * @see {@link findMany}
1273
1818
  */
1274
- findFirstOrThrow<T extends FindFirstArgs<Schema, Model>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>>;
1819
+ findFirstOrThrow<T extends FindFirstArgs<Schema, Model>>(args?: SelectSubset<T, FindFirstArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
1275
1820
  /**
1276
1821
  * Creates a new entity.
1277
1822
  * @param args - create args
@@ -1324,7 +1869,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1324
1869
  * });
1325
1870
  * ```
1326
1871
  */
1327
- create<T extends CreateArgs<Schema, Model>>(args: SelectSubset<T, CreateArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>>;
1872
+ create<T extends CreateArgs<Schema, Model>>(args: SelectSubset<T, CreateArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
1328
1873
  /**
1329
1874
  * Creates multiple entities. Only scalar fields are allowed.
1330
1875
  * @param args - create args
@@ -1369,7 +1914,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1369
1914
  * });
1370
1915
  * ```
1371
1916
  */
1372
- createManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(args?: SelectSubset<T, CreateManyAndReturnArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>[]>;
1917
+ createManyAndReturn<T extends CreateManyAndReturnArgs<Schema, Model>>(args?: SelectSubset<T, CreateManyAndReturnArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
1373
1918
  /**
1374
1919
  * Updates a uniquely identified entity.
1375
1920
  * @param args - update args. See {@link findMany} for how to control
@@ -1487,7 +2032,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1487
2032
  * });
1488
2033
  * ```
1489
2034
  */
1490
- update<T extends UpdateArgs<Schema, Model>>(args: SelectSubset<T, UpdateArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>>;
2035
+ update<T extends UpdateArgs<Schema, Model>>(args: SelectSubset<T, UpdateArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
1491
2036
  /**
1492
2037
  * Updates multiple entities.
1493
2038
  * @param args - update args. Only scalar fields are allowed for data.
@@ -1531,7 +2076,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1531
2076
  * });
1532
2077
  * ```
1533
2078
  */
1534
- updateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(args: Subset<T, UpdateManyAndReturnArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>[]>;
2079
+ updateManyAndReturn<T extends UpdateManyAndReturnArgs<Schema, Model>>(args: Subset<T, UpdateManyAndReturnArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>[]>;
1535
2080
  /**
1536
2081
  * Creates or updates an entity.
1537
2082
  * @param args - upsert args
@@ -1552,7 +2097,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1552
2097
  * });
1553
2098
  * ```
1554
2099
  */
1555
- upsert<T extends UpsertArgs<Schema, Model>>(args: SelectSubset<T, UpsertArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>>;
2100
+ upsert<T extends UpsertArgs<Schema, Model>>(args: SelectSubset<T, UpsertArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
1556
2101
  /**
1557
2102
  * Deletes a uniquely identifiable entity.
1558
2103
  * @param args - delete args
@@ -1572,7 +2117,7 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1572
2117
  * }); // result: `{ id: string; email: string }`
1573
2118
  * ```
1574
2119
  */
1575
- delete<T extends DeleteArgs<Schema, Model>>(args: SelectSubset<T, DeleteArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedModelResult<Schema, Model, Options, T>>;
2120
+ delete<T extends DeleteArgs<Schema, Model>>(args: SelectSubset<T, DeleteArgs<Schema, Model>>): ZenStackPromise<Schema, SimplifiedPlainResult<Schema, Model, T, Options>>;
1576
2121
  /**
1577
2122
  * Deletes multiple entities.
1578
2123
  * @param args - delete args
@@ -1666,12 +2211,12 @@ type AllModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema
1666
2211
  groupBy<T extends GroupByArgs<Schema, Model>>(args: Subset<T, GroupByArgs<Schema, Model>>): ZenStackPromise<Schema, Simplify<GroupByResult<Schema, Model, T>>>;
1667
2212
  };
1668
2213
  type OperationsIneligibleForDelegateModels = 'create' | 'createMany' | 'createManyAndReturn' | 'upsert';
1669
- type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends ClientOptions<Schema> = ClientOptions<Schema>> = Omit<AllModelOperations<Schema, Model, Options>, IsDelegateModel<Schema, Model> extends true ? OperationsIneligibleForDelegateModels : never>;
2214
+ type ModelOperations<Schema extends SchemaDef, Model extends GetModels<Schema>, Options extends QueryOptions<Schema> = QueryOptions<Schema>> = Omit<AllModelOperations<Schema, Model, Options>, IsDelegateModel<Schema, Model> extends true ? OperationsIneligibleForDelegateModels : never>;
1670
2215
  /**
1671
2216
  * Type for auth context that includes both scalar and relation fields.
1672
2217
  * Relations are recursively included to allow nested auth data like { user: { profile: { ... } } }
1673
2218
  */
1674
- type AuthModelType<Schema extends SchemaDef, Model extends GetModels<Schema>> = Partial<DefaultModelResult<Schema, Model, ClientOptions<Schema>>> & {
2219
+ type AuthModelType<Schema extends SchemaDef, Model extends GetModels<Schema>> = Partial<DefaultModelResult<Schema, Model>> & {
1675
2220
  [Key in RelationFields<Schema, Model>]?: FieldIsArray<Schema, Model, Key> extends true ? AuthModelType<Schema, RelationFieldType<Schema, Model, Key>>[] : AuthModelType<Schema, RelationFieldType<Schema, Model, Key>>;
1676
2221
  };
1677
2222
  type AuthType<Schema extends SchemaDef> = Schema['authType'] extends GetModels<Schema> ? AuthModelType<Schema, Schema['authType']> : Schema['authType'] extends GetTypeDefs<Schema> ? TypeDefResult<Schema, Schema['authType'], true> : Record<string, unknown>;
@@ -1769,10 +2314,11 @@ declare function hasModel(schema: SchemaDef, model: string): boolean;
1769
2314
  declare function getModel(schema: SchemaDef, model: string): ModelDef | undefined;
1770
2315
  declare function getTypeDef(schema: SchemaDef, type: string): _zenstackhq_schema.TypeDefDef | undefined;
1771
2316
  declare function requireModel(schema: SchemaDef, model: string): ModelDef;
2317
+ declare function requireTypeDef(schema: SchemaDef, type: string): _zenstackhq_schema.TypeDefDef;
1772
2318
  declare function getField(schema: SchemaDef, model: string, field: string): FieldDef | undefined;
1773
2319
  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[];
2320
+ declare function getIdFields<Schema extends SchemaDef>(schema: SchemaDef, model: GetModels<Schema>): readonly string[] | undefined;
2321
+ declare function requireIdFields(schema: SchemaDef, model: string): readonly string[];
1776
2322
  declare function getRelationForeignKeyFieldPairs(schema: SchemaDef, model: string, relationField: string): {
1777
2323
  keyPairs: {
1778
2324
  fk: string;
@@ -1795,6 +2341,7 @@ declare function getIdValues(schema: SchemaDef, model: string, data: any): Recor
1795
2341
  declare function fieldHasDefaultValue(fieldDef: FieldDef): boolean | undefined;
1796
2342
  declare function isEnum(schema: SchemaDef, type: string): boolean;
1797
2343
  declare function getEnum(schema: SchemaDef, type: string): _zenstackhq_schema.EnumDef | undefined;
2344
+ declare function isTypeDef(schema: SchemaDef, type: string): boolean;
1798
2345
  declare function buildJoinPairs(schema: SchemaDef, model: string, modelAlias: string, relationField: string, relationModelAlias: string): [string, string][];
1799
2346
  declare function makeDefaultOrderBy<Schema extends SchemaDef>(schema: SchemaDef, model: string): OrderBy<Schema, GetModels<Schema>, true, false>[];
1800
2347
  declare function getManyToManyRelation(schema: SchemaDef, model: string, field: string): {
@@ -1861,13 +2408,15 @@ declare const queryUtils_isForeignKeyField: typeof isForeignKeyField;
1861
2408
  declare const queryUtils_isInheritedField: typeof isInheritedField;
1862
2409
  declare const queryUtils_isRelationField: typeof isRelationField;
1863
2410
  declare const queryUtils_isScalarField: typeof isScalarField;
2411
+ declare const queryUtils_isTypeDef: typeof isTypeDef;
1864
2412
  declare const queryUtils_makeDefaultOrderBy: typeof makeDefaultOrderBy;
1865
2413
  declare const queryUtils_requireField: typeof requireField;
1866
2414
  declare const queryUtils_requireIdFields: typeof requireIdFields;
1867
2415
  declare const queryUtils_requireModel: typeof requireModel;
2416
+ declare const queryUtils_requireTypeDef: typeof requireTypeDef;
1868
2417
  declare const queryUtils_stripAlias: typeof stripAlias;
1869
2418
  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 };
2419
+ 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
2420
  }
1872
2421
 
1873
2422
  type VisitResult = void | {
@@ -1904,4 +2453,4 @@ declare namespace schemaUtils {
1904
2453
  export { schemaUtils_ExpressionVisitor as ExpressionVisitor, schemaUtils_MatchingExpressionVisitor as MatchingExpressionVisitor, type schemaUtils_VisitResult as VisitResult };
1905
2454
  }
1906
2455
 
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 };
2456
+ 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, type QueryOptions, queryUtils as QueryUtils, RejectedByPolicyReason, type RuntimePlugin, schemaUtils as SchemaUtils, type SelectIncludeOmit, type SelectInput, type SelectSubset, type SimplifiedPlainResult, type SimplifiedResult, type SortOrder, type StringFilter, type Subset, type ToKysely, type ToQueryOptions, type TransactionClientContract, TransactionIsolationLevel, type TypeDefResult, type TypedJsonFilter, type UpdateArgs, type UpdateInput, type UpdateManyAndReturnArgs, type UpdateManyArgs, type UpsertArgs, type WhereInput, type WhereUniqueInput, type ZModelFunction, type ZModelFunctionContext, ZenStackClient, type ZenStackPromise, definePlugin, getCrudDialect };