@mikro-orm/core 7.0.0-dev.27 → 7.0.0-dev.271

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 +92 -60
  2. package/EntityManager.js +311 -256
  3. package/MikroORM.d.ts +44 -35
  4. package/MikroORM.js +109 -143
  5. package/README.md +2 -0
  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 +12 -5
  13. package/connections/Connection.js +21 -12
  14. package/drivers/DatabaseDriver.d.ts +25 -16
  15. package/drivers/DatabaseDriver.js +118 -35
  16. package/drivers/IDatabaseDriver.d.ts +75 -23
  17. package/entity/BaseEntity.d.ts +63 -4
  18. package/entity/BaseEntity.js +0 -3
  19. package/entity/Collection.d.ts +101 -29
  20. package/entity/Collection.js +436 -104
  21. package/entity/EntityAssigner.js +17 -17
  22. package/entity/EntityFactory.d.ts +7 -1
  23. package/entity/EntityFactory.js +87 -55
  24. package/entity/EntityHelper.d.ts +2 -2
  25. package/entity/EntityHelper.js +50 -17
  26. package/entity/EntityLoader.d.ts +11 -10
  27. package/entity/EntityLoader.js +221 -93
  28. package/entity/EntityRepository.d.ts +28 -8
  29. package/entity/EntityRepository.js +8 -2
  30. package/entity/PolymorphicRef.d.ts +12 -0
  31. package/entity/PolymorphicRef.js +18 -0
  32. package/entity/Reference.d.ts +1 -5
  33. package/entity/Reference.js +15 -11
  34. package/entity/WrappedEntity.d.ts +3 -8
  35. package/entity/WrappedEntity.js +2 -7
  36. package/entity/defineEntity.d.ts +512 -310
  37. package/entity/defineEntity.js +134 -287
  38. package/entity/index.d.ts +2 -2
  39. package/entity/index.js +2 -2
  40. package/entity/utils.d.ts +6 -1
  41. package/entity/utils.js +34 -1
  42. package/entity/validators.d.ts +11 -0
  43. package/entity/validators.js +65 -0
  44. package/enums.d.ts +8 -6
  45. package/enums.js +2 -1
  46. package/errors.d.ts +20 -10
  47. package/errors.js +55 -23
  48. package/events/EventManager.d.ts +2 -1
  49. package/events/EventManager.js +19 -11
  50. package/hydration/Hydrator.js +1 -2
  51. package/hydration/ObjectHydrator.d.ts +4 -4
  52. package/hydration/ObjectHydrator.js +87 -35
  53. package/index.d.ts +2 -2
  54. package/index.js +1 -2
  55. package/logging/DefaultLogger.d.ts +1 -1
  56. package/logging/DefaultLogger.js +1 -0
  57. package/logging/SimpleLogger.d.ts +1 -1
  58. package/logging/colors.d.ts +1 -1
  59. package/logging/colors.js +7 -6
  60. package/logging/index.d.ts +1 -0
  61. package/logging/index.js +1 -0
  62. package/logging/inspect.d.ts +2 -0
  63. package/logging/inspect.js +11 -0
  64. package/metadata/EntitySchema.d.ts +47 -23
  65. package/metadata/EntitySchema.js +92 -33
  66. package/metadata/MetadataDiscovery.d.ts +64 -9
  67. package/metadata/MetadataDiscovery.js +779 -326
  68. package/metadata/MetadataProvider.d.ts +11 -2
  69. package/metadata/MetadataProvider.js +46 -2
  70. package/metadata/MetadataStorage.d.ts +13 -11
  71. package/metadata/MetadataStorage.js +70 -37
  72. package/metadata/MetadataValidator.d.ts +32 -9
  73. package/metadata/MetadataValidator.js +196 -41
  74. package/metadata/discover-entities.d.ts +5 -0
  75. package/metadata/discover-entities.js +40 -0
  76. package/metadata/index.d.ts +1 -1
  77. package/metadata/index.js +1 -1
  78. package/metadata/types.d.ts +577 -0
  79. package/metadata/types.js +1 -0
  80. package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
  81. package/naming-strategy/AbstractNamingStrategy.js +20 -2
  82. package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
  83. package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
  84. package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
  85. package/naming-strategy/MongoNamingStrategy.js +6 -6
  86. package/naming-strategy/NamingStrategy.d.ts +28 -4
  87. package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
  88. package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
  89. package/not-supported.d.ts +2 -0
  90. package/not-supported.js +4 -0
  91. package/package.json +22 -11
  92. package/platforms/ExceptionConverter.js +1 -1
  93. package/platforms/Platform.d.ts +10 -15
  94. package/platforms/Platform.js +21 -44
  95. package/serialization/EntitySerializer.d.ts +6 -3
  96. package/serialization/EntitySerializer.js +46 -26
  97. package/serialization/EntityTransformer.js +33 -21
  98. package/serialization/SerializationContext.d.ts +6 -6
  99. package/serialization/SerializationContext.js +3 -3
  100. package/types/ArrayType.d.ts +1 -1
  101. package/types/ArrayType.js +2 -3
  102. package/types/BigIntType.d.ts +8 -6
  103. package/types/BigIntType.js +1 -1
  104. package/types/BlobType.d.ts +0 -1
  105. package/types/BlobType.js +0 -3
  106. package/types/BooleanType.d.ts +1 -0
  107. package/types/BooleanType.js +3 -0
  108. package/types/DecimalType.d.ts +6 -4
  109. package/types/DecimalType.js +2 -2
  110. package/types/DoubleType.js +1 -1
  111. package/types/EnumArrayType.js +1 -2
  112. package/types/JsonType.d.ts +1 -1
  113. package/types/JsonType.js +7 -2
  114. package/types/TinyIntType.js +1 -1
  115. package/types/Type.d.ts +2 -4
  116. package/types/Type.js +3 -3
  117. package/types/Uint8ArrayType.d.ts +0 -1
  118. package/types/Uint8ArrayType.js +1 -4
  119. package/types/index.d.ts +1 -1
  120. package/typings.d.ts +446 -181
  121. package/typings.js +99 -44
  122. package/unit-of-work/ChangeSet.d.ts +4 -6
  123. package/unit-of-work/ChangeSet.js +4 -5
  124. package/unit-of-work/ChangeSetComputer.d.ts +3 -8
  125. package/unit-of-work/ChangeSetComputer.js +41 -20
  126. package/unit-of-work/ChangeSetPersister.d.ts +13 -12
  127. package/unit-of-work/ChangeSetPersister.js +94 -36
  128. package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
  129. package/unit-of-work/CommitOrderCalculator.js +13 -13
  130. package/unit-of-work/IdentityMap.d.ts +12 -0
  131. package/unit-of-work/IdentityMap.js +39 -1
  132. package/unit-of-work/UnitOfWork.d.ts +27 -3
  133. package/unit-of-work/UnitOfWork.js +248 -90
  134. package/utils/AbstractMigrator.d.ts +101 -0
  135. package/utils/AbstractMigrator.js +305 -0
  136. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  137. package/utils/AbstractSchemaGenerator.js +28 -17
  138. package/utils/AsyncContext.d.ts +6 -0
  139. package/utils/AsyncContext.js +42 -0
  140. package/utils/Configuration.d.ts +797 -209
  141. package/utils/Configuration.js +150 -192
  142. package/utils/ConfigurationLoader.d.ts +1 -54
  143. package/utils/ConfigurationLoader.js +1 -352
  144. package/utils/Cursor.d.ts +0 -3
  145. package/utils/Cursor.js +24 -11
  146. package/utils/DataloaderUtils.d.ts +10 -5
  147. package/utils/DataloaderUtils.js +29 -12
  148. package/utils/EntityComparator.d.ts +16 -9
  149. package/utils/EntityComparator.js +157 -57
  150. package/utils/QueryHelper.d.ts +18 -6
  151. package/utils/QueryHelper.js +76 -23
  152. package/utils/RawQueryFragment.d.ts +28 -34
  153. package/utils/RawQueryFragment.js +35 -71
  154. package/utils/RequestContext.js +2 -2
  155. package/utils/TransactionContext.js +2 -2
  156. package/utils/TransactionManager.js +28 -4
  157. package/utils/Utils.d.ts +14 -127
  158. package/utils/Utils.js +80 -396
  159. package/utils/clone.js +8 -23
  160. package/utils/env-vars.d.ts +7 -0
  161. package/utils/env-vars.js +97 -0
  162. package/utils/fs-utils.d.ts +34 -0
  163. package/utils/fs-utils.js +196 -0
  164. package/utils/index.d.ts +1 -3
  165. package/utils/index.js +1 -3
  166. package/utils/upsert-utils.d.ts +9 -4
  167. package/utils/upsert-utils.js +46 -3
  168. package/decorators/Check.d.ts +0 -3
  169. package/decorators/Check.js +0 -13
  170. package/decorators/CreateRequestContext.d.ts +0 -3
  171. package/decorators/CreateRequestContext.js +0 -32
  172. package/decorators/Embeddable.d.ts +0 -8
  173. package/decorators/Embeddable.js +0 -11
  174. package/decorators/Embedded.d.ts +0 -12
  175. package/decorators/Embedded.js +0 -18
  176. package/decorators/Entity.d.ts +0 -33
  177. package/decorators/Entity.js +0 -12
  178. package/decorators/Enum.d.ts +0 -9
  179. package/decorators/Enum.js +0 -16
  180. package/decorators/Filter.d.ts +0 -2
  181. package/decorators/Filter.js +0 -8
  182. package/decorators/Formula.d.ts +0 -4
  183. package/decorators/Formula.js +0 -15
  184. package/decorators/Indexed.d.ts +0 -19
  185. package/decorators/Indexed.js +0 -20
  186. package/decorators/ManyToMany.d.ts +0 -42
  187. package/decorators/ManyToMany.js +0 -14
  188. package/decorators/ManyToOne.d.ts +0 -34
  189. package/decorators/ManyToOne.js +0 -14
  190. package/decorators/OneToMany.d.ts +0 -28
  191. package/decorators/OneToMany.js +0 -17
  192. package/decorators/OneToOne.d.ts +0 -28
  193. package/decorators/OneToOne.js +0 -7
  194. package/decorators/PrimaryKey.d.ts +0 -8
  195. package/decorators/PrimaryKey.js +0 -20
  196. package/decorators/Property.d.ts +0 -250
  197. package/decorators/Property.js +0 -32
  198. package/decorators/Transactional.d.ts +0 -14
  199. package/decorators/Transactional.js +0 -28
  200. package/decorators/hooks.d.ts +0 -16
  201. package/decorators/hooks.js +0 -47
  202. package/decorators/index.d.ts +0 -17
  203. package/decorators/index.js +0 -17
  204. package/entity/ArrayCollection.d.ts +0 -118
  205. package/entity/ArrayCollection.js +0 -407
  206. package/entity/EntityValidator.d.ts +0 -19
  207. package/entity/EntityValidator.js +0 -150
  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,150 +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
