@mikro-orm/core 7.0.15 → 7.0.16-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 +584 -885
  2. package/EntityManager.js +1911 -1939
  3. package/MikroORM.d.ts +74 -103
  4. package/MikroORM.js +178 -177
  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 +305 -444
  20. package/entity/BaseEntity.d.ts +83 -120
  21. package/entity/BaseEntity.js +43 -43
  22. package/entity/Collection.d.ts +181 -215
  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 +413 -454
  28. package/entity/EntityHelper.d.ts +23 -35
  29. package/entity/EntityHelper.js +290 -302
  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 +786 -815
  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 +659 -1412
  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 -118
  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 +115 -115
  76. package/metadata/MetadataDiscovery.js +1931 -2013
  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 +340 -385
  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 +695 -715
  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 +746 -1268
  160. package/typings.js +233 -246
  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 +50 -69
  166. package/unit-of-work/ChangeSetPersister.js +446 -469
  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 +1226 -1240
  173. package/utils/AbstractMigrator.d.ts +92 -112
  174. package/utils/AbstractMigrator.js +288 -286
  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 +82 -99
  186. package/utils/EntityComparator.js +744 -836
  187. package/utils/NullHighlighter.d.ts +1 -1
  188. package/utils/NullHighlighter.js +3 -3
  189. package/utils/QueryHelper.d.ts +57 -85
  190. package/utils/QueryHelper.js +392 -404
  191. package/utils/RawQueryFragment.d.ts +34 -50
  192. package/utils/RawQueryFragment.js +121 -122
  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 +200 -202
  199. package/utils/Utils.d.ts +145 -204
  200. package/utils/Utils.js +826 -826
  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 +182 -181
  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,1440 +19,740 @@ 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
