@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.3
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 +18 -13
- package/EntityManager.js +203 -203
- package/MikroORM.d.ts +7 -6
- package/MikroORM.js +33 -45
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +18 -26
- package/cache/GeneratedCacheAdapter.d.ts +2 -2
- package/cache/GeneratedCacheAdapter.js +1 -5
- package/cache/MemoryCacheAdapter.d.ts +1 -1
- package/cache/MemoryCacheAdapter.js +1 -5
- package/cache/NullCacheAdapter.d.ts +1 -1
- package/cache/NullCacheAdapter.js +1 -5
- package/cache/index.d.ts +5 -5
- package/cache/index.js +5 -21
- package/connections/Connection.d.ts +7 -7
- package/connections/Connection.js +8 -12
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/decorators/Check.d.ts +1 -1
- package/decorators/Check.js +5 -8
- package/decorators/CreateRequestContext.d.ts +1 -1
- package/decorators/CreateRequestContext.js +13 -14
- package/decorators/Embeddable.d.ts +1 -1
- package/decorators/Embeddable.js +3 -6
- package/decorators/Embedded.d.ts +1 -1
- package/decorators/Embedded.js +10 -12
- package/decorators/Entity.d.ts +2 -2
- package/decorators/Entity.js +5 -8
- package/decorators/Enum.d.ts +2 -2
- package/decorators/Enum.js +7 -10
- package/decorators/Filter.d.ts +1 -1
- package/decorators/Filter.js +3 -6
- package/decorators/Formula.d.ts +2 -2
- package/decorators/Formula.js +7 -10
- package/decorators/Indexed.d.ts +2 -2
- package/decorators/Indexed.js +6 -10
- package/decorators/ManyToMany.d.ts +3 -3
- package/decorators/ManyToMany.js +10 -12
- package/decorators/ManyToOne.d.ts +3 -3
- package/decorators/ManyToOne.js +10 -12
- package/decorators/OneToMany.d.ts +3 -3
- package/decorators/OneToMany.js +11 -14
- package/decorators/OneToOne.d.ts +4 -4
- package/decorators/OneToOne.js +4 -7
- package/decorators/PrimaryKey.d.ts +2 -2
- package/decorators/PrimaryKey.js +10 -13
- package/decorators/Property.d.ts +5 -5
- package/decorators/Property.js +10 -12
- package/decorators/Transactional.d.ts +2 -2
- package/decorators/Transactional.js +7 -10
- package/decorators/hooks.js +23 -35
- package/decorators/index.d.ts +17 -17
- package/decorators/index.js +17 -36
- package/drivers/DatabaseDriver.d.ts +13 -12
- package/drivers/DatabaseDriver.js +60 -64
- package/drivers/IDatabaseDriver.d.ts +12 -12
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/ArrayCollection.d.ts +2 -2
- package/entity/ArrayCollection.js +29 -33
- package/entity/BaseEntity.d.ts +6 -6
- package/entity/BaseEntity.js +17 -21
- package/entity/Collection.d.ts +6 -6
- package/entity/Collection.js +40 -44
- package/entity/EntityAssigner.d.ts +2 -2
- package/entity/EntityAssigner.js +58 -63
- package/entity/EntityFactory.d.ts +3 -3
- package/entity/EntityFactory.js +58 -62
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +41 -45
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +5 -5
- package/entity/EntityLoader.js +92 -96
- package/entity/EntityRepository.d.ts +7 -7
- package/entity/EntityRepository.js +7 -11
- package/entity/EntityValidator.d.ts +1 -1
- package/entity/EntityValidator.js +25 -29
- package/entity/Reference.d.ts +2 -2
- package/entity/Reference.js +35 -42
- package/entity/WrappedEntity.d.ts +12 -12
- package/entity/WrappedEntity.js +23 -27
- package/entity/index.d.ts +13 -13
- package/entity/index.js +13 -29
- package/entity/utils.d.ts +1 -1
- package/entity/utils.js +9 -12
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +3 -3
- package/enums.js +37 -41
- package/errors.d.ts +1 -1
- package/errors.js +15 -24
- package/events/EventManager.d.ts +3 -3
- package/events/EventManager.js +8 -12
- package/events/EventSubscriber.d.ts +5 -4
- package/events/EventSubscriber.js +1 -2
- package/events/TransactionEventBroadcaster.d.ts +3 -3
- package/events/TransactionEventBroadcaster.js +1 -5
- package/events/index.d.ts +3 -3
- package/events/index.js +3 -19
- package/exceptions.js +18 -39
- package/hydration/Hydrator.d.ts +5 -5
- package/hydration/Hydrator.js +3 -6
- package/hydration/ObjectHydrator.d.ts +3 -3
- package/hydration/ObjectHydrator.js +25 -28
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +21 -46
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +9 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +2 -2
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +4 -4
- package/logging/index.js +4 -20
- package/metadata/EntitySchema.d.ts +12 -4
- package/metadata/EntitySchema.js +41 -45
- package/metadata/MetadataDiscovery.d.ts +7 -7
- package/metadata/MetadataDiscovery.js +174 -177
- package/metadata/MetadataProvider.d.ts +2 -2
- package/metadata/MetadataProvider.js +4 -7
- package/metadata/MetadataStorage.d.ts +2 -2
- package/metadata/MetadataStorage.js +15 -19
- package/metadata/MetadataValidator.d.ts +4 -4
- package/metadata/MetadataValidator.js +49 -53
- package/metadata/ReflectMetadataProvider.d.ts +2 -2
- package/metadata/ReflectMetadataProvider.js +8 -12
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/naming-strategy/AbstractNamingStrategy.d.ts +2 -2
- package/naming-strategy/AbstractNamingStrategy.js +4 -8
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
- package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
- package/naming-strategy/MongoNamingStrategy.js +2 -6
- package/naming-strategy/NamingStrategy.d.ts +1 -1
- package/naming-strategy/NamingStrategy.js +1 -2
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
- package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
- package/naming-strategy/index.d.ts +5 -5
- package/naming-strategy/index.js +5 -21
- package/package.json +5 -14
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +10 -10
- package/platforms/Platform.js +57 -61
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +2 -2
- package/serialization/EntitySerializer.js +36 -41
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +27 -31
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +10 -14
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +7 -11
- package/types/BigIntType.d.ts +3 -3
- package/types/BigIntType.js +3 -6
- package/types/BlobType.d.ts +3 -3
- package/types/BlobType.js +2 -8
- package/types/BooleanType.d.ts +3 -3
- package/types/BooleanType.js +2 -6
- package/types/CharacterType.d.ts +3 -3
- package/types/CharacterType.js +2 -6
- package/types/DateTimeType.d.ts +3 -3
- package/types/DateTimeType.js +2 -6
- package/types/DateType.d.ts +3 -3
- package/types/DateType.js +2 -6
- package/types/DecimalType.d.ts +3 -3
- package/types/DecimalType.js +4 -7
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +3 -6
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +5 -10
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +2 -6
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +2 -6
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +2 -6
- package/types/IntervalType.d.ts +3 -3
- package/types/IntervalType.js +2 -6
- package/types/JsonType.d.ts +3 -3
- package/types/JsonType.js +2 -6
- package/types/MediumIntType.d.ts +3 -3
- package/types/MediumIntType.js +2 -6
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +2 -6
- package/types/StringType.d.ts +3 -3
- package/types/StringType.js +2 -6
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +2 -6
- package/types/TimeType.d.ts +3 -3
- package/types/TimeType.js +4 -8
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +3 -6
- package/types/Type.d.ts +2 -2
- package/types/Type.js +5 -9
- package/types/Uint8ArrayType.d.ts +3 -3
- package/types/Uint8ArrayType.js +3 -9
- package/types/UnknownType.d.ts +3 -3
- package/types/UnknownType.js +2 -6
- package/types/UuidType.d.ts +3 -3
- package/types/UuidType.js +2 -6
- package/types/index.d.ts +25 -25
- package/types/index.js +52 -79
- package/typings.d.ts +22 -20
- package/typings.js +34 -38
- package/unit-of-work/ChangeSet.d.ts +1 -1
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -7
- package/unit-of-work/ChangeSetComputer.js +26 -30
- package/unit-of-work/ChangeSetPersister.d.ts +7 -6
- package/unit-of-work/ChangeSetPersister.js +44 -47
- package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
- package/unit-of-work/CommitOrderCalculator.js +6 -10
- package/unit-of-work/IdentityMap.d.ts +1 -1
- package/unit-of-work/IdentityMap.js +1 -5
- package/unit-of-work/UnitOfWork.d.ts +8 -7
- package/unit-of-work/UnitOfWork.js +171 -172
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +6 -6
- package/utils/AbstractSchemaGenerator.js +7 -11
- package/utils/Configuration.d.ts +26 -27
- package/utils/Configuration.js +50 -55
- package/utils/ConfigurationLoader.d.ts +9 -8
- package/utils/ConfigurationLoader.js +71 -86
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +22 -25
- package/utils/DataloaderUtils.d.ts +4 -4
- package/utils/DataloaderUtils.js +12 -16
- package/utils/EntityComparator.d.ts +2 -2
- package/utils/EntityComparator.js +48 -52
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +3 -3
- package/utils/QueryHelper.js +47 -51
- package/utils/RawQueryFragment.d.ts +1 -1
- package/utils/RawQueryFragment.js +16 -24
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +3 -7
- package/utils/TransactionContext.d.ts +1 -1
- package/utils/TransactionContext.js +4 -8
- package/utils/Utils.d.ts +16 -12
- package/utils/Utils.js +89 -93
- package/utils/clone.js +8 -11
- package/utils/index.d.ts +13 -13
- package/utils/index.js +13 -29
- package/utils/resolveContextProvider.d.ts +3 -3
- package/utils/resolveContextProvider.js +9 -12
- package/utils/upsert-utils.d.ts +3 -3
- package/utils/upsert-utils.js +5 -9
- package/index.mjs +0 -199
package/unit-of-work/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from './ChangeSet';
|
|
2
|
-
export * from './ChangeSetComputer';
|
|
3
|
-
export * from './ChangeSetPersister';
|
|
4
|
-
export * from './CommitOrderCalculator';
|
|
5
|
-
export * from './UnitOfWork';
|
|
6
|
-
export * from './IdentityMap';
|
|
1
|
+
export * from './ChangeSet.js';
|
|
2
|
+
export * from './ChangeSetComputer.js';
|
|
3
|
+
export * from './ChangeSetPersister.js';
|
|
4
|
+
export * from './CommitOrderCalculator.js';
|
|
5
|
+
export * from './UnitOfWork.js';
|
|
6
|
+
export * from './IdentityMap.js';
|
package/unit-of-work/index.js
CHANGED
|
@@ -1,22 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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);
|
|
1
|
+
export * from './ChangeSet.js';
|
|
2
|
+
export * from './ChangeSetComputer.js';
|
|
3
|
+
export * from './ChangeSetPersister.js';
|
|
4
|
+
export * from './CommitOrderCalculator.js';
|
|
5
|
+
export * from './UnitOfWork.js';
|
|
6
|
+
export * from './IdentityMap.js';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { ClearDatabaseOptions, DropSchemaOptions, EntityMetadata, ISchemaGenerator, UpdateSchemaOptions, CreateSchemaOptions, RefreshDatabaseOptions, EnsureDatabaseOptions } from '../typings';
|
|
2
|
-
import type
|
|
3
|
-
import type { MetadataStorage } from '../metadata/MetadataStorage';
|
|
4
|
-
import type { Configuration } from './Configuration';
|
|
1
|
+
import type { ClearDatabaseOptions, DropSchemaOptions, EntityMetadata, ISchemaGenerator, UpdateSchemaOptions, CreateSchemaOptions, RefreshDatabaseOptions, EnsureDatabaseOptions } from '../typings.js';
|
|
2
|
+
import { type EntityManagerType, type IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
|
|
3
|
+
import type { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
4
|
+
import type { Configuration } from './Configuration.js';
|
|
5
5
|
export declare abstract class AbstractSchemaGenerator<D extends IDatabaseDriver> implements ISchemaGenerator {
|
|
6
|
-
protected readonly em?:
|
|
6
|
+
protected readonly em?: D[typeof EntityManagerType];
|
|
7
7
|
protected readonly driver: D;
|
|
8
8
|
protected readonly config: Configuration;
|
|
9
9
|
protected readonly metadata: MetadataStorage;
|
|
10
10
|
protected readonly platform: ReturnType<D['getPlatform']>;
|
|
11
11
|
protected readonly connection: ReturnType<D['getConnection']>;
|
|
12
|
-
constructor(em: D |
|
|
12
|
+
constructor(em: D | D[typeof EntityManagerType]);
|
|
13
13
|
createSchema(options?: CreateSchemaOptions): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* Returns true if the database was created.
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const CommitOrderCalculator_1 = require("../unit-of-work/CommitOrderCalculator");
|
|
5
|
-
const EntityManager_1 = require("../EntityManager");
|
|
6
|
-
class AbstractSchemaGenerator {
|
|
1
|
+
import { CommitOrderCalculator } from '../unit-of-work/CommitOrderCalculator.js';
|
|
2
|
+
import { EntityManager } from '../EntityManager.js';
|
|
3
|
+
export class AbstractSchemaGenerator {
|
|
7
4
|
em;
|
|
8
5
|
driver;
|
|
9
6
|
config;
|
|
@@ -11,8 +8,8 @@ class AbstractSchemaGenerator {
|
|
|
11
8
|
platform;
|
|
12
9
|
connection;
|
|
13
10
|
constructor(em) {
|
|
14
|
-
this.em = em instanceof
|
|
15
|
-
this.driver = em instanceof
|
|
11
|
+
this.em = em instanceof EntityManager ? em : undefined;
|
|
12
|
+
this.driver = em instanceof EntityManager ? em.getDriver() : em;
|
|
16
13
|
this.config = this.driver.config;
|
|
17
14
|
this.metadata = this.driver.getMetadata();
|
|
18
15
|
this.platform = this.driver.getPlatform();
|
|
@@ -48,7 +45,7 @@ class AbstractSchemaGenerator {
|
|
|
48
45
|
this.clearIdentityMap();
|
|
49
46
|
}
|
|
50
47
|
clearIdentityMap() {
|
|
51
|
-
/*
|
|
48
|
+
/* v8 ignore next 3 */
|
|
52
49
|
if (!this.em) {
|
|
53
50
|
return;
|
|
54
51
|
}
|
|
@@ -95,7 +92,7 @@ class AbstractSchemaGenerator {
|
|
|
95
92
|
const isRootEntity = meta.root.className === meta.className;
|
|
96
93
|
return isRootEntity && !meta.embeddable && !meta.virtual;
|
|
97
94
|
});
|
|
98
|
-
const calc = new
|
|
95
|
+
const calc = new CommitOrderCalculator();
|
|
99
96
|
metadata.forEach(meta => calc.addNode(meta.root.className));
|
|
100
97
|
let meta = metadata.pop();
|
|
101
98
|
while (meta) {
|
|
@@ -112,4 +109,3 @@ class AbstractSchemaGenerator {
|
|
|
112
109
|
throw new Error(`This method is not supported by ${this.driver.constructor.name} driver`);
|
|
113
110
|
}
|
|
114
111
|
}
|
|
115
|
-
exports.AbstractSchemaGenerator = AbstractSchemaGenerator;
|
package/utils/Configuration.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
import type { NamingStrategy } from '../naming-strategy';
|
|
2
|
-
import { FileCacheAdapter
|
|
3
|
-
import type
|
|
4
|
-
import type {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import type
|
|
9
|
-
import type {
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
import
|
|
15
|
-
import type {
|
|
16
|
-
import type {
|
|
17
|
-
import type {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import
|
|
23
|
-
import type {
|
|
1
|
+
import type { NamingStrategy } from '../naming-strategy/NamingStrategy.js';
|
|
2
|
+
import { FileCacheAdapter } from '../cache/FileCacheAdapter.js';
|
|
3
|
+
import { type SyncCacheAdapter, type CacheAdapter } from '../cache/CacheAdapter.js';
|
|
4
|
+
import type { EntityRepository } from '../entity/EntityRepository.js';
|
|
5
|
+
import type { AnyEntity, Constructor, Dictionary, EntityClass, EntityClassGroup, FilterDef, Highlighter, HydratorConstructor, IHydrator, IMigrationGenerator, IPrimaryKey, MaybePromise, MigrationObject, EntityMetadata, EnsureDatabaseOptions, GenerateOptions, Migration } from '../typings.js';
|
|
6
|
+
import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
|
|
7
|
+
import { NullHighlighter } from '../utils/NullHighlighter.js';
|
|
8
|
+
import { type Logger, type LoggerNamespace, type LoggerOptions } from '../logging/Logger.js';
|
|
9
|
+
import type { EntityManager } from '../EntityManager.js';
|
|
10
|
+
import type { Platform } from '../platforms/Platform.js';
|
|
11
|
+
import type { EntitySchema } from '../metadata/EntitySchema.js';
|
|
12
|
+
import type { MetadataProvider } from '../metadata/MetadataProvider.js';
|
|
13
|
+
import type { MetadataStorage } from '../metadata/MetadataStorage.js';
|
|
14
|
+
import { ReflectMetadataProvider } from '../metadata/ReflectMetadataProvider.js';
|
|
15
|
+
import type { EmbeddedPrefixMode } from '../decorators/Embedded.js';
|
|
16
|
+
import type { EventSubscriber } from '../events/EventSubscriber.js';
|
|
17
|
+
import type { AssignOptions } from '../entity/EntityAssigner.js';
|
|
18
|
+
import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
|
|
19
|
+
import { NotFoundError } from '../errors.js';
|
|
20
|
+
import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums.js';
|
|
21
|
+
import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
|
|
22
|
+
import { EntityComparator } from './EntityComparator.js';
|
|
23
|
+
import type { Type } from '../types/Type.js';
|
|
24
|
+
import type { MikroORM } from '../MikroORM.js';
|
|
24
25
|
export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver, EM extends EntityManager = D[typeof EntityManagerType] & EntityManager> {
|
|
25
26
|
static readonly DEFAULTS: {
|
|
26
27
|
pool: {};
|
|
@@ -43,7 +44,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
43
44
|
strict: false;
|
|
44
45
|
validate: false;
|
|
45
46
|
validateRequired: true;
|
|
46
|
-
context: (name: string) => EntityManager<IDatabaseDriver<import("
|
|
47
|
+
context: (name: string) => EntityManager<IDatabaseDriver<import("../index.js").Connection>> | undefined;
|
|
47
48
|
contextName: string;
|
|
48
49
|
allowGlobalContext: false;
|
|
49
50
|
logger: (message?: any, ...optionalParams: any[]) => void;
|
|
@@ -231,7 +232,7 @@ export declare class Configuration<D extends IDatabaseDriver = IDatabaseDriver,
|
|
|
231
232
|
/**
|
|
232
233
|
* Type helper to make it easier to use `mikro-orm.config.js`.
|
|
233
234
|
*/
|
|
234
|
-
export declare function defineConfig<D extends IDatabaseDriver>(options: Options<D>): Options<D, D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<import("
|
|
235
|
+
export declare function defineConfig<D extends IDatabaseDriver>(options: Options<D>): Options<D, D[typeof EntityManagerType] & EntityManager<IDatabaseDriver<import("../index.js").Connection>>>;
|
|
235
236
|
export interface ConnectionOptions {
|
|
236
237
|
dbName?: string;
|
|
237
238
|
schema?: string;
|
|
@@ -367,8 +368,6 @@ export interface MikroORMOptions<D extends IDatabaseDriver = IDatabaseDriver, EM
|
|
|
367
368
|
* seeders. Should be used only for tests and stay disabled for production builds.
|
|
368
369
|
*/
|
|
369
370
|
preferTs?: boolean;
|
|
370
|
-
/** @deprecated use `preferTs` instead */
|
|
371
|
-
tsNode?: boolean;
|
|
372
371
|
baseDir: string;
|
|
373
372
|
migrations: MigrationsOptions;
|
|
374
373
|
schemaGenerator: {
|
package/utils/Configuration.js
CHANGED
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
const MemoryCacheAdapter_1 = require("../cache/MemoryCacheAdapter");
|
|
16
|
-
const EntityComparator_1 = require("./EntityComparator");
|
|
17
|
-
class Configuration {
|
|
1
|
+
import { FileCacheAdapter } from '../cache/FileCacheAdapter.js';
|
|
2
|
+
import { NullCacheAdapter } from '../cache/NullCacheAdapter.js';
|
|
3
|
+
import { ObjectHydrator } from '../hydration/ObjectHydrator.js';
|
|
4
|
+
import { NullHighlighter } from '../utils/NullHighlighter.js';
|
|
5
|
+
import { DefaultLogger } from '../logging/DefaultLogger.js';
|
|
6
|
+
import { colors } from '../logging/colors.js';
|
|
7
|
+
import { Utils } from '../utils/Utils.js';
|
|
8
|
+
import { ReflectMetadataProvider } from '../metadata/ReflectMetadataProvider.js';
|
|
9
|
+
import { NotFoundError } from '../errors.js';
|
|
10
|
+
import { RequestContext } from './RequestContext.js';
|
|
11
|
+
import { DataloaderType, FlushMode, LoadStrategy, PopulateHint } from '../enums.js';
|
|
12
|
+
import { MemoryCacheAdapter } from '../cache/MemoryCacheAdapter.js';
|
|
13
|
+
import { EntityComparator } from './EntityComparator.js';
|
|
14
|
+
export class Configuration {
|
|
18
15
|
static DEFAULTS = {
|
|
19
16
|
pool: {},
|
|
20
17
|
entities: [],
|
|
@@ -36,20 +33,20 @@ class Configuration {
|
|
|
36
33
|
strict: false,
|
|
37
34
|
validate: false,
|
|
38
35
|
validateRequired: true,
|
|
39
|
-
context: (name) =>
|
|
36
|
+
context: (name) => RequestContext.getEntityManager(name),
|
|
40
37
|
contextName: 'default',
|
|
41
38
|
allowGlobalContext: false,
|
|
42
39
|
// eslint-disable-next-line no-console
|
|
43
40
|
logger: console.log.bind(console),
|
|
44
41
|
colors: true,
|
|
45
|
-
findOneOrFailHandler: (entityName, where) =>
|
|
46
|
-
findExactlyOneOrFailHandler: (entityName, where) =>
|
|
42
|
+
findOneOrFailHandler: (entityName, where) => NotFoundError.findOneFailed(entityName, where),
|
|
43
|
+
findExactlyOneOrFailHandler: (entityName, where) => NotFoundError.findExactlyOneFailed(entityName, where),
|
|
47
44
|
baseDir: process.cwd(),
|
|
48
|
-
hydrator:
|
|
49
|
-
flushMode:
|
|
50
|
-
loadStrategy:
|
|
51
|
-
dataloader:
|
|
52
|
-
populateWhere:
|
|
45
|
+
hydrator: ObjectHydrator,
|
|
46
|
+
flushMode: FlushMode.AUTO,
|
|
47
|
+
loadStrategy: LoadStrategy.JOINED,
|
|
48
|
+
dataloader: DataloaderType.NONE,
|
|
49
|
+
populateWhere: PopulateHint.ALL,
|
|
53
50
|
connect: true,
|
|
54
51
|
ignoreUndefinedInQuery: false,
|
|
55
52
|
onQuery: sql => sql,
|
|
@@ -115,16 +112,16 @@ class Configuration {
|
|
|
115
112
|
},
|
|
116
113
|
metadataCache: {
|
|
117
114
|
pretty: false,
|
|
118
|
-
adapter:
|
|
115
|
+
adapter: FileCacheAdapter,
|
|
119
116
|
options: { cacheDir: process.cwd() + '/temp' },
|
|
120
117
|
},
|
|
121
118
|
resultCache: {
|
|
122
|
-
adapter:
|
|
119
|
+
adapter: MemoryCacheAdapter,
|
|
123
120
|
expiration: 1000, // 1s
|
|
124
121
|
options: {},
|
|
125
122
|
},
|
|
126
|
-
metadataProvider:
|
|
127
|
-
highlighter: new
|
|
123
|
+
metadataProvider: ReflectMetadataProvider,
|
|
124
|
+
highlighter: new NullHighlighter(),
|
|
128
125
|
seeder: {
|
|
129
126
|
path: './seeders',
|
|
130
127
|
defaultSeeder: 'DatabaseSeeder',
|
|
@@ -133,7 +130,7 @@ class Configuration {
|
|
|
133
130
|
fileName: (className) => className,
|
|
134
131
|
},
|
|
135
132
|
preferReadReplicas: true,
|
|
136
|
-
dynamicImportProvider: /*
|
|
133
|
+
dynamicImportProvider: /* v8 ignore next */ (id) => import(id),
|
|
137
134
|
};
|
|
138
135
|
options;
|
|
139
136
|
logger;
|
|
@@ -143,15 +140,15 @@ class Configuration {
|
|
|
143
140
|
extensions = new Map();
|
|
144
141
|
constructor(options, validate = true) {
|
|
145
142
|
if (options.dynamicImportProvider) {
|
|
146
|
-
|
|
143
|
+
Utils.setDynamicImportProvider(options.dynamicImportProvider);
|
|
147
144
|
}
|
|
148
|
-
this.options =
|
|
149
|
-
this.options.baseDir =
|
|
150
|
-
this.options.preferTs ??= options.
|
|
145
|
+
this.options = Utils.mergeConfig({}, Configuration.DEFAULTS, options);
|
|
146
|
+
this.options.baseDir = Utils.absolutePath(this.options.baseDir);
|
|
147
|
+
this.options.preferTs ??= options.preferTs;
|
|
151
148
|
if (validate) {
|
|
152
149
|
this.validateOptions();
|
|
153
150
|
}
|
|
154
|
-
this.options.loggerFactory ??=
|
|
151
|
+
this.options.loggerFactory ??= DefaultLogger.create;
|
|
155
152
|
this.logger = this.options.loggerFactory({
|
|
156
153
|
debugMode: this.options.debug,
|
|
157
154
|
ignoreDeprecations: this.options.ignoreDeprecations,
|
|
@@ -203,7 +200,7 @@ class Configuration {
|
|
|
203
200
|
}
|
|
204
201
|
getDataloaderType() {
|
|
205
202
|
if (typeof this.options.dataloader === 'boolean') {
|
|
206
|
-
return this.options.dataloader ?
|
|
203
|
+
return this.options.dataloader ? DataloaderType.ALL : DataloaderType.NONE;
|
|
207
204
|
}
|
|
208
205
|
return this.options.dataloader;
|
|
209
206
|
}
|
|
@@ -236,12 +233,12 @@ class Configuration {
|
|
|
236
233
|
return this.cache.get(name);
|
|
237
234
|
}
|
|
238
235
|
const ext = this.extensions.get(name);
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
return
|
|
236
|
+
/* v8 ignore next 3 */
|
|
237
|
+
if (!ext) {
|
|
238
|
+
return undefined;
|
|
242
239
|
}
|
|
243
|
-
|
|
244
|
-
return
|
|
240
|
+
this.cache.set(name, ext());
|
|
241
|
+
return this.cache.get(name);
|
|
245
242
|
}
|
|
246
243
|
/**
|
|
247
244
|
* Gets instance of NamingStrategy. (cached)
|
|
@@ -259,7 +256,7 @@ class Configuration {
|
|
|
259
256
|
* Gets instance of Comparator. (cached)
|
|
260
257
|
*/
|
|
261
258
|
getComparator(metadata) {
|
|
262
|
-
return this.getCachedService(
|
|
259
|
+
return this.getCachedService(EntityComparator, metadata, this.platform);
|
|
263
260
|
}
|
|
264
261
|
/**
|
|
265
262
|
* Gets instance of MetadataProvider. (cached)
|
|
@@ -306,7 +303,7 @@ class Configuration {
|
|
|
306
303
|
}
|
|
307
304
|
init(validate) {
|
|
308
305
|
if (!this.getMetadataProvider().useCache()) {
|
|
309
|
-
this.options.metadataCache.adapter =
|
|
306
|
+
this.options.metadataCache.adapter = NullCacheAdapter;
|
|
310
307
|
}
|
|
311
308
|
if (!('enabled' in this.options.metadataCache)) {
|
|
312
309
|
this.options.metadataCache.enabled = this.getMetadataProvider().useCache();
|
|
@@ -341,17 +338,16 @@ class Configuration {
|
|
|
341
338
|
Object.keys(this.options.filters).forEach(key => {
|
|
342
339
|
this.options.filters[key].default ??= true;
|
|
343
340
|
});
|
|
344
|
-
this.options.subscribers =
|
|
341
|
+
this.options.subscribers = Utils.unique(this.options.subscribers).map(subscriber => {
|
|
345
342
|
return subscriber.constructor.name === 'Function' ? new subscriber() : subscriber;
|
|
346
343
|
});
|
|
347
344
|
this.sync();
|
|
348
|
-
if (!
|
|
349
|
-
this.options.highlighter = new
|
|
345
|
+
if (!colors.enabled()) {
|
|
346
|
+
this.options.highlighter = new NullHighlighter();
|
|
350
347
|
}
|
|
351
348
|
}
|
|
352
349
|
sync() {
|
|
353
350
|
process.env.MIKRO_ORM_COLORS = '' + this.options.colors;
|
|
354
|
-
this.options.tsNode = this.options.preferTs;
|
|
355
351
|
this.logger.setDebugMode(this.options.debug);
|
|
356
352
|
}
|
|
357
353
|
/**
|
|
@@ -363,13 +359,13 @@ class Configuration {
|
|
|
363
359
|
* break existing projects, only help with the new ones.
|
|
364
360
|
*/
|
|
365
361
|
detectSourceFolder(options) {
|
|
366
|
-
if (!
|
|
362
|
+
if (!Utils.pathExistsSync(this.options.baseDir + '/src')) {
|
|
367
363
|
return;
|
|
368
364
|
}
|
|
369
|
-
const migrationsPathExists =
|
|
370
|
-
const seedersPathExists =
|
|
371
|
-
const distDir =
|
|
372
|
-
const buildDir =
|
|
365
|
+
const migrationsPathExists = Utils.pathExistsSync(this.options.baseDir + '/' + this.options.migrations.path);
|
|
366
|
+
const seedersPathExists = Utils.pathExistsSync(this.options.baseDir + '/' + this.options.seeder.path);
|
|
367
|
+
const distDir = Utils.pathExistsSync(this.options.baseDir + '/dist');
|
|
368
|
+
const buildDir = Utils.pathExistsSync(this.options.baseDir + '/build');
|
|
373
369
|
// if neither `dist` nor `build` exist, we use the `src` folder as it might be a JS project without building, but with `src` folder
|
|
374
370
|
const path = distDir ? './dist' : (buildDir ? './build' : './src');
|
|
375
371
|
// only if the user did not provide any values and if the default path does not exist
|
|
@@ -384,7 +380,7 @@ class Configuration {
|
|
|
384
380
|
}
|
|
385
381
|
}
|
|
386
382
|
validateOptions() {
|
|
387
|
-
/*
|
|
383
|
+
/* v8 ignore next 3 */
|
|
388
384
|
if ('type' in this.options) {
|
|
389
385
|
throw new Error('The `type` option has been removed in v6, please fill in the `driver` option instead or use `defineConfig` helper (to define your ORM config) or `MikroORM` class (to call the `init` method) exported from the driver package (e.g. `import { defineConfig } from \'@mikro-orm/mysql\'; export default defineConfig({ ... })`).');
|
|
390
386
|
}
|
|
@@ -399,10 +395,9 @@ class Configuration {
|
|
|
399
395
|
}
|
|
400
396
|
}
|
|
401
397
|
}
|
|
402
|
-
exports.Configuration = Configuration;
|
|
403
398
|
/**
|
|
404
399
|
* Type helper to make it easier to use `mikro-orm.config.js`.
|
|
405
400
|
*/
|
|
406
|
-
function defineConfig(options) {
|
|
401
|
+
export function defineConfig(options) {
|
|
407
402
|
return options;
|
|
408
403
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { EntityManager } from '../EntityManager';
|
|
2
|
-
import type { EntityManagerType, IDatabaseDriver } from '../drivers';
|
|
3
|
-
import type { Dictionary } from '../typings';
|
|
4
|
-
import { Configuration, type Options } from './Configuration';
|
|
1
|
+
import type { EntityManager } from '../EntityManager.js';
|
|
2
|
+
import type { EntityManagerType, IDatabaseDriver } from '../drivers/IDatabaseDriver.js';
|
|
3
|
+
import type { Dictionary } from '../typings.js';
|
|
4
|
+
import { Configuration, type Options } from './Configuration.js';
|
|
5
5
|
/**
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
@@ -35,9 +35,10 @@ export declare class ConfigurationLoader {
|
|
|
35
35
|
static configPathsFromArg(): string[] | undefined;
|
|
36
36
|
static getConfigPaths(): string[];
|
|
37
37
|
static isESM(): boolean;
|
|
38
|
-
static
|
|
39
|
-
static registerDotenv<D extends IDatabaseDriver>(options?: Options<D>
|
|
40
|
-
static loadEnvironmentVars<D extends IDatabaseDriver>(): Partial<Options<D
|
|
38
|
+
static registerTypeScriptSupport(configPath?: string): Promise<boolean>;
|
|
39
|
+
static registerDotenv<D extends IDatabaseDriver>(options?: Options<D>): void;
|
|
40
|
+
static loadEnvironmentVars<D extends IDatabaseDriver>(): Promise<Partial<Options<D>>>;
|
|
41
|
+
static loadEnvironmentVarsSync<D extends IDatabaseDriver>(): Partial<Options<D>>;
|
|
41
42
|
static getORMPackages(): Set<string>;
|
|
42
43
|
/** @internal */
|
|
43
44
|
static commonJSCompat(options: Partial<Options>): void;
|
|
@@ -47,7 +48,7 @@ export declare class ConfigurationLoader {
|
|
|
47
48
|
export interface Settings {
|
|
48
49
|
alwaysAllowTs?: boolean;
|
|
49
50
|
verbose?: boolean;
|
|
50
|
-
|
|
51
|
+
preferTs?: boolean;
|
|
51
52
|
tsConfigPath?: string;
|
|
52
53
|
configPaths?: string[];
|
|
53
54
|
}
|