@mikro-orm/core 7.0.0-dev.33 → 7.0.0-dev.35

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.
@@ -6,172 +6,224 @@ import type { ManyToOneOptions } from '../decorators/ManyToOne.js';
6
6
  import type { OneToManyOptions } from '../decorators/OneToMany.js';
7
7
  import type { OneToOneOptions } from '../decorators/OneToOne.js';
8
8
  import type { ManyToManyOptions } from '../decorators/ManyToMany.js';
9
- import type { AnyString, GeneratedColumnCallback, Constructor, Opt, Hidden, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata } from '../typings.js';
9
+ import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt, Primary, EntityClass } from '../typings.js';
10
10
  import type { Reference, ScalarReference } from './Reference.js';
11
11
  import type { SerializeOptions } from '../serialization/EntitySerializer.js';
12
- import type { Cascade, DeferMode, LoadStrategy, QueryOrderMap } from '../enums.js';
13
- import type { Collection } from './Collection.js';
12
+ import type { Cascade, DeferMode, EventType, LoadStrategy, QueryOrderMap } from '../enums.js';
14
13
  import type { IType, Type } from '../types/Type.js';
15
14
  import { types } from '../types/index.js';
16
15
  import { EntitySchema } from '../metadata/EntitySchema.js';
16
+ import type { Collection } from './Collection.js';
17
+ import type { EventSubscriber } from '../events/EventSubscriber.js';
18
+ export type UniversalPropertyKeys = keyof PropertyOptions<any> | keyof EnumOptions<any> | keyof EmbeddedOptions<any, any> | keyof ReferenceOptions<any, any> | keyof ManyToOneOptions<any, any> | keyof OneToManyOptions<any, any> | keyof OneToOneOptions<any, any> | keyof ManyToManyOptions<any, any>;
19
+ type BuilderExtraKeys = '~options' | '~type' | '$type';
20
+ type ExcludeKeys = 'entity' | 'items';
21
+ type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
22
+ type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> | BuilderExtraKeys;
23
+ type IncludeKeysForEnumOptions = Exclude<keyof EnumOptions<any>, ExcludeKeys> | BuilderExtraKeys;
24
+ type IncludeKeysForEmbeddedOptions = Exclude<keyof EmbeddedOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
25
+ type IncludeKeysForManyToOneOptions = Exclude<keyof ManyToOneOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
26
+ type IncludeKeysForOneToManyOptions = Exclude<keyof OneToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
27
+ type IncludeKeysForOneToOneOptions = Exclude<keyof OneToOneOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
28
+ type IncludeKeysForManyToManyOptions = Exclude<keyof ManyToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
17
29
  /** @internal */
