framework-do-dede 3.0.31 → 3.0.32
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/README.md +15 -15
- package/dist/application/entity.js +34 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# Framework do Dedé
|
|
2
|
-
|
|
3
|
-
To install dependencies:
|
|
4
|
-
|
|
5
|
-
```bash
|
|
6
|
-
bun install
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
To run:
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
bun run index.ts
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
This project was created using `bun init` in bun v1.1.42. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
1
|
+
# Framework do Dedé
|
|
2
|
+
|
|
3
|
+
To install dependencies:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
bun install
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
To run:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
bun run index.ts
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
This project was created using `bun init` in bun v1.1.42. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
|
|
@@ -4,16 +4,31 @@ export class Entity {
|
|
|
4
4
|
const propertiesConfigs = this.constructor.propertiesConfigs;
|
|
5
5
|
const result = {};
|
|
6
6
|
for (const [propName] of Object.entries(this)) {
|
|
7
|
+
let propertyName = propName;
|
|
7
8
|
let value = this[propName];
|
|
8
9
|
if (typeof value === 'function')
|
|
9
10
|
continue;
|
|
11
|
+
if (value === undefined)
|
|
12
|
+
continue;
|
|
10
13
|
// @ts-ignore
|
|
11
14
|
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
12
|
-
|
|
15
|
+
const serializedValue = propertiesConfigs[propName].serialize(value);
|
|
16
|
+
if (serializedValue && typeof serializedValue === 'object' && !Array.isArray(serializedValue)) {
|
|
17
|
+
const entries = Object.entries(serializedValue);
|
|
18
|
+
if (entries.length === 1) {
|
|
19
|
+
[propertyName, value] = entries[0];
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
value = serializedValue;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
value = serializedValue;
|
|
27
|
+
}
|
|
13
28
|
}
|
|
14
29
|
if (!value)
|
|
15
30
|
value = null;
|
|
16
|
-
result[
|
|
31
|
+
result[propertyName] = value;
|
|
17
32
|
}
|
|
18
33
|
return result;
|
|
19
34
|
}
|
|
@@ -22,16 +37,31 @@ export class Entity {
|
|
|
22
37
|
const propertiesConfigs = this.constructor.propertiesConfigs;
|
|
23
38
|
const result = {};
|
|
24
39
|
for (const [propName] of Object.entries(this)) {
|
|
40
|
+
let propertyName = propName;
|
|
25
41
|
let value = this[propName];
|
|
26
42
|
if (typeof value === 'function')
|
|
27
43
|
continue;
|
|
44
|
+
if (value === undefined)
|
|
45
|
+
continue;
|
|
28
46
|
// @ts-ignore
|
|
29
47
|
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
30
|
-
|
|
48
|
+
const serializedValue = await propertiesConfigs[propName].serialize(value);
|
|
49
|
+
if (serializedValue && typeof serializedValue === 'object' && !Array.isArray(serializedValue)) {
|
|
50
|
+
const entries = Object.entries(serializedValue);
|
|
51
|
+
if (entries.length === 1) {
|
|
52
|
+
[propertyName, value] = entries[0];
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
value = serializedValue;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
value = serializedValue;
|
|
60
|
+
}
|
|
31
61
|
}
|
|
32
62
|
if (!value)
|
|
33
63
|
value = null;
|
|
34
|
-
result[
|
|
64
|
+
result[propertyName] = value;
|
|
35
65
|
}
|
|
36
66
|
return result;
|
|
37
67
|
}
|