@itrocks/lazy-loading 0.2.3 → 0.2.5
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/cjs/lazy-loading.js +6 -4
- package/package.json +2 -1
package/cjs/lazy-loading.js
CHANGED
|
@@ -4,6 +4,7 @@ exports.PROTECT_GET = void 0;
|
|
|
4
4
|
exports.initClass = initClass;
|
|
5
5
|
exports.initLazyLoading = initLazyLoading;
|
|
6
6
|
const class_type_1 = require("@itrocks/class-type");
|
|
7
|
+
const class_type_2 = require("@itrocks/class-type");
|
|
7
8
|
const property_1 = require("@itrocks/decorator/property");
|
|
8
9
|
const property_type_1 = require("@itrocks/property-type");
|
|
9
10
|
const property_type_2 = require("@itrocks/property-type");
|
|
@@ -38,12 +39,13 @@ function defineCollectionProperty(elementType, property, builtClass) {
|
|
|
38
39
|
function defineObjectProperty(type, property, builtClass) {
|
|
39
40
|
const metadataName = (0, property_1.metadataNameOf)(property);
|
|
40
41
|
const propertyId = property.toString() + 'Id';
|
|
42
|
+
const readType = (type === (0, class_type_1.baseType)(builtClass)) ? builtClass : type;
|
|
41
43
|
const descriptor = {
|
|
42
44
|
configurable: true,
|
|
43
45
|
enumerable: true,
|
|
44
46
|
async get() {
|
|
45
47
|
const id = this[propertyId];
|
|
46
|
-
return this[property] = id ? await (0, storage_1.dataSource)().read(
|
|
48
|
+
return this[property] = id ? await (0, storage_1.dataSource)().read(readType, id) : undefined;
|
|
47
49
|
},
|
|
48
50
|
set(value) {
|
|
49
51
|
delete this[propertyId];
|
|
@@ -57,7 +59,7 @@ function defineObjectProperty(type, property, builtClass) {
|
|
|
57
59
|
}
|
|
58
60
|
function defineCollectionPropertyAction(BuiltClass, properties, property) {
|
|
59
61
|
const type = property.collectionType.elementType.lead;
|
|
60
|
-
if ((0,
|
|
62
|
+
if ((0, class_type_2.isAnyType)(type)) {
|
|
61
63
|
properties.push(defineCollectionProperty(type, property.name, BuiltClass));
|
|
62
64
|
return true;
|
|
63
65
|
}
|
|
@@ -65,7 +67,7 @@ function defineCollectionPropertyAction(BuiltClass, properties, property) {
|
|
|
65
67
|
}
|
|
66
68
|
function defineObjectPropertyAction(BuiltClass, properties, property) {
|
|
67
69
|
const type = property.type.lead;
|
|
68
|
-
if ((0,
|
|
70
|
+
if ((0, class_type_2.isAnyType)(type)) {
|
|
69
71
|
properties.push(defineObjectProperty(type, property.name, BuiltClass));
|
|
70
72
|
return true;
|
|
71
73
|
}
|
|
@@ -132,7 +134,7 @@ function initLazyLoading() {
|
|
|
132
134
|
defer = (defer === undefined)
|
|
133
135
|
? (type === undefined)
|
|
134
136
|
: (defer && (type === undefined));
|
|
135
|
-
if (!(0,
|
|
137
|
+
if (!(0, class_type_2.isAnyType)(type))
|
|
136
138
|
continue;
|
|
137
139
|
if (module && replacements) {
|
|
138
140
|
const replacement = replacements.get(type);
|
package/package.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@itrocks/class-type": "latest",
|
|
8
|
+
"@itrocks/decorator": "latest",
|
|
8
9
|
"@itrocks/property-type": "latest",
|
|
9
10
|
"@itrocks/reflect": "latest",
|
|
10
11
|
"@itrocks/storage": "latest",
|
|
@@ -49,5 +50,5 @@
|
|
|
49
50
|
"scripts": {
|
|
50
51
|
"build": "tsc"
|
|
51
52
|
},
|
|
52
|
-
"version": "0.2.
|
|
53
|
+
"version": "0.2.5"
|
|
53
54
|
}
|