- processOnCreateHooksEarly: false;
82
- ensureDatabase: true;
83
- ensureIndexes: false;
84
- batchSize: number;
85
- debug: false;
86
- ignoreDeprecations: false;
87
- verbose: false;
88
- driverOptions: {};
89
- migrations: {
90
- tableName: string;
91
- path: string;
92
- glob: string;
93
- silent: false;
94
- transactional: true;
95
- disableForeignKeys: false;
96
- allOrNothing: true;
97
- dropTables: true;
98
- safe: false;
99
- snapshot: true;
100
- emit: "ts";
101
- fileName: (timestamp: string, name?: string) => string;
102
- };
103
- schemaGenerator: {
104
- disableForeignKeys: false;
105
- createForeignKeyConstraints: true;
106
- ignoreSchema: never[];
107
- };
108
- embeddables: {
109
- prefixMode: "relative";
110
- };
111
- entityGenerator: {
112
- forceUndefined: true;
113
- undefinedDefaults: false;
114
- bidirectionalRelations: false;
115
- identifiedReferences: false;
116
- scalarTypeInDecorator: false;
117
- scalarPropertiesForRelations: "never";
118
- fileName: (className: string) => string;
119
- onlyPurePivotTables: false;
120
- outputPurePivotTables: false;
121
- readOnlyPivotTables: false;
122
- useCoreBaseEntity: false;
123
- };
124
- metadataCache: {
125
- pretty: false;
126
- adapter: typeof FileCacheAdapter;
127
- options: {
128
- cacheDir: string;
129
- };
130
- };
131
- resultCache: {
132
- adapter: typeof MemoryCacheAdapter;
133
- expiration: number;
134
- options: {};
135
- };
136
- metadataProvider: typeof ReflectMetadataProvider;
137
- highlighter: NullHighlighter;
138
- seeder: {
139
- path: string;
140
- defaultSeeder: string;
141
- glob: string;
142
- emit: "ts";
143
- fileName: (className: string) => string;
144
- };
145
- preferReadReplicas: true;
146
- 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";
147
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>> {
148
137
  private readonly options;
149
138
  private readonly logger;
150
139
  private readonly driver;
@@ -156,25 +145,21 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
156
145
  /**
157
146
  * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
158
147
  */
159
- get<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
160
- 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>;
161
150
  /**
162
151
  * Overrides specified configuration value.
163
152
  */
164
- 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;
165
154
  /**
166
155
  * Resets the configuration to its default value
167
156
  */
168
- reset<T extends keyof MikroORMOptions<D, EM>>(key: T): void;
157
+ reset<T extends keyof RequiredOptions<D, EM>>(key: T): void;
169
158
  /**
170
159
  * Gets Logger instance.
171
160
  */
172
161
  getLogger(): Logger;
173
162
  getDataloaderType(): DataloaderType;
174
- /**
175
- * Gets current client URL (connection string).
176
- */
177
- getClientUrl(hidePassword?: boolean): string;
178
163
  getSchema(skipDefaultSchema?: boolean): string | undefined;
179
164
  /**
180
165
  * Gets current database driver instance.
@@ -209,7 +194,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
209
194
  /**
210
195
  * Gets EntityRepository class to be instantiated.
211
196
  */
212
- getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): MikroORMOptions<D, EM>['entityRepository'];
197
+ getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): Options<D, EM>['entityRepository'];
213
198
  /**
214
199
  * Creates instance of given service and caches it.
215
200
  */
