@mikro-orm/core 7.0.7 → 7.0.8-dev.0

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.
Files changed (206) hide show
  1. package/EntityManager.d.ts +583 -884
  2. package/EntityManager.js +1899 -1926
  3. package/MikroORM.d.ts +74 -103
  4. package/MikroORM.js +179 -178
  5. package/README.md +1 -1
  6. package/cache/CacheAdapter.d.ts +36 -36
  7. package/cache/FileCacheAdapter.d.ts +24 -30
  8. package/cache/FileCacheAdapter.js +78 -80
  9. package/cache/GeneratedCacheAdapter.d.ts +20 -18
  10. package/cache/GeneratedCacheAdapter.js +30 -30
  11. package/cache/MemoryCacheAdapter.d.ts +20 -18
  12. package/cache/MemoryCacheAdapter.js +36 -35
  13. package/cache/NullCacheAdapter.d.ts +16 -16
  14. package/cache/NullCacheAdapter.js +24 -24
  15. package/connections/Connection.d.ts +84 -95
  16. package/connections/Connection.js +168 -165
  17. package/drivers/DatabaseDriver.d.ts +80 -186
  18. package/drivers/DatabaseDriver.js +443 -450
  19. package/drivers/IDatabaseDriver.d.ts +301 -440
  20. package/entity/BaseEntity.d.ts +83 -120
  21. package/entity/BaseEntity.js +43 -43
  22. package/entity/Collection.d.ts +180 -213
  23. package/entity/Collection.js +724 -730
  24. package/entity/EntityAssigner.d.ts +77 -88
  25. package/entity/EntityAssigner.js +230 -231
  26. package/entity/EntityFactory.d.ts +55 -67
  27. package/entity/EntityFactory.js +414 -455
  28. package/entity/EntityHelper.d.ts +23 -35
  29. package/entity/EntityHelper.js +277 -289
  30. package/entity/EntityIdentifier.d.ts +4 -4
  31. package/entity/EntityIdentifier.js +10 -10
  32. package/entity/EntityLoader.d.ts +72 -98
  33. package/entity/EntityLoader.js +730 -760
  34. package/entity/EntityRepository.d.ts +201 -316
  35. package/entity/EntityRepository.js +213 -213
  36. package/entity/PolymorphicRef.d.ts +5 -5
  37. package/entity/PolymorphicRef.js +10 -10
  38. package/entity/Reference.d.ts +83 -127
  39. package/entity/Reference.js +277 -281
  40. package/entity/WrappedEntity.d.ts +72 -115
  41. package/entity/WrappedEntity.js +166 -168
  42. package/entity/defineEntity.d.ts +657 -1346
  43. package/entity/defineEntity.js +518 -527
  44. package/entity/utils.d.ts +3 -13
  45. package/entity/utils.js +73 -71
  46. package/entity/validators.js +43 -43
  47. package/entity/wrap.js +8 -8
  48. package/enums.d.ts +253 -258
  49. package/enums.js +252 -251
  50. package/errors.d.ts +72 -114
  51. package/errors.js +253 -350
  52. package/events/EventManager.d.ts +14 -26
  53. package/events/EventManager.js +77 -79
  54. package/events/EventSubscriber.d.ts +29 -29
  55. package/events/TransactionEventBroadcaster.d.ts +8 -15
  56. package/events/TransactionEventBroadcaster.js +14 -14
  57. package/exceptions.d.ts +40 -23
  58. package/exceptions.js +52 -35
  59. package/hydration/Hydrator.d.ts +17 -42
  60. package/hydration/Hydrator.js +43 -43
  61. package/hydration/ObjectHydrator.d.ts +17 -50
  62. package/hydration/ObjectHydrator.js +418 -483
  63. package/index.d.ts +2 -116
  64. package/index.js +1 -10
  65. package/logging/DefaultLogger.d.ts +32 -34
  66. package/logging/DefaultLogger.js +86 -86
  67. package/logging/Logger.d.ts +41 -41
  68. package/logging/SimpleLogger.d.ts +11 -13
  69. package/logging/SimpleLogger.js +22 -22
  70. package/logging/colors.d.ts +6 -6
  71. package/logging/colors.js +10 -11
  72. package/logging/inspect.js +7 -7
  73. package/metadata/EntitySchema.d.ts +130 -214
  74. package/metadata/EntitySchema.js +412 -411
  75. package/metadata/MetadataDiscovery.d.ts +114 -114
  76. package/metadata/MetadataDiscovery.js +1868 -1944
  77. package/metadata/MetadataProvider.d.ts +26 -29
  78. package/metadata/MetadataProvider.js +97 -95
  79. package/metadata/MetadataStorage.d.ts +32 -38
  80. package/metadata/MetadataStorage.js +118 -118
  81. package/metadata/MetadataValidator.d.ts +39 -39
  82. package/metadata/MetadataValidator.js +338 -381
  83. package/metadata/discover-entities.d.ts +2 -5
  84. package/metadata/discover-entities.js +37 -35
  85. package/metadata/types.d.ts +531 -615
  86. package/naming-strategy/AbstractNamingStrategy.d.ts +39 -54
  87. package/naming-strategy/AbstractNamingStrategy.js +85 -90
  88. package/naming-strategy/EntityCaseNamingStrategy.d.ts +6 -6
  89. package/naming-strategy/EntityCaseNamingStrategy.js +22 -22
  90. package/naming-strategy/MongoNamingStrategy.d.ts +6 -6
  91. package/naming-strategy/MongoNamingStrategy.js +18 -18
  92. package/naming-strategy/NamingStrategy.d.ts +99 -109
  93. package/naming-strategy/UnderscoreNamingStrategy.d.ts +7 -7
  94. package/naming-strategy/UnderscoreNamingStrategy.js +21 -21
  95. package/not-supported.js +4 -7
  96. package/package.json +1 -1
  97. package/platforms/ExceptionConverter.d.ts +1 -1
  98. package/platforms/ExceptionConverter.js +4 -4
  99. package/platforms/Platform.d.ts +303 -312
  100. package/platforms/Platform.js +644 -667
  101. package/serialization/EntitySerializer.d.ts +26 -49
  102. package/serialization/EntitySerializer.js +218 -224
  103. package/serialization/EntityTransformer.d.ts +6 -10
  104. package/serialization/EntityTransformer.js +217 -219
  105. package/serialization/SerializationContext.d.ts +23 -27
  106. package/serialization/SerializationContext.js +105 -105
  107. package/types/ArrayType.d.ts +8 -8
  108. package/types/ArrayType.js +33 -33
  109. package/types/BigIntType.d.ts +10 -17
  110. package/types/BigIntType.js +37 -37
  111. package/types/BlobType.d.ts +3 -3
  112. package/types/BlobType.js +13 -13
  113. package/types/BooleanType.d.ts +4 -4
  114. package/types/BooleanType.js +12 -12
  115. package/types/CharacterType.d.ts +2 -2
  116. package/types/CharacterType.js +6 -6
  117. package/types/DateTimeType.d.ts +5 -5
  118. package/types/DateTimeType.js +15 -15
  119. package/types/DateType.d.ts +5 -5
  120. package/types/DateType.js +15 -15
  121. package/types/DecimalType.d.ts +7 -7
  122. package/types/DecimalType.js +26 -26
  123. package/types/DoubleType.d.ts +3 -3
  124. package/types/DoubleType.js +12 -12
  125. package/types/EnumArrayType.d.ts +5 -5
  126. package/types/EnumArrayType.js +24 -24
  127. package/types/EnumType.d.ts +3 -3
  128. package/types/EnumType.js +11 -11
  129. package/types/FloatType.d.ts +3 -3
  130. package/types/FloatType.js +9 -9
  131. package/types/IntegerType.d.ts +3 -3
  132. package/types/IntegerType.js +9 -9
  133. package/types/IntervalType.d.ts +4 -4
  134. package/types/IntervalType.js +12 -12
  135. package/types/JsonType.d.ts +8 -8
  136. package/types/JsonType.js +32 -32
  137. package/types/MediumIntType.d.ts +1 -1
  138. package/types/MediumIntType.js +3 -3
  139. package/types/SmallIntType.d.ts +3 -3
  140. package/types/SmallIntType.js +9 -9
  141. package/types/StringType.d.ts +4 -4
  142. package/types/StringType.js +12 -12
  143. package/types/TextType.d.ts +3 -3
  144. package/types/TextType.js +9 -9
  145. package/types/TimeType.d.ts +5 -5
  146. package/types/TimeType.js +17 -17
  147. package/types/TinyIntType.d.ts +3 -3
  148. package/types/TinyIntType.js +10 -10
  149. package/types/Type.d.ts +79 -83
  150. package/types/Type.js +82 -82
  151. package/types/Uint8ArrayType.d.ts +4 -4
  152. package/types/Uint8ArrayType.js +21 -21
  153. package/types/UnknownType.d.ts +4 -4
  154. package/types/UnknownType.js +12 -12
  155. package/types/UuidType.d.ts +5 -5
  156. package/types/UuidType.js +19 -19
  157. package/types/index.d.ts +49 -75
  158. package/types/index.js +26 -52
  159. package/typings.d.ts +741 -1254
  160. package/typings.js +233 -244
  161. package/unit-of-work/ChangeSet.d.ts +26 -26
  162. package/unit-of-work/ChangeSet.js +56 -56
  163. package/unit-of-work/ChangeSetComputer.d.ts +12 -12
  164. package/unit-of-work/ChangeSetComputer.js +179 -187
  165. package/unit-of-work/ChangeSetPersister.d.ts +44 -63
  166. package/unit-of-work/ChangeSetPersister.js +423 -446
  167. package/unit-of-work/CommitOrderCalculator.d.ts +40 -40
  168. package/unit-of-work/CommitOrderCalculator.js +88 -89
  169. package/unit-of-work/IdentityMap.d.ts +31 -31
  170. package/unit-of-work/IdentityMap.js +105 -105
  171. package/unit-of-work/UnitOfWork.d.ts +141 -181
  172. package/unit-of-work/UnitOfWork.js +1183 -1200
  173. package/utils/AbstractMigrator.d.ts +91 -111
  174. package/utils/AbstractMigrator.js +275 -275
  175. package/utils/AbstractSchemaGenerator.d.ts +34 -43
  176. package/utils/AbstractSchemaGenerator.js +122 -121
  177. package/utils/AsyncContext.d.ts +3 -3
  178. package/utils/AsyncContext.js +35 -34
  179. package/utils/Configuration.d.ts +808 -852
  180. package/utils/Configuration.js +344 -359
  181. package/utils/Cursor.d.ts +22 -40
  182. package/utils/Cursor.js +127 -135
  183. package/utils/DataloaderUtils.d.ts +43 -58
  184. package/utils/DataloaderUtils.js +198 -203
  185. package/utils/EntityComparator.d.ts +81 -98
  186. package/utils/EntityComparator.js +735 -829
  187. package/utils/NullHighlighter.d.ts +1 -1
  188. package/utils/NullHighlighter.js +3 -3
  189. package/utils/QueryHelper.d.ts +51 -79
  190. package/utils/QueryHelper.js +361 -372
  191. package/utils/RawQueryFragment.d.ts +34 -50
  192. package/utils/RawQueryFragment.js +105 -107
  193. package/utils/RequestContext.d.ts +32 -32
  194. package/utils/RequestContext.js +53 -52
  195. package/utils/TransactionContext.d.ts +16 -16
  196. package/utils/TransactionContext.js +27 -27
  197. package/utils/TransactionManager.d.ts +58 -58
  198. package/utils/TransactionManager.js +197 -199
  199. package/utils/Utils.d.ts +145 -204
  200. package/utils/Utils.js +815 -815
  201. package/utils/clone.js +114 -105
  202. package/utils/env-vars.js +88 -90
  203. package/utils/fs-utils.d.ts +15 -15
  204. package/utils/fs-utils.js +181 -180
  205. package/utils/upsert-utils.d.ts +5 -20
  206. package/utils/upsert-utils.js +116 -114
