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