@8ms/helpers 1.1.66 → 1.1.71

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.
Files changed (208) hide show
  1. package/api/response.js +2 -2
  2. package/api/states.js +1 -1
  3. package/api/unexpectedError.js +1 -1
  4. package/array/contains.js +1 -4
  5. package/array/getArray.js +2 -5
  6. package/aws/athenaExpress/initClient.d.ts +1 -1
  7. package/aws/athenaExpress/initClient.js +6 -7
  8. package/aws/athenaExpress/query.d.ts +8 -0
  9. package/aws/athenaExpress/query.js +10 -0
  10. package/aws/getConfig.d.ts +5 -1
  11. package/aws/getConfig.js +2 -3
  12. package/aws/glue/initClient.d.ts +5 -4
  13. package/aws/glue/initClient.js +4 -5
  14. package/aws/glue/invoke.d.ts +1 -3
  15. package/aws/glue/invoke.js +12 -63
  16. package/aws/isResponse200.js +4 -5
  17. package/aws/lambda/getHandlerPath.d.ts +4 -3
  18. package/aws/lambda/getHandlerPath.js +3 -4
  19. package/aws/lambda/initClient.d.ts +5 -4
  20. package/aws/lambda/initClient.js +4 -5
  21. package/aws/lambda/invoke.d.ts +1 -3
  22. package/aws/lambda/invoke.js +29 -77
  23. package/aws/s3/copyFile.js +7 -55
  24. package/aws/s3/deleteFile.js +6 -54
  25. package/aws/s3/deleteFiles.d.ts +5 -6
  26. package/aws/s3/deleteFiles.js +10 -58
  27. package/aws/s3/deleteFolder.d.ts +5 -6
  28. package/aws/s3/deleteFolder.js +26 -76
  29. package/aws/s3/getGlueJson.d.ts +3 -2
  30. package/aws/s3/getGlueJson.js +4 -5
  31. package/aws/s3/getPresignedPost.d.ts +6 -7
  32. package/aws/s3/getPresignedPost.js +9 -56
  33. package/aws/s3/getSignedUrl.js +8 -76
  34. package/aws/s3/initClient.d.ts +5 -4
  35. package/aws/s3/initClient.js +4 -5
  36. package/aws/s3/isFileExists.js +17 -66
  37. package/aws/s3/listFiles.js +22 -69
  38. package/aws/s3/listFolders.js +21 -68
  39. package/aws/s3/moveFile.d.ts +5 -4
  40. package/aws/s3/moveFile.js +10 -58
  41. package/aws/s3/readBuffer.js +41 -89
  42. package/aws/s3/readFile.js +42 -93
  43. package/aws/s3/writeFile.js +10 -72
  44. package/aws/s3/writePresignedPost.d.ts +2 -3
  45. package/aws/s3/writePresignedPost.js +22 -93
  46. package/aws/s3cache/getCache.js +25 -69
  47. package/aws/s3cache/getKey.js +7 -8
  48. package/aws/s3cache/saveCache.js +3 -49
  49. package/aws/s3cache/updateCache.js +13 -65
  50. package/aws/ses/SimpleEmail.d.ts +10 -13
  51. package/aws/ses/SimpleEmail.js +85 -189
  52. package/aws/ses/initClient.d.ts +5 -4
  53. package/aws/ses/initClient.js +4 -5
  54. package/aws/ssm/getParameter.js +31 -78
  55. package/aws/ssm/initClient.d.ts +5 -4
  56. package/aws/ssm/initClient.js +4 -5
  57. package/axios/get.js +35 -106
  58. package/axios/post.js +35 -106
  59. package/boolean/getBoolean.js +2 -3
  60. package/class/BaseClass.js +15 -22
  61. package/crypto/getDecrypt.js +3 -4
  62. package/crypto/getEncrypt.js +3 -4
  63. package/crypto/getRandom.js +1 -2
  64. package/crypto/getSha256.js +4 -5
  65. package/date/durationComparisons.js +1 -1
  66. package/date/durations.js +1 -1
  67. package/date/format.js +7 -8
  68. package/date/getDate.js +19 -20
  69. package/date/getDatesBetween.js +8 -9
  70. package/date/getDurationHours.js +6 -7
  71. package/date/getDurationMinutes.js +6 -7
  72. package/date/getFinancialYear.js +11 -12
  73. package/date/getFinancialYearToDate.js +5 -5
  74. package/date/getFinancialYearToYesterday.js +5 -5
  75. package/date/getFinancialYearWeeks.js +10 -11
  76. package/date/getLastWeek.js +11 -12
  77. package/date/getMax.js +5 -6
  78. package/date/getMidnight.js +2 -3
  79. package/date/getMin.js +5 -6
  80. package/date/getMonday.js +10 -11
  81. package/date/getNumber.js +4 -5
  82. package/date/getPredefinedTimeframe.js +5 -6
  83. package/date/getSunday.js +10 -11
  84. package/date/getThisWeek.js +11 -12
  85. package/date/getTimeZoned.js +11 -12
  86. package/date/getToday.js +6 -7
  87. package/date/getTwoWeeksAgo.js +11 -12
  88. package/date/getWeeksAgo.js +5 -6
  89. package/date/getYesterday.js +7 -8
  90. package/date/isDateValid.js +6 -7
  91. package/date/isLastWeek.js +3 -4
  92. package/date/isThisWeek.js +3 -4
  93. package/date/parseExcelDate.js +9 -10
  94. package/deepCrawl/buildRequest.js +19 -20
  95. package/deepCrawl/getData.js +21 -79
  96. package/deepCrawl/initClient.js +17 -64
  97. package/deepCrawl/operands.js +1 -1
  98. package/deepCrawl/orders.js +1 -1
  99. package/deepCrawl/reports.js +1 -1
  100. package/environment/environments.js +1 -1
  101. package/environment/getEnvironment.js +8 -8
  102. package/environment/isAws.js +2 -2
  103. package/environment/isDevelopment.js +3 -3
  104. package/environment/isLocalhost.js +4 -4
  105. package/environment/isProduction.js +3 -3
  106. package/environment/isStaging.js +3 -3
  107. package/environment/isVercel.js +1 -1
  108. package/environment/platforms.d.ts +1 -1
  109. package/environment/platforms.js +1 -1
  110. package/eskimi/ageGroups.js +1 -1
  111. package/eskimi/devices.js +1 -1
  112. package/eskimi/endpoints.js +1 -1
  113. package/eskimi/genders.js +1 -1
  114. package/eskimi/getAccessToken.js +11 -57
  115. package/eskimi/getAgeGroup.js +3 -4
  116. package/eskimi/getCampaignIds.js +2 -3
  117. package/eskimi/getDevice.js +3 -4
  118. package/eskimi/getGender.js +3 -4
  119. package/eskimi/request.js +13 -59
  120. package/google/bigQuery/initClient.d.ts +11 -0
  121. package/google/bigQuery/initClient.js +22 -0
  122. package/google/bigQuery/query.d.ts +9 -0
  123. package/google/bigQuery/query.js +10 -0
  124. package/google/getConfig.d.ts +20 -0
  125. package/google/getConfig.js +23 -0
  126. package/google/sheets/getAssociatedData.d.ts +2 -6
  127. package/google/sheets/getAssociatedData.js +42 -89
  128. package/google/sheets/getBatchData.d.ts +1 -3
  129. package/google/sheets/getBatchData.js +15 -60
  130. package/google/sheets/initClient.d.ts +11 -0
  131. package/google/sheets/initClient.js +25 -0
  132. package/google/sheets/isCellNa.js +1 -4
  133. package/google/storage/initClient.d.ts +12 -0
  134. package/google/storage/initClient.js +23 -0
  135. package/google/storage/writeFile.d.ts +2 -1
  136. package/google/storage/writeFile.js +20 -77
  137. package/googleAds/getCustomer.js +7 -48
  138. package/googleAds/initClient.d.ts +9 -8
  139. package/googleAds/initClient.js +13 -56
  140. package/initClients.d.ts +13 -3
  141. package/initClients.js +95 -101
  142. package/json/isJson.js +1 -2
  143. package/littleWarden/getUrlStatus.js +10 -56
  144. package/littleWarden/isAllGood.js +3 -4
  145. package/littleWarden/isDanger.js +3 -4
  146. package/littleWarden/isWarning.js +3 -4
  147. package/littleWarden/states.js +1 -1
  148. package/myTarget/getAccessToken.js +11 -57
  149. package/myTarget/request.js +13 -59
  150. package/nextAuth/isSessionReady.js +2 -3
  151. package/nextAuth/states.js +1 -1
  152. package/nextJs/getIp.js +2 -3
  153. package/nextJs/getUserAgent.js +1 -4
  154. package/number/getDivide.js +4 -5
  155. package/number/getNumber.js +6 -7
  156. package/number/getPercent.js +4 -5
  157. package/number/getPercentIncrease.js +4 -5
  158. package/number/getRounded.js +5 -6
  159. package/package.json +2 -1
  160. package/prisma/initClient.js +4 -5
  161. package/snapchat/getAccessToken.js +25 -72
  162. package/sorting/byNumberAscending.js +3 -4
  163. package/sorting/byNumberDescending.js +3 -4
  164. package/sorting/byStringAscending.js +3 -4
  165. package/sorting/byStringDescending.js +3 -4
  166. package/string/formatCapitalise.js +2 -3
  167. package/string/getCleanFolder.js +3 -6
  168. package/string/getString.js +9 -10
  169. package/string/getStringFromStream.js +7 -8
  170. package/string/toProperCase.js +6 -7
  171. package/swr/isAllData.js +4 -5
  172. package/swr/isAnyError.js +4 -5
  173. package/swr/isAnyLoading.js +4 -5
  174. package/swr/isData.js +1 -4
  175. package/swr/isError.js +1 -4
  176. package/swr/isLoading.js +3 -6
  177. package/upTimeRobot/getMonitors.d.ts +1 -0
  178. package/upTimeRobot/getMonitors.js +33 -0
  179. package/upTimeRobot/logTypes.d.ts +7 -0
  180. package/upTimeRobot/logTypes.js +9 -0
  181. package/upTimeRobot/monitorStatuses.d.ts +8 -0
  182. package/upTimeRobot/monitorStatuses.js +10 -0
  183. package/upTimeRobot/monitorSubTypes.d.ts +10 -0
  184. package/upTimeRobot/monitorSubTypes.js +12 -0
  185. package/upTimeRobot/monitorTypes.d.ts +8 -0
  186. package/upTimeRobot/monitorTypes.js +10 -0
  187. package/upTimeRobot/requestStatuses.d.ts +5 -0
  188. package/upTimeRobot/requestStatuses.js +7 -0
  189. package/url/buildParameters.js +7 -8
  190. package/url/buildRelative.js +3 -4
  191. package/url/buildUrl.js +6 -7
  192. package/url/isAbsolute.js +1 -2
  193. package/url/isRelative.js +2 -5
  194. package/util/defaultTo.d.ts +6 -5
  195. package/util/defaultTo.js +6 -7
  196. package/util/isUndefined.d.ts +9 -0
  197. package/util/isUndefined.js +19 -0
  198. package/util/sleep.js +2 -3
  199. package/webWorker/states.js +1 -1
  200. package/xml/getXml.js +10 -58
  201. package/aws/athenaExpress/request.d.ts +0 -8
  202. package/aws/athenaExpress/request.js +0 -54
  203. package/aws/config.d.ts +0 -5
  204. package/aws/config.js +0 -2
  205. package/google/getCredentials.d.ts +0 -20
  206. package/google/getCredentials.js +0 -76
  207. package/google/sheets/getAuth.d.ts +0 -8
  208. package/google/sheets/getAuth.js +0 -69
