ag-common 0.0.586 → 0.0.588
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb';
|
|
2
|
-
import type {
|
|
2
|
+
import type { IQueryDynamo, Key } from '../types';
|
|
3
3
|
export declare const setDynamo: (region: string) => DynamoDBDocument;
|
|
4
4
|
export declare let dynamoDb: DynamoDBDocument;
|
|
5
5
|
export declare const putDynamo: <T extends Record<string, any>>(item: T, tableName: string, opt?: {
|
|
@@ -62,7 +62,11 @@ export declare const getDynamoTtlMinutes: (mins: number) => number;
|
|
|
62
62
|
export declare const wipeTable: (tableName: string) => Promise<{
|
|
63
63
|
error?: string;
|
|
64
64
|
}>;
|
|
65
|
-
|
|
65
|
+
/** gets all fields in dynamokeys, and moves them into update expressions. eg will turn item.yourFieldName, into a dynamo write into field "yourFieldName" */
|
|
66
|
+
export declare const getDynamoUpdates: (item: Record<string, string | number | boolean>, opt?: {
|
|
67
|
+
/** default PK. will also exclude null or undefined */
|
|
68
|
+
excludeKeys?: string[];
|
|
69
|
+
}) => {
|
|
66
70
|
UpdateExpression: string;
|
|
67
71
|
ExpressionAttributeNames: Record<string, string>;
|
|
68
72
|
ExpressionAttributeValues: Record<string, string | number>;
|
|
@@ -311,22 +311,21 @@ const wipeTable = (tableName) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
311
311
|
}
|
|
312
312
|
});
|
|
313
313
|
exports.wipeTable = wipeTable;
|
|
314
|
-
|
|
315
|
-
|
|
314
|
+
/** gets all fields in dynamokeys, and moves them into update expressions. eg will turn item.yourFieldName, into a dynamo write into field "yourFieldName" */
|
|
315
|
+
const getDynamoUpdates = (item, opt) => {
|
|
316
|
+
var _a;
|
|
317
|
+
let ek = (_a = opt === null || opt === void 0 ? void 0 : opt.excludeKeys) !== null && _a !== void 0 ? _a : ['PK'];
|
|
316
318
|
let UpdateExpression = '';
|
|
317
319
|
const ExpressionAttributeNames = {};
|
|
318
320
|
const ExpressionAttributeValues = {};
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
}
|
|
327
|
-
else {
|
|
328
|
-
(0, log_1.warn)(`no value for key:${key}`);
|
|
329
|
-
}
|
|
321
|
+
//
|
|
322
|
+
const cleanedKeys = Object.entries(item).filter(([k]) => !ek.includes(k));
|
|
323
|
+
cleanedKeys
|
|
324
|
+
.filter(([_k, v]) => v !== null && v !== undefined)
|
|
325
|
+
.forEach(([k, v]) => {
|
|
326
|
+
UpdateExpression += `${!UpdateExpression ? '' : ','} #${k} = :${k}`;
|
|
327
|
+
ExpressionAttributeNames[`#${k}`] = k;
|
|
328
|
+
ExpressionAttributeValues[`:${k}`] = v.toString();
|
|
330
329
|
});
|
|
331
330
|
return {
|
|
332
331
|
UpdateExpression,
|
|
@@ -69,6 +69,7 @@ function logprocess(type, args) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
function printStackTrace(...args) {
|
|
72
|
+
var _a;
|
|
72
73
|
const callstack = [];
|
|
73
74
|
let isCallstackPopulated = false;
|
|
74
75
|
try {
|
|
@@ -114,8 +115,7 @@ function printStackTrace(...args) {
|
|
|
114
115
|
let currentFunction = args.callee.caller;
|
|
115
116
|
while (currentFunction) {
|
|
116
117
|
const fn = currentFunction.toString();
|
|
117
|
-
const fname = fn.substring(fn.indexOf('function') + 8, fn.indexOf('('))
|
|
118
|
-
'anonymous';
|
|
118
|
+
const fname = (_a = fn.substring(fn.indexOf('function') + 8, fn.indexOf('('))) !== null && _a !== void 0 ? _a : 'anonymous';
|
|
119
119
|
callstack.push(fname);
|
|
120
120
|
currentFunction = currentFunction.caller;
|
|
121
121
|
}
|
|
@@ -115,7 +115,7 @@ function DropdownList(p) {
|
|
|
115
115
|
if (JSON.stringify(newv) !== JSON.stringify(state)) {
|
|
116
116
|
setState(newv);
|
|
117
117
|
}
|
|
118
|
-
}, [p.
|
|
118
|
+
}, [p.value, state]);
|
|
119
119
|
const [style, setStyle] = (0, react_1.useState)({});
|
|
120
120
|
(0, react_1.useEffect)(() => {
|
|
121
121
|
var _a, _b, _c, _d;
|
package/package.json
CHANGED