@yandjin-mikro-orm/core 6.1.4-rc-sti-changes-1
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 +553 -0
- package/EntityManager.js +1736 -0
- package/LICENSE +21 -0
- package/MikroORM.d.ts +102 -0
- package/MikroORM.js +258 -0
- package/README.md +383 -0
- package/cache/CacheAdapter.d.ts +40 -0
- package/cache/CacheAdapter.js +2 -0
- package/cache/FileCacheAdapter.d.ts +31 -0
- package/cache/FileCacheAdapter.js +90 -0
- package/cache/GeneratedCacheAdapter.d.ts +25 -0
- package/cache/GeneratedCacheAdapter.js +38 -0
- package/cache/MemoryCacheAdapter.d.ts +24 -0
- package/cache/MemoryCacheAdapter.js +44 -0
- package/cache/NullCacheAdapter.d.ts +19 -0
- package/cache/NullCacheAdapter.js +30 -0
- package/cache/index.d.ts +5 -0
- package/cache/index.js +21 -0
- package/connections/Connection.d.ts +85 -0
- package/connections/Connection.js +128 -0
- package/connections/index.d.ts +1 -0
- package/connections/index.js +17 -0
- package/decorators/Check.d.ts +3 -0
- package/decorators/Check.js +17 -0
- package/decorators/CreateRequestContext.d.ts +2 -0
- package/decorators/CreateRequestContext.js +31 -0
- package/decorators/Embeddable.d.ts +8 -0
- package/decorators/Embeddable.js +15 -0
- package/decorators/Embedded.d.ts +13 -0
- package/decorators/Embedded.js +21 -0
- package/decorators/EnsureRequestContext.d.ts +2 -0
- package/decorators/EnsureRequestContext.js +26 -0
- package/decorators/Entity.d.ts +18 -0
- package/decorators/Entity.js +17 -0
- package/decorators/Enum.d.ts +9 -0
- package/decorators/Enum.js +20 -0
- package/decorators/Filter.d.ts +2 -0
- package/decorators/Filter.js +12 -0
- package/decorators/Formula.d.ts +5 -0
- package/decorators/Formula.js +19 -0
- package/decorators/Indexed.d.ts +12 -0
- package/decorators/Indexed.js +25 -0
- package/decorators/ManyToMany.d.ts +21 -0
- package/decorators/ManyToMany.js +17 -0
- package/decorators/ManyToOne.d.ts +15 -0
- package/decorators/ManyToOne.js +17 -0
- package/decorators/OneToMany.d.ts +18 -0
- package/decorators/OneToMany.js +21 -0
- package/decorators/OneToOne.d.ts +12 -0
- package/decorators/OneToOne.js +11 -0
- package/decorators/PrimaryKey.d.ts +8 -0
- package/decorators/PrimaryKey.js +24 -0
- package/decorators/Property.d.ts +218 -0
- package/decorators/Property.js +35 -0
- package/decorators/Subscriber.d.ts +1 -0
- package/decorators/Subscriber.js +2 -0
- package/decorators/hooks.d.ts +16 -0
- package/decorators/hooks.js +60 -0
- package/decorators/index.d.ts +17 -0
- package/decorators/index.js +36 -0
- package/drivers/DatabaseDriver.d.ts +72 -0
- package/drivers/DatabaseDriver.js +358 -0
- package/drivers/IDatabaseDriver.d.ts +193 -0
- package/drivers/IDatabaseDriver.js +4 -0
- package/drivers/index.d.ts +2 -0
- package/drivers/index.js +18 -0
- package/entity/ArrayCollection.d.ts +113 -0
- package/entity/ArrayCollection.js +386 -0
- package/entity/BaseEntity.d.ts +22 -0
- package/entity/BaseEntity.js +47 -0
- package/entity/Collection.d.ts +104 -0
- package/entity/Collection.js +373 -0
- package/entity/EntityAssigner.d.ts +28 -0
- package/entity/EntityAssigner.js +226 -0
- package/entity/EntityFactory.d.ts +41 -0
- package/entity/EntityFactory.js +302 -0
- package/entity/EntityHelper.d.ts +29 -0
- package/entity/EntityHelper.js +250 -0
- package/entity/EntityIdentifier.d.ts +10 -0
- package/entity/EntityIdentifier.js +19 -0
- package/entity/EntityLoader.d.ts +65 -0
- package/entity/EntityLoader.js +579 -0
- package/entity/EntityRepository.d.ts +161 -0
- package/entity/EntityRepository.js +207 -0
- package/entity/EntityValidator.d.ts +19 -0
- package/entity/EntityValidator.js +152 -0
- package/entity/Reference.d.ts +89 -0
- package/entity/Reference.js +242 -0
- package/entity/WrappedEntity.d.ts +67 -0
- package/entity/WrappedEntity.js +146 -0
- package/entity/index.d.ts +13 -0
- package/entity/index.js +29 -0
- package/entity/wrap.d.ts +15 -0
- package/entity/wrap.js +26 -0
- package/enums.d.ts +160 -0
- package/enums.js +169 -0
- package/errors.d.ts +65 -0
- package/errors.js +222 -0
- package/events/EventManager.d.ts +17 -0
- package/events/EventManager.js +77 -0
- package/events/EventSubscriber.d.ts +39 -0
- package/events/EventSubscriber.js +2 -0
- package/events/TransactionEventBroadcaster.d.ts +11 -0
- package/events/TransactionEventBroadcaster.js +17 -0
- package/events/index.d.ts +3 -0
- package/events/index.js +19 -0
- package/exceptions.d.ts +104 -0
- package/exceptions.js +130 -0
- package/hydration/Hydrator.d.ts +23 -0
- package/hydration/Hydrator.js +51 -0
- package/hydration/ObjectHydrator.d.ts +24 -0
- package/hydration/ObjectHydrator.js +332 -0
- package/hydration/index.d.ts +2 -0
- package/hydration/index.js +18 -0
- package/index.d.ts +25 -0
- package/index.js +50 -0
- package/index.mjs +192 -0
- package/logging/DefaultLogger.d.ts +32 -0
- package/logging/DefaultLogger.js +90 -0
- package/logging/Logger.d.ts +56 -0
- package/logging/Logger.js +2 -0
- package/logging/SimpleLogger.d.ts +17 -0
- package/logging/SimpleLogger.js +31 -0
- package/logging/colors.d.ts +9 -0
- package/logging/colors.js +20 -0
- package/logging/index.d.ts +4 -0
- package/logging/index.js +20 -0
- package/metadata/EntitySchema.d.ts +74 -0
- package/metadata/EntitySchema.js +293 -0
- package/metadata/MetadataDiscovery.d.ts +71 -0
- package/metadata/MetadataDiscovery.js +1244 -0
- package/metadata/MetadataProvider.d.ts +11 -0
- package/metadata/MetadataProvider.js +23 -0
- package/metadata/MetadataStorage.d.ts +22 -0
- package/metadata/MetadataStorage.js +87 -0
- package/metadata/MetadataValidator.d.ts +24 -0
- package/metadata/MetadataValidator.js +213 -0
- package/metadata/ReflectMetadataProvider.d.ts +8 -0
- package/metadata/ReflectMetadataProvider.js +48 -0
- package/metadata/index.d.ts +6 -0
- package/metadata/index.js +22 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +18 -0
- package/naming-strategy/AbstractNamingStrategy.js +48 -0
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +12 -0
- package/naming-strategy/EntityCaseNamingStrategy.js +32 -0
- package/naming-strategy/MongoNamingStrategy.d.ts +9 -0
- package/naming-strategy/MongoNamingStrategy.js +25 -0
- package/naming-strategy/NamingStrategy.d.ts +52 -0
- package/naming-strategy/NamingStrategy.js +2 -0
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +10 -0
- package/naming-strategy/UnderscoreNamingStrategy.js +28 -0
- package/naming-strategy/index.d.ts +5 -0
- package/naming-strategy/index.js +21 -0
- package/package.json +70 -0
- package/platforms/ExceptionConverter.d.ts +5 -0
- package/platforms/ExceptionConverter.js +11 -0
- package/platforms/Platform.d.ts +201 -0
- package/platforms/Platform.js +452 -0
- package/platforms/index.d.ts +2 -0
- package/platforms/index.js +18 -0
- package/serialization/EntitySerializer.d.ts +34 -0
- package/serialization/EntitySerializer.js +206 -0
- package/serialization/EntityTransformer.d.ts +8 -0
- package/serialization/EntityTransformer.js +192 -0
- package/serialization/SerializationContext.d.ts +30 -0
- package/serialization/SerializationContext.js +111 -0
- package/serialization/index.d.ts +3 -0
- package/serialization/index.js +19 -0
- package/types/ArrayType.d.ts +13 -0
- package/types/ArrayType.js +47 -0
- package/types/BigIntType.d.ts +16 -0
- package/types/BigIntType.js +45 -0
- package/types/BlobType.d.ts +10 -0
- package/types/BlobType.js +27 -0
- package/types/BooleanType.d.ts +8 -0
- package/types/BooleanType.js +16 -0
- package/types/DateTimeType.d.ts +8 -0
- package/types/DateTimeType.js +16 -0
- package/types/DateType.d.ts +8 -0
- package/types/DateType.js +16 -0
- package/types/DecimalType.d.ts +11 -0
- package/types/DecimalType.js +22 -0
- package/types/DoubleType.d.ts +11 -0
- package/types/DoubleType.js +22 -0
- package/types/EnumArrayType.d.ts +9 -0
- package/types/EnumArrayType.js +32 -0
- package/types/EnumType.d.ts +8 -0
- package/types/EnumType.js +16 -0
- package/types/FloatType.d.ts +8 -0
- package/types/FloatType.js +16 -0
- package/types/IntegerType.d.ts +8 -0
- package/types/IntegerType.js +16 -0
- package/types/IntervalType.d.ts +8 -0
- package/types/IntervalType.js +16 -0
- package/types/JsonType.d.ts +13 -0
- package/types/JsonType.js +34 -0
- package/types/MediumIntType.d.ts +6 -0
- package/types/MediumIntType.js +10 -0
- package/types/SmallIntType.d.ts +8 -0
- package/types/SmallIntType.js +16 -0
- package/types/StringType.d.ts +8 -0
- package/types/StringType.js +16 -0
- package/types/TextType.d.ts +8 -0
- package/types/TextType.js +16 -0
- package/types/TimeType.d.ts +9 -0
- package/types/TimeType.js +23 -0
- package/types/TinyIntType.d.ts +8 -0
- package/types/TinyIntType.js +16 -0
- package/types/Type.d.ts +64 -0
- package/types/Type.js +84 -0
- package/types/Uint8ArrayType.d.ts +11 -0
- package/types/Uint8ArrayType.js +37 -0
- package/types/UnknownType.d.ts +7 -0
- package/types/UnknownType.js +13 -0
- package/types/UuidType.d.ts +7 -0
- package/types/UuidType.js +13 -0
- package/types/index.d.ts +75 -0
- package/types/index.js +77 -0
- package/typings.d.ts +767 -0
- package/typings.js +198 -0
- package/unit-of-work/ChangeSet.d.ts +34 -0
- package/unit-of-work/ChangeSet.js +62 -0
- package/unit-of-work/ChangeSetComputer.d.ts +26 -0
- package/unit-of-work/ChangeSetComputer.js +153 -0
- package/unit-of-work/ChangeSetPersister.d.ts +50 -0
- package/unit-of-work/ChangeSetPersister.js +361 -0
- package/unit-of-work/CommitOrderCalculator.d.ts +62 -0
- package/unit-of-work/CommitOrderCalculator.js +113 -0
- package/unit-of-work/IdentityMap.d.ts +17 -0
- package/unit-of-work/IdentityMap.js +84 -0
- package/unit-of-work/UnitOfWork.d.ts +124 -0
- package/unit-of-work/UnitOfWork.js +1013 -0
- package/unit-of-work/index.d.ts +6 -0
- package/unit-of-work/index.js +22 -0
- package/utils/AbstractSchemaGenerator.d.ts +38 -0
- package/utils/AbstractSchemaGenerator.js +101 -0
- package/utils/Configuration.d.ts +390 -0
- package/utils/Configuration.js +357 -0
- package/utils/ConfigurationLoader.d.ts +29 -0
- package/utils/ConfigurationLoader.js +282 -0
- package/utils/Cursor.d.ts +77 -0
- package/utils/Cursor.js +169 -0
- package/utils/DataloaderUtils.d.ts +43 -0
- package/utils/DataloaderUtils.js +194 -0
- package/utils/EntityComparator.d.ts +73 -0
- package/utils/EntityComparator.js +568 -0
- package/utils/NullHighlighter.d.ts +4 -0
- package/utils/NullHighlighter.js +9 -0
- package/utils/QueryHelper.d.ts +28 -0
- package/utils/QueryHelper.js +228 -0
- package/utils/RawQueryFragment.d.ts +96 -0
- package/utils/RawQueryFragment.js +188 -0
- package/utils/RequestContext.d.ts +34 -0
- package/utils/RequestContext.js +54 -0
- package/utils/TransactionContext.d.ts +19 -0
- package/utils/TransactionContext.js +34 -0
- package/utils/Utils.d.ts +274 -0
- package/utils/Utils.js +1073 -0
- package/utils/clone.d.ts +6 -0
- package/utils/clone.js +127 -0
- package/utils/index.d.ts +13 -0
- package/utils/index.js +29 -0
- package/utils/upsert-utils.d.ts +6 -0
- package/utils/upsert-utils.js +33 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./ChangeSet"), exports);
|
|
18
|
+
__exportStar(require("./ChangeSetComputer"), exports);
|
|
19
|
+
__exportStar(require("./ChangeSetPersister"), exports);
|
|
20
|
+
__exportStar(require("./CommitOrderCalculator"), exports);
|
|
21
|
+
__exportStar(require("./UnitOfWork"), exports);
|
|
22
|
+
__exportStar(require("./IdentityMap"), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { ClearDatabaseOptions, DropSchemaOptions, EntityMetadata, ISchemaGenerator, UpdateSchemaOptions, CreateSchemaOptions, RefreshDatabaseOptions, EnsureDatabaseOptions } from '../typings';
|
|
2
|
+
import type { IDatabaseDriver } from '../drivers/IDatabaseDriver';
|
|
3
|
+
import type { MetadataStorage } from '../metadata/MetadataStorage';
|
|
4
|
+
import type { Configuration } from './Configuration';
|
|
5
|
+
export declare abstract class AbstractSchemaGenerator<D extends IDatabaseDriver> implements ISchemaGenerator {
|
|
6
|
+
protected readonly em?: ReturnType<D['createEntityManager']>;
|
|
7
|
+
protected readonly driver: D;
|
|
8
|
+
protected readonly config: Configuration;
|
|
9
|
+
protected readonly metadata: MetadataStorage;
|
|
10
|
+
protected readonly platform: ReturnType<D['getPlatform']>;
|
|
11
|
+
protected readonly connection: ReturnType<D['getConnection']>;
|
|
12
|
+
constructor(em: D | ReturnType<D['createEntityManager']>);
|
|
13
|
+
createSchema(options?: CreateSchemaOptions): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Returns true if the database was created.
|
|
16
|
+
*/
|
|
17
|
+
ensureDatabase(options?: EnsureDatabaseOptions): Promise<boolean>;
|
|
18
|
+
refreshDatabase(options?: RefreshDatabaseOptions): Promise<void>;
|
|
19
|
+
clearDatabase(options?: ClearDatabaseOptions): Promise<void>;
|
|
20
|
+
getCreateSchemaSQL(options?: CreateSchemaOptions): Promise<string>;
|
|
21
|
+
dropSchema(options?: DropSchemaOptions): Promise<void>;
|
|
22
|
+
getDropSchemaSQL(options?: Omit<DropSchemaOptions, 'dropDb'>): Promise<string>;
|
|
23
|
+
updateSchema(options?: UpdateSchemaOptions): Promise<void>;
|
|
24
|
+
getUpdateSchemaSQL(options?: UpdateSchemaOptions): Promise<string>;
|
|
25
|
+
getUpdateSchemaMigrationSQL(options?: UpdateSchemaOptions): Promise<{
|
|
26
|
+
up: string;
|
|
27
|
+
down: string;
|
|
28
|
+
}>;
|
|
29
|
+
/**
|
|
30
|
+
* creates new database and connects to it
|
|
31
|
+
*/
|
|
32
|
+
createDatabase(name: string): Promise<void>;
|
|
33
|
+
dropDatabase(name?: string): Promise<void>;
|
|
34
|
+
execute(query: string): Promise<void>;
|
|
35
|
+
ensureIndexes(): Promise<void>;
|
|
36
|
+
protected getOrderedMetadata(schema?: string): EntityMetadata[];
|
|
37
|
+
protected notImplemented(): never;
|
|
38
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AbstractSchemaGenerator = void 0;
|
|
4
|
+
const CommitOrderCalculator_1 = require("../unit-of-work/CommitOrderCalculator");
|
|
5
|
+
const EntityManager_1 = require("../EntityManager");
|
|
6
|
+
class AbstractSchemaGenerator {
|
|
7
|
+
em;
|
|
8
|
+
driver;
|
|
9
|
+
config;
|
|
10
|
+
metadata;
|
|
11
|
+
platform;
|
|
12
|
+
connection;
|
|
13
|
+
constructor(em) {
|
|
14
|
+
this.em = em instanceof EntityManager_1.EntityManager ? em : undefined;
|
|
15
|
+
this.driver = em instanceof EntityManager_1.EntityManager ? em.getDriver() : em;
|
|
16
|
+
this.config = this.driver.config;
|
|
17
|
+
this.metadata = this.driver.getMetadata();
|
|
18
|
+
this.platform = this.driver.getPlatform();
|
|
19
|
+
this.connection = this.driver.getConnection();
|
|
20
|
+
}
|
|
21
|
+
async createSchema(options) {
|
|
22
|
+
this.notImplemented();
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Returns true if the database was created.
|
|
26
|
+
*/
|
|
27
|
+
async ensureDatabase(options) {
|
|
28
|
+
this.notImplemented();
|
|
29
|
+
}
|
|
30
|
+
async refreshDatabase(options) {
|
|
31
|
+
await this.ensureDatabase();
|
|
32
|
+
await this.dropSchema();
|
|
33
|
+
await this.createSchema(options);
|
|
34
|
+
}
|
|
35
|
+
async clearDatabase(options) {
|
|
36
|
+
for (const meta of this.getOrderedMetadata(options?.schema).reverse()) {
|
|
37
|
+
await this.driver.nativeDelete(meta.className, {}, options);
|
|
38
|
+
}
|
|
39
|
+
if (this.em) {
|
|
40
|
+
const allowGlobalContext = this.config.get('allowGlobalContext');
|
|
41
|
+
this.config.set('allowGlobalContext', true);
|
|
42
|
+
this.em.clear();
|
|
43
|
+
this.config.set('allowGlobalContext', allowGlobalContext);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
async getCreateSchemaSQL(options) {
|
|
47
|
+
this.notImplemented();
|
|
48
|
+
}
|
|
49
|
+
async dropSchema(options) {
|
|
50
|
+
this.notImplemented();
|
|
51
|
+
}
|
|
52
|
+
async getDropSchemaSQL(options) {
|
|
53
|
+
this.notImplemented();
|
|
54
|
+
}
|
|
55
|
+
async updateSchema(options) {
|
|
56
|
+
this.notImplemented();
|
|
57
|
+
}
|
|
58
|
+
async getUpdateSchemaSQL(options) {
|
|
59
|
+
this.notImplemented();
|
|
60
|
+
}
|
|
61
|
+
async getUpdateSchemaMigrationSQL(options) {
|
|
62
|
+
this.notImplemented();
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* creates new database and connects to it
|
|
66
|
+
*/
|
|
67
|
+
async createDatabase(name) {
|
|
68
|
+
this.notImplemented();
|
|
69
|
+
}
|
|
70
|
+
async dropDatabase(name) {
|
|
71
|
+
this.notImplemented();
|
|
72
|
+
}
|
|
73
|
+
async execute(query) {
|
|
74
|
+
this.notImplemented();
|
|
75
|
+
}
|
|
76
|
+
async ensureIndexes() {
|
|
77
|
+
this.notImplemented();
|
|
78
|
+
}
|
|
79
|
+
getOrderedMetadata(schema) {
|
|
80
|
+
const metadata = Object.values(this.metadata.getAll()).filter(meta => {
|
|
81
|
+
const isRootEntity = meta.root.className === meta.className;
|
|
82
|
+
return isRootEntity && !meta.embeddable && !meta.virtual;
|
|
83
|
+
}).map(meta => meta.getStiRoot());
|
|
84
|
+
const calc = new CommitOrderCalculator_1.CommitOrderCalculator();
|
|
85
|
+
metadata.forEach(meta => calc.addNode(meta.root.className));
|
|
86
|
+
let meta = metadata.pop();
|
|
87
|
+
while (meta) {
|
|
88
|
+
for (const prop of meta.props) {
|
|
89
|
+
calc.discoverProperty(prop, meta.root.className);
|
|
90
|
+
}
|
|
91
|
+
meta = metadata.pop();
|
|
92
|
+
}
|
|
93
|
+
return calc.sort()
|
|
94
|
+
.map(cls => this.metadata.find(cls))
|
|
95
|
+
.filter(meta => schema ? [schema, '*'].includes(meta.schema) : meta.schema !== '*');
|
|
96
|
+
}
|
|
97
|
+
notImplemented() {
|
|
98
|
+
throw new Error(`This method is not supported by ${this.driver.constructor.name} driver`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.AbstractSchemaGenerator = AbstractSchemaGenerator;
|
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import type { NamingStrategy } from '../naming-strategy';
|
|
2
|
+
import { FileCacheAdapter, type SyncCacheAdapter, type CacheAdapter } from '../cache';
|
|
3
|
+
import type { EntityRepository } from '../entity/EntityRepository';
|
|
4
|
+
import type { AnyEntity, Constructor, Dictionary, EntityClass, EntityClassGroup, FilterDef, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, MigrationObject, EntityMetadata, EnsureDatabaseOptions, GenerateOptions } from '../typings';
|
|
5
|
+
import { ObjectHydrator } from '../hydration';
|
|
6
|
+
import { NullHighlighter } from '../utils/NullHighlighter';
|
|
7
|
+
import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging';
|
|
8
|
+
import type { EntityManager } from '../EntityManager';
|
|
9
|
+
import type { Platform } from '../platforms';
|
|
10
|
+
import type { EntitySchema } from '../metadata/EntitySchema';
|
|
11
|
+
import type { MetadataProvider } from '../metadata/MetadataProvider';
|
|
12
|
+
import type { MetadataStorage } from '../metadata/MetadataStorage';
|
|
13
|
+
import { ReflectMetadataProvider } from '../metadata/ReflectMetadataProvider';
|
|
14
|
+
import type { EventSubscriber } from '../events';
|
|
15
|
+
import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver';
|
|
16
|
+
import { NotFoundError } from '../errors';
|
|
17
|
+
import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums';
|
|
18
|
+
import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter';
|
|
19
|
+
import { EntityComparator } from './EntityComparator';
|
|
20
|
+
import type { Type } from '../types/Type';
|
|
21
|
+
import type { MikroORM } from '../MikroORM';
|
|
22
|
+
export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager> {
|
|
23
|
+
static readonly DEFAULTS: {
|
|
24
|
+
pool: {};
|
|
25
|
+
entities: never[];
|
|
26
|
+
entitiesTs: never[];
|
|
27
|
+
extensions: never[];
|
|
28
|
+
subscribers: never[];
|
|
29
|
+
filters: {};
|
|
30
|
+
discovery: {
|
|
31
|
+
warnWhenNoEntities: true;
|
|
32
|
+
requireEntitiesArray: false;
|
|
33
|
+
checkDuplicateTableNames: true;
|
|
34
|
+
checkDuplicateFieldNames: true;
|
|
35
|
+
alwaysAnalyseProperties: true;
|
|
36
|
+
disableDynamicFileAccess: false;
|
|
37
|
+
checkDuplicateEntities: true;
|
|
38
|
+
inferDefaultValues: true;
|
|
39
|
+
};
|
|
40
|
+
strict: false;
|
|
41
|
+
validate: false;
|
|
42
|
+
validateRequired: true;
|
|
43
|
+
context: (name: string) => EntityManager<IDatabaseDriver<import("..").Connection>> | undefined;
|
|
44
|
+
contextName: string;
|
|
45
|
+
allowGlobalContext: false;
|
|
46
|
+
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
47
|
+
colors: true;
|
|
48
|
+
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
|
|
49
|
+
findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => NotFoundError<Partial<any>>;
|
|
50
|
+
baseDir: string;
|
|
51
|
+
hydrator: typeof ObjectHydrator;
|
|
52
|
+
flushMode: FlushMode.AUTO;
|
|
53
|
+
loadStrategy: LoadStrategy.JOINED;
|
|
54
|
+
dataloader: DataloaderType.NONE;
|
|
55
|
+
populateWhere: PopulateHint.ALL;
|
|
56
|
+
connect: true;
|
|
57
|
+
ignoreUndefinedInQuery: false;
|
|
58
|
+
autoJoinOneToOneOwner: true;
|
|
59
|
+
autoJoinRefsForFilters: true;
|
|
60
|
+
propagationOnPrototype: true;
|
|
61
|
+
populateAfterFlush: true;
|
|
62
|
+
serialization: {
|
|
63
|
+
includePrimaryKeys: true;
|
|
64
|
+
};
|
|
65
|
+
persistOnCreate: true;
|
|
66
|
+
forceEntityConstructor: false;
|
|
67
|
+
forceUndefined: false;
|
|
68
|
+
forceUtcTimezone: false;
|
|
69
|
+
ensureDatabase: true;
|
|
70
|
+
ensureIndexes: false;
|
|
71
|
+
batchSize: number;
|
|
72
|
+
debug: false;
|
|
73
|
+
verbose: false;
|
|
74
|
+
driverOptions: {};
|
|
75
|
+
migrations: {
|
|
76
|
+
tableName: string;
|
|
77
|
+
path: string;
|
|
78
|
+
glob: string;
|
|
79
|
+
silent: false;
|
|
80
|
+
transactional: true;
|
|
81
|
+
disableForeignKeys: true;
|
|
82
|
+
allOrNothing: true;
|
|
83
|
+
dropTables: true;
|
|
84
|
+
safe: false;
|
|
85
|
+
snapshot: true;
|
|
86
|
+
emit: "ts";
|
|
87
|
+
fileName: (timestamp: string, name?: string) => string;
|
|
88
|
+
};
|
|
89
|
+
schemaGenerator: {
|
|
90
|
+
disableForeignKeys: true;
|
|
91
|
+
createForeignKeyConstraints: true;
|
|
92
|
+
ignoreSchema: never[];
|
|
93
|
+
};
|
|
94
|
+
entityGenerator: {
|
|
95
|
+
bidirectionalRelations: false;
|
|
96
|
+
identifiedReferences: false;
|
|
97
|
+
scalarTypeInDecorator: false;
|
|
98
|
+
scalarPropertiesForRelations: "never";
|
|
99
|
+
fileName: (className: string) => string;
|
|
100
|
+
onlyPurePivotTables: false;
|
|
101
|
+
readOnlyPivotTables: false;
|
|
102
|
+
useCoreBaseEntity: false;
|
|
103
|
+
};
|
|
104
|
+
metadataCache: {
|
|
105
|
+
pretty: false;
|
|
106
|
+
adapter: typeof FileCacheAdapter;
|
|
107
|
+
options: {
|
|
108
|
+
cacheDir: string;
|
|
109
|
+
};
|
|
110
|
+
};
|
|
111
|
+
resultCache: {
|
|
112
|
+
adapter: typeof MemoryCacheAdapter;
|
|
113
|
+
expiration: number;
|
|
114
|
+
options: {};
|
|
115
|
+
};
|
|
116
|
+
metadataProvider: typeof ReflectMetadataProvider;
|
|
117
|
+
highlighter: NullHighlighter;
|
|
118
|
+
seeder: {
|
|
119
|
+
path: string;
|
|
120
|
+
defaultSeeder: string;
|
|
121
|
+
glob: string;
|
|
122
|
+
emit: "ts";
|
|
123
|
+
fileName: (className: string) => string;
|
|
124
|
+
};
|
|
125
|
+
preferReadReplicas: true;
|
|
126
|
+
dynamicImportProvider: (id: string) => Promise<any>;
|
|
127
|
+
};
|
|
128
|
+
private readonly options;
|
|
129
|
+
private readonly logger;
|
|
130
|
+
private readonly driver;
|
|
131
|
+
private readonly platform;
|
|
132
|
+
private readonly cache;
|
|
133
|
+
private readonly extensions;
|
|
134
|
+
constructor(options: Options, validate?: boolean);
|
|
135
|
+
/**
|
|
136
|
+
* Gets specific configuration option. Falls back to specified `defaultValue` if provided.
|
|
137
|
+
*/
|
|
138
|
+
get<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, defaultValue?: U): U;
|
|
139
|
+
getAll(): MikroORMOptions<D, EM>;
|
|
140
|
+
/**
|
|
141
|
+
* Overrides specified configuration value.
|
|
142
|
+
*/
|
|
143
|
+
set<T extends keyof MikroORMOptions<D, EM>, U extends MikroORMOptions<D, EM>[T]>(key: T, value: U): void;
|
|
144
|
+
/**
|
|
145
|
+
* Resets the configuration to its default value
|
|
146
|
+
*/
|
|
147
|
+
reset<T extends keyof MikroORMOptions<D, EM>>(key: T): void;
|
|
148
|
+
/**
|
|
149
|
+
* Gets Logger instance.
|
|
150
|
+
*/
|
|
151
|
+
getLogger(): Logger;
|
|
152
|
+
/**
|
|
153
|
+
* Gets current client URL (connection string).
|
|
154
|
+
*/
|
|
155
|
+
getClientUrl(hidePassword?: boolean): string;
|
|
156
|
+
/**
|
|
157
|
+
* Gets current database driver instance.
|
|
158
|
+
*/
|
|
159
|
+
getDriver(): D;
|
|
160
|
+
registerExtension(name: string, cb: () => unknown): void;
|
|
161
|
+
getExtension<T>(name: string): T | undefined;
|
|
162
|
+
/**
|
|
163
|
+
* Gets instance of NamingStrategy. (cached)
|
|
164
|
+
*/
|
|
165
|
+
getNamingStrategy(): NamingStrategy;
|
|
166
|
+
/**
|
|
167
|
+
* Gets instance of Hydrator. (cached)
|
|
168
|
+
*/
|
|
169
|
+
getHydrator(metadata: MetadataStorage): IHydrator;
|
|
170
|
+
/**
|
|
171
|
+
* Gets instance of Comparator. (cached)
|
|
172
|
+
*/
|
|
173
|
+
getComparator(metadata: MetadataStorage): EntityComparator;
|
|
174
|
+
/**
|
|
175
|
+
* Gets instance of MetadataProvider. (cached)
|
|
176
|
+
*/
|
|
177
|
+
getMetadataProvider(): MetadataProvider;
|
|
178
|
+
/**
|
|
179
|
+
* Gets instance of metadata CacheAdapter. (cached)
|
|
180
|
+
*/
|
|
181
|
+
getMetadataCacheAdapter(): SyncCacheAdapter;
|
|
182
|
+
/**
|
|
183
|
+
* Gets instance of CacheAdapter for result cache. (cached)
|
|
184
|
+
*/
|
|
185
|
+
getResultCacheAdapter(): CacheAdapter;
|
|
186
|
+
/**
|
|
187
|
+
* Gets EntityRepository class to be instantiated.
|
|
188
|
+
*/
|
|
189
|
+
getRepositoryClass(repository: () => EntityClass<EntityRepository<AnyEntity>>): MikroORMOptions<D, EM>['entityRepository'];
|
|
190
|
+
/**
|
|
191
|
+
* Creates instance of given service and caches it.
|
|
192
|
+
*/
|
|
193
|
+
getCachedService<T extends {
|
|
194
|
+
new (...args: any[]): InstanceType<T>;
|
|
195
|
+
}>(cls: T, ...args: ConstructorParameters<T>): InstanceType<T>;
|
|
196
|
+
resetServiceCache(): void;
|
|
197
|
+
private init;
|
|
198
|
+
private sync;
|
|
199
|
+
/**
|
|
200
|
+
* Checks if `src` folder exists, it so, tries to adjust the migrations and seeders paths automatically to use it.
|
|
201
|
+
* If there is a `dist` or `build` folder, it will be used for the JS variant (`path` option), while the `src` folder will be
|
|
202
|
+
* used for the TS variant (`pathTs` option).
|
|
203
|
+
*
|
|
204
|
+
* If the default folder exists (e.g. `/migrations`), the config will respect that, so this auto-detection should not
|
|
205
|
+
* break existing projects, only help with the new ones.
|
|
206
|
+
*/
|
|
207
|
+
private detectSourceFolder;
|
|
208
|
+
private validateOptions;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Type helper to make it easier to use `mikro-orm.config.js`.
|
|
212
|
+
*/
|
|
213
|
+
export declare function defineConfig<D extends IDatabaseDriver>(options: Options<D>): Options<D, D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<import("..").Connection>>>;
|
|
214
|
+
export interface DynamicPassword {
|
|
215
|
+
password: string;
|
|
216
|
+
expirationChecker?: () => boolean;
|
|
217
|
+
}
|
|
218
|
+
export interface ConnectionOptions {
|
|
219
|
+
dbName?: string;
|
|
220
|
+
schema?: string;
|
|
221
|
+
name?: string;
|
|
222
|
+
clientUrl?: string;
|
|
223
|
+
host?: string;
|
|
224
|
+
port?: number;
|
|
225
|
+
user?: string;
|
|
226
|
+
password?: string | (() => MaybePromise<string> | MaybePromise<DynamicPassword>);
|
|
227
|
+
charset?: string;
|
|
228
|
+
collate?: string;
|
|
229
|
+
multipleStatements?: boolean;
|
|
230
|
+
pool?: PoolConfig;
|
|
231
|
+
}
|
|
232
|
+
export type MigrationsOptions = {
|
|
233
|
+
tableName?: string;
|
|
234
|
+
path?: string;
|
|
235
|
+
pathTs?: string;
|
|
236
|
+
glob?: string;
|
|
237
|
+
silent?: boolean;
|
|
238
|
+
transactional?: boolean;
|
|
239
|
+
disableForeignKeys?: boolean;
|
|
240
|
+
allOrNothing?: boolean;
|
|
241
|
+
dropTables?: boolean;
|
|
242
|
+
safe?: boolean;
|
|
243
|
+
snapshot?: boolean;
|
|
244
|
+
snapshotName?: string;
|
|
245
|
+
emit?: 'js' | 'ts' | 'cjs';
|
|
246
|
+
generator?: Constructor<IMigrationGenerator>;
|
|
247
|
+
fileName?: (timestamp: string, name?: string) => string;
|
|
248
|
+
migrationsList?: MigrationObject[];
|
|
249
|
+
};
|
|
250
|
+
export interface SeederOptions {
|
|
251
|
+
path?: string;
|
|
252
|
+
pathTs?: string;
|
|
253
|
+
glob?: string;
|
|
254
|
+
defaultSeeder?: string;
|
|
255
|
+
emit?: 'js' | 'ts';
|
|
256
|
+
fileName?: (className: string) => string;
|
|
257
|
+
}
|
|
258
|
+
export interface PoolConfig {
|
|
259
|
+
name?: string;
|
|
260
|
+
afterCreate?: (...a: unknown[]) => unknown;
|
|
261
|
+
min?: number;
|
|
262
|
+
max?: number;
|
|
263
|
+
refreshIdle?: boolean;
|
|
264
|
+
idleTimeoutMillis?: number;
|
|
265
|
+
reapIntervalMillis?: number;
|
|
266
|
+
returnToHead?: boolean;
|
|
267
|
+
priorityRange?: number;
|
|
268
|
+
log?: (message: string, logLevel: string) => void;
|
|
269
|
+
maxWaitingClients?: number;
|
|
270
|
+
testOnBorrow?: boolean;
|
|
271
|
+
acquireTimeoutMillis?: number;
|
|
272
|
+
fifo?: boolean;
|
|
273
|
+
autostart?: boolean;
|
|
274
|
+
evictionRunIntervalMillis?: number;
|
|
275
|
+
numTestsPerRun?: number;
|
|
276
|
+
softIdleTimeoutMillis?: number;
|
|
277
|
+
Promise?: any;
|
|
278
|
+
}
|
|
279
|
+
export interface MetadataDiscoveryOptions {
|
|
280
|
+
warnWhenNoEntities?: boolean;
|
|
281
|
+
requireEntitiesArray?: boolean;
|
|
282
|
+
checkDuplicateTableNames?: boolean;
|
|
283
|
+
checkDuplicateFieldNames?: boolean;
|
|
284
|
+
alwaysAnalyseProperties?: boolean;
|
|
285
|
+
disableDynamicFileAccess?: boolean;
|
|
286
|
+
inferDefaultValues?: boolean;
|
|
287
|
+
getMappedType?: (type: string, platform: Platform) => Type<unknown> | undefined;
|
|
288
|
+
checkDuplicateEntities?: boolean;
|
|
289
|
+
onMetadata?: (meta: EntityMetadata, platform: Platform) => MaybePromise<void>;
|
|
290
|
+
afterDiscovered?: (storage: MetadataStorage, platform: Platform) => MaybePromise<void>;
|
|
291
|
+
}
|
|
292
|
+
export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = EntityManager> extends ConnectionOptions {
|
|
293
|
+
entities: (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[];
|
|
294
|
+
entitiesTs: (string | EntityClass<AnyEntity> | EntityClassGroup<AnyEntity> | EntitySchema)[];
|
|
295
|
+
extensions: {
|
|
296
|
+
register: (orm: MikroORM) => void;
|
|
297
|
+
}[];
|
|
298
|
+
subscribers: (EventSubscriber | Constructor<EventSubscriber>)[];
|
|
299
|
+
filters: Dictionary<{
|
|
300
|
+
name?: string;
|
|
301
|
+
} & Omit<FilterDef, 'name'>>;
|
|
302
|
+
discovery: MetadataDiscoveryOptions;
|
|
303
|
+
driver?: {
|
|
304
|
+
new (config: Configuration): D;
|
|
305
|
+
};
|
|
306
|
+
driverOptions: Dictionary;
|
|
307
|
+
namingStrategy?: {
|
|
308
|
+
new (): NamingStrategy;
|
|
309
|
+
};
|
|
310
|
+
implicitTransactions?: boolean;
|
|
311
|
+
disableTransactions?: boolean;
|
|
312
|
+
connect: boolean;
|
|
313
|
+
verbose: boolean;
|
|
314
|
+
ignoreUndefinedInQuery?: boolean;
|
|
315
|
+
autoJoinOneToOneOwner: boolean;
|
|
316
|
+
autoJoinRefsForFilters: boolean;
|
|
317
|
+
propagationOnPrototype: boolean;
|
|
318
|
+
populateAfterFlush: boolean;
|
|
319
|
+
serialization: {
|
|
320
|
+
includePrimaryKeys?: boolean;
|
|
321
|
+
/** Enforce unpopulated references to be returned as objects, e.g. `{ author: { id: 1 } }` instead of `{ author: 1 }`. */
|
|
322
|
+
forceObject?: boolean;
|
|
323
|
+
};
|
|
324
|
+
persistOnCreate: boolean;
|
|
325
|
+
forceEntityConstructor: boolean | (Constructor<AnyEntity> | string)[];
|
|
326
|
+
forceUndefined: boolean;
|
|
327
|
+
forceUtcTimezone: boolean;
|
|
328
|
+
timezone?: string;
|
|
329
|
+
ensureDatabase: boolean | EnsureDatabaseOptions;
|
|
330
|
+
ensureIndexes: boolean;
|
|
331
|
+
useBatchInserts?: boolean;
|
|
332
|
+
useBatchUpdates?: boolean;
|
|
333
|
+
batchSize: number;
|
|
334
|
+
hydrator: HydratorConstructor;
|
|
335
|
+
loadStrategy: LoadStrategy | 'select-in' | 'joined';
|
|
336
|
+
dataloader: DataloaderType | boolean;
|
|
337
|
+
populateWhere: PopulateHint;
|
|
338
|
+
flushMode: FlushMode | 'commit' | 'auto' | 'always';
|
|
339
|
+
entityRepository?: EntityClass<EntityRepository<any>>;
|
|
340
|
+
entityManager?: Constructor<EM>;
|
|
341
|
+
replicas?: Partial<ConnectionOptions>[];
|
|
342
|
+
strict: boolean;
|
|
343
|
+
validate: boolean;
|
|
344
|
+
validateRequired: boolean;
|
|
345
|
+
context: (name: string) => EntityManager | undefined;
|
|
346
|
+
contextName: string;
|
|
347
|
+
allowGlobalContext: boolean;
|
|
348
|
+
disableIdentityMap?: boolean;
|
|
349
|
+
logger: (message: string) => void;
|
|
350
|
+
colors?: boolean;
|
|
351
|
+
loggerFactory?: (options: LoggerOptions) => Logger;
|
|
352
|
+
findOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
|
|
353
|
+
findExactlyOneOrFailHandler: (entityName: string, where: Dictionary | IPrimaryKey) => Error;
|
|
354
|
+
debug: boolean | LoggerNamespace[];
|
|
355
|
+
highlighter: Highlighter;
|
|
356
|
+
tsNode?: boolean;
|
|
357
|
+
baseDir: string;
|
|
358
|
+
migrations: MigrationsOptions;
|
|
359
|
+
schemaGenerator: {
|
|
360
|
+
disableForeignKeys?: boolean;
|
|
361
|
+
createForeignKeyConstraints?: boolean;
|
|
362
|
+
ignoreSchema?: string[];
|
|
363
|
+
managementDbName?: string;
|
|
364
|
+
};
|
|
365
|
+
entityGenerator: GenerateOptions;
|
|
366
|
+
metadataCache: {
|
|
367
|
+
enabled?: boolean;
|
|
368
|
+
combined?: boolean | string;
|
|
369
|
+
pretty?: boolean;
|
|
370
|
+
adapter?: {
|
|
371
|
+
new (...params: any[]): SyncCacheAdapter;
|
|
372
|
+
};
|
|
373
|
+
options?: Dictionary;
|
|
374
|
+
};
|
|
375
|
+
resultCache: {
|
|
376
|
+
expiration?: number;
|
|
377
|
+
adapter?: {
|
|
378
|
+
new (...params: any[]): CacheAdapter;
|
|
379
|
+
};
|
|
380
|
+
options?: Dictionary;
|
|
381
|
+
global?: boolean | number | [string, number];
|
|
382
|
+
};
|
|
383
|
+
metadataProvider: {
|
|
384
|
+
new (config: Configuration): MetadataProvider;
|
|
385
|
+
};
|
|
386
|
+
seeder: SeederOptions;
|
|
387
|
+
preferReadReplicas: boolean;
|
|
388
|
+
dynamicImportProvider: (id: string) => Promise<unknown>;
|
|
389
|
+
}
|
|
390
|
+
export type Options<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = D[typeof EntityManagerType] & EntityManager> = Pick<MikroORMOptions<D, EM>, Exclude<keyof MikroORMOptions<D, EM>, keyof typeof Configuration.DEFAULTS>> & Partial<MikroORMOptions<D, EM>>;
|