@mikro-orm/core 6.3.1-dev.0 → 6.3.1-dev.10
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/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 +8 -8
- 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.js +6 -6
- 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 +2 -2
- package/utils/Utils.js +25 -17
- 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}`
|
|
@@ -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/) ||
|
|
@@ -219,9 +219,6 @@ class MetadataDiscovery {
|
|
|
219
219
|
this.metadata.set(meta.className, meta);
|
|
220
220
|
found.push(schema);
|
|
221
221
|
}
|
|
222
|
-
for (const schema of found) {
|
|
223
|
-
this.discoverEntity(schema);
|
|
224
|
-
}
|
|
225
222
|
// discover parents (base entities) automatically
|
|
226
223
|
for (const meta of this.metadata) {
|
|
227
224
|
let parent = meta.extends;
|
|
@@ -236,6 +233,9 @@ class MetadataDiscovery {
|
|
|
236
233
|
this.discoverReferences([parent]);
|
|
237
234
|
}
|
|
238
235
|
}
|
|
236
|
+
for (const schema of found) {
|
|
237
|
+
this.discoverEntity(schema);
|
|
238
|
+
}
|
|
239
239
|
return this.discovered.filter(meta => found.find(m => m.name === meta.className));
|
|
240
240
|
}
|
|
241
241
|
prepare(entity) {
|
|
@@ -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) {
|
|
@@ -458,7 +458,7 @@ class MetadataDiscovery {
|
|
|
458
458
|
this.initColumnType(prop);
|
|
459
459
|
this.initRelation(prop);
|
|
460
460
|
}
|
|
461
|
-
meta.simplePK = pks.length === 1 && pks[0].kind === enums_1.ReferenceKind.SCALAR && !pks[0].customType;
|
|
461
|
+
meta.simplePK = pks.length === 1 && pks[0].kind === enums_1.ReferenceKind.SCALAR && !pks[0].customType && pks[0].runtimeType !== 'Date';
|
|
462
462
|
meta.serializedPrimaryKey = this.platform.getSerializedPrimaryKeyField(meta.primaryKeys[0]);
|
|
463
463
|
const serializedPKProp = meta.properties[meta.serializedPrimaryKey];
|
|
464
464
|
if (serializedPKProp && meta.serializedPrimaryKey !== meta.primaryKeys[0]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mikro-orm/core",
|
|
3
|
-
"version": "6.3.1-dev.
|
|
3
|
+
"version": "6.3.1-dev.10",
|
|
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.1-dev.
|
|
67
|
+
"mikro-orm": "6.3.1-dev.10",
|
|
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,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");
|
|
@@ -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';
|
|
@@ -133,7 +133,7 @@ export declare class Utils {
|
|
|
133
133
|
static extractPK<T extends object>(data: any, meta?: EntityMetadata<T>, strict?: boolean): Primary<T> | string | null;
|
|
134
134
|
static getCompositeKeyValue<T>(data: EntityData<T>, meta: EntityMetadata<T>, convertCustomTypes?: boolean | 'convertToDatabaseValue' | 'convertToJSValue', platform?: Platform): Primary<T>;
|
|
135
135
|
static getCompositeKeyHash<T>(data: EntityData<T>, meta: EntityMetadata<T>, convertCustomTypes?: boolean, platform?: Platform, flat?: boolean): string;
|
|
136
|
-
static getPrimaryKeyHash(pks: (string | Buffer)[]): string;
|
|
136
|
+
static getPrimaryKeyHash(pks: (string | Buffer | Date)[]): string;
|
|
137
137
|
static splitPrimaryKeys<T extends object>(key: string): EntityKey<T>[];
|
|
138
138
|
static getPrimaryKeyValues<T>(entity: T, primaryKeys: string[], allowScalar?: boolean, convertCustomTypes?: boolean): any;
|
|
139
139
|
static getPrimaryKeyCond<T>(entity: T, primaryKeys: EntityKey<T>[]): Record<string, Primary<T>> | null;
|
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");
|
|
@@ -476,7 +476,15 @@ class Utils {
|
|
|
476
476
|
return Utils.getPrimaryKeyHash(pks);
|
|
477
477
|
}
|
|
478
478
|
static getPrimaryKeyHash(pks) {
|
|
479
|
-
return pks.map(pk =>
|
|
479
|
+
return pks.map(pk => {
|
|
480
|
+
if (Buffer.isBuffer(pk)) {
|
|
481
|
+
return pk.toString('hex');
|
|
482
|
+
}
|
|
483
|
+
if (pk instanceof Date) {
|
|
484
|
+
return pk.toISOString();
|
|
485
|
+
}
|
|
486
|
+
return pk;
|
|
487
|
+
}).join(this.PK_SEPARATOR);
|
|
480
488
|
}
|
|
481
489
|
static splitPrimaryKeys(key) {
|
|
482
490
|
return key.split(this.PK_SEPARATOR);
|
|
@@ -704,7 +712,7 @@ class Utils {
|
|
|
704
712
|
}
|
|
705
713
|
static fileURLToPath(url) {
|
|
706
714
|
// expose `fileURLToPath` on Utils so that it can be properly mocked in tests
|
|
707
|
-
return (0,
|
|
715
|
+
return (0, node_url_1.fileURLToPath)(url);
|
|
708
716
|
}
|
|
709
717
|
/**
|
|
710
718
|
* Resolves and normalizes a series of path parts relative to each preceding part.
|
|
@@ -717,7 +725,7 @@ class Utils {
|
|
|
717
725
|
let start = 0;
|
|
718
726
|
for (let i = 0; i < parts.length; i++) {
|
|
719
727
|
const part = parts[i];
|
|
720
|
-
if ((0,
|
|
728
|
+
if ((0, node_path_1.isAbsolute)(part)) {
|
|
721
729
|
start = i;
|
|
722
730
|
}
|
|
723
731
|
else if (part.startsWith('file:')) {
|
|
@@ -729,7 +737,7 @@ class Utils {
|
|
|
729
737
|
parts = parts.slice(start);
|
|
730
738
|
}
|
|
731
739
|
let path = parts.join('/').replace(/\\/g, '/').replace(/\/$/, '');
|
|
732
|
-
path = (0,
|
|
740
|
+
path = (0, node_path_1.normalize)(path).replace(/\\/g, '/');
|
|
733
741
|
return (path.match(/^[/.]|[a-zA-Z]:/) || path.startsWith('!')) ? path : './' + path;
|
|
734
742
|
}
|
|
735
743
|
/**
|
|
@@ -744,7 +752,7 @@ class Utils {
|
|
|
744
752
|
if (path.startsWith('.')) {
|
|
745
753
|
return path;
|
|
746
754
|
}
|
|
747
|
-
path = (0,
|
|
755
|
+
path = (0, node_path_1.relative)(Utils.normalizePath(relativeTo), path);
|
|
748
756
|
return Utils.normalizePath(path);
|
|
749
757
|
}
|
|
750
758
|
/**
|
|
@@ -755,13 +763,13 @@ class Utils {
|
|
|
755
763
|
if (!path) {
|
|
756
764
|
return Utils.normalizePath(baseDir);
|
|
757
765
|
}
|
|
758
|
-
if (!(0,
|
|
766
|
+
if (!(0, node_path_1.isAbsolute)(path) && !path.startsWith('file://')) {
|
|
759
767
|
path = baseDir + '/' + path;
|
|
760
768
|
}
|
|
761
769
|
return Utils.normalizePath(path);
|
|
762
770
|
}
|
|
763
771
|
static hash(data, length) {
|
|
764
|
-
const hash = (0,
|
|
772
|
+
const hash = (0, node_crypto_1.createHash)('md5').update(data).digest('hex');
|
|
765
773
|
if (length) {
|
|
766
774
|
return hash.substring(0, length);
|
|
767
775
|
}
|
|
@@ -857,16 +865,16 @@ class Utils {
|
|
|
857
865
|
* @param [from] Location to start the node resolution
|
|
858
866
|
*/
|
|
859
867
|
static requireFrom(id, from = process.cwd()) {
|
|
860
|
-
if (!(0,
|
|
861
|
-
from = (0,
|
|
868
|
+
if (!(0, node_path_1.extname)(from)) {
|
|
869
|
+
from = (0, node_path_1.join)(from, '__fake.js');
|
|
862
870
|
}
|
|
863
|
-
return (0,
|
|
871
|
+
return (0, node_module_1.createRequire)((0, node_path_1.resolve)(from))(id);
|
|
864
872
|
}
|
|
865
873
|
static async dynamicImport(id) {
|
|
866
874
|
/* istanbul ignore next */
|
|
867
|
-
if ((0,
|
|
875
|
+
if ((0, node_os_1.platform)() === 'win32') {
|
|
868
876
|
try {
|
|
869
|
-
id = (0,
|
|
877
|
+
id = (0, node_url_1.pathToFileURL)(id).toString();
|
|
870
878
|
}
|
|
871
879
|
catch {
|
|
872
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') {
|