@@ -219,195 +204,798 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
219
204
  resetServiceCache(): void;
220
205
  private init;
221
206
  private sync;
222
- /**
223
- * Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it.
224
- * If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be
225
- * used for the TS variant (`pathTs` option).
226
- *
227
- * If the default folder exists (e.g. `/migrations`), the config will respect that, so this auto-detection should not
228
- * break existing projects, only help with the new ones.
229
- */
230
- private detectSourceFolder;
231
207
  private validateOptions;
232
208
  }
233
209
  /**
234
210
  * Type helper to make it easier to use `mikro-orm.config.js`.
235
211
  */
236
- 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
+ */
237
217
  export interface ConnectionOptions {
218
+ /** Name of the database to connect to. */
238
219
  dbName?: string;
220
+ /** Default database schema to use. */
239
221
  schema?: string;
222
+ /** Name of the connection (used for logging when replicas are used). */
240
223
  name?: string;
224
+ /** Full client connection URL. Overrides individual connection options. */
241
225
  clientUrl?: string;
226
+ /** Database server hostname. */
242
227
  host?: string;
228
+ /** Database server port number. */
243
229
  port?: number;
230
+ /** Database user name. */
244
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
+ */
245
238
  password?: string | (() => MaybePromise<string>);
239
+ /** Character set for the connection. */
246
240
  charset?: string;
241
+ /** Collation for the connection. */
247
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
+ */
248
249
  multipleStatements?: boolean;
250
+ /** Connection pool configuration. */
249
251
  pool?: PoolConfig;
252
+ /**
253
+ * Additional driver-specific options.
254
+ * The object will be deeply merged with internal driver options.
255
+ */
250
256
  driverOptions?: Dictionary;
257
+ /** Callback to execute when a new connection is created. */
251
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
+ }[];
252
274
  }
