@moicky/dynamodb 2.3.5 → 2.3.6
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/dist/lib/fixes.d.ts +1 -1
- package/dist/operations/get.d.ts +3 -3
- package/dist/operations/put.d.ts +1 -1
- package/dist/operations/query.d.ts +5 -5
- package/dist/operations/query.js +2 -2
- package/dist/operations/transactGetItems.d.ts +2 -2
- package/dist/operations/update.d.ts +2 -2
- package/dist/operations/update.js +2 -4
- package/package.json +1 -1
package/dist/lib/fixes.d.ts
CHANGED
|
@@ -63,4 +63,4 @@ export declare const marshallWithOptions: (input: Parameters<typeof marshall>[0]
|
|
|
63
63
|
* @returns The unmarshalled input
|
|
64
64
|
* @private
|
|
65
65
|
*/
|
|
66
|
-
export declare const unmarshallWithOptions:
|
|
66
|
+
export declare const unmarshallWithOptions: (input: Parameters<typeof unmarshall>[0]) => Record<string, any>;
|
package/dist/operations/get.d.ts
CHANGED
|
@@ -25,7 +25,7 @@ import { BatchGetItemCommandInput, GetItemCommandInput, ScanCommandInput } from
|
|
|
25
25
|
* );
|
|
26
26
|
* ```
|
|
27
27
|
*/
|
|
28
|
-
export declare function getItem
|
|
28
|
+
export declare function getItem(key: Record<string, any>, args?: Partial<GetItemCommandInput>): Promise<Record<string, any> | undefined>;
|
|
29
29
|
type GetItemsArgs = Partial<BatchGetItemCommandInput & {
|
|
30
30
|
TableName?: string;
|
|
31
31
|
}>;
|
|
@@ -58,7 +58,7 @@ type GetItemsArgs = Partial<BatchGetItemCommandInput & {
|
|
|
58
58
|
* );
|
|
59
59
|
* ```
|
|
60
60
|
*/
|
|
61
|
-
export declare function getItems
|
|
61
|
+
export declare function getItems(keys: Record<string, any>[], args?: GetItemsArgs, retry?: number): Promise<Record<string, any>[]>;
|
|
62
62
|
/**
|
|
63
63
|
* Retrieves all items from the DynamoDB table.
|
|
64
64
|
* @param args - The additional arguments to override or specify for {@link ScanCommandInput}
|
|
@@ -77,5 +77,5 @@ export declare function getItems<T extends Record<string, any> = Record<string,
|
|
|
77
77
|
* );
|
|
78
78
|
* ```
|
|
79
79
|
*/
|
|
80
|
-
export declare function getAllItems
|
|
80
|
+
export declare function getAllItems(args?: Partial<ScanCommandInput>): Promise<Record<string, any>[]>;
|
|
81
81
|
export {};
|
package/dist/operations/put.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import { BatchWriteItemCommandInput, BatchWriteItemCommandOutput, PutItemCommand
|
|
|
17
17
|
* });
|
|
18
18
|
* ```
|
|
19
19
|
*/
|
|
20
|
-
export declare function putItem
|
|
20
|
+
export declare function putItem(item: Record<string, any>, args?: Partial<PutItemCommandInput>): Promise<PutItemCommandOutput | Record<string, any>>;
|
|
21
21
|
type PutItemsArgs = Partial<BatchWriteItemCommandInput & {
|
|
22
22
|
TableName?: string;
|
|
23
23
|
}>;
|
|
@@ -32,7 +32,7 @@ export declare function query(keyCondition: string, key: Record<string, any>, ar
|
|
|
32
32
|
* });
|
|
33
33
|
* ```
|
|
34
34
|
*/
|
|
35
|
-
export declare function queryItems
|
|
35
|
+
export declare function queryItems(keyCondition: string, key: Record<string, any>, args?: Partial<QueryCommandInput>): Promise<Record<string, any>[]>;
|
|
36
36
|
/**
|
|
37
37
|
* Query all items from the DynamoDB table using a key condition and unmarshalls the result.
|
|
38
38
|
* This function retries until all items are retrieved due to the AWS limit of 1MB per query.
|
|
@@ -62,7 +62,7 @@ export declare function queryItems<T extends Record<string, any> = Record<string
|
|
|
62
62
|
* );
|
|
63
63
|
* ```
|
|
64
64
|
*/
|
|
65
|
-
export declare function queryAllItems
|
|
65
|
+
export declare function queryAllItems(keyCondition: string, key: Record<string, any>, args?: Partial<QueryCommandInput>): Promise<Record<string, any>[]>;
|
|
66
66
|
/**
|
|
67
67
|
* The structure for the PaginationPage type.
|
|
68
68
|
* @property number - The page number. Cannot be set manually.
|
|
@@ -81,8 +81,8 @@ export type PaginationPage = {
|
|
|
81
81
|
* @property hasNextPage - Whether there is a next page.
|
|
82
82
|
* @property currentPage - The current page.
|
|
83
83
|
*/
|
|
84
|
-
export type PaginationResult
|
|
85
|
-
items:
|
|
84
|
+
export type PaginationResult = {
|
|
85
|
+
items: Record<string, any>[];
|
|
86
86
|
hasPreviousPage: boolean;
|
|
87
87
|
hasNextPage: boolean;
|
|
88
88
|
currentPage: PaginationPage;
|
|
@@ -125,4 +125,4 @@ export interface PaginationArgs extends Partial<Omit<QueryCommandInput, "Limit">
|
|
|
125
125
|
* // currentPage: { number: 2, firstKey: { ... }, lastKey: { ... } }
|
|
126
126
|
* ```
|
|
127
127
|
*/
|
|
128
|
-
export declare function queryPaginatedItems
|
|
128
|
+
export declare function queryPaginatedItems(keyCondition: string, key: Record<string, any>, args: PaginationArgs): Promise<PaginationResult>;
|
package/dist/operations/query.js
CHANGED
|
@@ -66,8 +66,8 @@ exports.query = query;
|
|
|
66
66
|
async function queryItems(keyCondition, key, args = {}) {
|
|
67
67
|
args = (0, lib_1.withDefaults)(args, "queryItems");
|
|
68
68
|
return _query(keyCondition, key, args).then((res) => (res?.Items || [])
|
|
69
|
-
.map((item) => (0, lib_1.unmarshallWithOptions)(item))
|
|
70
|
-
.filter(
|
|
69
|
+
.map((item) => item && (0, lib_1.unmarshallWithOptions)(item))
|
|
70
|
+
.filter((item) => item));
|
|
71
71
|
}
|
|
72
72
|
exports.queryItems = queryItems;
|
|
73
73
|
/**
|
|
@@ -34,9 +34,9 @@ import { Get, TransactGetItemsCommandInput } from "@aws-sdk/client-dynamodb";
|
|
|
34
34
|
* );
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
export declare function transactGetItems
|
|
37
|
+
export declare function transactGetItems(keys: Array<Omit<Get, "TableName" | "Key"> & {
|
|
38
38
|
key: Record<string, any>;
|
|
39
39
|
TableName?: string;
|
|
40
40
|
}>, args?: Partial<TransactGetItemsCommandInput & {
|
|
41
41
|
TableName?: string;
|
|
42
|
-
}>): Promise<
|
|
42
|
+
}>): Promise<Array<Record<string, any> | undefined>>;
|
|
@@ -31,7 +31,7 @@ import { UpdateItemCommandInput, UpdateItemCommandOutput } from "@aws-sdk/client
|
|
|
31
31
|
* console.log(newItem); // { "PK": "User/1", "SK": "Book/1", "released": 2000 }
|
|
32
32
|
* ```
|
|
33
33
|
*/
|
|
34
|
-
export declare function updateItem
|
|
34
|
+
export declare function updateItem(key: Record<string, any>, data: Record<string, any>, args?: Partial<UpdateItemCommandInput>): Promise<undefined | Record<string, any>>;
|
|
35
35
|
/**
|
|
36
36
|
* Removes specified attributes from an item in DynamoDB.
|
|
37
37
|
*
|
|
@@ -46,4 +46,4 @@ export declare function updateItem<T extends Record<string, any> = Record<string
|
|
|
46
46
|
* await removeAttributes({ PK: "User/1", SK: "Book/1" }, ["description"]);
|
|
47
47
|
* ```
|
|
48
48
|
*/
|
|
49
|
-
export declare function removeAttributes
|
|
49
|
+
export declare function removeAttributes(key: Record<string, any>, attributes: string[], args?: Partial<UpdateItemCommandInput>): Promise<UpdateItemCommandOutput>;
|
|
@@ -79,8 +79,7 @@ exports.updateItem = updateItem;
|
|
|
79
79
|
async function removeAttributes(key, attributes, args = {}) {
|
|
80
80
|
args = (0, lib_1.withDefaults)(args, "removeAttributes");
|
|
81
81
|
const UpdateExpression = "REMOVE " + attributes.map((att) => `#${att}`).join(", ");
|
|
82
|
-
return (0, lib_1.getClient)()
|
|
83
|
-
.send(new client_dynamodb_1.UpdateItemCommand({
|
|
82
|
+
return (0, lib_1.getClient)().send(new client_dynamodb_1.UpdateItemCommand({
|
|
84
83
|
Key: (0, lib_1.stripKey)(key, args),
|
|
85
84
|
UpdateExpression,
|
|
86
85
|
ExpressionAttributeNames: (0, lib_1.getAttributeNames)(attributes.reduce((acc, att) => {
|
|
@@ -89,7 +88,6 @@ async function removeAttributes(key, attributes, args = {}) {
|
|
|
89
88
|
}, {})),
|
|
90
89
|
...args,
|
|
91
90
|
TableName: args?.TableName || (0, lib_1.getDefaultTable)(),
|
|
92
|
-
}))
|
|
93
|
-
.then((res) => args?.ReturnValues ? (0, lib_1.unmarshallWithOptions)(res.Attributes) : undefined);
|
|
91
|
+
}));
|
|
94
92
|
}
|
|
95
93
|
exports.removeAttributes = removeAttributes;
|