@mikro-orm/core 7.0.0-dev.8 → 7.0.0-dev.81

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