@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
@@ -1,148 +1,139 @@
1
- import type { NamingStrategy } from '../naming-strategy';
2
- import { FileCacheAdapter, type SyncCacheAdapter, type CacheAdapter } from '../cache';
3
- import type { EntityRepository } from '../entity/EntityRepository';
4
- import type { AnyEntity, Constructor, Dictionary, EntityClass, EntityClassGroup, FilterDef, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, MigrationObject, EntityMetadata, EnsureDatabaseOptions, GenerateOptions, Migration } from '../typings';
5
- import { ObjectHydrator } from '../hydration/ObjectHydrator';
6
- import { NullHighlighter } from '../utils/NullHighlighter';
7
- import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging';
8
- import type { EntityManager } from '../EntityManager';
9
- import type { Platform } from '../platforms';
10
- import type { EntitySchema } from '../metadata/EntitySchema';
11
- import type { MetadataProvider } from '../metadata/MetadataProvider';
12
- import type { MetadataStorage } from '../metadata/MetadataStorage';
13
- import { ReflectMetadataProvider } from '../metadata/ReflectMetadataProvider';
14
- import type { EmbeddedPrefixMode } from '../decorators/Embedded';
15
- import type { EventSubscriber } from '../events';
16
- import type { AssignOptions } from '../entity/EntityAssigner';
17
- import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver';
18
- import { NotFoundError } from '../errors';
19
- import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums';
20
- import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter';
21
- import { EntityComparator } from './EntityComparator';
22
- import type { Type } from '../types/Type';
23
- import type { MikroORM } from '../MikroORM';
24
- export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager> {
25
- static readonly DEFAULTS: {
26
- pool: {};
27
- entities: never[];
28
- entitiesTs: never[];
29
- extensions: never[];
30
- subscribers: never[];
31
- filters: {};
32
- discovery: {
33
- warnWhenNoEntities: true;
34
- requireEntitiesArray: false;
35
- checkDuplicateTableNames: true;
36
- checkDuplicateFieldNames: true;
37
- checkDuplicateEntities: true;
38
- checkNonPersistentCompositeProps: true;
39
- alwaysAnalyseProperties: true;
40
- disableDynamicFileAccess: false;
41
- inferDefaultValues: true;
42
- };
43
- strict: false;
44
- validate: false;
45
- validateRequired: true;
46
- context: (name: string) => EntityManager<IDatabaseDriver<import("..").Connection>> | undefined;
47
- contextName: string;
48
- allowGlobalContext: false;
49
- logger: (message?: any, ...optionalParams: any[]) => void;
50
- colors: true;
51
- findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
52
- findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
53
- baseDir: string;
54
- hydrator: typeof ObjectHydrator;
55
- flushMode: FlushMode.AUTO;
56
- loadStrategy: LoadStrategy.JOINED;
57
- dataloader: DataloaderType.NONE;
58
- populateWhere: PopulateHint.ALL;
59
- connect: true;
60
- ignoreUndefinedInQuery: false;
61
- onQuery: (sql: string) => string;
62
- autoJoinOneToOneOwner: true;
63
- autoJoinRefsForFilters: true;
64
- propagationOnPrototype: true;
65
- populateAfterFlush: true;
66
- serialization: {
67
- includePrimaryKeys: true;
68
- };
69
- assign: {
70
- updateNestedEntities: true;
71
- updateByPrimaryKey: true;
72
- mergeObjectProperties: false;
73
- mergeEmbeddedProperties: true;
74
- ignoreUndefined: false;
75
- };
76
- persistOnCreate: true;
77
- upsertManaged: true;
78
- forceEntityConstructor: false;
79
- forceUndefined: false;
80
- ensureDatabase: true;
81
- ensureIndexes: false;
82
- batchSize: number;
83
- debug: false;
84
- ignoreDeprecations: false;
85
- verbose: false;
86
- driverOptions: {};
87
- migrations: {
88
- tableName: string;
89
- path: string;
90
- glob: string;
91
- silent: false;
92
- transactional: true;
93
- disableForeignKeys: false;
94
- allOrNothing: true;
95
- dropTables: true;
96
- safe: false;
97
- snapshot: true;
98
- emit: "ts";
99
- fileName: (timestamp: string, name?: string) => string;
100
- };
101
- schemaGenerator: {
102
- disableForeignKeys: false;
103
- createForeignKeyConstraints: true;
104
- ignoreSchema: never[];
105
- };
106
- embeddables: {
107
- prefixMode: "absolute";
108
- };
109
- entityGenerator: {
110
- forceUndefined: true;
111
- undefinedDefaults: false;
112
- bidirectionalRelations: false;
113
- identifiedReferences: false;
114
- scalarTypeInDecorator: false;
115
- scalarPropertiesForRelations: "never";
116
- fileName: (className: string) => string;
117
- onlyPurePivotTables: false;
118
- outputPurePivotTables: false;
119
- readOnlyPivotTables: false;
120
- useCoreBaseEntity: false;
121
- };
122
- metadataCache: {
123
- pretty: false;
124
- adapter: typeof FileCacheAdapter;
125
- options: {
126
- cacheDir: string;
127
- };
128
- };
129
- resultCache: {
130
- adapter: typeof MemoryCacheAdapter;
131
- expiration: number;
132
- options: {};
133
- };
134
- metadataProvider: typeof ReflectMetadataProvider;
135
- highlighter: NullHighlighter;
136
- seeder: {
137
- path: string;
138
- defaultSeeder: string;
139
- glob: string;
140
- emit: "ts";
141
- fileName: (className: string) => string;
142
- };
143
- preferReadReplicas: true;
144
- dynamicImportProvider: (id: string) => Promise<any>;
1
+ import type { NamingStrategy } from '../naming-strategy/NamingStrategy.js';
2
+ import { type CacheAdapter, type SyncCacheAdapter } from '../cache/CacheAdapter.js';
3
+ import type { EntityRepository } from '../entity/EntityRepository.js';
4
+ import type { AnyEntity, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject } from '../typings.js';
5
+ import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
6
+ import { NullHighlighter } from '../utils/NullHighlighter.js';
7
+ import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
8
+ import type { EntityManager } from '../EntityManager.js';
9
+ import type { Platform } from '../platforms/Platform.js';
10
+ import type { EntitySchema } from '../metadata/EntitySchema.js';
11
+ import { MetadataProvider } from '../metadata/MetadataProvider.js';
12
+ import type { MetadataStorage } from '../metadata/MetadataStorage.js';
13
+ import type { EventSubscriber } from '../events/EventSubscriber.js';
14
+ import type { AssignOptions } from '../entity/EntityAssigner.js';
15
+ import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
16
+ import { NotFoundError } from '../errors.js';
17
+ import { DataloaderType, FlushMode, LoadStrategy, PopulateHint, type EmbeddedPrefixMode } from '../enums.js';
18
+ import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
19
+ import { EntityComparator } from './EntityComparator.js';
20
+ import type { Type } from '../types/Type.js';
21
+ import type { MikroORM } from '../MikroORM.js';
22
+ declare const DEFAULTS: {
23
+ readonly pool: {};
24
+ readonly entities: readonly [];
25
+ readonly entitiesTs: readonly [];
26
+ readonly extensions: readonly [];
27
+ readonly subscribers: readonly [];
28
+ readonly filters: {};
29
+ readonly discovery: {
30
+ readonly warnWhenNoEntities: true;
31
+ readonly checkDuplicateTableNames: true;
32
+ readonly checkDuplicateFieldNames: true;
33
+ readonly checkDuplicateEntities: true;
34
+ readonly checkNonPersistentCompositeProps: true;
35
+ readonly inferDefaultValues: true;
36
+ };
37
+ readonly validateRequired: true;
38
+ readonly context: (name: string) => EntityManager<IDatabaseDriver<import("@mikro-orm/sql").Connection>> | undefined;
39
+ readonly contextName: "default";
40
+ readonly allowGlobalContext: false;
41
+ readonly logger: (message?: any, ...optionalParams: any[]) => void;
42
+ readonly colors: true;
43
+ readonly findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
44
+ readonly findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
45
+ readonly baseDir: string;
46
+ readonly hydrator: typeof ObjectHydrator;
47
+ readonly flushMode: FlushMode.AUTO;
48
+ readonly loadStrategy: LoadStrategy.BALANCED;
49
+ readonly dataloader: DataloaderType.NONE;
50
+ readonly populateWhere: PopulateHint.ALL;
51
+ readonly ignoreUndefinedInQuery: false;
52
+ readonly onQuery: (sql: string) => string;
53
+ readonly autoJoinOneToOneOwner: true;
54
+ readonly autoJoinRefsForFilters: true;
55
+ readonly filtersOnRelations: true;
56
+ readonly propagationOnPrototype: true;
57
+ readonly populateAfterFlush: true;
58
+ readonly serialization: {
59
+ readonly includePrimaryKeys: true;
60
+ };
61
+ readonly assign: {
62
+ readonly updateNestedEntities: true;
63
+ readonly updateByPrimaryKey: true;
64
+ readonly mergeObjectProperties: false;
65
+ readonly mergeEmbeddedProperties: true;
66
+ readonly ignoreUndefined: false;
67
+ };
68
+ readonly persistOnCreate: true;
69
+ readonly upsertManaged: true;
70
+ readonly forceEntityConstructor: false;
71
+ readonly forceUndefined: false;
72
+ readonly processOnCreateHooksEarly: true;
73
+ readonly ensureDatabase: true;
74
+ readonly ensureIndexes: false;
75
+ readonly batchSize: 300;
76
+ readonly debug: false;
77
+ readonly ignoreDeprecations: false;
78
+ readonly verbose: false;
79
+ readonly driverOptions: {};
80
+ readonly migrations: {
81
+ readonly tableName: "mikro_orm_migrations";
82
+ readonly glob: "!(*.d).{js,ts,cjs}";
83
+ readonly silent: false;
84
+ readonly transactional: true;
85
+ readonly disableForeignKeys: false;
86
+ readonly allOrNothing: true;
87
+ readonly dropTables: true;
88
+ readonly safe: false;
89
+ readonly snapshot: true;
90
+ readonly emit: "ts";
91
+ readonly fileName: (timestamp: string, name?: string) => string;
92
+ };
93
+ readonly schemaGenerator: {
94
+ readonly disableForeignKeys: false;
95
+ readonly createForeignKeyConstraints: true;
96
+ readonly ignoreSchema: readonly [];
97
+ readonly skipTables: readonly [];
98
+ readonly skipColumns: {};
99
+ };
100
+ readonly embeddables: {
101
+ readonly prefixMode: "relative";
145
102
  };
103
+ readonly entityGenerator: {
104
+ readonly forceUndefined: true;
105
+ readonly undefinedDefaults: false;
106
+ readonly scalarTypeInDecorator: false;
107
+ readonly bidirectionalRelations: true;
108
+ readonly identifiedReferences: true;
109
+ readonly scalarPropertiesForRelations: "never";
110
+ readonly entityDefinition: "defineEntity";
111
+ readonly decorators: "legacy";
112
+ readonly enumMode: "dictionary";
113
+ readonly fileName: (className: string) => string;
114
+ readonly onlyPurePivotTables: false;
115
+ readonly outputPurePivotTables: false;
116
+ readonly readOnlyPivotTables: false;
117
+ readonly useCoreBaseEntity: false;
118
+ };
119
+ readonly metadataCache: {};
120
+ readonly resultCache: {
121
+ readonly adapter: typeof MemoryCacheAdapter;
122
+ readonly expiration: 1000;
123
+ readonly options: {};
124
+ };
125
+ readonly metadataProvider: typeof MetadataProvider;
126
+ readonly highlighter: NullHighlighter;
127
+ readonly seeder: {
128
+ readonly defaultSeeder: "DatabaseSeeder";
129
+ readonly glob: "!(*.d).{js,ts}";
130
+ readonly emit: "ts";
131
+ readonly fileName: (className: string) => string;
132
+ };
133
+ readonly preferReadReplicas: true;
134
+ readonly dynamicImportProvider: (id: string) => Promise<any>;
135
+ };
136
+ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>> {
146
137
  private readonly options;
147
138
  private readonly logger;
148
139
  private readonly driver;
@@ -154,25 +145,21 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
154
145
  /**
155
146
  * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
156
147
  */
157
- get<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
158
- getAll(): MikroORMOptions<D, EM>;
148
+ get<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
149
+ getAll(): RequiredOptions<D, EM>;
159
150
  /**
160
151
  * Overrides specified configuration value.
161
152
  */
162
- set<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, value: U): void;
153
+ set<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, value: U): void;
163
154
  /**
164
155
  * Resets the configuration to its default value
165
156
  */
166
- reset<T extends keyof MikroORMOptions<D, EM>>(key: T): void;
157
+ reset<T extends keyof RequiredOptions<D, EM>>(key: T): void;
167
158
  /**
168
159
  * Gets Logger instance.
169
160
  */
170
161
  getLogger(): Logger;
171
162
  getDataloaderType(): DataloaderType;
172
- /**
173
- * Gets current client URL (connection string).
174
- */
175
- getClientUrl(hidePassword?: boolean): string;
176
163
  getSchema(skipDefaultSchema?: boolean): string | undefined;
177
164
  /**
178
165
  * Gets current database driver instance.
@@ -207,7 +194,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
207
194
  /**
208
195
  * Gets EntityRepository class to be instantiated.
209
196
  */
210
- getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): MikroORMOptions<D, EM>['entityRepository'];
197
+ getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): Options<D, EM>['entityRepository'];
211
198
  /**
212
199
  * Creates instance of given service and caches it.
213
200
  */
