@mikro-orm/core 7.0.0-dev.32 → 7.0.0-dev.321

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 (216) hide show
  1. package/EntityManager.d.ts +71 -63
  2. package/EntityManager.js +365 -283
  3. package/MikroORM.d.ts +44 -35
  4. package/MikroORM.js +109 -142
  5. package/README.md +7 -4
  6. package/cache/FileCacheAdapter.d.ts +1 -2
  7. package/cache/FileCacheAdapter.js +19 -14
  8. package/cache/GeneratedCacheAdapter.d.ts +0 -1
  9. package/cache/GeneratedCacheAdapter.js +0 -2
  10. package/cache/index.d.ts +1 -2
  11. package/cache/index.js +0 -2
  12. package/connections/Connection.d.ts +12 -5
  13. package/connections/Connection.js +37 -15
  14. package/drivers/DatabaseDriver.d.ts +25 -18
  15. package/drivers/DatabaseDriver.js +144 -45
  16. package/drivers/IDatabaseDriver.d.ts +118 -23
  17. package/entity/BaseEntity.d.ts +63 -4
  18. package/entity/BaseEntity.js +0 -3
  19. package/entity/Collection.d.ts +101 -29
  20. package/entity/Collection.js +473 -115
  21. package/entity/EntityAssigner.js +37 -25
  22. package/entity/EntityFactory.d.ts +7 -1
  23. package/entity/EntityFactory.js +116 -64
  24. package/entity/EntityHelper.d.ts +2 -2
  25. package/entity/EntityHelper.js +69 -27
  26. package/entity/EntityLoader.d.ts +11 -10
  27. package/entity/EntityLoader.js +264 -102
  28. package/entity/EntityRepository.d.ts +28 -8
  29. package/entity/EntityRepository.js +8 -2
  30. package/entity/PolymorphicRef.d.ts +12 -0
  31. package/entity/PolymorphicRef.js +18 -0
  32. package/entity/Reference.d.ts +2 -6
  33. package/entity/Reference.js +52 -19
  34. package/entity/WrappedEntity.d.ts +3 -8
  35. package/entity/WrappedEntity.js +6 -7
  36. package/entity/defineEntity.d.ts +525 -311
  37. package/entity/defineEntity.js +134 -290
  38. package/entity/index.d.ts +2 -2
  39. package/entity/index.js +2 -2
  40. package/entity/utils.d.ts +6 -1
  41. package/entity/utils.js +46 -11
  42. package/entity/validators.d.ts +11 -0
  43. package/entity/validators.js +66 -0
  44. package/enums.d.ts +8 -6
  45. package/enums.js +13 -17
  46. package/errors.d.ts +20 -10
  47. package/errors.js +63 -31
  48. package/events/EventManager.d.ts +2 -1
  49. package/events/EventManager.js +24 -13
  50. package/events/index.d.ts +1 -1
  51. package/events/index.js +0 -1
  52. package/exceptions.js +9 -2
  53. package/hydration/Hydrator.js +1 -2
  54. package/hydration/ObjectHydrator.d.ts +4 -4
  55. package/hydration/ObjectHydrator.js +105 -46
  56. package/index.d.ts +2 -2
  57. package/index.js +1 -2
  58. package/logging/DefaultLogger.d.ts +1 -1
  59. package/logging/DefaultLogger.js +3 -4
  60. package/logging/SimpleLogger.d.ts +1 -1
  61. package/logging/colors.d.ts +1 -1
  62. package/logging/colors.js +5 -7
  63. package/logging/index.d.ts +2 -1
  64. package/logging/index.js +1 -1
  65. package/logging/inspect.d.ts +2 -0
  66. package/logging/inspect.js +11 -0
  67. package/metadata/EntitySchema.d.ts +47 -23
  68. package/metadata/EntitySchema.js +103 -34
  69. package/metadata/MetadataDiscovery.d.ts +64 -9
  70. package/metadata/MetadataDiscovery.js +867 -354
  71. package/metadata/MetadataProvider.d.ts +11 -2
  72. package/metadata/MetadataProvider.js +71 -2
  73. package/metadata/MetadataStorage.d.ts +13 -11
  74. package/metadata/MetadataStorage.js +72 -41
  75. package/metadata/MetadataValidator.d.ts +32 -9
  76. package/metadata/MetadataValidator.js +214 -44
  77. package/metadata/discover-entities.d.ts +5 -0
  78. package/metadata/discover-entities.js +40 -0
  79. package/metadata/index.d.ts +1 -1
  80. package/metadata/index.js +0 -1
  81. package/metadata/types.d.ts +577 -0
  82. package/metadata/types.js +1 -0
  83. package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
  84. package/naming-strategy/AbstractNamingStrategy.js +26 -5
  85. package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
  86. package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
  87. package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
  88. package/naming-strategy/MongoNamingStrategy.js +6 -6
  89. package/naming-strategy/NamingStrategy.d.ts +28 -4
  90. package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
  91. package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
  92. package/naming-strategy/index.d.ts +1 -1
  93. package/naming-strategy/index.js +0 -1
  94. package/not-supported.d.ts +2 -0
  95. package/not-supported.js +8 -0
  96. package/package.json +47 -36
  97. package/platforms/ExceptionConverter.js +1 -1
  98. package/platforms/Platform.d.ts +33 -15
  99. package/platforms/Platform.js +125 -69
  100. package/serialization/EntitySerializer.d.ts +6 -3
  101. package/serialization/EntitySerializer.js +53 -29
  102. package/serialization/EntityTransformer.js +33 -21
  103. package/serialization/SerializationContext.d.ts +6 -6
  104. package/serialization/SerializationContext.js +4 -4
  105. package/types/ArrayType.d.ts +1 -1
  106. package/types/ArrayType.js +2 -3
  107. package/types/BigIntType.js +1 -1
  108. package/types/BlobType.d.ts +0 -1
  109. package/types/BlobType.js +0 -3
  110. package/types/BooleanType.d.ts +1 -0
  111. package/types/BooleanType.js +3 -0
  112. package/types/DecimalType.js +2 -2
  113. package/types/DoubleType.js +1 -1
  114. package/types/EnumArrayType.js +1 -2
  115. package/types/JsonType.d.ts +1 -1
  116. package/types/JsonType.js +7 -2
  117. package/types/TinyIntType.js +1 -1
  118. package/types/Type.d.ts +2 -4
  119. package/types/Type.js +3 -3
  120. package/types/Uint8ArrayType.d.ts +0 -1
  121. package/types/Uint8ArrayType.js +1 -4
  122. package/types/UuidType.d.ts +2 -0
  123. package/types/UuidType.js +14 -2
  124. package/types/index.d.ts +3 -2
  125. package/typings.d.ts +427 -170
  126. package/typings.js +100 -45
  127. package/unit-of-work/ChangeSet.d.ts +4 -6
  128. package/unit-of-work/ChangeSet.js +8 -9
  129. package/unit-of-work/ChangeSetComputer.d.ts +3 -8
  130. package/unit-of-work/ChangeSetComputer.js +49 -26
  131. package/unit-of-work/ChangeSetPersister.d.ts +13 -12
  132. package/unit-of-work/ChangeSetPersister.js +107 -44
  133. package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
  134. package/unit-of-work/CommitOrderCalculator.js +17 -15
  135. package/unit-of-work/IdentityMap.d.ts +12 -0
  136. package/unit-of-work/IdentityMap.js +39 -1
  137. package/unit-of-work/UnitOfWork.d.ts +34 -4
  138. package/unit-of-work/UnitOfWork.js +294 -107
  139. package/utils/AbstractMigrator.d.ts +101 -0
  140. package/utils/AbstractMigrator.js +303 -0
  141. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  142. package/utils/AbstractSchemaGenerator.js +30 -18
  143. package/utils/AsyncContext.d.ts +6 -0
  144. package/utils/AsyncContext.js +42 -0
  145. package/utils/Configuration.d.ts +796 -211
  146. package/utils/Configuration.js +160 -197
  147. package/utils/ConfigurationLoader.d.ts +1 -52
  148. package/utils/ConfigurationLoader.js +1 -330
  149. package/utils/Cursor.d.ts +0 -3
  150. package/utils/Cursor.js +29 -14
  151. package/utils/DataloaderUtils.d.ts +10 -5
  152. package/utils/DataloaderUtils.js +42 -22
  153. package/utils/EntityComparator.d.ts +16 -9
  154. package/utils/EntityComparator.js +202 -96
  155. package/utils/QueryHelper.d.ts +34 -7
  156. package/utils/QueryHelper.js +183 -72
  157. package/utils/RawQueryFragment.d.ts +28 -34
  158. package/utils/RawQueryFragment.js +37 -72
  159. package/utils/RequestContext.js +2 -2
  160. package/utils/TransactionContext.js +2 -2
  161. package/utils/TransactionManager.js +11 -7
  162. package/utils/Utils.d.ts +16 -127
  163. package/utils/Utils.js +106 -401
  164. package/utils/clone.js +13 -23
  165. package/utils/env-vars.d.ts +7 -0
  166. package/utils/env-vars.js +98 -0
  167. package/utils/fs-utils.d.ts +34 -0
  168. package/utils/fs-utils.js +193 -0
  169. package/utils/index.d.ts +1 -3
  170. package/utils/index.js +1 -3
  171. package/utils/upsert-utils.d.ts +9 -4
  172. package/utils/upsert-utils.js +51 -5
  173. package/decorators/Check.d.ts +0 -3
  174. package/decorators/Check.js +0 -13
  175. package/decorators/CreateRequestContext.d.ts +0 -3
  176. package/decorators/CreateRequestContext.js +0 -32
  177. package/decorators/Embeddable.d.ts +0 -8
  178. package/decorators/Embeddable.js +0 -11
  179. package/decorators/Embedded.d.ts +0 -12
  180. package/decorators/Embedded.js +0 -18
  181. package/decorators/Entity.d.ts +0 -33
  182. package/decorators/Entity.js +0 -12
  183. package/decorators/Enum.d.ts +0 -9
  184. package/decorators/Enum.js +0 -16
  185. package/decorators/Filter.d.ts +0 -2
  186. package/decorators/Filter.js +0 -8
  187. package/decorators/Formula.d.ts +0 -4
  188. package/decorators/Formula.js +0 -15
  189. package/decorators/Indexed.d.ts +0 -19
  190. package/decorators/Indexed.js +0 -20
  191. package/decorators/ManyToMany.d.ts +0 -42
  192. package/decorators/ManyToMany.js +0 -14
  193. package/decorators/ManyToOne.d.ts +0 -34
  194. package/decorators/ManyToOne.js +0 -14
  195. package/decorators/OneToMany.d.ts +0 -28
  196. package/decorators/OneToMany.js +0 -17
  197. package/decorators/OneToOne.d.ts +0 -28
  198. package/decorators/OneToOne.js +0 -7
  199. package/decorators/PrimaryKey.d.ts +0 -8
  200. package/decorators/PrimaryKey.js +0 -20
  201. package/decorators/Property.d.ts +0 -250
  202. package/decorators/Property.js +0 -32
  203. package/decorators/Transactional.d.ts +0 -14
  204. package/decorators/Transactional.js +0 -28
  205. package/decorators/hooks.d.ts +0 -16
  206. package/decorators/hooks.js +0 -47
  207. package/decorators/index.d.ts +0 -17
  208. package/decorators/index.js +0 -17
  209. package/entity/ArrayCollection.d.ts +0 -118
  210. package/entity/ArrayCollection.js +0 -407
  211. package/entity/EntityValidator.d.ts +0 -19
  212. package/entity/EntityValidator.js +0 -150
  213. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  214. package/metadata/ReflectMetadataProvider.js +0 -44
  215. package/utils/resolveContextProvider.d.ts +0 -10
  216. package/utils/resolveContextProvider.js +0 -28
