@mikro-orm/core 7.0.0-dev.12 → 7.0.0-dev.120

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