@mikro-orm/core 6.5.8-dev.5 → 6.5.8-dev.7

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,14 +6,14 @@ import type { ManyToOneOptions } from '../decorators/ManyToOne';
6
6
  import type { OneToManyOptions } from '../decorators/OneToMany';
7
7
  import type { OneToOneOptions } from '../decorators/OneToOne';
8
8
  import type { ManyToManyOptions } from '../decorators/ManyToMany';
9
- import type { AnyString, GeneratedColumnCallback, Constructor, Opt, Hidden, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata } from '../typings';
9
+ import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, Hidden, Opt } from '../typings';
10
10
  import type { Reference, ScalarReference } from './Reference';
11
11
  import type { SerializeOptions } from '../serialization/EntitySerializer';
12
12
  import type { Cascade, DeferMode, LoadStrategy, QueryOrderMap } from '../enums';
13
- import type { Collection } from './Collection';
14
13
  import type { IType, Type } from '../types/Type';
15
14
  import { types } from '../types';
16
15
  import { EntitySchema } from '../metadata/EntitySchema';
16
+ import type { Collection } from './Collection';
17
17
  /** @internal */
18
18
  export declare class PropertyOptionsBuilder<Value> {
19
19
  '~options': PropertyOptions<any>;
@@ -21,157 +21,186 @@ export declare class PropertyOptionsBuilder<Value> {
21
21
  value: Value;
22
22
  };
23
23
  constructor(options: PropertyOptionsBuilder<Value>['~options']);
24
+ protected assignOptions(options: Partial<PropertyOptionsBuilder<any>['~options']>): this;
24
25
  /**
25
26
  * Alias for `fieldName`.
26
27
  */
27
- name(name: string): PropertyOptionsBuilder<Value>;
28
+ name(name: string): this;
28
29
  /**
29
30
  * Specify database column name for this property.
30
31
  *
31
32
  * @see https://mikro-orm.io/docs/naming-strategy
32
33
  */
33
- fieldName(fieldName: string): PropertyOptionsBuilder<Value>;
34
+ fieldName(fieldName: string): this;
34
35
  /**
35
36
  * Specify database column names for this property.
36
37
  * Same as `fieldName` but for composite FKs.
37
38
  *
38
39
  * @see https://mikro-orm.io/docs/naming-strategy
39
40
  */
40
- fieldNames(...fieldNames: string[]): PropertyOptionsBuilder<Value>;
41
+ fieldNames(...fieldNames: string[]): this;
41
42
  /**
42
43
  * 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
44
  */
44
- columnType(columnType: ColumnType | AnyString): PropertyOptionsBuilder<Value>;
45
+ columnType(columnType: ColumnType | AnyString): this;
45
46
  /**
46
47
  * 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
48
  */
48
- columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyOptionsBuilder<Value>;
49
+ columnTypes(...columnTypes: (ColumnType | AnyString)[]): this;
49
50
  /**
50
51
  * Explicitly specify the runtime type.
51
52
  *
52
53
  * @see https://mikro-orm.io/docs/metadata-providers
53
54
  * @see https://mikro-orm.io/docs/custom-types
54
55
  */
55
- type<TType extends PropertyValueType>(type: TType): PropertyOptionsBuilder<InferPropertyValueType<TType>>;
56
+ type<TType extends PropertyValueType>(type: TType): this;
56
57
  /**
57
58
  * 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
59
  * 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
60
  */
60
- runtimeType(runtimeType: string): PropertyOptionsBuilder<Value>;
61
+ runtimeType(runtimeType: string): this;
61
62
  /**
62
63
  * 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
64
  */
64
- length(length: number): PropertyOptionsBuilder<Value>;
65
+ length(length: number): this;
65
66
  /**
66
67
  * Set precision of database column to represent the number of significant digits. (SQL only)
67
68
  */
68
- precision(precision: number): PropertyOptionsBuilder<Value>;
69
+ precision(precision: number): this;
69
70
  /**
70
71
  * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
71
72
  */
72
- scale(scale: number): PropertyOptionsBuilder<Value>;
73
+ scale(scale: number): this;
73
74
  /**
74
75
  * Explicitly specify the auto increment of the primary key.
75
76
  */
76
- autoincrement<T extends boolean = true>(autoincrement?: T): PropertyOptionsBuilder<T extends true ? Opt<Value> : Value>;
77
+ autoincrement<T extends boolean = true>(autoincrement?: T): this & {
78
+ '~options': {
79
+ autoincrement: T;
80
+ };
81
+ };
77
82
  /**
78
83
  * Add the property to the `returning` statement.
79
84
  */
80
- returning(returning?: boolean): PropertyOptionsBuilder<Value>;
85
+ returning(returning?: boolean): this;
81
86
  /**
82
87
  * Automatically set the property value when entity gets created, executed during flush operation.
83
88
  * @param entity
84
89
  */
85
- onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyOptionsBuilder<Opt<Value>>;
90
+ onCreate(onCreate: (entity: any, em: EntityManager) => Value): this & {
91
+ '~options': {
92
+ onCreate: (...args: any[]) => any;
93
+ };
94
+ };
86
95
  /**
87
96
  * Automatically update the property value every time entity gets updated, executed during flush operation.
88
97
  * @param entity
89
98
  */
90
- onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyOptionsBuilder<Value>;
99
+ onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): this;
91
100
  /**
92
101
  * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
93
102
  * This is a runtime value, assignable to the entity property. (SQL only)
94
103
  */
