@mikro-orm/core 6.3.1-dev.9 → 6.3.2-dev.0
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 +1 -1
- package/EntityManager.js +2 -2
- package/connections/Connection.js +4 -4
- package/decorators/CreateRequestContext.js +4 -2
- package/entity/ArrayCollection.d.ts +1 -1
- package/entity/ArrayCollection.js +3 -3
- package/entity/EntityAssigner.js +2 -2
- package/entity/EntityHelper.js +3 -3
- package/entity/Reference.d.ts +1 -1
- package/entity/Reference.js +5 -5
- package/entity/WrappedEntity.d.ts +1 -1
- package/entity/WrappedEntity.js +2 -2
- package/errors.js +7 -7
- package/metadata/MetadataDiscovery.js +7 -5
- package/package.json +2 -2
- package/types/EnumArrayType.js +2 -2
- package/types/Type.d.ts +1 -1
- package/types/Type.js +3 -3
- package/unit-of-work/ChangeSet.d.ts +1 -1
- package/unit-of-work/ChangeSet.js +3 -3
- package/unit-of-work/UnitOfWork.js +2 -2
- package/utils/ConfigurationLoader.d.ts +2 -2
- package/utils/ConfigurationLoader.js +10 -10
- package/utils/Cursor.d.ts +1 -1
- package/utils/Cursor.js +3 -3
- package/utils/RawQueryFragment.d.ts +1 -1
- package/utils/RawQueryFragment.js +2 -2
- package/utils/RequestContext.js +2 -2
- package/utils/TransactionContext.js +2 -2
- package/utils/Utils.d.ts +1 -1
- package/utils/Utils.js +16 -16
- package/utils/clone.js +2 -2
package/EntityManager.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inspect } from 'util';
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
2
|
import DataLoader from 'dataloader';
|
|
3
3
|
import { type Configuration, Cursor } from './utils';
|
|
4
4
|
import { type AssignOptions, EntityFactory, type EntityLoaderOptions, type EntityRepository, EntityValidator, Reference } from './entity';
|
package/EntityManager.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.EntityManager = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
8
|
const dataloader_1 = __importDefault(require("dataloader"));
|
|
9
9
|
const utils_1 = require("./utils");
|
|
10
10
|
const entity_1 = require("./entity");
|
|
@@ -1718,7 +1718,7 @@ class EntityManager {
|
|
|
1718
1718
|
return this.getContext(false)._id;
|
|
1719
1719
|
}
|
|
1720
1720
|
/** @ignore */
|
|
1721
|
-
[
|
|
1721
|
+
[node_util_1.inspect.custom]() {
|
|
1722
1722
|
return `[EntityManager<${this.id}>]`;
|
|
1723
1723
|
}
|
|
1724
1724
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Connection = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_url_1 = require("node:url");
|
|
5
5
|
const utils_1 = require("../utils");
|
|
6
6
|
class Connection {
|
|
7
7
|
config;
|
|
@@ -57,7 +57,7 @@ class Connection {
|
|
|
57
57
|
getConnectionOptions() {
|
|
58
58
|
const ret = {};
|
|
59
59
|
if (this.options.clientUrl) {
|
|
60
|
-
const url = new
|
|
60
|
+
const url = new node_url_1.URL(this.options.clientUrl);
|
|
61
61
|
this.options.host = ret.host = this.options.host ?? decodeURIComponent(url.hostname);
|
|
62
62
|
this.options.port = ret.port = this.options.port ?? +url.port;
|
|
63
63
|
this.options.user = ret.user = this.options.user ?? decodeURIComponent(url.username);
|
|
@@ -69,7 +69,7 @@ class Connection {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
else {
|
|
72
|
-
const url = new
|
|
72
|
+
const url = new node_url_1.URL(this.config.getClientUrl());
|
|
73
73
|
this.options.host = ret.host = this.options.host ?? this.config.get('host', decodeURIComponent(url.hostname));
|
|
74
74
|
this.options.port = ret.port = this.options.port ?? this.config.get('port', +url.port);
|
|
75
75
|
this.options.user = ret.user = this.options.user ?? this.config.get('user', decodeURIComponent(url.username));
|
|
@@ -80,7 +80,7 @@ class Connection {
|
|
|
80
80
|
}
|
|
81
81
|
getClientUrl() {
|
|
82
82
|
const options = this.getConnectionOptions();
|
|
83
|
-
const url = new
|
|
83
|
+
const url = new node_url_1.URL(this.config.getClientUrl(true));
|
|
84
84
|
const password = options.password ? ':*****' : '';
|
|
85
85
|
const schema = options.schema && options.schema !== this.platform.getDefaultSchemaName()
|
|
86
86
|
? `?schema=${options.schema}`
|
|
@@ -18,10 +18,12 @@ function CreateRequestContext(getContext, respectExistingContext = false) {
|
|
|
18
18
|
let orm;
|
|
19
19
|
let em;
|
|
20
20
|
if (typeof getContext === 'function') {
|
|
21
|
-
|
|
21
|
+
const context = await getContext(this);
|
|
22
|
+
orm = context ?? await this.orm;
|
|
23
|
+
em = context ?? await this.em;
|
|
22
24
|
}
|
|
23
25
|
else if (getContext) {
|
|
24
|
-
orm = await getContext;
|
|
26
|
+
orm = em = await getContext;
|
|
25
27
|
}
|
|
26
28
|
else {
|
|
27
29
|
orm = await this.orm;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inspect } from 'util';
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
2
|
import type { EntityDTO, EntityProperty, IPrimaryKey, Primary } from '../typings';
|
|
3
3
|
import { Reference } from './Reference';
|
|
4
4
|
export declare class ArrayCollection<T extends object, O extends object> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ArrayCollection = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const Reference_1 = require("./Reference");
|
|
6
6
|
const wrap_1 = require("./wrap");
|
|
7
7
|
const errors_1 = require("../errors");
|
|
@@ -384,11 +384,11 @@ class ArrayCollection {
|
|
|
384
384
|
}
|
|
385
385
|
}
|
|
386
386
|
/** @ignore */
|
|
387
|
-
[
|
|
387
|
+
[node_util_1.inspect.custom](depth = 2) {
|
|
388
388
|
const object = { ...this };
|
|
389
389
|
const hidden = ['items', 'owner', '_property', '_count', 'snapshot', '_populated', '_snapshot', '_lazyInitialized', '_em', 'readonly'];
|
|
390
390
|
hidden.forEach(k => delete object[k]);
|
|
391
|
-
const ret = (0,
|
|
391
|
+
const ret = (0, node_util_1.inspect)(object, { depth });
|
|
392
392
|
const name = `${this.constructor.name}<${this.property?.type ?? 'unknown'}>`;
|
|
393
393
|
return ret === '[Object]' ? `[${name}]` : name + ' ' + ret;
|
|
394
394
|
}
|
package/entity/EntityAssigner.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assign = exports.EntityAssigner = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const Collection_1 = require("./Collection");
|
|
6
6
|
const Utils_1 = require("../utils/Utils");
|
|
7
7
|
const Reference_1 = require("./Reference");
|
|
@@ -175,7 +175,7 @@ class EntityAssigner {
|
|
|
175
175
|
});
|
|
176
176
|
if (invalid.length > 0) {
|
|
177
177
|
const name = entity.constructor.name;
|
|
178
|
-
throw new Error(`Invalid collection values provided for '${name}.${prop.name}' in ${name}.assign(): ${(0,
|
|
178
|
+
throw new Error(`Invalid collection values provided for '${name}.${prop.name}' in ${name}.assign(): ${(0, node_util_1.inspect)(invalid)}`);
|
|
179
179
|
}
|
|
180
180
|
if (Array.isArray(value)) {
|
|
181
181
|
collection.set(items);
|
package/entity/EntityHelper.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EntityHelper = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const typings_1 = require("../typings");
|
|
6
6
|
const EntityTransformer_1 = require("../serialization/EntityTransformer");
|
|
7
7
|
const Reference_1 = require("./Reference");
|
|
@@ -115,14 +115,14 @@ class EntityHelper {
|
|
|
115
115
|
}
|
|
116
116
|
static defineCustomInspect(meta) {
|
|
117
117
|
// @ts-ignore
|
|
118
|
-
meta.prototype[
|
|
118
|
+
meta.prototype[node_util_1.inspect.custom] ??= function (depth = 2) {
|
|
119
119
|
const object = { ...this };
|
|
120
120
|
// ensure we dont have internal symbols in the POJO
|
|
121
121
|
[typings_1.OptionalProps, typings_1.EntityRepositoryType, typings_1.PrimaryKeyProp, typings_1.EagerProps, typings_1.HiddenProps].forEach(sym => delete object[sym]);
|
|
122
122
|
meta.props
|
|
123
123
|
.filter(prop => object[prop.name] === undefined)
|
|
124
124
|
.forEach(prop => delete object[prop.name]);
|
|
125
|
-
const ret = (0,
|
|
125
|
+
const ret = (0, node_util_1.inspect)(object, { depth });
|
|
126
126
|
let name = (this).constructor.name;
|
|
127
127
|
const showEM = ['true', 't', '1'].includes(process.env.MIKRO_ORM_LOG_EM_ID?.toString().toLowerCase() ?? '');
|
|
128
128
|
if (showEM) {
|
package/entity/Reference.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inspect } from 'util';
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
2
|
import type { AddEager, Dictionary, EntityClass, EntityKey, EntityProperty, Loaded, LoadedReference, Primary, Ref } from '../typings';
|
|
3
3
|
import type { FindOneOptions, FindOneOrFailOptions } from '../drivers/IDatabaseDriver';
|
|
4
4
|
export declare class Reference<T extends object> {
|
package/entity/Reference.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Ref = exports.ScalarReference = exports.Reference = void 0;
|
|
4
4
|
exports.ref = ref;
|
|
5
5
|
exports.rel = rel;
|
|
6
|
-
const
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
7
7
|
const enums_1 = require("../enums");
|
|
8
8
|
const wrap_1 = require("./wrap");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
@@ -141,11 +141,11 @@ class Reference {
|
|
|
141
141
|
}
|
|
142
142
|
/* istanbul ignore next */
|
|
143
143
|
/** @ignore */
|
|
144
|
-
[
|
|
144
|
+
[node_util_1.inspect.custom](depth = 2) {
|
|
145
145
|
const object = { ...this };
|
|
146
146
|
const hidden = ['meta'];
|
|
147
147
|
hidden.forEach(k => delete object[k]);
|
|
148
|
-
const ret = (0,
|
|
148
|
+
const ret = (0, node_util_1.inspect)(object, { depth });
|
|
149
149
|
const wrapped = (0, wrap_1.helper)(this.entity);
|
|
150
150
|
const meta = wrapped.__meta;
|
|
151
151
|
const pk = wrapped.hasPrimaryKey() ? '<' + wrapped.getSerializedPrimaryKey() + '>' : '';
|
|
@@ -195,8 +195,8 @@ class ScalarReference {
|
|
|
195
195
|
}
|
|
196
196
|
/* istanbul ignore next */
|
|
197
197
|
/** @ignore */
|
|
198
|
-
[
|
|
199
|
-
return this.initialized ? `Ref<${(0,
|
|
198
|
+
[node_util_1.inspect.custom]() {
|
|
199
|
+
return this.initialized ? `Ref<${(0, node_util_1.inspect)(this.value)}>` : `Ref<?>`;
|
|
200
200
|
}
|
|
201
201
|
}
|
|
202
202
|
exports.ScalarReference = ScalarReference;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PopulatePath } from '../enums';
|
|
2
|
-
import { inspect } from 'util';
|
|
2
|
+
import { inspect } from 'node:util';
|
|
3
3
|
import type { EntityManager } from '../EntityManager';
|
|
4
4
|
import type { Dictionary, EntityData, EntityDictionary, EntityMetadata, IHydrator, EntityKey, PopulateOptions, Primary, AutoPath, Ref, AddEager, LoadedReference, EntityDTO, Loaded, FromEntityType, IsSubset, MergeSelected } from '../typings';
|
|
5
5
|
import { Reference } from './Reference';
|
package/entity/WrappedEntity.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.WrappedEntity = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const Reference_1 = require("./Reference");
|
|
6
6
|
const EntityTransformer_1 = require("../serialization/EntityTransformer");
|
|
7
7
|
const EntityAssigner_1 = require("./EntityAssigner");
|
|
@@ -139,7 +139,7 @@ class WrappedEntity {
|
|
|
139
139
|
return Utils_1.Utils.getPrimaryKeyValues(this.entity, this.__meta.primaryKeys);
|
|
140
140
|
}
|
|
141
141
|
/** @ignore */
|
|
142
|
-
[
|
|
142
|
+
[node_util_1.inspect.custom]() {
|
|
143
143
|
return `[WrappedEntity<${this.__meta.className}>]`;
|
|
144
144
|
}
|
|
145
145
|
}
|
package/errors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.NotFoundError = exports.MetadataError = exports.OptimisticLockError = exports.CursorError = exports.ValidationError = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
class ValidationError extends Error {
|
|
6
6
|
entity;
|
|
7
7
|
constructor(message, entity) {
|
|
@@ -19,7 +19,7 @@ class ValidationError extends Error {
|
|
|
19
19
|
}
|
|
20
20
|
static fromWrongPropertyType(entity, property, expectedType, givenType, givenValue) {
|
|
21
21
|
const entityName = entity.constructor.name;
|
|
22
|
-
const msg = `Trying to set ${entityName}.${property} of type '${expectedType}' to ${(0,
|
|
22
|
+
const msg = `Trying to set ${entityName}.${property} of type '${expectedType}' to ${(0, node_util_1.inspect)(givenValue)} of type '${givenType}'`;
|
|
23
23
|
return new ValidationError(msg);
|
|
24
24
|
}
|
|
25
25
|
static fromWrongRepositoryType(entityName, repoType, method) {
|
|
@@ -42,7 +42,7 @@ class ValidationError extends Error {
|
|
|
42
42
|
}
|
|
43
43
|
static notEntity(owner, prop, data) {
|
|
44
44
|
const type = Object.prototype.toString.call(data).match(/\[object (\w+)]/)[1].toLowerCase();
|
|
45
|
-
return new ValidationError(`Entity of type ${prop.type} expected for property ${owner.constructor.name}.${prop.name}, ${(0,
|
|
45
|
+
return new ValidationError(`Entity of type ${prop.type} expected for property ${owner.constructor.name}.${prop.name}, ${(0, node_util_1.inspect)(data)} of type ${type} given. If you are using Object.assign(entity, data), use em.assign(entity, data) instead.`);
|
|
46
46
|
}
|
|
47
47
|
static notDiscoveredEntity(data, meta, action = 'persist') {
|
|
48
48
|
/* istanbul ignore next */
|
|
@@ -66,7 +66,7 @@ class ValidationError extends Error {
|
|
|
66
66
|
}
|
|
67
67
|
static propertyRequired(entity, property) {
|
|
68
68
|
const entityName = entity.__meta.className;
|
|
69
|
-
return new ValidationError(`Value for ${entityName}.${property.name} is required, '${entity[property.name]}' found\nentity: ${(0,
|
|
69
|
+
return new ValidationError(`Value for ${entityName}.${property.name} is required, '${entity[property.name]}' found\nentity: ${(0, node_util_1.inspect)(entity)}`, entity);
|
|
70
70
|
}
|
|
71
71
|
static cannotModifyInverseCollection(owner, property) {
|
|
72
72
|
const inverseCollection = `${owner.constructor.name}.${property.name}`;
|
|
@@ -96,7 +96,7 @@ class ValidationError extends Error {
|
|
|
96
96
|
return new ValidationError('Using global EntityManager instance methods for context specific actions is disallowed. If you need to work with the global instance\'s identity map, use `allowGlobalContext` configuration option or `fork()` instead.');
|
|
97
97
|
}
|
|
98
98
|
static cannotUseOperatorsInsideEmbeddables(className, propName, payload) {
|
|
99
|
-
return new ValidationError(`Using operators inside embeddables is not allowed, move the operator above. (property: ${className}.${propName}, payload: ${(0,
|
|
99
|
+
return new ValidationError(`Using operators inside embeddables is not allowed, move the operator above. (property: ${className}.${propName}, payload: ${(0, node_util_1.inspect)(payload)})`);
|
|
100
100
|
}
|
|
101
101
|
static invalidEmbeddableQuery(className, propName, embeddableType) {
|
|
102
102
|
return new ValidationError(`Invalid query for entity '${className}', property '${propName}' does not exist in embeddable '${embeddableType}'`);
|
|
@@ -213,10 +213,10 @@ class MetadataError extends ValidationError {
|
|
|
213
213
|
exports.MetadataError = MetadataError;
|
|
214
214
|
class NotFoundError extends ValidationError {
|
|
215
215
|
static findOneFailed(name, where) {
|
|
216
|
-
return new NotFoundError(`${name} not found (${(0,
|
|
216
|
+
return new NotFoundError(`${name} not found (${(0, node_util_1.inspect)(where)})`);
|
|
217
217
|
}
|
|
218
218
|
static findExactlyOneFailed(name, where) {
|
|
219
|
-
return new NotFoundError(`Wrong number of ${name} entities found for query ${(0,
|
|
219
|
+
return new NotFoundError(`Wrong number of ${name} entities found for query ${(0, node_util_1.inspect)(where)}, expected exactly one`);
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
exports.NotFoundError = NotFoundError;
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.MetadataDiscovery = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_path_1 = require("node:path");
|
|
8
8
|
const globby_1 = __importDefault(require("globby"));
|
|
9
9
|
const typings_1 = require("../typings");
|
|
10
10
|
const Utils_1 = require("../utils/Utils");
|
|
@@ -183,7 +183,7 @@ class MetadataDiscovery {
|
|
|
183
183
|
this.logger.log('discovery', `- processing ${colors_1.colors.cyan('' + files.length)} files`);
|
|
184
184
|
const found = [];
|
|
185
185
|
for (const filepath of files) {
|
|
186
|
-
const filename = (0,
|
|
186
|
+
const filename = (0, node_path_1.basename)(filepath);
|
|
187
187
|
if (!filename.match(/\.[cm]?[jt]s$/) ||
|
|
188
188
|
filename.endsWith('.js.map') ||
|
|
189
189
|
filename.match(/\.d\.[cm]?ts/) ||
|
|
@@ -274,7 +274,7 @@ class MetadataDiscovery {
|
|
|
274
274
|
const meta = schema.meta;
|
|
275
275
|
const root = Utils_1.Utils.getRootEntity(this.metadata, meta);
|
|
276
276
|
schema.meta.path = Utils_1.Utils.relativePath(path || meta.path, this.config.get('baseDir'));
|
|
277
|
-
const cache = meta.useCache && meta.path && this.cache.get(meta.className + (0,
|
|
277
|
+
const cache = meta.useCache && meta.path && this.cache.get(meta.className + (0, node_path_1.extname)(meta.path));
|
|
278
278
|
if (cache) {
|
|
279
279
|
this.logger.log('discovery', `- using cached metadata for entity ${colors_1.colors.cyan(meta.className)}`);
|
|
280
280
|
this.metadataProvider.loadFromCache(meta, cache);
|
|
@@ -324,7 +324,7 @@ class MetadataDiscovery {
|
|
|
324
324
|
].forEach(key => delete copy[key]);
|
|
325
325
|
// base entity without properties might not have path, but nothing to cache there
|
|
326
326
|
if (meta.path) {
|
|
327
|
-
this.cache.set(meta.className + (0,
|
|
327
|
+
this.cache.set(meta.className + (0, node_path_1.extname)(meta.path), copy, meta.path);
|
|
328
328
|
}
|
|
329
329
|
}
|
|
330
330
|
initNullability(prop) {
|
|
@@ -723,6 +723,8 @@ class MetadataDiscovery {
|
|
|
723
723
|
let discriminatorColumn;
|
|
724
724
|
const inlineProperties = (meta) => {
|
|
725
725
|
Object.values(meta.properties).forEach(prop => {
|
|
726
|
+
// defaults on db level would mess up with change tracking
|
|
727
|
+
delete prop.default;
|
|
726
728
|
if (properties[prop.name] && properties[prop.name].type !== prop.type) {
|
|
727
729
|
properties[prop.name].type = `${properties[prop.name].type} | ${prop.type}`;
|
|
728
730
|
return properties[prop.name];
|
|
@@ -981,7 +983,7 @@ class MetadataDiscovery {
|
|
|
981
983
|
const entity1 = new meta.class();
|
|
982
984
|
const entity2 = new meta.class();
|
|
983
985
|
// we compare the two values by reference, this will discard things like `new Date()` or `Date.now()`
|
|
984
|
-
if (
|
|
986
|
+
if (this.config.get('discovery').inferDefaultValues && prop.default === undefined && entity1[prop.name] != null && entity1[prop.name] === entity2[prop.name] && entity1[prop.name] !== now) {
|
|
985
987
|
prop.default ??= entity1[prop.name];
|
|
986
988
|
}
|
|
987
989
|
// if the default value is null, infer nullability
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.2-dev.0",
|
|
4
4
|
"description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.mjs",
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"esprima": "4.0.1",
|
|
65
65
|
"fs-extra": "11.2.0",
|
|
66
66
|
"globby": "11.1.0",
|
|
67
|
-
"mikro-orm": "6.3.
|
|
67
|
+
"mikro-orm": "6.3.2-dev.0",
|
|
68
68
|
"reflect-metadata": "0.2.2"
|
|
69
69
|
}
|
|
70
70
|
}
|
package/types/EnumArrayType.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EnumArrayType = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const ArrayType_1 = require("./ArrayType");
|
|
6
6
|
const errors_1 = require("../errors");
|
|
7
7
|
function mapHydrator(items, hydrate) {
|
|
@@ -23,7 +23,7 @@ class EnumArrayType extends ArrayType_1.ArrayType {
|
|
|
23
23
|
if (Array.isArray(value) && Array.isArray(this.items)) {
|
|
24
24
|
const invalid = value.filter(v => !this.items.includes(v));
|
|
25
25
|
if (invalid.length > 0) {
|
|
26
|
-
throw new errors_1.ValidationError(`Invalid enum array items provided in ${this.owner}: ${(0,
|
|
26
|
+
throw new errors_1.ValidationError(`Invalid enum array items provided in ${this.owner}: ${(0, node_util_1.inspect)(invalid)}`);
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
return super.convertToDatabaseValue(value, platform, context);
|
package/types/Type.d.ts
CHANGED
package/types/Type.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Type = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
class Type {
|
|
6
6
|
static types = new Map();
|
|
7
7
|
platform;
|
|
@@ -68,11 +68,11 @@ class Type {
|
|
|
68
68
|
return !!data?.__mappedType;
|
|
69
69
|
}
|
|
70
70
|
/** @ignore */
|
|
71
|
-
[
|
|
71
|
+
[node_util_1.inspect.custom](depth = 2) {
|
|
72
72
|
const object = { ...this };
|
|
73
73
|
const hidden = ['prop', 'platform', 'meta'];
|
|
74
74
|
hidden.forEach(k => delete object[k]);
|
|
75
|
-
const ret = (0,
|
|
75
|
+
const ret = (0, node_util_1.inspect)(object, { depth });
|
|
76
76
|
const name = this.constructor.name;
|
|
77
77
|
/* istanbul ignore next */
|
|
78
78
|
return ret === '[Object]' ? `[${name}]` : name + ' ' + ret;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ChangeSetType = exports.ChangeSet = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const wrap_1 = require("../entity/wrap");
|
|
6
6
|
const Utils_1 = require("../utils/Utils");
|
|
7
7
|
class ChangeSet {
|
|
@@ -41,11 +41,11 @@ class ChangeSet {
|
|
|
41
41
|
return this.serializedPrimaryKey;
|
|
42
42
|
}
|
|
43
43
|
/** @ignore */
|
|
44
|
-
[
|
|
44
|
+
[node_util_1.inspect.custom](depth = 2) {
|
|
45
45
|
const object = { ...this };
|
|
46
46
|
const hidden = ['meta', 'serializedPrimaryKey'];
|
|
47
47
|
hidden.forEach(k => delete object[k]);
|
|
48
|
-
const ret = (0,
|
|
48
|
+
const ret = (0, node_util_1.inspect)(object, { depth });
|
|
49
49
|
const name = `${this.constructor.name}<${this.meta.className}>`;
|
|
50
50
|
/* istanbul ignore next */
|
|
51
51
|
return ret === '[Object]' ? `[${name}]` : name + ' ' + ret;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.UnitOfWork = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
5
|
const entity_1 = require("../entity");
|
|
6
6
|
const ChangeSet_1 = require("./ChangeSet");
|
|
7
7
|
const ChangeSetComputer_1 = require("./ChangeSetComputer");
|
|
@@ -13,7 +13,7 @@ const errors_1 = require("../errors");
|
|
|
13
13
|
const events_1 = require("../events");
|
|
14
14
|
const IdentityMap_1 = require("./IdentityMap");
|
|
15
15
|
// to deal with validation for flush inside flush hooks and `Promise.all`
|
|
16
|
-
const insideFlush = new
|
|
16
|
+
const insideFlush = new node_async_hooks_1.AsyncLocalStorage();
|
|
17
17
|
class UnitOfWork {
|
|
18
18
|
em;
|
|
19
19
|
/** map of references to managed entities */
|
|
@@ -6,10 +6,10 @@ import { Configuration, type Options } from './Configuration';
|
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
8
|
export declare class ConfigurationLoader {
|
|
9
|
-
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate?: boolean, options?: Partial<Options
|
|
9
|
+
static getConfiguration<D extends IDatabaseDriver = IDatabaseDriver, EM extends D[typeof EntityManagerType] & EntityManager = EntityManager>(validate?: boolean, options?: Partial<Options>): Promise<Configuration<D, EM>>;
|
|
10
10
|
static getPackageConfig(basePath?: string): Dictionary;
|
|
11
11
|
static getSettings(): Settings;
|
|
12
|
-
static getConfigPaths(
|
|
12
|
+
static getConfigPaths(): string[];
|
|
13
13
|
static isESM(): boolean;
|
|
14
14
|
static registerTsNode(configPath?: string): boolean;
|
|
15
15
|
static registerDotenv<D extends IDatabaseDriver>(options?: Options<D> | Configuration<D>): void;
|
|
@@ -6,9 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.ConfigurationLoader = void 0;
|
|
7
7
|
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
8
|
const fs_extra_1 = require("fs-extra");
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
const
|
|
9
|
+
const node_os_1 = require("node:os");
|
|
10
|
+
const node_path_1 = require("node:path");
|
|
11
|
+
const node_url_1 = require("node:url");
|
|
12
12
|
const colors_1 = require("../logging/colors");
|
|
13
13
|
const Configuration_1 = require("./Configuration");
|
|
14
14
|
const Utils_1 = require("./Utils");
|
|
@@ -16,10 +16,10 @@ const Utils_1 = require("./Utils");
|
|
|
16
16
|
* @internal
|
|
17
17
|
*/
|
|
18
18
|
class ConfigurationLoader {
|
|
19
|
-
static async getConfiguration(validate = true, options = {}
|
|
19
|
+
static async getConfiguration(validate = true, options = {}) {
|
|
20
20
|
this.commonJSCompat(options);
|
|
21
21
|
this.registerDotenv(options);
|
|
22
|
-
const paths = this.getConfigPaths(
|
|
22
|
+
const paths = this.getConfigPaths();
|
|
23
23
|
const env = this.loadEnvironmentVars();
|
|
24
24
|
for (let path of paths) {
|
|
25
25
|
path = Utils_1.Utils.absolutePath(path);
|
|
@@ -73,7 +73,7 @@ class ConfigurationLoader {
|
|
|
73
73
|
}
|
|
74
74
|
return settings;
|
|
75
75
|
}
|
|
76
|
-
static getConfigPaths(
|
|
76
|
+
static getConfigPaths() {
|
|
77
77
|
const options = Utils_1.Utils.parseArgs();
|
|
78
78
|
const configArgName = process.env.MIKRO_ORM_CONFIG_ARG_NAME ?? 'config';
|
|
79
79
|
if (options[configArgName]) {
|
|
@@ -85,7 +85,7 @@ class ConfigurationLoader {
|
|
|
85
85
|
paths.push(process.env.MIKRO_ORM_CLI_CONFIG);
|
|
86
86
|
}
|
|
87
87
|
paths.push(...(settings.configPaths || []));
|
|
88
|
-
if (
|
|
88
|
+
if (settings.useTsNode !== false || settings.alwaysAllowTs) {
|
|
89
89
|
paths.push('./src/mikro-orm.config.ts');
|
|
90
90
|
paths.push('./mikro-orm.config.ts');
|
|
91
91
|
}
|
|
@@ -104,7 +104,7 @@ class ConfigurationLoader {
|
|
|
104
104
|
return type === 'module';
|
|
105
105
|
}
|
|
106
106
|
static registerTsNode(configPath = 'tsconfig.json') {
|
|
107
|
-
const tsConfigPath = (0,
|
|
107
|
+
const tsConfigPath = (0, node_path_1.isAbsolute)(configPath) ? configPath : (0, node_path_1.join)(process.cwd(), configPath);
|
|
108
108
|
const tsNode = Utils_1.Utils.tryRequire({
|
|
109
109
|
module: 'ts-node',
|
|
110
110
|
from: tsConfigPath,
|
|
@@ -240,9 +240,9 @@ class ConfigurationLoader {
|
|
|
240
240
|
}
|
|
241
241
|
/* istanbul ignore next */
|
|
242
242
|
options.dynamicImportProvider ??= id => {
|
|
243
|
-
if ((0,
|
|
243
|
+
if ((0, node_os_1.platform)() === 'win32') {
|
|
244
244
|
try {
|
|
245
|
-
id = (0,
|
|
245
|
+
id = (0, node_url_1.fileURLToPath)(id);
|
|
246
246
|
}
|
|
247
247
|
catch {
|
|
248
248
|
// ignore
|
package/utils/Cursor.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { inspect } from 'util';
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
2
|
import type { EntityMetadata, FilterObject, Loaded } from '../typings';
|
|
3
3
|
import type { FindByCursorOptions, OrderDefinition } from '../drivers/IDatabaseDriver';
|
|
4
4
|
import { type QueryOrder } from '../enums';
|
package/utils/Cursor.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Cursor = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_util_1 = require("node:util");
|
|
5
5
|
const Utils_1 = require("./Utils");
|
|
6
6
|
const enums_1 = require("../enums");
|
|
7
7
|
const Reference_1 = require("../entity/Reference");
|
|
@@ -164,10 +164,10 @@ class Cursor {
|
|
|
164
164
|
}
|
|
165
165
|
/* istanbul ignore next */
|
|
166
166
|
/** @ignore */
|
|
167
|
-
[
|
|
167
|
+
[node_util_1.inspect.custom]() {
|
|
168
168
|
const type = this.items[0]?.constructor.name;
|
|
169
169
|
const { items, startCursor, endCursor, hasPrevPage, hasNextPage, totalCount, length } = this;
|
|
170
|
-
const options = (0,
|
|
170
|
+
const options = (0, node_util_1.inspect)({ startCursor, endCursor, totalCount, hasPrevPage, hasNextPage, items, length }, { depth: 0 });
|
|
171
171
|
return `Cursor${type ? `<${type}>` : ''} ${options.replace('items: [Array]', 'items: [...]')}`;
|
|
172
172
|
}
|
|
173
173
|
}
|
|
@@ -4,7 +4,7 @@ exports.ALIAS_REPLACEMENT_RE = exports.ALIAS_REPLACEMENT = exports.RawQueryFragm
|
|
|
4
4
|
exports.raw = raw;
|
|
5
5
|
exports.sql = sql;
|
|
6
6
|
exports.createSqlFunction = createSqlFunction;
|
|
7
|
-
const
|
|
7
|
+
const node_util_1 = require("node:util");
|
|
8
8
|
const Utils_1 = require("./Utils");
|
|
9
9
|
class RawQueryFragment {
|
|
10
10
|
sql;
|
|
@@ -79,7 +79,7 @@ class RawQueryFragment {
|
|
|
79
79
|
}
|
|
80
80
|
/* istanbul ignore next */
|
|
81
81
|
/** @ignore */
|
|
82
|
-
[
|
|
82
|
+
[node_util_1.inspect.custom]() {
|
|
83
83
|
if (this.params) {
|
|
84
84
|
return { sql: this.sql, params: this.params };
|
|
85
85
|
}
|
package/utils/RequestContext.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.RequestContext = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
5
|
/**
|
|
6
6
|
* Uses `AsyncLocalStorage` to create async context that holds the current EM fork.
|
|
7
7
|
*/
|
|
8
8
|
class RequestContext {
|
|
9
9
|
map;
|
|
10
|
-
static storage = new
|
|
10
|
+
static storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
11
11
|
static counter = 1;
|
|
12
12
|
id = RequestContext.counter++;
|
|
13
13
|
constructor(map) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TransactionContext = void 0;
|
|
4
|
-
const
|
|
4
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
5
5
|
class TransactionContext {
|
|
6
6
|
em;
|
|
7
|
-
static storage = new
|
|
7
|
+
static storage = new node_async_hooks_1.AsyncLocalStorage();
|
|
8
8
|
id;
|
|
9
9
|
constructor(em) {
|
|
10
10
|
this.em = em;
|
package/utils/Utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type GlobbyOptions } from 'globby';
|
|
2
|
-
import { type URL } from 'url';
|
|
2
|
+
import { type URL } from 'node:url';
|
|
3
3
|
import type { Dictionary, EntityData, EntityDictionary, EntityKey, EntityMetadata, EntityName, EntityProperty, IMetadataStorage, Primary } from '../typings';
|
|
4
4
|
import type { Collection } from '../entity/Collection';
|
|
5
5
|
import type { Platform } from '../platforms';
|
package/utils/Utils.js
CHANGED
|
@@ -10,13 +10,13 @@ exports.compareBooleans = compareBooleans;
|
|
|
10
10
|
exports.compareBuffers = compareBuffers;
|
|
11
11
|
exports.equals = equals;
|
|
12
12
|
exports.parseJsonSafe = parseJsonSafe;
|
|
13
|
-
const
|
|
13
|
+
const node_module_1 = require("node:module");
|
|
14
14
|
const globby_1 = __importDefault(require("globby"));
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
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
18
|
const fs_extra_1 = require("fs-extra");
|
|
19
|
-
const
|
|
19
|
+
const node_crypto_1 = require("node:crypto");
|
|
20
20
|
const esprima_1 = require("esprima");
|
|
21
21
|
const clone_1 = require("./clone");
|
|
22
22
|
const enums_1 = require("../enums");
|
|
@@ -712,7 +712,7 @@ class Utils {
|
|
|
712
712
|
}
|
|
713
713
|
static fileURLToPath(url) {
|
|
714
714
|
// expose `fileURLToPath` on Utils so that it can be properly mocked in tests
|
|
715
|
-
return (0,
|
|
715
|
+
return (0, node_url_1.fileURLToPath)(url);
|
|
716
716
|
}
|
|
717
717
|
/**
|
|
718
718
|
* Resolves and normalizes a series of path parts relative to each preceding part.
|
|
@@ -725,7 +725,7 @@ class Utils {
|
|
|
725
725
|
let start = 0;
|
|
726
726
|
for (let i = 0; i < parts.length; i++) {
|
|
727
727
|
const part = parts[i];
|
|
728
|
-
if ((0,
|
|
728
|
+
if ((0, node_path_1.isAbsolute)(part)) {
|
|
729
729
|
start = i;
|
|
730
730
|
}
|
|
731
731
|
else if (part.startsWith('file:')) {
|
|
@@ -737,7 +737,7 @@ class Utils {
|
|
|
737
737
|
parts = parts.slice(start);
|
|
738
738
|
}
|
|
739
739
|
let path = parts.join('/').replace(/\\/g, '/').replace(/\/$/, '');
|
|
740
|
-
path = (0,
|
|
740
|
+
path = (0, node_path_1.normalize)(path).replace(/\\/g, '/');
|
|
741
741
|
return (path.match(/^[/.]|[a-zA-Z]:/) || path.startsWith('!')) ? path : './' + path;
|
|
742
742
|
}
|
|
743
743
|
/**
|
|
@@ -752,7 +752,7 @@ class Utils {
|
|
|
752
752
|
if (path.startsWith('.')) {
|
|
753
753
|
return path;
|
|
754
754
|
}
|
|
755
|
-
path = (0,
|
|
755
|
+
path = (0, node_path_1.relative)(Utils.normalizePath(relativeTo), path);
|
|
756
756
|
return Utils.normalizePath(path);
|
|
757
757
|
}
|
|
758
758
|
/**
|
|
@@ -763,13 +763,13 @@ class Utils {
|
|
|
763
763
|
if (!path) {
|
|
764
764
|
return Utils.normalizePath(baseDir);
|
|
765
765
|
}
|
|
766
|
-
if (!(0,
|
|
766
|
+
if (!(0, node_path_1.isAbsolute)(path) && !path.startsWith('file://')) {
|
|
767
767
|
path = baseDir + '/' + path;
|
|
768
768
|
}
|
|
769
769
|
return Utils.normalizePath(path);
|
|
770
770
|
}
|
|
771
771
|
static hash(data, length) {
|
|
772
|
-
const hash = (0,
|
|
772
|
+
const hash = (0, node_crypto_1.createHash)('md5').update(data).digest('hex');
|
|
773
773
|
if (length) {
|
|
774
774
|
return hash.substring(0, length);
|
|
775
775
|
}
|
|
@@ -865,16 +865,16 @@ class Utils {
|
|
|
865
865
|
* @param [from] Location to start the node resolution
|
|
866
866
|
*/
|
|
867
867
|
static requireFrom(id, from = process.cwd()) {
|
|
868
|
-
if (!(0,
|
|
869
|
-
from = (0,
|
|
868
|
+
if (!(0, node_path_1.extname)(from)) {
|
|
869
|
+
from = (0, node_path_1.join)(from, '__fake.js');
|
|
870
870
|
}
|
|
871
|
-
return (0,
|
|
871
|
+
return (0, node_module_1.createRequire)((0, node_path_1.resolve)(from))(id);
|
|
872
872
|
}
|
|
873
873
|
static async dynamicImport(id) {
|
|
874
874
|
/* istanbul ignore next */
|
|
875
|
-
if ((0,
|
|
875
|
+
if ((0, node_os_1.platform)() === 'win32') {
|
|
876
876
|
try {
|
|
877
|
-
id = (0,
|
|
877
|
+
id = (0, node_url_1.pathToFileURL)(id).toString();
|
|
878
878
|
}
|
|
879
879
|
catch {
|
|
880
880
|
// ignore
|
package/utils/clone.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.clone = clone;
|
|
9
|
-
const
|
|
9
|
+
const node_events_1 = require("node:events");
|
|
10
10
|
const RawQueryFragment_1 = require("./RawQueryFragment");
|
|
11
11
|
function clone(parent, respectCustomCloneMethod = true) {
|
|
12
12
|
const allParents = [];
|
|
@@ -20,7 +20,7 @@ function clone(parent, respectCustomCloneMethod = true) {
|
|
|
20
20
|
if (raw && respectCustomCloneMethod) {
|
|
21
21
|
return raw.clone();
|
|
22
22
|
}
|
|
23
|
-
if (typeof parent !== 'object' || parent instanceof
|
|
23
|
+
if (typeof parent !== 'object' || parent instanceof node_events_1.EventEmitter) {
|
|
24
24
|
return parent;
|
|
25
25
|
}
|
|
26
26
|
if (respectCustomCloneMethod && 'clone' in parent && typeof parent.clone === 'function') {
|