electrodb 1.7.2 → 1.8.0
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/CHANGELOG.md +8 -1
- package/index.d.ts +2 -0
- package/package.json +1 -1
- package/src/client.js +13 -1
- package/src/schema.js +25 -28
package/CHANGELOG.md
CHANGED
|
@@ -159,4 +159,11 @@ All notable changes to this project will be documented in this file. Breaking ch
|
|
|
159
159
|
## [1.7.2] - 2022-03-27
|
|
160
160
|
### Fixed
|
|
161
161
|
- Fixed issue#111, `update` method specific query option typing no longer lost when using a `where` method in a query chain
|
|
162
|
-
- Fixing incorrect typing for exposed `UpdateEntityItem` type. Exported type was missing composite key attributes
|
|
162
|
+
- Fixing incorrect typing for exposed `UpdateEntityItem` type. Exported type was missing composite key attributes
|
|
163
|
+
|
|
164
|
+
## [1.8.0] - 2022-03-28
|
|
165
|
+
### Added
|
|
166
|
+
- Expected typings for the injected v2 client now include methods for `transactWrite` and `transactGet`
|
|
167
|
+
### Changed
|
|
168
|
+
- Map attributes will now always resolve to least an empty object on a `create` and `put` methods (instead of just the root map)
|
|
169
|
+
- In the past, default values for property attributes on maps only resolves when a user provided an object to place the values on. Now default values within maps attributes will now always resolve onto the object on `create` and `put` methods.
|
package/index.d.ts
CHANGED
|
@@ -1139,6 +1139,8 @@ type DocumentClient = {
|
|
|
1139
1139
|
batchWrite: DocumentClientMethod;
|
|
1140
1140
|
batchGet: DocumentClientMethod;
|
|
1141
1141
|
scan: DocumentClientMethod;
|
|
1142
|
+
transactGet: DocumentClientMethod;
|
|
1143
|
+
transactWrite: DocumentClientMethod;
|
|
1142
1144
|
} | {
|
|
1143
1145
|
send: (command: any) => Promise<any>;
|
|
1144
1146
|
}
|
package/package.json
CHANGED
package/src/client.js
CHANGED
|
@@ -9,7 +9,7 @@ const DocumentClientVersions = {
|
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
const v3Methods = ['send'];
|
|
12
|
-
const v2Methods = ['get', 'put', 'update', 'delete', 'batchWrite', 'batchGet', 'scan', 'query', 'createSet'];
|
|
12
|
+
const v2Methods = ['get', 'put', 'update', 'delete', 'batchWrite', 'batchGet', 'scan', 'query', 'createSet', 'transactWrite', 'transactGet'];
|
|
13
13
|
const supportedClientVersions = {
|
|
14
14
|
[DocumentClientVersions.v2]: v2Methods,
|
|
15
15
|
[DocumentClientVersions.v3]: v3Methods,
|
|
@@ -81,6 +81,18 @@ class DocumentClientV3Wrapper {
|
|
|
81
81
|
return this.client.send(command);
|
|
82
82
|
});
|
|
83
83
|
}
|
|
84
|
+
transactWrite(params) {
|
|
85
|
+
return this.promiseWrap(async () => {
|
|
86
|
+
const command = new this.lib.TransactWriteCommand(params);
|
|
87
|
+
return this.client.send(command);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
transactGet(params) {
|
|
91
|
+
return this.promiseWrap(async () => {
|
|
92
|
+
const command = new this.lib.TransactGetCommand(params);
|
|
93
|
+
return this.client.send(command);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
84
96
|
createSet(value) {
|
|
85
97
|
if (Array.isArray(value)) {
|
|
86
98
|
return new Set(value);
|
package/src/schema.js
CHANGED
|
@@ -575,30 +575,30 @@ class MapAttribute extends Attribute {
|
|
|
575
575
|
}
|
|
576
576
|
return v;
|
|
577
577
|
}
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
578
|
+
|
|
579
|
+
let data = value === undefined
|
|
580
|
+
? getValue(value)
|
|
581
|
+
: value;
|
|
582
|
+
|
|
583
|
+
const valueType = getValueType(data);
|
|
584
|
+
|
|
585
|
+
if (data === undefined) {
|
|
586
|
+
data = {};
|
|
583
587
|
} else if (valueType !== "object") {
|
|
584
588
|
throw new e.ElectroAttributeValidationError(this.path, `Invalid value type at entity path: "${this.path}". Expected value to be an object to fulfill attribute type "${this.type}"`);
|
|
585
589
|
}
|
|
586
590
|
|
|
587
|
-
const
|
|
591
|
+
const response = {};
|
|
588
592
|
|
|
589
593
|
for (const name of Object.keys(this.properties.attributes)) {
|
|
590
594
|
const attribute = this.properties.attributes[name];
|
|
591
|
-
const results = attribute.val(
|
|
595
|
+
const results = attribute.val(data[attribute.name]);
|
|
592
596
|
if (results !== undefined) {
|
|
593
|
-
|
|
597
|
+
response[name] = results;
|
|
594
598
|
}
|
|
595
599
|
}
|
|
596
600
|
|
|
597
|
-
|
|
598
|
-
return getValue(data);
|
|
599
|
-
} else {
|
|
600
|
-
return getValue();
|
|
601
|
-
}
|
|
601
|
+
return response;
|
|
602
602
|
}
|
|
603
603
|
}
|
|
604
604
|
|
|
@@ -726,28 +726,25 @@ class ListAttribute extends Attribute {
|
|
|
726
726
|
return v;
|
|
727
727
|
}
|
|
728
728
|
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
729
|
+
const data = value === undefined
|
|
730
|
+
? getValue(value)
|
|
731
|
+
: value;
|
|
732
|
+
|
|
733
|
+
if (data === undefined) {
|
|
734
|
+
return data;
|
|
735
|
+
} else if (!Array.isArray(data)) {
|
|
734
736
|
throw new e.ElectroAttributeValidationError(this.path, `Invalid value type at entity path "${this.path}. Received value of type "${getValueType(value)}", expected value of type "array"`);
|
|
735
737
|
}
|
|
736
738
|
|
|
737
|
-
const
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
const results = this.items.val(v);
|
|
739
|
+
const response = [];
|
|
740
|
+
for (const d of data) {
|
|
741
|
+
const results = this.items.val(d);
|
|
741
742
|
if (results !== undefined) {
|
|
742
|
-
|
|
743
|
+
response.push(results);
|
|
743
744
|
}
|
|
744
745
|
}
|
|
745
746
|
|
|
746
|
-
|
|
747
|
-
return getValue(data);
|
|
748
|
-
} else {
|
|
749
|
-
return getValue();
|
|
750
|
-
}
|
|
747
|
+
return response;
|
|
751
748
|
}
|
|
752
749
|
}
|
|
753
750
|
|