@izara_project/izara-core-library-dynamodb 1.0.10 → 1.0.12
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/index.js +3 -1
- package/package.json +7 -6
- package/src/DynamoDBSharedLib.js +14 -14
package/index.js
CHANGED
|
@@ -18,4 +18,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
20
|
// Re-export everything from DynamoDBSharedLib
|
|
21
|
-
|
|
21
|
+
import dynamoDBSharedLib from './src/DynamoDBSharedLib.js';
|
|
22
|
+
|
|
23
|
+
export default dynamoDBSharedLib;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@izara_project/izara-core-library-dynamodb",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.12",
|
|
4
4
|
"description": "Connecting with AWS DynamoDB Resource",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,16 +14,17 @@
|
|
|
14
14
|
"license": "AGPL-3.0-or-later",
|
|
15
15
|
"homepage": "https://bitbucket.org/izara-core-libraries/izara-core-library-dynamodb/src/master/README.md",
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"jest": "^30.0
|
|
17
|
+
"jest": "^30.2.0"
|
|
18
18
|
},
|
|
19
19
|
"jest": {
|
|
20
20
|
"testEnvironment": "node"
|
|
21
21
|
},
|
|
22
|
+
"type": "module",
|
|
22
23
|
"dependencies": {
|
|
23
|
-
"@aws-sdk/client-dynamodb": "^3.
|
|
24
|
-
"@aws-sdk/lib-dynamodb": "^3.
|
|
25
|
-
"@aws-sdk/util-dynamodb": "^3.
|
|
26
|
-
"@izara_project/izara-core-library-core": "^1.0.
|
|
24
|
+
"@aws-sdk/client-dynamodb": "^3.932.0",
|
|
25
|
+
"@aws-sdk/lib-dynamodb": "^3.932.0",
|
|
26
|
+
"@aws-sdk/util-dynamodb": "^3.932.0",
|
|
27
|
+
"@izara_project/izara-core-library-core": "^1.0.28",
|
|
27
28
|
"lodash.clonedeep": "^4.5.0"
|
|
28
29
|
}
|
|
29
30
|
}
|
package/src/DynamoDBSharedLib.js
CHANGED
|
@@ -17,15 +17,15 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
17
17
|
|
|
18
18
|
'use strict';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
21
|
+
import { DynamoDB } from '@aws-sdk/client-dynamodb';
|
|
22
|
+
import { marshall, unmarshall } from '@aws-sdk/util-dynamodb';
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
import cloneDeep from 'lodash.clonedeep';
|
|
25
25
|
|
|
26
26
|
// External Izara project imports
|
|
27
|
-
|
|
28
|
-
//
|
|
27
|
+
import { NoRetryError } from '@izara_project/izara-core-library-core';
|
|
28
|
+
// import { getServiceNameWithCache } = require('@izara_project/izara-core-library-service-schemas').serviceConfig;
|
|
29
29
|
|
|
30
30
|
// Constants
|
|
31
31
|
const MAX_RECURSION_LEVEL = 20;
|
|
@@ -330,7 +330,7 @@ function processLogicalElements(_izContext, logicalElements, level) {
|
|
|
330
330
|
// _izContext.logger.debug("I'm going in recursion");
|
|
331
331
|
|
|
332
332
|
conditionalExpression += '(';
|
|
333
|
-
conditionalExpression +=
|
|
333
|
+
conditionalExpression += processLogicalElements(_izContext, logicalElement.elements, level + 1); // ***recursion***
|
|
334
334
|
conditionalExpression += ')'; // close sub-group
|
|
335
335
|
|
|
336
336
|
} else { // end group types
|
|
@@ -690,7 +690,7 @@ async function query(_izContext, tableName, partitionKeyValue, queryElements = {
|
|
|
690
690
|
*/
|
|
691
691
|
async function queryResults(_izContext, tableName, partitionKeyValue, queryElements = {}, settings = {}) {
|
|
692
692
|
|
|
693
|
-
const queryResults = await
|
|
693
|
+
const queryResults = await query(
|
|
694
694
|
_izContext,
|
|
695
695
|
tableName,
|
|
696
696
|
partitionKeyValue,
|
|
@@ -773,7 +773,7 @@ async function putItem(
|
|
|
773
773
|
if (!Array.isArray(attributes[idx].value) || attributes[idx].value.length === 0) { // validate attributes value
|
|
774
774
|
throw new NoRetryError('attributes value should be array and not empty.');
|
|
775
775
|
}
|
|
776
|
-
attributes[idx].value =
|
|
776
|
+
attributes[idx].value = arrayToStringSet(attributes[idx].value);
|
|
777
777
|
}
|
|
778
778
|
payload.Item[`${attributes[idx].attributeName}`] = attributes[idx].value;
|
|
779
779
|
|
|
@@ -1084,7 +1084,7 @@ async function updateItem(
|
|
|
1084
1084
|
|
|
1085
1085
|
// attach value placeholders
|
|
1086
1086
|
if (Object.prototype.hasOwnProperty.call(item, 'isStringSet') && item.isStringSet === true) {
|
|
1087
|
-
item.value =
|
|
1087
|
+
item.value = arrayToStringSet(item.value);
|
|
1088
1088
|
}
|
|
1089
1089
|
if (Object.prototype.hasOwnProperty.call(item, 'value')) {
|
|
1090
1090
|
payload.ExpressionAttributeValues[':' + valueReference] = item.value;
|
|
@@ -1599,7 +1599,7 @@ async function batchDeleteItems(
|
|
|
1599
1599
|
*/
|
|
1600
1600
|
async function batchPutItems(
|
|
1601
1601
|
_izContext,
|
|
1602
|
-
|
|
1602
|
+
tableNameData,
|
|
1603
1603
|
writeItems,
|
|
1604
1604
|
settings // for batchWriteItems command,e.g., ReturnConsumedCapacity, ConsumedCapacity
|
|
1605
1605
|
) {
|
|
@@ -1643,7 +1643,7 @@ async function batchPutItems(
|
|
|
1643
1643
|
// NOTE: not help, cannot use complex in this batchWrite command just validata attributes and add context.
|
|
1644
1644
|
let putItemPayload = await module.exports.putItem(
|
|
1645
1645
|
_izContext,
|
|
1646
|
-
await
|
|
1646
|
+
await tableName(_izContext, tableNameData),
|
|
1647
1647
|
chunkSet[i].attributes,
|
|
1648
1648
|
chunkSet[i].queryElements,
|
|
1649
1649
|
chunkSet[i].settings
|
|
@@ -1659,7 +1659,7 @@ async function batchPutItems(
|
|
|
1659
1659
|
|
|
1660
1660
|
let payload = {
|
|
1661
1661
|
RequestItems: {
|
|
1662
|
-
[
|
|
1662
|
+
[tableNameData]: requestItems
|
|
1663
1663
|
},
|
|
1664
1664
|
ReturnConsumedCapacity: "TOTAL"
|
|
1665
1665
|
};
|
|
@@ -1718,7 +1718,7 @@ async function captureCapacityUsed(_izContext, capacityUsed, capacityStatus, que
|
|
|
1718
1718
|
}
|
|
1719
1719
|
|
|
1720
1720
|
// Consolidated exports
|
|
1721
|
-
|
|
1721
|
+
export default {
|
|
1722
1722
|
// Table name functions
|
|
1723
1723
|
tableName,
|
|
1724
1724
|
|