@mikro-orm/core 7.0.2-dev.9 → 7.0.2

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