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