@moicky/dynamodb 3.0.0 → 3.0.1
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.
|
@@ -10,10 +10,12 @@ export declare class Transaction {
|
|
|
10
10
|
private createdAt;
|
|
11
11
|
private updatedAt;
|
|
12
12
|
private operations;
|
|
13
|
-
|
|
13
|
+
private shouldSplitTransactions;
|
|
14
|
+
constructor({ tableName, createdAt, updatedAt, shouldSplitTransactions, }?: {
|
|
14
15
|
tableName?: string;
|
|
15
16
|
createdAt?: any;
|
|
16
17
|
updatedAt?: any;
|
|
18
|
+
shouldSplitTransactions?: boolean;
|
|
17
19
|
});
|
|
18
20
|
private getItemKey;
|
|
19
21
|
create<T extends ItemWithKey>(item: WithoutReferences<T>, args?: CreateOperation["args"]): CreateOperations<T>;
|
|
@@ -11,10 +11,15 @@ class Transaction {
|
|
|
11
11
|
createdAt;
|
|
12
12
|
updatedAt;
|
|
13
13
|
operations = {};
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
shouldSplitTransactions;
|
|
15
|
+
constructor({ tableName, createdAt, updatedAt, shouldSplitTransactions, } = {}) {
|
|
16
|
+
this.tableName = tableName ?? (0, __1.getDefaultTable)();
|
|
16
17
|
this.createdAt = createdAt ?? (0, __1.getItemModificationTimestamp)("createdAt");
|
|
17
18
|
this.updatedAt = updatedAt ?? (0, __1.getItemModificationTimestamp)("updatedAt");
|
|
19
|
+
this.shouldSplitTransactions =
|
|
20
|
+
shouldSplitTransactions ??
|
|
21
|
+
(0, __1.getConfig)().splitTransactionsIfAboveLimit ??
|
|
22
|
+
false;
|
|
18
23
|
}
|
|
19
24
|
getItemKey(item, tableName) {
|
|
20
25
|
return (0, __1.getItemKey)(item, { TableName: tableName || this.tableName });
|
|
@@ -127,10 +132,10 @@ class Transaction {
|
|
|
127
132
|
async execute(args) {
|
|
128
133
|
args = (0, __1.withDefaults)(args, "transactWriteItems");
|
|
129
134
|
return new Promise(async (resolve, reject) => {
|
|
130
|
-
const shouldSplitTransactions = (0, __1.getConfig)().splitTransactionsIfAboveLimit ?? false;
|
|
131
135
|
const operations = Object.values(this.operations);
|
|
132
136
|
if (operations.length === 0 ||
|
|
133
|
-
(operations.length > OPERATIONS_LIMIT &&
|
|
137
|
+
(operations.length > OPERATIONS_LIMIT &&
|
|
138
|
+
!this.shouldSplitTransactions)) {
|
|
134
139
|
reject(new Error("[@moicky/dynamodb]: Invalid number of operations"));
|
|
135
140
|
}
|
|
136
141
|
const conditionCheckItems = operations
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moicky/dynamodb",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"description": "Contains a collection of convenience functions for working with AWS DynamoDB",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
"dependencies": {
|
|
26
26
|
"@aws-sdk/client-dynamodb": "^3.338.0",
|
|
27
27
|
"@aws-sdk/util-dynamodb": "^3.338.0",
|
|
28
|
-
"aws-crt": "^1.15.20"
|
|
28
|
+
"aws-crt": "^1.15.20",
|
|
29
|
+
"@vercel/functions": "^2.0.0"
|
|
29
30
|
},
|
|
30
31
|
"devDependencies": {
|
|
31
32
|
"@types/jest": "^29.5.1",
|
|
32
33
|
"@types/node": "^20.2.4",
|
|
33
|
-
"@vercel/functions": "^2.0.0",
|
|
34
34
|
"dotenv": "^16.0.3",
|
|
35
35
|
"jest": "^29.5.0",
|
|
36
36
|
"typescript": "^5.0.4"
|