@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.100

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 (281) hide show
  1. package/EntityManager.d.ts +96 -58
  2. package/EntityManager.js +465 -395
  3. package/MikroORM.d.ts +45 -35
  4. package/MikroORM.js +109 -160
  5. package/README.md +3 -2
  6. package/cache/CacheAdapter.js +1 -2
  7. package/cache/FileCacheAdapter.d.ts +2 -2
  8. package/cache/FileCacheAdapter.js +20 -27
  9. package/cache/GeneratedCacheAdapter.d.ts +2 -3
  10. package/cache/GeneratedCacheAdapter.js +1 -7
  11. package/cache/MemoryCacheAdapter.d.ts +1 -1
  12. package/cache/MemoryCacheAdapter.js +1 -5
  13. package/cache/NullCacheAdapter.d.ts +1 -1
  14. package/cache/NullCacheAdapter.js +1 -5
  15. package/cache/index.d.ts +4 -5
  16. package/cache/index.js +4 -21
  17. package/connections/Connection.d.ts +22 -14
  18. package/connections/Connection.js +27 -23
  19. package/connections/index.d.ts +1 -1
  20. package/connections/index.js +1 -17
  21. package/drivers/DatabaseDriver.d.ts +25 -15
  22. package/drivers/DatabaseDriver.js +77 -64
  23. package/drivers/IDatabaseDriver.d.ts +40 -16
  24. package/drivers/IDatabaseDriver.js +1 -4
  25. package/drivers/index.d.ts +2 -2
  26. package/drivers/index.js +2 -18
  27. package/entity/BaseEntity.d.ts +6 -7
  28. package/entity/BaseEntity.js +16 -23
  29. package/entity/Collection.d.ts +98 -34
  30. package/entity/Collection.js +466 -131
  31. package/entity/EntityAssigner.d.ts +3 -3
  32. package/entity/EntityAssigner.js +67 -64
  33. package/entity/EntityFactory.d.ts +10 -3
  34. package/entity/EntityFactory.js +112 -91
  35. package/entity/EntityHelper.d.ts +2 -2
  36. package/entity/EntityHelper.js +66 -53
  37. package/entity/EntityIdentifier.d.ts +1 -1
  38. package/entity/EntityIdentifier.js +1 -5
  39. package/entity/EntityLoader.d.ts +8 -7
  40. package/entity/EntityLoader.js +161 -128
  41. package/entity/EntityRepository.d.ts +8 -8
  42. package/entity/EntityRepository.js +7 -11
  43. package/entity/Reference.d.ts +10 -13
  44. package/entity/Reference.js +64 -46
  45. package/entity/WrappedEntity.d.ts +12 -17
  46. package/entity/WrappedEntity.js +22 -31
  47. package/entity/defineEntity.d.ts +568 -0
  48. package/entity/defineEntity.js +529 -0
  49. package/entity/index.d.ts +14 -13
  50. package/entity/index.js +14 -29
  51. package/entity/utils.d.ts +8 -1
  52. package/entity/utils.js +22 -13
  53. package/entity/validators.d.ts +11 -0
  54. package/entity/validators.js +65 -0
  55. package/entity/wrap.d.ts +1 -1
  56. package/entity/wrap.js +2 -6
  57. package/enums.d.ts +24 -9
  58. package/enums.js +50 -41
  59. package/errors.d.ts +11 -3
  60. package/errors.js +42 -32
  61. package/events/EventManager.d.ts +5 -4
  62. package/events/EventManager.js +26 -22
  63. package/events/EventSubscriber.d.ts +8 -5
  64. package/events/EventSubscriber.js +1 -2
  65. package/events/TransactionEventBroadcaster.d.ts +3 -3
  66. package/events/TransactionEventBroadcaster.js +1 -5
  67. package/events/index.d.ts +3 -3
  68. package/events/index.js +3 -19
  69. package/exceptions.js +18 -39
  70. package/hydration/Hydrator.d.ts +5 -5
  71. package/hydration/Hydrator.js +2 -6
  72. package/hydration/ObjectHydrator.d.ts +7 -7
  73. package/hydration/ObjectHydrator.js +58 -50
  74. package/hydration/index.d.ts +2 -2
  75. package/hydration/index.js +2 -18
  76. package/index.d.ts +21 -21
  77. package/index.js +20 -46
  78. package/logging/DefaultLogger.d.ts +2 -2
  79. package/logging/DefaultLogger.js +10 -13
  80. package/logging/Logger.d.ts +1 -1
  81. package/logging/Logger.js +1 -2
  82. package/logging/SimpleLogger.d.ts +3 -3
  83. package/logging/SimpleLogger.js +2 -6
  84. package/logging/colors.js +1 -5
  85. package/logging/index.d.ts +5 -4
  86. package/logging/index.js +5 -20
  87. package/logging/inspect.d.ts +2 -0
  88. package/logging/inspect.js +16 -0
  89. package/metadata/EntitySchema.d.ts +14 -10
  90. package/metadata/EntitySchema.js +78 -64
  91. package/metadata/MetadataDiscovery.d.ts +11 -14
  92. package/metadata/MetadataDiscovery.js +278 -317
  93. package/metadata/MetadataProvider.d.ts +13 -4
  94. package/metadata/MetadataProvider.js +47 -8
  95. package/metadata/MetadataStorage.d.ts +2 -7
  96. package/metadata/MetadataStorage.js +19 -35
  97. package/metadata/MetadataValidator.d.ts +3 -10
  98. package/metadata/MetadataValidator.js +51 -64
  99. package/metadata/discover-entities.d.ts +5 -0
  100. package/metadata/discover-entities.js +40 -0
  101. package/metadata/index.d.ts +6 -6
  102. package/metadata/index.js +6 -22
  103. package/metadata/types.d.ts +480 -0
  104. package/metadata/types.js +1 -0
  105. package/naming-strategy/AbstractNamingStrategy.d.ts +7 -3
  106. package/naming-strategy/AbstractNamingStrategy.js +11 -9
  107. package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
  108. package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
  109. package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
  110. package/naming-strategy/MongoNamingStrategy.js +2 -6
  111. package/naming-strategy/NamingStrategy.d.ts +12 -2
  112. package/naming-strategy/NamingStrategy.js +1 -2
  113. package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
  114. package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
  115. package/naming-strategy/index.d.ts +5 -5
  116. package/naming-strategy/index.js +5 -21
  117. package/not-supported.d.ts +2 -0
  118. package/not-supported.js +4 -0
  119. package/package.json +19 -20
  120. package/platforms/ExceptionConverter.d.ts +2 -2
  121. package/platforms/ExceptionConverter.js +4 -8
  122. package/platforms/Platform.d.ts +15 -22
  123. package/platforms/Platform.js +58 -88
  124. package/platforms/index.d.ts +2 -2
  125. package/platforms/index.js +2 -18
  126. package/serialization/EntitySerializer.d.ts +4 -2
  127. package/serialization/EntitySerializer.js +64 -51
  128. package/serialization/EntityTransformer.d.ts +1 -1
  129. package/serialization/EntityTransformer.js +48 -42
  130. package/serialization/SerializationContext.d.ts +2 -2
  131. package/serialization/SerializationContext.js +24 -25
  132. package/serialization/index.d.ts +3 -3
  133. package/serialization/index.js +3 -19
  134. package/types/ArrayType.d.ts +3 -3
  135. package/types/ArrayType.js +6 -11
  136. package/types/BigIntType.d.ts +12 -9
  137. package/types/BigIntType.js +6 -6
  138. package/types/BlobType.d.ts +3 -4
  139. package/types/BlobType.js +2 -11
  140. package/types/BooleanType.d.ts +5 -4
  141. package/types/BooleanType.js +5 -6
  142. package/types/CharacterType.d.ts +3 -3
  143. package/types/CharacterType.js +2 -6
  144. package/types/DateTimeType.d.ts +3 -3
  145. package/types/DateTimeType.js +2 -6
  146. package/types/DateType.d.ts +3 -3
  147. package/types/DateType.js +2 -6
  148. package/types/DecimalType.d.ts +9 -7
  149. package/types/DecimalType.js +5 -8
  150. package/types/DoubleType.d.ts +3 -3
  151. package/types/DoubleType.js +4 -7
  152. package/types/EnumArrayType.d.ts +4 -4
  153. package/types/EnumArrayType.js +4 -10
  154. package/types/EnumType.d.ts +3 -3
  155. package/types/EnumType.js +2 -6
  156. package/types/FloatType.d.ts +3 -3
  157. package/types/FloatType.js +2 -6
  158. package/types/IntegerType.d.ts +3 -3
  159. package/types/IntegerType.js +2 -6
  160. package/types/IntervalType.d.ts +3 -3
  161. package/types/IntervalType.js +2 -6
  162. package/types/JsonType.d.ts +4 -4
  163. package/types/JsonType.js +9 -8
  164. package/types/MediumIntType.d.ts +3 -3
  165. package/types/MediumIntType.js +2 -6
  166. package/types/SmallIntType.d.ts +3 -3
  167. package/types/SmallIntType.js +2 -6
  168. package/types/StringType.d.ts +3 -3
  169. package/types/StringType.js +2 -6
  170. package/types/TextType.d.ts +3 -3
  171. package/types/TextType.js +2 -6
  172. package/types/TimeType.d.ts +3 -3
  173. package/types/TimeType.js +4 -8
  174. package/types/TinyIntType.d.ts +3 -3
  175. package/types/TinyIntType.js +3 -6
  176. package/types/Type.d.ts +4 -6
  177. package/types/Type.js +6 -10
  178. package/types/Uint8ArrayType.d.ts +3 -4
  179. package/types/Uint8ArrayType.js +3 -12
  180. package/types/UnknownType.d.ts +3 -3
  181. package/types/UnknownType.js +2 -6
  182. package/types/UuidType.d.ts +3 -3
  183. package/types/UuidType.js +2 -6
  184. package/types/index.d.ts +25 -25
  185. package/types/index.js +52 -79
  186. package/typings.d.ts +134 -93
  187. package/typings.js +67 -65
  188. package/unit-of-work/ChangeSet.d.ts +1 -4
  189. package/unit-of-work/ChangeSet.js +13 -17
  190. package/unit-of-work/ChangeSetComputer.d.ts +8 -9
  191. package/unit-of-work/ChangeSetComputer.js +36 -38
  192. package/unit-of-work/ChangeSetPersister.d.ts +11 -9
  193. package/unit-of-work/ChangeSetPersister.js +100 -65
  194. package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
  195. package/unit-of-work/CommitOrderCalculator.js +6 -10
  196. package/unit-of-work/IdentityMap.d.ts +1 -1
  197. package/unit-of-work/IdentityMap.js +1 -5
  198. package/unit-of-work/UnitOfWork.d.ts +16 -8
  199. package/unit-of-work/UnitOfWork.js +266 -209
  200. package/unit-of-work/index.d.ts +6 -6
  201. package/unit-of-work/index.js +6 -22
  202. package/utils/AbstractSchemaGenerator.d.ts +11 -11
  203. package/utils/AbstractSchemaGenerator.js +21 -20
  204. package/utils/Configuration.d.ts +774 -224
  205. package/utils/Configuration.js +166 -216
  206. package/utils/ConfigurationLoader.d.ts +1 -53
  207. package/utils/ConfigurationLoader.js +1 -367
  208. package/utils/Cursor.d.ts +6 -9
  209. package/utils/Cursor.js +25 -25
  210. package/utils/DataloaderUtils.d.ts +18 -8
  211. package/utils/DataloaderUtils.js +63 -21
  212. package/utils/EntityComparator.d.ts +9 -5
  213. package/utils/EntityComparator.js +155 -108
  214. package/utils/NullHighlighter.d.ts +1 -1
  215. package/utils/NullHighlighter.js +1 -5
  216. package/utils/QueryHelper.d.ts +12 -4
  217. package/utils/QueryHelper.js +110 -53
  218. package/utils/RawQueryFragment.d.ts +37 -14
  219. package/utils/RawQueryFragment.js +50 -33
  220. package/utils/RequestContext.d.ts +2 -2
  221. package/utils/RequestContext.js +3 -7
  222. package/utils/TransactionContext.d.ts +1 -1
  223. package/utils/TransactionContext.js +4 -8
  224. package/utils/TransactionManager.d.ts +65 -0
  225. package/utils/TransactionManager.js +223 -0
  226. package/utils/Utils.d.ts +16 -100
  227. package/utils/Utils.js +114 -332
  228. package/utils/clone.js +7 -11
  229. package/utils/env-vars.d.ts +3 -0
  230. package/utils/env-vars.js +87 -0
  231. package/utils/fs-utils.d.ts +12 -0
  232. package/utils/fs-utils.js +97 -0
  233. package/utils/index.d.ts +14 -13
  234. package/utils/index.js +14 -29
  235. package/utils/upsert-utils.d.ts +8 -3
  236. package/utils/upsert-utils.js +57 -10
  237. package/decorators/Check.d.ts +0 -3
  238. package/decorators/Check.js +0 -16
  239. package/decorators/CreateRequestContext.d.ts +0 -3
  240. package/decorators/CreateRequestContext.js +0 -33
  241. package/decorators/Embeddable.d.ts +0 -8
  242. package/decorators/Embeddable.js +0 -14
  243. package/decorators/Embedded.d.ts +0 -18
  244. package/decorators/Embedded.js +0 -20
  245. package/decorators/Entity.d.ts +0 -18
  246. package/decorators/Entity.js +0 -16
  247. package/decorators/Enum.d.ts +0 -9
  248. package/decorators/Enum.js +0 -19
  249. package/decorators/Filter.d.ts +0 -2
  250. package/decorators/Filter.js +0 -11
  251. package/decorators/Formula.d.ts +0 -5
  252. package/decorators/Formula.js +0 -18
  253. package/decorators/Indexed.d.ts +0 -17
  254. package/decorators/Indexed.js +0 -24
  255. package/decorators/ManyToMany.d.ts +0 -40
  256. package/decorators/ManyToMany.js +0 -16
  257. package/decorators/ManyToOne.d.ts +0 -30
  258. package/decorators/ManyToOne.js +0 -16
  259. package/decorators/OneToMany.d.ts +0 -28
  260. package/decorators/OneToMany.js +0 -20
  261. package/decorators/OneToOne.d.ts +0 -24
  262. package/decorators/OneToOne.js +0 -10
  263. package/decorators/PrimaryKey.d.ts +0 -9
  264. package/decorators/PrimaryKey.js +0 -23
  265. package/decorators/Property.d.ts +0 -250
  266. package/decorators/Property.js +0 -34
  267. package/decorators/Transactional.d.ts +0 -13
  268. package/decorators/Transactional.js +0 -31
  269. package/decorators/hooks.d.ts +0 -16
  270. package/decorators/hooks.js +0 -59
  271. package/decorators/index.d.ts +0 -17
  272. package/decorators/index.js +0 -36
  273. package/entity/ArrayCollection.d.ts +0 -116
  274. package/entity/ArrayCollection.js +0 -399
  275. package/entity/EntityValidator.d.ts +0 -19
  276. package/entity/EntityValidator.js +0 -154
  277. package/index.mjs +0 -199
  278. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  279. package/metadata/ReflectMetadataProvider.js +0 -48
  280. package/utils/resolveContextProvider.d.ts +0 -10
  281. package/utils/resolveContextProvider.js +0 -31