@@ -217,192 +204,755 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
217
204
  resetServiceCache(): void;
218
205
  private init;
219
206
  private sync;
220
- /**
221
- * Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it.
222
- * If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be
223
- * used for the TS variant (`pathTs` option).
224
- *
225
- * If the default folder exists (e.g. `/migrations`), the config will respect that, so this auto-detection should not
226
- * break existing projects, only help with the new ones.
227
- */
228
- private detectSourceFolder;
229
207
  private validateOptions;
230
208
  }
231
209
  /**
232
210
  * Type helper to make it easier to use `mikro-orm.config.js`.
233
211
  */
234
- export declare function defineConfig<D extends IDatabaseDriver>(options: Options<D>): Options<D, D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<import("..").Connection>>>;
212
+ export declare function defineConfig<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]>(options: Options<D, EM, Entities>): Options<D, EM, Entities>;
213
+ /**
214
+ * Connection configuration options for database connections.
215
+ * @see https://mikro-orm.io/docs/configuration#connection
216
+ */
235
217
  export interface ConnectionOptions {
218
+ /** Name of the database to connect to. */
236
219
  dbName?: string;
220
+ /** Default database schema to use. */
237
221
  schema?: string;
222
+ /** Name of the connection (used for logging when replicas are used). */
238
223
  name?: string;
224
+ /** Full client connection URL. Overrides individual connection options. */
239
225
  clientUrl?: string;
226
+ /** Database server hostname. */
240
227
  host?: string;
228
+ /** Database server port number. */
241
229
  port?: number;
230
+ /** Database user name. */
242
231
  user?: string;
232
+ /**
233
+ * Database password. Can be a string or a callback function that returns the password.
234
+ * The callback is useful for short-lived tokens from cloud providers.
235
+ * @example
236
+ * password: async () => someCallToGetTheToken()
237
+ */
243
238
  password?: string | (() => MaybePromise<string>);
239
+ /** Character set for the connection. */
244
240
  charset?: string;
241
+ /** Collation for the connection. */
245
242
  collate?: string;
243
+ /**
244
+ * Enable multiple statements in a single query.
245
+ * Required for importing database dump files.
246
+ * Should be disabled in production for security.
247
+ * @default false
248
+ */
246
249
  multipleStatements?: boolean;
250
+ /** Connection pool configuration. */
247
251
  pool?: PoolConfig;
252
+ /**
253
+ * Additional driver-specific options.
254
+ * The object will be deeply merged with internal driver options.
255
+ */
248
256
  driverOptions?: Dictionary;
257
+ /** Callback to execute when a new connection is created. */
249
258
  onCreateConnection?: (connection: unknown) => Promise<void>;
250
259
  }