95
- default(defaultValue: string | string[] | number | number[] | boolean | null): PropertyOptionsBuilder<Opt<Value>>;
104
+ default<T extends string | string[] | number | number[] | boolean | null>(defaultValue: T): this & {
105
+ '~options': {
106
+ default: T;
107
+ };
108
+ };
96
109
  /**
97
110
  * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
98
111
  * Since v4 you should use defaultRaw for SQL functions. e.g. now()
99
112
  */
100
- defaultRaw(defaultRaw: string): PropertyOptionsBuilder<Value>;
113
+ defaultRaw(defaultRaw: string): this & {
114
+ '~options': {
115
+ defaultRaw: string;
116
+ };
117
+ };
101
118
  /**
102
119
  * Set to map some SQL snippet for the entity.
103
120
  *
104
121
  * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
105
122
  */
106
- formula(formula: string | ((alias: string) => string)): PropertyOptionsBuilder<Value>;
123
+ formula(formula: string | ((alias: string) => string)): this;
107
124
  /**
108
125
  * For generated columns. This will be appended to the column type after the `generated always` clause.
109
126
  */
110
- generated(generated: string | GeneratedColumnCallback<any>): PropertyOptionsBuilder<Value>;
127
+ generated(generated: string | GeneratedColumnCallback<any>): this;
111
128
  /**
112
129
  * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
113
130
  */
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>>;
131
+ nullable<T extends boolean = true>(nullable?: T): this & {
132
+ '~options': {
133
+ nullable: T;
134
+ };
135
+ };
115
136
  /**
116
137
  * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
117
138
  */
118
- unsigned(unsigned?: boolean): PropertyOptionsBuilder<Value>;
139
+ unsigned(unsigned?: boolean): this;
119
140
  /**
120
141
  * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
121
142
  */
122
- persist(persist?: boolean): PropertyOptionsBuilder<Value>;
143
+ persist(persist?: boolean): this;
123
144
  /**
124
145
  * Set false to disable hydration of this property. Useful for persisted getters.
125
146
  */
126
- hydrate(hydrate?: boolean): PropertyOptionsBuilder<Value>;
147
+ hydrate(hydrate?: boolean): this;
127
148
  /**
128
149
  * 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
150
  */
130
- ref<T extends boolean = true>(ref?: T): PropertyOptionsBuilder<T extends true ? ScalarReference<Value> : UnwrapRef<Value>>;
151
+ ref<T extends boolean = true>(ref?: T): T extends true ? WithRef<this> : WithoutRef<this>;
131
152
  /**
132
153
  * Set false to disable change tracking on a property level.
133
154
  *
134
155
  * @see https://mikro-orm.io/docs/unit-of-work#change-tracking-and-performance-considerations
135
156
  */