@@ -1,220 +1,116 @@
1
1
  "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __assign = (this && this.__assign) || function () {
18
- __assign = Object.assign || function(t) {
19
- for (var s, i = 1, n = arguments.length; i < n; i++) {
20
- s = arguments[i];
21
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
22
- t[p] = s[p];
23
- }
24
- return t;
25
- };
26
- return __assign.apply(this, arguments);
27
- };
28
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
29
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
30
- return new (P || (P = Promise))(function (resolve, reject) {
31
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
32
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
33
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
34
- step((generator = generator.apply(thisArg, _arguments || [])).next());
35
- });
36
- };
37
- var __generator = (this && this.__generator) || function (thisArg, body) {
38
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
39
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
40
- function verb(n) { return function (v) { return step([n, v]); }; }
41
- function step(op) {
42
- if (f) throw new TypeError("Generator is already executing.");
43
- while (_) try {
44
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
45
- if (y = 0, t) op = [op[0] & 2, t.value];
46
- switch (op[0]) {
47
- case 0: case 1: t = op; break;
48
- case 4: _.label++; return { value: op[1], done: false };
49
- case 5: _.label++; y = op[1]; op = [0]; continue;
50
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
51
- default:
52
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
53
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
54
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
55
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
56
- if (t[2]) _.ops.pop();
57
- _.trys.pop(); continue;
58
- }
59
- op = body.call(thisArg, _);
60
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
61
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
62
- }
63
- };
64
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
65
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
66
4
  };
