ag-common 0.0.315 → 0.0.318
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/dynamo.d.ts +8 -3
- package/dist/api/helpers/dynamo.js +31 -7
- package/dist/api/helpers/s3.d.ts +2 -2
- package/dist/api/helpers/s3.js +3 -3
- package/dist/api/helpers/ses.d.ts +2 -2
- package/dist/api/helpers/ses.js +3 -3
- package/dist/api/helpers/sqs.d.ts +2 -2
- package/dist/api/helpers/sqs.js +3 -3
- package/dist/api/helpers/validateOpenApi.d.ts +2 -0
- package/dist/ui/components/index.d.ts +0 -1
- package/dist/ui/components/index.js +0 -1
- package/package.json +2 -2
- package/dist/ui/components/LogoutButton/index.d.ts +0 -6
- package/dist/ui/components/LogoutButton/index.js +0 -27
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IQueryDynamo, Key } from '../types';
|
|
2
|
-
import
|
|
3
|
-
export declare let dynamoDb:
|
|
1
|
+
import { DYNAMOKEYS, IQueryDynamo, Key } from '../types';
|
|
2
|
+
import DynamoDB from 'aws-sdk/clients/dynamodb';
|
|
3
|
+
export declare let dynamoDb: DynamoDB.DocumentClient;
|
|
4
4
|
export declare const setDynamo: (region: string) => void;
|
|
5
5
|
export declare const putDynamo: <T>(item: T, tableName: string) => Promise<{
|
|
6
6
|
error?: string | undefined;
|
|
@@ -44,3 +44,8 @@ export declare const getDynamoTtl: (days: number) => number;
|
|
|
44
44
|
export declare const wipeTable: (tableName: string) => Promise<{
|
|
45
45
|
errors?: string[] | undefined;
|
|
46
46
|
}>;
|
|
47
|
+
export declare const getDynamoUpdates: (items: DYNAMOKEYS) => {
|
|
48
|
+
UpdateExpression: string;
|
|
49
|
+
ExpressionAttributeNames: Record<string, string>;
|
|
50
|
+
ExpressionAttributeValues: Record<string, string | number>;
|
|
51
|
+
};
|
|
@@ -12,16 +12,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.wipeTable = exports.getDynamoTtl = exports.queryDynamo = exports.getItemsDynamo = exports.getItemDynamo = exports.scan = exports.batchDelete = exports.batchWrite = exports.putDynamo = exports.setDynamo = exports.dynamoDb = void 0;
|
|
15
|
+
exports.getDynamoUpdates = exports.wipeTable = exports.getDynamoTtl = exports.queryDynamo = exports.getItemsDynamo = exports.getItemDynamo = exports.scan = exports.batchDelete = exports.batchWrite = exports.putDynamo = exports.setDynamo = exports.dynamoDb = void 0;
|
|
16
16
|
const log_1 = require("../../common/helpers/log");
|
|
17
17
|
const array_1 = require("../../common/helpers/array");
|
|
18
18
|
const sleep_1 = require("../../common/helpers/sleep");
|
|
19
19
|
const async_1 = require("../../common/helpers/async");
|
|
20
|
-
const
|
|
20
|
+
const dynamodb_1 = __importDefault(require("aws-sdk/clients/dynamodb"));
|
|
21
21
|
// eslint-disable-next-line import/no-mutable-exports
|
|
22
|
-
exports.dynamoDb = new
|
|
22
|
+
exports.dynamoDb = new dynamodb_1.default.DocumentClient();
|
|
23
23
|
const setDynamo = (region) => {
|
|
24
|
-
exports.dynamoDb = new
|
|
24
|
+
exports.dynamoDb = new dynamodb_1.default.DocumentClient({ region });
|
|
25
25
|
};
|
|
26
26
|
exports.setDynamo = setDynamo;
|
|
27
27
|
const putDynamo = (item, tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -194,11 +194,11 @@ const getItemsDynamo = ({ tableName, items, }) => __awaiter(void 0, void 0, void
|
|
|
194
194
|
},
|
|
195
195
|
},
|
|
196
196
|
};
|
|
197
|
-
const dbRaw = new
|
|
197
|
+
const dbRaw = new dynamodb_1.default({ apiVersion: '2012-10-08' });
|
|
198
198
|
try {
|
|
199
199
|
const res = yield dbRaw.batchGetItem(params).promise();
|
|
200
200
|
(0, log_1.debug)(`got dynamo getitems=${JSON.stringify(res, null, 2)}`);
|
|
201
|
-
let ret = ((_f = (_e = res.Responses) === null || _e === void 0 ? void 0 : _e[tableName]) === null || _f === void 0 ? void 0 : _f.map((s) =>
|
|
201
|
+
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.default.Converter.unmarshall(s))) || [];
|
|
202
202
|
return ret;
|
|
203
203
|
}
|
|
204
204
|
catch (e) {
|
|
@@ -312,7 +312,7 @@ const getDynamoTtl = (days) => Math.ceil(new Date().getTime() / 1000) + days * 8
|
|
|
312
312
|
exports.getDynamoTtl = getDynamoTtl;
|
|
313
313
|
const wipeTable = (tableName) => __awaiter(void 0, void 0, void 0, function* () {
|
|
314
314
|
var _j;
|
|
315
|
-
const dbRaw = new
|
|
315
|
+
const dbRaw = new dynamodb_1.default({ apiVersion: '2012-10-08' });
|
|
316
316
|
let infoV = yield dbRaw
|
|
317
317
|
.describeTable({
|
|
318
318
|
TableName: tableName,
|
|
@@ -354,3 +354,27 @@ const wipeTable = (tableName) => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
354
354
|
return {};
|
|
355
355
|
});
|
|
356
356
|
exports.wipeTable = wipeTable;
|
|
357
|
+
const getDynamoUpdates = (items) => {
|
|
358
|
+
const cleanedKeys = Object.keys(items).filter((r) => r !== 'PK');
|
|
359
|
+
let UpdateExpression = '';
|
|
360
|
+
const ExpressionAttributeNames = {};
|
|
361
|
+
const ExpressionAttributeValues = {};
|
|
362
|
+
cleanedKeys.forEach((key) => {
|
|
363
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
364
|
+
const v = items[key];
|
|
365
|
+
if (v) {
|
|
366
|
+
UpdateExpression += `${!UpdateExpression ? '' : ','} #${key} = :${key}`;
|
|
367
|
+
ExpressionAttributeNames[`#${key}`] = key;
|
|
368
|
+
ExpressionAttributeValues[`:${key}`] = v;
|
|
369
|
+
}
|
|
370
|
+
else {
|
|
371
|
+
(0, log_1.warn)(`no value for key:${key}`);
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
return {
|
|
375
|
+
UpdateExpression,
|
|
376
|
+
ExpressionAttributeNames,
|
|
377
|
+
ExpressionAttributeValues,
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
exports.getDynamoUpdates = getDynamoUpdates;
|
package/dist/api/helpers/s3.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import { Blob } from 'aws-sdk/lib/dynamodb/document_client';
|
|
3
|
-
import
|
|
3
|
+
import S3 from 'aws-sdk/clients/s3';
|
|
4
4
|
export declare const setS3: (region: string) => void;
|
|
5
5
|
export declare const getS3Object: ({ fileurl, }: {
|
|
6
6
|
fileurl: {
|
|
7
7
|
Bucket: string;
|
|
8
8
|
Key: string;
|
|
9
9
|
};
|
|
10
|
-
}) => Promise<import("aws-sdk/lib/request").PromiseResult<
|
|
10
|
+
}) => Promise<import("aws-sdk/lib/request").PromiseResult<S3.GetObjectOutput, import("aws-sdk/lib/error").AWSError>>;
|
|
11
11
|
export declare const putS3Object: ({ Body, Bucket, Key, ContentType, }: {
|
|
12
12
|
ContentType?: string | undefined;
|
|
13
13
|
Body: string | Blob;
|
package/dist/api/helpers/s3.js
CHANGED
|
@@ -13,10 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.deleteFile = exports.uploadFile = exports.putS3Object = exports.getS3Object = exports.setS3 = void 0;
|
|
16
|
-
const
|
|
17
|
-
let s3 = new
|
|
16
|
+
const s3_1 = __importDefault(require("aws-sdk/clients/s3"));
|
|
17
|
+
let s3 = new s3_1.default();
|
|
18
18
|
const setS3 = (region) => {
|
|
19
|
-
s3 = new
|
|
19
|
+
s3 = new s3_1.default({ region });
|
|
20
20
|
};
|
|
21
21
|
exports.setS3 = setS3;
|
|
22
22
|
const getS3Object = ({ fileurl, }) => __awaiter(void 0, void 0, void 0, function* () {
|
package/dist/api/helpers/ses.js
CHANGED
|
@@ -13,10 +13,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.sendEmails = exports.sendEmail = exports.setSes = exports.ses = void 0;
|
|
16
|
-
const
|
|
17
|
-
exports.ses = new
|
|
16
|
+
const ses_1 = __importDefault(require("aws-sdk/clients/ses"));
|
|
17
|
+
exports.ses = new ses_1.default();
|
|
18
18
|
const setSes = (region) => {
|
|
19
|
-
exports.ses = new
|
|
19
|
+
exports.ses = new ses_1.default({ region });
|
|
20
20
|
};
|
|
21
21
|
exports.setSes = setSes;
|
|
22
22
|
const sendEmail = ({ to, message, subject, sourceArn, from, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
export declare let sqs:
|
|
1
|
+
import SQS from 'aws-sdk/clients/sqs';
|
|
2
|
+
export declare let sqs: SQS;
|
|
3
3
|
export declare const setSqs: (region: string) => void;
|
|
4
4
|
export declare const sendMessages: <T>(items: T[], queueUrl: string) => Promise<void>;
|
package/dist/api/helpers/sqs.js
CHANGED
|
@@ -14,11 +14,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.sendMessages = exports.setSqs = exports.sqs = void 0;
|
|
16
16
|
const common_1 = require("../../common");
|
|
17
|
-
const
|
|
17
|
+
const sqs_1 = __importDefault(require("aws-sdk/clients/sqs"));
|
|
18
18
|
// eslint-disable-next-line import/no-mutable-exports
|
|
19
|
-
exports.sqs = new
|
|
19
|
+
exports.sqs = new sqs_1.default();
|
|
20
20
|
const setSqs = (region) => {
|
|
21
|
-
exports.sqs = new
|
|
21
|
+
exports.sqs = new sqs_1.default({ region });
|
|
22
22
|
};
|
|
23
23
|
exports.setSqs = setSqs;
|
|
24
24
|
const sendMessages = (items, queueUrl) => __awaiter(void 0, void 0, void 0, function* () {
|
|
@@ -12,9 +12,11 @@ export declare type NextType<T> = ({ event, body, params, userProfile, lang, }:
|
|
|
12
12
|
export declare function validateOpenApi<T>({ event, next, authorized, schema, COGNITO_USER_POOL_ID, jwksRegion, getAndValidateTokenOverride, }: {
|
|
13
13
|
getAndValidateTokenOverride?: TGetAndValidateToken;
|
|
14
14
|
COGNITO_USER_POOL_ID: string;
|
|
15
|
+
/** pass in openapi schema. eg require('common/openapi.generated').default; */
|
|
15
16
|
schema: any;
|
|
16
17
|
event: APIGatewayEvent;
|
|
17
18
|
next: NextType<T>;
|
|
19
|
+
/** default false */
|
|
18
20
|
authorized?: true | false | 'optional';
|
|
19
21
|
/**
|
|
20
22
|
* default ap-southeast-2
|
|
@@ -27,7 +27,6 @@ __exportStar(require("./HeadersRaw"), exports);
|
|
|
27
27
|
__exportStar(require("./Icon"), exports);
|
|
28
28
|
__exportStar(require("./KebabDots"), exports);
|
|
29
29
|
__exportStar(require("./Loader"), exports);
|
|
30
|
-
__exportStar(require("./LogoutButton"), exports);
|
|
31
30
|
__exportStar(require("./Modal/Modal"), exports);
|
|
32
31
|
__exportStar(require("./Prompt"), exports);
|
|
33
32
|
__exportStar(require("./RowOrColumn"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.318",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"@storybook/react": "6.5.10",
|
|
43
43
|
"@storybook/theming": "6.5.10",
|
|
44
44
|
"@types/jsonwebtoken": "8.5.8",
|
|
45
|
-
"@types/node": "18.7.
|
|
45
|
+
"@types/node": "18.7.6",
|
|
46
46
|
"@types/react": "18.0.17",
|
|
47
47
|
"@types/react-dom": "18.0.6",
|
|
48
48
|
"@types/styled-components": "5.1.26",
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LogoutButton = void 0;
|
|
7
|
-
const colours_1 = require("../../styles/colours");
|
|
8
|
-
const Button_1 = require("../Button");
|
|
9
|
-
const react_1 = __importDefault(require("react"));
|
|
10
|
-
const styled_components_1 = __importDefault(require("styled-components"));
|
|
11
|
-
const Door_1 = require("../../icons/Door");
|
|
12
|
-
const Icon = styled_components_1.default.div `
|
|
13
|
-
width: 1.5rem;
|
|
14
|
-
height: 1.5rem;
|
|
15
|
-
`;
|
|
16
|
-
const ButtonStyled = (0, styled_components_1.default)(Button_1.Button) `
|
|
17
|
-
padding: 0;
|
|
18
|
-
margin: 0;
|
|
19
|
-
border: 0;
|
|
20
|
-
background-color: transparent;
|
|
21
|
-
svg {
|
|
22
|
-
fill: ${colours_1.colours.notificationBlue};
|
|
23
|
-
}
|
|
24
|
-
`;
|
|
25
|
-
const LogoutButton = ({ className, invert, logout, }) => (react_1.default.createElement(ButtonStyled, { invert: invert, className: className, onKeyPress: () => logout(), onClick: () => logout() },
|
|
26
|
-
react_1.default.createElement(Icon, null, Door_1.Door)));
|
|
27
|
-
exports.LogoutButton = LogoutButton;
|