136
- trackChanges(trackChanges?: boolean): PropertyOptionsBuilder<Value>;
157
+ trackChanges(trackChanges?: boolean): this;
137
158
  /**
138
159
  * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
139
160
  */
140
- hidden<T extends boolean = true>(hidden?: T): PropertyOptionsBuilder<T extends true ? Hidden<Value> : Value>;
161
+ hidden<T extends boolean = true>(hidden?: T): this & {
162
+ '~options': {
163
+ hidden: T;
164
+ };
165
+ };
141
166
  /**
142
167
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
143
168
  */
144
- version(version?: boolean): PropertyOptionsBuilder<Value>;
169
+ version(version?: boolean): this;
145
170
  /**
146
171
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
147
172
  */
148
- concurrencyCheck(concurrencyCheck?: boolean): PropertyOptionsBuilder<Value>;
173
+ concurrencyCheck(concurrencyCheck?: boolean): this;
149
174
  /**
150
175
  * Explicitly specify index on a property.
151
176
  */
152
- index(index?: boolean | string): PropertyOptionsBuilder<Value>;
177
+ index(index?: boolean | string): this;
153
178
  /**
154
179
  * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
155
180
  */
156
- unique(unique?: boolean | string): PropertyOptionsBuilder<Value>;
181
+ unique(unique?: boolean | string): this;
157
182
  /**
158
183
  * Specify column with check constraints. (Postgres driver only)
159
184
  *
160
185
  * @see https://mikro-orm.io/docs/defining-entities#check-constraints
161
186
  */
162
- check(check: string | CheckCallback<any>): PropertyOptionsBuilder<Value>;
187
+ check(check: string | CheckCallback<any>): this;
163
188
  /**
164
189
  * Set to omit the property from the select clause for lazy loading.
165
190
  *
166
191
  * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
167
192
  */
168
- lazy<T extends boolean = true>(lazy?: boolean, ref?: T): PropertyOptionsBuilder<T extends true ? ScalarReference<Value> : UnwrapRef<Value>>;
193
+ lazy<T extends boolean = true>(lazy?: boolean, ref?: T): T extends true ? WithRef<this> : WithoutRef<this>;
169
194
  /**
170
195
  * Set true to define entity's unique primary key identifier.
171
196
  *
172
197
  * @see https://mikro-orm.io/docs/decorators#primarykey
173
198
  */
174
- primary(primary?: boolean): PropertyOptionsBuilder<Value>;
199
+ primary<T extends boolean = true>(primary?: T): this & {
200
+ '~options': {
201
+ primary: T;
202
+ };
203
+ };
175
204
  /**
176
205
  * Set true to define the properties as setter. (virtual)
177
206
  *
@@ -183,7 +212,7 @@ export declare class PropertyOptionsBuilder<Value> {
183
212
  * }
184
213
  * ```
185
214
  */
186
- setter(setter?: boolean): PropertyOptionsBuilder<Value>;
215
+ setter(setter?: boolean): this;
187
216
  /**
188
217
  * Set true to define the properties as getter. (virtual)
189
218
  *
@@ -195,7 +224,7 @@ export declare class PropertyOptionsBuilder<Value> {
195
224
  * }
196
225
  * ```
197
226
  */
198
- getter(getter?: boolean): PropertyOptionsBuilder<Value>;
227
+ getter(getter?: boolean): this;
199
228
  /**
200
229
  * When defining a property over a method (not a getter, a regular function), you can use this option to point
201
230
  * to the method name.
@@ -208,45 +237,45 @@ export declare class PropertyOptionsBuilder<Value> {
208
237
  * }
209
238
  * ```
210
239
  */
211
- getterName(getterName: string): PropertyOptionsBuilder<Value>;
240
+ getterName(getterName: string): this;
212
241
  /**
213
242
  * Set to define serialized primary key for MongoDB. (virtual)
214
243
  * Alias for `@SerializedPrimaryKey()` decorator.
215
244
  *
216
245
  * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
217
246
  */