67
5
  Object.defineProperty(exports, "__esModule", { value: true });
68
- var uniq_1 = __importDefault(require("lodash/uniq"));
69
- var response_1 = __importDefault(require("../../api/response"));
70
- var states_1 = __importDefault(require("../../api/states"));
71
- var unexpectedError_1 = __importDefault(require("../../api/unexpectedError"));
72
- var BaseClass_1 = __importDefault(require("../../class/BaseClass"));
73
- var isResponse200_1 = __importDefault(require("../isResponse200"));
74
- var initClient_1 = __importDefault(require("./initClient"));
6
+ const uniq_1 = __importDefault(require("lodash/uniq"));
7
+ const BaseClass_1 = __importDefault(require("../../class/BaseClass"));
8
+ const isResponse200_1 = __importDefault(require("../isResponse200"));
75
9
  /**
76
10
  * Class to build and send an AWS SES email.
77
11
  */
78
- var SimpleEmail = /** @class */ (function (_super) {
79
- __extends(SimpleEmail, _super);
80
- function SimpleEmail(_a) {
81
- var _b = _a.bcc, bcc = _b === void 0 ? undefined : _b, _c = _a.cc, cc = _c === void 0 ? undefined : _c, _d = _a.from, from = _d === void 0 ? undefined : _d, _e = _a.html, html = _e === void 0 ? undefined : _e, _f = _a.subject, subject = _f === void 0 ? undefined : _f, _g = _a.to, to = _g === void 0 ? undefined : _g;
82
- var _this = _super.call(this) || this;
83
- _this.from = undefined;
84
- _this.to = [];
85
- _this.cc = [];
86
- _this.bcc = [];
87
- _this.html = undefined;
88
- _this.subject = undefined;
89
- if (undefined !== bcc) {
90
- _this.setBcc({ recipient: bcc });
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 });
91
20
  }
92
- if (undefined !== cc) {
93
- _this.setCc({ recipient: cc });
21
+ if (cc) {
22
+ this.setCc({ recipient: cc });
94
23
  }
95
- if (undefined !== from) {
96
- _this.setFrom({ from: from });
24
+ if (from) {
25
+ this.setFrom({ from });
97
26
  }
98
- if (undefined !== html) {
99
- _this.setHtml({ html: html });
27
+ if (html) {
28
+ this.setHtml({ html });
100
29
  }
101
- if (undefined !== subject) {
102
- _this.setSubject({ subject: subject });
30
+ if (subject) {
31
+ this.setSubject({ subject });
103
32
  }
104
- if (undefined !== to) {
105
- _this.setTo({ recipient: to });
33
+ if (to) {
34
+ this.setTo({ recipient: to });
106
35
  }
107
- return _this;
36
+ return this;
108
37
  }
109
- SimpleEmail.prototype.setFrom = function (_a) {
110
- var from = _a.from;
38
+ setFrom({ from }) {
111
39
  return this._setValue({ input: from, fields: 'from' });
112
- };
113
- SimpleEmail.prototype.setHtml = function (_a) {
114
- var html = _a.html;
40
+ }
41
+ setHtml({ html }) {
115
42
  return this._setValue({ input: html, fields: 'html' });
116
- };
117
- SimpleEmail.prototype.setSubject = function (_a) {
118
- var subject = _a.subject;
43
+ }
44
+ setSubject({ subject }) {
119
45
  return this._setValue({ input: subject, fields: 'subject' });
120
- };
121
- SimpleEmail.prototype.pushBcc = function (_a) {
122
- var recipient = _a.recipient;
46
+ }
47
+ pushBcc({ recipient }) {
123
48
  return this._push({ input: recipient, fields: 'bcc' });
124
- };
125
- SimpleEmail.prototype.pushCc = function (_a) {
126
- var recipient = _a.recipient;
49
+ }
50
+ pushCc({ recipient }) {
127
51
  return this._push({ input: recipient, fields: 'cc' });
128
- };
129
- SimpleEmail.prototype.pushTo = function (_a) {
130
- var recipient = _a.recipient;
52
+ }
53
+ pushTo({ recipient }) {
131
54
  return this._push({ input: recipient, fields: 'to' });
132
- };
133
- SimpleEmail.prototype.setBcc = function (_a) {
134
- var recipient = _a.recipient;
55
+ }
56
+ setBcc({ recipient }) {
135
57
  return this._setArray({ input: recipient, fields: 'bcc' });
136
- };
137
- SimpleEmail.prototype.setCc = function (_a) {
138
- var recipient = _a.recipient;
58
+ }
59
+ setCc({ recipient }) {
139
60
  return this._setArray({ input: recipient, fields: 'cc' });
140
- };
141
- SimpleEmail.prototype.setTo = function (_a) {
142
- var recipient = _a.recipient;
61
+ }
62
+ setTo({ recipient }) {
143
63
  return this._setArray({ input: recipient, fields: 'to' });
144
- };
145
- SimpleEmail.prototype.send = function (_a) {
146
- var config = _a.config;
147
- return __awaiter(this, void 0, void 0, function () {
148
- var SendEmailCommand, response, params, command, apiResponse_1, error_1;
149
- return __generator(this, function (_b) {
150
- switch (_b.label) {
151
- case 0:
152
- // Ensure the client has been initialised
153
- (0, initClient_1.default)({ config: config });
154
- SendEmailCommand = require('@aws-sdk/client-ses').SendEmailCommand;
155
- response = __assign({}, response_1.default);
156
- params = {
157
- Destination: {
158
- BccAddresses: this._filterRecipients({ field: 'bcc' }),
159
- CcAddresses: this._filterRecipients({ field: 'cc' }),
160
- ToAddresses: this._filterRecipients({ field: 'to' }),
161
- },
162
- Message: {
163
- Body: {
164
- Html: {
165
- Charset: "UTF-8",
166
- Data: this.html,
167
- },
168
- Text: {
169
- Charset: "UTF-8",
170
- Data: this.html,
171
- },
172
- },
173
- Subject: {
174
- Charset: "UTF-8",
175
- Data: this.subject,
176
- },
177
- },
178
- Source: this.from,
179
- };
180
- _b.label = 1;
181
- case 1:
182
- _b.trys.push([1, 3, , 4]);
183
- command = new SendEmailCommand(params);
184
- return [4 /*yield*/, global.awsSesClient.send(command)];
185
- case 2:
186
- apiResponse_1 = _b.sent();
187
- if ((0, isResponse200_1.default)({ apiResponse: apiResponse_1 })) {
188
- response.state = states_1.default.SUCCESS;
189
- }
190
- else {
191
- response.state = states_1.default.ERROR;
192
- response.error = unexpectedError_1.default;
193
- }
194
- return [3 /*break*/, 4];
195
- case 3:
196
- error_1 = _b.sent();
197
- response.state = states_1.default.ERROR;
198
- response.error = error_1.message;
199
- return [3 /*break*/, 4];
200
- case 4: return [2 /*return*/, response];
201
- }
202
- });
203
- });
204
- };
205
- SimpleEmail.prototype._filterRecipients = function (_a) {
206
- var field = _a.field;
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 }) {
207
104
  // Remove all undefined and null values
208
- var response = this[field].filter(function (recipient) { return undefined !== recipient && null !== recipient; });
105
+ let response = this[field].filter(recipient => recipient && null !== recipient);
209
106
  // Clean all the values
210
- response = response.map(function (recipient) { return recipient.toLowerCase()
211
- .trim(); });
107
+ response = response.map(recipient => recipient.toLowerCase()
108
+ .trim());
212
109
  // Remove all empty values
213
- response = response.filter(function (recipient) { return '' !== recipient; });
110
+ response = response.filter(recipient => '' !== recipient);
214
111
  // Return only unique values
215
112
  response = (0, uniq_1.default)(response);
216
113
  return response;
217
- };
218
- return SimpleEmail;
219
- }(BaseClass_1.default));
114
+ }
115
+ }
220
116
  exports.default = SimpleEmail;
@@ -1,9 +1,10 @@
1
- import { Config } from '../config';
1
+ import { Config } from '../getConfig';
2
+ declare type InitClient = {
3
+ config: Config;
4
+ };
2
5
  /**
3
6
  * Shorthand function to get the Lambda Client.
4
7
  * Library: @aws-sdk/client-ses
5
8
  */
6
- declare const initClient: ({ config }: {
7
- config: Config;
8
- }) => void;
9
+ declare const initClient: ({ config }: InitClient) => void;
9
10
  export default initClient;
@@ -3,17 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var getConfig_1 = __importDefault(require("../getConfig"));
6
+ const getConfig_1 = __importDefault(require("../getConfig"));
7
7
  global.awsSesClient = null;
8
8
  /**
9
9
  * Shorthand function to get the Lambda Client.
10
10
  * Library: @aws-sdk/client-ses
11
11
  */
12
- var initClient = function (_a) {
13
- var config = _a.config;
12
+ const initClient = ({ config }) => {
14
13
  if (!global.awsSesClient) {
15
- var SESClient = require('@aws-sdk/client-ses').SESClient;
16
- var formattedConfig = (0, getConfig_1.default)({ config: config });
14
+ const { SESClient } = require('@aws-sdk/client-ses');
15
+ const formattedConfig = (0, getConfig_1.default)({ config });
17
16
  global.awsSesClient = new SESClient(formattedConfig);
18
17
  }
19
18
  };
@@ -1,87 +1,40 @@
1
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 __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  global["awsSsmParameters"] = {};
40
4
  /**
41
5
  * Get a parameter and decryption if necessary (secure string)
42
6
  */
43
- var getParameter = function (_a) {
44
- var name = _a.name, withDecryption = _a.withDecryption, isJson = _a.isJson;
45
- return __awaiter(void 0, void 0, void 0, function () {
46
- var GetParameterCommand, apiResponse;
47
- return __generator(this, function (_b) {
48
- switch (_b.label) {
49
- case 0:
50
- if (!(undefined === global["awsSsmParameters"][name])) return [3 /*break*/, 2];
51
- GetParameterCommand = require('@aws-sdk/client-ssm').GetParameterCommand;
52
- return [4 /*yield*/, global.awsSsmClient.send(new GetParameterCommand({
53
- Name: name,
54
- WithDecryption: undefined === withDecryption ? true : withDecryption,
55
- }))];
56
- case 1:
57
- apiResponse = _b.sent();
58
- if (apiResponse.Parameter.Value) {
59
- // Value is undefined
60
- if (undefined === apiResponse.Parameter.Value) {
61
- global["awsSsmParameters"][name] = null;
62
- }
63
- // Value is defined
64
- else {
65
- // isJson is default - decode
66
- if (undefined === isJson || true === isJson) {
67
- global["awsSsmParameters"][name] = JSON.parse(apiResponse.Parameter.Value) || null;
68
- }
69
- // Not JSON don't decode
70
- else {
71
- global["awsSsmParameters"][name] = apiResponse.Parameter.Value;
72
- }
73
- }
74
- }
75
- // Value not found (null so it can be sent from server to front end)
76
- else {
77
- global["awsSsmParameters"][name] = null;
78
- }
79
- _b.label = 2;
80
- case 2:
81
- // Return the loaded result
82
- return [2 /*return*/, global["awsSsmParameters"][name]];
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
+ }
83
30
  }
84
- });
85
- });
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];
86
39
  };