260
+ /**
261
+ * Configuration options for database migrations.
262
+ * @see https://mikro-orm.io/docs/migrations
263
+ */
251
264
  export type MigrationsOptions = {
265
+ /**
266
+ * Name of the migrations table.
267
+ * @default 'mikro_orm_migrations'
268
+ */
252
269
  tableName?: string;
270
+ /**
271
+ * Path to the folder with migration files (for compiled JavaScript files).
272
+ * @default './migrations'
273
+ */
253
274
  path?: string;
275
+ /**
276
+ * Path to the folder with migration files (for TypeScript source files).
277
+ * Used when running in TypeScript mode.
278
+ */
254
279
  pathTs?: string;
280
+ /**
281
+ * Glob pattern to match migration files.
282
+ * @default '!(*.d).{js,ts,cjs}'
283
+ */
255
284
  glob?: string;
285
+ /**
286
+ * Disable logging for migration operations.
287
+ * @default false
288
+ */
256
289
  silent?: boolean;
290
+ /**
291
+ * Run each migration inside a transaction.
292
+ * @default true
293
+ */
257
294
  transactional?: boolean;
295
+ /**
296
+ * Try to disable foreign key checks during migrations.
297
+ * @default false
298
+ */
258
299
  disableForeignKeys?: boolean;
300
+ /**
301
+ * Run all migrations in the current batch in a master transaction.
302
+ * @default true
303
+ */
259
304
  allOrNothing?: boolean;
305
+ /**
306
+ * Allow dropping tables during schema diff.
307
+ * @default true
308
+ */
260
309
  dropTables?: boolean;
310
+ /**
311
+ * Safe mode - only allow adding new tables and columns, never dropping existing ones.
312
+ * @default false
313
+ */
261
314
  safe?: boolean;
315
+ /**
316
+ * Create a snapshot of the current schema after migration generation.
317
+ * @default true
318
+ */
262
319
  snapshot?: boolean;
320
+ /** Custom name for the snapshot file. */
263
321
  snapshotName?: string;
322
+ /**
323
+ * File extension for generated migration files.
324
+ * @default 'ts'
325
+ */
264
326
  emit?: 'js' | 'ts' | 'cjs';
327
+ /** Custom migration generator class. */
265
328
  generator?: Constructor<IMigrationGenerator>;
329
+ /**
330
+ * Custom function to generate migration file names.
331
+ * @default (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`
332
+ */
266
333
  fileName?: (timestamp: string, name?: string) => string;
334
+ /** List of migration classes or objects to use instead of file-based discovery. */
267
335
  migrationsList?: (MigrationObject | Constructor<Migration>)[];
268
336
  };
