@mikro-orm/core 7.0.0-dev.7 → 7.0.0-dev.71

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 (161) hide show
  1. package/EntityManager.d.ts +85 -42
  2. package/EntityManager.js +282 -194
  3. package/MikroORM.d.ts +11 -29
  4. package/MikroORM.js +33 -127
  5. package/README.md +3 -2
  6. package/cache/FileCacheAdapter.js +1 -2
  7. package/connections/Connection.d.ts +11 -7
  8. package/connections/Connection.js +16 -14
  9. package/drivers/DatabaseDriver.d.ts +11 -5
  10. package/drivers/DatabaseDriver.js +13 -4
  11. package/drivers/IDatabaseDriver.d.ts +27 -5
  12. package/entity/BaseEntity.d.ts +0 -1
  13. package/entity/BaseEntity.js +0 -3
  14. package/entity/Collection.d.ts +98 -30
  15. package/entity/Collection.js +432 -93
  16. package/entity/EntityAssigner.d.ts +1 -1
  17. package/entity/EntityAssigner.js +9 -1
  18. package/entity/EntityFactory.d.ts +7 -0
  19. package/entity/EntityFactory.js +63 -40
  20. package/entity/EntityHelper.js +26 -9
  21. package/entity/EntityLoader.d.ts +5 -4
  22. package/entity/EntityLoader.js +69 -36
  23. package/entity/EntityRepository.d.ts +1 -1
  24. package/entity/EntityValidator.js +4 -4
  25. package/entity/Reference.d.ts +9 -7
  26. package/entity/Reference.js +32 -5
  27. package/entity/WrappedEntity.d.ts +0 -2
  28. package/entity/WrappedEntity.js +1 -5
  29. package/entity/defineEntity.d.ts +549 -0
  30. package/entity/defineEntity.js +529 -0
  31. package/entity/index.d.ts +2 -1
  32. package/entity/index.js +2 -1
  33. package/entity/utils.d.ts +7 -0
  34. package/entity/utils.js +15 -3
  35. package/enums.d.ts +20 -5
  36. package/enums.js +13 -0
  37. package/errors.d.ts +6 -1
  38. package/errors.js +14 -4
  39. package/events/EventSubscriber.d.ts +3 -1
  40. package/hydration/ObjectHydrator.d.ts +4 -4
  41. package/hydration/ObjectHydrator.js +35 -24
  42. package/index.d.ts +2 -2
  43. package/index.js +1 -2
  44. package/logging/DefaultLogger.d.ts +1 -1
  45. package/logging/SimpleLogger.d.ts +1 -1
  46. package/metadata/EntitySchema.d.ts +9 -13
  47. package/metadata/EntitySchema.js +44 -26
  48. package/metadata/MetadataDiscovery.d.ts +6 -7
  49. package/metadata/MetadataDiscovery.js +161 -162
  50. package/metadata/MetadataProvider.d.ts +2 -2
  51. package/metadata/MetadataProvider.js +15 -0
  52. package/metadata/MetadataStorage.d.ts +0 -4
  53. package/metadata/MetadataStorage.js +6 -10
  54. package/metadata/MetadataValidator.d.ts +0 -7
  55. package/metadata/MetadataValidator.js +4 -13
  56. package/metadata/discover-entities.d.ts +5 -0
  57. package/metadata/discover-entities.js +39 -0
  58. package/metadata/index.d.ts +1 -1
  59. package/metadata/index.js +1 -1
  60. package/metadata/types.d.ts +480 -0
  61. package/metadata/types.js +1 -0
  62. package/naming-strategy/AbstractNamingStrategy.d.ts +5 -1
  63. package/naming-strategy/AbstractNamingStrategy.js +7 -1
  64. package/naming-strategy/NamingStrategy.d.ts +11 -1
  65. package/package.json +11 -10
  66. package/platforms/Platform.d.ts +6 -10
  67. package/platforms/Platform.js +6 -22
  68. package/serialization/EntitySerializer.d.ts +2 -0
  69. package/serialization/EntitySerializer.js +29 -11
  70. package/serialization/EntityTransformer.js +22 -12
  71. package/serialization/SerializationContext.js +14 -11
  72. package/types/ArrayType.d.ts +1 -1
  73. package/types/ArrayType.js +1 -2
  74. package/types/BigIntType.d.ts +8 -6
  75. package/types/BlobType.d.ts +0 -1
  76. package/types/BlobType.js +0 -3
  77. package/types/BooleanType.d.ts +2 -1
  78. package/types/BooleanType.js +3 -0
  79. package/types/DecimalType.d.ts +6 -4
  80. package/types/DecimalType.js +1 -1
  81. package/types/DoubleType.js +1 -1
  82. package/types/JsonType.d.ts +1 -1
  83. package/types/JsonType.js +7 -2
  84. package/types/Type.d.ts +2 -1
  85. package/types/Type.js +1 -1
  86. package/types/Uint8ArrayType.d.ts +0 -1
  87. package/types/Uint8ArrayType.js +0 -3
  88. package/types/index.d.ts +1 -1
  89. package/typings.d.ts +112 -77
  90. package/typings.js +32 -32
  91. package/unit-of-work/ChangeSetComputer.js +8 -3
  92. package/unit-of-work/ChangeSetPersister.d.ts +4 -2
  93. package/unit-of-work/ChangeSetPersister.js +37 -16
  94. package/unit-of-work/UnitOfWork.d.ts +8 -1
  95. package/unit-of-work/UnitOfWork.js +111 -54
  96. package/utils/AbstractSchemaGenerator.d.ts +5 -5
  97. package/utils/AbstractSchemaGenerator.js +10 -8
  98. package/utils/Configuration.d.ts +200 -191
  99. package/utils/Configuration.js +141 -152
  100. package/utils/ConfigurationLoader.d.ts +3 -44
  101. package/utils/ConfigurationLoader.js +26 -239
  102. package/utils/Cursor.d.ts +3 -3
  103. package/utils/Cursor.js +3 -0
  104. package/utils/DataloaderUtils.d.ts +15 -5
  105. package/utils/DataloaderUtils.js +53 -7
  106. package/utils/EntityComparator.d.ts +8 -4
  107. package/utils/EntityComparator.js +107 -60
  108. package/utils/QueryHelper.d.ts +9 -1
  109. package/utils/QueryHelper.js +69 -8
  110. package/utils/RawQueryFragment.d.ts +36 -4
  111. package/utils/RawQueryFragment.js +34 -13
  112. package/utils/TransactionManager.d.ts +65 -0
  113. package/utils/TransactionManager.js +223 -0
  114. package/utils/Utils.d.ts +17 -84
  115. package/utils/Utils.js +132 -252
  116. package/utils/index.d.ts +1 -0
  117. package/utils/index.js +1 -0
  118. package/utils/upsert-utils.d.ts +7 -2
  119. package/utils/upsert-utils.js +52 -1
  120. package/decorators/Check.d.ts +0 -3
  121. package/decorators/Check.js +0 -13
  122. package/decorators/CreateRequestContext.d.ts +0 -3
  123. package/decorators/CreateRequestContext.js +0 -32
  124. package/decorators/Embeddable.d.ts +0 -8
  125. package/decorators/Embeddable.js +0 -11
  126. package/decorators/Embedded.d.ts +0 -18
  127. package/decorators/Embedded.js +0 -18
  128. package/decorators/Entity.d.ts +0 -18
  129. package/decorators/Entity.js +0 -12
  130. package/decorators/Enum.d.ts +0 -9
  131. package/decorators/Enum.js +0 -16
  132. package/decorators/Filter.d.ts +0 -2
  133. package/decorators/Filter.js +0 -8
  134. package/decorators/Formula.d.ts +0 -4
  135. package/decorators/Formula.js +0 -15
  136. package/decorators/Indexed.d.ts +0 -19
  137. package/decorators/Indexed.js +0 -20
  138. package/decorators/ManyToMany.d.ts +0 -40
  139. package/decorators/ManyToMany.js +0 -14
  140. package/decorators/ManyToOne.d.ts +0 -30
  141. package/decorators/ManyToOne.js +0 -14
  142. package/decorators/OneToMany.d.ts +0 -28
  143. package/decorators/OneToMany.js +0 -17
  144. package/decorators/OneToOne.d.ts +0 -24
  145. package/decorators/OneToOne.js +0 -7
  146. package/decorators/PrimaryKey.d.ts +0 -8
  147. package/decorators/PrimaryKey.js +0 -20
  148. package/decorators/Property.d.ts +0 -250
  149. package/decorators/Property.js +0 -32
  150. package/decorators/Transactional.d.ts +0 -13
  151. package/decorators/Transactional.js +0 -28
  152. package/decorators/hooks.d.ts +0 -16
  153. package/decorators/hooks.js +0 -47
  154. package/decorators/index.d.ts +0 -17
  155. package/decorators/index.js +0 -17
  156. package/entity/ArrayCollection.d.ts +0 -116
  157. package/entity/ArrayCollection.js +0 -402
  158. package/metadata/ReflectMetadataProvider.d.ts +0 -8
  159. package/metadata/ReflectMetadataProvider.js +0 -44
  160. package/utils/resolveContextProvider.d.ts +0 -10
  161. package/utils/resolveContextProvider.js +0 -28