- TDiscriminatorColumn extends string | undefined = undefined,
1037
- TDiscriminatorValue extends string | number | undefined = undefined,
1038
- TBaseDiscriminatorColumn extends string | undefined = undefined,
1039
- > extends Omit<
1040
- Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK, TBase, TRepository>>>,
1041
- | 'properties'
1042
- | 'extends'
1043
- | 'primaryKeys'
1044
- | 'hooks'
1045
- | 'discriminatorColumn'
1046
- | 'discriminatorValue'
1047
- | 'versionProperty'
1048
- | 'concurrencyCheckKeys'
1049
- | 'serializedPrimaryKey'
1050
- | 'indexes'
1051
- | 'uniques'
1052
- | 'repository'
1053
- | 'filters'
1054
- | 'orderBy'
1055
- > {
1056
- name: TName;
1057
- tableName?: TTableName;
1058
- extends?:
1059
- | {
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, TDiscriminatorColumn extends string | undefined = undefined, TDiscriminatorValue extends string | number | undefined = undefined, TBaseDiscriminatorColumn extends string | undefined = undefined> extends Omit<Partial<EntityMetadata<InferEntityFromProperties<TProperties, TPK, TBase, TRepository>>>, 'properties' | 'extends' | 'primaryKeys' | 'hooks' | 'discriminatorColumn' | 'discriminatorValue' | 'versionProperty' | 'concurrencyCheckKeys' | 'serializedPrimaryKey' | 'indexes' | 'uniques' | 'repository' | 'filters' | 'orderBy'> {
560
+ name: TName;
561
+ tableName?: TTableName;
562
+ extends?: {
1060
563
  '~entity': TBase;
1061
564
  '~discriminatorColumn'?: TBaseDiscriminatorColumn;
1062
- }
1063
- | (EntityCtor<TBase> & {
565
+ } | (EntityCtor<TBase> & {
1064
566
  '~discriminatorColumn'?: TBaseDiscriminatorColumn;
1065
- });
1066
- properties: TProperties | ((properties: PropertyBuilders) => TProperties);
1067
- primaryKeys?: TPK & InferPrimaryKeyConstraint<TProperties>[];
1068
- hooks?: DefineEntityHooks;
1069
- repository?: () => TRepository;
1070
- filters?: Dictionary<{
1071
- name: string;
1072
- cond:
1073
- | Dictionary
1074
- | ((
1075
- args: Dictionary,
1076
- type: 'read' | 'update' | 'delete',
1077
- em: any,
1078
- options?: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>,
1079
- entityName?: string,
1080
- ) => MaybePromise<FilterQuery<any>>);
1081
- default?: boolean;
1082
- entity?: EntityName<any> | EntityName<any>[];
1083
- args?: boolean;
1084
- strict?: boolean;
1085
- }>;
1086
- forceObject?: TForceObject;
1087
- inheritance?: 'tpt';
1088
- orderBy?:
1089
- | {
567
+ });
568
+ properties: TProperties | ((properties: PropertyBuilders) => TProperties);
569
+ primaryKeys?: TPK & InferPrimaryKeyConstraint<TProperties>[];
570
+ hooks?: DefineEntityHooks;
571
+ repository?: () => TRepository;
572
+ filters?: Dictionary<{
573
+ name: string;
574
+ 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>>);
575
+ default?: boolean;
576
+ entity?: EntityName<any> | EntityName<any>[];
577
+ args?: boolean;
578
+ strict?: boolean;
579
+ }>;
580
+ forceObject?: TForceObject;
581
+ inheritance?: 'tpt';
582
+ orderBy?: {
1090
583
  [K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
1091
- }
1092
- | {
584
+ } | {
1093
585
  [K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
1094
- }[];
1095
- discriminatorColumn?: TDiscriminatorColumn;
1096
- discriminatorValue?: TDiscriminatorValue;
1097
- versionProperty?: AllKeys<TProperties, TBase>;
1098
- concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
1099
- serializedPrimaryKey?: AllKeys<TProperties, TBase>;
1100
- indexes?: {
1101
- properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1102
- name?: string;
1103
- type?: string;
1104
- options?: Dictionary;
1105
- expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
1106
- columns?: IndexColumnOptions[];
1107
- include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1108
- fillFactor?: number;
1109
- invisible?: boolean;
1110
- disabled?: boolean;
1111
- clustered?: boolean;
1112
- }[];
1113
- uniques?: {
1114
- properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1115
- name?: string;
1116
- options?: Dictionary;
1117
- expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
1118
- deferMode?: DeferMode | `${DeferMode}`;
1119
- columns?: IndexColumnOptions[];
1120
- include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
1121
- fillFactor?: number;
1122
- disabled?: boolean;
1123
- }[];
586
+ }[];
587
+ discriminatorColumn?: TDiscriminatorColumn;
588
+ discriminatorValue?: TDiscriminatorValue;
589
+ versionProperty?: AllKeys<TProperties, TBase>;
590
+ concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
591
+ serializedPrimaryKey?: AllKeys<TProperties, TBase>;
592
+ indexes?: {
593
+ properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
594
+ name?: string;
595
+ type?: string;
596
+ options?: Dictionary;
597
+ expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
598
+ columns?: IndexColumnOptions[];
599
+ include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
600
+ fillFactor?: number;
601
+ invisible?: boolean;
602
+ disabled?: boolean;
603
+ clustered?: boolean;
604
+ }[];
605
+ uniques?: {
606
+ properties?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
607
+ name?: string;
608
+ options?: Dictionary;
609
+ expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
610
+ deferMode?: DeferMode | `${DeferMode}`;
611
+ columns?: IndexColumnOptions[];
612
+ include?: NoInfer<AllKeys<TProperties, TBase>> | NoInfer<AllKeys<TProperties, TBase>>[];
613
+ fillFactor?: number;
614
+ disabled?: boolean;
615
+ }[];
1124
616
  }
1125
617
  /** Defines an entity schema using property builders, with full type inference from the property definitions. */
1126
- export declare function defineEntity<
1127
- const TName extends string,
1128
- const TTableName extends string,
1129
- const TProperties extends Record<string, any>,
1130
- const TPK extends (keyof TProperties)[] | undefined = undefined,
1131
- const TBase = never,
1132
- const TRepository = never,
1133
- const TForceObject extends boolean = false,
1134
- const TDiscriminatorColumn extends string | undefined = undefined,
1135
- const TDiscriminatorValue extends string | number | undefined = undefined,
1136
- const TBaseDiscriminatorColumn extends string | undefined = undefined,
1137
- >(
1138
- meta: EntityMetadataWithProperties<
1139
- TName,
1140
- TTableName,
1141
- TProperties,
1142
- TPK,
1143
- TBase,
1144
- TRepository,
1145
- TForceObject,
1146
- TDiscriminatorColumn,
1147
- TDiscriminatorValue,
1148
- TBaseDiscriminatorColumn
1149
- >,
1150
- ): EntitySchemaWithMeta<
1151
- TName,
1152
- TTableName,
1153
- InferEntityFromProperties<
1154
- TProperties,
1155
- TPK,
1156
- TBase,
1157
- TRepository,
1158
- TForceObject,
1159
- TBaseDiscriminatorColumn,
1160
- TDiscriminatorValue
1161
- >,
1162
- TBase,
1163
- TProperties,
1164
- EntityCtor<
1165
- InferEntityFromProperties<
1166
- TProperties,
1167
- TPK,
1168
- TBase,
1169
- TRepository,
1170
- TForceObject,
1171
- TBaseDiscriminatorColumn,
1172
- TDiscriminatorValue
1173
- >
1174
- >,
1175
- TDiscriminatorColumn
1176
- >;
618
+ 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, const TDiscriminatorColumn extends string | undefined = undefined, const TDiscriminatorValue extends string | number | undefined = undefined, const TBaseDiscriminatorColumn extends string | undefined = undefined>(meta: EntityMetadataWithProperties<TName, TTableName, TProperties, TPK, TBase, TRepository, TForceObject, TDiscriminatorColumn, TDiscriminatorValue, TBaseDiscriminatorColumn>): EntitySchemaWithMeta<TName, TTableName, InferEntityFromProperties<TProperties, TPK, TBase, TRepository, TForceObject, TBaseDiscriminatorColumn, TDiscriminatorValue>, TBase, TProperties, EntityCtor<InferEntityFromProperties<TProperties, TPK, TBase, TRepository, TForceObject, TBaseDiscriminatorColumn, TDiscriminatorValue>>, TDiscriminatorColumn>;
1177
619
  /** Defines an entity schema for an existing class, combining the class with property builders. */
1178
- export declare function defineEntity<
1179
- const TEntity = any,
1180
- const TProperties extends Record<string, any> = Record<string, any>,
1181
- const TClassName extends string = string,
1182
- const TTableName extends string = string,
1183
- const TBase = never,
1184
- const TClass extends EntityCtor = EntityCtor<TEntity>,
1185
- >(
1186
- meta: Omit<Partial<EntityMetadata<TEntity>>, 'properties' | 'extends' | 'className' | 'tableName' | 'hooks'> & {
620
+ 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'> & {
1187
621
  class: TClass;
1188
622
  className?: TClassName;
1189
623
  tableName?: TTableName;
1190
624
  extends?: TBase;
1191
625
  properties: TProperties | ((properties: PropertyBuilders) => TProperties);
1192
626
  hooks?: DefineEntityHooks<TEntity>;
1193
- },
1194
- ): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
627
+ }): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
1195
628
  export declare namespace defineEntity {
1196
- var properties: PropertyBuilders;
629
+ var properties: PropertyBuilders;
1197
630
  }