337
+ /**
338
+ * Configuration options for database seeders.
339
+ * @see https://mikro-orm.io/docs/seeding
340
+ */
269
341
  export interface SeederOptions {
342
+ /**
343
+ * Path to the folder with seeder files (for compiled JavaScript files).
344
+ * @default './seeders'
345
+ */
270
346
  path?: string;
347
+ /**
348
+ * Path to the folder with seeder files (for TypeScript source files).
349
+ * Used when running in TypeScript mode.
350
+ */
271
351
  pathTs?: string;
352
+ /**
353
+ * Glob pattern to match seeder files.
354
+ * @default '!(*.d).{js,ts}'
355
+ */
272
356
  glob?: string;
357
+ /**
358
+ * Name of the default seeder class to run.
359
+ * @default 'DatabaseSeeder'
360
+ */
273
361
  defaultSeeder?: string;
362
+ /**
363
+ * File extension for generated seeder files.
364
+ * @default 'ts'
365
+ */
274
366
  emit?: 'js' | 'ts';
367
+ /**
368
+ * Custom function to generate seeder file names.
369
+ * @default (className) => className
370
+ */
275
371
  fileName?: (className: string) => string;
276
372
  }
373
+ /**
374
+ * Connection pool configuration.
375
+ * @see https://mikro-orm.io/docs/configuration#connection
376
+ */
277
377
  export interface PoolConfig {
378
+ /** Minimum number of connections to keep in the pool. */
278
379
  min?: number;
380
+ /** Maximum number of connections allowed in the pool. */
279
381
  max?: number;
382
+ /** Time in milliseconds before an idle connection is closed. */
280
383
  idleTimeoutMillis?: number;
281
384
  }
385
+ /**
386
+ * Configuration options for metadata discovery.
387
+ * @see https://mikro-orm.io/docs/configuration#entity-discovery
388
+ */
282
389
  export interface MetadataDiscoveryOptions {
390
+ /**
391
+ * Throw an error when no entities are discovered.
392
+ * @default true
393
+ */
283
394
  warnWhenNoEntities?: boolean;
284
- requireEntitiesArray?: boolean;
395
+ /**
396
+ * Check for duplicate table names and throw an error if found.
397
+ * @default true
398
+ */
285
399
  checkDuplicateTableNames?: boolean;
400
+ /**
401
+ * Check for duplicate field names and throw an error if found.
402
+ * @default true
403
+ */
286
404
  checkDuplicateFieldNames?: boolean;
405
+ /**
406
+ * Check for duplicate entities and throw an error if found.
407
+ * @default true
408
+ */
287
409
  checkDuplicateEntities?: boolean;
410
+ /**
411
+ * Check for composite primary keys marked as `persist: false` and throw an error if found.
412
+ * @default true
413
+ */
288
414
  checkNonPersistentCompositeProps?: boolean;
289
- alwaysAnalyseProperties?: boolean;
290
- disableDynamicFileAccess?: boolean;
415
+ /**
416
+ * Infer default values from property initializers when possible
417
+ * (if the constructor can be invoked without parameters).
418
+ * @default true
419
+ */
291
420
  inferDefaultValues?: boolean;
421
+ /**
422
+ * Custom callback to override default type mapping.
423
+ * Allows customizing how property types are mapped to database column types.
424
+ * @example
425
+ * getMappedType(type, platform) {
426
+ * if (type === 'string') {
427
+ * return Type.getType(TextType);
428
+ * }
429
+ * return platform.getDefaultMappedType(type);
430
+ * }
431
+ */
292
432
  getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
433
+ /**
434
+ * Hook called for each entity metadata during discovery.
435
+ * Can be used to modify metadata dynamically before defaults are filled in.
436
+ * The hook can be async when using `MikroORM.init()`.
437
+ */
293
438
  onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
439
+ /**
440
+ * Hook called after all entities are discovered.
441
+ * Can be used to access and modify all metadata at once.
442
+ */
294
443
  afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
444
+ /** Path to the TypeScript configuration file for ts-morph metadata provider. */
295
445
  tsConfigPath?: string;
446
+ /** @internal */
447
+ skipSyncDiscovery?: boolean;
296
448
  }