275
+ /**
276
+ * Configuration options for database migrations.
277
+ * @see https://mikro-orm.io/docs/migrations
278
+ */
253
279
  export type MigrationsOptions = {
280
+ /**
281
+ * Name of the migrations table.
282
+ * @default 'mikro_orm_migrations'
283
+ */
254
284
  tableName?: string;
285
+ /**
286
+ * Path to the folder with migration files (for compiled JavaScript files).
287
+ * @default './migrations'
288
+ */
255
289
  path?: string;
290
+ /**
291
+ * Path to the folder with migration files (for TypeScript source files).
292
+ * Used when running in TypeScript mode.
293
+ */
256
294
  pathTs?: string;
295
+ /**
296
+ * Glob pattern to match migration files.
297
+ * @default '!(*.d).{js,ts,cjs}'
298
+ */
257
299
  glob?: string;
300
+ /**
301
+ * Disable logging for migration operations.
302
+ * @default false
303
+ */
258
304
  silent?: boolean;
305
+ /**
306
+ * Run each migration inside a transaction.
307
+ * @default true
308
+ */
259
309
  transactional?: boolean;
310
+ /**
311
+ * Try to disable foreign key checks during migrations.
312
+ * @default false
313
+ */
260
314
  disableForeignKeys?: boolean;
315
+ /**
316
+ * Run all migrations in the current batch in a master transaction.
317
+ * @default true
318
+ */
261
319
  allOrNothing?: boolean;
320
+ /**
321
+ * Allow dropping tables during schema diff.
322
+ * @default true
323
+ */
262
324
  dropTables?: boolean;
325
+ /**
326
+ * Safe mode - only allow adding new tables and columns, never dropping existing ones.
327
+ * @default false
328
+ */
263
329
  safe?: boolean;
330
+ /**
331
+ * Create a snapshot of the current schema after migration generation.
332
+ * @default true
333
+ */
264
334
  snapshot?: boolean;
335
+ /** Custom name for the snapshot file. */
265
336
  snapshotName?: string;
337
+ /**
338
+ * File extension for generated migration files.
339
+ * @default 'ts'
340
+ */
266
341
  emit?: 'js' | 'ts' | 'cjs';
342
+ /** Custom migration generator class. */
267
343
  generator?: Constructor<IMigrationGenerator>;
344
+ /**
345
+ * Custom function to generate migration file names.
346
+ * @default (timestamp, name) => `Migration${timestamp}${name ? '_' + name : ''}`
347
+ */
268
348
  fileName?: (timestamp: string, name?: string) => string;
349
+ /** List of migration classes or objects to use instead of file-based discovery. */
269
350
  migrationsList?: (MigrationObject | Constructor<Migration>)[];
270
351
  };
