@gugananuvem/aws-local-simulator 1.0.19 → 1.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gugananuvem/aws-local-simulator",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "Simulador local completo para serviços AWS",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -120,6 +120,6 @@
|
|
|
120
120
|
"optional": true
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
|
-
"buildDate": "2026-04-
|
|
123
|
+
"buildDate": "2026-04-22T02:31:17.105Z",
|
|
124
124
|
"published": true
|
|
125
125
|
}
|
|
@@ -550,39 +550,53 @@ class DynamoDBSimulator {
|
|
|
550
550
|
normalizeItem(item, table) {
|
|
551
551
|
const normalized = { ...item };
|
|
552
552
|
|
|
553
|
-
// Remove os tipos do DynamoDB (S, N, etc)
|
|
554
553
|
for (const [key, value] of Object.entries(normalized)) {
|
|
555
|
-
|
|
556
|
-
if (value.S !== undefined) normalized[key] = value.S;
|
|
557
|
-
else if (value.N !== undefined) normalized[key] = parseFloat(value.N);
|
|
558
|
-
else if (value.BOOL !== undefined) normalized[key] = value.BOOL;
|
|
559
|
-
else if (value.L !== undefined) normalized[key] = value.L.map((v) => this.normalizeItem(v, table));
|
|
560
|
-
else if (value.M !== undefined) normalized[key] = this.normalizeItem(value.M, table);
|
|
561
|
-
}
|
|
554
|
+
normalized[key] = this.normalizeValue(value, table);
|
|
562
555
|
}
|
|
563
556
|
|
|
564
557
|
return normalized;
|
|
565
558
|
}
|
|
566
559
|
|
|
560
|
+
normalizeValue(value, table) {
|
|
561
|
+
if (value === null || value === undefined) return value;
|
|
562
|
+
if (typeof value !== 'object') return value;
|
|
563
|
+
|
|
564
|
+
if (value.S !== undefined) return value.S;
|
|
565
|
+
if (value.N !== undefined) return parseFloat(value.N);
|
|
566
|
+
if (value.BOOL !== undefined) return value.BOOL;
|
|
567
|
+
if (value.NULL !== undefined) return null;
|
|
568
|
+
if (value.L !== undefined) return value.L.map((v) => this.normalizeValue(v, table));
|
|
569
|
+
if (value.M !== undefined) return this.normalizeItem(value.M, table);
|
|
570
|
+
if (value.SS !== undefined) return value.SS;
|
|
571
|
+
if (value.NS !== undefined) return value.NS.map(Number);
|
|
572
|
+
|
|
573
|
+
// plain object (already normalized, e.g. stored without DynamoDB types)
|
|
574
|
+
return value;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
marshallValue(value, table) {
|
|
578
|
+
if (value === null || value === undefined) return { NULL: true };
|
|
579
|
+
if (typeof value === 'boolean') return { BOOL: value };
|
|
580
|
+
if (typeof value === 'number') return { N: String(value) };
|
|
581
|
+
if (typeof value === 'string') return { S: value };
|
|
582
|
+
if (Array.isArray(value)) return { L: value.map((v) => this.marshallValue(v, table)) };
|
|
583
|
+
if (typeof value === 'object') return { M: this.marshallItem(value, table) };
|
|
584
|
+
return { S: String(value) };
|
|
585
|
+
}
|
|
586
|
+
|
|
567
587
|
marshallItem(item, table) {
|
|
568
588
|
const marshalled = {};
|
|
569
589
|
|
|
570
590
|
for (const [key, value] of Object.entries(item)) {
|
|
571
591
|
if (key.startsWith("_")) continue; // Pula campos internos
|
|
572
592
|
|
|
573
|
-
const type = table.attributeTypes[key];
|
|
593
|
+
const type = table ? table.attributeTypes[key] : null;
|
|
574
594
|
if (type === "S") {
|
|
575
595
|
marshalled[key] = { S: String(value) };
|
|
576
596
|
} else if (type === "N") {
|
|
577
597
|
marshalled[key] = { N: String(value) };
|
|
578
|
-
} else if (type === "BOOL") {
|
|
579
|
-
marshalled[key] = { BOOL: Boolean(value) };
|
|
580
|
-
} else if (Array.isArray(value)) {
|
|
581
|
-
marshalled[key] = { L: value.map((v) => ({ S: String(v) })) };
|
|
582
|
-
} else if (typeof value === "object") {
|
|
583
|
-
marshalled[key] = { M: this.marshallItem(value, table) };
|
|
584
598
|
} else {
|
|
585
|
-
marshalled[key] =
|
|
599
|
+
marshalled[key] = this.marshallValue(value, table);
|
|
586
600
|
}
|
|
587
601
|
}
|
|
588
602
|
|