@@ -1,70 +1,17 @@
1
1
  import type { EntityManager } from '../EntityManager.js';
2
- import type {
3
- ColumnType,
4
- PropertyOptions,
5
- ReferenceOptions,
6
- EnumOptions,
7
- EmbeddedOptions,
8
- ManyToOneOptions,
9
- OneToManyOptions,
10
- OneToOneOptions,
11
- ManyToManyOptions,
12
- IndexColumnOptions,
13
- } from '../metadata/types.js';
14
- import type {
15
- AnyString,
16
- GeneratedColumnCallback,
17
- Constructor,
18
- CheckCallback,
19
- FilterQuery,
20
- EntityName,
21
- Dictionary,
22
- EntityMetadata,
23
- PrimaryKeyProp,
24
- EntityRepositoryType,
25
- Hidden,
26
- Opt,
27
- Primary,
28
- EntityClass,
29
- EntitySchemaWithMeta,
30
- InferEntity,
31
- MaybeReturnType,
32
- Ref,
33
- IndexCallback,
34
- FormulaCallback,
35
- EntityCtor,
36
- IsNever,
37
- IWrappedEntity,
38
- DefineConfig,
39
- Config,
40
- MaybePromise,
41
- } from '../typings.js';
2
+ import type { ColumnType, PropertyOptions, ReferenceOptions, EnumOptions, EmbeddedOptions, ManyToOneOptions, OneToManyOptions, OneToOneOptions, ManyToManyOptions, IndexColumnOptions } from '../metadata/types.js';
3
+ import type { AnyString, GeneratedColumnCallback, Constructor, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata, PrimaryKeyProp, EntityRepositoryType, Hidden, Opt, Primary, EntityClass, EntitySchemaWithMeta, InferEntity, MaybeReturnType, Ref, IndexCallback, FormulaCallback, EntityCtor, IsNever, IWrappedEntity, DefineConfig, Config, MaybePromise } from '../typings.js';
42
4
  import type { Raw } from '../utils/RawQueryFragment.js';
43
5
  import type { ScalarReference } from './Reference.js';
44
6
  import type { SerializeOptions } from '../serialization/EntitySerializer.js';
45
- import type {
46
- Cascade,
47
- DeferMode,
48
- EmbeddedPrefixMode,
49
- LoadStrategy,
50
- QueryOrderKeysFlat,
51
- QueryOrderMap,
52
- } from '../enums.js';
7
+ import type { Cascade, DeferMode, EmbeddedPrefixMode, LoadStrategy, QueryOrderKeysFlat, QueryOrderMap } from '../enums.js';
53
8
  import type { EventSubscriber } from '../events/EventSubscriber.js';
54
9
  import type { IType, Type } from '../types/Type.js';
55
10
  import { types } from '../types/index.js';
56
11
  import type { Collection } from './Collection.js';
57
12
  import type { FilterOptions, FindOptions, FindOneOptions } from '../drivers/IDatabaseDriver.js';
58
13
  /** Union of all option keys supported across all property definition types (scalar, enum, embedded, relations). */
59
- export type UniversalPropertyKeys =
60
- | keyof PropertyOptions<any>
61
- | keyof EnumOptions<any>
62
- | keyof EmbeddedOptions<any, any>
63
- | keyof ReferenceOptions<any, any>
64
- | keyof ManyToOneOptions<any, any>
65
- | keyof OneToManyOptions<any, any>
66
- | keyof OneToOneOptions<any, any>
67
- | keyof ManyToManyOptions<any, any>;
14
+ 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>;
68
15
  type BuilderExtraKeys = '~options' | '~type' | '$type' | 'strictNullable';
69
16
  type ExcludeKeys = 'entity' | 'items';
70
17
  type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
@@ -72,1369 +19,733 @@ type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> |
72
19
  type IncludeKeysForEnumOptions = Exclude<keyof EnumOptions<any>, ExcludeKeys> | BuilderExtraKeys;
73
20
  type IncludeKeysForOneToManyOptions = Exclude<keyof OneToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
74
21
  type HasKind<Options, K extends string> = Options extends {
75
- kind: infer X extends string;
76
- }
77
- ? X extends K
78
- ? true
79
- : false
80
- : false;
22
+ kind: infer X extends string;
23
+ } ? X extends K ? true : false : false;
81
24
  /** Lightweight chain result type for property builders - reduces type instantiation cost by avoiding full class resolution. */