87
40
  exports.default = getParameter;
@@ -1,9 +1,10 @@
1
- import { Config } from '../config';
1
+ import { Config } from '../getConfig';
2
+ declare type InitClient = {
3
+ config: Config;
4
+ };
2
5
  /**
3
6
  * Shorthand function to get the Lambda Client.
4
7
  * Library: @aws-sdk/client-ssm
5
8
  */
6
- declare const initClient: ({ config }: {
7
- config: Config;
8
- }) => void;
9
+ declare const initClient: ({ config }: InitClient) => void;
9
10
  export default initClient;
@@ -3,17 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- var getConfig_1 = __importDefault(require("../getConfig"));
6
+ const getConfig_1 = __importDefault(require("../getConfig"));
7
7
  global.awsSsmClient = null;
8
8
  /**
9
9
  * Shorthand function to get the Lambda Client.
10
10
  * Library: @aws-sdk/client-ssm
11
11
  */
12
- var initClient = function (_a) {
13
- var config = _a.config;
12
+ const initClient = ({ config }) => {
14
13
  if (!global.awsSsmClient) {
15
- var SSMClient = require('@aws-sdk/client-ssm').SSMClient;
16
- var formattedConfig = (0, getConfig_1.default)({ config: config });
14
+ const { SSMClient } = require('@aws-sdk/client-ssm');
15
+ const formattedConfig = (0, getConfig_1.default)({ config });
17
16
  global.awsSsmClient = new SSMClient(formattedConfig);
18
17
  }
19
18
  };