18
- export declare class PropertyOptionsBuilder<Value> {
19
- '~options': PropertyOptions<any>;
30
+ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<Exclude<UniversalPropertyKeys, ExcludeKeys>, any> {
31
+ '~options': Options;
20
32
  '~type'?: {
21
33
  value: Value;
22
34
  };
23
- constructor(options: PropertyOptionsBuilder<Value>['~options']);
35
+ constructor(options: any);
36
+ protected assignOptions(options: EmptyOptions): any;
37
+ /**
38
+ * Set the TypeScript type of the property.
39
+ */
40
+ $type<T>(): UniversalPropertyOptionsBuilder<T, Options, IncludeKeys>;
41
+ /**
42
+ * Set the TypeScript type for custom types that map to objects.
43
+ * This method provides type safety for custom types by specifying the runtime type,
44
+ * raw database value type, and optional serialized type.
45
+ *
46
+ * @template Runtime - The runtime type that the property will have in JavaScript
47
+ * @template Raw - The raw value type as stored in the database
48
+ * @template Serialized - The type when serialized (defaults to Raw)
49
+ * @returns PropertyOptionsBuilder with IType wrapper for type safety
50
+ */
51
+ $type<Runtime, Raw, Serialized = Raw>(): UniversalPropertyOptionsBuilder<IType<Runtime, Raw, Serialized>, Options, IncludeKeys>;
24
52
  /**
25
53
  * Alias for `fieldName`.
26
54
  */
27
- name(name: string): PropertyOptionsBuilder<Value>;
55
+ name(name: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
28
56
  /**
29
57
  * Specify database column name for this property.
30
58
  *
31
59
  * @see https://mikro-orm.io/docs/naming-strategy
32
60
  */
33
- fieldName(fieldName: string): PropertyOptionsBuilder<Value>;
61
+ fieldName(fieldName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
34
62
  /**
35
63
  * Specify database column names for this property.
36
64
  * Same as `fieldName` but for composite FKs.
37
65
  *
38
66
  * @see https://mikro-orm.io/docs/naming-strategy
39
67
  */
40
- fieldNames(...fieldNames: string[]): PropertyOptionsBuilder<Value>;
68
+ fieldNames(...fieldNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
41
69
  /**
42
70
  * Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is only for simple properties represented by a single column. (SQL only)
43
71
  */
44
- columnType(columnType: ColumnType | AnyString): PropertyOptionsBuilder<Value>;
72
+ columnType(columnType: ColumnType | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
45
73
  /**
46
74
  * Specify an exact database column type for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. This option is suitable for composite keys, where one property is represented by multiple columns. (SQL only)
47
75
  */
48
- columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyOptionsBuilder<Value>;
76
+ columnTypes(...columnTypes: (ColumnType | AnyString)[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
49
77
  /**
50
78
  * Explicitly specify the runtime type.
51
79
  *
52
80
  * @see https://mikro-orm.io/docs/metadata-providers
53
81
  * @see https://mikro-orm.io/docs/custom-types
54
82
  */
55
- type<TType extends PropertyValueType>(type: TType): PropertyOptionsBuilder<InferPropertyValueType<TType>>;
83
+ type<TType extends PropertyValueType>(type: TType): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
56
84
  /**
57
85
  * Runtime type of the property. This is the JS type that your property is mapped to, e.g. `string` or `number`, and is normally inferred automatically via `reflect-metadata`.
58
86
  * In some cases, the inference won't work, and you might need to specify the `runtimeType` explicitly - the most common one is when you use a union type with null like `foo: number | null`.
59
87
  */
60
- runtimeType(runtimeType: string): PropertyOptionsBuilder<Value>;
88
+ runtimeType(runtimeType: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
61
89
  /**
62
90
  * Set length of database column, used for datetime/timestamp/varchar column types for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
63
91
  */
64
- length(length: number): PropertyOptionsBuilder<Value>;
92
+ length(length: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
65
93
  /**
66
94
  * Set precision of database column to represent the number of significant digits. (SQL only)
67
95
  */
68
- precision(precision: number): PropertyOptionsBuilder<Value>;
96
+ precision(precision: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
69
97
  /**
70
98
  * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
71
99
  */
72
- scale(scale: number): PropertyOptionsBuilder<Value>;
100
+ scale(scale: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
73
101
  /**
74
102
  * Explicitly specify the auto increment of the primary key.
75
103
  */
76
- autoincrement<T extends boolean = true>(autoincrement?: T): PropertyOptionsBuilder<T extends true ? Opt<Value> : Value>;
104
+ autoincrement<T extends boolean = true>(autoincrement?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
105
+ autoincrement: T;
106
+ }, IncludeKeys>, IncludeKeys>;
77
107
  /**
78
108
  * Add the property to the `returning` statement.
79
109
  */
80
- returning(returning?: boolean): PropertyOptionsBuilder<Value>;
110
+ returning(returning?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
81
111
  /**
82
112
  * Automatically set the property value when entity gets created, executed during flush operation.
83
113
  * @param entity
84
114
  */
85
- onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyOptionsBuilder<Opt<Value>>;
115
+ onCreate(onCreate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
116
+ onCreate: (...args: any[]) => any;
117
+ }, IncludeKeys>, IncludeKeys>;
86
118
  /**
87
119
  * Automatically update the property value every time entity gets updated, executed during flush operation.
88
120
  * @param entity
89
121
  */
90
- onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyOptionsBuilder<Value>;
122
+ onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
91
123
  /**
92
124
  * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
93
125
  * This is a runtime value, assignable to the entity property. (SQL only)
94
126
  */
95
- default(defaultValue: string | string[] | number | number[] | boolean | null): PropertyOptionsBuilder<Opt<Value>>;
127
+ default<T extends string | string[] | number | number[] | boolean | null>(defaultValue: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'default'> & {
128
+ default: T;
129
+ }, IncludeKeys>, IncludeKeys>;
96
130
  /**
97
131
  * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
98
132
  * Since v4 you should use defaultRaw for SQL functions. e.g. now()
99
133
  */
100
- defaultRaw(defaultRaw: string): PropertyOptionsBuilder<Value>;
134
+ defaultRaw(defaultRaw: string): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
135
+ defaultRaw: string;
136
+ }, IncludeKeys>, IncludeKeys>;
101
137
  /**
102
138
  * Set to map some SQL snippet for the entity.
103
139
  *
104
140
  * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
105
141
  */
106
- formula(formula: string | ((alias: string) => string)): PropertyOptionsBuilder<Value>;
142
+ formula<T extends string | ((alias: string) => string)>(formula: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'formula'> & {
143
+ formula: T;
144
+ }, IncludeKeys>, IncludeKeys>;
107
145
  /**
108
146
  * For generated columns. This will be appended to the column type after the `generated always` clause.
109
147
  */
110
- generated(generated: string | GeneratedColumnCallback<any>): PropertyOptionsBuilder<Value>;
148
+ generated(generated: string | GeneratedColumnCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
111
149
  /**
112
150
  * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
113
151
  */
114
- nullable<T extends boolean = true>(nullable?: T): PropertyOptionsBuilder<T extends true ? Value extends ScalarReference<infer InnerValue> ? ScalarReference<InnerValue | null> : Value | null | undefined : NonNullable<Value>>;
152
+ nullable<T extends boolean = true>(nullable?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable'> & {
153
+ nullable: T;
154
+ }, IncludeKeys>, IncludeKeys>;
115
155
  /**
116
156
  * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
117
157
  */
118
- unsigned(unsigned?: boolean): PropertyOptionsBuilder<Value>;
158
+ unsigned(unsigned?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
119
159
  /**
120
160
  * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
121
161
  */
122
- persist(persist?: boolean): PropertyOptionsBuilder<Value>;
162
+ persist<T extends boolean = true>(persist?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
163
+ persist: T;
164
+ }, IncludeKeys>, IncludeKeys>;
123
165
  /**
124
166
  * Set false to disable hydration of this property. Useful for persisted getters.
125
167
  */
126
- hydrate(hydrate?: boolean): PropertyOptionsBuilder<Value>;
168
+ hydrate(hydrate?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
127
169
  /**
128
170
  * Enable `ScalarReference` wrapper for lazy values. Use this in combination with `lazy: true` to have a type-safe accessor object in place of the value.
129
171
  */
130
- ref<T extends boolean = true>(ref?: T): PropertyOptionsBuilder<T extends true ? ScalarReference<Value> : UnwrapRef<Value>>;
172
+ ref<T extends boolean = true>(ref?: T): UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
173
+ ref: T;
174
+ }, IncludeKeys>;
131
175
  /**
132
176
  * Set false to disable change tracking on a property level.
133
177
  *
134
178
  * @see https://mikro-orm.io/docs/unit-of-work#change-tracking-and-performance-considerations
135
179
  */
136
- trackChanges(trackChanges?: boolean): PropertyOptionsBuilder<Value>;
180
+ trackChanges(trackChanges?: boolean): UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>;
137
181
  /**
138
182
  * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
139
183
  */
140
- hidden<T extends boolean = true>(hidden?: T): PropertyOptionsBuilder<T extends true ? Hidden<Value> : Value>;
184
+ hidden<T extends boolean = true>(hidden?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'hidden'> & {
185
+ hidden: T;
186
+ }, IncludeKeys>, IncludeKeys>;
141
187
  /**
142
188
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
143
189
  */
144
- version(version?: boolean): PropertyOptionsBuilder<Value>;
190
+ version<T extends boolean = true>(version?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'version'> & {
191
+ version: T;
192
+ }, IncludeKeys>, IncludeKeys>;
145
193
  /**
146
194
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
147
195
  */
148
- concurrencyCheck(concurrencyCheck?: boolean): PropertyOptionsBuilder<Value>;
196
+ concurrencyCheck(concurrencyCheck?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
149
197
  /**
150
198
  * Explicitly specify index on a property.
151
199
  */
152
- index(index?: boolean | string): PropertyOptionsBuilder<Value>;
200
+ index(index?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
153
201
  /**
154
202
  * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
155
203
  */
156
- unique(unique?: boolean | string): PropertyOptionsBuilder<Value>;
204
+ unique(unique?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
157
205
  /**
158
206
  * Specify column with check constraints. (Postgres driver only)
159
207
  *
160
208
  * @see https://mikro-orm.io/docs/defining-entities#check-constraints
161
209
  */
162
- check(check: string | CheckCallback<any>): PropertyOptionsBuilder<Value>;
210
+ check(check: string | CheckCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
163
211
  /**
164
212
  * Set to omit the property from the select clause for lazy loading.
165
213
  *
166
214
  * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
167
215
  */
168
- lazy<T extends boolean = true>(lazy?: boolean, ref?: T): PropertyOptionsBuilder<T extends true ? ScalarReference<Value> : UnwrapRef<Value>>;
216
+ lazy<T extends boolean = true>(lazy?: boolean, ref?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
217
+ ref: T;
218
+ }, IncludeKeys>, IncludeKeys>;
169
219
  /**
170
220
  * Set true to define entity's unique primary key identifier.
171
221
  *
172
222
  * @see https://mikro-orm.io/docs/decorators#primarykey
173
223
  */
174
- primary(primary?: boolean): PropertyOptionsBuilder<Value>;
224
+ primary<T extends boolean = true>(primary?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'primary'> & {
225
+ primary: T;
226
+ }, IncludeKeys>, IncludeKeys>;
175
227
  /**
176
228
  * Set true to define the properties as setter. (virtual)
177
229
  *
@@ -183,7 +235,7 @@ export declare class PropertyOptionsBuilder<Value> {
183
235
  * }
184
236
  * ```
185
237
  */
186
- setter(setter?: boolean): PropertyOptionsBuilder<Value>;
238
+ setter(setter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
187
239
  /**
188
240
  * Set true to define the properties as getter. (virtual)
189
241
  *
@@ -195,7 +247,7 @@ export declare class PropertyOptionsBuilder<Value> {
195
247
  * }
196
248
  * ```
197
249
  */
198
- getter(getter?: boolean): PropertyOptionsBuilder<Value>;
250
+ getter(getter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
199
251
  /**
200
252
  * When defining a property over a method (not a getter, a regular function), you can use this option to point
201
253
  * to the method name.
@@ -208,330 +260,292 @@ export declare class PropertyOptionsBuilder<Value> {
208
260
  * }
209
261
  * ```
210
262
  */
211
- getterName(getterName: string): PropertyOptionsBuilder<Value>;
263
+ getterName(getterName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
212
264
  /**
213
265
  * Set to define serialized primary key for MongoDB. (virtual)
214
266
  * Alias for `@SerializedPrimaryKey()` decorator.
215
267
  *
216
268
  * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
217
269
  */
218
- serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyOptionsBuilder<Value>;
270
+ serializedPrimaryKey(serializedPrimaryKey?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
219
271
  /**
220
272
  * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
221
273
  *
222
274
  * @see https://mikro-orm.io/docs/serializing#property-serializers
223
275
  */
224
- serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyOptionsBuilder<Value>;
276
+ serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
225
277
  /**
226
278
  * Specify name of key for the serialized value.
227
279
  */
228
- serializedName(serializedName: string): PropertyOptionsBuilder<Value>;
280
+ serializedName(serializedName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
229
281
  /**
230
282
  * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
231
283
  * otherwise only properties with a matching group are included.
232
284
  */
233
- groups(...groups: string[]): PropertyOptionsBuilder<Value>;
285
+ groups(...groups: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
234
286
  /**
235
287
  * Specify a custom order based on the values. (SQL only)
236
288
  */
237
- customOrder(...customOrder: (string[] | number[] | boolean[])): PropertyOptionsBuilder<Value>;
289
+ customOrder(...customOrder: (string[] | number[] | boolean[])): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
238
290
  /**
239
291
  * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
240
292
  */
241
- comment(comment: string): PropertyOptionsBuilder<Value>;
293
+ comment(comment: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
242
294
  /** mysql only */
243
- extra(extra: string): PropertyOptionsBuilder<Value>;
295
+ extra(extra: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
244
296
  /**
245
297
  * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
246
298
  *
247
299
  * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
248
300
  */
249
- ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyOptionsBuilder<Value>;
250
- /**
251
- * Set the TypeScript type of the property.
252
- */
253
- $type<T>(): PropertyOptionsBuilder<T>;
254
- /**
255
- * Set the TypeScript type for custom types that map to objects.
256
- * This method provides type safety for custom types by specifying the runtime type,
257
- * raw database value type, and optional serialized type.
258
- *
259
- * @template Runtime - The runtime type that the property will have in JavaScript
260
- * @template Raw - The raw value type as stored in the database
261
- * @template Serialized - The type when serialized (defaults to Raw)
262
- * @returns PropertyOptionsBuilder with IType wrapper for type safety
263
- */
264
- $type<Runtime, Raw, Serialized = Raw>(): PropertyOptionsBuilder<IType<Runtime, Raw, Serialized>>;
265
- }
266
- /** @internal */
267
- export declare class EnumOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
268
- '~options': {
269
- enum: true;
270
- } & EnumOptions<any>;
271
- constructor(options: EnumOptionsBuilder<Value>['~options']);
272
- array<T extends boolean = true>(array?: T): EnumOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
301
+ ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
302
+ array<T extends boolean = true>(array?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'array'> & {
303
+ array: T;
304
+ }, IncludeKeys>, IncludeKeys>;
273
305
  /** for postgres, by default it uses text column with check constraint */
274
- nativeEnumName(nativeEnumName: string): EnumOptionsBuilder<Value>;
275
- }
276
- /** @internal */
277
- export declare class EmbeddedOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
278
- '~options': ({
279
- kind: 'embedded';
280
- entity: () => EntitySchema<any, any> | EntitySchema<any, any>[];
281
- } & EmbeddedOptions<any, any> & PropertyOptions<any>);
282
- constructor(options: EmbeddedOptionsBuilder<Value>['~options']);
283
- prefix(prefix: string): EmbeddedOptionsBuilder<Value>;
284
- prefixMode(prefixMode: EmbeddedPrefixMode): EmbeddedOptionsBuilder<Value>;
285
- object(object?: boolean): EmbeddedOptionsBuilder<Value>;
286
- array<T extends boolean = true>(array?: T): EmbeddedOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
287
- }
288
- /** @internal */
289
- export declare class ReferenceOptionsBuilder<Value extends object> extends PropertyOptionsBuilder<Value> {
290
- '~options': ReferenceOptions<any, any>;
291
- constructor(options: ReferenceOptionsBuilder<Value>['~options']);
306
+ nativeEnumName(nativeEnumName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
307
+ prefix(prefix: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
308
+ prefixMode(prefixMode: EmbeddedPrefixMode): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
309
+ object(object?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
292
310
  /** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
293
- cascade(...cascade: Cascade[]): ReferenceOptionsBuilder<Value>;
311
+ cascade(...cascade: Cascade[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
294
312
  /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
295
- eager(eager?: boolean): ReferenceOptionsBuilder<Value>;
313
+ eager(eager?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
296
314
  /** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
297
- strategy(strategy: LoadStrategy | `${LoadStrategy}`): ReferenceOptionsBuilder<Value>;
298
- /**
299
- * @internal
300
- * re-declare to override type inference
301
- */
302
- ref(ref?: boolean): ReferenceOptionsBuilder<any>;
303
- /**
304
- * @internal
305
- * re-declare to override type inference
306
- */
307
- primary(primary?: boolean): ReferenceOptionsBuilder<any>;
308
- }
309
- /** @internal */
310
- export declare class ManyToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
311
- '~options': ({
312
- kind: 'm:n';
313
- entity: () => EntitySchema<any, any>;
314
- } & ManyToManyOptions<any, UnwrapCollection<TargetValue>>);
315
- constructor(options: ManyToManyOptionsBuilder<TargetValue>['~options']);
315
+ strategy(strategy: LoadStrategy | `${LoadStrategy}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
316
316
  /** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
317
- owner(owner?: boolean): ManyToManyOptionsBuilder<TargetValue>;
317
+ owner(owner?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
318
318
  /** Point to the inverse side property name. */
319
- inversedBy(inversedBy: (string & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): ManyToManyOptionsBuilder<TargetValue>;
319
+ inversedBy(inversedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
320
320
  /** Point to the owning side property name. */
321
- mappedBy(mappedBy: string | ((e: any) => any)): ManyToManyOptionsBuilder<TargetValue>;
321
+ mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
322
322
  /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
323
- where(...where: FilterQuery<object>[]): ManyToManyOptionsBuilder<TargetValue>;
323
+ where(...where: FilterQuery<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
324
324
  /** Set default ordering. */
325
- orderBy(...orderBy: QueryOrderMap<object>[]): ManyToManyOptionsBuilder<TargetValue>;
325
+ orderBy(...orderBy: QueryOrderMap<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
326
326
  /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
327
- fixedOrder(fixedOrder?: boolean): ManyToManyOptionsBuilder<TargetValue>;
327
+ fixedOrder(fixedOrder?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
328
328
  /** Override default order column name (`id`) for fixed ordering. */
329
- fixedOrderColumn(fixedOrderColumn: string): ManyToManyOptionsBuilder<TargetValue>;
329
+ fixedOrderColumn(fixedOrderColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
330
330
  /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
331
- pivotTable(pivotTable: string): ManyToManyOptionsBuilder<TargetValue>;
331
+ pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
332
332
  /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
333
- pivotEntity(pivotEntity: string | (() => EntityName<any>)): ManyToManyOptionsBuilder<TargetValue>;
333
+ pivotEntity(pivotEntity: string | (() => EntityName<any>)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
334
334
  /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
335
- joinColumn(joinColumn: string): ManyToManyOptionsBuilder<TargetValue>;
335
+ joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
336
336
  /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
337
- joinColumns(...joinColumns: string[]): ManyToManyOptionsBuilder<TargetValue>;
337
+ joinColumns(...joinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
338
338
  /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
339
- inverseJoinColumn(inverseJoinColumn: string): ManyToManyOptionsBuilder<TargetValue>;
339
+ inverseJoinColumn(inverseJoinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
340
340
  /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
341
- inverseJoinColumns(...inverseJoinColumns: string[]): ManyToManyOptionsBuilder<TargetValue>;
341
+ inverseJoinColumns(...inverseJoinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
342
342
  /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
343
- referenceColumnName(referenceColumnName: string): ManyToManyOptionsBuilder<TargetValue>;
343
+ referenceColumnName(referenceColumnName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
344
344
  /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
345
- referencedColumnNames(...referencedColumnNames: string[]): ManyToManyOptionsBuilder<TargetValue>;
345
+ referencedColumnNames(...referencedColumnNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
346
346
  /** What to do when the target entity gets deleted. */
347
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToManyOptionsBuilder<TargetValue>;
347
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
348
348
  /** What to do when the reference to the target entity gets updated. */
349
- updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToManyOptionsBuilder<TargetValue>;
350
- }
351
- /** @internal */
352
- export declare class ManyToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
353
- '~options': ({
354
- kind: 'm:1';
355
- entity: () => EntitySchema<any, any>;
356
- } & ManyToOneOptions<any, UnwrapRef<TargetValue>>);
357
- constructor(options: ManyToOneOptionsBuilder<TargetValue>['~options']);
358
- /** Point to the inverse side property name. */
359
- inversedBy(inversedBy: (string & keyof UnwrapRef<TargetValue>) | ((e: UnwrapRef<TargetValue>) => any)): ManyToOneOptionsBuilder<TargetValue>;
360
- /** Wrap the entity in {@apilink Reference} wrapper. */
361
- ref<T extends boolean = true>(ref?: T): ManyToOneOptionsBuilder<T extends true ? Reference<TargetValue> : UnwrapRef<TargetValue>>;
362
- /** Use this relation as a primary key. */
363
- primary(primary?: boolean): ManyToOneOptionsBuilder<TargetValue>;
349
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
364
350
  /** Map this relation to the primary key value instead of an entity. */
365
- mapToPk(mapToPk?: boolean): ManyToOneOptionsBuilder<TargetValue>;
366
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
367
- joinColumn(joinColumn: string): ManyToOneOptionsBuilder<TargetValue>;
368
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
369
- joinColumns(...joinColumns: string[]): ManyToOneOptionsBuilder<TargetValue>;
370
- /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
371
- ownColumns(...ownColumns: string[]): ManyToOneOptionsBuilder<TargetValue>;
372
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
373
- referenceColumnName(referenceColumnName: string): ManyToOneOptionsBuilder<TargetValue>;
374
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
375
- referencedColumnNames(...referencedColumnNames: string[]): ManyToOneOptionsBuilder<TargetValue>;
376
- /** What to do when the target entity gets deleted. */
377
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
378
- /** What to do when the reference to the target entity gets updated. */
379
- updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
351
+ mapToPk<T extends boolean = true>(mapToPk?: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'mapToPk'> & {
352
+ mapToPk: T;
353
+ }, IncludeKeys>, IncludeKeys>;
380
354
  /** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
381
- deferMode(deferMode: DeferMode | `${DeferMode}`): ManyToOneOptionsBuilder<TargetValue>;
382
- }
383
- /** @internal */
384
- export declare class OneToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
385
- '~options': ({
386
- kind: '1:m';
387
- entity: () => EntitySchema<TargetValue>;
388
- } & OneToManyOptions<any, UnwrapCollection<TargetValue>>);
389
- constructor(options: OneToManyOptionsBuilder<TargetValue>['~options']);
355
+ deferMode(deferMode: DeferMode | `${DeferMode}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
356
+ /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
357
+ ownColumns(...ownColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
358
+ /** Enable/disable foreign key constraint creation on this relation */
359
+ createForeignKeyConstraint(createForeignKeyConstraint?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
360
+ /** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
361
+ foreignKeyName(foreignKeyName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
390
362
  /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
391
- orphanRemoval(orphanRemoval?: boolean): OneToManyOptionsBuilder<TargetValue>;
392
- /** Set default ordering. */
393
- orderBy(orderBy: QueryOrderMap<UnwrapCollection<TargetValue>> | QueryOrderMap<UnwrapCollection<TargetValue>>[]): OneToManyOptionsBuilder<TargetValue>;
394
- /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
395
- where(where: FilterQuery<UnwrapCollection<TargetValue>>): OneToManyOptionsBuilder<TargetValue>;
396
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
397
- joinColumn(joinColumn: string): OneToManyOptionsBuilder<TargetValue>;
398
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
399
- joinColumns(...joinColumns: string[]): OneToManyOptionsBuilder<TargetValue>;
400
- /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
401
- inverseJoinColumn(inverseJoinColumn: string): OneToManyOptionsBuilder<TargetValue>;
402
- /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
403
- inverseJoinColumns(...inverseJoinColumns: string[]): OneToManyOptionsBuilder<TargetValue>;
404
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
405
- referenceColumnName(referenceColumnName: string): OneToManyOptionsBuilder<TargetValue>;
406
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
407
- referencedColumnNames(...referencedColumnNames: string[]): OneToManyOptionsBuilder<TargetValue>;
363
+ orphanRemoval(orphanRemoval?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
408
364
  }
409
- /** @internal */
410
- export declare class OneToManyOptionsBuilderOnlyMappedBy<TargetValue extends object> {
411
- '~options': ({
412
- kind: '1:m';
413
- entity: () => EntitySchema<TargetValue>;
414
- } & Omit<OneToManyOptions<any, UnwrapCollection<TargetValue>>, 'mappedBy'>);
415
- constructor(options: OneToManyOptionsBuilderOnlyMappedBy<TargetValue>['~options']);
416
- /** Point to the owning side property name. */
417
- mappedBy(mappedBy: (AnyString & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): OneToManyOptionsBuilder<TargetValue>;
365
+ export interface EmptyOptions extends Partial<Record<UniversalPropertyKeys, unknown>> {
418
366
  }
419
367
  /** @internal */
420
- export declare class OneToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
421
- '~options': ({
422
- kind: '1:1';
423
- entity: () => EntitySchema<any, any>;
424
- } & OneToOneOptions<any, UnwrapRef<TargetValue>>);
425
- constructor(options: OneToOneOptionsBuilder<TargetValue>['~options']);
426
- /** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
427
- owner(owner?: boolean): OneToOneOptionsBuilder<TargetValue>;
428
- /** Point to the inverse side property name. */
429
- inversedBy(inversedBy: (string & keyof UnwrapRef<TargetValue>) | ((e: UnwrapRef<TargetValue>) => any)): OneToOneOptionsBuilder<TargetValue>;
430
- /** Wrap the entity in {@apilink Reference} wrapper. */
431
- ref<T extends boolean = true>(ref?: T): OneToOneOptionsBuilder<T extends true ? Reference<TargetValue> : UnwrapRef<TargetValue>>;
432
- /** Use this relation as a primary key. */
433
- primary(primary?: boolean): OneToOneOptionsBuilder<TargetValue>;
434
- /** Map this relation to the primary key value instead of an entity. */
435
- mapToPk(mapToPk?: boolean): OneToOneOptionsBuilder<TargetValue>;
436
- /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
437
- ownColumns(...ownColumns: string[]): OneToOneOptionsBuilder<TargetValue>;
438
- /** What to do when the target entity gets deleted. */
439
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
440
- /** What to do when the reference to the target entity gets updated. */
441
- updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
442
- /** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
443
- deferMode(deferMode: DeferMode | `${DeferMode}`): OneToOneOptionsBuilder<TargetValue>;
368
+ export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
369
+ kind: '1:m';
370
+ }, IncludeKeysForOneToManyOptions> {
371
+ /** Point to the owning side property name. */
372
+ mappedBy(mappedBy: (AnyString & keyof Value) | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
373
+ kind: '1:m';
374
+ }, IncludeKeysForOneToManyOptions>, IncludeKeysForOneToManyOptions>;
444
375
  }
445
376
  declare const propertyBuilders: {
446
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
447
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
448
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
449
- json: <T>() => PropertyOptionsBuilder<T>;
450
- formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
451
- type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
452
- enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => EnumOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T>;
453
- embedded: <Target extends EntitySchema<any, any> | EntitySchema<any, any>[]>(target: Target) => EmbeddedOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>>;
454
- manyToMany: <Target extends EntitySchema<any, any>>(target: Target) => ManyToManyOptionsBuilder<Collection<InferEntity<Target>, object>>;
455
- manyToOne: <Target extends EntitySchema<any, any>>(target: Target) => ManyToOneOptionsBuilder<Reference<InferEntity<Target>>>;
456
- oneToMany: <Target extends EntitySchema<any, any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<Collection<InferEntity<Target>, object>>;
457
- oneToOne: <Target extends EntitySchema<any, any>>(target: Target) => OneToOneOptionsBuilder<Reference<InferEntity<Target>>>;
458
- date: () => PropertyOptionsBuilder<string>;
459
- time: () => PropertyOptionsBuilder<any>;
460
- datetime: () => PropertyOptionsBuilder<Date>;
461
- blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
462
- uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
463
- enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
464
- integer: () => PropertyOptionsBuilder<number>;
465
- smallint: () => PropertyOptionsBuilder<number>;
466
- tinyint: () => PropertyOptionsBuilder<number>;
467
- mediumint: () => PropertyOptionsBuilder<number>;
468
- float: () => PropertyOptionsBuilder<number>;
469
- double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
470
- boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
471
- character: () => PropertyOptionsBuilder<string>;
472
- string: () => PropertyOptionsBuilder<string>;
473
- uuid: () => PropertyOptionsBuilder<string>;
474
- text: () => PropertyOptionsBuilder<string>;
475
- interval: () => PropertyOptionsBuilder<string>;
476
- unknown: () => PropertyOptionsBuilder<{}>;
377
+ bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
378
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
379
+ decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
380
+ json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
381
+ formula: <T>(formula: string | ((alias: string) => string)) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
382
+ datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
383
+ time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
384
+ type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
385
+ enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
386
+ embedded: <Target extends EntitySchema<any, any> | EntityClass<any> | EntitySchema<any, any>[] | EntityClass<any>[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
387
+ manyToMany: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
388
+ kind: "m:n";
389
+ }, IncludeKeysForManyToManyOptions>;
390
+ manyToOne: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
391
+ kind: "m:1";
392
+ }, IncludeKeysForManyToOneOptions>;
393
+ oneToMany: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
394
+ oneToOne: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
395
+ kind: "1:1";
396
+ }, IncludeKeysForOneToOneOptions>;
397
+ date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
398
+ blob: () => UniversalPropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
399
+ uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
400
+ enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
401
+ integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
402
+ smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
403
+ tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
404
+ mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
405
+ float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
406
+ double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
407
+ boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
408
+ character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
409
+ string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
410
+ uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
411
+ text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
412
+ interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
413
+ unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
477
414
  };
478
- export declare function defineEntity<Properties extends Record<string, any>>(meta: Omit<Partial<EntityMetadata<InferEntityFromProperties<Properties>>>, 'properties' | 'extends'> & {
415
+ export declare function defineEntity<Properties extends Record<string, any>, const PK extends (keyof Properties)[] | undefined = undefined, Base = never>(meta: Omit<Partial<EntityMetadata<InferEntityFromProperties<Properties, PK>>>, 'properties' | 'extends' | 'primaryKeys' | 'hooks'> & {
479
416
  name: string;
417
+ extends?: string | EntitySchema<Base>;
480
418
  properties: Properties | ((properties: typeof propertyBuilders) => Properties);
481
- }): EntitySchema<InferEntityFromProperties<Properties>, never>;
419
+ primaryKeys?: PK & InferPrimaryKey<Properties>[];
420
+ hooks?: DefineEntityHooks<InferEntityFromProperties<Properties, PK>>;
421
+ }): EntitySchema<InferEntityFromProperties<Properties, PK>, Base>;
422
+ export declare function defineEntity<Entity = any, Base = never>(meta: Omit<Partial<EntityMetadata<Entity>>, 'properties'> & {
423
+ class: EntityClass<Entity>;
424
+ extends?: string | EntitySchema<Base>;
425
+ properties: Record<string, any> | ((properties: typeof propertyBuilders) => Record<string, any>);
426
+ }): EntitySchema<Entity, Base>;
482
427
  export declare namespace defineEntity {
483
428
  var properties: {
484
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
485
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
486
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
487
- json: <T>() => PropertyOptionsBuilder<T>;
488
- formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
489
- type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
490
- enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => EnumOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T>;
491
- embedded: <Target extends EntitySchema<any, any> | EntitySchema<any, any>[]>(target: Target) => EmbeddedOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>>;
492
- manyToMany: <Target extends EntitySchema<any, any>>(target: Target) => ManyToManyOptionsBuilder<Collection<InferEntity<Target>, object>>;
493
- manyToOne: <Target extends EntitySchema<any, any>>(target: Target) => ManyToOneOptionsBuilder<Reference<InferEntity<Target>>>;
494
- oneToMany: <Target extends EntitySchema<any, any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<Collection<InferEntity<Target>, object>>;
495
- oneToOne: <Target extends EntitySchema<any, any>>(target: Target) => OneToOneOptionsBuilder<Reference<InferEntity<Target>>>;
496
- date: () => PropertyOptionsBuilder<string>;
497
- time: () => PropertyOptionsBuilder<any>;
498
- datetime: () => PropertyOptionsBuilder<Date>;
499
- blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
500
- uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
501
- enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
502
- integer: () => PropertyOptionsBuilder<number>;
503
- smallint: () => PropertyOptionsBuilder<number>;
504
- tinyint: () => PropertyOptionsBuilder<number>;
505
- mediumint: () => PropertyOptionsBuilder<number>;
506
- float: () => PropertyOptionsBuilder<number>;
507
- double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
508
- boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
509
- character: () => PropertyOptionsBuilder<string>;
510
- string: () => PropertyOptionsBuilder<string>;
511
- uuid: () => PropertyOptionsBuilder<string>;
512
- text: () => PropertyOptionsBuilder<string>;
513
- interval: () => PropertyOptionsBuilder<string>;
514
- unknown: () => PropertyOptionsBuilder<{}>;
429
+ bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
430
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
431
+ decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
432
+ json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
433
+ formula: <T>(formula: string | ((alias: string) => string)) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
434
+ datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
435
+ time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
436
+ type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
437
+ enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
438
+ embedded: <Target extends EntitySchema<any, any> | EntityClass<any> | EntitySchema<any, any>[] | EntityClass<any>[]>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions, IncludeKeysForEmbeddedOptions>;
439
+ manyToMany: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
440
+ kind: "m:n";
441
+ }, IncludeKeysForManyToManyOptions>;
442
+ manyToOne: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
443
+ kind: "m:1";
444
+ }, IncludeKeysForManyToOneOptions>;
445
+ oneToMany: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
446
+ oneToOne: <Target extends EntitySchema<any, any> | EntityClass<any>>(target: Target) => UniversalPropertyOptionsBuilder<InferEntity<Target>, EmptyOptions & {
447
+ kind: "1:1";
448
+ }, IncludeKeysForOneToOneOptions>;
449
+ date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
450
+ blob: () => UniversalPropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
451
+ uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
452
+ enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
453
+ integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
454
+ smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
455
+ tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
456
+ mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
457
+ float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
458
+ double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
459
+ boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
460
+ character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
461
+ string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
462
+ uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
463
+ text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
464
+ interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
465
+ unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
515
466
  };
516
467
  }
468
+ export { propertyBuilders as p };
469
+ export interface DefineEntityHooks<T> extends Partial<MapToArray<Pick<EventSubscriber<T>, keyof typeof EventType>>> {
470
+ }
471
+ type MapToArray<T extends Record<string, any>> = {
472
+ [K in keyof T]: NonNullable<T[K]>[];
473
+ };
517
474
  type PropertyValueType = PropertyOptions<any>['type'];
518
475
  type InferPropertyValueType<T extends PropertyValueType> = T extends string ? InferTypeByString<T> : T extends NumberConstructor ? number : T extends StringConstructor ? string : T extends BooleanConstructor ? boolean : T extends DateConstructor ? Date : T extends ArrayConstructor ? string[] : T extends Constructor<infer TType> ? TType extends Type<infer TValue, any> ? NonNullable<TValue> : TType : T extends Type<infer TValue, any> ? NonNullable<TValue> : any;
519
476
  type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<typeof types[T]> : InferColumnType<T>;
520
477
  type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
521
478
  type InferColumnType<T extends string> = T extends 'int' | 'int4' | 'integer' | 'bigint' | 'int8' | 'int2' | 'tinyint' | 'smallint' | 'mediumint' ? number : T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4' ? number : T extends 'datetime' | 'time' | 'time with time zone' | 'timestamp' | 'timestamp with time zone' | 'timetz' | 'timestamptz' | 'date' | 'interval' ? Date : T extends 'ObjectId' | 'objectId' | 'character varying' | 'varchar' | 'char' | 'character' | 'uuid' | 'text' | 'tinytext' | 'mediumtext' | 'longtext' | 'enum' ? string : T extends 'boolean' | 'bool' | 'bit' ? boolean : T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea' ? Buffer : T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry' ? number[] : T extends 'tsvector' | 'tsquery' ? string[] : T extends 'json' | 'jsonb' ? any : any;
522
- export type InferEntityFromProperties<Properties extends Record<string, any>> = {
523
- -readonly [K in keyof Properties]: Properties[K] extends (() => any) ? InferBuilderValue<ReturnType<Properties[K]>> : InferBuilderValue<Properties[K]>;
479
+ export type InferEntityFromProperties<Properties extends Record<string, any>, PK extends (keyof Properties)[] | undefined = undefined> = {
480
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
481
+ } & {
482
+ [PrimaryKeyProp]?: PK extends undefined ? InferPrimaryKey<Properties> extends never ? never : IsUnion<InferPrimaryKey<Properties>> extends true ? InferPrimaryKey<Properties>[] : InferPrimaryKey<Properties> : PK;
524
483
  };
484
+ export type InferPrimaryKey<Properties extends Record<string, any>> = {
485
+ [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
486
+ '~options': {
487
+ primary: true;
488
+ };
489
+ } ? K : never;
490
+ }[keyof Properties];
491
+ type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
525
492
  type InferBuilderValue<Builder> = Builder extends {
526
493
  '~type'?: {
527
- value: infer T;
494
+ value: infer Value;
528
495
  };
529
- } ? T : never;
530
- type UnwrapRef<T> = T extends ScalarReference<any> ? UnwrapScalarReference<T> : T extends Reference<any> ? UnwrapReference<T> : T;
531
- type UnwrapScalarReference<T extends ScalarReference<any>> = T extends ScalarReference<infer Value> ? Value : T;
532
- type UnwrapReference<T extends Reference<any>> = T extends Reference<infer Value> ? Value : T;
533
- type UnwrapCollection<T> = T extends Collection<infer Value> ? Value : T;
534
- type UnwrapArray<T> = T extends (infer Value)[] ? Value : T;
496
+ '~options'?: infer Options;
497
+ } ? MaybeHidden<MaybeOpt<MaybeScalarRef<MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>, Options>, Options>, Options> : never;
498
+ type MaybeArray<Value, Options> = Options extends {
499
+ array: true;
500
+ } ? Value[] : Value;
501
+ type MaybeMapToPk<Value, Options> = Options extends {
502
+ mapToPk: true;
503
+ } ? Primary<Value> : Value;
504
+ type MaybeNullable<Value, Options> = Options extends {
505
+ nullable: true;
506
+ } ? Value | null | undefined : Value;
507
+ type MaybeRelationRef<Value, Options> = Options extends {
508
+ mapToPk: true;
509
+ } ? Value : Options extends {
510
+ ref: false;
511
+ } ? Value : Options extends {
512
+ ref: true;
513
+ kind: '1:1';
514
+ } ? Value extends object ? Reference<Value> : never : Options extends {
515
+ ref: true;
516
+ kind: 'm:1';
517
+ } ? Value extends object ? Reference<Value> : never : Options extends {
518
+ kind: '1:m';
519
+ } ? Value extends object ? Collection<Value> : never : Options extends {
520
+ kind: 'm:n';
521
+ } ? Value extends object ? Collection<Value> : never : Value;
522
+ type MaybeScalarRef<Value, Options> = Options extends {
523
+ ref: false;
524
+ } ? Value : Options extends {
525
+ kind: '1:1' | 'm:1' | '1:m' | 'm:n';
526
+ } ? Value : Options extends {
527
+ ref: true;
528
+ } ? ScalarReference<Value> : Value;
529
+ type MaybeOpt<Value, Options> = Options extends {
530
+ mapToPk: true;
531
+ } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Options extends {
532
+ autoincrement: true;
533
+ } ? Opt<Value> : Options extends {
534
+ onCreate: Function;
535
+ } ? Opt<Value> : Options extends {
536
+ default: string | string[] | number | number[] | boolean | null;
537
+ } ? Opt<Value> : Options extends {
538
+ defaultRaw: string;
539
+ } ? Opt<Value> : Options extends {
540
+ persist: false;
541
+ } ? Opt<Value> : Options extends {
542
+ version: true;
543
+ } ? Opt<Value> : Options extends {
544
+ formula: string | (() => string);
545
+ } ? Opt<Value> : Value;
546
+ type MaybeHidden<Value, Options> = Options extends {
547
+ hidden: true;
548
+ } ? Hidden<Value> : Value;
535
549
  type ValueOf<T extends Dictionary> = T[keyof T];
536
- export type InferEntity<Schema> = Schema extends EntitySchema<infer Entity, any> ? Entity : never;
537
- export {};
550
+ type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;
551
+ export type InferEntity<Schema> = Schema extends EntitySchema<infer Entity, any> ? Entity : Schema extends EntityClass<infer Entity> ? Entity : Schema;