@@ -1,149 +1,150 @@
1
1
  import type { NamingStrategy } from '../naming-strategy/NamingStrategy.js';
2
2
  import { FileCacheAdapter } from '../cache/FileCacheAdapter.js';
3
- import { type SyncCacheAdapter, type CacheAdapter } from '../cache/CacheAdapter.js';
3
+ import { type CacheAdapter, type SyncCacheAdapter } from '../cache/CacheAdapter.js';
4
4
  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';
5
+ import type { AnyEntity, Constructor, Dictionary, EnsureDatabaseOptions, EntityClass, EntityMetadata, FilterDef, GenerateOptions, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, Migration, MigrationObject } from '../typings.js';
6
6
  import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
7
7
  import { NullHighlighter } from '../utils/NullHighlighter.js';
8
8
  import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
9
9
  import type { EntityManager } from '../EntityManager.js';
10
10
  import type { Platform } from '../platforms/Platform.js';
11
11
  import type { EntitySchema } from '../metadata/EntitySchema.js';
12
- import type { MetadataProvider } from '../metadata/MetadataProvider.js';
12
+ import { MetadataProvider } from '../metadata/MetadataProvider.js';
13
13
  import type { MetadataStorage } from '../metadata/MetadataStorage.js';
14
- import { ReflectMetadataProvider } from '../metadata/ReflectMetadataProvider.js';
15
- import type { EmbeddedPrefixMode } from '../decorators/Embedded.js';
16
14
  import type { EventSubscriber } from '../events/EventSubscriber.js';