218
- serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyOptionsBuilder<Value>;
247
+ serializedPrimaryKey(serializedPrimaryKey?: boolean): this;
219
248
  /**
220
249
  * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
221
250
  *
222
251
  * @see https://mikro-orm.io/docs/serializing#property-serializers
223
252
  */
224
- serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyOptionsBuilder<Value>;
253
+ serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): this;
225
254
  /**
226
255
  * Specify name of key for the serialized value.
227
256
  */
228
- serializedName(serializedName: string): PropertyOptionsBuilder<Value>;
257
+ serializedName(serializedName: string): this;
229
258
  /**
230
259
  * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
231
260
  * otherwise only properties with a matching group are included.
232
261
  */
233
- groups(...groups: string[]): PropertyOptionsBuilder<Value>;
262
+ groups(...groups: string[]): this;
234
263
  /**
235
264
  * Specify a custom order based on the values. (SQL only)
236
265
  */
237
- customOrder(...customOrder: (string[] | number[] | boolean[])): PropertyOptionsBuilder<Value>;
266
+ customOrder(...customOrder: (string[] | number[] | boolean[])): this;
238
267
  /**
239
268
  * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
240
269
  */
241
- comment(comment: string): PropertyOptionsBuilder<Value>;
270
+ comment(comment: string): this;
242
271
  /** mysql only */
243
- extra(extra: string): PropertyOptionsBuilder<Value>;
272
+ extra(extra: string): this;
244
273
  /**
245
274
  * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
246
275
  *
247
276
  * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
248
277
  */
249
- ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyOptionsBuilder<Value>;
278
+ ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): this;
250
279
  /**
251
280
  * Set the TypeScript type of the property.
252
281
  */
@@ -269,178 +298,175 @@ export declare class EnumOptionsBuilder<Value> extends PropertyOptionsBuilder<Va
269
298
  enum: true;
270
299
  } & EnumOptions<any>;
271
300
  constructor(options: EnumOptionsBuilder<Value>['~options']);
272
- array<T extends boolean = true>(array?: T): EnumOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
301
+ protected assignOptions(options: Partial<EnumOptionsBuilder<any>['~options']>): this;
302
+ array<T extends boolean = true>(array?: T): this & {
303
+ '~options': {
304
+ array: T;
305
+ };
306
+ };
273
307
  /** for postgres, by default it uses text column with check constraint */
274
- nativeEnumName(nativeEnumName: string): EnumOptionsBuilder<Value>;
308
+ nativeEnumName(nativeEnumName: string): this;
275
309
  }
276
310
  /** @internal */
277
311
  export declare class EmbeddedOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
278
312
  '~options': ({
279
313
  kind: 'embedded';
280
314
  entity: () => EntitySchema<any, any> | EntitySchema<any, any>[];
281
- } & EmbeddedOptions<any, any> & PropertyOptions<any>);
315
+ } & EmbeddedOptions<any, any>);
282
316
  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>>;
317
+ protected assignOptions(options: Partial<EmbeddedOptionsBuilder<any>['~options']>): this;
318
+ prefix(prefix: string | boolean): this;
319
+ prefixMode(prefixMode: EmbeddedPrefixMode): this;
320
+ object(object?: boolean): this;
321
+ array<T extends boolean = true>(array?: T): this & {
322
+ '~options': {
323
+ array: T;
324
+ };
325
+ };
287
326
  }
288
327
  /** @internal */
289
- export declare class ReferenceOptionsBuilder<Value extends object> extends PropertyOptionsBuilder<Value> {
328
+ export declare abstract class ReferenceOptionsBuilder<Value extends object> extends PropertyOptionsBuilder<Value> {
290
329
  '~options': ReferenceOptions<any, any>;
291
330
  constructor(options: ReferenceOptionsBuilder<Value>['~options']);
331
+ protected abstract assignOptions(options: Partial<ReferenceOptionsBuilder<any>['~options']>): this;
292
332
  /** 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>;
333
+ cascade(...cascade: Cascade[]): this;
294
334
  /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
295
- eager(eager?: boolean): ReferenceOptionsBuilder<Value>;
335
+ eager(eager?: boolean): this;
296
336
  /** 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>;
337
+ strategy(strategy: LoadStrategy | `${LoadStrategy}`): this;
308
338
  }
309
339
  /** @internal */
310
340
  export declare class ManyToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
311
341
  '~options': ({
312
342
  kind: 'm:n';
313
343
  entity: () => EntitySchema<any, any>;
314
- } & ManyToManyOptions<any, UnwrapCollection<TargetValue>>);
344
+ } & ManyToManyOptions<any, TargetValue>);
315
345
  constructor(options: ManyToManyOptionsBuilder<TargetValue>['~options']);