1198
631
  /** Shorthand alias for `defineEntity.properties` - the property builders for use in `defineEntity()`. */
1199
632
  export { propertyBuilders as p };
1200
633
  type EntityHookValue<T, K extends keyof EventSubscriber<T>> = (keyof T | NonNullable<EventSubscriber<T>[K]>)[];
1201
634
  /** Lifecycle hook definitions for entities created via `defineEntity()`. */
1202
635
  export interface DefineEntityHooks<T = any> {
1203
- onInit?: EntityHookValue<T, 'onInit'>;
1204
- onLoad?: EntityHookValue<T, 'onLoad'>;
1205
- beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
1206
- afterCreate?: EntityHookValue<T, 'afterCreate'>;
1207
- beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
1208
- afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
1209
- beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
1210
- afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
1211
- beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
1212
- afterDelete?: EntityHookValue<T, 'afterDelete'>;
636
+ onInit?: EntityHookValue<T, 'onInit'>;
637
+ onLoad?: EntityHookValue<T, 'onLoad'>;
638
+ beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
639
+ afterCreate?: EntityHookValue<T, 'afterCreate'>;
640
+ beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
641
+ afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
642
+ beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
643
+ afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
644
+ beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
645
+ afterDelete?: EntityHookValue<T, 'afterDelete'>;
1213
646
  }