@@ -1,177 +1,352 @@
1
1
  import type { EntityManager } from '../EntityManager.js';
2
- import type { ColumnType, PropertyOptions, ReferenceOptions } from '../decorators/Property.js';
3
- import type { EnumOptions } from '../decorators/Enum.js';
4
- import type { EmbeddedOptions, EmbeddedPrefixMode } from '../decorators/Embedded.js';
5
- import type { ManyToOneOptions } from '../decorators/ManyToOne.js';
6
- import type { OneToManyOptions } from '../decorators/OneToMany.js';
7
- import type { OneToOneOptions } from '../decorators/OneToOne.js';
8
- import type { ManyToManyOptions } from '../decorators/ManyToMany.js';
9
- import type { AnyString, GeneratedColumnCallback, Constructor, Opt, Hidden, CheckCallback, FilterQuery, EntityName, Dictionary, EntityMetadata } from '../typings.js';
10
- import type { Reference, ScalarReference } from './Reference.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';
4
+ import type { Raw } from '../utils/RawQueryFragment.js';
5
+ import type { ScalarReference } from './Reference.js';
11
6
  import type { SerializeOptions } from '../serialization/EntitySerializer.js';
12
- import type { Cascade, DeferMode, LoadStrategy, QueryOrderMap } from '../enums.js';
13
- import type { Collection } from './Collection.js';
7
+ import type { Cascade, DeferMode, EmbeddedPrefixMode, LoadStrategy, QueryOrderKeysFlat, QueryOrderMap } from '../enums.js';
8
+ import type { EventSubscriber } from '../events/EventSubscriber.js';
14
9
  import type { IType, Type } from '../types/Type.js';
15
10
  import { types } from '../types/index.js';
16
- import { EntitySchema } from '../metadata/EntitySchema.js';
11
+ import type { Collection } from './Collection.js';
12
+ 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>;
14
+ type BuilderExtraKeys = '~options' | '~type' | '$type';
15
+ type ExcludeKeys = 'entity' | 'items';
16
+ type BuilderKeys = Exclude<UniversalPropertyKeys, ExcludeKeys> | BuilderExtraKeys;
17
+ type IncludeKeysForProperty = Exclude<keyof PropertyOptions<any>, ExcludeKeys> | BuilderExtraKeys;
18
+ type IncludeKeysForEnumOptions = Exclude<keyof EnumOptions<any>, ExcludeKeys> | BuilderExtraKeys;
19
+ type IncludeKeysForOneToManyOptions = Exclude<keyof OneToManyOptions<any, any>, ExcludeKeys> | BuilderExtraKeys;
20
+ type HasKind<Options, K extends string> = Options extends {
21
+ kind: infer X extends string;
22
+ } ? X extends K ? true : false : false;
23
+ /** Lightweight chain result type for property builders - reduces type instantiation cost by avoiding full class resolution. */
24
+ 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;
147
+ }
17
148
  /** @internal */
