@8ms/helpers 1.1.73 → 1.1.75
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/api/response.d.ts +8 -0
- package/api/response.js +12 -1
- package/api/states.d.ts +9 -0
- package/api/states.js +10 -1
- package/api/unexpectedError.d.ts +2 -0
- package/api/unexpectedError.js +4 -1
- package/array/contains.d.ts +8 -0
- package/array/contains.js +6 -2
- package/array/getArray.d.ts +7 -0
- package/array/getArray.js +10 -2
- package/atInternet/request.d.ts +30 -0
- package/atInternet/request.js +2 -1
- package/aws/athenaExpress/initClient.d.ts +12 -0
- package/aws/athenaExpress/initClient.js +27 -3
- package/aws/athenaExpress/query.d.ts +8 -0
- package/aws/athenaExpress/query.js +9 -2
- package/aws/getConfig.d.ts +13 -0
- package/aws/getConfig.js +26 -2
- package/aws/glue/initClient.d.ts +10 -0
- package/aws/glue/initClient.js +17 -2
- package/aws/glue/invoke.d.ts +9 -0
- package/aws/glue/invoke.js +19 -2
- package/aws/isResponse200.d.ts +7 -0
- package/aws/isResponse200.js +21 -2
- package/aws/lambda/getHandlerPath.d.ts +5 -0
- package/aws/lambda/getHandlerPath.js +7 -1
- package/aws/lambda/initClient.d.ts +10 -0
- package/aws/lambda/initClient.js +17 -2
- package/aws/lambda/invoke.d.ts +12 -0
- package/aws/lambda/invoke.js +39 -2
- package/aws/s3/copyFile.d.ts +13 -0
- package/aws/s3/copyFile.js +13 -2
- package/aws/s3/deleteFile.d.ts +9 -0
- package/aws/s3/deleteFile.js +12 -2
- package/aws/s3/deleteFiles.d.ts +9 -0
- package/aws/s3/deleteFiles.js +16 -2
- package/aws/s3/deleteFolder.d.ts +9 -0
- package/aws/s3/deleteFolder.js +35 -2
- package/aws/s3/getGlueJson.d.ts +5 -0
- package/aws/s3/getGlueJson.js +15 -2
- package/aws/s3/getPresignedPost.d.ts +20 -0
- package/aws/s3/getPresignedPost.js +16 -3
- package/aws/s3/getSignedUrl.d.ts +12 -0
- package/aws/s3/getSignedUrl.js +15 -2
- package/aws/s3/initClient.d.ts +10 -0
- package/aws/s3/initClient.js +17 -2
- package/aws/s3/isFileExists.d.ts +9 -0
- package/aws/s3/isFileExists.js +26 -2
- package/aws/s3/listFiles.d.ts +9 -0
- package/aws/s3/listFiles.js +32 -2
- package/aws/s3/listFolders.d.ts +9 -0
- package/aws/s3/listFolders.js +31 -4
- package/aws/s3/moveFile.d.ts +10 -0
- package/aws/s3/moveFile.js +20 -2
- package/aws/s3/readBuffer.d.ts +13 -0
- package/aws/s3/readBuffer.js +51 -2
- package/aws/s3/readFile.d.ts +30 -0
- package/aws/s3/readFile.js +69 -2
- package/aws/s3/writeFile.d.ts +10 -0
- package/aws/s3/writeFile.js +15 -2
- package/aws/s3/writePresignedPost.d.ts +14 -0
- package/aws/s3/writePresignedPost.js +30 -2
- package/aws/s3cache/cache.d.ts +7 -0
- package/aws/s3cache/cache.js +2 -1
- package/aws/s3cache/getCache.d.ts +12 -0
- package/aws/s3cache/getCache.js +35 -2
- package/aws/s3cache/getKey.d.ts +10 -0
- package/aws/s3cache/getKey.js +16 -2
- package/aws/s3cache/saveCache.d.ts +10 -0
- package/aws/s3cache/saveCache.js +12 -2
- package/aws/s3cache/updateCache.d.ts +10 -0
- package/aws/s3cache/updateCache.js +23 -2
- package/aws/ses/SimpleEmail.d.ts +51 -0
- package/aws/ses/SimpleEmail.js +115 -2
- package/aws/ses/initClient.d.ts +10 -0
- package/aws/ses/initClient.js +17 -2
- package/aws/ssm/getParameter.d.ts +10 -0
- package/aws/ssm/getParameter.js +39 -2
- package/aws/ssm/initClient.d.ts +10 -0
- package/aws/ssm/initClient.js +17 -2
- package/axios/get.d.ts +8 -0
- package/axios/get.js +44 -1
- package/axios/post.d.ts +12 -0
- package/axios/post.js +46 -2
- package/boolean/getBoolean.d.ts +7 -0
- package/boolean/getBoolean.js +15 -2
- package/class/BaseClass.d.ts +31 -0
- package/class/BaseClass.js +50 -9
- package/crud/actions.d.ts +8 -0
- package/crud/actions.js +10 -1
- package/crypto/getDecrypt.d.ts +10 -0
- package/crypto/getDecrypt.js +11 -2
- package/crypto/getEncrypt.d.ts +10 -0
- package/crypto/getEncrypt.js +11 -2
- package/crypto/getRandom.d.ts +8 -0
- package/crypto/getRandom.js +10 -2
- package/crypto/getSha256.d.ts +8 -0
- package/crypto/getSha256.js +15 -2
- package/date/date.d.ts +4 -0
- package/date/date.js +2 -1
- package/date/duration.d.ts +5 -0
- package/date/duration.js +2 -1
- package/date/durationComparisons.d.ts +5 -0
- package/date/durationComparisons.js +7 -1
- package/date/durations.d.ts +8 -0
- package/date/durations.js +10 -1
- package/date/financialYear.d.ts +4 -0
- package/date/financialYear.js +2 -1
- package/date/financialYearWeek.d.ts +6 -0
- package/date/financialYearWeek.js +2 -1
- package/date/format.d.ts +13 -0
- package/date/format.js +18 -2
- package/date/getDate.d.ts +12 -0
- package/date/getDate.js +96 -9
- package/date/getDatesBetween.d.ts +10 -0
- package/date/getDatesBetween.js +25 -3
- package/date/getDurationHours.d.ts +8 -0
- package/date/getDurationHours.js +25 -2
- package/date/getDurationMinutes.d.ts +8 -0
- package/date/getDurationMinutes.js +24 -2
- package/date/getFinancialYear.d.ts +9 -0
- package/date/getFinancialYear.js +48 -8
- package/date/getFinancialYearToDate.d.ts +7 -0
- package/date/getFinancialYearToDate.js +18 -2
- package/date/getFinancialYearToYesterday.d.ts +7 -0
- package/date/getFinancialYearToYesterday.js +18 -2
- package/date/getFinancialYearWeeks.d.ts +9 -0
- package/date/getFinancialYearWeeks.js +29 -2
- package/date/getLastWeek.d.ts +10 -0
- package/date/getLastWeek.js +28 -2
- package/date/getMax.d.ts +12 -0
- package/date/getMax.js +15 -2
- package/date/getMidnight.d.ts +10 -0
- package/date/getMidnight.js +12 -2
- package/date/getMin.d.ts +12 -0
- package/date/getMin.js +15 -2
- package/date/getMonday.d.ts +14 -0
- package/date/getMonday.js +32 -5
- package/date/getNumber.d.ts +11 -0
- package/date/getNumber.js +14 -2
- package/date/getPredefinedTimeframe.d.ts +9 -0
- package/date/getPredefinedTimeframe.js +23 -2
- package/date/getSunday.d.ts +14 -0
- package/date/getSunday.js +32 -5
- package/date/getThisWeek.d.ts +10 -0
- package/date/getThisWeek.js +28 -2
- package/date/getTimeZoned.d.ts +13 -0
- package/date/getTimeZoned.js +36 -5
- package/date/getToday.d.ts +9 -0
- package/date/getToday.js +39 -2
- package/date/getTwoWeeksAgo.d.ts +10 -0
- package/date/getTwoWeeksAgo.js +28 -2
- package/date/getWeeksAgo.d.ts +12 -0
- package/date/getWeeksAgo.js +16 -2
- package/date/getYesterday.d.ts +9 -0
- package/date/getYesterday.js +40 -2
- package/date/isDateValid.d.ts +7 -0
- package/date/isDateValid.js +22 -2
- package/date/isLastWeek.d.ts +6 -0
- package/date/isLastWeek.js +13 -2
- package/date/isThisWeek.d.ts +6 -0
- package/date/isThisWeek.js +13 -2
- package/date/parseExcelDate.d.ts +8 -0
- package/date/parseExcelDate.js +17 -2
- package/date/predefinedTimeframes.d.ts +7 -0
- package/date/predefinedTimeframes.js +9 -1
- package/date/timeframe.d.ts +8 -0
- package/date/timeframe.js +2 -1
- package/date/timeframes.d.ts +4 -0
- package/date/timeframes.js +7 -1
- package/deepCrawl/buildRequest.d.ts +15 -0
- package/deepCrawl/buildRequest.js +83 -4
- package/deepCrawl/filter.d.ts +5 -0
- package/deepCrawl/filter.js +2 -1
- package/deepCrawl/getData.d.ts +5 -0
- package/deepCrawl/getData.js +29 -1
- package/deepCrawl/initClient.d.ts +13 -0
- package/deepCrawl/initClient.js +31 -2
- package/deepCrawl/operands.d.ts +11 -0
- package/deepCrawl/operands.js +13 -1
- package/deepCrawl/orders.d.ts +9 -0
- package/deepCrawl/orders.js +7 -1
- package/deepCrawl/reports.d.ts +11 -0
- package/deepCrawl/reports.js +13 -1
- package/environment/environments.d.ts +7 -0
- package/environment/environments.js +8 -1
- package/environment/getEnvironment.d.ts +6 -0
- package/environment/getEnvironment.js +42 -2
- package/environment/isAws.d.ts +5 -0
- package/environment/isAws.js +10 -2
- package/environment/isDevelopment.d.ts +2 -0
- package/environment/isDevelopment.js +9 -1
- package/environment/isLocalhost.d.ts +5 -0
- package/environment/isLocalhost.js +21 -2
- package/environment/isProduction.d.ts +2 -0
- package/environment/isProduction.js +9 -1
- package/environment/isStaging.d.ts +2 -0
- package/environment/isStaging.js +9 -1
- package/environment/isVercel.d.ts +5 -0
- package/environment/isVercel.js +6 -2
- package/environment/platforms.d.ts +6 -0
- package/environment/platforms.js +7 -1
- package/eskimi/ageGroups.d.ts +5 -0
- package/eskimi/ageGroups.js +41 -1
- package/eskimi/campaign.d.ts +19 -0
- package/eskimi/campaign.js +2 -1
- package/eskimi/devices.d.ts +5 -0
- package/eskimi/devices.js +13 -1
- package/eskimi/endpoints.d.ts +16 -0
- package/eskimi/endpoints.js +17 -2
- package/eskimi/genders.d.ts +5 -0
- package/eskimi/genders.js +13 -1
- package/eskimi/getAccessToken.d.ts +9 -0
- package/eskimi/getAccessToken.js +22 -2
- package/eskimi/getAgeGroup.d.ts +7 -0
- package/eskimi/getAgeGroup.js +16 -2
- package/eskimi/getCampaignIds.d.ts +7 -0
- package/eskimi/getCampaignIds.js +11 -2
- package/eskimi/getDevice.d.ts +7 -0
- package/eskimi/getDevice.js +16 -2
- package/eskimi/getGender.d.ts +7 -0
- package/eskimi/getGender.js +16 -2
- package/eskimi/request.d.ts +8 -0
- package/eskimi/request.js +23 -2
- package/google/bigQuery/initClient.d.ts +11 -0
- package/google/bigQuery/initClient.js +20 -2
- package/google/bigQuery/query.d.ts +9 -0
- package/google/bigQuery/query.js +9 -2
- package/google/getConfig.d.ts +20 -0
- package/google/getConfig.js +21 -3
- package/google/sheets/getAssociatedData.d.ts +16 -0
- package/google/sheets/getAssociatedData.js +52 -8
- package/google/sheets/getBatchData.d.ts +18 -0
- package/google/sheets/getBatchData.js +19 -1
- package/google/sheets/initClient.d.ts +11 -0
- package/google/sheets/initClient.js +22 -2
- package/google/sheets/isCellNa.d.ts +7 -0
- package/google/sheets/isCellNa.js +6 -2
- package/google/storage/initClient.d.ts +12 -0
- package/google/storage/initClient.js +20 -2
- package/google/storage/writeFile.d.ts +12 -0
- package/google/storage/writeFile.js +30 -2
- package/googleAds/getCustomer.d.ts +8 -0
- package/googleAds/getCustomer.js +13 -2
- package/googleAds/initClient.d.ts +16 -0
- package/googleAds/initClient.js +23 -2
- package/initClients.d.ts +40 -0
- package/initClients.js +106 -5
- package/json/isJson.d.ts +8 -0
- package/json/isJson.js +18 -2
- package/littleWarden/getUrlStatus.d.ts +9 -0
- package/littleWarden/getUrlStatus.js +20 -2
- package/littleWarden/isAllGood.d.ts +7 -0
- package/littleWarden/isAllGood.js +17 -2
- package/littleWarden/isDanger.d.ts +7 -0
- package/littleWarden/isDanger.js +17 -2
- package/littleWarden/isWarning.d.ts +7 -0
- package/littleWarden/isWarning.js +17 -2
- package/littleWarden/states.d.ts +7 -0
- package/littleWarden/states.js +8 -1
- package/myTarget/getAccessToken.d.ts +9 -0
- package/myTarget/getAccessToken.js +22 -2
- package/myTarget/request.d.ts +8 -0
- package/myTarget/request.js +23 -2
- package/nextAuth/isSessionReady.d.ts +4 -0
- package/nextAuth/isSessionReady.js +12 -1
- package/nextAuth/states.d.ts +7 -0
- package/nextAuth/states.js +8 -2
- package/nextJs/getIp.d.ts +7 -0
- package/nextJs/getIp.js +12 -2
- package/nextJs/getUserAgent.d.ts +7 -0
- package/nextJs/getUserAgent.js +6 -2
- package/number/getDivide.d.ts +9 -0
- package/number/getDivide.js +17 -2
- package/number/getNumber.d.ts +8 -0
- package/number/getNumber.js +50 -7
- package/number/getPercent.d.ts +9 -0
- package/number/getPercent.js +17 -2
- package/number/getPercentIncrease.d.ts +9 -0
- package/number/getPercentIncrease.js +17 -2
- package/number/getRounded.d.ts +9 -0
- package/number/getRounded.js +21 -2
- package/package.json +44 -47
- package/prisma/initClient.d.ts +4 -0
- package/prisma/initClient.js +33 -3
- package/snapchat/getAccessToken.d.ts +9 -0
- package/snapchat/getAccessToken.js +36 -2
- package/sorting/byNumberAscending.d.ts +8 -0
- package/sorting/byNumberAscending.js +16 -2
- package/sorting/byNumberDescending.d.ts +8 -0
- package/sorting/byNumberDescending.js +16 -2
- package/sorting/byStringAscending.d.ts +8 -0
- package/sorting/byStringAscending.js +20 -2
- package/sorting/byStringDescending.d.ts +8 -0
- package/sorting/byStringDescending.js +20 -2
- package/string/formatCapitalise.d.ts +9 -0
- package/string/formatCapitalise.js +14 -2
- package/string/getCleanFolder.d.ts +7 -0
- package/string/getCleanFolder.js +11 -2
- package/string/getString.d.ts +7 -0
- package/string/getString.js +35 -2
- package/string/getStringFromStream.d.ts +8 -0
- package/string/getStringFromStream.js +14 -2
- package/string/toProperCase.d.ts +7 -0
- package/string/toProperCase.js +17 -2
- package/swr/isAllData.d.ts +7 -0
- package/swr/isAllData.js +18 -2
- package/swr/isAnyError.d.ts +7 -0
- package/swr/isAnyError.js +18 -2
- package/swr/isAnyLoading.d.ts +7 -0
- package/swr/isAnyLoading.js +20 -2
- package/swr/isData.d.ts +7 -0
- package/swr/isData.js +6 -2
- package/swr/isError.d.ts +7 -0
- package/swr/isError.js +6 -2
- package/swr/isLoading.d.ts +7 -0
- package/swr/isLoading.js +11 -2
- package/upTimeRobot/getMonitors.d.ts +1 -0
- package/upTimeRobot/getMonitors.js +31 -2
- package/upTimeRobot/logTypes.d.ts +7 -0
- package/upTimeRobot/logTypes.js +9 -1
- package/upTimeRobot/monitorStatuses.d.ts +8 -0
- package/upTimeRobot/monitorStatuses.js +10 -1
- package/upTimeRobot/monitorSubTypes.d.ts +10 -0
- package/upTimeRobot/monitorSubTypes.js +12 -1
- package/upTimeRobot/monitorTypes.d.ts +8 -0
- package/upTimeRobot/monitorTypes.js +10 -1
- package/upTimeRobot/requestStatuses.d.ts +5 -0
- package/upTimeRobot/requestStatuses.js +7 -1
- package/url/buildParameters.d.ts +8 -0
- package/url/buildParameters.js +21 -2
- package/url/buildRelative.d.ts +8 -0
- package/url/buildRelative.js +12 -2
- package/url/buildUrl.d.ts +10 -0
- package/url/buildUrl.js +28 -2
- package/url/isAbsolute.d.ts +7 -0
- package/url/isAbsolute.js +14 -2
- package/url/isRelative.d.ts +7 -0
- package/url/isRelative.js +7 -2
- package/url/url.d.ts +6 -0
- package/url/url.js +2 -1
- package/util/defaultTo.d.ts +10 -0
- package/util/defaultTo.js +34 -2
- package/util/isUndefined.d.ts +9 -0
- package/util/isUndefined.js +18 -2
- package/util/sleep.d.ts +4 -0
- package/util/sleep.js +6 -1
- package/webWorker/states.d.ts +7 -0
- package/webWorker/states.js +8 -1
- package/xml/getXml.d.ts +4 -0
- package/xml/getXml.js +14 -1
- package/globals.d.js +0 -1
package/aws/ses/SimpleEmail.js
CHANGED
|
@@ -1,3 +1,116 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const uniq_1 = __importDefault(require("lodash/uniq"));
|
|
7
|
+
const BaseClass_1 = __importDefault(require("../../class/BaseClass"));
|
|
8
|
+
const isResponse200_1 = __importDefault(require("../isResponse200"));
|
|
9
|
+
/**
|
|
2
10
|
* Class to build and send an AWS SES email.
|
|
3
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
class SimpleEmail extends BaseClass_1.default {
|
|
13
|
+
constructor({ bcc, cc, from, html, subject, to }) {
|
|
14
|
+
super();
|
|
15
|
+
this.to = [];
|
|
16
|
+
this.cc = [];
|
|
17
|
+
this.bcc = [];
|
|
18
|
+
if (bcc) {
|
|
19
|
+
this.setBcc({ recipient: bcc });
|
|
20
|
+
}
|
|
21
|
+
if (cc) {
|
|
22
|
+
this.setCc({ recipient: cc });
|
|
23
|
+
}
|
|
24
|
+
if (from) {
|
|
25
|
+
this.setFrom({ from });
|
|
26
|
+
}
|
|
27
|
+
if (html) {
|
|
28
|
+
this.setHtml({ html });
|
|
29
|
+
}
|
|
30
|
+
if (subject) {
|
|
31
|
+
this.setSubject({ subject });
|
|
32
|
+
}
|
|
33
|
+
if (to) {
|
|
34
|
+
this.setTo({ recipient: to });
|
|
35
|
+
}
|
|
36
|
+
return this;
|
|
37
|
+
}
|
|
38
|
+
setFrom({ from }) {
|
|
39
|
+
return this._setValue({ input: from, fields: 'from' });
|
|
40
|
+
}
|
|
41
|
+
setHtml({ html }) {
|
|
42
|
+
return this._setValue({ input: html, fields: 'html' });
|
|
43
|
+
}
|
|
44
|
+
setSubject({ subject }) {
|
|
45
|
+
return this._setValue({ input: subject, fields: 'subject' });
|
|
46
|
+
}
|
|
47
|
+
pushBcc({ recipient }) {
|
|
48
|
+
return this._push({ input: recipient, fields: 'bcc' });
|
|
49
|
+
}
|
|
50
|
+
pushCc({ recipient }) {
|
|
51
|
+
return this._push({ input: recipient, fields: 'cc' });
|
|
52
|
+
}
|
|
53
|
+
pushTo({ recipient }) {
|
|
54
|
+
return this._push({ input: recipient, fields: 'to' });
|
|
55
|
+
}
|
|
56
|
+
setBcc({ recipient }) {
|
|
57
|
+
return this._setArray({ input: recipient, fields: 'bcc' });
|
|
58
|
+
}
|
|
59
|
+
setCc({ recipient }) {
|
|
60
|
+
return this._setArray({ input: recipient, fields: 'cc' });
|
|
61
|
+
}
|
|
62
|
+
setTo({ recipient }) {
|
|
63
|
+
return this._setArray({ input: recipient, fields: 'to' });
|
|
64
|
+
}
|
|
65
|
+
async send() {
|
|
66
|
+
const { SendEmailCommand } = require('@aws-sdk/client-ses');
|
|
67
|
+
let response;
|
|
68
|
+
// https://docs.aws.amazon.com/sdk-for-javascript/v3/developer-guide/ses-examples-sending-email.html
|
|
69
|
+
const params = {
|
|
70
|
+
Destination: {
|
|
71
|
+
BccAddresses: this._filterRecipients({ field: 'bcc' }),
|
|
72
|
+
CcAddresses: this._filterRecipients({ field: 'cc' }),
|
|
73
|
+
ToAddresses: this._filterRecipients({ field: 'to' }),
|
|
74
|
+
},
|
|
75
|
+
Message: {
|
|
76
|
+
Body: {
|
|
77
|
+
Html: {
|
|
78
|
+
Charset: "UTF-8",
|
|
79
|
+
Data: this.html,
|
|
80
|
+
},
|
|
81
|
+
Text: {
|
|
82
|
+
Charset: "UTF-8",
|
|
83
|
+
Data: this.html,
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
Subject: {
|
|
87
|
+
Charset: "UTF-8",
|
|
88
|
+
Data: this.subject,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
Source: this.from,
|
|
92
|
+
};
|
|
93
|
+
try {
|
|
94
|
+
const command = new SendEmailCommand(params);
|
|
95
|
+
const apiResponse = await global.awsSesClient.send(command);
|
|
96
|
+
response = (0, isResponse200_1.default)({ apiResponse });
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
response = false;
|
|
100
|
+
}
|
|
101
|
+
return response;
|
|
102
|
+
}
|
|
103
|
+
_filterRecipients({ field }) {
|
|
104
|
+
// Remove all undefined and null values
|
|
105
|
+
let response = this[field].filter(recipient => recipient && null !== recipient);
|
|
106
|
+
// Clean all the values
|
|
107
|
+
response = response.map(recipient => recipient.toLowerCase()
|
|
108
|
+
.trim());
|
|
109
|
+
// Remove all empty values
|
|
110
|
+
response = response.filter(recipient => '' !== recipient);
|
|
111
|
+
// Return only unique values
|
|
112
|
+
response = (0, uniq_1.default)(response);
|
|
113
|
+
return response;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.default = SimpleEmail;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from '../getConfig';
|
|
2
|
+
declare type InitClient = {
|
|
3
|
+
config: Config;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Shorthand function to get the Lambda Client.
|
|
7
|
+
* Library: @aws-sdk/client-ses
|
|
8
|
+
*/
|
|
9
|
+
declare const initClient: ({ config }: InitClient) => void;
|
|
10
|
+
export default initClient;
|
package/aws/ses/initClient.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const getConfig_1 = __importDefault(require("../getConfig"));
|
|
7
|
+
global.awsSesClient = null;
|
|
8
|
+
/**
|
|
2
9
|
* Shorthand function to get the Lambda Client.
|
|
3
10
|
* Library: @aws-sdk/client-ses
|
|
4
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const initClient = ({ config }) => {
|
|
13
|
+
if (!global.awsSesClient) {
|
|
14
|
+
const { SESClient } = require('@aws-sdk/client-ses');
|
|
15
|
+
const formattedConfig = (0, getConfig_1.default)({ config });
|
|
16
|
+
global.awsSesClient = new SESClient(formattedConfig);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = initClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare type GetParameter = {
|
|
2
|
+
name: string;
|
|
3
|
+
withDecryption?: boolean;
|
|
4
|
+
isJson?: boolean;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Get a parameter and decryption if necessary (secure string)
|
|
8
|
+
*/
|
|
9
|
+
declare const getParameter: ({ name, withDecryption, isJson }: GetParameter) => Promise<any>;
|
|
10
|
+
export default getParameter;
|
package/aws/ssm/getParameter.js
CHANGED
|
@@ -1,3 +1,40 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
global["awsSsmParameters"] = {};
|
|
4
|
+
/**
|
|
2
5
|
* Get a parameter and decryption if necessary (secure string)
|
|
3
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const getParameter = async ({ name, withDecryption, isJson }) => {
|
|
8
|
+
// Haven't fetched already
|
|
9
|
+
if (undefined === global["awsSsmParameters"][name]) {
|
|
10
|
+
const { GetParameterCommand } = require('@aws-sdk/client-ssm');
|
|
11
|
+
const apiResponse = await global.awsSsmClient.send(new GetParameterCommand({
|
|
12
|
+
Name: name,
|
|
13
|
+
WithDecryption: undefined === withDecryption ? true : withDecryption,
|
|
14
|
+
}));
|
|
15
|
+
if (apiResponse.Parameter.Value) {
|
|
16
|
+
// Value is undefined
|
|
17
|
+
if (undefined === apiResponse.Parameter.Value) {
|
|
18
|
+
global["awsSsmParameters"][name] = null;
|
|
19
|
+
}
|
|
20
|
+
// Value is defined
|
|
21
|
+
else {
|
|
22
|
+
// isJson is default - decode
|
|
23
|
+
if (undefined === isJson || true === isJson) {
|
|
24
|
+
global["awsSsmParameters"][name] = JSON.parse(apiResponse.Parameter.Value) || null;
|
|
25
|
+
}
|
|
26
|
+
// Not JSON don't decode
|
|
27
|
+
else {
|
|
28
|
+
global["awsSsmParameters"][name] = apiResponse.Parameter.Value;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Value not found (null so it can be sent from server to front end)
|
|
33
|
+
else {
|
|
34
|
+
global["awsSsmParameters"][name] = null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
// Return the loaded result
|
|
38
|
+
return global["awsSsmParameters"][name];
|
|
39
|
+
};
|
|
40
|
+
exports.default = getParameter;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Config } from '../getConfig';
|
|
2
|
+
declare type InitClient = {
|
|
3
|
+
config: Config;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* Shorthand function to get the Lambda Client.
|
|
7
|
+
* Library: @aws-sdk/client-ssm
|
|
8
|
+
*/
|
|
9
|
+
declare const initClient: ({ config }: InitClient) => void;
|
|
10
|
+
export default initClient;
|
package/aws/ssm/initClient.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const getConfig_1 = __importDefault(require("../getConfig"));
|
|
7
|
+
global.awsSsmClient = null;
|
|
8
|
+
/**
|
|
2
9
|
* Shorthand function to get the Lambda Client.
|
|
3
10
|
* Library: @aws-sdk/client-ssm
|
|
4
|
-
*/
|
|
11
|
+
*/
|
|
12
|
+
const initClient = ({ config }) => {
|
|
13
|
+
if (!global.awsSsmClient) {
|
|
14
|
+
const { SSMClient } = require('@aws-sdk/client-ssm');
|
|
15
|
+
const formattedConfig = (0, getConfig_1.default)({ config });
|
|
16
|
+
global.awsSsmClient = new SSMClient(formattedConfig);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
exports.default = initClient;
|
package/axios/get.d.ts
ADDED
package/axios/get.js
CHANGED
|
@@ -1 +1,44 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const states_1 = __importDefault(require("../api/states"));
|
|
8
|
+
const get = async ({ config = {}, onError, onSuccess, url }) => {
|
|
9
|
+
const response = await axios_1.default.get(url, config)
|
|
10
|
+
.then(async (response) => {
|
|
11
|
+
if (200 === response.status) {
|
|
12
|
+
// Is an API request
|
|
13
|
+
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
14
|
+
// Success return the body
|
|
15
|
+
if (states_1.default.SUCCESS === response.data.state) {
|
|
16
|
+
return onSuccess ? await onSuccess(response.data.body) : response.data.body;
|
|
17
|
+
}
|
|
18
|
+
// Error
|
|
19
|
+
else {
|
|
20
|
+
if (onError) {
|
|
21
|
+
return await onError(response.data.error);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw new Error(response.data.error);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return onSuccess ? await onSuccess(response) : response;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return onError ? await onError(response) : response;
|
|
33
|
+
})
|
|
34
|
+
.catch(async (error) => {
|
|
35
|
+
if (onError) {
|
|
36
|
+
return await onError(error);
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw Error;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return response;
|
|
43
|
+
};
|
|
44
|
+
exports.default = get;
|
package/axios/post.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare type Post = {
|
|
2
|
+
config?: object;
|
|
3
|
+
data?: object;
|
|
4
|
+
onError?: Function;
|
|
5
|
+
onSuccess?: Function;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Make a POST request.
|
|
10
|
+
*/
|
|
11
|
+
declare const post: ({ config, data, onError, onSuccess, url }: Post) => Promise<any>;
|
|
12
|
+
export default post;
|
package/axios/post.js
CHANGED
|
@@ -1,3 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const axios_1 = __importDefault(require("axios"));
|
|
7
|
+
const states_1 = __importDefault(require("../api/states"));
|
|
8
|
+
/**
|
|
2
9
|
* Make a POST request.
|
|
3
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const post = async ({ config = {}, data = {}, onError, onSuccess, url }) => {
|
|
12
|
+
const response = await axios_1.default.post(url, data, config)
|
|
13
|
+
.then(async (response) => {
|
|
14
|
+
if (200 === response.status) {
|
|
15
|
+
// Is an API request
|
|
16
|
+
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
17
|
+
// Success return the body
|
|
18
|
+
if (states_1.default.SUCCESS === response.data.state) {
|
|
19
|
+
return onSuccess ? await onSuccess(response.data.body) : response.data.body;
|
|
20
|
+
}
|
|
21
|
+
// Error
|
|
22
|
+
else {
|
|
23
|
+
if (onError) {
|
|
24
|
+
return await onError(response.data.error);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
throw new Error(response.data.error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
return onSuccess ? await onSuccess(response) : response;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return onError ? await onError(response) : response;
|
|
36
|
+
})
|
|
37
|
+
.catch(async (error) => {
|
|
38
|
+
if (onError) {
|
|
39
|
+
return await onError(error);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
throw Error;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return response;
|
|
46
|
+
};
|
|
47
|
+
exports.default = post;
|
package/boolean/getBoolean.js
CHANGED
|
@@ -1,3 +1,16 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const isBoolean_1 = __importDefault(require("lodash/isBoolean"));
|
|
7
|
+
/**
|
|
2
8
|
* Convert an input from a variety of forms into boolean.
|
|
3
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const getBoolean = ({ input }) => {
|
|
11
|
+
if ((0, isBoolean_1.default)(input)) {
|
|
12
|
+
return input;
|
|
13
|
+
}
|
|
14
|
+
return 'true' === input || 1 === input || '1' === input || 'yes' === input || 'y' === input;
|
|
15
|
+
};
|
|
16
|
+
exports.default = getBoolean;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
declare class BaseClass {
|
|
2
|
+
/**
|
|
3
|
+
* Shortcut to set a value to an array and return the instance.
|
|
4
|
+
*/
|
|
5
|
+
protected _setArray({ input, fields }: {
|
|
6
|
+
input: any | any[];
|
|
7
|
+
fields: any | any[];
|
|
8
|
+
}): this;
|
|
9
|
+
/**
|
|
10
|
+
* Shortcut to set a value and return the instance.
|
|
11
|
+
*/
|
|
12
|
+
protected _setValue({ input, fields }: {
|
|
13
|
+
input: any;
|
|
14
|
+
fields: any | any[];
|
|
15
|
+
}): this;
|
|
16
|
+
/**
|
|
17
|
+
* Shortcut to add a value to an existing array.
|
|
18
|
+
*/
|
|
19
|
+
protected _push({ input, fields }: {
|
|
20
|
+
input: any | any[];
|
|
21
|
+
fields: any | any[];
|
|
22
|
+
}): this;
|
|
23
|
+
/**
|
|
24
|
+
* Shortcut to get a value, but default if the fields don't exist.
|
|
25
|
+
*/
|
|
26
|
+
protected _get({ defaultValue, fields }: {
|
|
27
|
+
defaultValue: any;
|
|
28
|
+
fields: any | any[];
|
|
29
|
+
}): any;
|
|
30
|
+
}
|
|
31
|
+
export default BaseClass;
|
package/class/BaseClass.js
CHANGED
|
@@ -1,9 +1,50 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
+
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
7
|
+
const set_1 = __importDefault(require("lodash/set"));
|
|
8
|
+
const defaultTo_1 = __importDefault(require("../util/defaultTo"));
|
|
9
|
+
class BaseClass {
|
|
10
|
+
/**
|
|
11
|
+
* Shortcut to set a value to an array and return the instance.
|
|
12
|
+
*/
|
|
13
|
+
_setArray({ input, fields }) {
|
|
14
|
+
if ((0, isArray_1.default)(input)) {
|
|
15
|
+
(0, set_1.default)(this, fields, input);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
(0, set_1.default)(this, fields, [input]);
|
|
19
|
+
}
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Shortcut to set a value and return the instance.
|
|
24
|
+
*/
|
|
25
|
+
_setValue({ input, fields }) {
|
|
26
|
+
(0, set_1.default)(this, fields, input);
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Shortcut to add a value to an existing array.
|
|
31
|
+
*/
|
|
32
|
+
_push({ input, fields }) {
|
|
33
|
+
let temp = this._get({ defaultValue: [], fields });
|
|
34
|
+
if ((0, isArray_1.default)(input)) {
|
|
35
|
+
temp = temp.concat(input);
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
temp = temp.push(input);
|
|
39
|
+
}
|
|
40
|
+
(0, set_1.default)(this, fields, temp);
|
|
41
|
+
return this;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Shortcut to get a value, but default if the fields don't exist.
|
|
45
|
+
*/
|
|
46
|
+
_get({ defaultValue, fields }) {
|
|
47
|
+
return (0, defaultTo_1.default)({ defaultValue, instance: this, keys: fields });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.default = BaseClass;
|
package/crud/actions.js
CHANGED
|
@@ -1 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.actions = void 0;
|
|
4
|
+
exports.actions = {
|
|
5
|
+
CREATE: 'create',
|
|
6
|
+
READ: 'read',
|
|
7
|
+
UPDATE: 'update',
|
|
8
|
+
DELETE: 'delete',
|
|
9
|
+
};
|
|
10
|
+
exports.default = exports.actions;
|
package/crypto/getDecrypt.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
2
4
|
* Decrypt an encoding string using a salt
|
|
3
5
|
* Library: crypto-js
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const getDecrypt = ({ appSalt, input, salt }) => {
|
|
8
|
+
const { AES, enc } = require('crypto-js');
|
|
9
|
+
const customSalt = `${appSalt}-${salt}`;
|
|
10
|
+
return AES.decrypt(input, customSalt)
|
|
11
|
+
.toString(enc.Utf8);
|
|
12
|
+
};
|
|
13
|
+
exports.default = getDecrypt;
|