1214
647
  type PropertyValueType = PropertyOptions<any>['type'];
1215
- type InferPropertyValueType<T extends PropertyValueType> = T extends string
1216
- ? InferTypeByString<T>
1217
- : T extends NumberConstructor
1218
- ? number
1219
- : T extends StringConstructor
1220
- ? string
1221
- : T extends BooleanConstructor
1222
- ? boolean
1223
- : T extends DateConstructor
1224
- ? Date
1225
- : T extends ArrayConstructor
1226
- ? string[]
1227
- : T extends Constructor<infer TType>
1228
- ? TType extends Type<infer TValue, any>
1229
- ? NonNullable<TValue>
1230
- : TType
1231
- : T extends Type<infer TValue, any>
1232
- ? NonNullable<TValue>
1233
- : any;
1234
- type InferTypeByString<T extends string> = T extends keyof typeof types
1235
- ? InferJSType<(typeof types)[T]>
1236
- : InferColumnType<T>;
648
+ 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;
649
+ type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<(typeof types)[T]> : InferColumnType<T>;
1237
650
  type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
1238
- type InferColumnType<T extends string> = T extends
1239
- | 'int'
1240
- | 'int4'
1241
- | 'integer'
1242
- | 'bigint'
1243
- | 'int8'
1244
- | 'int2'
1245
- | 'tinyint'
1246
- | 'smallint'
1247
- | 'mediumint'
1248
- ? number
1249
- : T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4'
1250
- ? number
1251
- : T extends
1252
- | 'datetime'
1253
- | 'time'
1254
- | 'time with time zone'
1255
- | 'timestamp'
1256
- | 'timestamp with time zone'
1257
- | 'timetz'
1258
- | 'timestamptz'
1259
- | 'date'
1260
- | 'interval'
1261
- ? Date
1262
- : T extends
1263
- | 'ObjectId'
1264
- | 'objectId'
1265
- | 'character varying'
1266
- | 'varchar'
1267
- | 'char'
1268
- | 'character'
1269
- | 'uuid'
1270
- | 'text'
1271
- | 'tinytext'
1272
- | 'mediumtext'
1273
- | 'longtext'
1274
- | 'enum'
1275
- ? string
1276
- : T extends 'boolean' | 'bool' | 'bit'
1277
- ? boolean
1278
- : T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea'
1279
- ? Buffer
1280
- : T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry'
1281
- ? number[]
1282
- : T extends 'tsvector' | 'tsquery'
1283
- ? string[]
1284
- : T extends 'json' | 'jsonb'
1285
- ? any
1286
- : any;
651
+ 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;
1287
652
  type BaseEntityMethodKeys = 'toObject' | 'toPOJO' | 'serialize' | 'assign' | 'populate' | 'init' | 'toReference';
1288
653
  /** Infers the entity type from a `defineEntity()` properties map, resolving builders, base classes, and primary keys. */
