@mikro-orm/core 7.0.0-dev.3 → 7.0.0-dev.300

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