297
- export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = EntityManager> extends ConnectionOptions {
298
- entities: (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[];
299
- entitiesTs: (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[];
300
- extensions: {
449
+ /**
450
+ * MikroORM configuration options.
451
+ * @see https://mikro-orm.io/docs/configuration
452
+ */
453
+ export interface Options<Driver extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<Driver> & Driver[typeof EntityManagerType] = EntityManager<Driver> & Driver[typeof EntityManagerType], Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> extends ConnectionOptions {
454
+ /**
455
+ * Array of entity classes or paths to entity modules.
456
+ * Paths support glob patterns for automatic discovery.
457
+ * @example
458
+ * entities: [Author, Book, Publisher] // class references
459
+ * entities: ['./dist/entities'] // folder paths
460
+ */
461
+ entities?: Entities;
462
+ /**
463
+ * Array of TypeScript entity source paths.
464
+ * Used when running in TypeScript mode (e.g., via `tsx` or `swc`).
465
+ * Should always be specified when using folder-based discovery.
466
+ * @example
467
+ * entitiesTs: ['./src/entities']
468
+ */
469
+ entitiesTs?: Entities;
470
+ /**
471
+ * ORM extensions to register (e.g., Migrator, EntityGenerator, SeedManager).
472
+ * Extensions registered here are available via shortcuts like `orm.migrator`.
473
+ * @example
474
+ * extensions: [Migrator, EntityGenerator, SeedManager]
475
+ */
476
+ extensions?: {
301
477
  register: (orm: MikroORM) => void;
302
478
  }[];
303
- subscribers: (EventSubscriber | Constructor<EventSubscriber>)[];
304
- filters: Dictionary<{
479
+ /**
480
+ * Event subscribers to register.
481
+ * Can be class references or instances.
482
+ */
483
+ subscribers?: Iterable<EventSubscriber | Constructor<EventSubscriber>>;
484
+ /**
485
+ * Global entity filters to apply.
486
+ * Filters are applied by default unless explicitly disabled.
487
+ * @see https://mikro-orm.io/docs/filters
488
+ */
489
+ filters?: Dictionary<{
305
490
  name?: string;
306
491
  } & Omit<FilterDef, 'name'>>;
307
- discovery: MetadataDiscoveryOptions;
492
+ /**
493
+ * Metadata discovery configuration options.
494
+ * Controls how entities are discovered and validated.
495
+ */
496
+ discovery?: MetadataDiscoveryOptions;
497
+ /**
498
+ * Database driver class to use.
499
+ * Should be imported from the specific driver package (e.g. `@mikro-orm/mysql`, `@mikro-orm/postgresql`).
500
+ * Alternatively, use the `defineConfig` helper or `MikroORM` class exported from the driver package.
501
+ * @example
502
+ * import { MySqlDriver } from '@mikro-orm/mysql';
503
+ *
504
+ * MikroORM.init({
505
+ * driver: MySqlDriver,
506
+ * dbName: 'my_db',
507
+ * });
508
+ */
308
509
  driver?: {
309
- new (config: Configuration): D;
510
+ new (config: Configuration): Driver;
310
511
  };
512
+ /**
513
+ * Custom naming strategy class for mapping entity/property names to database table/column names.
514
+ * Built-in options: `UnderscoreNamingStrategy`, `MongoNamingStrategy`, `EntityCaseNamingStrategy`.
515
+ * @see https://mikro-orm.io/docs/naming-strategy
516
+ */
311
517
  namingStrategy?: {
312
518
  new (): NamingStrategy;
313
519
  };
520
+ /**
521
+ * Enable implicit transactions for all write operations.
522
+ * When enabled, all queries will be wrapped in a transaction.
523
+ * Disabled for MongoDB driver by default.
524
+ */
314
525
  implicitTransactions?: boolean;
526
+ /**
527
+ * Disable all transactions.
528
+ * When enabled, no queries will be wrapped in transactions, even when explicitly requested.
529
+ * @default false
530
+ */
315
531
  disableTransactions?: boolean;
316
- connect: boolean;
317
- verbose: boolean;
532
+ /**
533
+ * Enable verbose logging of internal operations.
534
+ * @default false
535
+ */
536
+ verbose?: boolean;
537
+ /**
538
+ * Ignore `undefined` values in find queries instead of treating them as `null`.
539
+ * @default false
540
+ * @example
541
+ * // With ignoreUndefinedInQuery: true
542
+ * em.find(User, { email: undefined }) // resolves to em.find(User, {})
543
+ */
318
544
  ignoreUndefinedInQuery?: boolean;
319
- onQuery: (sql: string, params: readonly unknown[]) => string;
320
- autoJoinOneToOneOwner: boolean;
321
- autoJoinRefsForFilters: boolean;
322
- propagationOnPrototype: boolean;
323
- populateAfterFlush: boolean;
324
- serialization: {
545
+ /**
546
+ * Hook to modify SQL queries before execution.
547
+ * Useful for adding observability hints or query modifications.
548
+ * @param sql - The generated SQL query
549
+ * @param params - Query parameters
550
+ * @returns Modified SQL query
551
+ */
552
+ onQuery?: (sql: string, params: readonly unknown[]) => string;
553
+ /**
554
+ * Automatically join the owning side of 1:1 relations when querying the inverse side.
555
+ * @default true
556
+ */
557
+ autoJoinOneToOneOwner?: boolean;
558
+ /**
559
+ * Automatically join M:1 and 1:1 relations when filters are defined on them.
560
+ * Important for implementing soft deletes via filters.
561
+ * @default true
562
+ */
563
+ autoJoinRefsForFilters?: boolean;
564
+ /**
565
+ * Apply filters to relations in queries.
566
+ * @default true
567
+ */
568
+ filtersOnRelations?: boolean;
569
+ /**
570
+ * Enable propagation of changes on entity prototypes.
571
+ * @default true
572
+ */
573
+ propagationOnPrototype?: boolean;
574
+ /**
575
+ * Mark all relations as populated after flush for new entities.
576
+ * This aligns serialized output of loaded entities and just-inserted ones.
577
+ * @default true
578
+ */
579
+ populateAfterFlush?: boolean;
580
+ /**
581
+ * Serialization options for `toJSON()` and `serialize()` methods.
582
+ */
583
+ serialization?: {
584
+ /**
585
+ * Include primary keys in serialized output.
586
+ * @default true
587
+ */
325
588
  includePrimaryKeys?: boolean;
326
- /** Enforce unpopulated references to be returned as objects, e.g. `{ author: { id: 1 } }` instead of `{ author: 1 }`. */
589
+ /**
590
+ * Enforce unpopulated references to be returned as objects.
591
+ * When enabled, references are serialized as `{ author: { id: 1 } }` instead of `{ author: 1 }`.
592
+ * @default false
593
+ */
327
594
  forceObject?: boolean;
328
595
  };
329
- assign: AssignOptions<boolean>;
330
- persistOnCreate: boolean;
331
- upsertManaged: boolean;
332
- forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
333
- forceUndefined: boolean;
596
+ /**
597
+ * Default options for entity assignment via `em.assign()`.
598
+ * @see https://mikro-orm.io/docs/entity-helper
599
+ */
600
+ assign?: AssignOptions<boolean>;
601
+ /**
602
+ * Automatically call `em.persist()` on entities created via `em.create()`.
603
+ * @default true
604
+ */
605
+ persistOnCreate?: boolean;
606
+ /**
607
+ * When upsert creates a new entity, mark it as managed in the identity map.
608
+ * @default true
609
+ */
610
+ upsertManaged?: boolean;
611
+ /**
612
+ * Force use of entity constructors when creating entity instances.
613
+ * Required when using native private properties inside entities.
614
+ * Can be `true` for all entities or an array of specific entity classes/names.
615
+ * @default false
616
+ */
617
+ forceEntityConstructor?: boolean | (Constructor<AnyEntity> | string)[];
618
+ /**
619
+ * Convert `null` values from database to `undefined` when hydrating entities.
620
+ * @default false
621
+ */
622
+ forceUndefined?: boolean;
623
+ /**
624
+ * Property `onCreate` hooks are normally executed during `flush` operation.
625
+ * With this option, they will be processed early inside `em.create()` method.
626
+ * @default true
627
+ */
628
+ processOnCreateHooksEarly?: boolean;
629
+ /**
630
+ * Force `Date` values to be stored in UTC for datetime columns without timezone.
631
+ * Works for MySQL (`datetime` type) and PostgreSQL (`timestamp` type).
632
+ * SQLite does this by default.
633
+ * @default false
634
+ */
334
635
  forceUtcTimezone?: boolean;
636
+ /**
637
+ * Timezone to use for date operations.
638
+ * @example '+02:00'
639
+ */
335
640
  timezone?: string;
336
- ensureDatabase: boolean | EnsureDatabaseOptions;
337
- ensureIndexes: boolean;
641
+ /**
642
+ * Ensure the database exists when initializing the ORM.
643
+ * When `true`, will create the database if it doesn't exist.
644
+ * @default true
645
+ */
646
+ ensureDatabase?: boolean | EnsureDatabaseOptions;
647
+ /**
648
+ * Ensure database indexes exist on startup. This option works only with the MongoDB driver.
649
+ * When enabled, indexes will be created based on entity metadata.
650
+ * @default false
651
+ */
652
+ ensureIndexes?: boolean;
653
+ /**
654
+ * Use batch insert queries for better performance.
655
+ * @default true
656
+ */
338
657
  useBatchInserts?: boolean;
658
+ /**
659
+ * Use batch update queries for better performance.
660
+ * @default true
661
+ */
339
662
  useBatchUpdates?: boolean;
340
- batchSize: number;
341
- hydrator: HydratorConstructor;
342
- loadStrategy: LoadStrategy | 'select-in' | 'joined';
343
- dataloader: DataloaderType | boolean;
663
+ /**
664
+ * Number of entities to process in each batch for batch inserts/updates.
665
+ * @default 300
666
+ */
667
+ batchSize?: number;
668
+ /**
669
+ * Custom hydrator class for assigning database values to entities.
670
+ * @default ObjectHydrator
671
+ */
672
+ hydrator?: HydratorConstructor;
673
+ /**
674
+ * Default loading strategy for relations.
675
+ * - `'joined'`: Use SQL JOINs (single query, may cause cartesian product)
676
+ * - `'select-in'`: Use separate SELECT IN queries (multiple queries)
677
+ * - `'balanced'`: Decides based on relation type and context.
678
+ * @default 'balanced'
679
+ */
680
+ loadStrategy?: LoadStrategy | `${LoadStrategy}`;
681
+ /**
682
+ * Enable dataloader for batching reference loading.
683
+ * - `true` or `DataloaderType.ALL`: Enable for all relation types
684
+ * - `false` or `DataloaderType.NONE`: Disable dataloader
685
+ * - `DataloaderType.REFERENCE`: Enable only for scalar references
686
+ * - `DataloaderType.COLLECTION`: Enable only for collections
687
+ * @default DataloaderType.NONE
688
+ */
689
+ dataloader?: DataloaderType | boolean;
690
+ /**
691
+ * Determines how where conditions are applied during population.
692
+ * - `'all'`: Populate all matching relations (default in v5+)
693
+ * - `'infer'`: Infer conditions from the original query (v4 behavior)
694
+ * @default 'all'
695
+ */
344
696
  populateWhere?: PopulateHint | `${PopulateHint}`;
345
- flushMode: FlushMode | 'commit' | 'auto' | 'always';
697
+ /**
698
+ * Default flush mode for the entity manager.
699
+ * - `'commit'`: Flush only on explicit commit
700
+ * - `'auto'`: Flush before queries when needed
701
+ * - `'always'`: Always flush before queries
702
+ * @default 'auto'
703
+ */
704
+ flushMode?: FlushMode | `${FlushMode}`;
705
+ /**
706
+ * Custom base repository class for all entities.
707
+ * Entity-specific repositories can still be defined and will take precedence.
708
+ * @see https://mikro-orm.io/docs/repositories
709
+ */
346
710
  entityRepository?: EntityClass<EntityRepository<any>>;
711
+ /**
712
+ * Custom entity manager class to use.
713
+ */
347
714
  entityManager?: Constructor<EM>;
715
+ /**
716
+ * Read replica connection configurations.
717
+ * Each replica can override parts of the main connection options.
718
+ * @see https://mikro-orm.io/docs/read-connections
719
+ */
348
720
  replicas?: ConnectionOptions[];
349
- strict: boolean;
350
- validate: boolean;
351
- validateRequired: boolean;
352
- context: (name: string) => EntityManager | undefined;
353
- contextName: string;
354
- allowGlobalContext: boolean;
721
+ /**
722
+ * Validate that required properties are set on new entities before insert.
723
+ * @default true
724
+ */
725
+ validateRequired?: boolean;
726
+ /**
727
+ * Callback to get the current request context's EntityManager.
728
+ * Used for automatic context propagation in web frameworks.
729
+ * @default RequestContext.getEntityManager
730
+ */
731
+ context?: (name: string) => EntityManager | undefined;
732
+ /**
733
+ * Name of the context for multi-ORM setups.
734
+ * @default 'default'
735
+ */
736
+ contextName?: string;
737
+ /**
738
+ * Allow using the global EntityManager without a request context.
739
+ * Not recommended for production - each request should have its own context.
740
+ * Can also be set via `MIKRO_ORM_ALLOW_GLOBAL_CONTEXT` environment variable.
741
+ * @default false
742
+ */
743
+ allowGlobalContext?: boolean;
744
+ /**
745
+ * Disable the identity map.
746
+ * When disabled, each query returns new entity instances.
747
+ * Not recommended for most use cases.
748
+ * @default false
749
+ */
355
750
  disableIdentityMap?: boolean;
356
- logger: (message: string) => void;
751
+ /**
752
+ * Custom logger function for ORM output.
753
+ * @default console.log
754
+ */
755
+ logger?: (message: string) => void;
756
+ /**
757
+ * Enable colored output in logs.
758
+ * @default true
759
+ */
357
760
  colors?: boolean;
761
+ /**
762
+ * Factory function to create a custom logger instance.
763
+ * @default DefaultLogger.create
764
+ */
358
765
  loggerFactory?: (options: LoggerOptions) => Logger;
359
- findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
360
- findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
361
- debug: boolean | LoggerNamespace[];
362
- ignoreDeprecations: boolean | string[];
363
- highlighter: Highlighter;
364
766
  /**
365
- * Using this option, you can force the ORM to use the TS options regardless of whether the TypeScript support
366
- * is detected or not. This effectively means using `entitiesTs` for discovery and `pathTs` for migrations and
367
- * seeders. Should be used only for tests and stay disabled for production builds.
767
+ * Custom error handler for `em.findOneOrFail()` when no entity is found.
768
+ * @param entityName - Name of the entity being queried
769
+ * @param where - Query conditions
770
+ * @returns Error instance to throw
771
+ */
772
+ findOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
773
+ /**
774
+ * Custom error handler for `em.findExactlyOneOrFail()` when entity count is not exactly one.
775
+ * Used when strict mode is enabled.
776
+ * @param entityName - Name of the entity being queried
777
+ * @param where - Query conditions
778
+ * @returns Error instance to throw
779
+ */
780
+ findExactlyOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
781
+ /**
782
+ * Enable debug logging.
783
+ * Can be `true` for all namespaces or an array of specific namespaces.
784
+ * Available namespaces: `'query'`, `'query-params'`, `'discovery'`, `'info'`.
785
+ * @default false
786
+ * @see https://mikro-orm.io/docs/logging
787
+ */
788
+ debug?: boolean | LoggerNamespace[];
789
+ /**
790
+ * Ignore deprecation warnings.
791
+ * Can be `true` to ignore all or an array of specific deprecation labels.
792
+ * @default false
793
+ * @see https://mikro-orm.io/docs/logging#deprecation-warnings
794
+ */
795
+ ignoreDeprecations?: boolean | string[];
796
+ /**
797
+ * Syntax highlighter for SQL queries in logs.
798
+ * @default NullHighlighter
799
+ */
800
+ highlighter?: Highlighter;
801
+ /**
802
+ * Force the ORM to use TypeScript options regardless of detection.
803
+ * Uses `entitiesTs` for discovery and `pathTs` for migrations/seeders.
804
+ * Should only be used for tests, not production builds.
805
+ * @default false
368
806
  */
369
807
  preferTs?: boolean;
370
- /** @deprecated use `preferTs` instead */
371
- tsNode?: boolean;
372
- baseDir: string;
373
- migrations: MigrationsOptions;
374
- schemaGenerator: {
808
+ /**
809
+ * Base directory for resolving relative paths.
810
+ * @default process.cwd()
811
+ */
812
+ baseDir?: string;
813
+ /**
814
+ * Migration configuration options.
815
+ * @see https://mikro-orm.io/docs/migrations
816
+ */
817
+ migrations?: MigrationsOptions;
818
+ /**
819
+ * Schema generator configuration options.
820
+ */
821
+ schemaGenerator?: {
822
+ /**
823
+ * Try to disable foreign key checks during schema operations.
824
+ * @default false
825
+ */
375
826
  disableForeignKeys?: boolean;
827
+ /**
828
+ * Generate foreign key constraints.
829
+ * @default true
830
+ */
376
831
  createForeignKeyConstraints?: boolean;
832
+ /**
833
+ * Schema names to ignore when comparing schemas.
834
+ * @default []
835
+ */
377
836
  ignoreSchema?: string[];
837
+ /**
838
+ * Table names or patterns to skip during schema generation.
839
+ * @default []
840
+ */
841
+ skipTables?: (string | RegExp)[];
842
+ /**
843
+ * Column names or patterns to skip during schema generation, keyed by table name.
844
+ * @default {}
845
+ */
846
+ skipColumns?: Dictionary<(string | RegExp)[]>;
847
+ /**
848
+ * Database name to use for management operations (e.g., creating/dropping databases).
849
+ */
378
850
  managementDbName?: string;
379
851
  };
380
- embeddables: {
852
+ /**
853
+ * Embeddable entity configuration options.
854
+ */
855
+ embeddables?: {
856
+ /**
857
+ * Mode for generating column prefixes for embedded properties.
858
+ * @default 'relative'
859
+ */
381
860
  prefixMode: EmbeddedPrefixMode;
382
861
  };
383
- entityGenerator: GenerateOptions;
384
- metadataCache: {
862
+ /**
863
+ * Entity generator (code generation) configuration options.
864
+ * @see https://mikro-orm.io/docs/entity-generator
865
+ */
866
+ entityGenerator?: GenerateOptions;
867
+ /**
868
+ * Metadata cache configuration for improved startup performance.
869
+ * @see https://mikro-orm.io/docs/metadata-cache
870
+ */
871
+ metadataCache?: {
872
+ /**
873
+ * Enable metadata caching.
874
+ * Defaults based on the metadata provider's `useCache()` method.
875
+ */
385
876
  enabled?: boolean;
877
+ /**
878
+ * Combine all metadata into a single cache file.
879
+ * Can be `true` for default path or a custom path string.
880
+ */
386
881
  combined?: boolean | string;
882
+ /**
883
+ * Pretty print JSON cache files.
884
+ * @default false
885
+ */
387
886
  pretty?: boolean;
887
+ /**
888
+ * Cache adapter class to use. When cache is enabled, and no adapter is provided explicitly, {@link FileCacheAdapter} is used automatically - but only if you use the async `MikroORM.init()` method.
889
+ */
388
890
  adapter?: {
389
891
  new (...params: any[]): SyncCacheAdapter;
390
892
  };
893
+ /**
894
+ * Options passed to the cache adapter constructor.
895
+ * @default { cacheDir: process.cwd() + '/temp' }
896
+ */
391
897
  options?: Dictionary;
392
898
  };
393
- resultCache: {
899
+ /**
900
+ * Result cache configuration for query result caching.
901
+ */
902
+ resultCache?: {
903
+ /**
904
+ * Default cache expiration time in milliseconds.
905
+ * @default 1000
906
+ */
394
907
  expiration?: number;
908
+ /**
909
+ * Cache adapter class to use.
910
+ * @default MemoryCacheAdapter
911
+ */
395
912
  adapter?: {
396
913
  new (...params: any[]): CacheAdapter;
397
914
  };
915
+ /**
916
+ * Options passed to the cache adapter constructor.
917
+ * @default {}
918
+ */
398
919
  options?: Dictionary;
920
+ /**
921
+ * Enable global result caching for all queries.
922
+ * Can be `true`, an expiration number, or a tuple of `[key, expiration]`.
923
+ */
399
924
  global?: boolean | number | [string, number];
400
925
  };
401
- metadataProvider: {
926
+ /**
927
+ * Metadata provider class for entity discovery.
928
+ * Built-in options: `ReflectMetadataProvider` (default), `TsMorphMetadataProvider`.
929
+ * @default ReflectMetadataProvider
930
+ * @see https://mikro-orm.io/docs/metadata-providers
931
+ */
932
+ metadataProvider?: {
402
933
  new (config: Configuration): MetadataProvider;
934
+ useCache?: MetadataProvider['useCache'];
403
935
  };
404
- seeder: SeederOptions;
405
- preferReadReplicas: boolean;
406
- dynamicImportProvider: (id: string) => Promise<unknown>;
936
+ /**
937
+ * Seeder configuration options.
938
+ * @see https://mikro-orm.io/docs/seeding
939
+ */
940
+ seeder?: SeederOptions;
941
+ /**
942
+ * Prefer read replicas for read operations when available.
943
+ * @default true
944
+ */
945
+ preferReadReplicas?: boolean;
946
+ /**
947
+ * Custom dynamic import provider for loading modules.
948
+ * @default (id) => import(id)
949
+ */
950
+ dynamicImportProvider?: (id: string) => Promise<unknown>;
407
951
  }
408
- export type Options<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = D[typeof EntityManagerType] & EntityManager> = Pick<MikroORMOptions<D, EM>, Exclude<keyof MikroORMOptions<D, EM>, keyof typeof Configuration.DEFAULTS>> & Partial<MikroORMOptions<D, EM>>;
952
+ type MarkRequired<T, D> = {
953
+ [K in keyof T as Extract<K, keyof D>]-?: T[K];
954
+ } & {
955
+ [K in keyof T as Exclude<K, keyof D>]?: T[K];
956
+ };
957
+ export type RequiredOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = EntityManager<D>, Entities extends (string | EntityClass<AnyEntity> | EntitySchema)[] = (string | EntityClass<AnyEntity> | EntitySchema)[]> = MarkRequired<Options<D, EM, Entities>, typeof DEFAULTS>;
958
+ export {};