1289
- export type InferEntityFromProperties<
1290
- Properties extends Record<string, any>,
1291
- PK extends (keyof Properties)[] | undefined = undefined,
1292
- Base = never,
1293
- Repository = never,
1294
- ForceObject extends boolean = false,
1295
- BaseDiscriminatorColumn extends string | undefined = undefined,
1296
- DiscriminatorValue extends string | number | undefined = undefined,
1297
- > = (IsNever<Base> extends true
1298
- ? {}
1299
- : Base extends {
1300
- toObject(...args: any[]): any;
1301
- }
1302
- ? Pick<
1303
- IWrappedEntity<
1304
- {
1305
- -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
1306
- } & {
1307
- [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
1308
- } & (IsNever<Repository> extends true
1309
- ? {}
1310
- : {
1311
- [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
1312
- }) &
1313
- NarrowDiscriminator<Omit<Base, typeof PrimaryKeyProp>, BaseDiscriminatorColumn, DiscriminatorValue>
1314
- >,
1315
- BaseEntityMethodKeys
1316
- >
1317
- : {}) & {
1318
- -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
654
+ export type InferEntityFromProperties<Properties extends Record<string, any>, PK extends (keyof Properties)[] | undefined = undefined, Base = never, Repository = never, ForceObject extends boolean = false, BaseDiscriminatorColumn extends string | undefined = undefined, DiscriminatorValue extends string | number | undefined = undefined> = (IsNever<Base> extends true ? {} : Base extends {
655
+ toObject(...args: any[]): any;
656
+ } ? Pick<IWrappedEntity<{
657
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
658
+ } & {
659
+ [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
660
+ } & (IsNever<Repository> extends true ? {} : {
661
+ [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
662
+ }) & NarrowDiscriminator<Omit<Base, typeof PrimaryKeyProp>, BaseDiscriminatorColumn, DiscriminatorValue>>, BaseEntityMethodKeys> : {}) & {
663
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
1319
664
  } & {
1320
- [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
1321
- } & (IsNever<Repository> extends true
1322
- ? {}
1323
- : {
1324
- [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
1325
- }) &
1326
- (IsNever<Base> extends true
1327
- ? {}
1328
- : NarrowDiscriminator<Omit<Base, typeof PrimaryKeyProp>, BaseDiscriminatorColumn, DiscriminatorValue>) &
1329
- (ForceObject extends true
1330
- ? {
1331
- [Config]?: DefineConfig<{
1332
- forceObject: true;
1333
- }>;
1334
- }
1335
- : {});
1336
- type NarrowDiscriminator<Base, DiscColumn extends string | undefined, DiscValue> = DiscColumn extends string
1337
- ? DiscColumn extends keyof Base
1338
- ? DiscValue extends string | number
1339
- ? Omit<Base, DiscColumn> & {
1340
- [K in DiscColumn]: DiscValue;
1341
- }
1342
- : Base
1343
- : Base
1344
- : Base;
1345
- type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined
1346
- ? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>>
1347
- : PK;
665
+ [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
666
+ } & (IsNever<Repository> extends true ? {} : {
667
+ [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
668
+ }) & (IsNever<Base> extends true ? {} : NarrowDiscriminator<Omit<Base, typeof PrimaryKeyProp>, BaseDiscriminatorColumn, DiscriminatorValue>) & (ForceObject extends true ? {
669
+ [Config]?: DefineConfig<{
670
+ forceObject: true;
671
+ }>;
672
+ } : {});
673
+ type NarrowDiscriminator<Base, DiscColumn extends string | undefined, DiscValue> = DiscColumn extends string ? DiscColumn extends keyof Base ? DiscValue extends string | number ? Omit<Base, DiscColumn> & {
674
+ [K in DiscColumn]: DiscValue;
675
+ } : Base : Base : Base;
676
+ type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined ? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>> : PK;
1348
677
  type ExtractBasePrimaryKey<Base> = Base extends {
1349
- [PrimaryKeyProp]?: infer BasePK;
1350
- }
1351
- ? BasePK
1352
- : never;
1353
- type CombinePrimaryKeys<ChildPK, BasePK> = [ChildPK] extends [never]
1354
- ? BasePK
1355
- : [BasePK] extends [never]
1356
- ? IsUnion<ChildPK> extends true
1357
- ? ChildPK[]
1358
- : ChildPK
1359
- : ChildPK | BasePK;
678
+ [PrimaryKeyProp]?: infer BasePK;
679
+ } ? BasePK : never;
680
+ type CombinePrimaryKeys<ChildPK, BasePK> = [ChildPK] extends [never] ? BasePK : [BasePK] extends [never] ? IsUnion<ChildPK> extends true ? ChildPK[] : ChildPK : ChildPK | BasePK;
1360
681
  /** Extracts the primary key property names from a properties map by finding builders with `primary: true`. */
1361
682
  export type InferPrimaryKey<Properties extends Record<string, any>> = {
1362
- [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
1363
- '~options': {
1364
- primary: true;
1365
- };
1366
- }
1367
- ? K
1368
- : never;
683
+ [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
684
+ '~options': {
685
+ primary: true;
686
+ };
687
+ } ? K : never;
1369
688
  }[keyof Properties];
1370
689
  /** Like InferPrimaryKey, but skips evaluating function return types to prevent circular inference (GH #7445). */
1371
690
  export type InferPrimaryKeyConstraint<Properties extends Record<string, any>> = {
1372
- [K in keyof Properties]: Properties[K] extends (...args: any) => any
1373
- ? K
1374
- : Properties[K] extends {
1375
- '~options': {
691
+ [K in keyof Properties]: Properties[K] extends (...args: any) => any ? K : Properties[K] extends {
692
+ '~options': {
1376
693
  primary: true;
1377
- };
1378
- }
1379
- ? K
1380
- : never;
694
+ };
695
+ } ? K : never;
1381
696
  }[keyof Properties];
1382
697
  type InferBuilderValue<Builder> = Builder extends {
1383
- '~type'?: {
1384
- value: infer Value;
1385
- };
1386
- '~options'?: infer Options;
1387
- }
1388
- ? MaybeHidden<
1389
- MaybeOpt<
1390
- MaybeScalarRef<
1391
- MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>,
1392
- Options
1393
- >,
1394
- Options
1395
- >,
1396
- Options
1397
- >
1398
- : never;
698
+ '~type'?: {
699
+ value: infer Value;
700
+ };
701
+ '~options'?: infer Options;
702
+ } ? MaybeHidden<MaybeOpt<MaybeScalarRef<MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>, Options>, Options>, Options> : never;
1399
703
  type MaybeArray<Value, Options> = Options extends {
1400
- array: true;
1401
- }
1402
- ? Value[]
1403
- : Value;
704
+ array: true;
705
+ } ? Value[] : Value;
1404
706
  type MaybeMapToPk<Value, Options> = Options extends {
1405
- mapToPk: true;
1406
- }
1407
- ? Primary<Value>
1408
- : Value;
707
+ mapToPk: true;
708
+ } ? Primary<Value> : Value;
1409
709
  type MaybeNullable<Value, Options> = Options extends {
1410
- nullable: true;
1411
- }
1412
- ? Options extends {
1413
- strictNullable: true;
1414
- }
1415
- ? Value | null
1416
- : Value | null | undefined
1417
- : Value;
710
+ nullable: true;
711
+ } ? Options extends {
712
+ strictNullable: true;
713
+ } ? Value | null : Value | null | undefined : Value;
1418
714
  type MaybeRelationRef<Value, Options> = Options extends {
1419
- mapToPk: true;
1420
- }
1421
- ? Value
1422
- : Options extends {
1423
- ref: true;
1424
- kind: '1:1';
1425
- }
1426
- ? Value extends object
1427
- ? Ref<Value>
1428
- : never
1429
- : Options extends {
1430
- ref: true;
1431
- kind: 'm:1';
1432
- }
1433
- ? Value extends object
1434
- ? Ref<Value>
1435
- : never
1436
- : Options extends {
1437
- kind: '1:m';
1438
- }
1439
- ? Value extends object
1440
- ? Collection<Value>
1441
- : never
1442
- : Options extends {
1443
- kind: 'm:n';
1444
- }
1445
- ? Value extends object
1446
- ? Collection<Value>
1447
- : never
1448
- : Value;
715
+ mapToPk: true;
716
+ } ? Value : Options extends {
717
+ ref: true;
718
+ kind: '1:1';
719
+ } ? Value extends object ? Ref<Value> : never : Options extends {
720
+ ref: true;
721
+ kind: 'm:1';
722
+ } ? Value extends object ? Ref<Value> : never : Options extends {
723
+ kind: '1:m';
724
+ } ? Value extends object ? Collection<Value> : never : Options extends {
725
+ kind: 'm:n';
726
+ } ? Value extends object ? Collection<Value> : never : Value;
1449
727
  type MaybeScalarRef<Value, Options> = Options extends {
1450
- kind: '1:1' | 'm:1' | '1:m' | 'm:n';
1451
- }
1452
- ? Value
1453
- : Options extends {
1454
- ref: true;
1455
- }
1456
- ? ScalarReference<Value>
1457
- : Value;
1458
- type IsAllPropsOpt<T> = [Exclude<keyof T, symbol>] extends [never]
1459
- ? false
1460
- : {
1461
- [K in Exclude<keyof T, symbol>]-?: T[K] extends Opt ? never : K;
1462
- }[Exclude<keyof T, symbol>] extends never
1463
- ? true
1464
- : false;
728
+ kind: '1:1' | 'm:1' | '1:m' | 'm:n';
729
+ } ? Value : Options extends {
730
+ ref: true;
731
+ } ? ScalarReference<Value> : Value;
732
+ type IsAllPropsOpt<T> = [Exclude<keyof T, symbol>] extends [never] ? false : {
733
+ [K in Exclude<keyof T, symbol>]-?: T[K] extends Opt ? never : K;
734
+ }[Exclude<keyof T, symbol>] extends never ? true : false;
1465
735
  type MaybeOpt<Value, Options> = Options extends {
1466
- mapToPk: true;
1467
- }
1468
- ? Value extends Opt<infer OriginalValue>
1469
- ? OriginalValue
1470
- : Value
1471
- : Options extends
1472
- | {
1473
- autoincrement: true;
1474
- }
1475
- | {
1476
- onCreate: Function;
1477
- }
1478
- | {
1479
- default: string | string[] | number | number[] | boolean | null | Date | Raw;
1480
- }
1481
- | {
1482
- defaultRaw: string;
1483
- }
1484
- | {
1485
- persist: false;
1486
- }
1487
- | {
1488
- version: true;
1489
- }
1490
- | {
1491
- formula: string | ((...args: any[]) => any);
1492
- }
1493
- ? Opt<NonNullable<Value>> | Extract<Value, null | undefined>
1494
- : Options extends {
1495
- kind: 'embedded';
1496
- }
1497
- ? IsAllPropsOpt<Value> extends true
1498
- ? Opt<NonNullable<Value>> | Extract<Value, null | undefined>
1499
- : Value
1500
- : Value;
736
+ mapToPk: true;
737
+ } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Options extends {
738
+ autoincrement: true;
739
+ } | {
740
+ onCreate: Function;
741
+ } | {
742
+ default: string | string[] | number | number[] | boolean | null | Date | Raw;
743
+ } | {
744
+ defaultRaw: string;
745
+ } | {
746
+ persist: false;
747
+ } | {
748
+ version: true;
749
+ } | {
750
+ formula: string | ((...args: any[]) => any);
751
+ } ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Options extends {
752
+ kind: 'embedded';
753
+ } ? IsAllPropsOpt<Value> extends true ? Opt<NonNullable<Value>> | Extract<Value, null | undefined> : Value : Value;
1501
754
  type MaybeHidden<Value, Options> = Options extends {
1502
- hidden: true;
1503
- }
1504
- ? Hidden<NonNullable<Value>> | Extract<Value, null | undefined>
1505
- : Value;
1506
- type ValueOf<T extends Dictionary> = T[keyof T] extends infer V
1507
- ? V extends (...args: any[]) => any
1508
- ? never
1509
- : V
1510
- : never;
755
+ hidden: true;
756
+ } ? Hidden<NonNullable<Value>> | Extract<Value, null | undefined> : Value;
757
+ type ValueOf<T extends Dictionary> = T[keyof T] extends infer V ? V extends (...args: any[]) => any ? never : V : never;
1511
758
  type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;