@mikro-orm/core 7.0.4-dev.8 → 7.0.4

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