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