ag-common 0.0.410 → 0.0.412
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.
|
@@ -2,7 +2,10 @@ import DynamoDB from 'aws-sdk/clients/dynamodb';
|
|
|
2
2
|
import { DYNAMOKEYS, IQueryDynamo, Key } from '../types';
|
|
3
3
|
export declare let dynamoDb: DynamoDB.DocumentClient;
|
|
4
4
|
export declare const setDynamo: (region: string) => void;
|
|
5
|
-
export declare const putDynamo: <T>(item: T, tableName: string
|
|
5
|
+
export declare const putDynamo: <T>(item: T, tableName: string, opt?: {
|
|
6
|
+
/** if provided, will assert this PK value doesnt already exist */
|
|
7
|
+
pkName?: string;
|
|
8
|
+
}) => Promise<{
|
|
6
9
|
error?: string | undefined;
|
|
7
10
|
data?: T | undefined;
|
|
8
11
|
}>;
|
|
@@ -48,12 +48,12 @@ const setDynamo = (region) => {
|
|
|
48
48
|
exports.dynamoDb = new dynamodb_1.DocumentClient({ region });
|
|
49
49
|
};
|
|
50
50
|
exports.setDynamo = setDynamo;
|
|
51
|
-
const putDynamo = (item, tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
-
const params = {
|
|
53
|
-
TableName: tableName,
|
|
51
|
+
const putDynamo = (item, tableName, opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const params = Object.assign({ TableName: tableName,
|
|
54
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
55
|
-
Item: item,
|
|
56
|
-
|
|
54
|
+
Item: item }, ((opt === null || opt === void 0 ? void 0 : opt.pkName) && {
|
|
55
|
+
ConditionExpression: `attribute_not_exists(${opt.pkName})`,
|
|
56
|
+
}));
|
|
57
57
|
(0, log_1.info)(`running dynamo put=${JSON.stringify(params, null, 2)}`);
|
|
58
58
|
// write the todo to the database
|
|
59
59
|
const put = yield exports.dynamoDb.put(params).promise();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.412",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -35,16 +35,16 @@
|
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
37
|
"@babel/core": "7.20.12",
|
|
38
|
-
"@storybook/addon-actions": "6.5.
|
|
39
|
-
"@storybook/addon-docs": "6.5.
|
|
40
|
-
"@storybook/addon-essentials": "6.5.
|
|
41
|
-
"@storybook/addon-interactions": "6.5.
|
|
42
|
-
"@storybook/addon-links": "6.5.
|
|
43
|
-
"@storybook/addons": "6.5.
|
|
44
|
-
"@storybook/react": "6.5.
|
|
45
|
-
"@storybook/theming": "6.5.
|
|
38
|
+
"@storybook/addon-actions": "6.5.16",
|
|
39
|
+
"@storybook/addon-docs": "6.5.16",
|
|
40
|
+
"@storybook/addon-essentials": "6.5.16",
|
|
41
|
+
"@storybook/addon-interactions": "6.5.16",
|
|
42
|
+
"@storybook/addon-links": "6.5.16",
|
|
43
|
+
"@storybook/addons": "6.5.16",
|
|
44
|
+
"@storybook/react": "6.5.16",
|
|
45
|
+
"@storybook/theming": "6.5.16",
|
|
46
46
|
"@types/jsonwebtoken": "9.0.1",
|
|
47
|
-
"@types/node": "18.
|
|
47
|
+
"@types/node": "18.13.0",
|
|
48
48
|
"@types/react": "18.0.27",
|
|
49
49
|
"@types/react-dom": "18.0.10",
|
|
50
50
|
"@emotion/react": "11.10.5",
|