package/typings.d.ts CHANGED
@@ -1,22 +1,23 @@
1
- import type { Transaction } from './connections';
2
- import { type Cascade, type DeferMode, type EventType, type LoadStrategy, type PopulatePath, type QueryOrderMap, ReferenceKind } from './enums';
3
- import { type AssignOptions } from './entity/EntityAssigner';
4
- import { type EntityIdentifier } from './entity/EntityIdentifier';
5
- import { type EntityLoaderOptions } from './entity/EntityLoader';
6
- import { type Collection } from './entity/Collection';
7
- import { type EntityFactory } from './entity/EntityFactory';
8
- import { type EntityRepository } from './entity/EntityRepository';
9
- import { Reference, type ScalarReference } from './entity/Reference';
10
- import type { MikroORM } from './MikroORM';
11
- import type { SerializationContext, SerializeOptions } from './serialization';
12
- import type { EntitySchema, MetadataStorage } from './metadata';
13
- import type { Type, types } from './types';
14
- import type { Platform } from './platforms';
15
- import type { Configuration, RawQueryFragment } from './utils';
16
- import type { EntityManager } from './EntityManager';
17
- import type { EmbeddedPrefixMode } from './decorators/Embedded';
18
- import type { EventSubscriber } from './events';
19
- import type { FindOneOptions, FindOptions, LoadHint } from './drivers';
1
+ import type { Transaction } from './connections/Connection.js';
2
+ import { type Cascade, type DeferMode, type EmbeddedPrefixMode, type EventType, type LoadStrategy, type PopulatePath, type QueryOrderMap, ReferenceKind } from './enums.js';
3
+ import { type AssignOptions } from './entity/EntityAssigner.js';
4
+ import { type EntityIdentifier } from './entity/EntityIdentifier.js';
5
+ import { type EntityLoaderOptions } from './entity/EntityLoader.js';
6
+ import { type Collection } from './entity/Collection.js';
7
+ import { type EntityFactory } from './entity/EntityFactory.js';
8
+ import { type EntityRepository } from './entity/EntityRepository.js';
9
+ import { Reference, type ScalarReference } from './entity/Reference.js';
10
+ import type { SerializationContext } from './serialization/SerializationContext.js';
11
+ import type { SerializeOptions } from './serialization/EntitySerializer.js';
12
+ import type { MetadataStorage } from './metadata/MetadataStorage.js';
13
+ import type { EntitySchema } from './metadata/EntitySchema.js';
14
+ import type { Type, types } from './types/index.js';
15
+ import type { Platform } from './platforms/Platform.js';
16
+ import type { Configuration } from './utils/Configuration.js';
17
+ import type { RawQueryFragment } from './utils/RawQueryFragment.js';
18
+ import type { EntityManager } from './EntityManager.js';
19
+ import type { EventSubscriber } from './events/EventSubscriber.js';
20
+ import type { FilterOptions, FindOneOptions, FindOptions, LoadHint } from './drivers/IDatabaseDriver.js';
20
21
  export type Constructor<T = unknown> = new (...args: any[]) => T;