352
+ /**
353
+ * Configuration options for database seeders.
354
+ * @see https://mikro-orm.io/docs/seeding
355
+ */
271
356
  export interface SeederOptions {
357
+ /**
358
+ * Path to the folder with seeder files (for compiled JavaScript files).
359
+ * @default './seeders'
360
+ */
272
361
  path?: string;
362
+ /**
363
+ * Path to the folder with seeder files (for TypeScript source files).
364
+ * Used when running in TypeScript mode.
365
+ */
273
366
  pathTs?: string;
367
+ /**
368
+ * Glob pattern to match seeder files.
369
+ * @default '!(*.d).{js,ts}'
370
+ */
274
371
  glob?: string;
372
+ /**
373
+ * Name of the default seeder class to run.
374
+ * @default 'DatabaseSeeder'
375
+ */
275
376
  defaultSeeder?: string;
377
+ /**
378
+ * File extension for generated seeder files.
379
+ * @default 'ts'
380
+ */
276
381
  emit?: 'js' | 'ts';
382
+ /**
383
+ * Custom function to generate seeder file names.
384
+ * @default (className) => className
385
+ */
277
386
  fileName?: (className: string) => string;
387
+ /** List of seeder classes or objects to use instead of file-based discovery. */
388
+ seedersList?: (SeederObject | Constructor<Seeder>)[];
278
389
  }