18
- export declare class PropertyOptionsBuilder<Value> {
19
- '~options': PropertyOptions<any>;
149
+ export declare class UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys extends BuilderKeys> implements Record<Exclude<UniversalPropertyKeys, ExcludeKeys>, any> {
150
+ '~options': Options;
20
151
  '~type'?: {
21
152
  value: Value;
22
153
  };
23
- constructor(options: PropertyOptionsBuilder<Value>['~options']);
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>;
24
171
  /**
25
172
  * Alias for `fieldName`.
26
173
  */
27
- name(name: string): PropertyOptionsBuilder<Value>;
174
+ name<T extends string>(name: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'fieldName'> & {
175
+ fieldName: T;
176
+ }, IncludeKeys>, IncludeKeys>;
28
177
  /**
29
178
  * Specify database column name for this property.
30
179
  *
31
180
  * @see https://mikro-orm.io/docs/naming-strategy
32
181
  */
33
- fieldName(fieldName: string): PropertyOptionsBuilder<Value>;
182
+ fieldName<T extends string>(fieldName: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'fieldName'> & {
183
+ fieldName: T;
184
+ }, IncludeKeys>, IncludeKeys>;
34
185
  /**
35
186
  * Specify database column names for this property.
36
187
  * Same as `fieldName` but for composite FKs.
37
188
  *
38
189
  * @see https://mikro-orm.io/docs/naming-strategy
39
190
  */
40
- fieldNames(...fieldNames: string[]): PropertyOptionsBuilder<Value>;
191
+ fieldNames(...fieldNames: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
41
192
  /**
42
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)
43
194
  */
44
- columnType(columnType: ColumnType | AnyString): PropertyOptionsBuilder<Value>;
195
+ columnType(columnType: ColumnType | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
45
196
  /**
46
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)
47
198
  */
48
- columnTypes(...columnTypes: (ColumnType | AnyString)[]): PropertyOptionsBuilder<Value>;
199
+ columnTypes(...columnTypes: (ColumnType | AnyString)[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
49
200
  /**
50
201
  * Explicitly specify the runtime type.
51
202
  *
52
203
  * @see https://mikro-orm.io/docs/metadata-providers
53
204
  * @see https://mikro-orm.io/docs/custom-types
54
205
  */
55
- type<TType extends PropertyValueType>(type: TType): PropertyOptionsBuilder<InferPropertyValueType<TType>>;
206
+ type<TType extends PropertyValueType>(type: TType): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
56
207
  /**
57
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`.
58
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`.
59
210
  */
60
- runtimeType(runtimeType: string): PropertyOptionsBuilder<Value>;
211
+ runtimeType(runtimeType: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
61
212
  /**
62
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)
63
214
  */
64
- length(length: number): PropertyOptionsBuilder<Value>;
215
+ length(length: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
65
216
  /**
66
217
  * Set precision of database column to represent the number of significant digits. (SQL only)
67
218
  */
68
- precision(precision: number): PropertyOptionsBuilder<Value>;
219
+ precision(precision: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
69
220
  /**
70
221
  * Set scale of database column to represents the number of digits after the decimal point. (SQL only)
71
222
  */
72
- scale(scale: number): PropertyOptionsBuilder<Value>;
223
+ scale(scale: number): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
73
224
  /**
74
225
  * Explicitly specify the auto increment of the primary key.
75
226
  */
76
- autoincrement<T extends boolean = true>(autoincrement?: T): PropertyOptionsBuilder<T extends true ? Opt<Value> : Value>;
227
+ autoincrement(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
228
+ autoincrement: true;
229
+ }, IncludeKeys>, IncludeKeys>;
230
+ autoincrement(autoincrement: false): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'autoincrement'> & {
231
+ autoincrement: false;
232
+ }, IncludeKeys>, IncludeKeys>;
77
233
  /**
78
234
  * Add the property to the `returning` statement.
79
235
  */
80
- returning(returning?: boolean): PropertyOptionsBuilder<Value>;
236
+ returning(returning?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
81
237
  /**
82
238
  * Automatically set the property value when entity gets created, executed during flush operation.
83
- * @param entity
84
239
  */
85
- onCreate(onCreate: (entity: any, em: EntityManager) => Value): PropertyOptionsBuilder<Opt<Value>>;
240
+ onCreate(onCreate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
241
+ onCreate: (...args: any[]) => any;
242
+ }, IncludeKeys>, IncludeKeys>;
86
243
  /**
87
244
  * Automatically update the property value every time entity gets updated, executed during flush operation.
88
- * @param entity
89
245
  */
90
- onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): PropertyOptionsBuilder<Value>;
246
+ onUpdate(onUpdate: (entity: any, em: EntityManager) => Value): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
91
247
  /**
92
248
  * Specify default column value for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
93
249
  * This is a runtime value, assignable to the entity property. (SQL only)
94
250
  */
95
- default(defaultValue: string | string[] | number | number[] | boolean | null): PropertyOptionsBuilder<Opt<Value>>;
251
+ default<T extends string | string[] | number | number[] | boolean | null | Date | Raw>(defaultValue: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'default'> & {
252
+ default: T;
253
+ }, IncludeKeys>, IncludeKeys>;
96
254
  /**
97
255
  * Specify SQL functions for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
98
256
  * Since v4 you should use defaultRaw for SQL functions. e.g. now()
99
257
  */
100
- defaultRaw(defaultRaw: string): PropertyOptionsBuilder<Value>;
258
+ defaultRaw(defaultRaw: string): Pick<UniversalPropertyOptionsBuilder<Value, Options & {
259
+ 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>;
101
265
  /**
102
266
  * Set to map some SQL snippet for the entity.
103
267
  *
104
268
  * @see https://mikro-orm.io/docs/defining-entities#formulas Formulas
105
269
  */
106
- formula(formula: string | ((alias: string) => string)): PropertyOptionsBuilder<Value>;
270
+ formula<T extends string | FormulaCallback<any>>(formula: T): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'formula'> & {
271
+ formula: T;
272
+ }, IncludeKeys>, IncludeKeys>;
107
273
  /**
108
274
  * For generated columns. This will be appended to the column type after the `generated always` clause.
109
275
  */
110
- generated(generated: string | GeneratedColumnCallback<any>): PropertyOptionsBuilder<Value>;
276
+ generated(generated: string | GeneratedColumnCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
111
277
  /**
112
278
  * Set column as nullable for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}.
113
279
  */
114
- nullable<T extends boolean = true>(nullable?: T): PropertyOptionsBuilder<T extends true ? Value extends ScalarReference<infer InnerValue> ? ScalarReference<InnerValue | null> : Value | null | undefined : NonNullable<Value>>;
280
+ nullable(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'nullable'> & {
281
+ nullable: true;
282
+ }, IncludeKeys>, IncludeKeys>;
115
283
  /**
116
284
  * Set column as unsigned for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
117
285
  */
118
- unsigned(unsigned?: boolean): PropertyOptionsBuilder<Value>;
286
+ unsigned(unsigned?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
119
287
  /**
120
288
  * Set false to define {@link https://mikro-orm.io/docs/serializing#shadow-properties Shadow Property}.
121
289
  */
122
- persist(persist?: boolean): PropertyOptionsBuilder<Value>;
290
+ persist(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
291
+ persist: true;
292
+ }, IncludeKeys>, IncludeKeys>;
293
+ persist(persist: false): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'persist'> & {
294
+ persist: false;
295
+ }, IncludeKeys>, IncludeKeys>;
123
296
  /**
124
297
  * Set false to disable hydration of this property. Useful for persisted getters.
125
298
  */
126
- hydrate(hydrate?: boolean): PropertyOptionsBuilder<Value>;
299
+ hydrate(hydrate?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
127
300
  /**
128
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.
129
302
  */
130
- ref<T extends boolean = true>(ref?: T): PropertyOptionsBuilder<T extends true ? ScalarReference<Value> : UnwrapRef<Value>>;
131
- /**
132
- * Set false to disable change tracking on a property level.
133
- *
134
- * @see https://mikro-orm.io/docs/unit-of-work#change-tracking-and-performance-considerations
135
- */
136
- trackChanges(trackChanges?: boolean): PropertyOptionsBuilder<Value>;
303
+ ref(): UniversalPropertyOptionsBuilder<Value, Omit<Options, 'ref'> & {
304
+ ref: true;
305
+ }, IncludeKeys>;
137
306
  /**
138
307
  * Set to true to omit the property when {@link https://mikro-orm.io/docs/serializing Serializing}.
139
308
  */
140
- hidden<T extends boolean = true>(hidden?: T): PropertyOptionsBuilder<T extends true ? Hidden<Value> : Value>;
309
+ hidden(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'hidden'> & {
310
+ hidden: true;
311
+ }, IncludeKeys>, IncludeKeys>;
141
312
  /**
142
313
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via version field. (SQL only)
143
314
  */
144
- version(version?: boolean): PropertyOptionsBuilder<Value>;
315
+ version(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'version'> & {
316
+ version: true;
317
+ }, IncludeKeys>, IncludeKeys>;
145
318
  /**
146
319
  * Set to true to enable {@link https://mikro-orm.io/docs/transactions#optimistic-locking Optimistic Locking} via concurrency fields.
147
320
  */
148
- concurrencyCheck(concurrencyCheck?: boolean): PropertyOptionsBuilder<Value>;
321
+ concurrencyCheck(concurrencyCheck?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
149
322
  /**
150
323
  * Explicitly specify index on a property.
151
324
  */
152
- index(index?: boolean | string): PropertyOptionsBuilder<Value>;
325
+ index(index?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
153
326
  /**
154
327
  * Set column as unique for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
155
328
  */
156
- unique(unique?: boolean | string): PropertyOptionsBuilder<Value>;
329
+ unique(unique?: boolean | string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
157
330
  /**
158
331
  * Specify column with check constraints. (Postgres driver only)
159
332
  *
160
333
  * @see https://mikro-orm.io/docs/defining-entities#check-constraints
161
334
  */
162
- check(check: string | CheckCallback<any>): PropertyOptionsBuilder<Value>;
335
+ check(check: string | CheckCallback<any>): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
163
336
  /**
164
337
  * Set to omit the property from the select clause for lazy loading.
165
338
  *
166
339
  * @see https://mikro-orm.io/docs/defining-entities#lazy-scalar-properties
167
340
  */
168
- lazy<T extends boolean = true>(lazy?: boolean, ref?: T): PropertyOptionsBuilder<T extends true ? ScalarReference<Value> : UnwrapRef<Value>>;
341
+ lazy(): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
169
342
  /**
170
343
  * Set true to define entity's unique primary key identifier.
171
344
  *
172
345
  * @see https://mikro-orm.io/docs/decorators#primarykey
173
346
  */
174
- primary(primary?: boolean): PropertyOptionsBuilder<Value>;
347
+ primary(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'primary'> & {
348
+ primary: true;
349
+ }, IncludeKeys>, IncludeKeys>;
175
350
  /**
176
351
  * Set true to define the properties as setter. (virtual)
177
352
  *
@@ -183,7 +358,7 @@ export declare class PropertyOptionsBuilder<Value> {
183
358
  * }
184
359
  * ```
185
360
  */
186
- setter(setter?: boolean): PropertyOptionsBuilder<Value>;
361
+ setter(setter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
187
362
  /**
188
363
  * Set true to define the properties as getter. (virtual)
189
364
  *
@@ -195,7 +370,7 @@ export declare class PropertyOptionsBuilder<Value> {
195
370
  * }
196
371
  * ```
197
372
  */
198
- getter(getter?: boolean): PropertyOptionsBuilder<Value>;
373
+ getter(getter?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
199
374
  /**
200
375
  * When defining a property over a method (not a getter, a regular function), you can use this option to point
201
376
  * to the method name.
@@ -208,330 +383,369 @@ export declare class PropertyOptionsBuilder<Value> {
208
383
  * }
209
384
  * ```
210
385
  */
211
- getterName(getterName: string): PropertyOptionsBuilder<Value>;
386
+ getterName(getterName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
212
387
  /**
213
388
  * Set to define serialized primary key for MongoDB. (virtual)
214
389
  * Alias for `@SerializedPrimaryKey()` decorator.
215
390
  *
216
391
  * @see https://mikro-orm.io/docs/decorators#serializedprimarykey
217
392
  */
218
- serializedPrimaryKey(serializedPrimaryKey?: boolean): PropertyOptionsBuilder<Value>;
393
+ serializedPrimaryKey(serializedPrimaryKey?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
219
394
  /**
220
395
  * Set to use serialize property. Allow to specify a callback that will be used when serializing a property.
221
396
  *
222
397
  * @see https://mikro-orm.io/docs/serializing#property-serializers
223
398
  */
224
- serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): PropertyOptionsBuilder<Value>;
399
+ serializer(serializer: (value: Value, options?: SerializeOptions<any>) => any): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
225
400
  /**
226
401
  * Specify name of key for the serialized value.
227
402
  */
228
- serializedName(serializedName: string): PropertyOptionsBuilder<Value>;
403
+ serializedName(serializedName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
229
404
  /**
230
405
  * Specify serialization groups for `serialize()` calls. If a property does not specify any group, it will be included,
231
406
  * otherwise only properties with a matching group are included.
232
407
  */
233
- groups(...groups: string[]): PropertyOptionsBuilder<Value>;
408
+ groups(...groups: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
234
409
  /**
235
410
  * Specify a custom order based on the values. (SQL only)
236
411
  */
237
- customOrder(...customOrder: (string[] | number[] | boolean[])): PropertyOptionsBuilder<Value>;
412
+ customOrder(...customOrder: string[] | number[] | boolean[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
238
413
  /**
239
414
  * Specify comment of column for {@link https://mikro-orm.io/docs/schema-generator Schema Generator}. (SQL only)
240
415
  */
241
- comment(comment: string): PropertyOptionsBuilder<Value>;
416
+ comment(comment: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
242
417
  /** mysql only */
243
- extra(extra: string): PropertyOptionsBuilder<Value>;
418
+ extra(extra: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
244
419
  /**
245
420
  * Set to avoid a perpetual diff from the {@link https://mikro-orm.io/docs/schema-generator Schema Generator} when columns are generated.
246
421
  *
247
422
  * @see https://mikro-orm.io/docs/defining-entities#sql-generated-columns
248
423
  */
249
- ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): PropertyOptionsBuilder<Value>;
250
- /**
251
- * Set the TypeScript type of the property.
252
- */
253
- $type<T>(): PropertyOptionsBuilder<T>;
254
- /**
255
- * Set the TypeScript type for custom types that map to objects.
256
- * This method provides type safety for custom types by specifying the runtime type,
257
- * raw database value type, and optional serialized type.
258
- *
259
- * @template Runtime - The runtime type that the property will have in JavaScript
260
- * @template Raw - The raw value type as stored in the database
261
- * @template Serialized - The type when serialized (defaults to Raw)
262
- * @returns PropertyOptionsBuilder with IType wrapper for type safety
263
- */
264
- $type<Runtime, Raw, Serialized = Raw>(): PropertyOptionsBuilder<IType<Runtime, Raw, Serialized>>;
265
- }
266
- /** @internal */
267
- export declare class EnumOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
268
- '~options': {
269
- enum: true;
270
- } & EnumOptions<any>;
271
- constructor(options: EnumOptionsBuilder<Value>['~options']);
272
- array<T extends boolean = true>(array?: T): EnumOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
424
+ ignoreSchemaChanges(...ignoreSchemaChanges: ('type' | 'extra' | 'default')[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
425
+ array(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'array'> & {
426
+ array: true;
427
+ }, IncludeKeys>, IncludeKeys>;
273
428
  /** for postgres, by default it uses text column with check constraint */
274
- nativeEnumName(nativeEnumName: string): EnumOptionsBuilder<Value>;
275
- }
276
- /** @internal */
277
- export declare class EmbeddedOptionsBuilder<Value> extends PropertyOptionsBuilder<Value> {
278
- '~options': ({
279
- kind: 'embedded';
280
- entity: () => EntitySchema<any, any> | EntitySchema<any, any>[];
281
- } & EmbeddedOptions<any, any> & PropertyOptions<any>);
282
- constructor(options: EmbeddedOptionsBuilder<Value>['~options']);
283
- prefix(prefix: string): EmbeddedOptionsBuilder<Value>;
284
- prefixMode(prefixMode: EmbeddedPrefixMode): EmbeddedOptionsBuilder<Value>;
285
- object(object?: boolean): EmbeddedOptionsBuilder<Value>;
286
- array<T extends boolean = true>(array?: T): EmbeddedOptionsBuilder<T extends true ? Value[] : UnwrapArray<Value>>;
287
- }
288
- /** @internal */
289
- export declare class ReferenceOptionsBuilder<Value extends object> extends PropertyOptionsBuilder<Value> {
290
- '~options': ReferenceOptions<any, any>;
291
- constructor(options: ReferenceOptionsBuilder<Value>['~options']);
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>;
292
433
  /** Set what actions on owning entity should be cascaded to the relationship. Defaults to [Cascade.PERSIST, Cascade.MERGE] (see {@doclink cascading}). */
293
- cascade(...cascade: Cascade[]): ReferenceOptionsBuilder<Value>;
434
+ cascade(...cascade: Cascade[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
294
435
  /** Always load the relationship. Discouraged for use with to-many relations for performance reasons. */
295
- eager(eager?: boolean): ReferenceOptionsBuilder<Value>;
436
+ eager(eager?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
296
437
  /** Override the default loading strategy for this property. This option has precedence over the global `loadStrategy`, but can be overridden by `FindOptions.strategy`. */
297
- strategy(strategy: LoadStrategy | `${LoadStrategy}`): ReferenceOptionsBuilder<Value>;
298
- /**
299
- * @internal
300
- * re-declare to override type inference
301
- */
302
- ref(ref?: boolean): ReferenceOptionsBuilder<any>;
303
- /**
304
- * @internal
305
- * re-declare to override type inference
306
- */
307
- primary(primary?: boolean): ReferenceOptionsBuilder<any>;
308
- }
309
- /** @internal */
310
- export declare class ManyToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
311
- '~options': ({
312
- kind: 'm:n';
313
- entity: () => EntitySchema<any, any>;
314
- } & ManyToManyOptions<any, UnwrapCollection<TargetValue>>);
315
- constructor(options: ManyToManyOptionsBuilder<TargetValue>['~options']);
438
+ strategy(strategy: LoadStrategy | `${LoadStrategy}`): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
316
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. */
317
- owner(owner?: boolean): ManyToManyOptionsBuilder<TargetValue>;
440
+ owner(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'owner'> & {
441
+ 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>;
318
447
  /** Point to the inverse side property name. */
319
- inversedBy(inversedBy: (string & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): ManyToManyOptionsBuilder<TargetValue>;
448
+ inversedBy(inversedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
320
449
  /** Point to the owning side property name. */
321
- mappedBy(mappedBy: string | ((e: any) => any)): ManyToManyOptionsBuilder<TargetValue>;
450
+ mappedBy(mappedBy: keyof Value | ((e: Value) => any)): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
322
451
  /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
323
- where(...where: FilterQuery<object>[]): ManyToManyOptionsBuilder<TargetValue>;
452
+ where(...where: FilterQuery<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
324
453
  /** Set default ordering. */
325
- orderBy(...orderBy: QueryOrderMap<object>[]): ManyToManyOptionsBuilder<TargetValue>;
454
+ orderBy(...orderBy: QueryOrderMap<object>[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
326
455
  /** Force stable insertion order of items in the collection (see {@doclink collections | Collections}). */
327
- fixedOrder(fixedOrder?: boolean): ManyToManyOptionsBuilder<TargetValue>;
456
+ fixedOrder(fixedOrder?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
328
457
  /** Override default order column name (`id`) for fixed ordering. */
329
- fixedOrderColumn(fixedOrderColumn: string): ManyToManyOptionsBuilder<TargetValue>;
458
+ fixedOrderColumn(fixedOrderColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
330
459
  /** Override default name for pivot table (see {@doclink naming-strategy | Naming Strategy}). */
331
- pivotTable(pivotTable: string): ManyToManyOptionsBuilder<TargetValue>;
460
+ pivotTable(pivotTable: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
332
461
  /** Set pivot entity for this relation (see {@doclink collections#custom-pivot-table-entity | Custom pivot table entity}). */
333
- pivotEntity(pivotEntity: string | (() => EntityName<any>)): ManyToManyOptionsBuilder<TargetValue>;
462
+ pivotEntity(pivotEntity: () => EntityName): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
334
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. */
335
- joinColumn(joinColumn: string): ManyToManyOptionsBuilder<TargetValue>;
464
+ joinColumn(joinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
336
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. */
337
- joinColumns(...joinColumns: string[]): ManyToManyOptionsBuilder<TargetValue>;
466
+ joinColumns(...joinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
338
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. */
339
- inverseJoinColumn(inverseJoinColumn: string): ManyToManyOptionsBuilder<TargetValue>;
468
+ inverseJoinColumn(inverseJoinColumn: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
340
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. */
341
- inverseJoinColumns(...inverseJoinColumns: string[]): ManyToManyOptionsBuilder<TargetValue>;
470
+ inverseJoinColumns(...inverseJoinColumns: string[]): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
342
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. */
343
- referenceColumnName(referenceColumnName: string): ManyToManyOptionsBuilder<TargetValue>;
472
+ referenceColumnName(referenceColumnName: string): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
344
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. */
345
- referencedColumnNames(...referencedColumnNames: string[]): ManyToManyOptionsBuilder<TargetValue>;
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>;
346
477
  /** What to do when the target entity gets deleted. */
347
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToManyOptionsBuilder<TargetValue>;
478
+ deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
348
479
  /** What to do when the reference to the target entity gets updated. */
349
- updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToManyOptionsBuilder<TargetValue>;
350
- }
351
- /** @internal */
352
- export declare class ManyToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
353
- '~options': ({
354
- kind: 'm:1';
355
- entity: () => EntitySchema<any, any>;
356
- } & ManyToOneOptions<any, UnwrapRef<TargetValue>>);
357
- constructor(options: ManyToOneOptionsBuilder<TargetValue>['~options']);
358
- /** Point to the inverse side property name. */
359
- inversedBy(inversedBy: (string & keyof UnwrapRef<TargetValue>) | ((e: UnwrapRef<TargetValue>) => any)): ManyToOneOptionsBuilder<TargetValue>;
360
- /** Wrap the entity in {@apilink Reference} wrapper. */
361
- ref<T extends boolean = true>(ref?: T): ManyToOneOptionsBuilder<T extends true ? Reference<TargetValue> : UnwrapRef<TargetValue>>;
362
- /** Use this relation as a primary key. */
363
- primary(primary?: boolean): ManyToOneOptionsBuilder<TargetValue>;
480
+ updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
364
481
  /** Map this relation to the primary key value instead of an entity. */
365
- mapToPk(mapToPk?: boolean): ManyToOneOptionsBuilder<TargetValue>;
366
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
367
- joinColumn(joinColumn: string): ManyToOneOptionsBuilder<TargetValue>;
368
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
369
- joinColumns(...joinColumns: string[]): ManyToOneOptionsBuilder<TargetValue>;
370
- /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
371
- ownColumns(...ownColumns: string[]): ManyToOneOptionsBuilder<TargetValue>;
372
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
373
- referenceColumnName(referenceColumnName: string): ManyToOneOptionsBuilder<TargetValue>;
374
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
375
- referencedColumnNames(...referencedColumnNames: string[]): ManyToOneOptionsBuilder<TargetValue>;
376
- /** What to do when the target entity gets deleted. */
377
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
378
- /** What to do when the reference to the target entity gets updated. */
379
- updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): ManyToOneOptionsBuilder<TargetValue>;
482
+ mapToPk(): Pick<UniversalPropertyOptionsBuilder<Value, Omit<Options, 'mapToPk'> & {
483
+ mapToPk: true;
484
+ }, IncludeKeys>, IncludeKeys>;
380
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. */
381
- deferMode(deferMode: DeferMode | `${DeferMode}`): ManyToOneOptionsBuilder<TargetValue>;
382
- }
383
- /** @internal */
384
- export declare class OneToManyOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
385
- '~options': ({
386
- kind: '1:m';
387
- entity: () => EntitySchema<TargetValue>;
388
- } & OneToManyOptions<any, UnwrapCollection<TargetValue>>);
389
- constructor(options: OneToManyOptionsBuilder<TargetValue>['~options']);
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>;
390
493
  /** Remove the entity when it gets disconnected from the relationship (see {@doclink cascading | Cascading}). */
391
- orphanRemoval(orphanRemoval?: boolean): OneToManyOptionsBuilder<TargetValue>;
392
- /** Set default ordering. */
393
- orderBy(orderBy: QueryOrderMap<UnwrapCollection<TargetValue>> | QueryOrderMap<UnwrapCollection<TargetValue>>[]): OneToManyOptionsBuilder<TargetValue>;
394
- /** Condition for {@doclink collections#declarative-partial-loading | Declarative partial loading}. */
395
- where(where: FilterQuery<UnwrapCollection<TargetValue>>): OneToManyOptionsBuilder<TargetValue>;
396
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
397
- joinColumn(joinColumn: string): OneToManyOptionsBuilder<TargetValue>;
398
- /** Override the default database column name on the owning side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
399
- joinColumns(...joinColumns: string[]): OneToManyOptionsBuilder<TargetValue>;
400
- /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
401
- inverseJoinColumn(inverseJoinColumn: string): OneToManyOptionsBuilder<TargetValue>;
402
- /** Override the default database column name on the inverse side (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
403
- inverseJoinColumns(...inverseJoinColumns: string[]): OneToManyOptionsBuilder<TargetValue>;
404
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is only for simple properties represented by a single column. */
405
- referenceColumnName(referenceColumnName: string): OneToManyOptionsBuilder<TargetValue>;
406
- /** Override the default database column name on the target entity (see {@doclink naming-strategy | Naming Strategy}). This option is suitable for composite keys, where one property is represented by multiple columns. */
407
- referencedColumnNames(...referencedColumnNames: string[]): OneToManyOptionsBuilder<TargetValue>;
494
+ orphanRemoval(orphanRemoval?: boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
495
+ accessor(accessor?: string | boolean): Pick<UniversalPropertyOptionsBuilder<Value, Options, IncludeKeys>, IncludeKeys>;
408
496
  }
409
- /** @internal */
410
- export declare class OneToManyOptionsBuilderOnlyMappedBy<TargetValue extends object> {
411
- '~options': ({
412
- kind: '1:m';
413
- entity: () => EntitySchema<TargetValue>;
414
- } & Omit<OneToManyOptions<any, UnwrapCollection<TargetValue>>, 'mappedBy'>);
415
- constructor(options: OneToManyOptionsBuilderOnlyMappedBy<TargetValue>['~options']);
416
- /** Point to the owning side property name. */
417
- mappedBy(mappedBy: (AnyString & keyof UnwrapCollection<TargetValue>) | ((e: UnwrapCollection<TargetValue>) => any)): OneToManyOptionsBuilder<TargetValue>;
497
+ export interface EmptyOptions extends Partial<Record<UniversalPropertyKeys, unknown>> {
418
498
  }
419
499
  /** @internal */
420
- export declare class OneToOneOptionsBuilder<TargetValue extends object> extends ReferenceOptionsBuilder<TargetValue> {
421
- '~options': ({
422
- kind: '1:1';
423
- entity: () => EntitySchema<any, any>;
424
- } & OneToOneOptions<any, UnwrapRef<TargetValue>>);
425
- constructor(options: OneToOneOptionsBuilder<TargetValue>['~options']);
426
- /** Set this side as owning. Owning side is where the foreign key is defined. This option is not required if you use `inversedBy` or `mappedBy` to distinguish owning and inverse side. */
427
- owner(owner?: boolean): OneToOneOptionsBuilder<TargetValue>;
428
- /** Point to the inverse side property name. */
429
- inversedBy(inversedBy: (string & keyof UnwrapRef<TargetValue>) | ((e: UnwrapRef<TargetValue>) => any)): OneToOneOptionsBuilder<TargetValue>;
430
- /** Wrap the entity in {@apilink Reference} wrapper. */
431
- ref<T extends boolean = true>(ref?: T): OneToOneOptionsBuilder<T extends true ? Reference<TargetValue> : UnwrapRef<TargetValue>>;
432
- /** Use this relation as a primary key. */
433
- primary(primary?: boolean): OneToOneOptionsBuilder<TargetValue>;
434
- /** Map this relation to the primary key value instead of an entity. */
435
- mapToPk(mapToPk?: boolean): OneToOneOptionsBuilder<TargetValue>;
436
- /** When a part of a composite column is shared in other properties, use this option to specify what columns are considered as owned by this property. This is useful when your composite property is nullable, but parts of it are not. */
437
- ownColumns(...ownColumns: string[]): OneToOneOptionsBuilder<TargetValue>;
438
- /** What to do when the target entity gets deleted. */
439
- deleteRule(deleteRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
440
- /** What to do when the reference to the target entity gets updated. */
441
- updateRule(updateRule: 'cascade' | 'no action' | 'set null' | 'set default' | AnyString): OneToOneOptionsBuilder<TargetValue>;
442
- /** Set the constraint type. Immediate constraints are checked for each statement, while deferred ones are only checked at the end of the transaction. Only for postgres unique constraints. */
443
- deferMode(deferMode: DeferMode | `${DeferMode}`): OneToOneOptionsBuilder<TargetValue>;
500
+ export declare class OneToManyOptionsBuilderOnlyMappedBy<Value extends object> extends UniversalPropertyOptionsBuilder<Value, EmptyOptions & {
501
+ 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 & {
505
+ kind: '1:m';
506
+ }, IncludeKeysForOneToManyOptions>, IncludeKeysForOneToManyOptions>;
444
507
  }
508
+ type EntityTarget = {
509
+ '~entity': any;
510
+ } | EntityClass;
445
511
  declare const propertyBuilders: {
446
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
447
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
448
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
449
- json: <T>() => PropertyOptionsBuilder<T>;
450
- formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
451
- type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
452
- enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => EnumOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T>;
453
- embedded: <Target extends EntitySchema<any, any> | EntitySchema<any, any>[]>(target: Target) => EmbeddedOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>>;
454
- manyToMany: <Target extends EntitySchema<any, any>>(target: Target) => ManyToManyOptionsBuilder<Collection<InferEntity<Target>, object>>;
455
- manyToOne: <Target extends EntitySchema<any, any>>(target: Target) => ManyToOneOptionsBuilder<Reference<InferEntity<Target>>>;
456
- oneToMany: <Target extends EntitySchema<any, any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<Collection<InferEntity<Target>, object>>;
457
- oneToOne: <Target extends EntitySchema<any, any>>(target: Target) => OneToOneOptionsBuilder<Reference<InferEntity<Target>>>;
458
- date: () => PropertyOptionsBuilder<string>;
459
- time: () => PropertyOptionsBuilder<any>;
460
- datetime: () => PropertyOptionsBuilder<Date>;
461
- blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
462
- uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
463
- enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
464
- integer: () => PropertyOptionsBuilder<number>;
465
- smallint: () => PropertyOptionsBuilder<number>;
466
- tinyint: () => PropertyOptionsBuilder<number>;
467
- mediumint: () => PropertyOptionsBuilder<number>;
468
- float: () => PropertyOptionsBuilder<number>;
469
- double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
470
- boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
471
- character: () => PropertyOptionsBuilder<string>;
472
- string: () => PropertyOptionsBuilder<string>;
473
- uuid: () => PropertyOptionsBuilder<string>;
474
- text: () => PropertyOptionsBuilder<string>;
475
- interval: () => PropertyOptionsBuilder<string>;
476
- unknown: () => PropertyOptionsBuilder<{}>;
512
+ bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
513
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
514
+ decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
515
+ json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
516
+ formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
517
+ datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
518
+ time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
519
+ type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
520
+ enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
521
+ embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
522
+ kind: "embedded";
523
+ }>;
524
+ manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
525
+ kind: "m:n";
526
+ }>;
527
+ manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
528
+ kind: "m:1";
529
+ }>;
530
+ oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
531
+ kind: "1:m";
532
+ }>;
533
+ oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
534
+ kind: "1:1";
535
+ }>;
536
+ date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
537
+ blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
538
+ uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
539
+ enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
540
+ integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
541
+ smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
542
+ tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
543
+ mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
544
+ float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
545
+ double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
546
+ boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
547
+ character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
548
+ string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
549
+ uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
550
+ text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
551
+ interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
552
+ unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
477
553
  };
478
- export declare function defineEntity<Properties extends Record<string, any>>(meta: Omit<Partial<EntityMetadata<InferEntityFromProperties<Properties>>>, 'properties' | 'extends'> & {
479
- name: string;
480
- properties: Properties | ((properties: typeof propertyBuilders) => Properties);
481
- }): EntitySchema<InferEntityFromProperties<Properties>, never>;
554
+ /** Own keys + base entity keys (when TBase is not `never`). Guards against `keyof never = string | number | symbol`. */
555
+ type AllKeys<TProperties, TBase> = keyof TProperties | (IsNever<TBase> extends true ? never : keyof TBase);
556
+ 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'> {
557
+ name: TName;
558
+ tableName?: TTableName;
559
+ extends?: {
560
+ '~entity': TBase;
561
+ } | EntityCtor<TBase>;
562
+ properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
563
+ primaryKeys?: TPK & InferPrimaryKey<TProperties>[];
564
+ hooks?: DefineEntityHooks;
565
+ repository?: () => TRepository;
566
+ forceObject?: TForceObject;
567
+ inheritance?: 'tpt';
568
+ orderBy?: {
569
+ [K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
570
+ } | {
571
+ [K in Extract<AllKeys<TProperties, TBase>, string>]?: QueryOrderKeysFlat;
572
+ }[];
573
+ discriminatorColumn?: string;
574
+ versionProperty?: AllKeys<TProperties, TBase>;
575
+ concurrencyCheckKeys?: Set<AllKeys<TProperties, TBase>>;
576
+ serializedPrimaryKey?: AllKeys<TProperties, TBase>;
577
+ indexes?: {
578
+ properties?: keyof TProperties | (keyof TProperties)[];
579
+ name?: string;
580
+ type?: string;
581
+ options?: Dictionary;
582
+ expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
583
+ }[];
584
+ uniques?: {
585
+ properties?: keyof TProperties | (keyof TProperties)[];
586
+ name?: string;
587
+ options?: Dictionary;
588
+ expression?: string | IndexCallback<InferEntityFromProperties<TProperties, TPK, TBase>>;
589
+ deferMode?: DeferMode | `${DeferMode}`;
590
+ }[];
591
+ }
592
+ 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>;
593
+ 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'> & {
594
+ class: TClass;
595
+ className?: TClassName;
596
+ tableName?: TTableName;
597
+ extends?: TBase;
598
+ properties: TProperties | ((properties: typeof propertyBuilders) => TProperties);
599
+ hooks?: DefineEntityHooks<TEntity>;
600
+ }): EntitySchemaWithMeta<TClassName, TTableName, TEntity, TBase, TProperties, TClass>;
482
601
  export declare namespace defineEntity {
483
602
  var properties: {
484
- bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => PropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}>;
485
- array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => PropertyOptionsBuilder<T[]>;
486
- decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => PropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>>;
487
- json: <T>() => PropertyOptionsBuilder<T>;
488
- formula: <T>(formula: string | ((alias: string) => string)) => PropertyOptionsBuilder<T>;
489
- type: <T extends PropertyValueType>(type: T) => PropertyOptionsBuilder<InferPropertyValueType<T>>;
490
- enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => EnumOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T>;
491
- embedded: <Target extends EntitySchema<any, any> | EntitySchema<any, any>[]>(target: Target) => EmbeddedOptionsBuilder<InferEntity<Target extends (infer T)[] ? T : Target>>;
492
- manyToMany: <Target extends EntitySchema<any, any>>(target: Target) => ManyToManyOptionsBuilder<Collection<InferEntity<Target>, object>>;
493
- manyToOne: <Target extends EntitySchema<any, any>>(target: Target) => ManyToOneOptionsBuilder<Reference<InferEntity<Target>>>;
494
- oneToMany: <Target extends EntitySchema<any, any>>(target: Target) => OneToManyOptionsBuilderOnlyMappedBy<Collection<InferEntity<Target>, object>>;
495
- oneToOne: <Target extends EntitySchema<any, any>>(target: Target) => OneToOneOptionsBuilder<Reference<InferEntity<Target>>>;
496
- date: () => PropertyOptionsBuilder<string>;
497
- time: () => PropertyOptionsBuilder<any>;
498
- datetime: () => PropertyOptionsBuilder<Date>;
499
- blob: () => PropertyOptionsBuilder<NonNullable<Uint8Array<ArrayBufferLike> | Buffer<ArrayBufferLike> | null>>;
500
- uint8array: () => PropertyOptionsBuilder<Uint8Array<ArrayBufferLike>>;
501
- enumArray: () => PropertyOptionsBuilder<(string | number)[]>;
502
- integer: () => PropertyOptionsBuilder<number>;
503
- smallint: () => PropertyOptionsBuilder<number>;
504
- tinyint: () => PropertyOptionsBuilder<number>;
505
- mediumint: () => PropertyOptionsBuilder<number>;
506
- float: () => PropertyOptionsBuilder<number>;
507
- double: () => PropertyOptionsBuilder<NonNullable<string | number>>;
508
- boolean: () => PropertyOptionsBuilder<NonNullable<boolean | null | undefined>>;
509
- character: () => PropertyOptionsBuilder<string>;
510
- string: () => PropertyOptionsBuilder<string>;
511
- uuid: () => PropertyOptionsBuilder<string>;
512
- text: () => PropertyOptionsBuilder<string>;
513
- interval: () => PropertyOptionsBuilder<string>;
514
- unknown: () => PropertyOptionsBuilder<{}>;
603
+ bigint: <Mode extends "bigint" | "number" | "string" = "bigint">(mode?: Mode) => UniversalPropertyOptionsBuilder<(Mode extends "bigint" ? bigint : Mode extends "number" ? number : string) & {}, EmptyOptions, IncludeKeysForProperty>;
604
+ array: <T = string>(toJsValue?: (i: string) => T, toDbValue?: (i: T) => string) => UniversalPropertyOptionsBuilder<T[], EmptyOptions, IncludeKeysForProperty>;
605
+ decimal: <Mode extends "number" | "string" = "string">(mode?: Mode) => UniversalPropertyOptionsBuilder<NonNullable<Mode extends "number" ? number : string>, EmptyOptions, IncludeKeysForProperty>;
606
+ json: <T>() => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
607
+ formula: <T>(formula: string | FormulaCallback<any>) => UniversalPropertyOptionsBuilder<T, EmptyOptions, IncludeKeysForProperty>;
608
+ datetime: (length?: number) => UniversalPropertyOptionsBuilder<Date, EmptyOptions, IncludeKeysForProperty>;
609
+ time: (length?: number) => UniversalPropertyOptionsBuilder<any, EmptyOptions, IncludeKeysForProperty>;
610
+ type: <T extends PropertyValueType>(type: T) => UniversalPropertyOptionsBuilder<InferPropertyValueType<T>, EmptyOptions, IncludeKeysForProperty>;
611
+ enum: <const T extends (number | string)[] | (() => Dictionary)>(items?: T) => UniversalPropertyOptionsBuilder<T extends () => Dictionary ? ValueOf<ReturnType<T>> : T extends (infer Value)[] ? Value : T, EmptyOptions, IncludeKeysForEnumOptions>;
612
+ embedded: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
613
+ kind: "embedded";
614
+ }>;
615
+ manyToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
616
+ kind: "m:n";
617
+ }>;
618
+ manyToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
619
+ kind: "m:1";
620
+ }>;
621
+ oneToMany: <Target extends EntityTarget>(target: Target) => PropertyChain<InferEntity<Target>, EmptyOptions & {
622
+ kind: "1:m";
623
+ }>;
624
+ oneToOne: <Target extends EntityTarget | EntityTarget[]>(target: Target) => PropertyChain<InferEntity<Target extends (infer T)[] ? T : Target>, EmptyOptions & {
625
+ kind: "1:1";
626
+ }>;
627
+ date: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
628
+ blob: () => UniversalPropertyOptionsBuilder<NonNullable<Buffer<ArrayBufferLike> | Uint8Array<ArrayBufferLike> | null>, EmptyOptions, IncludeKeysForProperty>;
629
+ uint8array: () => UniversalPropertyOptionsBuilder<Uint8Array<ArrayBufferLike>, EmptyOptions, IncludeKeysForProperty>;
630
+ enumArray: () => UniversalPropertyOptionsBuilder<(string | number)[], EmptyOptions, IncludeKeysForProperty>;
631
+ integer: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
632
+ smallint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
633
+ tinyint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
634
+ mediumint: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
635
+ float: () => UniversalPropertyOptionsBuilder<number, EmptyOptions, IncludeKeysForProperty>;
636
+ double: () => UniversalPropertyOptionsBuilder<NonNullable<string | number>, EmptyOptions, IncludeKeysForProperty>;
637
+ boolean: () => UniversalPropertyOptionsBuilder<NonNullable<boolean | null | undefined>, EmptyOptions, IncludeKeysForProperty>;
638
+ character: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
639
+ string: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
640
+ uuid: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
641
+ text: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
642
+ interval: () => UniversalPropertyOptionsBuilder<string, EmptyOptions, IncludeKeysForProperty>;
643
+ unknown: () => UniversalPropertyOptionsBuilder<{}, EmptyOptions, IncludeKeysForProperty>;
515
644
  };
516
645
  }
646
+ export { propertyBuilders as p };
647
+ type EntityHookValue<T, K extends keyof EventSubscriber<T>> = (keyof T | NonNullable<EventSubscriber<T>[K]>)[];
648
+ export interface DefineEntityHooks<T = any> {
649
+ onInit?: EntityHookValue<T, 'onInit'>;
650
+ onLoad?: EntityHookValue<T, 'onLoad'>;
651
+ beforeCreate?: EntityHookValue<T, 'beforeCreate'>;
652
+ afterCreate?: EntityHookValue<T, 'afterCreate'>;
653
+ beforeUpdate?: EntityHookValue<T, 'beforeUpdate'>;
654
+ afterUpdate?: EntityHookValue<T, 'afterUpdate'>;
655
+ beforeUpsert?: EntityHookValue<T, 'beforeUpsert'>;
656
+ afterUpsert?: EntityHookValue<T, 'afterUpsert'>;
657
+ beforeDelete?: EntityHookValue<T, 'beforeDelete'>;
658
+ afterDelete?: EntityHookValue<T, 'afterDelete'>;
659
+ }
517
660
  type PropertyValueType = PropertyOptions<any>['type'];
518
661
  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;
519
- type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<typeof types[T]> : InferColumnType<T>;
662
+ type InferTypeByString<T extends string> = T extends keyof typeof types ? InferJSType<(typeof types)[T]> : InferColumnType<T>;
520
663
  type InferJSType<T> = T extends typeof Type<infer TValue, any> ? NonNullable<TValue> : never;
521
664
  type InferColumnType<T extends string> = T extends 'int' | 'int4' | 'integer' | 'bigint' | 'int8' | 'int2' | 'tinyint' | 'smallint' | 'mediumint' ? number : T extends 'double' | 'double precision' | 'real' | 'float8' | 'decimal' | 'numeric' | 'float' | 'float4' ? number : T extends 'datetime' | 'time' | 'time with time zone' | 'timestamp' | 'timestamp with time zone' | 'timetz' | 'timestamptz' | 'date' | 'interval' ? Date : T extends 'ObjectId' | 'objectId' | 'character varying' | 'varchar' | 'char' | 'character' | 'uuid' | 'text' | 'tinytext' | 'mediumtext' | 'longtext' | 'enum' ? string : T extends 'boolean' | 'bool' | 'bit' ? boolean : T extends 'blob' | 'tinyblob' | 'mediumblob' | 'longblob' | 'bytea' ? Buffer : T extends 'point' | 'line' | 'lseg' | 'box' | 'circle' | 'path' | 'polygon' | 'geometry' ? number[] : T extends 'tsvector' | 'tsquery' ? string[] : T extends 'json' | 'jsonb' ? any : any;
522
- export type InferEntityFromProperties<Properties extends Record<string, any>> = {
523
- -readonly [K in keyof Properties]: Properties[K] extends (() => any) ? InferBuilderValue<ReturnType<Properties[K]>> : InferBuilderValue<Properties[K]>;
524
- };
665
+ type BaseEntityMethodKeys = 'toObject' | 'toPOJO' | 'serialize' | 'assign' | 'populate' | 'init' | 'toReference';
666
+ 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 {
667
+ toObject(...args: any[]): any;
668
+ } ? Pick<IWrappedEntity<{
669
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
670
+ } & {
671
+ [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
672
+ } & (IsNever<Repository> extends true ? {} : {
673
+ [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
674
+ }) & Omit<Base, typeof PrimaryKeyProp>>, BaseEntityMethodKeys> : {}) & {
675
+ -readonly [K in keyof Properties]: InferBuilderValue<MaybeReturnType<Properties[K]>>;
676
+ } & {
677
+ [PrimaryKeyProp]?: InferCombinedPrimaryKey<Properties, PK, Base>;
678
+ } & (IsNever<Repository> extends true ? {} : {
679
+ [EntityRepositoryType]?: Repository extends Constructor<infer R> ? R : Repository;
680
+ }) & (IsNever<Base> extends true ? {} : Omit<Base, typeof PrimaryKeyProp>) & (ForceObject extends true ? {
681
+ [Config]?: DefineConfig<{
682
+ forceObject: true;
683
+ }>;
684
+ } : {});
685
+ type InferCombinedPrimaryKey<Properties extends Record<string, any>, PK, Base> = PK extends undefined ? CombinePrimaryKeys<InferPrimaryKey<Properties>, ExtractBasePrimaryKey<Base>> : PK;
686
+ type ExtractBasePrimaryKey<Base> = Base extends {
687
+ [PrimaryKeyProp]?: infer BasePK;
688
+ } ? BasePK : never;
689
+ type CombinePrimaryKeys<ChildPK, BasePK> = [ChildPK] extends [never] ? BasePK : [BasePK] extends [never] ? IsUnion<ChildPK> extends true ? ChildPK[] : ChildPK : ChildPK | BasePK;
690
+ export type InferPrimaryKey<Properties extends Record<string, any>> = {
691
+ [K in keyof Properties]: MaybeReturnType<Properties[K]> extends {
692
+ '~options': {
693
+ primary: true;
694
+ };
695
+ } ? K : never;
696
+ }[keyof Properties];
525
697
  type InferBuilderValue<Builder> = Builder extends {
526
698
  '~type'?: {
527
- value: infer T;
699
+ value: infer Value;
528
700
  };
529
- } ? T : never;
530
- type UnwrapRef<T> = T extends ScalarReference<any> ? UnwrapScalarReference<T> : T extends Reference<any> ? UnwrapReference<T> : T;
531
- type UnwrapScalarReference<T extends ScalarReference<any>> = T extends ScalarReference<infer Value> ? Value : T;
532
- type UnwrapReference<T extends Reference<any>> = T extends Reference<infer Value> ? Value : T;
533
- type UnwrapCollection<T> = T extends Collection<infer Value> ? Value : T;
534
- type UnwrapArray<T> = T extends (infer Value)[] ? Value : T;
701
+ '~options'?: infer Options;
702
+ } ? MaybeHidden<MaybeOpt<MaybeScalarRef<MaybeNullable<MaybeRelationRef<MaybeMapToPk<MaybeArray<Value, Options>, Options>, Options>, Options>, Options>, Options>, Options> : never;
703
+ type MaybeArray<Value, Options> = Options extends {
704
+ array: true;
705
+ } ? Value[] : Value;
706
+ type MaybeMapToPk<Value, Options> = Options extends {
707
+ mapToPk: true;
708
+ } ? Primary<Value> : Value;
709
+ type MaybeNullable<Value, Options> = Options extends {
710
+ nullable: true;
711
+ } ? Value | null | undefined : Value;
712
+ type MaybeRelationRef<Value, Options> = Options extends {
713
+ mapToPk: true;
714
+ } ? Value : Options extends {
715
+ ref: true;
716
+ kind: '1:1';
717
+ } ? Value extends object ? Ref<Value> : never : Options extends {
718
+ ref: true;
719
+ kind: 'm:1';
720
+ } ? Value extends object ? Ref<Value> : never : Options extends {
721
+ kind: '1:m';
722
+ } ? Value extends object ? Collection<Value> : never : Options extends {
723
+ kind: 'm:n';
724
+ } ? Value extends object ? Collection<Value> : never : Value;
725
+ type MaybeScalarRef<Value, Options> = Options extends {
726
+ kind: '1:1' | 'm:1' | '1:m' | 'm:n';
727
+ } ? Value : Options extends {
728
+ ref: true;
729
+ } ? ScalarReference<Value> : Value;
730
+ type MaybeOpt<Value, Options> = Options extends {
731
+ mapToPk: true;
732
+ } ? Value extends Opt<infer OriginalValue> ? OriginalValue : Value : Options extends {
733
+ autoincrement: true;
734
+ } | {
735
+ onCreate: Function;
736
+ } | {
737
+ default: string | string[] | number | number[] | boolean | null | Date | Raw;
738
+ } | {
739
+ defaultRaw: string;
740
+ } | {
741
+ persist: false;
742
+ } | {
743
+ version: true;
744
+ } | {
745
+ formula: string | ((...args: any[]) => any);
746
+ } ? Opt<Value> : Value;
747
+ type MaybeHidden<Value, Options> = Options extends {
748
+ hidden: true;
749
+ } ? Hidden<Value> : Value;
535
750
  type ValueOf<T extends Dictionary> = T[keyof T];
536
- export type InferEntity<Schema> = Schema extends EntitySchema<infer Entity, any> ? Entity : never;
537
- export {};
751
+ type IsUnion<T, U = T> = T extends U ? ([U] extends [T] ? false : true) : false;