@mikro-orm/core 7.0.0-dev.19 → 7.0.0-dev.191

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