82
25
  export interface PropertyChain<Value, Options> {
83
- '~type'?: {
84
- value: Value;
85
- };
86
- '~options': Options;
87
- $type<T>(): PropertyChain<T, Options>;
88
- $type<Runtime, Raw, Serialized = Raw>(): PropertyChain<IType<Runtime, Raw, Serialized>, Options>;
89
- nullable(): PropertyChain<
90
- Value,
91
- Omit<Options, 'nullable'> & {
92
- nullable: true;
93
- }
94
- >;
95
- strictNullable(): PropertyChain<
96
- Value,
97
- Omit<Options, 'nullable' | 'strictNullable'> & {
98
- nullable: true;
99
- strictNullable: true;
100
- }
101
- >;
102
- ref(): PropertyChain<
103
- Value,
104
- Omit<Options, 'ref'> & {
105
- ref: true;
106
- }
107
- >;
108
- primary(): PropertyChain<
109
- Value,
110
- Omit<Options, 'primary'> & {
111
- primary: true;
112
- }
113
- >;
114
- hidden(): PropertyChain<
115
- Value,
116
- Omit<Options, 'hidden'> & {
117
- hidden: true;
118
- }
119
- >;
120
- autoincrement(): PropertyChain<
121
- Value,
122
- Omit<Options, 'autoincrement'> & {
123
- autoincrement: true;
124
- }
125
- >;
126
- autoincrement(autoincrement: false): PropertyChain<
127
- Value,
128
- Omit<Options, 'autoincrement'> & {
129
- autoincrement: false;
130
- }
131
- >;
132
- persist(): PropertyChain<
133
- Value,
134
- Omit<Options, 'persist'> & {
135
- persist: true;
136
- }
137
- >;
138
- persist(persist: false): PropertyChain<
139
- Value,
140
- Omit<Options, 'persist'> & {
141
- persist: false;
142
- }
143
- >;
144
- version(): PropertyChain<
145
- Value,
146
- Omit<Options, 'version'> & {
147
- version: true;
148
- }
149
- >;
150
- lazy(): PropertyChain<Value, Options>;
151
- name<T extends string>(
152
- name: T,
153
- ): PropertyChain<
154
- Value,
155
- Omit<Options, 'fieldName'> & {
156
- fieldName: T;
157
- }
158
- >;
159
- fieldName<T extends string>(
160
- fieldName: T,
161
- ): PropertyChain<
162
- Value,
163
- Omit<Options, 'fieldName'> & {
164
- fieldName: T;
165
- }
166
- >;
167
- onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyChain<
168
- Value,
169
- Options & {
170
- onCreate: (...args: any[]) => any;
171
- }
172
- >;
173
- default(defaultValue: string | string[] | number | number[] | boolean | null | Date | Raw): PropertyChain<
174
- Value,
175
- Omit<Options, 'default'> & {
176
- default: any;
177
- }
178
- >;
179
- defaultRaw(defaultRaw: string): PropertyChain<
180
- Value,
181
- Options & {
182
- defaultRaw: string;
183
- }
184
- >;
185
- formula(formula: string | FormulaCallback<any>): PropertyChain<
186
- Value,
187
- Omit<Options, 'formula'> & {
188
- formula: any;
189
- }
190
- >;
191
- onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyChain<Value, Options>;
192
- fieldNames(...fieldNames: string[]): PropertyChain<Value, Options>;
193
- type(type: PropertyValueType): PropertyChain<Value, Options>;
194
- runtimeType(runtimeType: string): PropertyChain<Value, Options>;
195
- columnType(columnType: ColumnType | AnyString): PropertyChain<Value, Options>;
196
- columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyChain<Value, Options>;
197
- length(length: number): PropertyChain<Value, Options>;
198
- precision(precision: number): PropertyChain<Value, Options>;
199
- scale(scale: number): PropertyChain<Value, Options>;
200
- returning(returning?: boolean): PropertyChain<Value, Options>;
201
- unsigned(unsigned?: boolean): PropertyChain<Value, Options>;
202
- hydrate(hydrate?: boolean): PropertyChain<Value, Options>;
203
- concurrencyCheck(concurrencyCheck?: boolean): PropertyChain<Value, Options>;
204
- generated(generated: string | GeneratedColumnCallback<any>): PropertyChain<Value, Options>;
205
- check(check: string | CheckCallback<any>): PropertyChain<Value, Options>;
206
- setter(setter?: boolean): PropertyChain<Value, Options>;
207
- getter(getter?: boolean): PropertyChain<Value, Options>;
208
- getterName(getterName: string): PropertyChain<Value, Options>;
209
- serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyChain<Value, Options>;
210
- serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyChain<Value, Options>;
211
- serializedName(serializedName: string): PropertyChain<Value, Options>;
212
- groups(...groups: string[]): PropertyChain<Value, Options>;
213
- customOrder(...customOrder: string[] | number[] | boolean[]): PropertyChain<Value, Options>;
214
- extra(extra: string): PropertyChain<Value, Options>;
215
- ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyChain<Value, Options>;
216
- index(index?: boolean | string): PropertyChain<Value, Options>;
217
- unique(unique?: boolean | string): PropertyChain<Value, Options>;
218
- comment(comment: string): PropertyChain<Value, Options>;
219
- accessor(accessor?: string | boolean): PropertyChain<Value, Options>;
220
- eager(
221
- eager?: boolean,
222
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
223
- cascade(
224
- ...cascade: Cascade[]
225
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
226
- strategy(
227
- strategy: LoadStrategy | `${LoadStrategy}`,
228
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
229
- filters(
230
- filters: FilterOptions,
231
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
232
- mappedBy(
233
- mappedBy: (keyof Value & string) | ((e: Value) => any),
234
- ): HasKind<Options, '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
235
- inversedBy(
236
- inversedBy: (keyof Value & string) | ((e: Value) => any),
237
- ): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
238
- owner(): HasKind<Options, '1:1' | 'm:n'> extends true
239
- ? PropertyChain<
240
- Value,
241
- Omit<Options, 'owner'> & {
242
- owner: true;
243
- }
244
- >
245
- : never;
246
- mapToPk(): HasKind<Options, 'm:1' | '1:1'> extends true
247
- ? PropertyChain<
248
- Value,
249
- Omit<Options, 'mapToPk'> & {
250
- mapToPk: true;
251
- }
252
- >
253
- : never;
254
- orphanRemoval(
255
- orphanRemoval?: boolean,
256
- ): HasKind<Options, '1:m' | '1:1'> extends true ? PropertyChain<Value, Options> : never;
257
- discriminator(
258
- discriminator: string,
259
- ): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
260
- discriminatorMap(
261
- discriminatorMap: Dictionary<string>,
262
- ): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
263
- pivotTable(pivotTable: string): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
264
- pivotEntity(
265
- pivotEntity: () => EntityName,
266
- ): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
267
- fixedOrder(fixedOrder?: boolean): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
268
- fixedOrderColumn(
269
- fixedOrderColumn: string,
270
- ): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
271
- array(): HasKind<Options, 'embedded' | 'enum'> extends true
272
- ? PropertyChain<
273
- Value,
274
- Omit<Options, 'array'> & {
275
- array: true;
276
- }
277
- >
278
- : never;
279
- prefix(prefix: string | boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
280
- prefixMode(
281
- prefixMode: EmbeddedPrefixMode,
282
- ): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
283
- object(object?: boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
284
- nativeEnumName(nativeEnumName: string): HasKind<Options, 'enum'> extends true ? PropertyChain<Value, Options> : never;
285
- orderBy(
286
- ...orderBy: QueryOrderMap<object>[]
287
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
288
- where(
289
- ...where: FilterQuery<object>[]
290
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
291
- joinColumn(
292
- joinColumn: string,
293
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
294
- joinColumns(
295
- ...joinColumns: string[]
296
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
297
- inverseJoinColumn(
298
- inverseJoinColumn: string,
299
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
300
- inverseJoinColumns(
301
- ...inverseJoinColumns: string[]
302
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
303
- referenceColumnName(
304
- referenceColumnName: string,
305
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
306
- referencedColumnNames(
307
- ...referencedColumnNames: string[]
308
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
309
- ownColumns(
310
- ...ownColumns: string[]
311
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
312
- targetKey(
313
- targetKey: keyof Value & string,
314
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
315
- deleteRule(
316
- deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
317
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
318
- updateRule(
319
- updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
320
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
321
- deferMode(
322
- deferMode: DeferMode | `${DeferMode}`,
323
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
324
- createForeignKeyConstraint(
325
- createForeignKeyConstraint?: boolean,
326
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
327
- foreignKeyName(
328
- foreignKeyName: string,
329
- ): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
26
+ '~type'?: {
27
+ value: Value;
28
+ };
29
+ '~options': Options;
30
+ $type<T>(): PropertyChain<T, Options>;
31
+ $type<Runtime, Raw, Serialized = Raw>(): PropertyChain<IType<Runtime, Raw, Serialized>, Options>;
32
+ nullable(): PropertyChain<Value, Omit<Options, 'nullable'> & {
33
+ nullable: true;
34
+ }>;
35
+ strictNullable(): PropertyChain<Value, Omit<Options, 'nullable' | 'strictNullable'> & {
36
+ nullable: true;
37
+ strictNullable: true;
38
+ }>;
39
+ ref(): PropertyChain<Value, Omit<Options, 'ref'> & {
40
+ ref: true;
41
+ }>;
42
+ primary(): PropertyChain<Value, Omit<Options, 'primary'> & {
43
+ primary: true;
44
+ }>;
45
+ hidden(): PropertyChain<Value, Omit<Options, 'hidden'> & {
46
+ hidden: true;
47
+ }>;
48
+ autoincrement(): PropertyChain<Value, Omit<Options, 'autoincrement'> & {
49
+ autoincrement: true;
50
+ }>;
51
+ autoincrement(autoincrement: false): PropertyChain<Value, Omit<Options, 'autoincrement'> & {
52
+ autoincrement: false;
53
+ }>;
54
+ persist(): PropertyChain<Value, Omit<Options, 'persist'> & {
55
+ persist: true;
56
+ }>;
57
+ persist(persist: false): PropertyChain<Value, Omit<Options, 'persist'> & {
58
+ persist: false;
59
+ }>;
60
+ version(): PropertyChain<Value, Omit<Options, 'version'> & {
61
+ version: true;
62
+ }>;
63
+ lazy(): PropertyChain<Value, Options>;
64
+ name<T extends string>(name: T): PropertyChain<Value, Omit<Options, 'fieldName'> & {
65
+ fieldName: T;
66
+ }>;
67
+ fieldName<T extends string>(fieldName: T): PropertyChain<Value, Omit<Options, 'fieldName'> & {
68
+ fieldName: T;
69
+ }>;
70
+ onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyChain<Value, Options & {
71
+ onCreate: (...args: any[]) => any;
72
+ }>;
73
+ default(defaultValue: string | string[] | number | number[] | boolean | null | Date | Raw): PropertyChain<Value, Omit<Options, 'default'> & {
74
+ default: any;
75
+ }>;
76
+ defaultRaw(defaultRaw: string): PropertyChain<Value, Options & {
77
+ defaultRaw: string;
78
+ }>;
79
+ formula(formula: string | FormulaCallback<any>): PropertyChain<Value, Omit<Options, 'formula'> & {
80
+ formula: any;
81
+ }>;
82
+ onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyChain<Value, Options>;
83
+ fieldNames(...fieldNames: string[]): PropertyChain<Value, Options>;
84
+ type(type: PropertyValueType): PropertyChain<Value, Options>;
85
+ runtimeType(runtimeType: string): PropertyChain<Value, Options>;
86
+ columnType(columnType: ColumnType | AnyString): PropertyChain<Value, Options>;
87
+ columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyChain<Value, Options>;
88
+ length(length: number): PropertyChain<Value, Options>;
89
+ precision(precision: number): PropertyChain<Value, Options>;
90
+ scale(scale: number): PropertyChain<Value, Options>;
91
+ returning(returning?: boolean): PropertyChain<Value, Options>;
92
+ unsigned(unsigned?: boolean): PropertyChain<Value, Options>;
93
+ hydrate(hydrate?: boolean): PropertyChain<Value, Options>;
94
+ concurrencyCheck(concurrencyCheck?: boolean): PropertyChain<Value, Options>;
95
+ generated(generated: string | GeneratedColumnCallback<any>): PropertyChain<Value, Options>;
96
+ check(check: string | CheckCallback<any>): PropertyChain<Value, Options>;
97
+ setter(setter?: boolean): PropertyChain<Value, Options>;
98
+ getter(getter?: boolean): PropertyChain<Value, Options>;
99
+ getterName(getterName: string): PropertyChain<Value, Options>;
100
+ serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyChain<Value, Options>;
101
+ serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyChain<Value, Options>;
102
+ serializedName(serializedName: string): PropertyChain<Value, Options>;
103
+ groups(...groups: string[]): PropertyChain<Value, Options>;
104
+ customOrder(...customOrder: string[] | number[] | boolean[]): PropertyChain<Value, Options>;
105
+ extra(extra: string): PropertyChain<Value, Options>;
106
+ ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyChain<Value, Options>;
107
+ index(index?: boolean | string): PropertyChain<Value, Options>;
108
+ unique(unique?: boolean | string): PropertyChain<Value, Options>;
109
+ comment(comment: string): PropertyChain<Value, Options>;
110
+ accessor(accessor?: string | boolean): PropertyChain<Value, Options>;
111
+ eager(eager?: boolean): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
112
+ cascade(...cascade: Cascade[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
113
+ strategy(strategy: LoadStrategy | `${LoadStrategy}`): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
114
+ filters(filters: FilterOptions): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
115
+ mappedBy(mappedBy: (keyof Value & string) | ((e: Value) => any)): HasKind<Options, '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
116
+ inversedBy(inversedBy: (keyof Value & string) | ((e: Value) => any)): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
117
+ owner(): HasKind<Options, '1:1' | 'm:n'> extends true ? PropertyChain<Value, Omit<Options, 'owner'> & {
118
+ owner: true;
119
+ }> : never;
120
+ mapToPk(): HasKind<Options, 'm:1' | '1:1'> extends true ? PropertyChain<Value, Omit<Options, 'mapToPk'> & {
121
+ mapToPk: true;
122
+ }> : never;
123
+ orphanRemoval(orphanRemoval?: boolean): HasKind<Options, '1:m' | '1:1'> extends true ? PropertyChain<Value, Options> : never;
124
+ discriminator(discriminator: string): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
125
+ discriminatorMap(discriminatorMap: Dictionary<string>): HasKind<Options, 'm:1' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
126
+ pivotTable(pivotTable: string): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
127
+ pivotEntity(pivotEntity: () => EntityName): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
128
+ fixedOrder(fixedOrder?: boolean): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
129
+ fixedOrderColumn(fixedOrderColumn: string): HasKind<Options, 'm:n'> extends true ? PropertyChain<Value, Options> : never;
130
+ array(): HasKind<Options, 'embedded' | 'enum'> extends true ? PropertyChain<Value, Omit<Options, 'array'> & {
131
+ array: true;
132
+ }> : never;
133
+ prefix(prefix: string | boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
134
+ prefixMode(prefixMode: EmbeddedPrefixMode): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
135
+ object(object?: boolean): HasKind<Options, 'embedded'> extends true ? PropertyChain<Value, Options> : never;
136
+ nativeEnumName(nativeEnumName: string): HasKind<Options, 'enum'> extends true ? PropertyChain<Value, Options> : never;
137
+ orderBy(...orderBy: QueryOrderMap<object>[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
138
+ where(...where: FilterQuery<object>[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
139
+ joinColumn(joinColumn: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
140
+ joinColumns(...joinColumns: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
141
+ inverseJoinColumn(inverseJoinColumn: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
142
+ inverseJoinColumns(...inverseJoinColumns: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
143
+ referenceColumnName(referenceColumnName: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
144
+ referencedColumnNames(...referencedColumnNames: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
145
+ ownColumns(...ownColumns: string[]): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
146
+ targetKey(targetKey: keyof Value & string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
147
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
148
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
149
+ deferMode(deferMode: DeferMode | `${DeferMode}`): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
150
+ createForeignKeyConstraint(createForeignKeyConstraint?: boolean): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
151
+ foreignKeyName(foreignKeyName: string): HasKind<Options, 'm:1' | '1:m' | '1:1' | 'm:n'> extends true ? PropertyChain<Value, Options> : never;
330
152
  }
331
153
  /** @internal */
332
- export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<
333
- Exclude<UniversalPropertyKeys, ExcludeKeys>,
334
- any
335
- > {
336
- '~options': Options;
337
- '~type'?: {
338
- value: Value;
339
- };
340
- constructor(options: any);
341
- protected assignOptions(options: EmptyOptions): any;
342
- /**
343
- * Set the TypeScript type of the property.
344
- */
345
- $type<T>(): UniversalPropertyOptionsBuilder<T, Options, IncludeKeys>;
346
- /**
347
- * Set the TypeScript type for custom types that map to objects.
348
- * This method provides type safety for custom types by specifying the runtime type,
349
- * raw database value type, and optional serialized type.
350
- *
351
- * @template Runtime - The runtime type that the property will have in JavaScript
352
- * @template Raw - The raw value type as stored in the database
353
- * @template Serialized - The type when serialized (defaults to Raw)
354
- * @returns PropertyOptionsBuilder with IType wrapper for type safety
355
- */
356
- $type<Runtime, Raw, Serialized = Raw>(): UniversalPropertyOptionsBuilder<
357
- IType<Runtime, Raw, Serialized>,
358
- Options,
359
- IncludeKeys
360
- >;
361
- /**
362
- * Alias for `fieldName`.
363
- */
364
- name<T extends string>(
365
- name: T,
366
- ): Pick<
367
- UniversalPropertyOptionsBuilder<
368
- Value,
369
- Omit<Options, 'fieldName'> & {
154
+ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<Exclude<UniversalPropertyKeys, ExcludeKeys>, any> {
155
+ '~options': Options;
156
+ '~type'?: {
157
+ value: Value;
158
+ };
159
+ constructor(options: any);
160
+ protected assignOptions(options: EmptyOptions): any;
161
+ /**
162
+ * Set the TypeScript type of the property.
163
+ */
164
+ $type<T>(): UniversalPropertyOptionsBuilder<T, Options, IncludeKeys>;
165
+ /**
166
+ * Set the TypeScript type for custom types that map to objects.
167
+ * This method provides type safety for custom types by specifying the runtime type,
168
+ * raw database value type, and optional serialized type.
169
+ *
170
+ * @template Runtime - The runtime type that the property will have in JavaScript
171
+ * @template Raw - The raw value type as stored in the database
172
+ * @template Serialized - The type when serialized (defaults to Raw)
173
+ * @returns PropertyOptionsBuilder with IType wrapper for type safety
174
+ */
175
+ $type<Runtime, Raw, Serialized = Raw>(): UniversalPropertyOptionsBuilder<IType<Runtime, Raw, Serialized>, Options, IncludeKeys>;
176
+ /**
177
+ * Alias for `fieldName`.
178
+ */
179
+ name<T extends string>(name: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'fieldName'> & {
370
180
  fieldName: T;
371
- },
372
- IncludeKeys
373
- >,
374
- IncludeKeys
375
- >;
376
- /**
377
- * Specify database column name for this property.
378
- *
379
- * @see https://mikro-orm.io/docs/naming-strategy
380
- */
381
- fieldName<T extends string>(
382
- fieldName: T,
383
- ): Pick<
384
- UniversalPropertyOptionsBuilder<
385
- Value,
386
- Omit<Options, 'fieldName'> & {
181
+ }, IncludeKeys>, IncludeKeys>;
182
+ /**
183
+ * Specify database column name for this property.
184
+ *
185
+ * @see https://mikro-orm.io/docs/naming-strategy
186
+ */
187
+ fieldName<T extends string>(fieldName: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'fieldName'> & {
387
188
  fieldName: T;
388
- },
389
- IncludeKeys
390
- >,
391
- IncludeKeys
392
- >;
393
- /**
394
- * Specify database column names for this property.
395
- * Same as `fieldName` but for composite FKs.
396
- *
397
- * @see https://mikro-orm.io/docs/naming-strategy
398
- */
399
- fieldNames(...fieldNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
400
- /**
401
- * 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)
402
- */
403
- columnType(
404
- columnType: ColumnType | AnyString,
405
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
406
- /**
407
- * 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)
408
- */
409
- columnTypes(
410
- ...columnTypes: (ColumnType | AnyString)[]
411
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
412
- /**
413
- * Explicitly specify the runtime type.
414
- *
415
- * @see https://mikro-orm.io/docs/metadata-providers
416
- * @see https://mikro-orm.io/docs/custom-types
417
- */
418
- type<TType extends PropertyValueType>(
419
- type: TType,
420
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
421
- /**
422
- * 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`.
423
- * 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`.
424
- */
425
- runtimeType(runtimeType: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
426
- /**
427
- * 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)
428
- */
429
- length(length: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
430
- /**
431
- * Set precision of database column to represent the number of significant digits. (SQL only)
432
- */
433
- precision(precision: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
434
- /**
435
- * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
436
- */
437
- scale(scale: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
438
- /**
439
- * Explicitly specify the auto increment of the primary key.
440
- */
441
- autoincrement(): Pick<
442
- UniversalPropertyOptionsBuilder<
443
- Value,
444
- Omit<Options, 'autoincrement'> & {
189
+ }, IncludeKeys>, IncludeKeys>;
190
+ /**
191
+ * Specify database column names for this property.
192
+ * Same as `fieldName` but for composite FKs.
193
+ *
194
+ * @see https://mikro-orm.io/docs/naming-strategy
195
+ */
196
+ fieldNames(...fieldNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
197
+ /**
198
+ * 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)
199
+ */
200
+ columnType(columnType: ColumnType | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
201
+ /**
202
+ * 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)
203
+ */
204
+ columnTypes(...columnTypes: (ColumnType | AnyString)[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
205
+ /**
206
+ * Explicitly specify the runtime type.
207
+ *
208
+ * @see https://mikro-orm.io/docs/metadata-providers
209
+ * @see https://mikro-orm.io/docs/custom-types
210
+ */
211
+ type<TType extends PropertyValueType>(type: TType): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
212
+ /**
213
+ * 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`.
214
+ * 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`.
215
+ */
216
+ runtimeType(runtimeType: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
217
+ /**
218
+ * 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)
219
+ */
220
+ length(length: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
221
+ /**
222
+ * Set precision of database column to represent the number of significant digits. (SQL only)
223
+ */
224
+ precision(precision: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
225
+ /**
226
+ * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
227
+ */
228
+ scale(scale: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
229
+ /**
230
+ * Explicitly specify the auto increment of the primary key.
231
+ */
232
+ autoincrement(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
445
233
  autoincrement: true;
446
- },
447
- IncludeKeys
448
- >,
449
- IncludeKeys
450
- >;
451
- autoincrement(autoincrement: false): Pick<
452
- UniversalPropertyOptionsBuilder<
453
- Value,
454
- Omit<Options, 'autoincrement'> & {
234
+ }, IncludeKeys>, IncludeKeys>;
235
+ autoincrement(autoincrement: false): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
455
236
  autoincrement: false;
456
- },
457
- IncludeKeys
458
- >,
459
- IncludeKeys
460
- >;
461
- /**
462
- * Add the property to the `returning` statement.
463
- */
464
- returning(returning?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
465
- /**
466
- * Automatically set the property value when entity gets created, executed during flush operation.
467
- */
468
- onCreate(onCreate: (entity: any, em: EntityManager) => Value): Pick<
469
- UniversalPropertyOptionsBuilder<
470
- Value,
471
- Options & {
237
+ }, IncludeKeys>, IncludeKeys>;
238
+ /**
239
+ * Add the property to the `returning` statement.
240
+ */
241
+ returning(returning?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
242
+ /**
243
+ * Automatically set the property value when entity gets created, executed during flush operation.
244
+ */
245
+ onCreate(onCreate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
472
246
  onCreate: (...args: any[]) => any;
473
- },
474
- IncludeKeys
475
- >,
476
- IncludeKeys
477
- >;
478
- /**
479
- * Automatically update the property value every time entity gets updated, executed during flush operation.
480
- */
481
- onUpdate(
482
- onUpdate: (entity: any, em: EntityManager) => Value,
483
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
484
- /**
485
- * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
486
- * This is a runtime value, assignable to the entity property. (SQL only)
487
- */
488
- default<T extends string | string[] | number | number[] | boolean | null | Date | Raw>(
489
- defaultValue: T,
490
- ): Pick<
491
- UniversalPropertyOptionsBuilder<
492
- Value,
493
- Omit<Options, 'default'> & {
247
+ }, IncludeKeys>, IncludeKeys>;
248
+ /**
249
+ * Automatically update the property value every time entity gets updated, executed during flush operation.
250
+ */
251
+ onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
252
+ /**
253
+ * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
254
+ * This is a runtime value, assignable to the entity property. (SQL only)
255
+ */
256
+ default<T extends string | string[] | number | number[] | boolean | null | Date | Raw>(defaultValue: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'default'> & {
494
257
  default: T;
495
- },
496
- IncludeKeys
497
- >,
498
- IncludeKeys
499
- >;
500
- /**
501
- * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
502
- * Since v4 you should use defaultRaw for SQL functions. e.g. now()
503
- */
504
- defaultRaw(defaultRaw: string): Pick<
505
- UniversalPropertyOptionsBuilder<
506
- Value,
507
- Options & {
258
+ }, IncludeKeys>, IncludeKeys>;
259
+ /**
260
+ * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
261
+ * Since v4 you should use defaultRaw for SQL functions. e.g. now()
262
+ */
263
+ defaultRaw(defaultRaw: string): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
508
264
  defaultRaw: string;
509
- },
510
- IncludeKeys
511
- >,
512
- IncludeKeys
513
- >;
514
- /**
515
- * Allow controlling `filters` option. This will be overridden with `em.fork` or `FindOptions` if provided.
516
- */
517
- filters(filters: FilterOptions): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
518
- /**
519
- * Set to map some SQL snippet for the entity.
520
- *
521
- * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
522
- */
523
- formula<T extends string | FormulaCallback<any>>(
524
- formula: T,
525
- ): Pick<
526
- UniversalPropertyOptionsBuilder<
527
- Value,
528
- Omit<Options, 'formula'> & {
265
+ }, IncludeKeys>, IncludeKeys>;
266
+ /**
267
+ * Allow controlling `filters` option. This will be overridden with `em.fork` or `FindOptions` if provided.
268
+ */
269
+ filters(filters: FilterOptions): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
270
+ /**
271
+ * Set to map some SQL snippet for the entity.
272
+ *
273
+ * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
274
+ */
275
+ formula<T extends string | FormulaCallback<any>>(formula: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'formula'> & {
529
276
  formula: T;
530
- },
531
- IncludeKeys
532
- >,
533
- IncludeKeys
534
- >;
535
- /**
536
- * For generated columns. This will be appended to the column type after the `generated always` clause.
537
- */
538
- generated(
539
- generated: string | GeneratedColumnCallback<any>,
540
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
541
- /**
542
- * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
543
- */
544
- nullable(): Pick<
545
- UniversalPropertyOptionsBuilder<
546
- Value,
547
- Omit<Options, 'nullable'> & {
277
+ }, IncludeKeys>, IncludeKeys>;
278
+ /**
279
+ * For generated columns. This will be appended to the column type after the `generated always` clause.
280
+ */
281
+ generated(generated: string | GeneratedColumnCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
282
+ /**
283
+ * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
284
+ */
285
+ nullable(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable'> & {
548
286
  nullable: true;
549
- },
550
- IncludeKeys
551
- >,
552
- IncludeKeys
553
- >;
554
- /**
555
- * Set column as nullable without adding `| undefined` to the type.
556
- * Use this when the property is always explicitly set (e.g. in constructor) but can be `null`.
557
- */
558
- strictNullable(): Pick<
559
- UniversalPropertyOptionsBuilder<
560
- Value,
561
- Omit<Options, 'nullable' | 'strictNullable'> & {
287
+ }, IncludeKeys>, IncludeKeys>;
288
+ /**
289
+ * Set column as nullable without adding `| undefined` to the type.
290
+ * Use this when the property is always explicitly set (e.g. in constructor) but can be `null`.
291
+ */
292
+ strictNullable(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable' | 'strictNullable'> & {
562
293
  nullable: true;
563
294
  strictNullable: true;
564
- },
565
- IncludeKeys
566
- >,
567
- IncludeKeys
568
- >;
569
- /**
570
- * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
571
- */
572
- unsigned(unsigned?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
573
- /**
574
- * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
575
- */
576
- persist(): Pick<
577
- UniversalPropertyOptionsBuilder<
578
- Value,
579
- Omit<Options, 'persist'> & {
295
+ }, IncludeKeys>, IncludeKeys>;
296
+ /**
297
+ * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
298
+ */
299
+ unsigned(unsigned?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
300
+ /**
301
+ * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
302
+ */
303
+ persist(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
580
304
  persist: true;
581
- },
582
- IncludeKeys
583
- >,
584
- IncludeKeys
585
- >;
586
- persist(persist: false): Pick<
587
- UniversalPropertyOptionsBuilder<
588
- Value,
589
- Omit<Options, 'persist'> & {
305
+ }, IncludeKeys>, IncludeKeys>;
306
+ persist(persist: false): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
590
307
  persist: false;
591
- },
592
- IncludeKeys
593
- >,
594
- IncludeKeys
595
- >;
596
- /**
597
- * Set false to disable hydration of this property. Useful for persisted getters.
598
- */
599
- hydrate(hydrate?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
600
- /**
601
- * 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.
602
- */
603
- ref(): UniversalPropertyOptionsBuilder<
604
- Value,
605
- Omit<Options, 'ref'> & {
606
- ref: true;
607
- },
608
- IncludeKeys
609
- >;
610
- /**
611
- * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
612
- */
613
- hidden(): Pick<
614
- UniversalPropertyOptionsBuilder<
615
- Value,
616
- Omit<Options, 'hidden'> & {
308
+ }, IncludeKeys>, IncludeKeys>;
309
+ /**
310
+ * Set false to disable hydration of this property. Useful for persisted getters.
311
+ */
312
+ hydrate(hydrate?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
313
+ /**
314
+ * 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.
315
+ */
316
+ ref(): UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
317
+ ref: true;
318
+ }, IncludeKeys>;
319
+ /**
320
+ * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
321
+ */
322
+ hidden(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'hidden'> & {
617
323
  hidden: true;
618
- },
619
- IncludeKeys
620
- >,
621
- IncludeKeys
622
- >;
623
- /**
624
- * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
625
- */
626
- version(): Pick<
627
- UniversalPropertyOptionsBuilder<
628
- Value,
629
- Omit<Options, 'version'> & {
324
+ }, IncludeKeys>, IncludeKeys>;
325
+ /**
326
+ * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
327
+ */
328
+ version(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'version'> & {
630
329
  version: true;
631
- },
632
- IncludeKeys
633
- >,
634
- IncludeKeys
635
- >;
636
- /**
637
- * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
638
- */
639
- concurrencyCheck(
640
- concurrencyCheck?: boolean,
641
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
642
- /**
643
- * Explicitly specify index on a property.
644
- */
645
- index(index?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
646
- /**
647
- * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
648
- */
649
- unique(unique?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
650
- /**
651
- * Specify column with check constraints. (Postgres driver only)
652
- *
653
- * @see https://mikro-orm.io/docs/defining-entities#check-constraints
654
- */
655
- check(
656
- check: string | CheckCallback<any>,
657
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
658
- /**
659
- * Set to omit the property from the select clause for lazy loading.
660
- *
661
- * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
662
- */
663
- lazy(): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
664
- /**
665
- * Set true to define entity's unique primary key identifier.
666
- *
667
- * @see https://mikro-orm.io/docs/decorators#primarykey
668
- */
669
- primary(): Pick<
670
- UniversalPropertyOptionsBuilder<
671
- Value,
672
- Omit<Options, 'primary'> & {
330
+ }, IncludeKeys>, IncludeKeys>;
331
+ /**
332
+ * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
333
+ */
334
+ concurrencyCheck(concurrencyCheck?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
335
+ /**
336
+ * Explicitly specify index on a property.
337
+ */
338
+ index(index?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
339
+ /**
340
+ * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
341
+ */
342
+ unique(unique?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
343
+ /**
344
+ * Specify column with check constraints. (Postgres driver only)
345
+ *
346
+ * @see https://mikro-orm.io/docs/defining-entities#check-constraints
347
+ */
348
+ check(check: string | CheckCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
349
+ /**
350
+ * Set to omit the property from the select clause for lazy loading.
351
+ *
352
+ * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
353
+ */
354
+ lazy(): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
355
+ /**
356
+ * Set true to define entity's unique primary key identifier.
357
+ *
358
+ * @see https://mikro-orm.io/docs/decorators#primarykey
359
+ */
360
+ primary(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'primary'> & {
673
361
  primary: true;
674
- },
675
- IncludeKeys
676
- >,
677
- IncludeKeys
678
- >;
679
- /**
680
- * Set true to define the properties as setter. (virtual)
681
- *
682
- * @example
683
- * ```
684
- * @Property({ setter: true })
685
- * set address(value: string) {
686
- * this._address = value.toLocaleLowerCase();
687
- * }
688
- * ```
689
- */
690
- setter(setter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
691
- /**
692
- * Set true to define the properties as getter. (virtual)
693
- *
694
- * @example
695
- * ```
696
- * @Property({ getter: true })
697
- * get fullName() {
698
- * return this.firstName + this.lastName;
699
- * }
700
- * ```
701
- */
702
- getter(getter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
703
- /**
704
- * When defining a property over a method (not a getter, a regular function), you can use this option to point
705
- * to the method name.
706
- *
707
- * @example
708
- * ```
709
- * @Property({ getter: true })
710
- * getFullName() {
711
- * return this.firstName + this.lastName;
712
- * }
713
- * ```
714
- */
715
- getterName(getterName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
716
- /**
717
- * Set to define serialized primary key for MongoDB. (virtual)
718
- * Alias for `@SerializedPrimaryKey()` decorator.
719
- *
720
- * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
721
- */
722
- serializedPrimaryKey(
723
- serializedPrimaryKey?: boolean,
724
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
725
- /**
726
- * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
727
- *
728
- * @see https://mikro-orm.io/docs/serializing#property-serializers
729
- */
730
- serializer(
731
- serializer: (value: Value, options?: SerializeOptions<any>) => any,
732
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
733
- /**
734
- * Specify name of key for the serialized value.
735
- */
736
- serializedName(
737
- serializedName: string,
738
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
739
- /**
740
- * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
741
- * otherwise only properties with a matching group are included.
742
- */
743
- groups(...groups: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
744
- /**
745
- * Specify a custom order based on the values. (SQL only)
746
- */
747
- customOrder(
748
- ...customOrder: string[] | number[] | boolean[]
749
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
750
- /**
751
- * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
752
- */
753
- comment(comment: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
754
- /** mysql only */
755
- extra(extra: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
756
- /**
757
- * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
758
- *
759
- * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
760
- */
761
- ignoreSchemaChanges(
762
- ...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]
763
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
764
- array(): Pick<
765
- UniversalPropertyOptionsBuilder<
766
- Value,
767
- Omit<Options, 'array'> & {
362
+ }, IncludeKeys>, IncludeKeys>;
363
+ /**
364
+ * Set true to define the properties as setter. (virtual)
365
+ *
366
+ * @example
367
+ * ```
368
+ * @Property({ setter: true })
369
+ * set address(value: string) {
370
+ * this._address = value.toLocaleLowerCase();
371
+ * }
372
+ * ```
373
+ */
374
+ setter(setter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
375
+ /**
376
+ * Set true to define the properties as getter. (virtual)
377
+ *
378
+ * @example
379
+ * ```
380
+ * @Property({ getter: true })
381
+ * get fullName() {
382
+ * return this.firstName + this.lastName;
383
+ * }
384
+ * ```
385
+ */
386
+ getter(getter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
387
+ /**
388
+ * When defining a property over a method (not a getter, a regular function), you can use this option to point
389
+ * to the method name.
390
+ *
391
+ * @example
392
+ * ```
393
+ * @Property({ getter: true })
394
+ * getFullName() {
395
+ * return this.firstName + this.lastName;
396
+ * }
397
+ * ```
398
+ */
399
+ getterName(getterName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
400
+ /**
401
+ * Set to define serialized primary key for MongoDB. (virtual)
402
+ * Alias for `@SerializedPrimaryKey()` decorator.
403
+ *
404
+ * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
405
+ */
406
+ serializedPrimaryKey(serializedPrimaryKey?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
407
+ /**
408
+ * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
409
+ *
410
+ * @see https://mikro-orm.io/docs/serializing#property-serializers
411
+ */
412
+ serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
413
+ /**
414
+ * Specify name of key for the serialized value.
415
+ */
416
+ serializedName(serializedName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
417
+ /**
418
+ * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
419
+ * otherwise only properties with a matching group are included.
420
+ */
421
+ groups(...groups: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
422
+ /**
423
+ * Specify a custom order based on the values. (SQL only)
424
+ */
425
+ customOrder(...customOrder: string[] | number[] | boolean[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
426
+ /**
427
+ * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
428
+ */
429
+ comment(comment: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
430
+ /** mysql only */
431
+ extra(extra: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
432
+ /**
433
+ * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
434
+ *
435
+ * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
436
+ */
437
+ ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
438
+ array(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'array'> & {
768
439
  array: true;
769
- },
770
- IncludeKeys
771
- >,
772
- IncludeKeys
773
- >;
774
- /** for postgres, by default it uses text column with check constraint */
775
- nativeEnumName(
776
- nativeEnumName: string,
777
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
778
- prefix(prefix: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
779
- prefixMode(
780
- prefixMode: EmbeddedPrefixMode,
781
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
782
- object(object?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
783
- /** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
784
- cascade(...cascade: Cascade[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
785
- /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
786
- eager(eager?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
787
- /** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
788
- strategy(
789
- strategy: LoadStrategy | `${LoadStrategy}`,
790
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
791
- /** 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. */
792
- owner(): Pick<
793
- UniversalPropertyOptionsBuilder<
794
- Value,
795
- Omit<Options, 'owner'> & {
440
+ }, IncludeKeys>, IncludeKeys>;
441
+ /** for postgres, by default it uses text column with check constraint */
442
+ nativeEnumName(nativeEnumName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
443
+ prefix(prefix: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
444
+ prefixMode(prefixMode: EmbeddedPrefixMode): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
445
+ object(object?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
446
+ /** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
447
+ cascade(...cascade: Cascade[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
448
+ /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
449
+ eager(eager?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
450
+ /** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
451
+ strategy(strategy: LoadStrategy | `${LoadStrategy}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
452
+ /** 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. */
453
+ owner(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'owner'> & {
796
454
  owner: true;
797
- },
798
- IncludeKeys
799
- >,
800
- IncludeKeys
801
- >;
802
- /** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
803
- discriminator(discriminator: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
804
- /** For polymorphic relations. Custom mapping of discriminator values to entity class names. */
805
- discriminatorMap(
806
- discriminatorMap: Dictionary<string>,
807
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
808
- /** Point to the inverse side property name. */
809
- inversedBy(
810
- inversedBy: keyof Value | ((e: Value) => any),
811
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
812
- /** Point to the owning side property name. */
813
- mappedBy(
814
- mappedBy: keyof Value | ((e: Value) => any),
815
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
816
- /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
817
- where(
818
- ...where: FilterQuery<object>[]
819
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
820
- /** Set default ordering. */
821
- orderBy(
822
- ...orderBy: QueryOrderMap<object>[]
823
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
824
- /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
825
- fixedOrder(fixedOrder?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
826
- /** Override default order column name (`id`) for fixed ordering. */
827
- fixedOrderColumn(
828
- fixedOrderColumn: string,
829
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
830
- /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
831
- pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
832
- /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
833
- pivotEntity(
834
- pivotEntity: () => EntityName,
835
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
836
- /** 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. */
837
- joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
838
- /** 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. */
839
- joinColumns(
840
- ...joinColumns: string[]
841
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
842
- /** 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. */
843
- inverseJoinColumn(
844
- inverseJoinColumn: string,
845
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
846
- /** 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. */
847
- inverseJoinColumns(
848
- ...inverseJoinColumns: string[]
849
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
850
- /** 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. */
851
- referenceColumnName(
852
- referenceColumnName: string,
853
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
854
- /** 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. */
855
- referencedColumnNames(
856
- ...referencedColumnNames: string[]
857
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
858
- /** Specify the property name on the target entity that this FK references instead of the primary key. */
859
- targetKey(targetKey: keyof Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
860
- /** What to do when the target entity gets deleted. */
861
- deleteRule(
862
- deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
863
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
864
- /** What to do when the reference to the target entity gets updated. */
865
- updateRule(
866
- updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString,
867
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
868
- /** Map this relation to the primary key value instead of an entity. */
869
- mapToPk(): Pick<
870
- UniversalPropertyOptionsBuilder<
871
- Value,
872
- Omit<Options, 'mapToPk'> & {
455
+ }, IncludeKeys>, IncludeKeys>;
456
+ /** For polymorphic relations. Specifies the property name that stores the entity type discriminator. Defaults to the property name. */
457
+ discriminator(discriminator: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
458
+ /** For polymorphic relations. Custom mapping of discriminator values to entity class names. */
459
+ discriminatorMap(discriminatorMap: Dictionary<string>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
460
+ /** Point to the inverse side property name. */
461
+ inversedBy(inversedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
462
+ /** Point to the owning side property name. */
463
+ mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
464
+ /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
465
+ where(...where: FilterQuery<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
466
+ /** Set default ordering. */
467
+ orderBy(...orderBy: QueryOrderMap<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
468
+ /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
469
+ fixedOrder(fixedOrder?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
470
+ /** Override default order column name (`id`) for fixed ordering. */
471
+ fixedOrderColumn(fixedOrderColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
472
+ /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
473
+ pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
474
+ /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
475
+ pivotEntity(pivotEntity: () => EntityName): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
476
+ /** 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. */
477
+ joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
478
+ /** 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. */
479
+ joinColumns(...joinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
480
+ /** 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. */
481
+ inverseJoinColumn(inverseJoinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
482
+ /** 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. */
483
+ inverseJoinColumns(...inverseJoinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
484
+ /** 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. */
485
+ referenceColumnName(referenceColumnName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
486
+ /** 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. */
487
+ referencedColumnNames(...referencedColumnNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
488
+ /** Specify the property name on the target entity that this FK references instead of the primary key. */
489
+ targetKey(targetKey: keyof Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
490
+ /** What to do when the target entity gets deleted. */
491
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
492
+ /** What to do when the reference to the target entity gets updated. */
493
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
494
+ /** Map this relation to the primary key value instead of an entity. */
495
+ mapToPk(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'mapToPk'> & {
873
496
  mapToPk: true;
874
- },
875
- IncludeKeys
876
- >,
877
- IncludeKeys
878
- >;
879
- /** 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. */
880
- deferMode(
881
- deferMode: DeferMode | `${DeferMode}`,
882
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
883
- /** 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. */
884
- ownColumns(...ownColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
885
- /** Enable/disable foreign key constraint creation on this relation */
886
- createForeignKeyConstraint(
887
- createForeignKeyConstraint?: boolean,
888
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
889
- /** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
890
- foreignKeyName(
891
- foreignKeyName: string,
892
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
893
- /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
894
- orphanRemoval(
895
- orphanRemoval?: boolean,
896
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
897
- accessor(
898
- accessor?: string | boolean,
899
- ): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
497
+ }, IncludeKeys>, IncludeKeys>;
498
+ /** 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. */
499
+ deferMode(deferMode: DeferMode | `${DeferMode}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
500
+ /** 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. */
501
+ ownColumns(...ownColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
502
+ /** Enable/disable foreign key constraint creation on this relation */
503
+ createForeignKeyConstraint(createForeignKeyConstraint?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
504
+ /** Set a custom foreign key constraint name, overriding NamingStrategy.indexName(). */
505
+ foreignKeyName(foreignKeyName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
506
+ /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
507
+ orphanRemoval(orphanRemoval?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
508
+ accessor(accessor?: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
900
509
  }
901
510
  /** Empty options object used as the initial state for property builders. */
902
- export interface EmptyOptions extends Partial<Record<UniversalPropertyKeys, unknown>> {}
511
+ export interface EmptyOptions extends Partial<Record<UniversalPropertyKeys, unknown>> {
512
+ }
903
513
  /** @internal */
904
- export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<
905
- Value,
906
- EmptyOptions & {
514
+ export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
907
515
  kind: '1:m';
908
- },
909
- IncludeKeysForOneToManyOptions
910
- > {
911
- /** Point to the owning side property name. */
912
- mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<
913
- UniversalPropertyOptionsBuilder<
914
- Value,
915
- EmptyOptions & {
516
+ }, IncludeKeysForOneToManyOptions> {
517
+ /** Point to the owning side property name. */
518
+ mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
916
519
  kind: '1:m';
917
- },
918
- IncludeKeysForOneToManyOptions
919
- >,
920
- IncludeKeysForOneToManyOptions
921
- >;
520
+ }, IncludeKeysForOneToManyOptions>, IncludeKeysForOneToManyOptions>;
922
521
  }
923
- type EntityTarget =
924
- | {
925
- '~entity': any;
926
- }
927
- | EntityClass;
522
+ type EntityTarget = {
523
+ '~entity': any;
524
+ } | EntityClass;
928
525
  declare const propertyBuilders: PropertyBuilders;
929
526
  type PropertyBuildersOverrideKeys = 'bigint' | 'array' | 'decimal' | 'json' | 'datetime' | 'time' | 'enum';
930
527
  /** Map of factory functions for creating type-safe property builders (scalars, enums, embeddables, and relations). */
931
528
  export type PropertyBuilders = {
932
- [K in Exclude<keyof typeof types, PropertyBuildersOverrideKeys>]: () => UniversalPropertyOptionsBuilder<
933
- InferPropertyValueType<(typeof types)[K]>,
934
- EmptyOptions,
935
- IncludeKeysForProperty
936
- >;
529
+ [K in Exclude<keyof typeof types, PropertyBuildersOverrideKeys>]: () => UniversalPropertyOptionsBuilder<InferPropertyValueType<(typeof types)[K]>, EmptyOptions, IncludeKeysForProperty>;
937
530
  } & {
938
- bigint: <Mode extends 'bigint' | 'number' | 'string' = 'bigint'>(
939
- mode?: Mode,
940
- ) => UniversalPropertyOptionsBuilder<
941
- InferPropertyValueType<typeof types.bigint<Mode>>,
942
- EmptyOptions,
943
- IncludeKeysForProperty
944
- >;
945
- array: <T = string>(
946
- toJsValue?: (i: string) => T,
947
- toDbValue?: (i: T) => string,
948
- ) => UniversalPropertyOptionsBuilder<
949
- InferPropertyValueType<typeof types.array<T>>,
950
- EmptyOptions,
951
- IncludeKeysForProperty
952
- >;
953
- decimal: <Mode extends 'number' | 'string' = 'string'>(
954
- mode?: Mode,
955
- ) => UniversalPropertyOptionsBuilder<
956
- InferPropertyValueType<typeof types.decimal<Mode>>,
957
- EmptyOptions,
958
- IncludeKeysForProperty
959
- >;
960
- json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
961
- formula: <T>(
962
- formula: string | FormulaCallback<any>,
963
- ) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
964
- datetime: (
965
- length?: number,
966
- ) => UniversalPropertyOptionsBuilder<
967
- InferPropertyValueType<typeof types.datetime>,
968
- EmptyOptions,
969
- IncludeKeysForProperty
970
- >;
971
- time: (
972
- length?: number,
973
- ) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.time>, EmptyOptions, IncludeKeysForProperty>;
974
- type: <T extends PropertyValueType>(
975
- type: T,
976
- ) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
977
- enum: <const T extends readonly (number | string)[] | (() => Dictionary)>(
978
- items?: T,
979
- ) => UniversalPropertyOptionsBuilder<
980
- T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends readonly (infer Value)[] ? Value : T,
981
- EmptyOptions,
982
- IncludeKeysForEnumOptions
983
- >;
984
- embedded: <Target extends EntityTarget | EntityTarget[]>(
985
- target: Target,
986
- ) => PropertyChain<
987
- InferEntity<Target extends (infer T)[] ? T : Target>,
988
- EmptyOptions & {
989
- kind: 'embedded';
990
- }
991
- >;
992
- manyToMany: <Target extends EntityTarget>(
993
- target: Target,
994
- ) => PropertyChain<
995
- InferEntity<Target>,
996
- EmptyOptions & {
997
- kind: 'm:n';
998
- }
999
- >;
1000
- manyToOne: <Target extends EntityTarget | EntityTarget[]>(
1001
- target: Target,
1002
- ) => PropertyChain<
1003
- InferEntity<Target extends (infer T)[] ? T : Target>,
1004
- EmptyOptions & {
1005
- kind: 'm:1';
1006
- }
1007
- >;
1008
- oneToMany: <Target extends EntityTarget>(
1009
- target: Target,
1010
- ) => PropertyChain<
1011
- InferEntity<Target>,
1012
- EmptyOptions & {
1013
- kind: '1:m';
1014
- }
1015
- >;
1016
- oneToOne: <Target extends EntityTarget | EntityTarget[]>(
1017
- target: Target,
1018
- ) => PropertyChain<
1019
- InferEntity<Target extends (infer T)[] ? T : Target>,
1020
- EmptyOptions & {
1021
- kind: '1:1';
1022
- }
1023
- >;
531
+ bigint: <Mode extends 'bigint' | 'number' | 'string' = 'bigint'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.bigint<Mode>>, EmptyOptions, IncludeKeysForProperty>;
532
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.array<T>>, EmptyOptions, IncludeKeysForProperty>;
533
+ decimal: <Mode extends 'number' | 'string' = 'string'>(mode?: Mode) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.decimal<Mode>>, EmptyOptions, IncludeKeysForProperty>;
534
+ json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
535
+ formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
536
+ datetime: (length?: number) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.datetime>, EmptyOptions, IncludeKeysForProperty>;
537
+ time: (length?: number) => UniversalPropertyOptionsBuilder<InferPropertyValueType<typeof types.time>, EmptyOptions, IncludeKeysForProperty>;
538
+ type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
539
+ enum: <const T extends readonly (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends readonly (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
540
+ embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
541
+ kind: 'embedded';
542
+ }>;
543
+ manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
544
+ kind: 'm:n';
545
+ }>;
546
+ manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
547
+ kind: 'm:1';
548
+ }>;
549
+ oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
550
+ kind: '1:m';
551
+ }>;
552
+ oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
553
+ kind: '1:1';
554
+ }>;
1024
555
  };
1025
556
  /** Own keys + base entity keys (when TBase is not `never`). Guards against `keyof never = string | number | symbol`. */
1026
557
  type AllKeys<TProperties, TBase> = keyof TProperties | (IsNever<TBase> extends true ? never : keyof TBase);
1027
558
  /** Metadata descriptor for `defineEntity()`, combining entity options with property definitions. */
1028
- export interface EntityMetadataWithProperties<
1029
- TName extends string,
1030
- TTableName extends string,
1031
- TProperties extends Record<string, any>,
1032
- TPK extends (keyof TProperties)[] | undefined = undefined,
1033
- TBase = never,
1034
- TRepository = never,
1035
- TForceObject extends boolean = false,
1036
- > extends Omit<
1037
- Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK, TBase, TRepository>>>,
1038
- | 'properties'
1039
- | 'extends'
1040
- | 'primaryKeys'
1041
- | 'hooks'
1042
- | 'discriminatorColumn'
1043
- | 'versionProperty'
1044
- | 'concurrencyCheckKeys'
1045
- | 'serializedPrimaryKey'
1046
- | 'indexes'
1047
- | 'uniques'
1048
- | 'repository'
1049
- | 'filters'
1050
- | 'orderBy'
1051
- > {
1052
- name: TName;
1053
- tableName?: TTableName;
1054
- extends?:
1055
- | {
559
+ export interface EntityMetadataWithProperties<TName extends string, TTableName extends string, TProperties extends Record<string, any>, TPK extends (keyof TProperties)[] | undefined = undefined, TBase = never, TRepository = never, TForceObject extends boolean = false> extends Omit<Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK, TBase, TRepository>>>, 'properties' | 'extends' | 'primaryKeys' | 'hooks' | 'discriminatorColumn' | 'versionProperty' | 'concurrencyCheckKeys' | 'serializedPrimaryKey' | 'indexes' | 'uniques' | 'repository' | 'filters' | 'orderBy'> {
560
+ name: TName;
561
+ tableName?: TTableName;
562
+ extends?: {
1056
563
  '~entity': TBase;
1057
- }
1058
- | EntityCtor<TBase>;
1059
- properties: TProperties | ((properties: PropertyBuilders) => TProperties);
1060
- primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
1061
- hooks?: DefineEntityHooks;
1062
- repository?: () => TRepository;
1063
- filters?: Dictionary<{
1064
- name: string;
1065
- cond:
1066
- | Dictionary
1067
- | ((
1068
- args: Dictionary,
1069
- type: 'read' | 'update' | 'delete',
1070
- em: any,
1071
- options?: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>,
1072
- entityName?: string,
1073
- ) => MaybePromise<FilterQuery<any>>);
1074
- default?: boolean;
1075
- entity?: EntityName<any> | EntityName<any>[];
1076
- args?: boolean;
1077
- strict?: boolean;
1078
- }>;
1079
- forceObject?: TForceObject;
1080
- inheritance?: 'tpt';
1081
- orderBy?:
1082
- | {
564
+ } | EntityCtor<TBase>;
565
+ properties: TProperties | ((properties: PropertyBuilders) => TProperties);
566
+ primaryKeys?: TPK & InferPrimaryKeyConstraint<TProperties>[];
567
+ hooks?: DefineEntityHooks;
568
+ repository?: () => TRepository;
569
+ filters?: Dictionary<{
570
+ name: string;
571
+ cond: Dictionary | ((args: Dictionary, type: 'read' | 'update' | 'delete', em: any, options?: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>, entityName?: string) => MaybePromise<FilterQuery<any>>);
572
+ default?: boolean;
573
+ entity?: EntityName<any> | EntityName<any>[];
574
+ args?: boolean;
575
+ strict?: boolean;
576
+ }>;
577
+ forceObject?: TForceObject;
578
+ inheritance?: 'tpt';
579
+ orderBy?: {
1083
580
  [K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
1084
- }
1085
- | {
581
+ } | {
1086
582
  [K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
1087
- }[];
1088
- discriminatorColumn?: string;
1089
- versionProperty?: AllKeys<TProperties, TBase>;
1090
- concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
1091
- serializedPrimaryKey?: AllKeys<TProperties, TBase>;
1092
- indexes?: {
1093
- properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1094
- name?: string;
1095
- type?: string;
1096
- options?: Dictionary;
1097
- expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
1098
- columns?: IndexColumnOptions[];
1099
- include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1100
- fillFactor?: number;
1101
- invisible?: boolean;
1102
- disabled?: boolean;
1103
- clustered?: boolean;
1104
- }[];
1105
- uniques?: {
1106
- properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1107
- name?: string;
1108
- options?: Dictionary;
1109
- expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
1110
- deferMode?: DeferMode | `${DeferMode}`;
1111
- columns?: IndexColumnOptions[];
1112
- include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1113
- fillFactor?: number;
1114
- disabled?: boolean;
1115
- }[];
583
+ }[];
584
+ discriminatorColumn?: string;
585
+ versionProperty?: AllKeys<TProperties, TBase>;
586
+ concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
587
+ serializedPrimaryKey?: AllKeys<TProperties, TBase>;
588
+ indexes?: {
589
+ properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
590
+ name?: string;
591
+ type?: string;
592
+ options?: Dictionary;
593
+ expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
594
+ columns?: IndexColumnOptions[];
595
+ include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
596
+ fillFactor?: number;
597
+ invisible?: boolean;
598
+ disabled?: boolean;
599
+ clustered?: boolean;
600
+ }[];
601
+ uniques?: {
602
+ properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
603
+ name?: string;
604
+ options?: Dictionary;
605
+ expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
606
+ deferMode?: DeferMode | `${DeferMode}`;
607
+ columns?: IndexColumnOptions[];
608
+ include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
609
+ fillFactor?: number;
610
+ disabled?: boolean;
611
+ }[];
1116
612
  }
1117
613
  /** Defines an entity schema using property builders, with full type inference from the property definitions. */
1118
- export declare function defineEntity<
1119
- const TName extends string,
1120
- const TTableName extends string,
1121
- const TProperties extends Record<string, any>,
1122
- const TPK extends (keyof TProperties)[] | undefined = undefined,
1123
- const TBase = never,
1124
- const TRepository = never,
1125
- const TForceObject extends boolean = false,
1126
- >(
1127
- meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase, TRepository, TForceObject>,
1128
- ): EntitySchemaWithMeta<
1129
- TName,
1130
- TTableName,
1131
- InferEntityFromProperties<TProperties, TPK, TBase, TRepository, TForceObject>,
1132
- TBase,
1133
- TProperties
1134
- >;
614
+ export declare function defineEntity<const TName extends string, const TTableName extends string, const TProperties extends Record<string, any>, const TPK extends (keyof TProperties)[] | undefined = undefined, const TBase = never, const TRepository = never, const TForceObject extends boolean = false>(meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase, TRepository, TForceObject>): EntitySchemaWithMeta<TName, TTableName, InferEntityFromProperties<TProperties, TPK, TBase, TRepository, TForceObject>, TBase, TProperties>;
1135
615
  /** Defines an entity schema for an existing class, combining the class with property builders. */
1136
- export declare function defineEntity<
1137
- const TEntity = any,
1138
- const TProperties extends Record<string, any> = Record<string, any>,
1139
- const TClassName extends string = string,
1140
- const TTableName extends string = string,
1141
- const TBase = never,
1142
- const TClass extends EntityCtor = EntityCtor<TEntity>,
1143
- >(
1144
- meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName' | 'hooks'> & {
616
+ export declare function defineEntity<const TEntity = any, const TProperties extends Record<string, any> = Record<string, any>, const TClassName extends string = string, const TTableName extends string = string, const TBase = never, const TClass extends EntityCtor = EntityCtor<TEntity>>(meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName' | 'hooks'> & {
1145
617
  class: TClass;
1146
618
  className?: TClassName;
1147
619
  tableName?: TTableName;
1148
620
  extends?: TBase;
1149
621
  properties: TProperties | ((properties: PropertyBuilders) => TProperties);
1150
622
  hooks?: DefineEntityHooks<TEntity>;
1151
- },
1152
- ): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
623
+ }): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
1153
624
  export declare namespace defineEntity {
1154
- var properties: PropertyBuilders;
625
+ var properties: PropertyBuilders;
1155
626
  }
1156
627
  /** Shorthand alias for `defineEntity.properties` - the property builders for use in `defineEntity()`. */
1157
628
  export { propertyBuilders as p };
1158
629
  type EntityHookValue<T, K extends keyof EventSubscriber<T>> = (keyof T | NonNullable<EventSubscriber<T>[K]>)[];
1159
630
  /** Lifecycle hook definitions for entities created via `defineEntity()`. */
1160
631
  export interface DefineEntityHooks<T = any> {
1161
- onInit?: EntityHookValue<T, 'onInit'>;
1162
- onLoad?: EntityHookValue<T, 'onLoad'>;
1163
- beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
1164
- afterCreate?: EntityHookValue<T, 'afterCreate'>;
1165
- beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
1166
- afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
1167
- beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
1168
- afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
1169
- beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
1170
- afterDelete?: EntityHookValue<T, 'afterDelete'>;
632
+ onInit?: EntityHookValue<T, 'onInit'>;
633
+ onLoad?: EntityHookValue<T, 'onLoad'>;
634
+ beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
635
+ afterCreate?: EntityHookValue<T, 'afterCreate'>;
636
+ beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
637
+ afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
638
+ beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
639
+ afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
640
+ beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
641
+ afterDelete?: EntityHookValue<T, 'afterDelete'>;
1171
642
  }
1172
643
  type PropertyValueType = PropertyOptions<any>['type'];
1173
- type InferPropertyValueType<T extends PropertyValueType> = T extends string
1174
- ? InferTypeByString<T>
1175
- : T extends NumberConstructor
1176
- ? number
1177
- : T extends StringConstructor
1178
- ? string
1179
- : T extends BooleanConstructor
1180
- ? boolean
1181
- : T extends DateConstructor
1182
- ? Date
1183
- : T extends ArrayConstructor
1184
- ? string[]
1185
- : T extends Constructor<infer TType>
1186
- ? TType extends Type<infer TValue, any>
1187
- ? NonNullable<TValue>
1188
- : TType
1189
- : T extends Type<infer TValue, any>
1190
- ? NonNullable<TValue>
1191
- : any;
1192
- type InferTypeByString<T extends string> = T extends keyof typeof types
1193
- ? InferJSType<(typeof types)[T]>
1194
- : InferColumnType<T>;
644
+ 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;
645
+ type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<(typeof types)[T]> : InferColumnType<T>;
1195
646
  type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
1196
- type InferColumnType<T extends string> = T extends
1197
- | 'int'
1198
- | 'int4'
1199
- | 'integer'
1200
- | 'bigint'
1201
- | 'int8'
1202
- | 'int2'
1203
- | 'tinyint'
1204
- | 'smallint'
1205
- | 'mediumint'
1206
- ? number
1207
- : T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4'
1208
- ? number
1209
- : T extends
1210
- | 'datetime'
1211
- | 'time'
1212
- | 'time with time zone'
1213
- | 'timestamp'
1214
- | 'timestamp with time zone'
1215
- | 'timetz'
1216
- | 'timestamptz'
1217
- | 'date'
1218
- | 'interval'
1219
- ? Date
1220
- : T extends
1221
- | 'ObjectId'
1222
- | 'objectId'
1223
- | 'character varying'
1224
- | 'varchar'
1225
- | 'char'
1226
- | 'character'
1227
- | 'uuid'
1228
- | 'text'
1229
- | 'tinytext'
1230
- | 'mediumtext'
1231
- | 'longtext'
1232
- | 'enum'
1233
- ? string
1234
- : T extends 'boolean' | 'bool' | 'bit'
1235
- ? boolean
1236
- : T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea'
1237
- ? Buffer
1238
- : T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry'
1239
- ? number[]
1240
- : T extends 'tsvector' | 'tsquery'
1241
- ? string[]
1242
- : T extends 'json' | 'jsonb'
1243
- ? any
1244
- : any;
647
+ 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;
1245
648
  type BaseEntityMethodKeys = 'toObject' | 'toPOJO' | 'serialize' | 'assign' | 'populate' | 'init' | 'toReference';
1246
649
  /** Infers the entity type from a `defineEntity()` properties map, resolving builders, base classes, and primary keys. */
1247
- export type InferEntityFromProperties<
1248
- Properties extends Record<string, any>,
1249
- PK extends (keyof Properties)[] | undefined = undefined,
1250
- Base = never,
1251
- Repository = never,
1252
- ForceObject extends boolean = false,
1253
- > = (IsNever<Base> extends true
1254
- ? {}
1255
- : Base extends {
1256
- toObject(...args: any[]): any;
1257
- }
1258
- ? Pick<
1259
- IWrappedEntity<
1260
- {
1261
- -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
1262
- } & {
1263
- [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
1264
- } & (IsNever<Repository> extends true
1265
- ? {}
1266
- : {
1267
- [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
1268
- }) &
1269
- Omit<Base, typeof PrimaryKeyProp>
1270
- >,
1271
- BaseEntityMethodKeys
1272
- >
1273
- : {}) & {
1274
- -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
650
+ export type InferEntityFromProperties<Properties extends Record<string, any>, PK extends (keyof Properties)[] | undefined = undefined, Base = never, Repository = never, ForceObject extends boolean = false> = (IsNever<Base> extends true ? {} : Base extends {
651
+ toObject(...args: any[]): any;
652
+ } ? Pick<IWrappedEntity<{
653
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
654
+ } & {
655
+ [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
656
+ } & (IsNever<Repository> extends true ? {} : {
657
+ [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
658
+ }) & Omit<Base, typeof PrimaryKeyProp>>, BaseEntityMethodKeys> : {}) & {
659
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
1275
660
  } & {
1276
- [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
1277
- } & (IsNever<Repository> extends true
1278
- ? {}
1279
- : {
1280
- [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
1281
- }) &
1282
- (IsNever<Base> extends true ? {} : Omit<Base, typeof PrimaryKeyProp>) &
1283
- (ForceObject extends true
1284
- ? {
1285
- [Config]?: DefineConfig<{
1286
- forceObject: true;
1287
- }>;
1288
- }
1289
- : {});
1290
- type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined
1291
- ? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>>
1292
- : PK;
661
+ [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
662
+ } & (IsNever<Repository> extends true ? {} : {
663
+ [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
664
+ }) & (IsNever<Base> extends true ? {} : Omit<Base, typeof PrimaryKeyProp>) & (ForceObject extends true ? {
665
+ [Config]?: DefineConfig<{
666
+ forceObject: true;
667
+ }>;
668
+ } : {});
669
+ type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined ? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>> : PK;
1293
670
  type ExtractBasePrimaryKey<Base> = Base extends {
1294
- [PrimaryKeyProp]?: infer BasePK;
1295
- }
1296
- ? BasePK
1297
- : never;
1298
- type CombinePrimaryKeys<ChildPK, BasePK> = [ChildPK] extends [never]
1299
- ? BasePK
1300
- : [BasePK] extends [never]
1301
- ? IsUnion<ChildPK> extends true
1302
- ? ChildPK[]
1303
- : ChildPK
1304
- : ChildPK | BasePK;
671
+ [PrimaryKeyProp]?: infer BasePK;
672
+ } ? BasePK : never;
673
+ type CombinePrimaryKeys<ChildPK, BasePK> = [ChildPK] extends [never] ? BasePK : [BasePK] extends [never] ? IsUnion<ChildPK> extends true ? ChildPK[] : ChildPK : ChildPK | BasePK;
1305
674
  /** Extracts the primary key property names from a properties map by finding builders with `primary: true`. */
1306
675
  export type InferPrimaryKey<Properties extends Record<string, any>> = {
1307
- [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
1308
- '~options': {
1309
- primary: true;
1310
- };
1311
- }
1312
- ? K
1313
- : never;
676
+ [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
677
+ '~options': {
678
+ primary: true;
679
+ };
680
+ } ? K : never;
681
+ }[keyof Properties];
682
+ /** Like InferPrimaryKey, but skips evaluating function return types to prevent circular inference (GH #7445). */
683
+ export type InferPrimaryKeyConstraint<Properties extends Record<string, any>> = {
684
+ [K in keyof Properties]: Properties[K] extends (...args: any) => any ? K : Properties[K] extends {
685
+ '~options': {
686
+ primary: true;
687
+ };
688
+ } ? K : never;
1314
689
  }[keyof Properties];
1315
690
  type InferBuilderValue<Builder> = Builder extends {
1316
- '~type'?: {
1317
- value: infer Value;
1318
- };
1319
- '~options'?: infer Options;
1320
- }
1321
- ? MaybeHidden<
1322
- MaybeOpt<
1323
- MaybeScalarRef<
1324
- MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>,
1325
- Options
1326
- >,
1327
- Options
1328
- >,
1329
- Options
1330
- >
1331
- : never;
691
+ '~type'?: {
692
+ value: infer Value;
693
+ };
694
+ '~options'?: infer Options;
695
+ } ? MaybeHidden<MaybeOpt<MaybeScalarRef<MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>, Options>, Options>, Options> : never;
1332
696
  type MaybeArray<Value, Options> = Options extends {
1333
- array: true;
1334
- }
1335
- ? Value[]
1336
- : Value;
697
+ array: true;
698
+ } ? Value[] : Value;
1337
699
  type MaybeMapToPk<Value, Options> = Options extends {
1338
- mapToPk: true;
1339
- }
1340
- ? Primary<Value>
1341
- : Value;
700
+ mapToPk: true;
701
+ } ? Primary<Value> : Value;
1342
702
  type MaybeNullable<Value, Options> = Options extends {
1343
- nullable: true;
1344
- }
1345
- ? Options extends {
1346
- strictNullable: true;
1347
- }
1348
- ? Value | null
1349
- : Value | null | undefined
1350
- : Value;
703
+ nullable: true;
704
+ } ? Options extends {
705
+ strictNullable: true;
706
+ } ? Value | null : Value | null | undefined : Value;
1351
707
  type MaybeRelationRef<Value, Options> = Options extends {
1352
- mapToPk: true;
1353
- }
1354
- ? Value
1355
- : Options extends {
1356
- ref: true;
1357
- kind: '1:1';
1358
- }
1359
- ? Value extends object
1360
- ? Ref<Value>
1361
- : never
1362
- : Options extends {
1363
- ref: true;
1364
- kind: 'm:1';
1365
- }
1366
- ? Value extends object
1367
- ? Ref<Value>
1368
- : never
1369
- : Options extends {
1370
- kind: '1:m';
1371
- }
1372
- ? Value extends object
1373
- ? Collection<Value>
1374
- : never
1375
- : Options extends {
1376
- kind: 'm:n';
1377
- }
1378
- ? Value extends object
1379
- ? Collection<Value>
1380
- : never
1381
- : Value;
708
+ mapToPk: true;
709
+ } ? Value : Options extends {
710
+ ref: true;
711
+ kind: '1:1';
712
+ } ? Value extends object ? Ref<Value> : never : Options extends {
713
+ ref: true;
714
+ kind: 'm:1';
715
+ } ? Value extends object ? Ref<Value> : never : Options extends {
716
+ kind: '1:m';
717
+ } ? Value extends object ? Collection<Value> : never : Options extends {
718
+ kind: 'm:n';
719
+ } ? Value extends object ? Collection<Value> : never : Value;
1382
720
  type MaybeScalarRef<Value, Options> = Options extends {
1383
- kind: '1:1' | 'm:1' | '1:m' | 'm:n';
1384
- }
1385
- ? Value
1386
- : Options extends {
1387
- ref: true;
1388
- }
1389
- ? ScalarReference<Value>
1390
- : Value;
1391
- type IsAllPropsOpt<T> = [Exclude<keyof T, symbol>] extends [never]
1392
- ? false
1393
- : {
1394
- [K in Exclude<keyof T, symbol>]-?: T[K] extends Opt ? never : K;
1395
- }[Exclude<keyof T, symbol>] extends never
1396
- ? true
1397
- : false;
721
+ kind: '1:1' | 'm:1' | '1:m' | 'm:n';
722
+ } ? Value : Options extends {
723
+ ref: true;
724
+ } ? ScalarReference<Value> : Value;
725
+ type IsAllPropsOpt<T> = [Exclude<keyof T, symbol>] extends [never] ? false : {
726
+ [K in Exclude<keyof T, symbol>]-?: T[K] extends Opt ? never : K;
727
+ }[Exclude<keyof T, symbol>] extends never ? true : false;
1398
728
  type MaybeOpt<Value, Options> = Options extends {
1399
- mapToPk: true;
1400
- }
1401
- ? Value extends Opt<infer OriginalValue>
1402
- ? OriginalValue
1403
- : Value
1404
- : Options extends
1405
- | {
1406
- autoincrement: true;
1407
- }
1408
- | {
1409
- onCreate: Function;
1410
- }
1411
- | {
1412
- default: string | string[] | number | number[] | boolean | null | Date | Raw;
1413
- }
1414
- | {
1415
- defaultRaw: string;
1416
- }
1417
- | {
1418
- persist: false;
1419
- }
1420
- | {
1421
- version: true;
1422
- }
1423
- | {
1424
- formula: string | ((...args: any[]) => any);
1425
- }
1426
- ? Opt<NonNullable<Value>> | Extract<Value, null | undefined>
1427
- : Options extends {
1428
- kind: 'embedded';
1429
- }
1430
- ? IsAllPropsOpt<Value> extends true
1431
- ? Opt<NonNullable<Value>> | Extract<Value, null | undefined>
1432
- : Value
1433
- : Value;
729
+ mapToPk: true;
730
+ } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Options extends {
731
+ autoincrement: true;
732
+ } | {
733
+ onCreate: Function;
734
+ } | {
735
+ default: string | string[] | number | number[] | boolean | null | Date | Raw;
736
+ } | {
737
+ defaultRaw: string;
738
+ } | {
739
+ persist: false;
740
+ } | {
741
+ version: true;
742
+ } | {
743
+ formula: string | ((...args: any[]) => any);
744
+ } ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Options extends {
745
+ kind: 'embedded';
746
+ } ? IsAllPropsOpt<Value> extends true ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Value : Value;
1434
747
  type MaybeHidden<Value, Options> = Options extends {
1435
- hidden: true;
1436
- }
1437
- ? Hidden<NonNullable<Value>> | Extract<Value, null | undefined>
1438
- : Value;
748
+ hidden: true;
749
+ } ? Hidden<NonNullable<Value>> | Extract<Value, null | undefined> : Value;
1439
750
  type ValueOf<T extends Dictionary> = T[keyof T];
1440
751
  type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;