346
+ protected assignOptions(options: Partial<ManyToManyOptionsBuilder<any>['~options']>): this;
316
347
  /** 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>;
348
+ owner(owner?: boolean): this;
318
349
  /** Point to the inverse side property name. */
319
- inversedBy(inversedBy: (string & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): ManyToManyOptionsBuilder<TargetValue>;
350
+ inversedBy(inversedBy: (string & keyof TargetValue) | ((e: TargetValue) => any)): this;
320
351
  /** Point to the owning side property name. */
321
- mappedBy(mappedBy: string | ((e: any) => any)): ManyToManyOptionsBuilder<TargetValue>;
352
+ mappedBy(mappedBy: string | ((e: any) => any)): this;
322
353
  /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
323
- where(...where: FilterQuery<object>[]): ManyToManyOptionsBuilder<TargetValue>;
354
+ where(...where: FilterQuery<object>[]): this;
324
355
  /** Set default ordering. */
325
- orderBy(...orderBy: QueryOrderMap<object>[]): ManyToManyOptionsBuilder<TargetValue>;
356
+ orderBy(...orderBy: QueryOrderMap<object>[]): this;
326
357
  /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
327
- fixedOrder(fixedOrder?: boolean): ManyToManyOptionsBuilder<TargetValue>;
358
+ fixedOrder(fixedOrder?: boolean): this;
328
359
  /** Override default order column name (`id`) for fixed ordering. */
329
- fixedOrderColumn(fixedOrderColumn: string): ManyToManyOptionsBuilder<TargetValue>;
360
+ fixedOrderColumn(fixedOrderColumn: string): this;
330
361
  /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
331
- pivotTable(pivotTable: string): ManyToManyOptionsBuilder<TargetValue>;
362
+ pivotTable(pivotTable: string): this;
332
363
  /** 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>;
364
+ pivotEntity(pivotEntity: string | (() => EntityName<any>)): this;
334
365
  /** 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>;
366
+ joinColumn(joinColumn: string): this;
336
367
  /** 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>;
368
+ joinColumns(...joinColumns: string[]): this;
338
369
  /** 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>;
370
+ inverseJoinColumn(inverseJoinColumn: string): this;
340
371
  /** 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>;
372
+ inverseJoinColumns(...inverseJoinColumns: string[]): this;
342
373
  /** 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>;
374
+ referenceColumnName(referenceColumnName: string): this;
344
375
  /** 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>;
376
+ referencedColumnNames(...referencedColumnNames: string[]): this;
346
377
  /** What to do when the target entity gets deleted. */
347
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToManyOptionsBuilder<TargetValue>;
378
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): this;
348
379
  /** 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>;
380
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): this;
350
381
  }
351
382
  /** @internal */
352
383
  export declare class ManyToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
353
384
  '~options': ({
354
385
  kind: 'm:1';
355
386
  entity: () => EntitySchema<any, any>;
356
- } & ManyToOneOptions<any, UnwrapRef<TargetValue>>);
387
+ } & ManyToOneOptions<any, TargetValue>);
357
388
  constructor(options: ManyToOneOptionsBuilder<TargetValue>['~options']);
389
+ protected assignOptions(options: Partial<ManyToOneOptionsBuilder<any>['~options']>): this;
358
390
  /** 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>;
391
+ inversedBy(inversedBy: (string & keyof TargetValue) | ((e: TargetValue) => any)): this;
364
392
  /** Map this relation to the primary key value instead of an entity. */
