@mikro-orm/core 7.0.0-dev.23 → 7.0.0-dev.231
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 +91 -59
- package/EntityManager.js +303 -251
- package/MikroORM.d.ts +44 -35
- package/MikroORM.js +109 -143
- package/README.md +2 -0
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +17 -8
- package/cache/GeneratedCacheAdapter.d.ts +0 -1
- package/cache/GeneratedCacheAdapter.js +0 -2
- package/cache/index.d.ts +0 -1
- package/cache/index.js +0 -1
- package/connections/Connection.d.ts +12 -5
- package/connections/Connection.js +21 -12
- package/drivers/DatabaseDriver.d.ts +25 -16
- package/drivers/DatabaseDriver.js +118 -35
- package/drivers/IDatabaseDriver.d.ts +42 -19
- package/entity/BaseEntity.d.ts +61 -2
- package/entity/BaseEntity.js +0 -3
- package/entity/Collection.d.ts +101 -29
- package/entity/Collection.js +436 -104
- package/entity/EntityAssigner.d.ts +1 -1
- package/entity/EntityAssigner.js +26 -18
- package/entity/EntityFactory.d.ts +7 -1
- package/entity/EntityFactory.js +83 -54
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +48 -15
- package/entity/EntityLoader.d.ts +7 -6
- package/entity/EntityLoader.js +221 -93
- package/entity/EntityRepository.d.ts +27 -7
- package/entity/EntityRepository.js +8 -2
- package/entity/PolymorphicRef.d.ts +12 -0
- package/entity/PolymorphicRef.js +18 -0
- package/entity/Reference.d.ts +1 -5
- package/entity/Reference.js +21 -12
- package/entity/WrappedEntity.d.ts +0 -5
- package/entity/WrappedEntity.js +2 -7
- package/entity/defineEntity.d.ts +380 -310
- package/entity/defineEntity.js +124 -273
- package/entity/index.d.ts +2 -2
- package/entity/index.js +2 -2
- package/entity/utils.js +1 -1
- package/entity/validators.d.ts +11 -0
- package/entity/validators.js +65 -0
- package/enums.d.ts +8 -6
- package/enums.js +2 -1
- package/errors.d.ts +20 -10
- package/errors.js +55 -23
- package/events/EventManager.d.ts +2 -1
- package/events/EventManager.js +19 -11
- package/hydration/Hydrator.js +1 -2
- package/hydration/ObjectHydrator.d.ts +4 -4
- package/hydration/ObjectHydrator.js +87 -35
- package/index.d.ts +2 -2
- package/index.js +1 -2
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +1 -0
- package/logging/SimpleLogger.d.ts +1 -1
- package/logging/colors.d.ts +1 -1
- package/logging/colors.js +7 -6
- package/logging/index.d.ts +1 -0
- package/logging/index.js +1 -0
- package/logging/inspect.d.ts +2 -0
- package/logging/inspect.js +11 -0
- package/metadata/EntitySchema.d.ts +47 -23
- package/metadata/EntitySchema.js +92 -33
- package/metadata/MetadataDiscovery.d.ts +64 -9
- package/metadata/MetadataDiscovery.js +778 -325
- package/metadata/MetadataProvider.d.ts +11 -2
- package/metadata/MetadataProvider.js +46 -2
- package/metadata/MetadataStorage.d.ts +13 -11
- package/metadata/MetadataStorage.js +70 -37
- package/metadata/MetadataValidator.d.ts +32 -9
- package/metadata/MetadataValidator.js +196 -41
- package/metadata/discover-entities.d.ts +5 -0
- package/metadata/discover-entities.js +40 -0
- package/metadata/index.d.ts +1 -1
- package/metadata/index.js +1 -1
- package/metadata/types.d.ts +526 -0
- package/metadata/types.js +1 -0
- package/naming-strategy/AbstractNamingStrategy.d.ts +16 -4
- package/naming-strategy/AbstractNamingStrategy.js +20 -2
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +3 -3
- package/naming-strategy/EntityCaseNamingStrategy.js +6 -5
- package/naming-strategy/MongoNamingStrategy.d.ts +3 -3
- package/naming-strategy/MongoNamingStrategy.js +6 -6
- package/naming-strategy/NamingStrategy.d.ts +28 -4
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +3 -3
- package/naming-strategy/UnderscoreNamingStrategy.js +6 -6
- package/not-supported.d.ts +2 -0
- package/not-supported.js +4 -0
- package/package.json +19 -11
- package/platforms/ExceptionConverter.js +1 -1
- package/platforms/Platform.d.ts +7 -14
- package/platforms/Platform.js +20 -43
- package/serialization/EntitySerializer.d.ts +5 -0
- package/serialization/EntitySerializer.js +47 -27
- package/serialization/EntityTransformer.js +28 -18
- package/serialization/SerializationContext.d.ts +6 -6
- package/serialization/SerializationContext.js +3 -3
- package/types/ArrayType.d.ts +1 -1
- package/types/ArrayType.js +2 -3
- package/types/BigIntType.d.ts +8 -6
- package/types/BigIntType.js +1 -1
- package/types/BlobType.d.ts +0 -1
- package/types/BlobType.js +0 -3
- package/types/BooleanType.d.ts +1 -0
- package/types/BooleanType.js +3 -0
- package/types/DecimalType.d.ts +6 -4
- package/types/DecimalType.js +2 -2
- package/types/DoubleType.js +1 -1
- package/types/EnumArrayType.js +1 -2
- package/types/JsonType.d.ts +1 -1
- package/types/JsonType.js +7 -2
- package/types/TinyIntType.js +1 -1
- package/types/Type.d.ts +2 -4
- package/types/Type.js +3 -3
- package/types/Uint8ArrayType.d.ts +0 -1
- package/types/Uint8ArrayType.js +1 -4
- package/types/index.d.ts +1 -1
- package/typings.d.ts +381 -171
- package/typings.js +97 -44
- package/unit-of-work/ChangeSet.d.ts +4 -6
- package/unit-of-work/ChangeSet.js +4 -5
- package/unit-of-work/ChangeSetComputer.d.ts +1 -3
- package/unit-of-work/ChangeSetComputer.js +35 -14
- package/unit-of-work/ChangeSetPersister.d.ts +7 -3
- package/unit-of-work/ChangeSetPersister.js +83 -25
- package/unit-of-work/CommitOrderCalculator.d.ts +12 -10
- package/unit-of-work/CommitOrderCalculator.js +13 -13
- package/unit-of-work/IdentityMap.d.ts +12 -0
- package/unit-of-work/IdentityMap.js +39 -1
- package/unit-of-work/UnitOfWork.d.ts +27 -3
- package/unit-of-work/UnitOfWork.js +258 -92
- package/utils/AbstractSchemaGenerator.d.ts +5 -5
- package/utils/AbstractSchemaGenerator.js +28 -17
- package/utils/AsyncContext.d.ts +6 -0
- package/utils/AsyncContext.js +42 -0
- package/utils/Configuration.d.ts +795 -209
- package/utils/Configuration.js +150 -192
- package/utils/ConfigurationLoader.d.ts +1 -54
- package/utils/ConfigurationLoader.js +1 -352
- package/utils/Cursor.d.ts +0 -3
- package/utils/Cursor.js +24 -11
- package/utils/DataloaderUtils.d.ts +10 -5
- package/utils/DataloaderUtils.js +29 -12
- package/utils/EntityComparator.d.ts +16 -9
- package/utils/EntityComparator.js +158 -58
- package/utils/QueryHelper.d.ts +18 -6
- package/utils/QueryHelper.js +76 -23
- package/utils/RawQueryFragment.d.ts +28 -34
- package/utils/RawQueryFragment.js +35 -71
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/TransactionManager.js +28 -4
- package/utils/Utils.d.ts +14 -127
- package/utils/Utils.js +85 -397
- package/utils/clone.js +8 -23
- package/utils/env-vars.d.ts +7 -0
- package/utils/env-vars.js +97 -0
- package/utils/fs-utils.d.ts +33 -0
- package/utils/fs-utils.js +192 -0
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -1
- package/utils/upsert-utils.d.ts +9 -4
- package/utils/upsert-utils.js +46 -3
- package/decorators/Check.d.ts +0 -3
- package/decorators/Check.js +0 -13
- package/decorators/CreateRequestContext.d.ts +0 -3
- package/decorators/CreateRequestContext.js +0 -32
- package/decorators/Embeddable.d.ts +0 -8
- package/decorators/Embeddable.js +0 -11
- package/decorators/Embedded.d.ts +0 -12
- package/decorators/Embedded.js +0 -18
- package/decorators/Entity.d.ts +0 -33
- package/decorators/Entity.js +0 -12
- package/decorators/Enum.d.ts +0 -9
- package/decorators/Enum.js +0 -16
- package/decorators/Filter.d.ts +0 -2
- package/decorators/Filter.js +0 -8
- package/decorators/Formula.d.ts +0 -4
- package/decorators/Formula.js +0 -15
- package/decorators/Indexed.d.ts +0 -19
- package/decorators/Indexed.js +0 -20
- package/decorators/ManyToMany.d.ts +0 -42
- package/decorators/ManyToMany.js +0 -14
- package/decorators/ManyToOne.d.ts +0 -34
- package/decorators/ManyToOne.js +0 -14
- package/decorators/OneToMany.d.ts +0 -28
- package/decorators/OneToMany.js +0 -17
- package/decorators/OneToOne.d.ts +0 -28
- package/decorators/OneToOne.js +0 -7
- package/decorators/PrimaryKey.d.ts +0 -8
- package/decorators/PrimaryKey.js +0 -20
- package/decorators/Property.d.ts +0 -250
- package/decorators/Property.js +0 -32
- package/decorators/Transactional.d.ts +0 -14
- package/decorators/Transactional.js +0 -28
- package/decorators/hooks.d.ts +0 -16
- package/decorators/hooks.js +0 -47
- package/decorators/index.d.ts +0 -17
- package/decorators/index.js +0 -17
- package/entity/ArrayCollection.d.ts +0 -118
- package/entity/ArrayCollection.js +0 -407
- package/entity/EntityValidator.d.ts +0 -19
- package/entity/EntityValidator.js +0 -150
- package/metadata/ReflectMetadataProvider.d.ts +0 -8
- package/metadata/ReflectMetadataProvider.js +0 -44
- package/utils/resolveContextProvider.d.ts +0 -10
- package/utils/resolveContextProvider.js +0 -28
|
@@ -15,7 +15,7 @@ export class AbstractSchemaGenerator {
|
|
|
15
15
|
this.platform = this.driver.getPlatform();
|
|
16
16
|
this.connection = this.driver.getConnection();
|
|
17
17
|
}
|
|
18
|
-
async
|
|
18
|
+
async create(options) {
|
|
19
19
|
this.notImplemented();
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
@@ -24,7 +24,7 @@ export class AbstractSchemaGenerator {
|
|
|
24
24
|
async ensureDatabase(options) {
|
|
25
25
|
this.notImplemented();
|
|
26
26
|
}
|
|
27
|
-
async
|
|
27
|
+
async refresh(options) {
|
|
28
28
|
if (options?.dropDb) {
|
|
29
29
|
const name = this.config.get('dbName');
|
|
30
30
|
await this.dropDatabase(name);
|
|
@@ -32,20 +32,22 @@ export class AbstractSchemaGenerator {
|
|
|
32
32
|
}
|
|
33
33
|
else {
|
|
34
34
|
await this.ensureDatabase();
|
|
35
|
-
await this.
|
|
35
|
+
await this.drop(options);
|
|
36
36
|
}
|
|
37
37
|
if (options?.createSchema !== false) {
|
|
38
|
-
await this.
|
|
38
|
+
await this.create(options);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
async
|
|
41
|
+
async clear(options) {
|
|
42
42
|
for (const meta of this.getOrderedMetadata(options?.schema).reverse()) {
|
|
43
|
-
await this.driver.nativeDelete(meta.
|
|
43
|
+
await this.driver.nativeDelete(meta.class, {}, options);
|
|
44
|
+
}
|
|
45
|
+
if (options?.clearIdentityMap ?? true) {
|
|
46
|
+
this.clearIdentityMap();
|
|
44
47
|
}
|
|
45
|
-
this.clearIdentityMap();
|
|
46
48
|
}
|
|
47
49
|
clearIdentityMap() {
|
|
48
|
-
/* v8 ignore next
|
|
50
|
+
/* v8 ignore next */
|
|
49
51
|
if (!this.em) {
|
|
50
52
|
return;
|
|
51
53
|
}
|
|
@@ -57,13 +59,13 @@ export class AbstractSchemaGenerator {
|
|
|
57
59
|
async getCreateSchemaSQL(options) {
|
|
58
60
|
this.notImplemented();
|
|
59
61
|
}
|
|
60
|
-
async
|
|
62
|
+
async drop(options) {
|
|
61
63
|
this.notImplemented();
|
|
62
64
|
}
|
|
63
65
|
async getDropSchemaSQL(options) {
|
|
64
66
|
this.notImplemented();
|
|
65
67
|
}
|
|
66
|
-
async
|
|
68
|
+
async update(options) {
|
|
67
69
|
this.notImplemented();
|
|
68
70
|
}
|
|
69
71
|
async getUpdateSchemaSQL(options) {
|
|
@@ -88,21 +90,30 @@ export class AbstractSchemaGenerator {
|
|
|
88
90
|
this.notImplemented();
|
|
89
91
|
}
|
|
90
92
|
getOrderedMetadata(schema) {
|
|
91
|
-
const metadata =
|
|
92
|
-
const isRootEntity = meta.root.
|
|
93
|
-
|
|
93
|
+
const metadata = [...this.metadata.getAll().values()].filter(meta => {
|
|
94
|
+
const isRootEntity = meta.root.class === meta.class;
|
|
95
|
+
const isTPTChild = meta.inheritanceType === 'tpt' && meta.tptParent;
|
|
96
|
+
return (isRootEntity || isTPTChild) && !meta.embeddable && !meta.virtual;
|
|
94
97
|
});
|
|
95
98
|
const calc = new CommitOrderCalculator();
|
|
96
|
-
metadata.forEach(meta =>
|
|
99
|
+
metadata.forEach(meta => {
|
|
100
|
+
const nodeId = meta.inheritanceType === 'tpt' && meta.tptParent ? meta._id : meta.root._id;
|
|
101
|
+
calc.addNode(nodeId);
|
|
102
|
+
});
|
|
97
103
|
let meta = metadata.pop();
|
|
98
104
|
while (meta) {
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
const nodeId = meta.inheritanceType === 'tpt' && meta.tptParent ? meta._id : meta.root._id;
|
|
106
|
+
for (const prop of meta.relations) {
|
|
107
|
+
calc.discoverProperty(prop, nodeId);
|
|
108
|
+
}
|
|
109
|
+
if (meta.inheritanceType === 'tpt' && meta.tptParent) {
|
|
110
|
+
const parentId = meta.tptParent._id;
|
|
111
|
+
calc.addDependency(parentId, nodeId, 1);
|
|
101
112
|
}
|
|
102
113
|
meta = metadata.pop();
|
|
103
114
|
}
|
|
104
115
|
return calc.sort()
|
|
105
|
-
.map(cls => this.metadata.
|
|
116
|
+
.map(cls => this.metadata.getById(cls))
|
|
106
117
|
.filter(meta => {
|
|
107
118
|
const targetSchema = meta.schema ?? this.config.get('schema', this.platform.getDefaultSchemaName());
|
|
108
119
|
return schema ? [schema, '*'].includes(targetSchema) : meta.schema !== '*';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
function getNodeAsyncContext() {
|
|
2
|
+
const mod = globalThis.process?.getBuiltinModule?.('node:async_hooks');
|
|
3
|
+
/* v8 ignore next */
|
|
4
|
+
if (!mod?.AsyncLocalStorage) {
|
|
5
|
+
throw new Error('AsyncLocalStorage not available');
|
|
6
|
+
}
|
|
7
|
+
return new mod.AsyncLocalStorage();
|
|
8
|
+
}
|
|
9
|
+
/* v8 ignore next */
|
|
10
|
+
function createFallbackAsyncContext() {
|
|
11
|
+
let store;
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.warn('AsyncLocalStorage not available');
|
|
14
|
+
return {
|
|
15
|
+
getStore: () => store,
|
|
16
|
+
enterWith: value => store = value,
|
|
17
|
+
run: (value, cb) => {
|
|
18
|
+
const prev = store;
|
|
19
|
+
store = value;
|
|
20
|
+
try {
|
|
21
|
+
return cb();
|
|
22
|
+
}
|
|
23
|
+
finally {
|
|
24
|
+
store = prev;
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export function createAsyncContext() {
|
|
30
|
+
/* v8 ignore next */
|
|
31
|
+
const ALS = globalThis.AsyncLocalStorage;
|
|
32
|
+
/* v8 ignore next */
|
|
33
|
+
if (typeof ALS === 'function' && ALS.prototype?.run) {
|
|
34
|
+
return new ALS();
|
|
35
|
+
}
|
|
36
|
+
/* v8 ignore else */
|
|
37
|
+
if (globalThis.process?.versions?.node) {
|
|
38
|
+
return getNodeAsyncContext();
|
|
39
|
+
}
|
|
40
|
+
/* v8 ignore next */
|
|
41
|
+
return createFallbackAsyncContext();
|
|
42
|
+
}
|