390
+ /**
391
+ * Connection pool configuration.
392
+ * @see https://mikro-orm.io/docs/configuration#connection
393
+ */
279
394
  export interface PoolConfig {
395
+ /** Minimum number of connections to keep in the pool. */
280
396
  min?: number;
397
+ /** Maximum number of connections allowed in the pool. */
281
398
  max?: number;
399
+ /** Time in milliseconds before an idle connection is closed. */
282
400
  idleTimeoutMillis?: number;
283
401
  }
402
+ /**
403
+ * Configuration options for metadata discovery.
404
+ * @see https://mikro-orm.io/docs/configuration#entity-discovery
405
+ */
284
406
  export interface MetadataDiscoveryOptions {
407
+ /**
408
+ * Throw an error when no entities are discovered.
409
+ * @default true
410
+ */
285
411
  warnWhenNoEntities?: boolean;
286
- requireEntitiesArray?: boolean;
412
+ /**
413
+ * Check for duplicate table names and throw an error if found.
414
+ * @default true
415
+ */
287
416
  checkDuplicateTableNames?: boolean;
417
+ /**
418
+ * Check for duplicate field names and throw an error if found.
419
+ * @default true
420
+ */
288
421
  checkDuplicateFieldNames?: boolean;
289
- checkDuplicateEntities?: boolean;
422
+ /**
423
+ * Check for composite primary keys marked as `persist: false` and throw an error if found.
424
+ * @default true
425
+ */
290
426
  checkNonPersistentCompositeProps?: boolean;
291
- alwaysAnalyseProperties?: boolean;
292
- 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
+ */
293
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
+ */
294
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
+ */
295
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
+ */
296
455
  afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
456
+ /** Path to the TypeScript configuration file for ts-morph metadata provider. */
297
457
  tsConfigPath?: string;
458
+ /** @internal */
459
+ skipSyncDiscovery?: boolean;
298
460
  }