365
- mapToPk(mapToPk?: boolean): ManyToOneOptionsBuilder<TargetValue>;
393
+ mapToPk(mapToPk?: boolean): this;
366
394
  /** 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>;
395
+ joinColumn(joinColumn: string): this;
368
396
  /** 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>;
397
+ joinColumns(...joinColumns: string[]): this;
370
398
  /** 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>;
399
+ ownColumns(...ownColumns: string[]): this;
372
400
  /** 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>;
401
+ referenceColumnName(referenceColumnName: string): this;
374
402
  /** 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>;
403
+ referencedColumnNames(...referencedColumnNames: string[]): this;
376
404
  /** What to do when the target entity gets deleted. */
377
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
405
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): this;
378
406
  /** 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>;
407
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): this;
380
408
  /** 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>;
409
+ deferMode(deferMode: DeferMode | `${DeferMode}`): this;
382
410
  }
383
411
  /** @internal */
384
412
  export declare class OneToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
385
413
  '~options': ({
386
414
  kind: '1:m';
387
415
  entity: () => EntitySchema<TargetValue>;
388
- } & OneToManyOptions<any, UnwrapCollection<TargetValue>>);
416
+ } & OneToManyOptions<any, TargetValue>);
389
417
  constructor(options: OneToManyOptionsBuilder<TargetValue>['~options']);
418
+ protected assignOptions(options: Partial<OneToManyOptionsBuilder<any>['~options']>): this;
390
419
  /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
391
- orphanRemoval(orphanRemoval?: boolean): OneToManyOptionsBuilder<TargetValue>;
420
+ orphanRemoval(orphanRemoval?: boolean): this;
392
421
  /** Set default ordering. */
393
- orderBy(orderBy: QueryOrderMap<UnwrapCollection<TargetValue>> | QueryOrderMap<UnwrapCollection<TargetValue>>[]): OneToManyOptionsBuilder<TargetValue>;
422
+ orderBy(orderBy: QueryOrderMap<TargetValue> | QueryOrderMap<TargetValue>[]): this;
394
423
  /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
395
- where(where: FilterQuery<UnwrapCollection<TargetValue>>): OneToManyOptionsBuilder<TargetValue>;
424
+ where(where: FilterQuery<TargetValue>): this;
396
425
  /** 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>;
426
+ joinColumn(joinColumn: string): this;
398
427
  /** 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>;
428
+ joinColumns(...joinColumns: string[]): this;
400
429
  /** 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>;
430
+ inverseJoinColumn(inverseJoinColumn: string): this;
402
431
  /** 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>;
432
+ inverseJoinColumns(...inverseJoinColumns: string[]): this;
404
433
  /** 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>;
434
+ referenceColumnName(referenceColumnName: string): this;
406
435
  /** 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>;
436
+ referencedColumnNames(...referencedColumnNames: string[]): this;
408
437
  }
409
438
  /** @internal */
410
439
  export declare class OneToManyOptionsBuilderOnlyMappedBy<TargetValue extends object> {
411
440
  '~options': ({
412
441
  kind: '1:m';
413
442
  entity: () => EntitySchema<TargetValue>;
414
- } & Omit<OneToManyOptions<any, UnwrapCollection<TargetValue>>, 'mappedBy'>);
443
+ } & Omit<OneToManyOptions<any, TargetValue>, 'mappedBy'>);
415
444
  constructor(options: OneToManyOptionsBuilderOnlyMappedBy<TargetValue>['~options']);
416
445
  /** Point to the owning side property name. */
417
- mappedBy(mappedBy: (AnyString & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): OneToManyOptionsBuilder<TargetValue>;
446
+ mappedBy(mappedBy: (AnyString & keyof TargetValue) | ((e: TargetValue) => any)): OneToManyOptionsBuilder<TargetValue>;
418
447
  }
419
448
  /** @internal */
420
449
  export declare class OneToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
421
450
  '~options': ({
422
451
  kind: '1:1';
423
452
  entity: () => EntitySchema<any, any>;
424
- } & OneToOneOptions<any, UnwrapRef<TargetValue>>);
453
+ } & OneToOneOptions<any, TargetValue>);
425
454
  constructor(options: OneToOneOptionsBuilder<TargetValue>['~options']);
