@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.11
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 +25 -16
- package/EntityManager.js +219 -209
- 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 +2 -2
- package/decorators/Check.js +5 -8
- package/decorators/CreateRequestContext.d.ts +1 -1
- package/decorators/CreateRequestContext.js +13 -14
- package/decorators/Embeddable.d.ts +5 -5
- package/decorators/Embeddable.js +4 -7
- package/decorators/Embedded.d.ts +3 -3
- package/decorators/Embedded.js +10 -12
- package/decorators/Entity.d.ts +6 -6
- package/decorators/Entity.js +5 -9
- package/decorators/Enum.d.ts +3 -3
- 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 -3
- package/decorators/Formula.js +7 -10
- package/decorators/Indexed.d.ts +10 -8
- package/decorators/Indexed.js +7 -11
- package/decorators/ManyToMany.d.ts +4 -4
- package/decorators/ManyToMany.js +10 -12
- package/decorators/ManyToOne.d.ts +4 -4
- package/decorators/ManyToOne.js +10 -12
- package/decorators/OneToMany.d.ts +6 -6
- package/decorators/OneToMany.js +11 -14
- package/decorators/OneToOne.d.ts +4 -4
- package/decorators/OneToOne.js +4 -7
- package/decorators/PrimaryKey.d.ts +3 -4
- package/decorators/PrimaryKey.js +10 -13
- package/decorators/Property.d.ts +6 -6
- 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 +16 -13
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/ArrayCollection.d.ts +3 -3
- package/entity/ArrayCollection.js +38 -35
- package/entity/BaseEntity.d.ts +6 -6
- package/entity/BaseEntity.js +17 -21
- package/entity/Collection.d.ts +6 -7
- package/entity/Collection.js +47 -51
- package/entity/EntityAssigner.d.ts +2 -2
- package/entity/EntityAssigner.js +58 -63
- package/entity/EntityFactory.d.ts +3 -3
- package/entity/EntityFactory.js +62 -63
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +44 -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 +106 -98
- 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 +4 -8
- 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 +8 -5
- 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 +26 -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 +14 -6
- package/metadata/EntitySchema.js +41 -45
- package/metadata/MetadataDiscovery.d.ts +7 -7
- package/metadata/MetadataDiscovery.js +181 -180
- 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 +52 -55
- 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 +6 -15
- 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 +4 -3
- package/types/BigIntType.js +6 -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 +33 -28
- package/typings.js +37 -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 +51 -48
- 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 +193 -178
- 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 +12 -13
- 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 +6 -6
- 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 +109 -97
- 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 +22 -25
- 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 +96 -95
- 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/utils/Utils.js
CHANGED
|
@@ -1,27 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const node_module_1 = require("node:module");
|
|
14
|
-
const globby_1 = __importDefault(require("globby"));
|
|
15
|
-
const node_path_1 = require("node:path");
|
|
16
|
-
const node_os_1 = require("node:os");
|
|
17
|
-
const node_url_1 = require("node:url");
|
|
18
|
-
const fs_extra_1 = require("fs-extra");
|
|
19
|
-
const node_crypto_1 = require("node:crypto");
|
|
20
|
-
const esprima_1 = require("esprima");
|
|
21
|
-
const clone_1 = require("./clone");
|
|
22
|
-
const enums_1 = require("../enums");
|
|
23
|
-
const wrap_1 = require("../entity/wrap");
|
|
24
|
-
exports.ObjectBindingPattern = Symbol('ObjectBindingPattern');
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
import globby from 'globby';
|
|
3
|
+
import { extname, isAbsolute, join, normalize, relative, resolve } from 'node:path';
|
|
4
|
+
import { platform } from 'node:os';
|
|
5
|
+
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
6
|
+
import { existsSync, mkdirSync, readFileSync } from 'node:fs';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
8
|
+
import { tokenize } from 'esprima';
|
|
9
|
+
import { clone } from './clone.js';
|
|
10
|
+
import { ARRAY_OPERATORS, JSON_KEY_OPERATORS, GroupOperator, PlainObject, QueryOperator, ReferenceKind } from '../enums.js';
|
|
11
|
+
import { helper } from '../entity/wrap.js';
|
|
12
|
+
export const ObjectBindingPattern = Symbol('ObjectBindingPattern');
|
|
25
13
|
function compareConstructors(a, b) {
|
|
26
14
|
if (a.constructor === b.constructor) {
|
|
27
15
|
return true;
|
|
@@ -34,10 +22,7 @@ function compareConstructors(a, b) {
|
|
|
34
22
|
}
|
|
35
23
|
return false;
|
|
36
24
|
}
|
|
37
|
-
function
|
|
38
|
-
return typeof value === 'object' && !!value && '__raw' in value;
|
|
39
|
-
}
|
|
40
|
-
function compareObjects(a, b) {
|
|
25
|
+
export function compareObjects(a, b) {
|
|
41
26
|
if (a === b || (a == null && b == null)) {
|
|
42
27
|
return true;
|
|
43
28
|
}
|
|
@@ -56,6 +41,7 @@ function compareObjects(a, b) {
|
|
|
56
41
|
}
|
|
57
42
|
return timeA === timeB;
|
|
58
43
|
}
|
|
44
|
+
/* v8 ignore next 9 */
|
|
59
45
|
if ((typeof a === 'function' && typeof b === 'function') ||
|
|
60
46
|
(typeof a === 'object' && a.client && ['Ref', 'Raw'].includes(a.constructor.name) && typeof b === 'object' && b.client && ['Ref', 'Raw'].includes(b.constructor.name)) || // knex qb
|
|
61
47
|
(a instanceof RegExp && b instanceof RegExp) ||
|
|
@@ -82,7 +68,7 @@ function compareObjects(a, b) {
|
|
|
82
68
|
}
|
|
83
69
|
return true;
|
|
84
70
|
}
|
|
85
|
-
function compareArrays(a, b) {
|
|
71
|
+
export function compareArrays(a, b) {
|
|
86
72
|
const length = a.length;
|
|
87
73
|
if (length !== b.length) {
|
|
88
74
|
return false;
|
|
@@ -95,12 +81,12 @@ function compareArrays(a, b) {
|
|
|
95
81
|
}
|
|
96
82
|
return true;
|
|
97
83
|
}
|
|
98
|
-
function compareBooleans(a, b) {
|
|
84
|
+
export function compareBooleans(a, b) {
|
|
99
85
|
a = typeof a === 'number' ? Boolean(a) : a;
|
|
100
86
|
b = typeof b === 'number' ? Boolean(b) : b;
|
|
101
87
|
return a === b;
|
|
102
88
|
}
|
|
103
|
-
function compareBuffers(a, b) {
|
|
89
|
+
export function compareBuffers(a, b) {
|
|
104
90
|
const length = a.length;
|
|
105
91
|
if (length !== b.length) {
|
|
106
92
|
return false;
|
|
@@ -115,7 +101,7 @@ function compareBuffers(a, b) {
|
|
|
115
101
|
/**
|
|
116
102
|
* Checks if arguments are deeply (but not strictly) equal.
|
|
117
103
|
*/
|
|
118
|
-
function equals(a, b) {
|
|
104
|
+
export function equals(a, b) {
|
|
119
105
|
if (a === b) {
|
|
120
106
|
return true;
|
|
121
107
|
}
|
|
@@ -131,8 +117,9 @@ function equals(a, b) {
|
|
|
131
117
|
return Number.isNaN(a) && Number.isNaN(b);
|
|
132
118
|
}
|
|
133
119
|
const equalsFn = equals;
|
|
134
|
-
function parseJsonSafe(value) {
|
|
120
|
+
export function parseJsonSafe(value) {
|
|
135
121
|
if (typeof value === 'string') {
|
|
122
|
+
/* v8 ignore next 6 */
|
|
136
123
|
try {
|
|
137
124
|
return JSON.parse(value);
|
|
138
125
|
}
|
|
@@ -143,9 +130,9 @@ function parseJsonSafe(value) {
|
|
|
143
130
|
}
|
|
144
131
|
return value;
|
|
145
132
|
}
|
|
146
|
-
class Utils {
|
|
133
|
+
export class Utils {
|
|
147
134
|
static PK_SEPARATOR = '~~~';
|
|
148
|
-
/*
|
|
135
|
+
/* v8 ignore next */
|
|
149
136
|
static dynamicImportProvider = (id) => import(id);
|
|
150
137
|
/**
|
|
151
138
|
* Checks if the argument is not undefined
|
|
@@ -220,7 +207,6 @@ class Utils {
|
|
|
220
207
|
static getObjectKeysSize(object) {
|
|
221
208
|
let size = 0;
|
|
222
209
|
for (const key in object) {
|
|
223
|
-
/* istanbul ignore else */
|
|
224
210
|
if (Object.hasOwn(object, key)) {
|
|
225
211
|
size++;
|
|
226
212
|
}
|
|
@@ -233,7 +219,6 @@ class Utils {
|
|
|
233
219
|
*/
|
|
234
220
|
static hasObjectKeys(object) {
|
|
235
221
|
for (const key in object) {
|
|
236
|
-
/* istanbul ignore else */
|
|
237
222
|
if (Object.hasOwn(object, key)) {
|
|
238
223
|
return true;
|
|
239
224
|
}
|
|
@@ -297,7 +282,7 @@ class Utils {
|
|
|
297
282
|
target[key] = Utils.copy(value);
|
|
298
283
|
continue;
|
|
299
284
|
}
|
|
300
|
-
/*
|
|
285
|
+
/* v8 ignore next 3 */
|
|
301
286
|
if (!(key in target)) {
|
|
302
287
|
Object.assign(target, { [key]: {} });
|
|
303
288
|
}
|
|
@@ -338,7 +323,7 @@ class Utils {
|
|
|
338
323
|
* Creates deep copy of given object.
|
|
339
324
|
*/
|
|
340
325
|
static copy(entity, respectCustomCloneMethod = true) {
|
|
341
|
-
return
|
|
326
|
+
return clone(entity, respectCustomCloneMethod);
|
|
342
327
|
}
|
|
343
328
|
/**
|
|
344
329
|
* Normalize the argument to always be an array.
|
|
@@ -380,11 +365,11 @@ class Utils {
|
|
|
380
365
|
if (Array.isArray(func)) {
|
|
381
366
|
return func;
|
|
382
367
|
}
|
|
368
|
+
/* v8 ignore next 5 */
|
|
383
369
|
try {
|
|
384
|
-
return
|
|
370
|
+
return tokenize(func.toString(), { tolerant: true });
|
|
385
371
|
}
|
|
386
372
|
catch {
|
|
387
|
-
/* istanbul ignore next */
|
|
388
373
|
return [];
|
|
389
374
|
}
|
|
390
375
|
}
|
|
@@ -412,7 +397,7 @@ class Utils {
|
|
|
412
397
|
break;
|
|
413
398
|
}
|
|
414
399
|
if (inside === 2 && token.type === 'Punctuator' && token.value === '{' && i === currentBlockStart + 1) {
|
|
415
|
-
ret.push(
|
|
400
|
+
ret.push(ObjectBindingPattern);
|
|
416
401
|
i = tokens.findIndex((t, idx) => idx > i + 2 && t.type === 'Punctuator' && t.value === '}');
|
|
417
402
|
continue;
|
|
418
403
|
}
|
|
@@ -450,7 +435,7 @@ class Utils {
|
|
|
450
435
|
return data;
|
|
451
436
|
}
|
|
452
437
|
if (Utils.isEntity(data, true)) {
|
|
453
|
-
return
|
|
438
|
+
return helper(data).getPrimaryKey();
|
|
454
439
|
}
|
|
455
440
|
if (strict && meta && Utils.getObjectKeysSize(data) !== meta.primaryKeys.length) {
|
|
456
441
|
return null;
|
|
@@ -499,7 +484,7 @@ class Utils {
|
|
|
499
484
|
return key.split(this.PK_SEPARATOR);
|
|
500
485
|
}
|
|
501
486
|
static getPrimaryKeyValues(entity, primaryKeys, allowScalar = false, convertCustomTypes = false) {
|
|
502
|
-
/*
|
|
487
|
+
/* v8 ignore next 3 */
|
|
503
488
|
if (entity == null) {
|
|
504
489
|
return entity;
|
|
505
490
|
}
|
|
@@ -510,7 +495,7 @@ class Utils {
|
|
|
510
495
|
return val;
|
|
511
496
|
}
|
|
512
497
|
const pk = Utils.isEntity(entity, true)
|
|
513
|
-
?
|
|
498
|
+
? helper(entity).getPrimaryKey(convertCustomTypes)
|
|
514
499
|
: primaryKeys.reduce((o, pk) => { o[pk] = entity[pk]; return o; }, {});
|
|
515
500
|
if (primaryKeys.length > 1) {
|
|
516
501
|
return toArray(pk);
|
|
@@ -570,7 +555,7 @@ class Utils {
|
|
|
570
555
|
if (convertCustomTypes && platform && prop.customType && !prop.targetMeta) {
|
|
571
556
|
value = prop.customType.convertToJSValue(value, platform);
|
|
572
557
|
}
|
|
573
|
-
if (prop.kind !==
|
|
558
|
+
if (prop.kind !== ReferenceKind.SCALAR && prop.targetMeta) {
|
|
574
559
|
const value2 = this.getOrderedPrimaryKeys(value, prop.targetMeta, platform, convertCustomTypes);
|
|
575
560
|
value = value2.length > 1 ? value2 : value2[0];
|
|
576
561
|
}
|
|
@@ -631,19 +616,21 @@ class Utils {
|
|
|
631
616
|
.map(field => field === allSymbol ? allSymbol : field.substring(prefix.length + 1));
|
|
632
617
|
}
|
|
633
618
|
/**
|
|
634
|
-
* Tries to detect
|
|
619
|
+
* Tries to detect TypeScript support.
|
|
635
620
|
*/
|
|
636
|
-
static
|
|
637
|
-
/*
|
|
621
|
+
static detectTypeScriptSupport() {
|
|
622
|
+
/* v8 ignore next 7 */
|
|
638
623
|
return process.argv[0].endsWith('ts-node') // running via ts-node directly
|
|
639
|
-
//
|
|
640
|
-
|| !!process[Symbol.for('ts-node.register.instance')] // check if internal ts-node symbol exists
|
|
624
|
+
|| !!process.env.MIKRO_ORM_CLI_ALWAYS_ALLOW_TS // forced explicitly or enabled via `registerTypeScriptSupport()`
|
|
641
625
|
|| !!process.env.TS_JEST // check if ts-jest is used (works only with v27.0.4+)
|
|
642
626
|
|| !!process.env.VITEST // check if vitest is used
|
|
643
627
|
|| !!process.versions.bun // check if bun is used
|
|
644
|
-
|| process.argv.slice(1).some(arg => arg.
|
|
645
|
-
|| process.execArgv.some(arg =>
|
|
646
|
-
|
|
628
|
+
|| process.argv.slice(1).some(arg => arg.match(/\.([mc]?ts|tsx)$/)) // executing `.ts` file
|
|
629
|
+
|| process.execArgv.some(arg => {
|
|
630
|
+
return arg.includes('ts-node') // check for ts-node loader
|
|
631
|
+
|| arg.includes('@swc-node/register') // check for swc-node/register loader
|
|
632
|
+
|| arg.includes('node_modules/tsx/'); // check for tsx loader
|
|
633
|
+
});
|
|
647
634
|
}
|
|
648
635
|
/**
|
|
649
636
|
* Uses some dark magic to get source path to caller where decorator is used.
|
|
@@ -661,7 +648,8 @@ class Utils {
|
|
|
661
648
|
// but those are also present in node, so we need to check this only if they weren't found.
|
|
662
649
|
if (line === -1) {
|
|
663
650
|
// here we handle bun which stack is different from nodejs so we search for reflect-metadata
|
|
664
|
-
|
|
651
|
+
// Different bun versions might have different stack traces. The "last index" works for both 1.2.6 and 1.2.7.
|
|
652
|
+
const reflectLine = stack.findLastIndex(line => Utils.normalizePath(line).includes('node_modules/reflect-metadata/Reflect.js'));
|
|
665
653
|
if (reflectLine === -1 || reflectLine + 2 >= stack.length || !stack[reflectLine + 1].includes('bun:wrap')) {
|
|
666
654
|
return name;
|
|
667
655
|
}
|
|
@@ -705,7 +693,7 @@ class Utils {
|
|
|
705
693
|
&& typeof value.constructor === 'function'
|
|
706
694
|
&& (Object.hasOwn(value.constructor.prototype, 'isPrototypeOf') || Object.getPrototypeOf(value.constructor.prototype) === null))
|
|
707
695
|
|| (value && Object.getPrototypeOf(value) === null)
|
|
708
|
-
|| value instanceof
|
|
696
|
+
|| value instanceof PlainObject;
|
|
709
697
|
}
|
|
710
698
|
/**
|
|
711
699
|
* Executes the `cb` promise serially on every element of the `items` array and returns array of resolved values.
|
|
@@ -722,7 +710,7 @@ class Utils {
|
|
|
722
710
|
}
|
|
723
711
|
static fileURLToPath(url) {
|
|
724
712
|
// expose `fileURLToPath` on Utils so that it can be properly mocked in tests
|
|
725
|
-
return
|
|
713
|
+
return fileURLToPath(url);
|
|
726
714
|
}
|
|
727
715
|
/**
|
|
728
716
|
* Resolves and normalizes a series of path parts relative to each preceding part.
|
|
@@ -735,7 +723,7 @@ class Utils {
|
|
|
735
723
|
let start = 0;
|
|
736
724
|
for (let i = 0; i < parts.length; i++) {
|
|
737
725
|
const part = parts[i];
|
|
738
|
-
if (
|
|
726
|
+
if (isAbsolute(part)) {
|
|
739
727
|
start = i;
|
|
740
728
|
}
|
|
741
729
|
else if (part.startsWith('file:')) {
|
|
@@ -747,7 +735,7 @@ class Utils {
|
|
|
747
735
|
parts = parts.slice(start);
|
|
748
736
|
}
|
|
749
737
|
let path = parts.join('/').replace(/\\/g, '/').replace(/\/$/, '');
|
|
750
|
-
path =
|
|
738
|
+
path = normalize(path).replace(/\\/g, '/');
|
|
751
739
|
return (path.match(/^[/.]|[a-zA-Z]:/) || path.startsWith('!')) ? path : './' + path;
|
|
752
740
|
}
|
|
753
741
|
/**
|
|
@@ -762,7 +750,7 @@ class Utils {
|
|
|
762
750
|
if (path.startsWith('.')) {
|
|
763
751
|
return path;
|
|
764
752
|
}
|
|
765
|
-
path =
|
|
753
|
+
path = relative(Utils.normalizePath(relativeTo), path);
|
|
766
754
|
return Utils.normalizePath(path);
|
|
767
755
|
}
|
|
768
756
|
/**
|
|
@@ -773,13 +761,13 @@ class Utils {
|
|
|
773
761
|
if (!path) {
|
|
774
762
|
return Utils.normalizePath(baseDir);
|
|
775
763
|
}
|
|
776
|
-
if (!
|
|
764
|
+
if (!isAbsolute(path) && !path.startsWith('file://')) {
|
|
777
765
|
path = baseDir + '/' + path;
|
|
778
766
|
}
|
|
779
767
|
return Utils.normalizePath(path);
|
|
780
768
|
}
|
|
781
769
|
static hash(data, length) {
|
|
782
|
-
const hash =
|
|
770
|
+
const hash = createHash('md5').update(data).digest('hex');
|
|
783
771
|
if (length) {
|
|
784
772
|
return hash.substring(0, length);
|
|
785
773
|
}
|
|
@@ -812,11 +800,11 @@ class Utils {
|
|
|
812
800
|
return Math.round(Math.random() * (max - min)) + min;
|
|
813
801
|
}
|
|
814
802
|
static async pathExists(path, options = {}) {
|
|
815
|
-
if (
|
|
816
|
-
const found = await (
|
|
803
|
+
if (globby.hasMagic(path)) {
|
|
804
|
+
const found = await globby(path, options);
|
|
817
805
|
return found.length > 0;
|
|
818
806
|
}
|
|
819
|
-
return
|
|
807
|
+
return this.pathExistsSync(path);
|
|
820
808
|
}
|
|
821
809
|
/**
|
|
822
810
|
* Extracts all possible values of a TS enum. Works with both string and numeric enums.
|
|
@@ -839,18 +827,18 @@ class Utils {
|
|
|
839
827
|
}
|
|
840
828
|
static isOperator(key, includeGroupOperators = true) {
|
|
841
829
|
if (!includeGroupOperators) {
|
|
842
|
-
return key in
|
|
830
|
+
return key in QueryOperator;
|
|
843
831
|
}
|
|
844
|
-
return key in
|
|
832
|
+
return key in GroupOperator || key in QueryOperator;
|
|
845
833
|
}
|
|
846
834
|
static isGroupOperator(key) {
|
|
847
|
-
return key in
|
|
835
|
+
return key in GroupOperator;
|
|
848
836
|
}
|
|
849
837
|
static isArrayOperator(key) {
|
|
850
|
-
return
|
|
838
|
+
return ARRAY_OPERATORS.includes(key);
|
|
851
839
|
}
|
|
852
840
|
static isJsonKeyOperator(key) {
|
|
853
|
-
return
|
|
841
|
+
return JSON_KEY_OPERATORS.includes(key);
|
|
854
842
|
}
|
|
855
843
|
static hasNestedKey(object, key) {
|
|
856
844
|
if (!object) {
|
|
@@ -875,49 +863,55 @@ class Utils {
|
|
|
875
863
|
* @param [from] Location to start the node resolution
|
|
876
864
|
*/
|
|
877
865
|
static requireFrom(id, from = process.cwd()) {
|
|
878
|
-
if (!
|
|
879
|
-
from =
|
|
866
|
+
if (!extname(from)) {
|
|
867
|
+
from = join(from, '__fake.js');
|
|
880
868
|
}
|
|
881
|
-
return
|
|
869
|
+
return createRequire(resolve(from))(id);
|
|
882
870
|
}
|
|
883
871
|
static async dynamicImport(id) {
|
|
884
|
-
/*
|
|
885
|
-
if (
|
|
872
|
+
/* v8 ignore next 7 */
|
|
873
|
+
if (platform() === 'win32') {
|
|
886
874
|
try {
|
|
887
|
-
id =
|
|
875
|
+
id = pathToFileURL(id).toString();
|
|
888
876
|
}
|
|
889
877
|
catch {
|
|
890
878
|
// ignore
|
|
891
879
|
}
|
|
892
|
-
// If the extension is not registered, we need to fall back to a file path.
|
|
893
|
-
if (require.extensions && !require.extensions[(0, node_path_1.extname)(id)]) {
|
|
894
|
-
id = (0, node_url_1.fileURLToPath)(id);
|
|
895
|
-
}
|
|
896
880
|
}
|
|
897
|
-
/*
|
|
881
|
+
/* v8 ignore next */
|
|
898
882
|
return this.dynamicImportProvider(id);
|
|
899
883
|
}
|
|
900
|
-
/*
|
|
884
|
+
/* v8 ignore next 3 */
|
|
901
885
|
static setDynamicImportProvider(provider) {
|
|
902
886
|
this.dynamicImportProvider = provider;
|
|
903
887
|
}
|
|
888
|
+
static ensureDir(path) {
|
|
889
|
+
if (!existsSync(path)) {
|
|
890
|
+
mkdirSync(path, { recursive: true });
|
|
891
|
+
}
|
|
892
|
+
}
|
|
893
|
+
static pathExistsSync(path) {
|
|
894
|
+
return existsSync(path);
|
|
895
|
+
}
|
|
896
|
+
static readJSONSync(path) {
|
|
897
|
+
const file = readFileSync(path);
|
|
898
|
+
return JSON.parse(file.toString());
|
|
899
|
+
}
|
|
904
900
|
static getORMVersion() {
|
|
905
|
-
/* istanbul ignore next */
|
|
906
901
|
try {
|
|
907
|
-
// this works
|
|
908
|
-
|
|
909
|
-
|
|
902
|
+
// this works during development where we have `src` folder
|
|
903
|
+
return this.requireFrom('../../package.json', import.meta.dirname).version;
|
|
904
|
+
/* v8 ignore next 5 */
|
|
910
905
|
}
|
|
911
906
|
catch {
|
|
912
|
-
// this works
|
|
913
|
-
|
|
914
|
-
return require('../package.json').version;
|
|
907
|
+
// this works in production build where we do not have the `src` folder
|
|
908
|
+
return this.requireFrom('../package.json', import.meta.dirname).version;
|
|
915
909
|
}
|
|
916
910
|
}
|
|
917
|
-
/* istanbul ignore next */
|
|
918
911
|
static createFunction(context, code) {
|
|
919
912
|
try {
|
|
920
913
|
return new Function(...context.keys(), `'use strict';\n` + code)(...context.values());
|
|
914
|
+
/* v8 ignore next 5 */
|
|
921
915
|
}
|
|
922
916
|
catch (e) {
|
|
923
917
|
// eslint-disable-next-line no-console
|
|
@@ -925,12 +919,12 @@ class Utils {
|
|
|
925
919
|
throw e;
|
|
926
920
|
}
|
|
927
921
|
}
|
|
928
|
-
/* istanbul ignore next */
|
|
929
922
|
static callCompiledFunction(fn, ...args) {
|
|
930
923
|
try {
|
|
931
924
|
return fn(...args);
|
|
932
925
|
}
|
|
933
926
|
catch (e) {
|
|
927
|
+
/* v8 ignore start */
|
|
934
928
|
if ([SyntaxError, TypeError, EvalError, ReferenceError].some(t => e instanceof t)) {
|
|
935
929
|
const position = e.stack.match(/<anonymous>:(\d+):(\d+)/);
|
|
936
930
|
let code = fn.toString();
|
|
@@ -947,6 +941,7 @@ class Utils {
|
|
|
947
941
|
// eslint-disable-next-line no-console
|
|
948
942
|
console.error(`JIT runtime error: ${e.message}\n\n${code}`);
|
|
949
943
|
}
|
|
944
|
+
/* v8 ignore stop */
|
|
950
945
|
throw e;
|
|
951
946
|
}
|
|
952
947
|
}
|
|
@@ -1052,6 +1047,16 @@ class Utils {
|
|
|
1052
1047
|
throw err;
|
|
1053
1048
|
}
|
|
1054
1049
|
}
|
|
1050
|
+
static async tryImport({ module, warning }) {
|
|
1051
|
+
try {
|
|
1052
|
+
return await this.dynamicImport(module);
|
|
1053
|
+
}
|
|
1054
|
+
catch (err) {
|
|
1055
|
+
// eslint-disable-next-line no-console
|
|
1056
|
+
console.warn(warning);
|
|
1057
|
+
return undefined;
|
|
1058
|
+
}
|
|
1059
|
+
}
|
|
1055
1060
|
static stripRelativePath(str) {
|
|
1056
1061
|
return str.replace(/^(?:\.\.\/|\.\/)+/, '/');
|
|
1057
1062
|
}
|
|
@@ -1087,9 +1092,6 @@ class Utils {
|
|
|
1087
1092
|
static entries(obj) {
|
|
1088
1093
|
return Object.entries(obj);
|
|
1089
1094
|
}
|
|
1090
|
-
static isRawSql(value) {
|
|
1091
|
-
return isRawSql(value);
|
|
1092
|
-
}
|
|
1093
1095
|
static primaryKeyToObject(meta, primaryKey, visible) {
|
|
1094
1096
|
const pks = meta.compositePK && Utils.isPlainObject(primaryKey) ? Object.values(primaryKey) : Utils.asArray(primaryKey);
|
|
1095
1097
|
const pkProps = meta.getPrimaryProps();
|
|
@@ -1107,4 +1109,3 @@ class Utils {
|
|
|
1107
1109
|
}, {});
|
|
1108
1110
|
}
|
|
1109
1111
|
}
|
|
1110
|
-
exports.Utils = Utils;
|
package/utils/clone.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Inspired by https://github.com/pvorb/clone but simplified and never tries to
|
|
4
3
|
* clone `EventEmitter`s to get around https://github.com/mikro-orm/mikro-orm/issues/2748
|
|
5
4
|
* @internal
|
|
6
5
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const node_events_1 = require("node:events");
|
|
10
|
-
const RawQueryFragment_1 = require("./RawQueryFragment");
|
|
6
|
+
import { EventEmitter } from 'node:events';
|
|
7
|
+
import { RawQueryFragment } from './RawQueryFragment.js';
|
|
11
8
|
/**
|
|
12
9
|
* Get the property descriptor of a property on an object or its prototype chain.
|
|
13
10
|
*
|
|
@@ -25,7 +22,7 @@ function getPropertyDescriptor(obj, prop) {
|
|
|
25
22
|
}
|
|
26
23
|
return null;
|
|
27
24
|
}
|
|
28
|
-
function clone(parent, respectCustomCloneMethod = true) {
|
|
25
|
+
export function clone(parent, respectCustomCloneMethod = true) {
|
|
29
26
|
const allParents = [];
|
|
30
27
|
const allChildren = [];
|
|
31
28
|
function _clone(parent) {
|
|
@@ -33,11 +30,11 @@ function clone(parent, respectCustomCloneMethod = true) {
|
|
|
33
30
|
if (parent === null) {
|
|
34
31
|
return null;
|
|
35
32
|
}
|
|
36
|
-
const raw =
|
|
33
|
+
const raw = RawQueryFragment.getKnownFragment(parent, false);
|
|
37
34
|
if (raw && respectCustomCloneMethod) {
|
|
38
35
|
return raw.clone();
|
|
39
36
|
}
|
|
40
|
-
if (typeof parent !== 'object' || parent instanceof
|
|
37
|
+
if (typeof parent !== 'object' || parent instanceof EventEmitter) {
|
|
41
38
|
return parent;
|
|
42
39
|
}
|
|
43
40
|
if (respectCustomCloneMethod && 'clone' in parent && typeof parent.clone === 'function') {
|
|
@@ -84,7 +81,7 @@ function clone(parent, respectCustomCloneMethod = true) {
|
|
|
84
81
|
return child;
|
|
85
82
|
}
|
|
86
83
|
else if (parent instanceof Error) {
|
|
87
|
-
child =
|
|
84
|
+
child = new parent.constructor(parent.message);
|
|
88
85
|
}
|
|
89
86
|
else {
|
|
90
87
|
proto = Object.getPrototypeOf(parent);
|
|
@@ -117,7 +114,7 @@ function clone(parent, respectCustomCloneMethod = true) {
|
|
|
117
114
|
if (attrs && typeof attrs.get === 'function' && attrs.set == null) {
|
|
118
115
|
continue;
|
|
119
116
|
}
|
|
120
|
-
const raw =
|
|
117
|
+
const raw = RawQueryFragment.getKnownFragment(i, false);
|
|
121
118
|
if (raw && respectCustomCloneMethod) {
|
|
122
119
|
const i2 = raw.clone().toString();
|
|
123
120
|
child[i2] = _clone(parent[i]);
|
|
@@ -130,7 +127,7 @@ function clone(parent, respectCustomCloneMethod = true) {
|
|
|
130
127
|
for (let i = 0; i < symbols.length; i++) {
|
|
131
128
|
const symbol = symbols[i];
|
|
132
129
|
const descriptor = Object.getOwnPropertyDescriptor(parent, symbol);
|
|
133
|
-
/*
|
|
130
|
+
/* v8 ignore next 3 */
|
|
134
131
|
if (descriptor && !descriptor.enumerable) {
|
|
135
132
|
continue;
|
|
136
133
|
}
|
package/utils/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './Configuration';
|
|
2
|
-
export * from './ConfigurationLoader';
|
|
3
|
-
export * from './Cursor';
|
|
4
|
-
export * from './DataloaderUtils';
|
|
5
|
-
export * from './Utils';
|
|
6
|
-
export * from './RequestContext';
|
|
7
|
-
export * from './TransactionContext';
|
|
8
|
-
export * from './QueryHelper';
|
|
9
|
-
export * from './NullHighlighter';
|
|
10
|
-
export * from './EntityComparator';
|
|
11
|
-
export * from './AbstractSchemaGenerator';
|
|
12
|
-
export * from './RawQueryFragment';
|
|
13
|
-
export * from './upsert-utils';
|
|
1
|
+
export * from './Configuration.js';
|
|
2
|
+
export * from './ConfigurationLoader.js';
|
|
3
|
+
export * from './Cursor.js';
|
|
4
|
+
export * from './DataloaderUtils.js';
|
|
5
|
+
export * from './Utils.js';
|
|
6
|
+
export * from './RequestContext.js';
|
|
7
|
+
export * from './TransactionContext.js';
|
|
8
|
+
export * from './QueryHelper.js';
|
|
9
|
+
export * from './NullHighlighter.js';
|
|
10
|
+
export * from './EntityComparator.js';
|
|
11
|
+
export * from './AbstractSchemaGenerator.js';
|
|
12
|
+
export * from './RawQueryFragment.js';
|
|
13
|
+
export * from './upsert-utils.js';
|
package/utils/index.js
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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("./Configuration"), exports);
|
|
18
|
-
__exportStar(require("./ConfigurationLoader"), exports);
|
|
19
|
-
__exportStar(require("./Cursor"), exports);
|
|
20
|
-
__exportStar(require("./DataloaderUtils"), exports);
|
|
21
|
-
__exportStar(require("./Utils"), exports);
|
|
22
|
-
__exportStar(require("./RequestContext"), exports);
|
|
23
|
-
__exportStar(require("./TransactionContext"), exports);
|
|
24
|
-
__exportStar(require("./QueryHelper"), exports);
|
|
25
|
-
__exportStar(require("./NullHighlighter"), exports);
|
|
26
|
-
__exportStar(require("./EntityComparator"), exports);
|
|
27
|
-
__exportStar(require("./AbstractSchemaGenerator"), exports);
|
|
28
|
-
__exportStar(require("./RawQueryFragment"), exports);
|
|
29
|
-
__exportStar(require("./upsert-utils"), exports);
|
|
1
|
+
export * from './Configuration.js';
|
|
2
|
+
export * from './ConfigurationLoader.js';
|
|
3
|
+
export * from './Cursor.js';
|
|
4
|
+
export * from './DataloaderUtils.js';
|
|
5
|
+
export * from './Utils.js';
|
|
6
|
+
export * from './RequestContext.js';
|
|
7
|
+
export * from './TransactionContext.js';
|
|
8
|
+
export * from './QueryHelper.js';
|
|
9
|
+
export * from './NullHighlighter.js';
|
|
10
|
+
export * from './EntityComparator.js';
|
|
11
|
+
export * from './AbstractSchemaGenerator.js';
|
|
12
|
+
export * from './RawQueryFragment.js';
|
|
13
|
+
export * from './upsert-utils.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { EntityManager } from '../EntityManager';
|
|
2
|
-
import { MikroORM } from '../MikroORM';
|
|
3
|
-
import type { ContextProvider, MaybePromise } from '../typings';
|
|
1
|
+
import { EntityManager } from '../EntityManager.js';
|
|
2
|
+
import { MikroORM } from '../MikroORM.js';
|
|
3
|
+
import type { ContextProvider, MaybePromise } from '../typings.js';
|
|
4
4
|
/**
|
|
5
5
|
* Find `EntityManager` in provided context, or else in instance's `orm` or `em` properties.
|
|
6
6
|
*/
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const EntityRepository_1 = require("../entity/EntityRepository");
|
|
5
|
-
const EntityManager_1 = require("../EntityManager");
|
|
6
|
-
const MikroORM_1 = require("../MikroORM");
|
|
1
|
+
import { EntityRepository } from '../entity/EntityRepository.js';
|
|
2
|
+
import { EntityManager } from '../EntityManager.js';
|
|
3
|
+
import { MikroORM } from '../MikroORM.js';
|
|
7
4
|
function getEntityManager(caller, context) {
|
|
8
|
-
if (context instanceof
|
|
5
|
+
if (context instanceof EntityManager) {
|
|
9
6
|
return context;
|
|
10
7
|
}
|
|
11
|
-
if (context instanceof
|
|
8
|
+
if (context instanceof EntityRepository) {
|
|
12
9
|
return context.getEntityManager();
|
|
13
10
|
}
|
|
14
|
-
if (context instanceof
|
|
11
|
+
if (context instanceof MikroORM) {
|
|
15
12
|
return context.em;
|
|
16
13
|
}
|
|
17
|
-
if (caller.em instanceof
|
|
14
|
+
if (caller.em instanceof EntityManager) {
|
|
18
15
|
return caller.em;
|
|
19
16
|
}
|
|
20
|
-
if (caller.orm instanceof
|
|
17
|
+
if (caller.orm instanceof MikroORM) {
|
|
21
18
|
return caller.orm.em;
|
|
22
19
|
}
|
|
23
20
|
return undefined;
|
|
@@ -25,7 +22,7 @@ function getEntityManager(caller, context) {
|
|
|
25
22
|
/**
|
|
26
23
|
* Find `EntityManager` in provided context, or else in instance's `orm` or `em` properties.
|
|
27
24
|
*/
|
|
28
|
-
async function resolveContextProvider(caller, provider) {
|
|
25
|
+
export async function resolveContextProvider(caller, provider) {
|
|
29
26
|
const context = typeof provider === 'function' ? await provider(caller) : await provider;
|
|
30
27
|
return getEntityManager({ orm: await caller.orm, em: await caller.em }, context);
|
|
31
28
|
}
|