framework-do-dede 3.0.32 → 3.0.34
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 +18 -14
- 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.
|
|
@@ -10,23 +10,25 @@ export class Entity {
|
|
|
10
10
|
continue;
|
|
11
11
|
if (value === undefined)
|
|
12
12
|
continue;
|
|
13
|
+
const valueIsZero = !isNaN(value) ? Number(value) === 0 : false;
|
|
13
14
|
// @ts-ignore
|
|
14
|
-
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && value) {
|
|
15
|
+
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && (value || valueIsZero)) {
|
|
15
16
|
const serializedValue = propertiesConfigs[propName].serialize(value);
|
|
16
17
|
if (serializedValue && typeof serializedValue === 'object' && !Array.isArray(serializedValue)) {
|
|
17
18
|
const entries = Object.entries(serializedValue);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
19
|
+
for (const [serializedKey, serializedPropValue] of entries) {
|
|
20
|
+
let currentValue = serializedPropValue;
|
|
21
|
+
if (!currentValue)
|
|
22
|
+
currentValue = null;
|
|
23
|
+
result[serializedKey] = currentValue;
|
|
23
24
|
}
|
|
25
|
+
continue;
|
|
24
26
|
}
|
|
25
27
|
else {
|
|
26
28
|
value = serializedValue;
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
|
-
if (!value)
|
|
31
|
+
if (!value && !valueIsZero)
|
|
30
32
|
value = null;
|
|
31
33
|
result[propertyName] = value;
|
|
32
34
|
}
|
|
@@ -44,22 +46,24 @@ export class Entity {
|
|
|
44
46
|
if (value === undefined)
|
|
45
47
|
continue;
|
|
46
48
|
// @ts-ignore
|
|
47
|
-
|
|
49
|
+
const valueIsZero = !isNaN(value) ? Number(value) === 0 : false;
|
|
50
|
+
if (propertiesConfigs && propertiesConfigs[propName]?.serialize && (value || valueIsZero)) {
|
|
48
51
|
const serializedValue = await propertiesConfigs[propName].serialize(value);
|
|
49
52
|
if (serializedValue && typeof serializedValue === 'object' && !Array.isArray(serializedValue)) {
|
|
50
53
|
const entries = Object.entries(serializedValue);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
for (const [serializedKey, serializedPropValue] of entries) {
|
|
55
|
+
let currentValue = serializedPropValue;
|
|
56
|
+
if (!currentValue)
|
|
57
|
+
currentValue = null;
|
|
58
|
+
result[serializedKey] = currentValue;
|
|
56
59
|
}
|
|
60
|
+
continue;
|
|
57
61
|
}
|
|
58
62
|
else {
|
|
59
63
|
value = serializedValue;
|
|
60
64
|
}
|
|
61
65
|
}
|
|
62
|
-
if (!value)
|
|
66
|
+
if (!value && !valueIsZero)
|
|
63
67
|
value = null;
|
|
64
68
|
result[propertyName] = value;
|
|
65
69
|
}
|