21
22
  export type Dictionary<T = any> = {
22
23
  [k: string]: T;
@@ -25,6 +26,7 @@ export type EntityKey<T = unknown, B extends boolean = false> = string & {
25
26
  [K in keyof T]-?: CleanKeys<T, K, B> extends never ? never : K;
26
27
  }[keyof T];
27
28
  export type EntityValue<T> = T[EntityKey<T>];
29
+ export type EntityDataValue<T> = EntityData<T>[EntityKey<T>];
28
30
  export type FilterKey<T> = keyof FilterQuery<T>;
29
31
  export type AsyncFunction<R = any, T = Dictionary> = (args: T) => Promise<T>;
30
32
  export type Compute<T> = {
@@ -48,18 +50,34 @@ export declare const OptionalProps: unique symbol;
48
50
  export declare const EagerProps: unique symbol;
49
51
  export declare const HiddenProps: unique symbol;
50
52
  export declare const Config: unique symbol;
51
- declare const __optional: unique symbol;
52
- declare const __hidden: unique symbol;
53
- declare const __config: unique symbol;
54
- export type Opt<T = unknown> = T & {
55
- [__optional]?: 1;
56
- };
57
- export type Hidden<T = unknown> = T & {
58
- [__hidden]?: 1;
59
- };
60
- export type DefineConfig<T extends TypeConfig> = T & {
61
- [__config]?: 1;
62
- };
53
+ export type Opt<T = unknown> = T & Opt.Brand;
54
+ export declare namespace Opt {
55
+ const __optional: unique symbol;
56
+ interface Brand {
57
+ [__optional]?: 1;
58
+ }
59
+ }
60
+ export type RequiredNullable<T = never> = (T & RequiredNullable.Brand) | null;
61
+ export declare namespace RequiredNullable {
62
+ const __requiredNullable: unique symbol;
63
+ interface Brand {
64
+ [__requiredNullable]?: 1;
65
+ }
66
+ }
67
+ export type Hidden<T = unknown> = T & Hidden.Brand;
68
+ export declare namespace Hidden {
69
+ const __hidden: unique symbol;
70
+ interface Brand {
71
+ [__hidden]?: 1;
72
+ }
73
+ }
74
+ export type DefineConfig<T extends TypeConfig> = T & DefineConfig.Brand;
75
+ export declare namespace DefineConfig {
76
+ const __config: unique symbol;
77
+ interface Brand {
78
+ [__config]?: 1;
79
+ }
80
+ }
63
81
  export type CleanTypeConfig<T> = Compute<Pick<T, Extract<keyof T, keyof TypeConfig>>>;
64
82
  export interface TypeConfig {
65
83
  forceObject?: boolean;
@@ -71,13 +89,14 @@ type PrimaryPropToType<T, Keys extends (keyof T)[]> = {
71
89
  type ReadonlyPrimary<T> = T extends any[] ? Readonly<T> : T;
72
90
  export type Primary<T> = IsAny<T> extends true ? any : T extends {
73
91
  [PrimaryKeyProp]?: infer PK;
74
- } ? (PK extends keyof T ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : (PK extends (keyof T)[] ? ReadonlyPrimary<PrimaryPropToType<T, PK>> : PK)) : T extends {
92
+ } ? PK extends undefined ? Omit<T, typeof PrimaryKeyProp> : PK extends keyof T ? ReadonlyPrimary<UnwrapPrimary<T[PK]>> : PK extends (keyof T)[] ? ReadonlyPrimary<PrimaryPropToType<T, PK>> : PK : T extends {
75
93
  _id?: infer PK;
76
94
  } ? ReadonlyPrimary<PK> | string : T extends {
77
- uuid?: infer PK;
78
- } ? ReadonlyPrimary<PK> : T extends {
79
95
  id?: infer PK;
96
+ } ? ReadonlyPrimary<PK> : T extends {
97
+ uuid?: infer PK;
80
98
  } ? ReadonlyPrimary<PK> : T;
99
+ /** @internal */
81
100
  export type PrimaryProperty<T> = T extends {
82
101
  [PrimaryKeyProp]?: infer PK;
83
102
  } ? (PK extends keyof T ? PK : (PK extends any[] ? PK[number] : never)) : T extends {
@@ -85,10 +104,10 @@ export type PrimaryProperty<T> = T extends {
85
104
  } ? (T extends {
86
105
  id?: any;
87
106
  } ? 'id' | '_id' : '_id') : T extends {
88
- uuid?: any;
89
- } ? 'uuid' : T extends {
90
107
  id?: any;
91
- } ? 'id' : never;
108
+ } ? 'id' : T extends {
109
+ uuid?: any;
110
+ } ? 'uuid' : never;
92
111
  export type IPrimaryKeyValue = number | string | bigint | Date | {
93
112
  toHexString(): string;
94
113
  };
@@ -129,7 +148,6 @@ export type FilterValue<T> = OperatorMap<FilterItemValue<T>> | FilterItemValue<T
129
148
  export type FilterObject<T> = {
130
149
  -readonly [K in EntityKey<T>]?: ExpandQuery<ExpandProperty<T[K]>> | FilterValue<ExpandProperty<T[K]>> | null;
131
150
  };
132
- export type ExpandObject<T> = T extends object ? T extends Scalar ? never : FilterObject<T> : never;
133
151
  export type ExpandQuery<T> = T extends object ? T extends Scalar ? never : FilterQuery<T> : FilterValue<T>;
134
152
  export type EntityProps<T> = {
135
153
  -readonly [K in EntityKey<T>]?: T[K];
@@ -139,7 +157,6 @@ export type FilterQuery<T> = ObjectQuery<T> | NonNullable<ExpandScalar<Primary<T
139
157
  export type QBFilterQuery<T = any> = ObjectQuery<T> | Dictionary;
140
158
  export interface IWrappedEntity<Entity extends object> {
141
159
  isInitialized(): boolean;
142
- isTouched(): boolean;
143
160
  isManaged(): boolean;
144
161
  populated(populated?: boolean): void;
145
162
  populate<Hint extends string = never>(populate: AutoPath<Entity, Hint>[] | false, options?: EntityLoaderOptions<Entity>): Promise<Loaded<Entity, Hint>>;
@@ -170,10 +187,9 @@ export interface IWrappedEntityInternal<Entity extends object> extends IWrappedE
170
187
  __factory: EntityFactory;
171
188
  __hydrator: IHydrator;
172
189
  __initialized: boolean;
173
- __touched: boolean;
174
190
  __originalEntityData?: EntityData<Entity>;
175
191
  __loadedProperties: Set<string>;
176
- __identifier?: EntityIdentifier;
192
+ __identifier?: EntityIdentifier | EntityIdentifier[];
177
193
  __managed: boolean;
178
194
  __processing: boolean;
179
195
  __schema?: string;
@@ -193,16 +209,12 @@ export type AnyEntity<T = any> = Partial<T>;
193
209
  export type EntityClass<T> = Function & {
194
210
  prototype: T;
195
211
  };
196
- export type EntityClassGroup<T> = {
197
- entity: EntityClass<T>;
198
- schema: EntityMetadata<T> | EntitySchema<T>;
199
- };
200
212
  export type EntityName<T> = string | EntityClass<T> | EntitySchema<T, any> | {
201
213
  name: string;
202
214
  };
203
215
  export type GetRepository<Entity extends {
204
216
  [k: PropertyKey]: any;
205
- }, Fallback> = Entity[typeof EntityRepositoryType] extends EntityRepository<Entity> | undefined ? NonNullable<Entity[typeof EntityRepositoryType]> : Fallback;
217
+ }, Fallback> = Entity[typeof EntityRepositoryType] extends EntityRepository<any> | undefined ? NonNullable<Entity[typeof EntityRepositoryType]> : Fallback;
206
218
  export type EntityDataPropValue<T> = T | Primary<T>;
207
219
  type ExpandEntityProp<T, C extends boolean = false> = T extends Record<string, any> ? {
208
220
  [K in keyof T as CleanKeys<T, K>]?: EntityDataProp<ExpandProperty<T[K]>, C> | EntityDataPropValue<ExpandProperty<T[K]>> | null;
@@ -213,14 +225,17 @@ type ExpandRequiredEntityPropObject<T, I = never, C extends boolean = false> = {
213
225
  } & {
214
226
  [K in keyof T as OptionalKeys<T, K, I>]?: RequiredEntityDataProp<ExpandProperty<T[K]>, T, C> | EntityDataPropValue<ExpandProperty<T[K]>> | null | undefined;
215
227
  };
228
+ type NonArrayObject = object & {
229
+ [Symbol.iterator]?: never;
230
+ };
216
231
  export type EntityDataProp<T, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
217
232
  __runtime?: infer Runtime;
218
233
  __raw?: infer Raw;
219
- } ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? EntityDataNested<U, C> : T extends ScalarReference<infer U> ? EntityDataProp<U, C> : T extends Collection<infer U, any> ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : T extends readonly (infer U)[] ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
220
- export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : T extends Scalar ? T : T extends {
234
+ } ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? EntityDataNested<U, C> : T extends ScalarReference<infer U> ? EntityDataProp<U, C> : T extends Collection<infer U, any> ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | EntityDataNested<U, C> | EntityDataNested<U, C>[] : U[] | EntityDataNested<U, C>[] : EntityDataNested<T, C>;
235
+ export type RequiredEntityDataProp<T, O, C extends boolean> = T extends Date ? string | Date : Exclude<T, null> extends RequiredNullable.Brand ? T | null : T extends Scalar ? T : T extends {
221
236
  __runtime?: infer Runtime;
222
237
  __raw?: infer Raw;
223
- } ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? RequiredEntityDataNested<U, O, C> : T extends ScalarReference<infer U> ? RequiredEntityDataProp<U, O, C> : T extends Collection<infer U, any> ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : T extends readonly (infer U)[] ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : RequiredEntityDataNested<T, O, C>;
238
+ } ? (C extends true ? Raw : Runtime) : T extends Reference<infer U> ? RequiredEntityDataNested<U, O, C> : T extends ScalarReference<infer U> ? RequiredEntityDataProp<U, O, C> : T extends Collection<infer U, any> ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : T extends readonly (infer U)[] ? U extends NonArrayObject ? U | U[] | RequiredEntityDataNested<U, O, C> | RequiredEntityDataNested<U, O, C>[] : U[] | RequiredEntityDataNested<U, O, C>[] : RequiredEntityDataNested<T, O, C>;
224
239
  export type EntityDataNested<T, C extends boolean = false> = T extends undefined ? never : T extends any[] ? Readonly<T> : EntityData<T, C> | ExpandEntityProp<T, C>;
225
240
  type EntityDataItem<T, C extends boolean> = C extends false ? T | EntityDataProp<T, C> | null : EntityDataProp<T, C> | null;
226
241
  export type RequiredEntityDataNested<T, O, C extends boolean> = T extends any[] ? Readonly<T> : RequiredEntityData<T, O> | ExpandRequiredEntityProp<T, O, C>;
@@ -232,12 +247,15 @@ type ExplicitlyOptionalProps<T> = (T extends {
232
247
  type NullableKeys<T, V = null> = {
233
248
  [K in keyof T]: V extends T[K] ? K : never;
234
249
  }[keyof T];
235
- type ProbablyOptionalProps<T> = PrimaryProperty<T> | ExplicitlyOptionalProps<T> | NonNullable<NullableKeys<T, null | undefined>>;
250
+ type RequiredNullableKeys<T> = {
251
+ [K in keyof T]: Exclude<T[K], null> extends RequiredNullable.Brand ? K : never;
252
+ }[keyof T];
253
+ type ProbablyOptionalProps<T> = PrimaryProperty<T> | ExplicitlyOptionalProps<T> | Exclude<NonNullable<NullableKeys<T, null | undefined>>, RequiredNullableKeys<T>>;
236
254
  type IsOptional<T, K extends keyof T, I> = T[K] extends Collection<any, any> ? true : ExtractType<T[K]> extends I ? true : K extends ProbablyOptionalProps<T> ? true : false;
237
255
  type RequiredKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? CleanKeys<T, K> : never;
238
256
  type OptionalKeys<T, K extends keyof T, I> = IsOptional<T, K, I> extends false ? never : CleanKeys<T, K>;
239
257
  export type EntityData<T, C extends boolean = false> = {
240
- [K in EntityKey<T>]?: EntityDataItem<T[K], C>;
258
+ [K in EntityKey<T>]?: EntityDataItem<T[K] & {}, C>;
241
259
  };
242
260
  export type RequiredEntityData<T, I = never, C extends boolean = false> = {
243
261
  [K in keyof T as RequiredKeys<T, K, I>]: T[K] | RequiredEntityDataProp<T[K], T, C> | Primary<T[K]>;
@@ -279,7 +297,7 @@ type PrimaryOrObject<T, U, C extends TypeConfig> = PreferExplicitConfig<C, Extra
279
297
  } : Primary<U>;
280
298
  export type EntityDTOProp<E, T, C extends TypeConfig = never> = T extends Scalar ? T : T extends {
281
299
  __serialized?: infer U;
282
- } ? U : T extends LoadedReference<infer U> ? EntityDTO<U, C> : T extends Reference<infer U> ? PrimaryOrObject<E, U, C> : T extends ScalarReference<infer U> ? U : T extends LoadedCollection<infer U> ? EntityDTO<U, C>[] : T extends Collection<infer U> ? PrimaryOrObject<E, U, C>[] : T extends readonly (infer U)[] ? (T extends readonly any[] ? T : U[]) : T extends Relation<T> ? EntityDTO<T, C> : T;
300
+ } ? (IsUnknown<U> extends false ? U : T) : T extends LoadedReference<infer U> ? EntityDTO<U, C> : T extends Reference<infer U> ? PrimaryOrObject<E, U, C> : T extends ScalarReference<infer U> ? U : T extends LoadedCollection<infer U> ? EntityDTO<U, C>[] : T extends Collection<infer U> ? PrimaryOrObject<E, U, C>[] : T extends readonly (infer U)[] ? (T extends readonly any[] ? T : U[]) : T extends Relation<T> ? EntityDTO<T, C> : T;
283
301
  type DTOProbablyOptionalProps<T> = NonNullable<NullableKeys<T, undefined>>;
284
302
  type DTOIsOptional<T, K extends keyof T> = T[K] extends LoadedCollection<any> ? false : K extends PrimaryProperty<T> ? false : K extends DTOProbablyOptionalProps<T> ? true : false;
285
303
  type DTORequiredKeys<T, K extends keyof T> = DTOIsOptional<T, K> extends false ? ExcludeHidden<T, K> & CleanKeys<T, K> : never;
@@ -289,7 +307,15 @@ export type EntityDTO<T, C extends TypeConfig = never> = {
289
307
  } & {
290
308
  [K in keyof T as DTOOptionalKeys<T, K>]?: EntityDTOProp<T, T[K], C> | AddOptional<T[K]>;
291
309
  };
292
- export type CheckCallback<T> = (columns: Record<keyof T, string>) => string;
310
+ type TargetKeys<T> = T extends EntityClass<infer P> ? keyof P : keyof T;
311
+ type PropertyName<T> = IsUnknown<T> extends false ? TargetKeys<T> : string;
312
+ type TableName = {
313
+ name: string;
314
+ schema?: string;
315
+ toString: () => string;
316
+ };
317
+ export type IndexCallback<T> = (table: TableName, columns: Record<PropertyName<T>, string>, indexName: string) => string | RawQueryFragment;
318
+ export type CheckCallback<T> = (columns: Record<PropertyName<T>, string>) => string;
293
319
  export type GeneratedColumnCallback<T> = (columns: Record<keyof T, string>) => string;
294
320
  export interface CheckConstraint<T = any> {
295
321
  name?: string;
@@ -326,6 +352,7 @@ export interface EntityProperty<Owner = any, Target = any> {
326
352
  default?: string | number | boolean | null;
327
353
  defaultRaw?: string;
328
354
  formula?: (alias: string) => string;
355
+ filters?: FilterOptions;
329
356
  prefix?: string | boolean;
330
357
  prefixMode?: EmbeddedPrefixMode;
331
358
  embedded?: [EntityKey<Owner>, EntityKey<Owner>];
@@ -342,7 +369,6 @@ export interface EntityProperty<Owner = any, Target = any> {
342
369
  mapToPk?: boolean;
343
370
  persist?: boolean;
344
371
  hydrate?: boolean;
345
- trackChanges?: boolean;
346
372
  hidden?: boolean;
347
373
  enum?: boolean;
348
374
  items?: (number | string)[];
@@ -353,6 +379,7 @@ export interface EntityProperty<Owner = any, Target = any> {
353
379
  setter?: boolean;
354
380
  getter?: boolean;
355
381
  getterName?: keyof Owner;
382
+ accessor?: EntityKey<Owner>;
356
383
  cascade: Cascade[];
357
384
  orphanRemoval?: boolean;
358
385
  onCreate?: (entity: Owner, em: EntityManager) => any;
@@ -385,6 +412,8 @@ export interface EntityProperty<Owner = any, Target = any> {
385
412
  optional?: boolean;
386
413
  ignoreSchemaChanges?: ('type' | 'extra' | 'default')[];
387
414
  deferMode?: DeferMode;
415
+ createForeignKeyConstraint: boolean;
416
+ foreignKeyName?: string;
388
417
  }
389
418
  export declare class EntityMetadata<T = any> {
390
419
  private static counter;
@@ -393,8 +422,9 @@ export declare class EntityMetadata<T = any> {
393
422
  constructor(meta?: Partial<EntityMetadata>);
394
423
  addProperty(prop: Partial<EntityProperty<T>>, sync?: boolean): void;
395
424
  removeProperty(name: string, sync?: boolean): void;
396
- getPrimaryProps(): EntityProperty<T>[];
425
+ getPrimaryProps(flatten?: boolean): EntityProperty<T>[];
397
426
  getPrimaryProp(): EntityProperty<T>;
427
+ createColumnMappingObject(): Dictionary<any>;
398
428
  get tableName(): string;
399
429
  set tableName(name: string);
400
430
  sync(initIndexes?: boolean, config?: Configuration): void;
@@ -413,14 +443,13 @@ export interface EntityMetadata<T = any> {
413
443
  schema?: string;
414
444
  pivotTable?: boolean;
415
445
  virtual?: boolean;
416
- expression?: string | ((em: any, where: FilterQuery<T>, options: FindOptions<T, any, any, any>) => MaybePromise<RawQueryFragment | object | string>);
446
+ expression?: string | ((em: any, where: ObjectQuery<T>, options: FindOptions<T, any, any, any>, stream?: boolean) => MaybePromise<RawQueryFragment | object | string>);
417
447
  discriminatorColumn?: EntityKey<T> | AnyString;
418
448
  discriminatorValue?: number | string;
419
449
  discriminatorMap?: Dictionary<string>;
420
450
  embeddable: boolean;
421
- constructorParams: EntityKey<T>[];
451
+ constructorParams?: (keyof T)[];
422
452
  forceConstructor: boolean;
423
- toJsonParams: string[];
424
453
  extends: string;
425
454
  collection: string;
426
455
  path: string;
@@ -429,7 +458,7 @@ export interface EntityMetadata<T = any> {
429
458
  compositePK: boolean;
430
459
  versionProperty: EntityKey<T>;
431
460
  concurrencyCheckKeys: Set<EntityKey<T>>;
432
- serializedPrimaryKey: EntityKey<T>;
461
+ serializedPrimaryKey?: EntityKey<T>;
433
462
  properties: {
434
463
  [K in EntityKey<T>]: EntityProperty<T>;
435
464
  };
@@ -443,21 +472,22 @@ export interface EntityMetadata<T = any> {
443
472
  comparableProps: EntityProperty<T>[];
444
473
  trackingProps: EntityProperty<T>[];
445
474
  hydrateProps: EntityProperty<T>[];
475
+ validateProps: EntityProperty<T>[];
446
476
  uniqueProps: EntityProperty<T>[];
447
477
  getterProps: EntityProperty<T>[];
448
478
  indexes: {
449
- properties: EntityKey<T> | EntityKey<T>[];
479
+ properties?: EntityKey<T> | EntityKey<T>[];
450
480
  name?: string;
451
481
  type?: string;
452
482
  options?: Dictionary;
453
- expression?: string;
483
+ expression?: string | IndexCallback<T>;
454
484
  }[];
455
485
  uniques: {
456
- properties: EntityKey<T> | EntityKey<T>[];
486
+ properties?: EntityKey<T> | EntityKey<T>[];
457
487
  name?: string;
458
488
  options?: Dictionary;
459
- expression?: string;
460
- deferMode?: DeferMode;
489
+ expression?: string | IndexCallback<T>;
490
+ deferMode?: DeferMode | `${DeferMode}`;
461
491
  }[];
462
492
  checks: CheckConstraint<T>[];
463
493
  repositoryClass?: string;
@@ -468,7 +498,6 @@ export interface EntityMetadata<T = any> {
468
498
  prototype: T;
469
499
  class: EntityClass<T>;
470
500
  abstract: boolean;
471
- useCache: boolean;
472
501
  filters: Dictionary<FilterDef>;
473
502
  comment?: string;
474
503
  selfReferencing?: boolean;
@@ -477,6 +506,7 @@ export interface EntityMetadata<T = any> {
477
506
  polymorphs?: EntityMetadata[];
478
507
  root: EntityMetadata<T>;
479
508
  definedProperties: Dictionary;
509
+ hasTriggers?: boolean;
480
510
  /** @internal can be used for computed numeric cache keys */
481
511
  readonly _id: number;
482
512
  }
@@ -487,6 +517,7 @@ export interface CreateSchemaOptions {
487
517
  export interface ClearDatabaseOptions {
488
518
  schema?: string;
489
519
  truncate?: boolean;
520
+ clearIdentityMap?: boolean;
490
521
  }
491
522
  export interface EnsureDatabaseOptions extends CreateSchemaOptions, ClearDatabaseOptions {
492
523
  clear?: boolean;
@@ -514,25 +545,25 @@ export interface RefreshDatabaseOptions extends CreateSchemaOptions {
514
545
  createSchema?: boolean;
515
546
  }
516
547
  export interface ISchemaGenerator {
517
- createSchema(options?: CreateSchemaOptions): Promise<void>;
518
- ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
548
+ create(options?: CreateSchemaOptions): Promise<void>;
549
+ update(options?: UpdateSchemaOptions): Promise<void>;
550
+ drop(options?: DropSchemaOptions): Promise<void>;
551
+ refresh(options?: RefreshDatabaseOptions): Promise<void>;
552
+ clear(options?: ClearDatabaseOptions): Promise<void>;
553
+ execute(sql: string, options?: {
554
+ wrap?: boolean;
555
+ }): Promise<void>;
519
556
  getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
520
- dropSchema(options?: DropSchemaOptions): Promise<void>;
521
557
  getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
522
- updateSchema(options?: UpdateSchemaOptions): Promise<void>;
523
558
  getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
524
559
  getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
525
560
  up: string;
526
561
  down: string;
527
562
  }>;
563
+ ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
528
564
  createDatabase(name?: string): Promise<void>;
529
565
  dropDatabase(name?: string): Promise<void>;
530
- execute(sql: string, options?: {
531
- wrap?: boolean;
532
- }): Promise<void>;
533
566
  ensureIndexes(): Promise<void>;
534
- refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
535
- clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
536
567
  }
537
568
  export type ImportsResolver = (alias: string, basePath: string, extension: '.js' | '', originFileName: string) => {
538
569
  path: string;
@@ -549,7 +580,10 @@ export interface GenerateOptions {
549
580
  undefinedDefaults?: boolean;
550
581
  bidirectionalRelations?: boolean;
551
582
  identifiedReferences?: boolean;
552
- entitySchema?: boolean;
583
+ entityDefinition?: 'decorators' | 'defineEntity' | 'entitySchema';
584
+ decorators?: 'es' | 'legacy';
585
+ inferEntityType?: boolean;
586
+ enumMode?: 'ts-enum' | 'union-type' | 'dictionary';
553
587
  esmImport?: boolean;
554
588
  scalarTypeInDecorator?: boolean;
555
589
  scalarPropertiesForRelations?: 'always' | 'never' | 'smart';
@@ -609,26 +643,26 @@ export interface IMigrator {
609
643
  /**
610
644
  * Checks current schema for changes, generates new migration if there are any.
611
645
  */
612
- createMigration(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
646
+ create(path?: string, blank?: boolean, initial?: boolean, name?: string): Promise<MigrationResult>;
613
647
  /**
614
648
  * Checks current schema for changes.
615
649
  */
616
- checkMigrationNeeded(): Promise<boolean>;
650
+ checkSchema(): Promise<boolean>;
617
651
  /**
618
652
  * Creates initial migration. This generates the schema based on metadata, and checks whether all the tables
619
653
  * are already present. If yes, it will also automatically log the migration as executed.
620
654
  * Initial migration can be created only if the schema is already aligned with the metadata, or when no schema
621
655
  * is present - in such case regular migration would have the same effect.
622
656
  */
623
- createInitialMigration(path?: string): Promise<MigrationResult>;
657
+ createInitial(path?: string): Promise<MigrationResult>;
624
658
  /**
625
659
  * Returns list of already executed migrations.
626
660
  */
627
- getExecutedMigrations(): Promise<MigrationRow[]>;
661
+ getExecuted(): Promise<MigrationRow[]>;
628
662
  /**
629
663
  * Returns list of pending (not yet executed) migrations found in the migration directory.
630
664
  */
631
- getPendingMigrations(): Promise<UmzugMigration[]>;
665
+ getPending(): Promise<UmzugMigration[]>;
632
666
  /**
633
667
  * Executes specified migrations. Without parameter it will migrate up to the latest version.
634
668
  */
@@ -677,12 +711,17 @@ export interface MigrationObject {
677
711
  name: string;
678
712
  class: Constructor<Migration>;
679
713
  }
680
- export type FilterDef = {
714
+ type EntityFromInput<T> = T extends readonly EntityName<infer U>[] ? U : T extends EntityName<infer U> ? U : never;
715
+ type FilterDefResolved<T extends object = any> = {
681
716
  name: string;
682
- cond: Dictionary | ((args: Dictionary, type: 'read' | 'update' | 'delete', em: any, options?: FindOptions<any, any, any, any> | FindOneOptions<any, any, any, any>) => Dictionary | Promise<Dictionary>);
717
+ cond: FilterQuery<T> | ((args: Dictionary, type: 'read' | 'update' | 'delete', em: any, options?: FindOptions<T, any, any, any> | FindOneOptions<T, any, any, any>, entityName?: EntityName<T>) => MaybePromise<FilterQuery<T>>);
683
718
  default?: boolean;
684
- entity?: string[];
719
+ entity?: EntityName<T> | EntityName<T>[];
685
720
  args?: boolean;
721
+ strict?: boolean;
722
+ };
723
+ export type FilterDef<T extends EntityName<any> | readonly EntityName<any>[] = any> = FilterDefResolved<EntityFromInput<T>> & {
724
+ entity?: T;
686
725
  };
687
726
  export type Populate<T, P extends string = never> = readonly AutoPath<T, P, `${PopulatePath}`>[] | false;
688
727
  export type PopulateOptions<T> = {
@@ -690,6 +729,7 @@ export type PopulateOptions<T> = {
690
729
  strategy?: LoadStrategy;
691
730
  all?: boolean;
692
731
  filter?: boolean;
732
+ joinType?: 'inner join' | 'left join';
693
733
  children?: PopulateOptions<T[keyof T]>[];
694
734
  };
695
735
  type Loadable<T extends object> = Collection<T, any> | Reference<T> | Ref<T> | readonly T[];
@@ -724,7 +764,7 @@ export type MergeSelected<T, U, F extends string> = T extends Loaded<infer TT, i
724
764
  type MergeFields<F1 extends string, F2 extends string, P1, P2> = P1 | P2 extends '*' ? '*' : F1 | F2;
725
765
  type MergeExcludes<F extends string, E extends string> = F extends E ? never : Exclude<E, F>;
726
766
  export type MergeLoaded<T, U, P extends string, F extends string, E extends string, R extends boolean = false> = T extends Loaded<U, infer PP, infer FF, infer EE> ? string extends FF ? Loaded<T, P, F, AnyStringToNever<EE> | E> : string extends P ? Loaded<U, never, F | (FF & string), MergeExcludes<F | (FF & string), EE | E>> : Loaded<U, P | AnyStringToNever<PP>, MergeFields<F, AnyStringToNever<FF>, P, PP>, MergeExcludes<MergeFields<F, AnyStringToNever<FF>, P, PP>, (R extends true ? never : EE) | E>> : Loaded<T, P, F>;
727
- type AddOptional<T> = undefined | null extends T ? null | undefined : null extends T ? null : undefined extends T ? undefined : never;
767
+ export type AddOptional<T> = undefined | null extends T ? null | undefined : null extends T ? null : undefined extends T ? undefined : never;
728
768
  type LoadedProp<T, L extends string = never, F extends string = '*', E extends string = never> = LoadedLoadable<T, Loaded<ExtractType<T>, L, F, E>>;
729
769
  export type AddEager<T> = ExtractEagerProps<T> & string;
730
770
  export type ExpandHint<T, L extends string> = L | AddEager<T>;
@@ -785,11 +825,11 @@ export interface IHydrator {
785
825
  * Hydrates the whole entity. This process handles custom type conversions, creating missing Collection instances,
786
826
  * mapping FKs to entity instances, as well as merging those entities.
787
827
  */
788
- hydrate<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, type: 'full' | 'reference', newEntity?: boolean, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
828
+ hydrate<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, type: 'full' | 'reference', newEntity?: boolean, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
789
829
  /**
790
830
  * Hydrates primary keys only
791
831
  */
792
- hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string): void;
832
+ hydrateReference<T extends object>(entity: T, meta: EntityMetadata<T>, data: EntityData<T>, factory: EntityFactory, convertCustomTypes?: boolean, schema?: string, parentSchema?: string, normalizeAccessors?: boolean): void;
793
833
  isRunning(): boolean;
794
834
  }
795
835
  export interface HydratorConstructor {
@@ -799,17 +839,18 @@ export interface ISeedManager {
799
839
  seed(...classNames: Constructor<Seeder>[]): Promise<void>;
800
840
  /** @internal */
801
841
  seedString(...classNames: string[]): Promise<void>;
802
- createSeeder(className: string): Promise<string>;
842
+ create(className: string): Promise<string>;
803
843
  }
804
844
  export interface Seeder<T extends Dictionary = Dictionary> {
805
845
  run(em: EntityManager, context?: T): void | Promise<void>;
806
846
  }
807
847
  export type ConnectionType = 'read' | 'write';
808
848
  export type MetadataProcessor = (metadata: EntityMetadata[], platform: Platform) => MaybePromise<void>;
809
- /**
810
- * The type of context that the user intends to inject.
811
- */
812
- export type ContextProvider<T> = MaybePromise<MikroORM> | ((type: T) => MaybePromise<MikroORM | EntityManager | EntityRepository<any> | {
813
- getEntityManager(): EntityManager;
814
- }>);
849
+ export type MaybeReturnType<T> = T extends (...args: any[]) => infer R ? R : T;
850
+ export interface EntitySchemaWithMeta<TName extends string = string, TTableName extends string = string, TEntity = any, TBase = never, TProperties extends Record<string, any> = Record<string, any>> extends EntitySchema<TEntity, TBase> {
851
+ readonly name: TName;
852
+ readonly properties: TProperties;
853
+ readonly tableName: TTableName;
854
+ }
855
+ export type InferEntity<Schema> = Schema extends EntitySchemaWithMeta<any, any, infer Entity, any, any> ? Entity : Schema extends EntitySchema<infer Entity> ? Entity : Schema extends EntityClass<infer Entity> ? Entity : Schema;
815
856
  export {};