@mikro-orm/core 7.0.0-dev.1 → 7.0.0-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/EntityManager.d.ts +18 -13
- package/EntityManager.js +203 -203
- package/MikroORM.d.ts +7 -6
- package/MikroORM.js +33 -45
- package/cache/CacheAdapter.js +1 -2
- package/cache/FileCacheAdapter.d.ts +1 -1
- package/cache/FileCacheAdapter.js +18 -26
- package/cache/GeneratedCacheAdapter.d.ts +2 -2
- package/cache/GeneratedCacheAdapter.js +1 -5
- package/cache/MemoryCacheAdapter.d.ts +1 -1
- package/cache/MemoryCacheAdapter.js +1 -5
- package/cache/NullCacheAdapter.d.ts +1 -1
- package/cache/NullCacheAdapter.js +1 -5
- package/cache/index.d.ts +5 -5
- package/cache/index.js +5 -21
- package/connections/Connection.d.ts +7 -7
- package/connections/Connection.js +8 -12
- package/connections/index.d.ts +1 -1
- package/connections/index.js +1 -17
- package/decorators/Check.d.ts +1 -1
- package/decorators/Check.js +5 -8
- package/decorators/CreateRequestContext.d.ts +1 -1
- package/decorators/CreateRequestContext.js +13 -14
- package/decorators/Embeddable.d.ts +1 -1
- package/decorators/Embeddable.js +3 -6
- package/decorators/Embedded.d.ts +1 -1
- package/decorators/Embedded.js +10 -12
- package/decorators/Entity.d.ts +2 -2
- package/decorators/Entity.js +5 -8
- package/decorators/Enum.d.ts +2 -2
- package/decorators/Enum.js +7 -10
- package/decorators/Filter.d.ts +1 -1
- package/decorators/Filter.js +3 -6
- package/decorators/Formula.d.ts +2 -2
- package/decorators/Formula.js +7 -10
- package/decorators/Indexed.d.ts +2 -2
- package/decorators/Indexed.js +6 -10
- package/decorators/ManyToMany.d.ts +3 -3
- package/decorators/ManyToMany.js +10 -12
- package/decorators/ManyToOne.d.ts +3 -3
- package/decorators/ManyToOne.js +10 -12
- package/decorators/OneToMany.d.ts +3 -3
- package/decorators/OneToMany.js +11 -14
- package/decorators/OneToOne.d.ts +4 -4
- package/decorators/OneToOne.js +4 -7
- package/decorators/PrimaryKey.d.ts +2 -2
- package/decorators/PrimaryKey.js +10 -13
- package/decorators/Property.d.ts +5 -5
- package/decorators/Property.js +10 -12
- package/decorators/Transactional.d.ts +2 -2
- package/decorators/Transactional.js +7 -10
- package/decorators/hooks.js +23 -35
- package/decorators/index.d.ts +17 -17
- package/decorators/index.js +17 -36
- package/drivers/DatabaseDriver.d.ts +13 -12
- package/drivers/DatabaseDriver.js +60 -64
- package/drivers/IDatabaseDriver.d.ts +12 -12
- package/drivers/IDatabaseDriver.js +1 -4
- package/drivers/index.d.ts +2 -2
- package/drivers/index.js +2 -18
- package/entity/ArrayCollection.d.ts +2 -2
- package/entity/ArrayCollection.js +29 -33
- package/entity/BaseEntity.d.ts +6 -6
- package/entity/BaseEntity.js +17 -21
- package/entity/Collection.d.ts +6 -6
- package/entity/Collection.js +40 -44
- package/entity/EntityAssigner.d.ts +2 -2
- package/entity/EntityAssigner.js +58 -63
- package/entity/EntityFactory.d.ts +3 -3
- package/entity/EntityFactory.js +58 -62
- package/entity/EntityHelper.d.ts +2 -2
- package/entity/EntityHelper.js +41 -45
- package/entity/EntityIdentifier.d.ts +1 -1
- package/entity/EntityIdentifier.js +1 -5
- package/entity/EntityLoader.d.ts +5 -5
- package/entity/EntityLoader.js +92 -96
- package/entity/EntityRepository.d.ts +7 -7
- package/entity/EntityRepository.js +7 -11
- package/entity/EntityValidator.d.ts +1 -1
- package/entity/EntityValidator.js +25 -29
- package/entity/Reference.d.ts +2 -2
- package/entity/Reference.js +35 -42
- package/entity/WrappedEntity.d.ts +12 -12
- package/entity/WrappedEntity.js +23 -27
- package/entity/index.d.ts +13 -13
- package/entity/index.js +13 -29
- package/entity/utils.d.ts +1 -1
- package/entity/utils.js +9 -12
- package/entity/wrap.d.ts +1 -1
- package/entity/wrap.js +2 -6
- package/enums.d.ts +3 -3
- package/enums.js +37 -41
- package/errors.d.ts +1 -1
- package/errors.js +15 -24
- package/events/EventManager.d.ts +3 -3
- package/events/EventManager.js +8 -12
- package/events/EventSubscriber.d.ts +5 -4
- package/events/EventSubscriber.js +1 -2
- package/events/TransactionEventBroadcaster.d.ts +3 -3
- package/events/TransactionEventBroadcaster.js +1 -5
- package/events/index.d.ts +3 -3
- package/events/index.js +3 -19
- package/exceptions.js +18 -39
- package/hydration/Hydrator.d.ts +5 -5
- package/hydration/Hydrator.js +3 -6
- package/hydration/ObjectHydrator.d.ts +3 -3
- package/hydration/ObjectHydrator.js +25 -28
- package/hydration/index.d.ts +2 -2
- package/hydration/index.js +2 -18
- package/index.d.ts +21 -21
- package/index.js +21 -46
- package/logging/DefaultLogger.d.ts +1 -1
- package/logging/DefaultLogger.js +9 -13
- package/logging/Logger.d.ts +1 -1
- package/logging/Logger.js +1 -2
- package/logging/SimpleLogger.d.ts +2 -2
- package/logging/SimpleLogger.js +2 -6
- package/logging/colors.js +1 -5
- package/logging/index.d.ts +4 -4
- package/logging/index.js +4 -20
- package/metadata/EntitySchema.d.ts +12 -4
- package/metadata/EntitySchema.js +41 -45
- package/metadata/MetadataDiscovery.d.ts +7 -7
- package/metadata/MetadataDiscovery.js +174 -177
- package/metadata/MetadataProvider.d.ts +2 -2
- package/metadata/MetadataProvider.js +4 -7
- package/metadata/MetadataStorage.d.ts +2 -2
- package/metadata/MetadataStorage.js +15 -19
- package/metadata/MetadataValidator.d.ts +4 -4
- package/metadata/MetadataValidator.js +49 -53
- package/metadata/ReflectMetadataProvider.d.ts +2 -2
- package/metadata/ReflectMetadataProvider.js +8 -12
- package/metadata/index.d.ts +6 -6
- package/metadata/index.js +6 -22
- package/naming-strategy/AbstractNamingStrategy.d.ts +2 -2
- package/naming-strategy/AbstractNamingStrategy.js +4 -8
- package/naming-strategy/EntityCaseNamingStrategy.d.ts +1 -1
- package/naming-strategy/EntityCaseNamingStrategy.js +2 -6
- package/naming-strategy/MongoNamingStrategy.d.ts +1 -1
- package/naming-strategy/MongoNamingStrategy.js +2 -6
- package/naming-strategy/NamingStrategy.d.ts +1 -1
- package/naming-strategy/NamingStrategy.js +1 -2
- package/naming-strategy/UnderscoreNamingStrategy.d.ts +1 -1
- package/naming-strategy/UnderscoreNamingStrategy.js +2 -6
- package/naming-strategy/index.d.ts +5 -5
- package/naming-strategy/index.js +5 -21
- package/package.json +5 -14
- package/platforms/ExceptionConverter.d.ts +2 -2
- package/platforms/ExceptionConverter.js +4 -8
- package/platforms/Platform.d.ts +10 -10
- package/platforms/Platform.js +57 -61
- package/platforms/index.d.ts +2 -2
- package/platforms/index.js +2 -18
- package/serialization/EntitySerializer.d.ts +2 -2
- package/serialization/EntitySerializer.js +36 -41
- package/serialization/EntityTransformer.d.ts +1 -1
- package/serialization/EntityTransformer.js +27 -31
- package/serialization/SerializationContext.d.ts +2 -2
- package/serialization/SerializationContext.js +10 -14
- package/serialization/index.d.ts +3 -3
- package/serialization/index.js +3 -19
- package/types/ArrayType.d.ts +3 -3
- package/types/ArrayType.js +7 -11
- package/types/BigIntType.d.ts +3 -3
- package/types/BigIntType.js +3 -6
- package/types/BlobType.d.ts +3 -3
- package/types/BlobType.js +2 -8
- package/types/BooleanType.d.ts +3 -3
- package/types/BooleanType.js +2 -6
- package/types/CharacterType.d.ts +3 -3
- package/types/CharacterType.js +2 -6
- package/types/DateTimeType.d.ts +3 -3
- package/types/DateTimeType.js +2 -6
- package/types/DateType.d.ts +3 -3
- package/types/DateType.js +2 -6
- package/types/DecimalType.d.ts +3 -3
- package/types/DecimalType.js +4 -7
- package/types/DoubleType.d.ts +3 -3
- package/types/DoubleType.js +3 -6
- package/types/EnumArrayType.d.ts +4 -4
- package/types/EnumArrayType.js +5 -10
- package/types/EnumType.d.ts +3 -3
- package/types/EnumType.js +2 -6
- package/types/FloatType.d.ts +3 -3
- package/types/FloatType.js +2 -6
- package/types/IntegerType.d.ts +3 -3
- package/types/IntegerType.js +2 -6
- package/types/IntervalType.d.ts +3 -3
- package/types/IntervalType.js +2 -6
- package/types/JsonType.d.ts +3 -3
- package/types/JsonType.js +2 -6
- package/types/MediumIntType.d.ts +3 -3
- package/types/MediumIntType.js +2 -6
- package/types/SmallIntType.d.ts +3 -3
- package/types/SmallIntType.js +2 -6
- package/types/StringType.d.ts +3 -3
- package/types/StringType.js +2 -6
- package/types/TextType.d.ts +3 -3
- package/types/TextType.js +2 -6
- package/types/TimeType.d.ts +3 -3
- package/types/TimeType.js +4 -8
- package/types/TinyIntType.d.ts +3 -3
- package/types/TinyIntType.js +3 -6
- package/types/Type.d.ts +2 -2
- package/types/Type.js +5 -9
- package/types/Uint8ArrayType.d.ts +3 -3
- package/types/Uint8ArrayType.js +3 -9
- package/types/UnknownType.d.ts +3 -3
- package/types/UnknownType.js +2 -6
- package/types/UuidType.d.ts +3 -3
- package/types/UuidType.js +2 -6
- package/types/index.d.ts +25 -25
- package/types/index.js +52 -79
- package/typings.d.ts +22 -20
- package/typings.js +34 -38
- package/unit-of-work/ChangeSet.d.ts +1 -1
- package/unit-of-work/ChangeSet.js +13 -17
- package/unit-of-work/ChangeSetComputer.d.ts +8 -7
- package/unit-of-work/ChangeSetComputer.js +26 -30
- package/unit-of-work/ChangeSetPersister.d.ts +7 -6
- package/unit-of-work/ChangeSetPersister.js +44 -47
- package/unit-of-work/CommitOrderCalculator.d.ts +1 -1
- package/unit-of-work/CommitOrderCalculator.js +6 -10
- package/unit-of-work/IdentityMap.d.ts +1 -1
- package/unit-of-work/IdentityMap.js +1 -5
- package/unit-of-work/UnitOfWork.d.ts +8 -7
- package/unit-of-work/UnitOfWork.js +171 -172
- package/unit-of-work/index.d.ts +6 -6
- package/unit-of-work/index.js +6 -22
- package/utils/AbstractSchemaGenerator.d.ts +6 -6
- package/utils/AbstractSchemaGenerator.js +7 -11
- package/utils/Configuration.d.ts +26 -27
- package/utils/Configuration.js +50 -55
- package/utils/ConfigurationLoader.d.ts +9 -8
- package/utils/ConfigurationLoader.js +71 -86
- package/utils/Cursor.d.ts +3 -3
- package/utils/Cursor.js +22 -25
- package/utils/DataloaderUtils.d.ts +4 -4
- package/utils/DataloaderUtils.js +12 -16
- package/utils/EntityComparator.d.ts +2 -2
- package/utils/EntityComparator.js +48 -52
- package/utils/NullHighlighter.d.ts +1 -1
- package/utils/NullHighlighter.js +1 -5
- package/utils/QueryHelper.d.ts +3 -3
- package/utils/QueryHelper.js +47 -51
- package/utils/RawQueryFragment.d.ts +1 -1
- package/utils/RawQueryFragment.js +16 -24
- package/utils/RequestContext.d.ts +2 -2
- package/utils/RequestContext.js +3 -7
- package/utils/TransactionContext.d.ts +1 -1
- package/utils/TransactionContext.js +4 -8
- package/utils/Utils.d.ts +16 -12
- package/utils/Utils.js +89 -93
- package/utils/clone.js +8 -11
- package/utils/index.d.ts +13 -13
- package/utils/index.js +13 -29
- package/utils/resolveContextProvider.d.ts +3 -3
- package/utils/resolveContextProvider.js +9 -12
- package/utils/upsert-utils.d.ts +3 -3
- package/utils/upsert-utils.js +5 -9
- package/index.mjs +0 -199
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const wrap_1 = require("./wrap");
|
|
8
|
-
const RawQueryFragment_1 = require("../utils/RawQueryFragment");
|
|
9
|
-
class EntityValidator {
|
|
1
|
+
import { ReferenceKind } from '../enums.js';
|
|
2
|
+
import { Utils } from '../utils/Utils.js';
|
|
3
|
+
import { ValidationError } from '../errors.js';
|
|
4
|
+
import { helper } from './wrap.js';
|
|
5
|
+
import { RawQueryFragment } from '../utils/RawQueryFragment.js';
|
|
6
|
+
export class EntityValidator {
|
|
10
7
|
strict;
|
|
11
8
|
KNOWN_TYPES = new Set(['string', 'number', 'boolean', 'bigint', 'Uint8Array', 'Date', 'Buffer', 'RegExp']);
|
|
12
9
|
constructor(strict) {
|
|
@@ -17,11 +14,11 @@ class EntityValidator {
|
|
|
17
14
|
if (prop.inherited) {
|
|
18
15
|
return;
|
|
19
16
|
}
|
|
20
|
-
if ([
|
|
17
|
+
if ([ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind)) {
|
|
21
18
|
this.validateCollection(entity, prop);
|
|
22
19
|
}
|
|
23
20
|
const SCALAR_TYPES = ['string', 'number', 'boolean', 'Date'];
|
|
24
|
-
if (prop.kind !==
|
|
21
|
+
if (prop.kind !== ReferenceKind.SCALAR || !SCALAR_TYPES.includes(prop.type)) {
|
|
25
22
|
return;
|
|
26
23
|
}
|
|
27
24
|
const newValue = this.validateProperty(prop, this.getValue(payload, prop), entity);
|
|
@@ -29,14 +26,13 @@ class EntityValidator {
|
|
|
29
26
|
return;
|
|
30
27
|
}
|
|
31
28
|
this.setValue(payload, prop, newValue);
|
|
32
|
-
/* istanbul ignore else */
|
|
33
29
|
if (entity[prop.name]) {
|
|
34
30
|
entity[prop.name] = payload[prop.name];
|
|
35
31
|
}
|
|
36
32
|
});
|
|
37
33
|
}
|
|
38
34
|
validateRequired(entity) {
|
|
39
|
-
const wrapped =
|
|
35
|
+
const wrapped = helper(entity);
|
|
40
36
|
for (const prop of wrapped.__meta.props) {
|
|
41
37
|
if (!prop.nullable &&
|
|
42
38
|
!prop.autoincrement &&
|
|
@@ -45,47 +41,48 @@ class EntityValidator {
|
|
|
45
41
|
!prop.onCreate &&
|
|
46
42
|
!prop.generated &&
|
|
47
43
|
!prop.embedded &&
|
|
48
|
-
![
|
|
44
|
+
![ReferenceKind.ONE_TO_MANY, ReferenceKind.MANY_TO_MANY].includes(prop.kind) &&
|
|
49
45
|
prop.name !== wrapped.__meta.root.discriminatorColumn &&
|
|
50
46
|
prop.type.toLowerCase() !== 'objectid' &&
|
|
51
47
|
prop.persist !== false &&
|
|
52
48
|
entity[prop.name] == null) {
|
|
53
|
-
throw
|
|
49
|
+
throw ValidationError.propertyRequired(entity, prop);
|
|
54
50
|
}
|
|
55
51
|
}
|
|
56
52
|
}
|
|
57
53
|
validateProperty(prop, givenValue, entity) {
|
|
58
|
-
if (givenValue == null || givenValue instanceof
|
|
54
|
+
if (givenValue == null || givenValue instanceof RawQueryFragment) {
|
|
59
55
|
return givenValue;
|
|
60
56
|
}
|
|
61
57
|
const expectedType = prop.runtimeType;
|
|
62
58
|
const propName = prop.embedded ? prop.name.replace(/~/g, '.') : prop.name;
|
|
63
|
-
let givenType =
|
|
59
|
+
let givenType = Utils.getObjectType(givenValue);
|
|
64
60
|
let ret = givenValue;
|
|
65
61
|
if (!this.strict) {
|
|
66
62
|
ret = this.fixTypes(expectedType, givenType, givenValue);
|
|
67
|
-
givenType =
|
|
63
|
+
givenType = Utils.getObjectType(ret);
|
|
68
64
|
}
|
|
69
65
|
if (prop.enum && prop.items) {
|
|
66
|
+
/* v8 ignore next 3 */
|
|
70
67
|
if (!prop.items.some(it => it === givenValue)) {
|
|
71
|
-
throw
|
|
68
|
+
throw ValidationError.fromWrongPropertyType(entity, propName, expectedType, givenType, givenValue);
|
|
72
69
|
}
|
|
73
70
|
}
|
|
74
71
|
else {
|
|
75
72
|
if (givenType !== expectedType && this.KNOWN_TYPES.has(expectedType)) {
|
|
76
|
-
throw
|
|
73
|
+
throw ValidationError.fromWrongPropertyType(entity, propName, expectedType, givenType, givenValue);
|
|
77
74
|
}
|
|
78
75
|
}
|
|
79
76
|
return ret;
|
|
80
77
|
}
|
|
81
78
|
validateParams(params, type = 'search condition', field) {
|
|
82
|
-
if (
|
|
79
|
+
if (Utils.isPrimaryKey(params) || Utils.isEntity(params)) {
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
82
|
if (Array.isArray(params)) {
|
|
86
83
|
return params.forEach(item => this.validateParams(item, type, field));
|
|
87
84
|
}
|
|
88
|
-
if (
|
|
85
|
+
if (Utils.isPlainObject(params)) {
|
|
89
86
|
Object.keys(params).forEach(k => {
|
|
90
87
|
this.validateParams(params[k], type, k);
|
|
91
88
|
});
|
|
@@ -94,11 +91,11 @@ class EntityValidator {
|
|
|
94
91
|
validatePrimaryKey(entity, meta) {
|
|
95
92
|
const pkExists = meta.primaryKeys.every(pk => entity[pk] != null) || entity[meta.serializedPrimaryKey] != null;
|
|
96
93
|
if (!entity || !pkExists) {
|
|
97
|
-
throw
|
|
94
|
+
throw ValidationError.fromMergeWithoutPK(meta);
|
|
98
95
|
}
|
|
99
96
|
}
|
|
100
97
|
validateEmptyWhere(where) {
|
|
101
|
-
if (
|
|
98
|
+
if (Utils.isEmpty(where)) {
|
|
102
99
|
throw new Error(`You cannot call 'EntityManager.findOne()' with empty 'where' parameter`);
|
|
103
100
|
}
|
|
104
101
|
}
|
|
@@ -109,15 +106,15 @@ class EntityValidator {
|
|
|
109
106
|
return o[prop.name];
|
|
110
107
|
}
|
|
111
108
|
setValue(o, prop, v) {
|
|
112
|
-
/*
|
|
109
|
+
/* v8 ignore next 3 */
|
|
113
110
|
if (prop.embedded && prop.embedded[0] in o) {
|
|
114
111
|
return o[prop.embedded[0]][prop.embedded[1]] = v;
|
|
115
112
|
}
|
|
116
113
|
o[prop.name] = v;
|
|
117
114
|
}
|
|
118
115
|
validateCollection(entity, prop) {
|
|
119
|
-
if (prop.hydrate !== false &&
|
|
120
|
-
throw
|
|
116
|
+
if (prop.hydrate !== false && helper(entity).__initialized && !entity[prop.name]) {
|
|
117
|
+
throw ValidationError.fromCollectionNotInitialized(entity, prop);
|
|
121
118
|
}
|
|
122
119
|
}
|
|
123
120
|
fixTypes(expectedType, givenType, givenValue) {
|
|
@@ -134,7 +131,7 @@ class EntityValidator {
|
|
|
134
131
|
}
|
|
135
132
|
fixDateType(givenValue) {
|
|
136
133
|
let date;
|
|
137
|
-
if (
|
|
134
|
+
if (Utils.isString(givenValue) && givenValue.match(/^-?\d+(\.\d+)?$/)) {
|
|
138
135
|
date = new Date(+givenValue);
|
|
139
136
|
}
|
|
140
137
|
else {
|
|
@@ -151,4 +148,3 @@ class EntityValidator {
|
|
|
151
148
|
return +bool === givenValue ? bool : givenValue;
|
|
152
149
|
}
|
|
153
150
|
}
|
|
154
|
-
exports.EntityValidator = EntityValidator;
|
package/entity/Reference.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { inspect } from 'node:util';
|
|
2
|
-
import type { AddEager, Dictionary, EntityClass, EntityKey, EntityProperty, Loaded, LoadedReference, Primary, Ref } from '../typings';
|
|
3
|
-
import type { FindOneOptions, FindOneOrFailOptions } from '../drivers/IDatabaseDriver';
|
|
2
|
+
import type { AddEager, Dictionary, EntityClass, EntityKey, EntityProperty, Loaded, LoadedReference, Primary, Ref } from '../typings.js';
|
|
3
|
+
import type { FindOneOptions, FindOneOrFailOptions } from '../drivers/IDatabaseDriver.js';
|
|
4
4
|
export declare class Reference<T extends object> {
|
|
5
5
|
private entity;
|
|
6
6
|
constructor(entity: T);
|
package/entity/Reference.js
CHANGED
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const node_util_1 = require("node:util");
|
|
7
|
-
const enums_1 = require("../enums");
|
|
8
|
-
const wrap_1 = require("./wrap");
|
|
9
|
-
const Utils_1 = require("../utils/Utils");
|
|
10
|
-
class Reference {
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
|
+
import { DataloaderType } from '../enums.js';
|
|
3
|
+
import { helper, wrap } from './wrap.js';
|
|
4
|
+
import { Utils } from '../utils/Utils.js';
|
|
5
|
+
export class Reference {
|
|
11
6
|
entity;
|
|
12
7
|
constructor(entity) {
|
|
13
8
|
this.entity = entity;
|
|
14
9
|
this.set(entity);
|
|
15
|
-
const meta =
|
|
10
|
+
const meta = helper(this.entity).__meta;
|
|
16
11
|
meta.primaryKeys.forEach(primaryKey => {
|
|
17
12
|
Object.defineProperty(this, primaryKey, {
|
|
18
13
|
get() {
|
|
@@ -23,14 +18,14 @@ class Reference {
|
|
|
23
18
|
if (meta.serializedPrimaryKey && meta.primaryKeys[0] !== meta.serializedPrimaryKey) {
|
|
24
19
|
Object.defineProperty(this, meta.serializedPrimaryKey, {
|
|
25
20
|
get() {
|
|
26
|
-
return
|
|
21
|
+
return helper(this.entity).getSerializedPrimaryKey();
|
|
27
22
|
},
|
|
28
23
|
});
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
26
|
static create(entity) {
|
|
32
27
|
const unwrapped = Reference.unwrapReference(entity);
|
|
33
|
-
const ref =
|
|
28
|
+
const ref = helper(entity).toReference();
|
|
34
29
|
if (unwrapped !== ref.unwrap()) {
|
|
35
30
|
ref.set(unwrapped);
|
|
36
31
|
}
|
|
@@ -38,7 +33,7 @@ class Reference {
|
|
|
38
33
|
}
|
|
39
34
|
static createFromPK(entityType, pk, options) {
|
|
40
35
|
const ref = this.createNakedFromPK(entityType, pk, options);
|
|
41
|
-
return
|
|
36
|
+
return helper(ref).toReference();
|
|
42
37
|
}
|
|
43
38
|
static createNakedFromPK(entityType, pk, options) {
|
|
44
39
|
const factory = entityType.prototype.__factory;
|
|
@@ -47,7 +42,7 @@ class Reference {
|
|
|
47
42
|
convertCustomTypes: false,
|
|
48
43
|
...options,
|
|
49
44
|
});
|
|
50
|
-
const wrapped =
|
|
45
|
+
const wrapped = helper(entity);
|
|
51
46
|
wrapped.__meta.primaryKeys.forEach(key => wrapped.__loadedProperties.add(key));
|
|
52
47
|
wrapped.__originalEntityData = factory.getComparator().prepareEntity(entity);
|
|
53
48
|
return entity;
|
|
@@ -79,7 +74,7 @@ class Reference {
|
|
|
79
74
|
* the method returns `null`. Use `loadOrFail()` if you want an error to be thrown in such a case.
|
|
80
75
|
*/
|
|
81
76
|
async load(options = {}) {
|
|
82
|
-
const wrapped =
|
|
77
|
+
const wrapped = helper(this.entity);
|
|
83
78
|
if (!wrapped.__em) {
|
|
84
79
|
return this.entity;
|
|
85
80
|
}
|
|
@@ -87,7 +82,7 @@ class Reference {
|
|
|
87
82
|
await wrapped.__em.populate(this.entity, options.populate, options);
|
|
88
83
|
}
|
|
89
84
|
if (!this.isInitialized() || options.refresh) {
|
|
90
|
-
if (options.dataloader ?? [
|
|
85
|
+
if (options.dataloader ?? [DataloaderType.ALL, DataloaderType.REFERENCE].includes(wrapped.__em.config.getDataloaderType())) {
|
|
91
86
|
// eslint-disable-next-line dot-notation
|
|
92
87
|
return wrapped.__em['refLoader'].load([this, options]);
|
|
93
88
|
}
|
|
@@ -102,7 +97,7 @@ class Reference {
|
|
|
102
97
|
async loadOrFail(options = {}) {
|
|
103
98
|
const ret = await this.load(options);
|
|
104
99
|
if (!ret) {
|
|
105
|
-
const wrapped =
|
|
100
|
+
const wrapped = helper(this.entity);
|
|
106
101
|
options.failHandler ??= wrapped.__em.config.get('findOneOrFailHandler');
|
|
107
102
|
const entityName = this.entity.constructor.name;
|
|
108
103
|
const where = wrapped.getPrimaryKey();
|
|
@@ -112,14 +107,14 @@ class Reference {
|
|
|
112
107
|
}
|
|
113
108
|
set(entity) {
|
|
114
109
|
this.entity = Reference.unwrapReference(entity);
|
|
115
|
-
delete
|
|
110
|
+
delete helper(this.entity).__reference;
|
|
116
111
|
}
|
|
117
112
|
unwrap() {
|
|
118
113
|
return this.entity;
|
|
119
114
|
}
|
|
120
115
|
getEntity() {
|
|
121
116
|
if (!this.isInitialized()) {
|
|
122
|
-
throw new Error(`Reference<${
|
|
117
|
+
throw new Error(`Reference<${helper(this.entity).__meta.name}> ${helper(this.entity).getPrimaryKey()} not initialized`);
|
|
123
118
|
}
|
|
124
119
|
return this.entity;
|
|
125
120
|
}
|
|
@@ -131,31 +126,29 @@ class Reference {
|
|
|
131
126
|
return this.getEntity()[prop];
|
|
132
127
|
}
|
|
133
128
|
isInitialized() {
|
|
134
|
-
return
|
|
129
|
+
return helper(this.entity).__initialized;
|
|
135
130
|
}
|
|
136
131
|
populated(populated) {
|
|
137
|
-
|
|
132
|
+
helper(this.entity).populated(populated);
|
|
138
133
|
}
|
|
139
134
|
toJSON(...args) {
|
|
140
|
-
return
|
|
135
|
+
return wrap(this.entity).toJSON(...args);
|
|
141
136
|
}
|
|
142
|
-
/* istanbul ignore next */
|
|
143
137
|
/** @ignore */
|
|
144
|
-
[
|
|
138
|
+
[inspect.custom](depth = 2) {
|
|
145
139
|
const object = { ...this };
|
|
146
140
|
const hidden = ['meta'];
|
|
147
141
|
hidden.forEach(k => delete object[k]);
|
|
148
|
-
const ret =
|
|
149
|
-
const wrapped =
|
|
142
|
+
const ret = inspect(object, { depth });
|
|
143
|
+
const wrapped = helper(this.entity);
|
|
150
144
|
const meta = wrapped.__meta;
|
|
145
|
+
/* v8 ignore next */
|
|
151
146
|
const pk = wrapped.hasPrimaryKey() ? '<' + wrapped.getSerializedPrimaryKey() + '>' : '';
|
|
152
147
|
const name = `Ref<${meta.className}${pk}>`;
|
|
153
148
|
return ret === '[Object]' ? `[${name}]` : name + ' ' + ret;
|
|
154
149
|
}
|
|
155
150
|
}
|
|
156
|
-
|
|
157
|
-
exports.Ref = Reference;
|
|
158
|
-
class ScalarReference {
|
|
151
|
+
export class ScalarReference {
|
|
159
152
|
value;
|
|
160
153
|
initialized;
|
|
161
154
|
entity;
|
|
@@ -174,7 +167,7 @@ class ScalarReference {
|
|
|
174
167
|
if (this.entity == null || this.property == null) {
|
|
175
168
|
throw new Error('Cannot load scalar reference that is not bound to an entity property.');
|
|
176
169
|
}
|
|
177
|
-
await
|
|
170
|
+
await helper(this.entity).populate([this.property], opts);
|
|
178
171
|
}
|
|
179
172
|
return this.value;
|
|
180
173
|
}
|
|
@@ -193,13 +186,12 @@ class ScalarReference {
|
|
|
193
186
|
isInitialized() {
|
|
194
187
|
return this.initialized;
|
|
195
188
|
}
|
|
196
|
-
/*
|
|
189
|
+
/* v8 ignore next 4 */
|
|
197
190
|
/** @ignore */
|
|
198
|
-
[
|
|
199
|
-
return this.initialized ? `Ref<${
|
|
191
|
+
[inspect.custom]() {
|
|
192
|
+
return this.initialized ? `Ref<${inspect(this.value)}>` : `Ref<?>`;
|
|
200
193
|
}
|
|
201
194
|
}
|
|
202
|
-
exports.ScalarReference = ScalarReference;
|
|
203
195
|
Object.defineProperties(Reference.prototype, {
|
|
204
196
|
__reference: { value: true, enumerable: false },
|
|
205
197
|
__meta: { get() { return this.entity.__meta; } },
|
|
@@ -216,15 +208,15 @@ Object.defineProperties(ScalarReference.prototype, {
|
|
|
216
208
|
/**
|
|
217
209
|
* shortcut for `wrap(entity).toReference()`
|
|
218
210
|
*/
|
|
219
|
-
function ref(entityOrType, pk) {
|
|
211
|
+
export function ref(entityOrType, pk) {
|
|
220
212
|
if (entityOrType == null) {
|
|
221
213
|
return entityOrType;
|
|
222
214
|
}
|
|
223
|
-
if (
|
|
224
|
-
return
|
|
215
|
+
if (Utils.isEntity(entityOrType, true)) {
|
|
216
|
+
return helper(entityOrType).toReference();
|
|
225
217
|
}
|
|
226
|
-
if (
|
|
227
|
-
return
|
|
218
|
+
if (Utils.isEntity(pk, true)) {
|
|
219
|
+
return helper(pk).toReference();
|
|
228
220
|
}
|
|
229
221
|
if (arguments.length === 1) {
|
|
230
222
|
return new ScalarReference(entityOrType, true);
|
|
@@ -237,9 +229,10 @@ function ref(entityOrType, pk) {
|
|
|
237
229
|
/**
|
|
238
230
|
* shortcut for `Reference.createNakedFromPK(entityType, pk)`
|
|
239
231
|
*/
|
|
240
|
-
function rel(entityType, pk) {
|
|
241
|
-
if (pk == null ||
|
|
232
|
+
export function rel(entityType, pk) {
|
|
233
|
+
if (pk == null || Utils.isEntity(pk)) {
|
|
242
234
|
return pk;
|
|
243
235
|
}
|
|
244
236
|
return Reference.createNakedFromPK(entityType, pk);
|
|
245
237
|
}
|
|
238
|
+
export { Reference as Ref };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type { PopulatePath } from '../enums';
|
|
1
|
+
import type { PopulatePath } from '../enums.js';
|
|
2
2
|
import { inspect } from 'node:util';
|
|
3
|
-
import type { EntityManager } from '../EntityManager';
|
|
4
|
-
import type { Dictionary, EntityData, EntityDictionary, EntityMetadata, IHydrator, EntityKey, PopulateOptions, Primary, AutoPath, Ref, AddEager, LoadedReference, EntityDTO, Loaded, FromEntityType, IsSubset, MergeSelected } from '../typings';
|
|
5
|
-
import { Reference } from './Reference';
|
|
6
|
-
import { type AssignOptions } from './EntityAssigner';
|
|
7
|
-
import type { EntityLoaderOptions } from './EntityLoader';
|
|
8
|
-
import type { EntityIdentifier } from './EntityIdentifier';
|
|
9
|
-
import type { SerializationContext } from '../serialization/SerializationContext';
|
|
10
|
-
import { type SerializeOptions } from '../serialization/EntitySerializer';
|
|
11
|
-
import type { FindOneOptions, LoadHint } from '../drivers/IDatabaseDriver';
|
|
3
|
+
import type { EntityManager } from '../EntityManager.js';
|
|
4
|
+
import type { Dictionary, EntityData, EntityDictionary, EntityMetadata, IHydrator, EntityKey, PopulateOptions, Primary, AutoPath, Ref, AddEager, LoadedReference, EntityDTO, Loaded, FromEntityType, IsSubset, MergeSelected } from '../typings.js';
|
|
5
|
+
import { Reference } from './Reference.js';
|
|
6
|
+
import { type AssignOptions } from './EntityAssigner.js';
|
|
7
|
+
import type { EntityLoaderOptions } from './EntityLoader.js';
|
|
8
|
+
import type { EntityIdentifier } from './EntityIdentifier.js';
|
|
9
|
+
import type { SerializationContext } from '../serialization/SerializationContext.js';
|
|
10
|
+
import { type SerializeOptions } from '../serialization/EntitySerializer.js';
|
|
11
|
+
import type { FindOneOptions, LoadHint } from '../drivers/IDatabaseDriver.js';
|
|
12
12
|
export declare class WrappedEntity<Entity extends object> {
|
|
13
13
|
__initialized: boolean;
|
|
14
14
|
__touched: boolean;
|
|
@@ -61,8 +61,8 @@ export declare class WrappedEntity<Entity extends object> {
|
|
|
61
61
|
setPrimaryKey(id: Primary<Entity> | null): void;
|
|
62
62
|
getSerializedPrimaryKey(): string;
|
|
63
63
|
get __meta(): EntityMetadata<Entity>;
|
|
64
|
-
get __platform(): import("
|
|
65
|
-
get __config(): import("
|
|
64
|
+
get __platform(): import("../index.js").Platform;
|
|
65
|
+
get __config(): import("../index.js").Configuration<import("../drivers/IDatabaseDriver.js").IDatabaseDriver<import("../index.js").Connection>, EntityManager<import("../drivers/IDatabaseDriver.js").IDatabaseDriver<import("../index.js").Connection>>>;
|
|
66
66
|
get __primaryKeys(): Primary<Entity>[];
|
|
67
67
|
/** @ignore */
|
|
68
68
|
[inspect.custom](): string;
|
package/entity/WrappedEntity.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const EntitySerializer_1 = require("../serialization/EntitySerializer");
|
|
12
|
-
const utils_1 = require("./utils");
|
|
13
|
-
class WrappedEntity {
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
|
+
import { Reference } from './Reference.js';
|
|
3
|
+
import { EntityTransformer } from '../serialization/EntityTransformer.js';
|
|
4
|
+
import { EntityAssigner } from './EntityAssigner.js';
|
|
5
|
+
import { Utils } from '../utils/Utils.js';
|
|
6
|
+
import { ValidationError } from '../errors.js';
|
|
7
|
+
import { helper } from './wrap.js';
|
|
8
|
+
import { EntitySerializer } from '../serialization/EntitySerializer.js';
|
|
9
|
+
import { expandDotPaths } from './utils.js';
|
|
10
|
+
export class WrappedEntity {
|
|
14
11
|
constructor(entity, hydrator, pkGetter, pkSerializer, pkGetterConverted) {
|
|
15
12
|
this.entity = entity;
|
|
16
13
|
this.hydrator = hydrator;
|
|
@@ -39,7 +36,7 @@ class WrappedEntity {
|
|
|
39
36
|
setSerializationContext(options) {
|
|
40
37
|
const exclude = options.exclude ?? [];
|
|
41
38
|
const context = this.__serializationContext;
|
|
42
|
-
const populate =
|
|
39
|
+
const populate = expandDotPaths(this.__meta, options.populate);
|
|
43
40
|
context.populate = context.populate ? context.populate.concat(populate) : populate;
|
|
44
41
|
context.exclude = context.exclude ? context.exclude.concat(exclude) : exclude;
|
|
45
42
|
if (context.fields && options.fields) {
|
|
@@ -53,17 +50,17 @@ class WrappedEntity {
|
|
|
53
50
|
}
|
|
54
51
|
}
|
|
55
52
|
toReference() {
|
|
56
|
-
this.__reference ??= new
|
|
53
|
+
this.__reference ??= new Reference(this.entity);
|
|
57
54
|
return this.__reference;
|
|
58
55
|
}
|
|
59
56
|
toObject(ignoreFields) {
|
|
60
|
-
return
|
|
57
|
+
return EntityTransformer.toObject(this.entity, ignoreFields);
|
|
61
58
|
}
|
|
62
59
|
serialize(options) {
|
|
63
|
-
return
|
|
60
|
+
return EntitySerializer.serialize(this.entity, options);
|
|
64
61
|
}
|
|
65
62
|
toPOJO() {
|
|
66
|
-
return
|
|
63
|
+
return EntityTransformer.toObject(this.entity, [], true);
|
|
67
64
|
}
|
|
68
65
|
toJSON(...args) {
|
|
69
66
|
// toJSON methods is added to the prototype during discovery to support automatic serialization via JSON.stringify()
|
|
@@ -73,17 +70,17 @@ class WrappedEntity {
|
|
|
73
70
|
if ('assign' in this.entity) {
|
|
74
71
|
return this.entity.assign(data, options);
|
|
75
72
|
}
|
|
76
|
-
return
|
|
73
|
+
return EntityAssigner.assign(this.entity, data, options);
|
|
77
74
|
}
|
|
78
75
|
async init(options) {
|
|
79
76
|
if (!this.__em) {
|
|
80
|
-
throw
|
|
77
|
+
throw ValidationError.entityNotManaged(this.entity);
|
|
81
78
|
}
|
|
82
79
|
return this.__em.findOne(this.entity.constructor.name, this.entity, { ...options, refresh: true, schema: this.__schema });
|
|
83
80
|
}
|
|
84
81
|
async populate(populate, options = {}) {
|
|
85
82
|
if (!this.__em) {
|
|
86
|
-
throw
|
|
83
|
+
throw ValidationError.entityNotManaged(this.entity);
|
|
87
84
|
}
|
|
88
85
|
// @ts-ignore hard to type
|
|
89
86
|
await this.__em.populate(this.entity, populate, options);
|
|
@@ -99,7 +96,7 @@ class WrappedEntity {
|
|
|
99
96
|
return null;
|
|
100
97
|
}
|
|
101
98
|
if (this.__pk != null && this.__meta.compositePK) {
|
|
102
|
-
return
|
|
99
|
+
return Utils.getCompositeKeyValue(this.__pk, this.__meta, convertCustomTypes ? 'convertToDatabaseValue' : false, this.__platform);
|
|
103
100
|
}
|
|
104
101
|
if (convertCustomTypes && this.__pk != null && prop.customType) {
|
|
105
102
|
return prop.customType.convertToDatabaseValue(this.__pk, this.__platform);
|
|
@@ -118,8 +115,8 @@ class WrappedEntity {
|
|
|
118
115
|
if (this.__meta.compositePK) {
|
|
119
116
|
return this.__meta.primaryKeys.reduce((ret, pk) => {
|
|
120
117
|
const child = this.entity[pk];
|
|
121
|
-
if (
|
|
122
|
-
const childPk =
|
|
118
|
+
if (Utils.isEntity(child, true)) {
|
|
119
|
+
const childPk = helper(child).getPrimaryKeys(convertCustomTypes);
|
|
123
120
|
ret.push(...childPk);
|
|
124
121
|
}
|
|
125
122
|
else {
|
|
@@ -153,11 +150,10 @@ class WrappedEntity {
|
|
|
153
150
|
return this.__em?.config ?? this.entity.__config;
|
|
154
151
|
}
|
|
155
152
|
get __primaryKeys() {
|
|
156
|
-
return
|
|
153
|
+
return Utils.getPrimaryKeyValues(this.entity, this.__meta.primaryKeys);
|
|
157
154
|
}
|
|
158
155
|
/** @ignore */
|
|
159
|
-
[
|
|
156
|
+
[inspect.custom]() {
|
|
160
157
|
return `[WrappedEntity<${this.__meta.className}>]`;
|
|
161
158
|
}
|
|
162
159
|
}
|
|
163
|
-
exports.WrappedEntity = WrappedEntity;
|
package/entity/index.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export * from './EntityRepository';
|
|
2
|
-
export * from './EntityIdentifier';
|
|
3
|
-
export * from './EntityValidator';
|
|
4
|
-
export * from './EntityAssigner';
|
|
5
|
-
export * from './EntityHelper';
|
|
6
|
-
export * from './EntityFactory';
|
|
7
|
-
export * from './ArrayCollection';
|
|
8
|
-
export * from './Collection';
|
|
9
|
-
export * from './EntityLoader';
|
|
10
|
-
export * from './Reference';
|
|
11
|
-
export * from './BaseEntity';
|
|
12
|
-
export * from './WrappedEntity';
|
|
13
|
-
export * from './wrap';
|
|
1
|
+
export * from './EntityRepository.js';
|
|
2
|
+
export * from './EntityIdentifier.js';
|
|
3
|
+
export * from './EntityValidator.js';
|
|
4
|
+
export * from './EntityAssigner.js';
|
|
5
|
+
export * from './EntityHelper.js';
|
|
6
|
+
export * from './EntityFactory.js';
|
|
7
|
+
export * from './ArrayCollection.js';
|
|
8
|
+
export * from './Collection.js';
|
|
9
|
+
export * from './EntityLoader.js';
|
|
10
|
+
export * from './Reference.js';
|
|
11
|
+
export * from './BaseEntity.js';
|
|
12
|
+
export * from './WrappedEntity.js';
|
|
13
|
+
export * from './wrap.js';
|
package/entity/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("./EntityRepository"), exports);
|
|
18
|
-
__exportStar(require("./EntityIdentifier"), exports);
|
|
19
|
-
__exportStar(require("./EntityValidator"), exports);
|
|
20
|
-
__exportStar(require("./EntityAssigner"), exports);
|
|
21
|
-
__exportStar(require("./EntityHelper"), exports);
|
|
22
|
-
__exportStar(require("./EntityFactory"), exports);
|
|
23
|
-
__exportStar(require("./ArrayCollection"), exports);
|
|
24
|
-
__exportStar(require("./Collection"), exports);
|
|
25
|
-
__exportStar(require("./EntityLoader"), exports);
|
|
26
|
-
__exportStar(require("./Reference"), exports);
|
|
27
|
-
__exportStar(require("./BaseEntity"), exports);
|
|
28
|
-
__exportStar(require("./WrappedEntity"), exports);
|
|
29
|
-
__exportStar(require("./wrap"), exports);
|
|
1
|
+
export * from './EntityRepository.js';
|
|
2
|
+
export * from './EntityIdentifier.js';
|
|
3
|
+
export * from './EntityValidator.js';
|
|
4
|
+
export * from './EntityAssigner.js';
|
|
5
|
+
export * from './EntityHelper.js';
|
|
6
|
+
export * from './EntityFactory.js';
|
|
7
|
+
export * from './ArrayCollection.js';
|
|
8
|
+
export * from './Collection.js';
|
|
9
|
+
export * from './EntityLoader.js';
|
|
10
|
+
export * from './Reference.js';
|
|
11
|
+
export * from './BaseEntity.js';
|
|
12
|
+
export * from './WrappedEntity.js';
|
|
13
|
+
export * from './wrap.js';
|
package/entity/utils.d.ts
CHANGED
package/entity/utils.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.expandDotPaths = expandDotPaths;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const core_1 = require("@mikro-orm/core");
|
|
1
|
+
import { PopulatePath, ReferenceKind } from '../enums.js';
|
|
2
|
+
import { Utils } from '@mikro-orm/core';
|
|
6
3
|
/**
|
|
7
4
|
* Expands `books.perex` like populate to use `children` array instead of the dot syntax
|
|
8
5
|
*/
|
|
@@ -19,13 +16,13 @@ function expandNestedPopulate(parentProp, parts, strategy, all) {
|
|
|
19
16
|
/**
|
|
20
17
|
* @internal
|
|
21
18
|
*/
|
|
22
|
-
function expandDotPaths(meta, populate, normalized = false) {
|
|
23
|
-
const ret = normalized ? populate :
|
|
19
|
+
export function expandDotPaths(meta, populate, normalized = false) {
|
|
20
|
+
const ret = normalized ? populate : Utils.asArray(populate).map(field => {
|
|
24
21
|
if (typeof field === 'string') {
|
|
25
22
|
return { field };
|
|
26
23
|
}
|
|
27
|
-
/*
|
|
28
|
-
return typeof field === 'boolean' || field.field ===
|
|
24
|
+
/* v8 ignore next 3 */
|
|
25
|
+
return typeof field === 'boolean' || field.field === PopulatePath.ALL
|
|
29
26
|
? { all: !!field, field: meta.primaryKeys[0] }
|
|
30
27
|
: field;
|
|
31
28
|
});
|
|
@@ -38,12 +35,12 @@ function expandDotPaths(meta, populate, normalized = false) {
|
|
|
38
35
|
p.children ??= [];
|
|
39
36
|
const prop = meta.properties[p.field];
|
|
40
37
|
p.strategy ??= prop.strategy;
|
|
41
|
-
if (parts[0] ===
|
|
38
|
+
if (parts[0] === PopulatePath.ALL) {
|
|
42
39
|
prop.targetMeta.props
|
|
43
|
-
.filter(prop => prop.lazy || prop.kind !==
|
|
40
|
+
.filter(prop => prop.lazy || prop.kind !== ReferenceKind.SCALAR)
|
|
44
41
|
.forEach(prop => p.children.push({ field: prop.name, strategy: p.strategy }));
|
|
45
42
|
}
|
|
46
|
-
else if (prop.kind ===
|
|
43
|
+
else if (prop.kind === ReferenceKind.EMBEDDED) {
|
|
47
44
|
const embeddedProp = Object.values(prop.embeddedProps).find(c => c.embedded[1] === parts[0]);
|
|
48
45
|
ret.push({
|
|
49
46
|
...p,
|
package/entity/wrap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IWrappedEntity, IWrappedEntityInternal } from '../typings';
|
|
1
|
+
import type { IWrappedEntity, IWrappedEntityInternal } from '../typings.js';
|
|
2
2
|
/**
|
|
3
3
|
* returns WrappedEntity instance associated with this entity. This includes all the internal properties like `__meta` or `__em`.
|
|
4
4
|
*/
|