17
15
  import type { AssignOptions } from '../entity/EntityAssigner.js';
18
16
  import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
19
17
  import { NotFoundError } from '../errors.js';
20
- import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums.js';
18
+ import { DataloaderType, FlushMode, LoadStrategy, PopulateHint, type EmbeddedPrefixMode } from '../enums.js';
21
19
  import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
22
20
  import { EntityComparator } from './EntityComparator.js';
23
21
  import type { Type } from '../types/Type.js';
24
22
  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;
23
+ declare const DEFAULTS: {
24
+ readonly pool: {};
25
+ readonly entities: readonly [];
26
+ readonly entitiesTs: readonly [];
27
+ readonly extensions: readonly [];
28
+ readonly subscribers: readonly [];
29
+ readonly filters: {};
30
+ readonly discovery: {
31
+ readonly warnWhenNoEntities: true;
32
+ readonly checkDuplicateTableNames: true;
33
+ readonly checkDuplicateFieldNames: true;
34
+ readonly checkDuplicateEntities: true;
35
+ readonly checkNonPersistentCompositeProps: true;
36
+ readonly inferDefaultValues: true;
37
+ };
38
+ readonly strict: false;
39
+ readonly validate: false;
40
+ readonly validateRequired: true;
41
+ readonly context: (name: string) => EntityManager<IDatabaseDriver<import("../index.js").Connection>> | undefined;
42
+ readonly contextName: "default";
43
+ readonly allowGlobalContext: false;
44
+ readonly logger: (message?: any, ...optionalParams: any[]) => void;
45
+ readonly colors: true;
46
+ readonly findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
47
+ readonly findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
48
+ readonly baseDir: string;
49
+ readonly hydrator: typeof ObjectHydrator;
50
+ readonly flushMode: FlushMode.AUTO;
51
+ readonly loadStrategy: LoadStrategy.BALANCED;
52
+ readonly dataloader: DataloaderType.NONE;
53
+ readonly populateWhere: PopulateHint.ALL;
54
+ readonly ignoreUndefinedInQuery: false;
55
+ readonly onQuery: (sql: string) => string;
56
+ readonly autoJoinOneToOneOwner: true;
57
+ readonly autoJoinRefsForFilters: true;
58
+ readonly filtersOnRelations: true;
59
+ readonly propagationOnPrototype: true;
60
+ readonly populateAfterFlush: true;
61
+ readonly serialization: {
62
+ readonly includePrimaryKeys: true;
63
+ };
64
+ readonly assign: {
65
+ readonly updateNestedEntities: true;
66
+ readonly updateByPrimaryKey: true;
67
+ readonly mergeObjectProperties: false;
68
+ readonly mergeEmbeddedProperties: true;
69
+ readonly ignoreUndefined: false;
70
+ };
71
+ readonly persistOnCreate: true;
72
+ readonly upsertManaged: true;
73
+ readonly forceEntityConstructor: false;
74
+ readonly forceUndefined: false;
75
+ readonly processOnCreateHooksEarly: false;
76
+ readonly ensureDatabase: true;
77
+ readonly ensureIndexes: false;
78
+ readonly batchSize: 300;
79
+ readonly debug: false;
80
+ readonly ignoreDeprecations: false;
81
+ readonly verbose: false;
82
+ readonly driverOptions: {};
83
+ readonly migrations: {
84
+ readonly tableName: "mikro_orm_migrations";
85
+ readonly path: "./migrations";
86
+ readonly glob: "!(*.d).{js,ts,cjs}";
87
+ readonly silent: false;
88
+ readonly transactional: true;
89
+ readonly disableForeignKeys: false;
90
+ readonly allOrNothing: true;
91
+ readonly dropTables: true;
92
+ readonly safe: false;
93
+ readonly snapshot: true;
94
+ readonly emit: "ts";
95
+ readonly fileName: (timestamp: string, name?: string) => string;
96
+ };
97
+ readonly schemaGenerator: {
98
+ readonly disableForeignKeys: false;
99
+ readonly createForeignKeyConstraints: true;
100
+ readonly ignoreSchema: readonly [];
101
+ readonly skipTables: readonly [];
102
+ readonly skipColumns: {};
103
+ };
104
+ readonly embeddables: {
105
+ readonly prefixMode: "relative";
106
+ };
107
+ readonly entityGenerator: {
108
+ readonly forceUndefined: true;
109
+ readonly undefinedDefaults: false;
110
+ readonly scalarTypeInDecorator: false;
111
+ readonly bidirectionalRelations: true;
112
+ readonly identifiedReferences: true;
113
+ readonly scalarPropertiesForRelations: "never";
114
+ readonly entityDefinition: "defineEntity";
115
+ readonly decorators: "legacy";
116
+ readonly enumMode: "dictionary";
117
+ readonly fileName: (className: string) => string;
118
+ readonly onlyPurePivotTables: false;
119
+ readonly outputPurePivotTables: false;
120
+ readonly readOnlyPivotTables: false;
121
+ readonly useCoreBaseEntity: false;
122
+ };
123
+ readonly metadataCache: {
124
+ readonly pretty: false;
125
+ readonly adapter: typeof FileCacheAdapter;
126
+ readonly options: {
127
+ readonly cacheDir: string;
143
128
  };
144
- preferReadReplicas: true;
145
- dynamicImportProvider: (id: string) => Promise<any>;
146
129
  };
130
+ readonly resultCache: {
131
+ readonly adapter: typeof MemoryCacheAdapter;
132
+ readonly expiration: 1000;
133
+ readonly options: {};
134
+ };
135
+ readonly metadataProvider: typeof MetadataProvider;
136
+ readonly highlighter: NullHighlighter;
137
+ readonly seeder: {
138
+ readonly path: "./seeders";
139
+ readonly defaultSeeder: "DatabaseSeeder";
140
+ readonly glob: "!(*.d).{js,ts}";
141
+ readonly emit: "ts";
142
+ readonly fileName: (className: string) => string;
143
+ };
144
+ readonly preferReadReplicas: true;
145
+ readonly dynamicImportProvider: (id: string) => Promise<any>;
146
+ };
147
+ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager<D> = D[typeof EntityManagerType] & EntityManager<D>> {
147
148
  private readonly options;
148
149
  private readonly logger;
149
150
  private readonly driver;
@@ -155,25 +156,21 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
155
156
  /**
156
157
  * Gets specific configuration option. Falls back to specified `defaultValue` if provided.
157
158
  */
158
- get<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
159
- getAll(): MikroORMOptions<D, EM>;
159
+ get<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
160
+ getAll(): RequiredOptions<D, EM>;
160
161
  /**
161
162
  * Overrides specified configuration value.
162
163
  */
163
- set<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, value: U): void;
164
+ set<T extends keyof Options<D, EM>, U extends RequiredOptions<D, EM>[T]>(key: T, value: U): void;
164
165
  /**
165
166
  * Resets the configuration to its default value
166
167
  */