455
+ protected assignOptions(options: Partial<OneToOneOptionsBuilder<any>['~options']>): this;
426
456
  /** 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>;
457
+ owner(owner?: boolean): this;
428
458
  /** 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>;
459
+ inversedBy(inversedBy: (string & keyof TargetValue) | ((e: TargetValue) => any)): this;
434
460
  /** Map this relation to the primary key value instead of an entity. */
435
- mapToPk(mapToPk?: boolean): OneToOneOptionsBuilder<TargetValue>;
461
+ mapToPk(mapToPk?: boolean): this;
436
462
  /** 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>;
463
+ ownColumns(...ownColumns: string[]): this;
438
464
  /** What to do when the target entity gets deleted. */
439
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
465
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): this;
440
466
  /** 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>;
467
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): this;
442
468
  /** 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>;
469
+ deferMode(deferMode: DeferMode | `${DeferMode}`): this;
444
470
  }
445
471
  declare const propertyBuilders: {
446
472
  bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
@@ -451,10 +477,10 @@ declare const propertyBuilders: {
451
477
  type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
452
478
  enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => EnumOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T>;
453
479
  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>>>;
480
+ manyToMany: <Target extends EntitySchema<any, any>>(target: Target) => ManyToManyOptionsBuilder<InferEntity<Target>>;
481
+ manyToOne: <Target extends EntitySchema<any, any>>(target: Target) => ManyToOneOptionsBuilder<InferEntity<Target>>;
482
+ oneToMany: <Target extends EntitySchema<any, any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
483
+ oneToOne: <Target extends EntitySchema<any, any>>(target: Target) => OneToOneOptionsBuilder<InferEntity<Target>>;
458
484
  date: () => PropertyOptionsBuilder<string>;
459
485
  time: () => PropertyOptionsBuilder<any>;
460
486
  datetime: () => PropertyOptionsBuilder<Date>;
@@ -475,10 +501,11 @@ declare const propertyBuilders: {
475
501
  interval: () => PropertyOptionsBuilder<string>;
476
502
  unknown: () => PropertyOptionsBuilder<{}>;
477
503
  };
478
- export declare function defineEntity<Properties extends Record<string, any>>(meta: Omit<Partial<EntityMetadata<InferEntityFromProperties<Properties>>>, 'properties' | 'extends'> & {
504
+ export declare function defineEntity<Properties extends Record<string, any>, const PK extends (keyof Properties)[] | undefined = undefined>(meta: Omit<Partial<EntityMetadata<InferEntityFromProperties<Properties, PK>>>, 'properties' | 'extends' | 'primaryKeys'> & {
479
505
  name: string;
480
506
  properties: Properties | ((properties: typeof propertyBuilders) => Properties);
481
- }): EntitySchema<InferEntityFromProperties<Properties>, never>;
507
+ primaryKeys?: PK & InferPrimaryKey<Properties>[];
508
+ }): EntitySchema<InferEntityFromProperties<Properties, PK>, never>;
482
509
  export declare namespace defineEntity {
483
510
  var properties: {
484
511
  bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
@@ -489,10 +516,10 @@ export declare namespace defineEntity {
489
516
  type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
490
517
  enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => EnumOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T>;
491
518
  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>>>;
519
+ manyToMany: <Target extends EntitySchema<any, any>>(target: Target) => ManyToManyOptionsBuilder<InferEntity<Target>>;
520
+ manyToOne: <Target extends EntitySchema<any, any>>(target: Target) => ManyToOneOptionsBuilder<InferEntity<Target>>;
521
+ oneToMany: <Target extends EntitySchema<any, any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<InferEntity<Target>>;
522
+ oneToOne: <Target extends EntitySchema<any, any>>(target: Target) => OneToOneOptionsBuilder<InferEntity<Target>>;
496
523
  date: () => PropertyOptionsBuilder<string>;
497
524
  time: () => PropertyOptionsBuilder<any>;
498
525
  datetime: () => PropertyOptionsBuilder<Date>;
@@ -519,19 +546,96 @@ type InferPropertyValueType<T extends PropertyValueType> = T extends string ? In
519
546
  type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<typeof types[T]> : InferColumnType<T>;
520
547
  type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
521
548
  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]>;
549
+ export type InferEntityFromProperties<Properties extends Record<string, any>, PK extends (keyof Properties)[] | undefined = undefined> = {
550
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
551
+ } & {
552
+ [PrimaryKeyProp]?: PK extends undefined ? InferPrimaryKey<Properties> extends never ? never : IsUnion<InferPrimaryKey<Properties>> extends true ? InferPrimaryKey<Properties>[] : InferPrimaryKey<Properties> : PK;
553
+ };
554
+ export type InferPrimaryKey<Properties extends Record<string, any>> = {
555
+ [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
556
+ '~options': {
557
+ primary: true;
558
+ };
559
+ } ? K : never;
560
+ }[keyof Properties];
561
+ type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
562
+ type WithRef<T> = T & {
563
+ '~options': {
564
+ ref: true;
565
+ };
566
+ };
567
+ type WithoutRef<T> = T extends WithRef<infer U> ? U & {
568
+ '~options': {
569
+ ref: false;
570
+ };
571
+ } : T & {
572
+ '~options': {
573
+ ref: false;
574
+ };
524
575
  };
525
576
  type InferBuilderValue<Builder> = Builder extends {
526
577
  '~type'?: {
527
- value: infer T;
578
+ value: infer Value;
579
+ };
580
+ } ? MaybeHidden<MaybeOpt<MaybeRef<MaybeNullable<MaybeArray<Value, Builder>, Builder>, Builder>, Builder>, Builder> : never;
581
+ type MaybeArray<Value, Builder> = Builder extends {
582
+ '~options': {
583
+ array: true;
584
+ };
585
+ } ? Value[] : Value;
586
+ type MaybeNullable<Value, Builder> = Builder extends {
587
+ '~options': {
588
+ nullable: true;
589
+ };
590
+ } ? Value | null | undefined : Value;
591
+ type MaybeRef<Value, Builder> = Builder extends {
592
+ '~options': {
593
+ ref: false;
594
+ };
595
+ } ? Value : Builder extends {
596
+ '~options': {
597
+ kind: '1:1';
598
+ };
599
+ } ? Value extends object ? Reference<Value> : never : Builder extends {
600
+ '~options': {
601
+ kind: 'm:1';
602
+ };
603
+ } ? Value extends object ? Reference<Value> : never : Builder extends {
604
+ '~options': {
605
+ kind: '1:m';
606
+ };
607
+ } ? Value extends object ? Collection<Value> : never : Builder extends {
608
+ '~options': {
609
+ kind: 'm:n';
610
+ };
611
+ } ? Value extends object ? Collection<Value> : never : Builder extends {
612
+ '~options': {
613
+ ref: true;
614
+ };
615
+ } ? ScalarReference<Value> : Value;
616
+ type MaybeOpt<Value, Builder> = Builder extends {
617
+ '~options': {
618
+ autoincrement: true;
619
+ };
620
+ } ? Opt<Value> : Builder extends {
621
+ '~options': {
622
+ onCreate: Function;
623
+ };
624
+ } ? Opt<Value> : Builder extends {
625
+ '~options': {
626
+ default: string | string[] | number | number[] | boolean | null;
627
+ };
628
+ } ? Opt<Value> : Builder extends {
629
+ '~options': {
630
+ defaultRaw: string;
631
+ };
632
+ } ? Opt<Value> : Value;
633
+ type MaybeHidden<Value, Builder> = Builder extends {
634
+ '~options': {
635
+ hidden: true;
528
636
  };
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;
637
+ } ? Hidden<Value> : Value;
535
638
  type ValueOf<T extends Dictionary> = T[keyof T];
639
+ type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;
536
640
  export type InferEntity<Schema> = Schema extends EntitySchema<infer Entity, any> ? Entity : never;
537
641
  export {};