ag-common 0.0.419 → 0.0.421
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/api/helpers/api.js +35 -34
- package/dist/api/helpers/aws.js +13 -9
- package/dist/api/helpers/cloudfront.js +24 -7
- package/dist/api/helpers/dynamo.js +134 -85
- package/dist/api/helpers/dynamoInfra.js +19 -14
- package/dist/api/helpers/enforceDynamoProvisionCap.js +18 -14
- package/dist/api/helpers/index.js +30 -14
- package/dist/api/helpers/openApiHelpers.js +37 -34
- package/dist/api/helpers/s3.js +126 -81
- package/dist/api/helpers/ses.js +28 -9
- package/dist/api/helpers/sqs.js +26 -9
- package/dist/api/helpers/ssm.js +14 -8
- package/dist/api/helpers/sts.js +34 -16
- package/dist/api/helpers/validateOpenApi.js +103 -92
- package/dist/api/helpers/validations.js +46 -29
- package/dist/api/index.js +18 -2
- package/dist/api/openapi-prefix.js +38 -25
- package/dist/api/types/aws.js +2 -1
- package/dist/api/types/index.js +17 -1
- package/dist/common/const.js +5 -2
- package/dist/common/helpers/array.js +19 -8
- package/dist/common/helpers/async.js +28 -10
- package/dist/common/helpers/binary.js +10 -5
- package/dist/common/helpers/date.js +25 -14
- package/dist/common/helpers/email.js +11 -5
- package/dist/common/helpers/func.js +7 -3
- package/dist/common/helpers/generator.js +24 -9
- package/dist/common/helpers/groupBy.js +9 -3
- package/dist/common/helpers/hashCode.js +9 -3
- package/dist/common/helpers/i18n.js +17 -9
- package/dist/common/helpers/index.js +34 -18
- package/dist/common/helpers/log.js +28 -16
- package/dist/common/helpers/math.js +21 -9
- package/dist/common/helpers/memo.js +7 -3
- package/dist/common/helpers/object.js +35 -20
- package/dist/common/helpers/random.js +10 -4
- package/dist/common/helpers/secondsInNearest.js +7 -2
- package/dist/common/helpers/sleep.js +5 -1
- package/dist/common/helpers/string/base64.js +7 -2
- package/dist/common/helpers/string/chunk.js +5 -1
- package/dist/common/helpers/string/contains.js +7 -2
- package/dist/common/helpers/string/getExtendedStringSegment.js +9 -5
- package/dist/common/helpers/string/index.js +26 -10
- package/dist/common/helpers/string/json.js +5 -1
- package/dist/common/helpers/string/object.js +5 -1
- package/dist/common/helpers/string/surround.js +5 -1
- package/dist/common/helpers/string/trim.js +7 -2
- package/dist/common/helpers/string/truncate.js +5 -1
- package/dist/common/helpers/string/url.js +9 -4
- package/dist/common/index.js +18 -2
- package/dist/index.js +19 -3
- package/dist/ui/components/BorderGradient/index.js +25 -18
- package/dist/ui/components/Button/index.js +25 -17
- package/dist/ui/components/Chevron/index.js +16 -9
- package/dist/ui/components/Close/index.js +13 -6
- package/dist/ui/components/Confirm/Dialog.js +25 -9
- package/dist/ui/components/Confirm/Modal.js +27 -20
- package/dist/ui/components/Confirm/index.js +19 -3
- package/dist/ui/components/Confirm/types.js +2 -1
- package/dist/ui/components/DropdownList/Base.js +64 -33
- package/dist/ui/components/DropdownList/Dialog.js +24 -8
- package/dist/ui/components/DropdownList/index.js +18 -2
- package/dist/ui/components/DropdownList/types.js +2 -1
- package/dist/ui/components/FlexColumn/index.js +14 -4
- package/dist/ui/components/FlexRow/index.js +14 -4
- package/dist/ui/components/HeadersRaw/index.js +27 -20
- package/dist/ui/components/HorizontalScrollBar/index.js +34 -6
- package/dist/ui/components/Icon/index.js +16 -9
- package/dist/ui/components/Image/index.js +28 -10
- package/dist/ui/components/InfiniteScroll/index.js +50 -18
- package/dist/ui/components/KebabDots/index.js +13 -6
- package/dist/ui/components/Loader/index.js +39 -9
- package/dist/ui/components/Modal/Dialog.js +23 -7
- package/dist/ui/components/Modal/Modal.js +49 -19
- package/dist/ui/components/Modal/index.js +19 -3
- package/dist/ui/components/Modal/types.js +2 -1
- package/dist/ui/components/OpenApiCodeBlock/OpenApiCodeBlock.js +34 -26
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/body.js +19 -12
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/getCurlLines.js +11 -6
- package/dist/ui/components/OpenApiCodeBlock/curl/helpers/security.js +15 -8
- package/dist/ui/components/OpenApiCodeBlock/curl/index.js +21 -14
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/call.js +15 -8
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/getFetchLines.js +8 -3
- package/dist/ui/components/OpenApiCodeBlock/fetch/helpers/req.js +34 -27
- package/dist/ui/components/OpenApiCodeBlock/fetch/index.js +18 -11
- package/dist/ui/components/OpenApiCodeBlock/helpers/common.js +17 -7
- package/dist/ui/components/OpenApiCodeBlock/helpers/joinJsx.js +15 -6
- package/dist/ui/components/OpenApiCodeBlock/index.js +18 -2
- package/dist/ui/components/OpenApiCodeBlock/types.js +2 -1
- package/dist/ui/components/PieChart/index.js +18 -11
- package/dist/ui/components/ProgressBar/index.js +45 -15
- package/dist/ui/components/Prompt/Dialog.js +23 -7
- package/dist/ui/components/Prompt/Modal.js +55 -25
- package/dist/ui/components/Prompt/index.js +18 -2
- package/dist/ui/components/RowOrColumn/index.js +17 -7
- package/dist/ui/components/Search/AutoHideSearchBox.js +56 -24
- package/dist/ui/components/Search/Base.js +52 -21
- package/dist/ui/components/Search/Dialog.js +26 -10
- package/dist/ui/components/Search/Inline.js +10 -3
- package/dist/ui/components/Search/Modal.js +17 -10
- package/dist/ui/components/Search/SearchBox.js +58 -26
- package/dist/ui/components/Search/index.js +23 -7
- package/dist/ui/components/Search/types.js +2 -1
- package/dist/ui/components/Sidebar/index.js +25 -18
- package/dist/ui/components/SparkLine/index.js +27 -17
- package/dist/ui/components/Table/index.js +22 -15
- package/dist/ui/components/TextEdit/CheckboxEdit.js +51 -21
- package/dist/ui/components/TextEdit/ColourEdit.js +44 -17
- package/dist/ui/components/TextEdit/LengthBox.js +12 -5
- package/dist/ui/components/TextEdit/ListboxEdit.js +42 -15
- package/dist/ui/components/TextEdit/RadioGroup.js +43 -13
- package/dist/ui/components/TextEdit/TextEdit.js +78 -48
- package/dist/ui/components/TextEdit/common.js +17 -11
- package/dist/ui/components/TextEdit/index.js +22 -6
- package/dist/ui/components/TextEdit/types.js +2 -1
- package/dist/ui/components/TextWithButton/index.js +40 -10
- package/dist/ui/components/TimelineChart/index.js +24 -14
- package/dist/ui/components/Toast/Cross.js +16 -9
- package/dist/ui/components/Toast/Tick.js +11 -4
- package/dist/ui/components/Toast/Warning.js +15 -8
- package/dist/ui/components/Toast/base.js +65 -33
- package/dist/ui/components/Toast/index.js +18 -2
- package/dist/ui/components/Toast/types.js +2 -1
- package/dist/ui/components/UserImage/index.js +48 -17
- package/dist/ui/components/index.js +46 -30
- package/dist/ui/helpers/axiosHelper.js +39 -25
- package/dist/ui/helpers/browserHelpers.js +22 -7
- package/dist/ui/helpers/callOpenApi/cached.js +37 -18
- package/dist/ui/helpers/callOpenApi/direct.js +59 -46
- package/dist/ui/helpers/callOpenApi/helpers.js +40 -25
- package/dist/ui/helpers/callOpenApi/hook.js +36 -47
- package/dist/ui/helpers/callOpenApi/index.js +21 -5
- package/dist/ui/helpers/callOpenApi/types.js +2 -1
- package/dist/ui/helpers/cognito.js +2 -1
- package/dist/ui/helpers/cookie/const.js +5 -2
- package/dist/ui/helpers/cookie/get.js +14 -13
- package/dist/ui/helpers/cookie/index.js +21 -5
- package/dist/ui/helpers/cookie/raw.js +16 -9
- package/dist/ui/helpers/cookie/set.js +15 -10
- package/dist/ui/helpers/cookie/use.js +16 -23
- package/dist/ui/helpers/date.js +15 -10
- package/dist/ui/helpers/debounce.js +10 -5
- package/dist/ui/helpers/dom.js +13 -6
- package/dist/ui/helpers/extractAttributes.js +7 -2
- package/dist/ui/helpers/index.js +41 -25
- package/dist/ui/helpers/jwt.js +2 -1
- package/dist/ui/helpers/plural.js +5 -1
- package/dist/ui/helpers/routes.js +24 -17
- package/dist/ui/helpers/serviceWorker.js +23 -8
- package/dist/ui/helpers/useContextMenu.js +14 -9
- package/dist/ui/helpers/useElementAttribute.js +7 -3
- package/dist/ui/helpers/useGranularHook.js +10 -5
- package/dist/ui/helpers/useInterval.js +12 -8
- package/dist/ui/helpers/useLocalStorage.js +32 -24
- package/dist/ui/helpers/useLockBodyScroll.js +7 -3
- package/dist/ui/helpers/useOnClickOutside.js +12 -7
- package/dist/ui/helpers/useOnScroll.js +21 -15
- package/dist/ui/helpers/useOverloadPageSearch.js +7 -3
- package/dist/ui/helpers/useQueryString.js +20 -14
- package/dist/ui/helpers/useResize.js +19 -17
- package/dist/ui/helpers/useTimeout.js +9 -5
- package/dist/ui/icons/ChevronRight.js +9 -3
- package/dist/ui/icons/CrossIcon.js +12 -5
- package/dist/ui/icons/Door.js +10 -4
- package/dist/ui/icons/HorizontalDots.js +9 -3
- package/dist/ui/icons/Magnify.js +10 -3
- package/dist/ui/icons/Pencil.js +12 -5
- package/dist/ui/icons/Save.js +11 -4
- package/dist/ui/icons/Undo.js +12 -5
- package/dist/ui/icons/UserOutline.js +9 -3
- package/dist/ui/icons/index.js +25 -9
- package/dist/ui/index.js +20 -4
- package/dist/ui/styles/colours.js +12 -7
- package/dist/ui/styles/common.js +22 -14
- package/dist/ui/styles/index.js +20 -4
- package/dist/ui/styles/media.js +10 -7
- package/dist/ui/styles/standaloneStyles.js +16 -10
- package/package.json +2 -2
package/dist/api/helpers/api.js
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.generateDynamoPKS = exports.stripPKs = exports.returnCode = void 0;
|
|
1
15
|
/* eslint-disable @typescript-eslint/ban-ts-comment */
|
|
2
16
|
// eslint-disable-next-line
|
|
3
|
-
|
|
4
|
-
|
|
17
|
+
const array_1 = require("../../common/helpers/array");
|
|
18
|
+
const returnCode = (statusCode, body, extraHeaders, fullSiteUrl) => {
|
|
5
19
|
let headers = {
|
|
6
20
|
'Access-Control-Allow-Headers': 'Content-Type,X-Amz-Date,Authorization,X-Api-Key,X-Amz-Security-Token,X-Amz-User-Agent,User-Agent,Origin',
|
|
7
21
|
'Access-Control-Allow-Methods': '*',
|
|
@@ -9,10 +23,7 @@ export const returnCode = (statusCode, body, extraHeaders, fullSiteUrl) => {
|
|
|
9
23
|
'Access-Control-Allow-Credentials': true, // Required for cookies, authorization headers with HTTPS
|
|
10
24
|
};
|
|
11
25
|
if (extraHeaders && Object.keys(extraHeaders).length > 0) {
|
|
12
|
-
headers = {
|
|
13
|
-
...headers,
|
|
14
|
-
...extraHeaders,
|
|
15
|
-
};
|
|
26
|
+
headers = Object.assign(Object.assign({}, headers), extraHeaders);
|
|
16
27
|
}
|
|
17
28
|
return {
|
|
18
29
|
headers,
|
|
@@ -21,6 +32,7 @@ export const returnCode = (statusCode, body, extraHeaders, fullSiteUrl) => {
|
|
|
21
32
|
body: (!body ? undefined : JSON.stringify(body, null, 2)),
|
|
22
33
|
};
|
|
23
34
|
};
|
|
35
|
+
exports.returnCode = returnCode;
|
|
24
36
|
/**
|
|
25
37
|
* strip all dynamo generated keys. can optionally keep PK
|
|
26
38
|
* @param record
|
|
@@ -28,14 +40,14 @@ export const returnCode = (statusCode, body, extraHeaders, fullSiteUrl) => {
|
|
|
28
40
|
* @returns stripped record
|
|
29
41
|
*/
|
|
30
42
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
31
|
-
|
|
43
|
+
const stripPKs = (record, keepPk = true) => {
|
|
32
44
|
if (!record) {
|
|
33
45
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
46
|
return null;
|
|
35
47
|
}
|
|
36
48
|
// @ts-ignore
|
|
37
49
|
// eslint-disable-next-line
|
|
38
|
-
const { PK, PK1, PK2, PK3, PK4, PK5, L1, L2, L3, L4, L5, L6, type,
|
|
50
|
+
const { PK, PK1, PK2, PK3, PK4, PK5, L1, L2, L3, L4, L5, L6, type } = record, rest = __rest(record, ["PK", "PK1", "PK2", "PK3", "PK4", "PK5", "L1", "L2", "L3", "L4", "L5", "L6", "type"]);
|
|
39
51
|
if (keepPk) {
|
|
40
52
|
//@ts-ignore
|
|
41
53
|
rest.PK = PK;
|
|
@@ -44,6 +56,7 @@ export const stripPKs = (record, keepPk = true) => {
|
|
|
44
56
|
// @ts-ignore
|
|
45
57
|
return rest;
|
|
46
58
|
};
|
|
59
|
+
exports.stripPKs = stripPKs;
|
|
47
60
|
/**
|
|
48
61
|
* generate dynamo PKs.
|
|
49
62
|
* PK = all Ls joined with #
|
|
@@ -54,33 +67,21 @@ export const stripPKs = (record, keepPk = true) => {
|
|
|
54
67
|
* @param param0
|
|
55
68
|
* @returns
|
|
56
69
|
*/
|
|
57
|
-
|
|
70
|
+
const generateDynamoPKS = ({ type, L1, L2, L3, L4, L5, L6, additionalPKValues, }) => {
|
|
58
71
|
const c = '#';
|
|
59
|
-
const keys = [L1, L2, L3, L4, L5, L6].filter(notEmpty);
|
|
60
|
-
const additionalPK = additionalPKValues && additionalPKValues
|
|
72
|
+
const keys = [L1, L2, L3, L4, L5, L6].filter(array_1.notEmpty);
|
|
73
|
+
const additionalPK = additionalPKValues && (additionalPKValues === null || additionalPKValues === void 0 ? void 0 : additionalPKValues.length) > 0
|
|
61
74
|
? `#${additionalPKValues.join(c)}`
|
|
62
75
|
: '';
|
|
63
|
-
return {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
...(keys.length >= 2 && {
|
|
74
|
-
PK2: [keys[0], keys[1]].join(c),
|
|
75
|
-
}),
|
|
76
|
-
...(keys.length >= 3 && {
|
|
77
|
-
PK3: [keys[0], keys[1], keys[2]].join(c),
|
|
78
|
-
}),
|
|
79
|
-
...(keys.length >= 4 && {
|
|
80
|
-
PK4: [keys[0], keys[1], keys[2], keys[3]].join(c),
|
|
81
|
-
}),
|
|
82
|
-
...(keys.length >= 5 && {
|
|
83
|
-
PK5: [keys[0], keys[1], keys[2], keys[3], keys[4]].join(c),
|
|
84
|
-
}),
|
|
85
|
-
};
|
|
76
|
+
return Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ PK: keys.join(c) + additionalPK, type,
|
|
77
|
+
L1 }, (L2 && { L2 })), (L3 && { L3 })), (L4 && { L4 })), (L5 && { L5 })), (L6 && { L6 })), { PK1: L1 }), (keys.length >= 2 && {
|
|
78
|
+
PK2: [keys[0], keys[1]].join(c),
|
|
79
|
+
})), (keys.length >= 3 && {
|
|
80
|
+
PK3: [keys[0], keys[1], keys[2]].join(c),
|
|
81
|
+
})), (keys.length >= 4 && {
|
|
82
|
+
PK4: [keys[0], keys[1], keys[2], keys[3]].join(c),
|
|
83
|
+
})), (keys.length >= 5 && {
|
|
84
|
+
PK5: [keys[0], keys[1], keys[2], keys[3], keys[4]].join(c),
|
|
85
|
+
}));
|
|
86
86
|
};
|
|
87
|
+
exports.generateDynamoPKS = generateDynamoPKS;
|
package/dist/api/helpers/aws.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.setAwsRegion = void 0;
|
|
4
|
+
const dynamo_1 = require("./dynamo");
|
|
5
|
+
const s3_1 = require("./s3");
|
|
6
|
+
const ses_1 = require("./ses");
|
|
7
|
+
const sqs_1 = require("./sqs");
|
|
8
|
+
const setAwsRegion = (region) => {
|
|
9
|
+
(0, dynamo_1.setDynamo)(region);
|
|
10
|
+
(0, s3_1.setS3)(region);
|
|
11
|
+
(0, ses_1.setSes)(region);
|
|
12
|
+
(0, sqs_1.setSqs)(region);
|
|
10
13
|
};
|
|
14
|
+
exports.setAwsRegion = setAwsRegion;
|
|
@@ -1,9 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
5
10
|
};
|
|
6
|
-
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.invalidateCloudfrontPath = exports.setCF = void 0;
|
|
16
|
+
const cloudfront_1 = __importDefault(require("aws-sdk/clients/cloudfront"));
|
|
17
|
+
let cf = new cloudfront_1.default();
|
|
18
|
+
const setCF = (region) => {
|
|
19
|
+
cf = new cloudfront_1.default({ region });
|
|
20
|
+
};
|
|
21
|
+
exports.setCF = setCF;
|
|
22
|
+
const invalidateCloudfrontPath = ({ path, distributionId, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
7
23
|
const params = {
|
|
8
24
|
DistributionId: distributionId,
|
|
9
25
|
InvalidationBatch: {
|
|
@@ -14,5 +30,6 @@ export const invalidateCloudfrontPath = async ({ path, distributionId, }) => {
|
|
|
14
30
|
},
|
|
15
31
|
},
|
|
16
32
|
};
|
|
17
|
-
|
|
18
|
-
};
|
|
33
|
+
yield cf.createInvalidation(params).promise();
|
|
34
|
+
});
|
|
35
|
+
exports.invalidateCloudfrontPath = invalidateCloudfrontPath;
|
|
@@ -1,42 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.getDynamoUpdates = exports.wipeTable = exports.getDynamoTtlMinutes = exports.getDynamoTtlDays = exports.queryDynamo = exports.getItemsDynamo = exports.getItemDynamo = exports.scan = exports.batchDelete = exports.batchWrite = exports.putDynamo = exports.setDynamo = exports.dynamoDb = void 0;
|
|
1
36
|
/* eslint-disable guard-for-in */
|
|
2
37
|
/* eslint-disable no-restricted-syntax */
|
|
3
38
|
/* eslint-disable no-await-in-loop */
|
|
4
39
|
/* eslint-disable prefer-const */
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
40
|
+
const dynamodb_1 = __importStar(require("aws-sdk/clients/dynamodb"));
|
|
41
|
+
const array_1 = require("../../common/helpers/array");
|
|
42
|
+
const async_1 = require("../../common/helpers/async");
|
|
43
|
+
const log_1 = require("../../common/helpers/log");
|
|
44
|
+
const sleep_1 = require("../../common/helpers/sleep");
|
|
10
45
|
// eslint-disable-next-line import/no-mutable-exports
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
dynamoDb = new DocumentClient({ region });
|
|
46
|
+
exports.dynamoDb = new dynamodb_1.DocumentClient();
|
|
47
|
+
const setDynamo = (region) => {
|
|
48
|
+
exports.dynamoDb = new dynamodb_1.DocumentClient({ region });
|
|
14
49
|
};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
50
|
+
exports.setDynamo = setDynamo;
|
|
51
|
+
const putDynamo = (item, tableName, opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
|
+
const params = Object.assign({ TableName: tableName,
|
|
18
53
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
-
Item: item,
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
};
|
|
24
|
-
info(`running dynamo put=${JSON.stringify(params, null, 2)}`);
|
|
54
|
+
Item: item }, ((opt === null || opt === void 0 ? void 0 : opt.pkName) && {
|
|
55
|
+
ConditionExpression: `attribute_not_exists(${opt.pkName})`,
|
|
56
|
+
}));
|
|
57
|
+
(0, log_1.info)(`running dynamo put=${JSON.stringify(params, null, 2)}`);
|
|
25
58
|
// write the todo to the database
|
|
26
|
-
const put =
|
|
59
|
+
const put = yield exports.dynamoDb.put(params).promise();
|
|
27
60
|
if (put.$response.error && put.$response.error.statusCode) {
|
|
28
61
|
return { error: put.$response.error.message };
|
|
29
62
|
}
|
|
30
63
|
// put never returns into, so just use what we have already
|
|
31
64
|
return { data: item };
|
|
32
|
-
};
|
|
33
|
-
|
|
65
|
+
});
|
|
66
|
+
exports.putDynamo = putDynamo;
|
|
67
|
+
let batchWriteRaw = (req) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
68
|
let count = 0;
|
|
35
69
|
let max = 5;
|
|
36
70
|
// eslint-disable-next-line no-constant-condition
|
|
37
71
|
while (true)
|
|
38
72
|
try {
|
|
39
|
-
const res =
|
|
73
|
+
const res = yield exports.dynamoDb
|
|
40
74
|
.batchWrite({
|
|
41
75
|
RequestItems: req,
|
|
42
76
|
})
|
|
@@ -50,7 +84,7 @@ let batchWriteRaw = async (req) => {
|
|
|
50
84
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
85
|
let es = e.toString();
|
|
52
86
|
let msg = es;
|
|
53
|
-
warn('dynamo write error', msg);
|
|
87
|
+
(0, log_1.warn)('dynamo write error', msg);
|
|
54
88
|
if (es.indexOf('429') !== -1 ||
|
|
55
89
|
es.indexOf('ProvisionedThroughputExceeded') !== -1) {
|
|
56
90
|
count += 1;
|
|
@@ -62,17 +96,18 @@ let batchWriteRaw = async (req) => {
|
|
|
62
96
|
if (count >= max) {
|
|
63
97
|
throw e;
|
|
64
98
|
}
|
|
65
|
-
warn(`dynamo retry ${count}/${max}`);
|
|
66
|
-
|
|
99
|
+
(0, log_1.warn)(`dynamo retry ${count}/${max}`);
|
|
100
|
+
yield (0, sleep_1.sleep)(2000);
|
|
67
101
|
}
|
|
68
|
-
};
|
|
102
|
+
});
|
|
69
103
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
70
|
-
|
|
104
|
+
const batchWrite = (tableName, itemsIn, breakOnError = false) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
var _a, _b;
|
|
71
106
|
let items = JSON.parse(JSON.stringify(itemsIn));
|
|
72
|
-
debug(`push to dynamo:${tableName} - count=${itemsIn.length}`);
|
|
107
|
+
(0, log_1.debug)(`push to dynamo:${tableName} - count=${itemsIn.length}`);
|
|
73
108
|
const error = [];
|
|
74
109
|
while (items.length > 0) {
|
|
75
|
-
const { part, rest } = take(items, 25);
|
|
110
|
+
const { part, rest } = (0, array_1.take)(items, 25);
|
|
76
111
|
// eslint-disable-next-line no-param-reassign
|
|
77
112
|
items = rest;
|
|
78
113
|
let req = {
|
|
@@ -80,8 +115,8 @@ export const batchWrite = async (tableName, itemsIn, breakOnError = false) => {
|
|
|
80
115
|
PutRequest: { Item: item },
|
|
81
116
|
})),
|
|
82
117
|
};
|
|
83
|
-
let res =
|
|
84
|
-
const newError = res.$response
|
|
118
|
+
let res = yield batchWriteRaw(req);
|
|
119
|
+
const newError = (_b = (_a = res.$response) === null || _a === void 0 ? void 0 : _a.error) !== null && _b !== void 0 ? _b : null;
|
|
85
120
|
if (newError) {
|
|
86
121
|
error.push(newError);
|
|
87
122
|
if (breakOnError) {
|
|
@@ -89,18 +124,20 @@ export const batchWrite = async (tableName, itemsIn, breakOnError = false) => {
|
|
|
89
124
|
}
|
|
90
125
|
}
|
|
91
126
|
}
|
|
92
|
-
if (error
|
|
127
|
+
if ((error === null || error === void 0 ? void 0 : error.length) > 0) {
|
|
93
128
|
const me = error.join('\n');
|
|
94
|
-
|
|
129
|
+
(0, log_1.error)(`batch write error=${me}`);
|
|
95
130
|
return { error: me };
|
|
96
131
|
}
|
|
97
132
|
return {};
|
|
98
|
-
};
|
|
99
|
-
|
|
100
|
-
|
|
133
|
+
});
|
|
134
|
+
exports.batchWrite = batchWrite;
|
|
135
|
+
const batchDelete = ({ tableName, breakOnError = true, pkName, keys, rangeName, rangeKeys, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
+
(0, log_1.info)(`wipe keys dynamo:${tableName} - count=${keys.length}`);
|
|
101
137
|
const error = [];
|
|
102
138
|
let breakV = false;
|
|
103
|
-
|
|
139
|
+
yield (0, async_1.asyncForEach)(keys, (key, i) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
var _c, _d;
|
|
104
141
|
if (breakV) {
|
|
105
142
|
return;
|
|
106
143
|
}
|
|
@@ -109,28 +146,29 @@ export const batchDelete = async ({ tableName, breakOnError = true, pkName, keys
|
|
|
109
146
|
Key: { [pkName]: key },
|
|
110
147
|
};
|
|
111
148
|
if (rangeName) {
|
|
112
|
-
let rangeValue = rangeKeys
|
|
149
|
+
let rangeValue = rangeKeys === null || rangeKeys === void 0 ? void 0 : rangeKeys[i];
|
|
113
150
|
if (rangeValue) {
|
|
114
151
|
params.Key[rangeName] = rangeValue;
|
|
115
152
|
}
|
|
116
153
|
}
|
|
117
|
-
const res =
|
|
118
|
-
const newError = res.$response
|
|
154
|
+
const res = yield exports.dynamoDb.delete(params).promise();
|
|
155
|
+
const newError = (_d = (_c = res.$response) === null || _c === void 0 ? void 0 : _c.error) !== null && _d !== void 0 ? _d : null;
|
|
119
156
|
if (newError) {
|
|
120
157
|
error.push(newError);
|
|
121
158
|
if (breakOnError) {
|
|
122
159
|
breakV = true;
|
|
123
160
|
}
|
|
124
161
|
}
|
|
125
|
-
});
|
|
126
|
-
if (error
|
|
162
|
+
}));
|
|
163
|
+
if ((error === null || error === void 0 ? void 0 : error.length) > 0) {
|
|
127
164
|
const me = error.join('\n');
|
|
128
|
-
|
|
165
|
+
(0, log_1.error)(`batch write error=${me}`);
|
|
129
166
|
return { error: me };
|
|
130
167
|
}
|
|
131
168
|
return {};
|
|
132
|
-
};
|
|
133
|
-
|
|
169
|
+
});
|
|
170
|
+
exports.batchDelete = batchDelete;
|
|
171
|
+
const scan = (tableName, opt) => __awaiter(void 0, void 0, void 0, function* () {
|
|
134
172
|
const Items = [];
|
|
135
173
|
let ExclusiveStartKey;
|
|
136
174
|
do {
|
|
@@ -138,17 +176,17 @@ export const scan = async (tableName, opt) => {
|
|
|
138
176
|
TableName: tableName,
|
|
139
177
|
ExclusiveStartKey,
|
|
140
178
|
};
|
|
141
|
-
if (opt
|
|
179
|
+
if (opt === null || opt === void 0 ? void 0 : opt.filter) {
|
|
142
180
|
params.FilterExpression = opt.filter.filterExpression;
|
|
143
181
|
params.ExpressionAttributeNames = opt.filter.attrNames;
|
|
144
182
|
params.ExpressionAttributeValues = opt.filter.attrValues;
|
|
145
183
|
}
|
|
146
|
-
if (opt
|
|
184
|
+
if (opt === null || opt === void 0 ? void 0 : opt.requiredAttributeList) {
|
|
147
185
|
params.ProjectionExpression = opt.requiredAttributeList.join(', ');
|
|
148
186
|
}
|
|
149
187
|
const { Items: newitems, LastEvaluatedKey, $response,
|
|
150
188
|
// eslint-disable-next-line no-await-in-loop
|
|
151
|
-
} =
|
|
189
|
+
} = yield exports.dynamoDb.scan(params).promise();
|
|
152
190
|
ExclusiveStartKey = LastEvaluatedKey;
|
|
153
191
|
if ($response.error && $response.error.statusCode) {
|
|
154
192
|
throw new Error($response.error.message);
|
|
@@ -157,26 +195,29 @@ export const scan = async (tableName, opt) => {
|
|
|
157
195
|
Items.push(...newitems.map((r) => r));
|
|
158
196
|
}
|
|
159
197
|
} while (ExclusiveStartKey);
|
|
160
|
-
info(`dynamo scan against ${tableName} ok, count=${Items
|
|
198
|
+
(0, log_1.info)(`dynamo scan against ${tableName} ok, count=${Items === null || Items === void 0 ? void 0 : Items.length}`);
|
|
161
199
|
return Items;
|
|
162
|
-
};
|
|
163
|
-
|
|
200
|
+
});
|
|
201
|
+
exports.scan = scan;
|
|
202
|
+
const getItemDynamo = ({ tableName, pkName, pkValue, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
164
203
|
const params = {
|
|
165
204
|
Key: { [pkName]: pkValue },
|
|
166
205
|
TableName: tableName,
|
|
167
206
|
};
|
|
168
207
|
try {
|
|
169
|
-
const res =
|
|
208
|
+
const res = yield exports.dynamoDb.get(params).promise();
|
|
170
209
|
const ret = res.Item;
|
|
171
|
-
debug(`got dynamo getitem=${JSON.stringify(params, null, 2)}`);
|
|
210
|
+
(0, log_1.debug)(`got dynamo getitem=${JSON.stringify(params, null, 2)}`);
|
|
172
211
|
return ret;
|
|
173
212
|
}
|
|
174
213
|
catch (e) {
|
|
175
|
-
|
|
214
|
+
(0, log_1.error)(e);
|
|
176
215
|
throw e;
|
|
177
216
|
}
|
|
178
|
-
};
|
|
179
|
-
|
|
217
|
+
});
|
|
218
|
+
exports.getItemDynamo = getItemDynamo;
|
|
219
|
+
const getItemsDynamo = ({ tableName, items, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
220
|
+
var _e, _f;
|
|
180
221
|
const params = {
|
|
181
222
|
RequestItems: {
|
|
182
223
|
[tableName]: {
|
|
@@ -186,11 +227,11 @@ export const getItemsDynamo = async ({ tableName, items, }) => {
|
|
|
186
227
|
},
|
|
187
228
|
},
|
|
188
229
|
};
|
|
189
|
-
const dbRaw = new
|
|
230
|
+
const dbRaw = new dynamodb_1.default({ apiVersion: '2012-10-08' });
|
|
190
231
|
try {
|
|
191
|
-
const res =
|
|
192
|
-
debug(`got dynamo getitems=${JSON.stringify(res, null, 2)}`);
|
|
193
|
-
let ret = res.Responses
|
|
232
|
+
const res = yield dbRaw.batchGetItem(params).promise();
|
|
233
|
+
(0, log_1.debug)(`got dynamo getitems=${JSON.stringify(res, null, 2)}`);
|
|
234
|
+
let ret = ((_f = (_e = res.Responses) === null || _e === void 0 ? void 0 : _e[tableName]) === null || _f === void 0 ? void 0 : _f.map((s) => dynamodb_1.Converter.unmarshall(s))) ||
|
|
194
235
|
[];
|
|
195
236
|
return ret;
|
|
196
237
|
}
|
|
@@ -200,11 +241,13 @@ export const getItemsDynamo = async ({ tableName, items, }) => {
|
|
|
200
241
|
'\n' +
|
|
201
242
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
243
|
e.toString();
|
|
203
|
-
|
|
244
|
+
(0, log_1.error)(msg);
|
|
204
245
|
throw e;
|
|
205
246
|
}
|
|
206
|
-
};
|
|
207
|
-
|
|
247
|
+
});
|
|
248
|
+
exports.getItemsDynamo = getItemsDynamo;
|
|
249
|
+
const queryDynamo = ({ tableName, pkName, pkValue, pkOperator = '=', skName, skValue, skOperator = '=', indexName, count = 1000, startKey: startKeyIn, filterName, filterValue, filterOperator = '=', sortAscending = true, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
250
|
+
var _g;
|
|
208
251
|
let startKey = startKeyIn;
|
|
209
252
|
let kce = `#${pkName.toLowerCase()} ${pkOperator} :${pkName.toLowerCase()}`;
|
|
210
253
|
const ean = { [`#${pkName.toLowerCase()}`]: pkName };
|
|
@@ -277,32 +320,36 @@ export const queryDynamo = async ({ tableName, pkName, pkValue, pkOperator = '='
|
|
|
277
320
|
LastEvaluatedKey: lek,
|
|
278
321
|
$response,
|
|
279
322
|
// eslint-disable-next-line no-await-in-loop
|
|
280
|
-
} =
|
|
323
|
+
} = yield exports.dynamoDb.query(params).promise());
|
|
281
324
|
}
|
|
282
325
|
catch (e) {
|
|
283
|
-
|
|
326
|
+
(0, log_1.error)('error. query params=', JSON.stringify(params), e);
|
|
284
327
|
throw e;
|
|
285
328
|
}
|
|
286
329
|
startKey = lek;
|
|
287
330
|
if ($response.error) {
|
|
288
|
-
|
|
331
|
+
(0, log_1.error)('error. query params=', JSON.stringify(params));
|
|
289
332
|
throw new Error($response.error.message);
|
|
290
333
|
}
|
|
291
|
-
debug(`dynamo query against ${params
|
|
334
|
+
(0, log_1.debug)(`dynamo query against ${params === null || params === void 0 ? void 0 : params.TableName} ok, count=${newitems === null || newitems === void 0 ? void 0 : newitems.length} ${JSON.stringify(params)}`, ` next startkey=${startKey}`);
|
|
292
335
|
if (newitems) {
|
|
293
336
|
Items.push(...newitems.map((r) => r));
|
|
294
337
|
}
|
|
295
|
-
if (count > 0 && (newitems
|
|
338
|
+
if (count > 0 && ((_g = newitems === null || newitems === void 0 ? void 0 : newitems.length) !== null && _g !== void 0 ? _g : 0) >= count) {
|
|
296
339
|
return { Items, startKey };
|
|
297
340
|
}
|
|
298
341
|
} while (startKey && Object.keys(startKey).length > 0);
|
|
299
342
|
return { Items, startKey: undefined };
|
|
300
|
-
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
343
|
+
});
|
|
344
|
+
exports.queryDynamo = queryDynamo;
|
|
345
|
+
const getDynamoTtlDays = (days) => Math.ceil(new Date().getTime() / 1000) + days * 86400;
|
|
346
|
+
exports.getDynamoTtlDays = getDynamoTtlDays;
|
|
347
|
+
const getDynamoTtlMinutes = (mins) => Math.ceil(new Date().getTime() / 1000) + mins * 60;
|
|
348
|
+
exports.getDynamoTtlMinutes = getDynamoTtlMinutes;
|
|
349
|
+
const wipeTable = (tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
350
|
+
var _h;
|
|
351
|
+
const dbRaw = new dynamodb_1.default({ apiVersion: '2012-10-08' });
|
|
352
|
+
let infoV = yield dbRaw
|
|
306
353
|
.describeTable({
|
|
307
354
|
TableName: tableName,
|
|
308
355
|
})
|
|
@@ -317,15 +364,15 @@ export const wipeTable = async (tableName) => {
|
|
|
317
364
|
let all = [];
|
|
318
365
|
let working;
|
|
319
366
|
do {
|
|
320
|
-
working =
|
|
321
|
-
working.Items
|
|
367
|
+
working = yield dbRaw.scan(params).promise();
|
|
368
|
+
(_h = working.Items) === null || _h === void 0 ? void 0 : _h.forEach((item) => all.push(item));
|
|
322
369
|
params.ExclusiveStartKey = working.LastEvaluatedKey;
|
|
323
370
|
} while (typeof working.LastEvaluatedKey !== 'undefined');
|
|
324
|
-
warn(`will delete ${all
|
|
371
|
+
(0, log_1.warn)(`will delete ${all === null || all === void 0 ? void 0 : all.length} items from ${tableName}`);
|
|
325
372
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
326
373
|
// @ts-ignore
|
|
327
|
-
const datagr = chunk(all, 25);
|
|
328
|
-
let res =
|
|
374
|
+
const datagr = (0, array_1.chunk)(all, 25);
|
|
375
|
+
let res = yield Promise.all(datagr.map((group) => dbRaw
|
|
329
376
|
.batchWriteItem({
|
|
330
377
|
RequestItems: {
|
|
331
378
|
[`${tableName}`]: group.map((s) => ({
|
|
@@ -339,16 +386,17 @@ export const wipeTable = async (tableName) => {
|
|
|
339
386
|
})
|
|
340
387
|
.promise()));
|
|
341
388
|
let errors = res
|
|
342
|
-
.map((r) => (r
|
|
343
|
-
.filter(notEmpty);
|
|
389
|
+
.map((r) => { var _a, _b; return ((_b = (((_a = r === null || r === void 0 ? void 0 : r.$response) === null || _a === void 0 ? void 0 : _a.error) || {})) === null || _b === void 0 ? void 0 : _b.message) || undefined; })
|
|
390
|
+
.filter(array_1.notEmpty);
|
|
344
391
|
if (errors.length > 0) {
|
|
345
|
-
|
|
392
|
+
(0, log_1.error)('errors=', JSON.stringify(errors));
|
|
346
393
|
return { errors };
|
|
347
394
|
}
|
|
348
|
-
warn(`cleared table ${tableName}`);
|
|
395
|
+
(0, log_1.warn)(`cleared table ${tableName}`);
|
|
349
396
|
return {};
|
|
350
|
-
};
|
|
351
|
-
|
|
397
|
+
});
|
|
398
|
+
exports.wipeTable = wipeTable;
|
|
399
|
+
const getDynamoUpdates = (items) => {
|
|
352
400
|
const cleanedKeys = Object.keys(items).filter((r) => r !== 'PK');
|
|
353
401
|
let UpdateExpression = '';
|
|
354
402
|
const ExpressionAttributeNames = {};
|
|
@@ -362,7 +410,7 @@ export const getDynamoUpdates = (items) => {
|
|
|
362
410
|
ExpressionAttributeValues[`:${key}`] = v;
|
|
363
411
|
}
|
|
364
412
|
else {
|
|
365
|
-
warn(`no value for key:${key}`);
|
|
413
|
+
(0, log_1.warn)(`no value for key:${key}`);
|
|
366
414
|
}
|
|
367
415
|
});
|
|
368
416
|
return {
|
|
@@ -371,3 +419,4 @@ export const getDynamoUpdates = (items) => {
|
|
|
371
419
|
ExpressionAttributeValues,
|
|
372
420
|
};
|
|
373
421
|
};
|
|
422
|
+
exports.getDynamoUpdates = getDynamoUpdates;
|
|
@@ -1,15 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.generateSSMParams = exports.generateTableRef = void 0;
|
|
4
|
+
const aws_cdk_lib_1 = require("aws-cdk-lib");
|
|
5
|
+
const ssm_1 = require("./ssm");
|
|
6
|
+
const generateTableRef = ({ stack, baseKey, hasStream, hasGSI, }) => {
|
|
4
7
|
const tableStreamArn = !hasStream
|
|
5
8
|
? undefined
|
|
6
|
-
: loadSsmString({ stack, path: `${baseKey}/streamArn` });
|
|
9
|
+
: (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/streamArn` });
|
|
7
10
|
const globalIndexes = !hasGSI
|
|
8
11
|
? undefined
|
|
9
|
-
: loadSsmStringList({ stack, path: `${baseKey}/gsi` });
|
|
10
|
-
const shortName =
|
|
11
|
-
const table =
|
|
12
|
-
tableArn: loadSsmString({ stack, path: `${baseKey}/arn` }),
|
|
12
|
+
: (0, ssm_1.loadSsmStringList)({ stack, path: `${baseKey}/gsi` });
|
|
13
|
+
const shortName = aws_cdk_lib_1.aws_ssm.StringParameter.valueFromLookup(stack, `${baseKey}/shortName`);
|
|
14
|
+
const table = aws_cdk_lib_1.aws_dynamodb.Table.fromTableAttributes(stack, baseKey, {
|
|
15
|
+
tableArn: (0, ssm_1.loadSsmString)({ stack, path: `${baseKey}/arn` }),
|
|
13
16
|
tableStreamArn,
|
|
14
17
|
globalIndexes,
|
|
15
18
|
});
|
|
@@ -18,25 +21,27 @@ export const generateTableRef = ({ stack, baseKey, hasStream, hasGSI, }) => {
|
|
|
18
21
|
table,
|
|
19
22
|
};
|
|
20
23
|
};
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
exports.generateTableRef = generateTableRef;
|
|
25
|
+
const generateSSMParams = ({ stack, table, baseKey, gsi, shortName, }) => {
|
|
26
|
+
(0, ssm_1.saveToSsm)({ stack, path: `${baseKey}/arn`, value: table.tableArn });
|
|
23
27
|
if (table.tableStreamArn) {
|
|
24
|
-
saveToSsm({
|
|
28
|
+
(0, ssm_1.saveToSsm)({
|
|
25
29
|
stack,
|
|
26
30
|
path: `${baseKey}/streamArn`,
|
|
27
31
|
value: table.tableStreamArn,
|
|
28
32
|
});
|
|
29
33
|
}
|
|
30
|
-
if (gsi && gsi
|
|
31
|
-
saveToSsm({
|
|
34
|
+
if (gsi && (gsi === null || gsi === void 0 ? void 0 : gsi.length) > 0) {
|
|
35
|
+
(0, ssm_1.saveToSsm)({
|
|
32
36
|
stack,
|
|
33
37
|
path: `${baseKey}/gsi`,
|
|
34
38
|
value: gsi.join(','),
|
|
35
39
|
});
|
|
36
40
|
}
|
|
37
|
-
saveToSsm({
|
|
41
|
+
(0, ssm_1.saveToSsm)({
|
|
38
42
|
stack,
|
|
39
43
|
path: `${baseKey}/shortName`,
|
|
40
44
|
value: shortName,
|
|
41
45
|
});
|
|
42
46
|
};
|
|
47
|
+
exports.generateSSMParams = generateSSMParams;
|