167
- reset<T extends keyof MikroORMOptions<D, EM>>(key: T): void;
168
+ reset<T extends keyof RequiredOptions<D, EM>>(key: T): void;
168
169
  /**
169
170
  * Gets Logger instance.
170
171
  */
171
172
  getLogger(): Logger;
172
173
  getDataloaderType(): DataloaderType;
173
- /**
174
- * Gets current client URL (connection string).
175
- */
176
- getClientUrl(hidePassword?: boolean): string;
177
174
  getSchema(skipDefaultSchema?: boolean): string | undefined;
178
175
  /**
179
176
  * Gets current database driver instance.
@@ -208,7 +205,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
208
205
  /**
209
206
  * Gets EntityRepository class to be instantiated.
210
207
  */
211
- getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): MikroORMOptions<D, EM>['entityRepository'];
208
+ getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): Options<D, EM>['entityRepository'];
212
209
  /**
213
210
  * Creates instance of given service and caches it.
214
211
  */
@@ -232,7 +229,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
232
229
  /**
233
230
  * Type helper to make it easier to use `mikro-orm.config.js`.
234
231
  */
235
- export declare function defineConfig<D extends IDatabaseDriver>(options: Options<D>): Options<D, D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<import("../index.js").Connection>>>;
232
+ 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>;
236
233
  export interface ConnectionOptions {
237
234
  dbName?: string;
238
235
  schema?: string;
@@ -282,105 +279,111 @@ export interface PoolConfig {
282
279
  }
283
280
  export interface MetadataDiscoveryOptions {
284
281
  warnWhenNoEntities?: boolean;
285
- requireEntitiesArray?: boolean;
286
282
  checkDuplicateTableNames?: boolean;
287
283
  checkDuplicateFieldNames?: boolean;
288
284
  checkDuplicateEntities?: boolean;
289
285
  checkNonPersistentCompositeProps?: boolean;
290
- alwaysAnalyseProperties?: boolean;
291
- disableDynamicFileAccess?: boolean;
292
286
  inferDefaultValues?: boolean;
293
287
  getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
294
288
  onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
295
289
  afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
296
290
  tsConfigPath?: string;
291
+ /** @internal */
292
+ skipSyncDiscovery?: boolean;
297
293
  }
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: {
294
+ 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 {
295
+ entities?: Entities;
296
+ entitiesTs?: Entities;
297
+ extensions?: {
302
298
  register: (orm: MikroORM) => void;
303
299
  }[];
304
- subscribers: (EventSubscriber | Constructor<EventSubscriber>)[];
305
- filters: Dictionary<{
300
+ subscribers?: (EventSubscriber | Constructor<EventSubscriber>)[];
301
+ filters?: Dictionary<{
306
302
  name?: string;
307
303
  } & Omit<FilterDef, 'name'>>;
308
- discovery: MetadataDiscoveryOptions;
304
+ discovery?: MetadataDiscoveryOptions;
309
305
  driver?: {
310
- new (config: Configuration): D;
306
+ new (config: Configuration): Driver;
311
307
  };
312
308
  namingStrategy?: {
313
309
  new (): NamingStrategy;
314
310
  };
315
311
  implicitTransactions?: boolean;
316
312
  disableTransactions?: boolean;
317
- connect: boolean;
318
- verbose: boolean;
313
+ verbose?: boolean;
319
314
  ignoreUndefinedInQuery?: boolean;
320
- onQuery: (sql: string, params: readonly unknown[]) => string;
321
- autoJoinOneToOneOwner: boolean;
322
- autoJoinRefsForFilters: boolean;
323
- propagationOnPrototype: boolean;
324
- populateAfterFlush: boolean;
325
- serialization: {
315
+ onQuery?: (sql: string, params: readonly unknown[]) => string;
316
+ autoJoinOneToOneOwner?: boolean;
317
+ autoJoinRefsForFilters?: boolean;
318
+ filtersOnRelations?: boolean;
319
+ propagationOnPrototype?: boolean;
320
+ populateAfterFlush?: boolean;
321
+ serialization?: {
326
322
  includePrimaryKeys?: boolean;
327
323
  /** Enforce unpopulated references to be returned as objects, e.g. `{ author: { id: 1 } }` instead of `{ author: 1 }`. */
328
324
  forceObject?: boolean;
329
325
  };
330
- assign: AssignOptions<boolean>;
331
- persistOnCreate: boolean;
332
- upsertManaged: boolean;
333
- forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
334
- forceUndefined: boolean;
326
+ assign?: AssignOptions<boolean>;
327
+ persistOnCreate?: boolean;
328
+ upsertManaged?: boolean;
329
+ forceEntityConstructor?: boolean | (Constructor<AnyEntity> | string)[];
330
+ forceUndefined?: boolean;
331
+ /**
332
+ * Property `onCreate` hooks are normally executed during `flush` operation.
333
+ * With this option, they will be processed early inside `em.create()` method.
334
+ */
335
+ processOnCreateHooksEarly?: boolean;
335
336
  forceUtcTimezone?: boolean;
336
337
  timezone?: string;
337
- ensureDatabase: boolean | EnsureDatabaseOptions;
338
- ensureIndexes: boolean;
338
+ ensureDatabase?: boolean | EnsureDatabaseOptions;
339
+ ensureIndexes?: boolean;
339
340
  useBatchInserts?: boolean;
340
341
  useBatchUpdates?: boolean;
341
- batchSize: number;
342
- hydrator: HydratorConstructor;
343
- loadStrategy: LoadStrategy | 'select-in' | 'joined';
344
- dataloader: DataloaderType | boolean;
342
+ batchSize?: number;
343
+ hydrator?: HydratorConstructor;
344
+ loadStrategy?: LoadStrategy | `${LoadStrategy}`;
345
+ dataloader?: DataloaderType | boolean;
345
346
  populateWhere?: PopulateHint | `${PopulateHint}`;
346
- flushMode: FlushMode | 'commit' | 'auto' | 'always';
347
+ flushMode?: FlushMode | `${FlushMode}`;
347
348
  entityRepository?: EntityClass<EntityRepository<any>>;
348
349
  entityManager?: Constructor<EM>;
349
350
  replicas?: ConnectionOptions[];
350
- strict: boolean;
351
- validate: boolean;
352
- validateRequired: boolean;
353
- context: (name: string) => EntityManager | undefined;
354
- contextName: string;
355
- allowGlobalContext: boolean;
351
+ strict?: boolean;
352
+ validate?: boolean;
353
+ validateRequired?: boolean;
354
+ context?: (name: string) => EntityManager | undefined;
355
+ contextName?: string;
356
+ allowGlobalContext?: boolean;
356
357
  disableIdentityMap?: boolean;
357
- logger: (message: string) => void;
358
+ logger?: (message: string) => void;
358
359
  colors?: boolean;
359
360
  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;
361
+ findOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
362
+ findExactlyOneOrFailHandler?: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
363
+ debug?: boolean | LoggerNamespace[];
364
+ ignoreDeprecations?: boolean | string[];
365
+ highlighter?: Highlighter;
365
366
  /**
366
367
  * Using this option, you can force the ORM to use the TS options regardless of whether the TypeScript support
367
368
  * is detected or not. This effectively means using `entitiesTs` for discovery and `pathTs` for migrations and
368
369
  * seeders. Should be used only for tests and stay disabled for production builds.
369
370
  */
370
371
  preferTs?: boolean;
371
- baseDir: string;
372
- migrations: MigrationsOptions;
373
- schemaGenerator: {
372
+ baseDir?: string;
373
+ migrations?: MigrationsOptions;
374
+ schemaGenerator?: {
374
375
  disableForeignKeys?: boolean;
375
376
  createForeignKeyConstraints?: boolean;
376
377
  ignoreSchema?: string[];
378
+ skipTables?: (string | RegExp)[];
379
+ skipColumns?: Dictionary<(string | RegExp)[]>;
377
380
  managementDbName?: string;
378
381
  };
379
- embeddables: {
382
+ embeddables?: {
380
383
  prefixMode: EmbeddedPrefixMode;
381
384
  };
382
- entityGenerator: GenerateOptions;
383
- metadataCache: {
385
+ entityGenerator?: GenerateOptions;
386
+ metadataCache?: {
384
387
  enabled?: boolean;
385
388
  combined?: boolean | string;
386
389
  pretty?: boolean;
@@ -389,7 +392,7 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
389
392
  };
390
393
  options?: Dictionary;
391
394
  };
392
- resultCache: {
395
+ resultCache?: {
393
396
  expiration?: number;
394
397
  adapter?: {
395
398
  new (...params: any[]): CacheAdapter;
@@ -397,11 +400,17 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
397
400
  options?: Dictionary;
398
401
  global?: boolean | number | [string, number];
399
402
  };
400
- metadataProvider: {
403
+ metadataProvider?: {
401
404
  new (config: Configuration): MetadataProvider;
402
405
  };
403
- seeder: SeederOptions;
404
- preferReadReplicas: boolean;
405
- dynamicImportProvider: (id: string) => Promise<unknown>;
406
+ seeder?: SeederOptions;
407
+ preferReadReplicas?: boolean;
408
+ dynamicImportProvider?: (id: string) => Promise<unknown>;
406
409
  }
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>>;
410
+ type MarkRequired<T, D> = {
411
+ [K in keyof T as Extract<K, keyof D>]-?: T[K];
412
+ } & {
413
+ [K in keyof T as Exclude<K, keyof D>]?: T[K];
414
+ };
415
+ 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>;
416
+ export {};