299
- export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = EntityManager> extends ConnectionOptions {
300
- entities: (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[];
301
- entitiesTs: (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[];
302
- 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?: {
303
489
  register: (orm: MikroORM) => void;
304
490
  }[];
305
- subscribers: (EventSubscriber | Constructor<EventSubscriber>)[];
306
- 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<{
307
502
  name?: string;
308
503
  } & Omit<FilterDef, 'name'>>;
309
- 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
+ */
310
521
  driver?: {
311
- new (config: Configuration): D;
522
+ new (config: Configuration): Driver;
312
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
+ */
313
529
  namingStrategy?: {
314
530
  new (): NamingStrategy;
315
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
+ */
316
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
+ */
317
543
  disableTransactions?: boolean;
318
- connect: boolean;
319
- 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
+ */
320
556
  ignoreUndefinedInQuery?: boolean;
321
- onQuery: (sql: string, params: readonly unknown[]) => string;
322
- autoJoinOneToOneOwner: boolean;
323
- autoJoinRefsForFilters: boolean;
324
- propagationOnPrototype: boolean;
325
- populateAfterFlush: boolean;
326
- 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
+ */
327
600
  includePrimaryKeys?: boolean;
328
- /** 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
+ */
329
606
  forceObject?: boolean;
330
607
  };
331
- assign: AssignOptions<boolean>;
332
- persistOnCreate: boolean;
333
- upsertManaged: boolean;
334
- forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
335
- 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;
336
635
  /**
337
636
  * Property `onCreate` hooks are normally executed during `flush` operation.
338
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
339
646
  */
340
- processOnCreateHooksEarly: boolean;
341
647
  forceUtcTimezone?: boolean;
648
+ /**
649
+ * Timezone to use for date operations.
650
+ * @example '+02:00'
651
+ */
342
652
  timezone?: string;
343
- ensureDatabase: boolean | EnsureDatabaseOptions;
344
- 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
+ */
345
669
  useBatchInserts?: boolean;
670
+ /**
671
+ * Use batch update queries for better performance.
672
+ * @default true
673
+ */
346
674
  useBatchUpdates?: boolean;
347
- batchSize: number;
348
- hydrator: HydratorConstructor;
349
- loadStrategy: LoadStrategy | `${LoadStrategy}`;
350
- 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
+ */
351
714
  populateWhere?: PopulateHint | `${PopulateHint}`;
352
- 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
+ */
353
728
  entityRepository?: EntityClass<EntityRepository<any>>;
729
+ /**
730
+ * Custom entity manager class to use.
731
+ */
354
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
+ */
355
738
  replicas?: ConnectionOptions[];
356
- strict: boolean;
357
- validate: boolean;
358
- validateRequired: boolean;
359
- context: (name: string) => EntityManager | undefined;
360
- contextName: string;
361
- 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
+ */
362
774
  disableIdentityMap?: boolean;
363
- 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
+ */
364
784
  colors?: boolean;
785
+ /**
786
+ * Factory function to create a custom logger instance.
787
+ * @default DefaultLogger.create
788
+ */
365
789
  loggerFactory?: (options: LoggerOptions) => Logger;
366
- findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
367
- findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
368
- debug: boolean | LoggerNamespace[];
369
- ignoreDeprecations: boolean | string[];
370
- highlighter: Highlighter;
371
790
  /**
372
- * Using this option, you can force the ORM to use the TS options regardless of whether the TypeScript support
373
- * is detected or not. This effectively means using `entitiesTs` for discovery and `pathTs` for migrations and
374
- * 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
375
830
  */
376
831
  preferTs?: boolean;
377
- baseDir: string;
378
- migrations: MigrationsOptions;
379
- 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
+ */
380
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
+ */
381
859
  createForeignKeyConstraints?: boolean;
860
+ /**
861
+ * Schema names to ignore when comparing schemas.
862
+ * @default []
863
+ */
382
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
+ */
383
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';
384
894
  };
385
- embeddables: {
895
+ /**
896
+ * Embeddable entity configuration options.
897
+ */
898
+ embeddables?: {
899
+ /**
900
+ * Mode for generating column prefixes for embedded properties.
901
+ * @default 'relative'
902
+ */
386
903
  prefixMode: EmbeddedPrefixMode;
387
904
  };
388
- entityGenerator: GenerateOptions;
389
- 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
+ */
390
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
+ */
391
924
  combined?: boolean | string;
925
+ /**
926
+ * Pretty print JSON cache files.
927
+ * @default false
928
+ */
392
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
+ */
393
933
  adapter?: {
394
934
  new (...params: any[]): SyncCacheAdapter;
395
935
  };
936
+ /**
937
+ * Options passed to the cache adapter constructor.
938
+ * @default { cacheDir: process.cwd() + '/temp' }
939
+ */
396
940
  options?: Dictionary;
397
941
  };
398
- 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
+ */
399
950
  expiration?: number;
951
+ /**
952
+ * Cache adapter class to use.
953
+ * @default MemoryCacheAdapter
954
+ */
400
955
  adapter?: {
401
956
  new (...params: any[]): CacheAdapter;
402
957
  };
958
+ /**
959
+ * Options passed to the cache adapter constructor.
960
+ * @default {}
961
+ */
403
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
+ */
404
967
  global?: boolean | number | [string, number];
405
968
  };
406
- 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?: {
407
976
  new (config: Configuration): MetadataProvider;
977
+ useCache?: MetadataProvider['useCache'];
408
978
  };
409
- seeder: SeederOptions;
410
- preferReadReplicas: boolean;
411
- 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>;
412
994
  }
413
- 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 {};