ag-common 0.0.308 → 0.0.311
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/aws.js +4 -2
- package/dist/api/helpers/dynamo.d.ts +1 -1
- package/dist/api/helpers/dynamo.js +2 -13
- package/dist/api/helpers/index.d.ts +1 -0
- package/dist/api/helpers/index.js +1 -0
- package/dist/api/helpers/ses.d.ts +12 -0
- package/dist/api/helpers/ses.js +49 -0
- package/dist/api/types/index.d.ts +6 -0
- package/package.json +6 -6
package/dist/api/helpers/aws.js
CHANGED
|
@@ -3,10 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.setAwsRegion = void 0;
|
|
4
4
|
const dynamo_1 = require("./dynamo");
|
|
5
5
|
const s3_1 = require("./s3");
|
|
6
|
-
const
|
|
6
|
+
const ses_1 = require("./ses");
|
|
7
|
+
const sqs_1 = require("./sqs");
|
|
7
8
|
const setAwsRegion = (region) => {
|
|
8
9
|
(0, dynamo_1.setDynamo)(region);
|
|
9
10
|
(0, s3_1.setS3)(region);
|
|
10
|
-
(0,
|
|
11
|
+
(0, ses_1.setSes)(region);
|
|
12
|
+
(0, sqs_1.setSqs)(region);
|
|
11
13
|
};
|
|
12
14
|
exports.setAwsRegion = setAwsRegion;
|
|
@@ -36,7 +36,7 @@ export declare const getItemsDynamo: <T>({ tableName, items, }: {
|
|
|
36
36
|
}[];
|
|
37
37
|
tableName: string;
|
|
38
38
|
}) => Promise<T[]>;
|
|
39
|
-
export declare const queryDynamo: <T>({ tableName, pkName, pkValue, pkOperator, skName, skValue, skOperator, indexName, count, startKey: startKeyIn, filterName, filterValue, filterOperator, }: IQueryDynamo) => Promise<{
|
|
39
|
+
export declare const queryDynamo: <T>({ tableName, pkName, pkValue, pkOperator, skName, skValue, skOperator, indexName, count, startKey: startKeyIn, filterName, filterValue, filterOperator, sortAscending, }: IQueryDynamo) => Promise<{
|
|
40
40
|
Items: T[];
|
|
41
41
|
startKey?: Key | undefined;
|
|
42
42
|
}>;
|
|
@@ -212,19 +212,7 @@ const getItemsDynamo = ({ tableName, items, }) => __awaiter(void 0, void 0, void
|
|
|
212
212
|
}
|
|
213
213
|
});
|
|
214
214
|
exports.getItemsDynamo = getItemsDynamo;
|
|
215
|
-
const queryDynamo = ({ tableName, pkName, pkValue,
|
|
216
|
-
/**
|
|
217
|
-
* default =
|
|
218
|
-
*/
|
|
219
|
-
pkOperator = '=', skName, skValue,
|
|
220
|
-
/**
|
|
221
|
-
* default =
|
|
222
|
-
*/
|
|
223
|
-
skOperator = '=', indexName, count = 1000, startKey: startKeyIn, filterName, filterValue,
|
|
224
|
-
/**
|
|
225
|
-
* default =
|
|
226
|
-
*/
|
|
227
|
-
filterOperator = '=', }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
+
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* () {
|
|
228
216
|
var _g, _h;
|
|
229
217
|
let startKey = startKeyIn;
|
|
230
218
|
let kce = `#${pkName.toLowerCase()} ${pkOperator} :${pkName.toLowerCase()}`;
|
|
@@ -278,6 +266,7 @@ filterOperator = '=', }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
278
266
|
ExpressionAttributeValues: eav,
|
|
279
267
|
ExclusiveStartKey: startKey,
|
|
280
268
|
FilterExpression,
|
|
269
|
+
ScanIndexForward: sortAscending,
|
|
281
270
|
};
|
|
282
271
|
if (count > 0) {
|
|
283
272
|
params.Limit = count;
|
|
@@ -21,6 +21,7 @@ __exportStar(require("./enforceDynamoProvisionCap"), exports);
|
|
|
21
21
|
__exportStar(require("./dynamoInfra"), exports);
|
|
22
22
|
__exportStar(require("./openApiHelpers"), exports);
|
|
23
23
|
__exportStar(require("./s3"), exports);
|
|
24
|
+
__exportStar(require("./ses"), exports);
|
|
24
25
|
__exportStar(require("./sqs"), exports);
|
|
25
26
|
__exportStar(require("./validateOpenApi"), exports);
|
|
26
27
|
__exportStar(require("./validations"), exports);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import AWS from 'aws-sdk';
|
|
2
|
+
export declare let ses: AWS.SES;
|
|
3
|
+
export declare const setSes: (region: string) => void;
|
|
4
|
+
export interface ISendEmail {
|
|
5
|
+
to: string;
|
|
6
|
+
message: string;
|
|
7
|
+
subject: string;
|
|
8
|
+
sourceArn: string;
|
|
9
|
+
from: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const sendEmail: ({ to, message, subject, sourceArn, from, }: ISendEmail) => Promise<void>;
|
|
12
|
+
export declare const sendEmails: (emails: ISendEmail[]) => Promise<void[]>;
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|
+
});
|
|
10
|
+
};
|
|
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.sendEmails = exports.sendEmail = exports.setSes = exports.ses = void 0;
|
|
16
|
+
const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
17
|
+
exports.ses = new aws_sdk_1.default.SES();
|
|
18
|
+
const setSes = (region) => {
|
|
19
|
+
exports.ses = new aws_sdk_1.default.SES({ region });
|
|
20
|
+
};
|
|
21
|
+
exports.setSes = setSes;
|
|
22
|
+
const sendEmail = ({ to, message, subject, sourceArn, from, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
23
|
+
// Create sendEmail params
|
|
24
|
+
const params = {
|
|
25
|
+
Destination: {
|
|
26
|
+
CcAddresses: [],
|
|
27
|
+
ToAddresses: [to],
|
|
28
|
+
},
|
|
29
|
+
Message: {
|
|
30
|
+
Body: {
|
|
31
|
+
Text: {
|
|
32
|
+
Charset: 'UTF-8',
|
|
33
|
+
Data: message,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
Subject: {
|
|
37
|
+
Charset: 'UTF-8',
|
|
38
|
+
Data: subject,
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
Source: from,
|
|
42
|
+
ReplyToAddresses: [from],
|
|
43
|
+
SourceArn: sourceArn,
|
|
44
|
+
};
|
|
45
|
+
yield exports.ses.sendEmail(params).promise();
|
|
46
|
+
});
|
|
47
|
+
exports.sendEmail = sendEmail;
|
|
48
|
+
const sendEmails = (emails) => __awaiter(void 0, void 0, void 0, function* () { return Promise.all(emails.map(exports.sendEmail)); });
|
|
49
|
+
exports.sendEmails = sendEmails;
|
|
@@ -54,16 +54,22 @@ export declare type TSkOperator = 'BETWEEN' | '<' | '<=' | '=' | '>=' | '>' | '<
|
|
|
54
54
|
export interface IQueryDynamo {
|
|
55
55
|
pkName: string;
|
|
56
56
|
pkValue: string | number;
|
|
57
|
+
/** default, = */
|
|
57
58
|
pkOperator?: string;
|
|
58
59
|
skName?: string;
|
|
59
60
|
skValue?: string | number | string[] | number[];
|
|
61
|
+
/** default, = */
|
|
60
62
|
skOperator?: TSkOperator;
|
|
61
63
|
tableName: string;
|
|
62
64
|
indexName?: string;
|
|
65
|
+
/** default 1000 */
|
|
63
66
|
count?: number;
|
|
64
67
|
startKey?: Key;
|
|
65
68
|
filterName?: string;
|
|
66
69
|
filterValue?: string | number | boolean;
|
|
70
|
+
/** default, = */
|
|
67
71
|
filterOperator?: string;
|
|
72
|
+
/** default = true */
|
|
73
|
+
sortAscending?: boolean;
|
|
68
74
|
}
|
|
69
75
|
export * from './aws';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ag-common",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.311",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"author": "Andrei Gec <@andreigec> (https://gec.dev/)",
|
|
@@ -42,12 +42,12 @@
|
|
|
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.
|
|
46
|
-
"@types/react": "18.0.
|
|
45
|
+
"@types/node": "18.7.1",
|
|
46
|
+
"@types/react": "18.0.17",
|
|
47
47
|
"@types/react-dom": "18.0.6",
|
|
48
|
-
"@types/styled-components": "5.1.
|
|
49
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
50
|
-
"@typescript-eslint/parser": "5.
|
|
48
|
+
"@types/styled-components": "5.1.26",
|
|
49
|
+
"@typescript-eslint/eslint-plugin": "5.33.0",
|
|
50
|
+
"@typescript-eslint/parser": "5.33.0",
|
|
51
51
|
"cross-env": "7.0.3",
|
|
52
52
|
"eslint": "8.21.0",
|
|
53
53
|
"eslint-config-airbnb-typescript": "17.0.0",
|