framework-do-dede 3.0.18 → 3.0.20
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/dist/application/entity.js +22 -11
- package/package.json +1 -1
|
@@ -7,7 +7,7 @@ export class Entity {
|
|
|
7
7
|
let value = this[propName];
|
|
8
8
|
if (typeof value === 'function')
|
|
9
9
|
continue;
|
|
10
|
-
if (propertiesConfigs[propName]?.serialize && value) {
|
|
10
|
+
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
11
11
|
value = propertiesConfigs[propName].serialize(value);
|
|
12
12
|
}
|
|
13
13
|
if (!value)
|
|
@@ -24,7 +24,7 @@ export class Entity {
|
|
|
24
24
|
let value = this[propName];
|
|
25
25
|
if (typeof value === 'function')
|
|
26
26
|
continue;
|
|
27
|
-
if (propertiesConfigs[propName]?.serialize && value) {
|
|
27
|
+
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
28
28
|
value = await propertiesConfigs[propName].serialize(value);
|
|
29
29
|
}
|
|
30
30
|
if (!value)
|
|
@@ -40,12 +40,12 @@ export class Entity {
|
|
|
40
40
|
const virtualProperties = this.constructor.virtualProperties;
|
|
41
41
|
const result = {};
|
|
42
42
|
for (const [propName] of Object.entries(this)) {
|
|
43
|
-
if (propertiesConfigs[propName]?.restrict)
|
|
43
|
+
if (propertiesConfigs && propertiesConfigs[propName]?.restrict)
|
|
44
44
|
continue;
|
|
45
45
|
if (typeof this[propName] === 'function')
|
|
46
46
|
continue;
|
|
47
47
|
let value = this[propName];
|
|
48
|
-
if (serialize && propertiesConfigs[propName]?.serialize && value) {
|
|
48
|
+
if (serialize && propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
49
49
|
value = propertiesConfigs[propName].serialize(value);
|
|
50
50
|
}
|
|
51
51
|
result[propName] = value;
|
|
@@ -68,10 +68,10 @@ export class Entity {
|
|
|
68
68
|
for (const [propName] of Object.entries(this)) {
|
|
69
69
|
if (typeof this[propName] === 'function')
|
|
70
70
|
continue;
|
|
71
|
-
if (propertiesConfigs[propName]?.restrict)
|
|
71
|
+
if (propertiesConfigs && propertiesConfigs[propName]?.restrict)
|
|
72
72
|
continue;
|
|
73
73
|
let value = this[propName];
|
|
74
|
-
if (serialize && propertiesConfigs[propName]?.serialize && value) {
|
|
74
|
+
if (serialize && propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
75
75
|
value = await propertiesConfigs[propName].serialize(value);
|
|
76
76
|
}
|
|
77
77
|
result[propName] = value;
|
|
@@ -96,12 +96,23 @@ export class Entity {
|
|
|
96
96
|
this[`get${property[0].toUpperCase()}${property.slice(1)}`] = () => this[property];
|
|
97
97
|
continue;
|
|
98
98
|
}
|
|
99
|
+
let prefixName = null;
|
|
99
100
|
// @ts-ignore
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
101
|
+
if (this.constructor.propertiesConfigs && this.constructor.propertiesConfigs[property] && this.constructor.propertiesConfigs[property].prefix) {
|
|
102
|
+
// @ts-ignore
|
|
103
|
+
prefixName = this.constructor.propertiesConfigs[property].prefix;
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
const isBoolean = this[property] ? typeof this[property] === 'boolean' : false;
|
|
107
|
+
prefixName = isBoolean ? 'is' : 'get';
|
|
108
|
+
}
|
|
109
|
+
let getterName = null;
|
|
110
|
+
if (property[0]) {
|
|
111
|
+
getterName = `${prefixName}${property[0].toUpperCase()}${property.slice(1)}`;
|
|
112
|
+
if (this[getterName])
|
|
113
|
+
continue;
|
|
114
|
+
this[getterName] = () => this[property];
|
|
115
|
+
}
|
|
105
116
|
}
|
|
106
117
|
}
|
|
107
118
|
constructor() {
|