@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.
Files changed (352) hide show
  1. package/api/response.d.ts +8 -0
  2. package/api/response.js +12 -1
  3. package/api/states.d.ts +9 -0
  4. package/api/states.js +10 -1
  5. package/api/unexpectedError.d.ts +2 -0
  6. package/api/unexpectedError.js +4 -1
  7. package/array/contains.d.ts +8 -0
  8. package/array/contains.js +6 -2
  9. package/array/getArray.d.ts +7 -0
  10. package/array/getArray.js +10 -2
  11. package/atInternet/request.d.ts +30 -0
  12. package/atInternet/request.js +2 -1
  13. package/aws/athenaExpress/initClient.d.ts +12 -0
  14. package/aws/athenaExpress/initClient.js +27 -3
  15. package/aws/athenaExpress/query.d.ts +8 -0
  16. package/aws/athenaExpress/query.js +9 -2
  17. package/aws/getConfig.d.ts +13 -0
  18. package/aws/getConfig.js +26 -2
  19. package/aws/glue/initClient.d.ts +10 -0
  20. package/aws/glue/initClient.js +17 -2
  21. package/aws/glue/invoke.d.ts +9 -0
  22. package/aws/glue/invoke.js +19 -2
  23. package/aws/isResponse200.d.ts +7 -0
  24. package/aws/isResponse200.js +21 -2
  25. package/aws/lambda/getHandlerPath.d.ts +5 -0
  26. package/aws/lambda/getHandlerPath.js +7 -1
  27. package/aws/lambda/initClient.d.ts +10 -0
  28. package/aws/lambda/initClient.js +17 -2
  29. package/aws/lambda/invoke.d.ts +12 -0
  30. package/aws/lambda/invoke.js +39 -2
  31. package/aws/s3/copyFile.d.ts +13 -0
  32. package/aws/s3/copyFile.js +13 -2
  33. package/aws/s3/deleteFile.d.ts +9 -0
  34. package/aws/s3/deleteFile.js +12 -2
  35. package/aws/s3/deleteFiles.d.ts +9 -0
  36. package/aws/s3/deleteFiles.js +16 -2
  37. package/aws/s3/deleteFolder.d.ts +9 -0
  38. package/aws/s3/deleteFolder.js +35 -2
  39. package/aws/s3/getGlueJson.d.ts +5 -0
  40. package/aws/s3/getGlueJson.js +15 -2
  41. package/aws/s3/getPresignedPost.d.ts +20 -0
  42. package/aws/s3/getPresignedPost.js +16 -3
  43. package/aws/s3/getSignedUrl.d.ts +12 -0
  44. package/aws/s3/getSignedUrl.js +15 -2
  45. package/aws/s3/initClient.d.ts +10 -0
  46. package/aws/s3/initClient.js +17 -2
  47. package/aws/s3/isFileExists.d.ts +9 -0
  48. package/aws/s3/isFileExists.js +26 -2
  49. package/aws/s3/listFiles.d.ts +9 -0
  50. package/aws/s3/listFiles.js +32 -2
  51. package/aws/s3/listFolders.d.ts +9 -0
  52. package/aws/s3/listFolders.js +31 -4
  53. package/aws/s3/moveFile.d.ts +10 -0
  54. package/aws/s3/moveFile.js +20 -2
  55. package/aws/s3/readBuffer.d.ts +13 -0
  56. package/aws/s3/readBuffer.js +51 -2
  57. package/aws/s3/readFile.d.ts +30 -0
  58. package/aws/s3/readFile.js +69 -2
  59. package/aws/s3/writeFile.d.ts +10 -0
  60. package/aws/s3/writeFile.js +15 -2
  61. package/aws/s3/writePresignedPost.d.ts +14 -0
  62. package/aws/s3/writePresignedPost.js +30 -2
  63. package/aws/s3cache/cache.d.ts +7 -0
  64. package/aws/s3cache/cache.js +2 -1
  65. package/aws/s3cache/getCache.d.ts +12 -0
  66. package/aws/s3cache/getCache.js +35 -2
  67. package/aws/s3cache/getKey.d.ts +10 -0
  68. package/aws/s3cache/getKey.js +16 -2
  69. package/aws/s3cache/saveCache.d.ts +10 -0
  70. package/aws/s3cache/saveCache.js +12 -2
  71. package/aws/s3cache/updateCache.d.ts +10 -0
  72. package/aws/s3cache/updateCache.js +23 -2
  73. package/aws/ses/SimpleEmail.d.ts +51 -0
  74. package/aws/ses/SimpleEmail.js +115 -2
  75. package/aws/ses/initClient.d.ts +10 -0
  76. package/aws/ses/initClient.js +17 -2
  77. package/aws/ssm/getParameter.d.ts +10 -0
  78. package/aws/ssm/getParameter.js +39 -2
  79. package/aws/ssm/initClient.d.ts +10 -0
  80. package/aws/ssm/initClient.js +17 -2
  81. package/axios/get.d.ts +8 -0
  82. package/axios/get.js +44 -1
  83. package/axios/post.d.ts +12 -0
  84. package/axios/post.js +46 -2
  85. package/boolean/getBoolean.d.ts +7 -0
  86. package/boolean/getBoolean.js +15 -2
  87. package/class/BaseClass.d.ts +31 -0
  88. package/class/BaseClass.js +50 -9
  89. package/crud/actions.d.ts +8 -0
  90. package/crud/actions.js +10 -1
  91. package/crypto/getDecrypt.d.ts +10 -0
  92. package/crypto/getDecrypt.js +11 -2
  93. package/crypto/getEncrypt.d.ts +10 -0
  94. package/crypto/getEncrypt.js +11 -2
  95. package/crypto/getRandom.d.ts +8 -0
  96. package/crypto/getRandom.js +10 -2
  97. package/crypto/getSha256.d.ts +8 -0
  98. package/crypto/getSha256.js +15 -2
  99. package/date/date.d.ts +4 -0
  100. package/date/date.js +2 -1
  101. package/date/duration.d.ts +5 -0
  102. package/date/duration.js +2 -1
  103. package/date/durationComparisons.d.ts +5 -0
  104. package/date/durationComparisons.js +7 -1
  105. package/date/durations.d.ts +8 -0
  106. package/date/durations.js +10 -1
  107. package/date/financialYear.d.ts +4 -0
  108. package/date/financialYear.js +2 -1
  109. package/date/financialYearWeek.d.ts +6 -0
  110. package/date/financialYearWeek.js +2 -1
  111. package/date/format.d.ts +13 -0
  112. package/date/format.js +18 -2
  113. package/date/getDate.d.ts +12 -0
  114. package/date/getDate.js +96 -9
  115. package/date/getDatesBetween.d.ts +10 -0
  116. package/date/getDatesBetween.js +25 -3
  117. package/date/getDurationHours.d.ts +8 -0
  118. package/date/getDurationHours.js +25 -2
  119. package/date/getDurationMinutes.d.ts +8 -0
  120. package/date/getDurationMinutes.js +24 -2
  121. package/date/getFinancialYear.d.ts +9 -0
  122. package/date/getFinancialYear.js +48 -8
  123. package/date/getFinancialYearToDate.d.ts +7 -0
  124. package/date/getFinancialYearToDate.js +18 -2
  125. package/date/getFinancialYearToYesterday.d.ts +7 -0
  126. package/date/getFinancialYearToYesterday.js +18 -2
  127. package/date/getFinancialYearWeeks.d.ts +9 -0
  128. package/date/getFinancialYearWeeks.js +29 -2
  129. package/date/getLastWeek.d.ts +10 -0
  130. package/date/getLastWeek.js +28 -2
  131. package/date/getMax.d.ts +12 -0
  132. package/date/getMax.js +15 -2
  133. package/date/getMidnight.d.ts +10 -0
  134. package/date/getMidnight.js +12 -2
  135. package/date/getMin.d.ts +12 -0
  136. package/date/getMin.js +15 -2
  137. package/date/getMonday.d.ts +14 -0
  138. package/date/getMonday.js +32 -5
  139. package/date/getNumber.d.ts +11 -0
  140. package/date/getNumber.js +14 -2
  141. package/date/getPredefinedTimeframe.d.ts +9 -0
  142. package/date/getPredefinedTimeframe.js +23 -2
  143. package/date/getSunday.d.ts +14 -0
  144. package/date/getSunday.js +32 -5
  145. package/date/getThisWeek.d.ts +10 -0
  146. package/date/getThisWeek.js +28 -2
  147. package/date/getTimeZoned.d.ts +13 -0
  148. package/date/getTimeZoned.js +36 -5
  149. package/date/getToday.d.ts +9 -0
  150. package/date/getToday.js +39 -2
  151. package/date/getTwoWeeksAgo.d.ts +10 -0
  152. package/date/getTwoWeeksAgo.js +28 -2
  153. package/date/getWeeksAgo.d.ts +12 -0
  154. package/date/getWeeksAgo.js +16 -2
  155. package/date/getYesterday.d.ts +9 -0
  156. package/date/getYesterday.js +40 -2
  157. package/date/isDateValid.d.ts +7 -0
  158. package/date/isDateValid.js +22 -2
  159. package/date/isLastWeek.d.ts +6 -0
  160. package/date/isLastWeek.js +13 -2
  161. package/date/isThisWeek.d.ts +6 -0
  162. package/date/isThisWeek.js +13 -2
  163. package/date/parseExcelDate.d.ts +8 -0
  164. package/date/parseExcelDate.js +17 -2
  165. package/date/predefinedTimeframes.d.ts +7 -0
  166. package/date/predefinedTimeframes.js +9 -1
  167. package/date/timeframe.d.ts +8 -0
  168. package/date/timeframe.js +2 -1
  169. package/date/timeframes.d.ts +4 -0
  170. package/date/timeframes.js +7 -1
  171. package/deepCrawl/buildRequest.d.ts +15 -0
  172. package/deepCrawl/buildRequest.js +83 -4
  173. package/deepCrawl/filter.d.ts +5 -0
  174. package/deepCrawl/filter.js +2 -1
  175. package/deepCrawl/getData.d.ts +5 -0
  176. package/deepCrawl/getData.js +29 -1
  177. package/deepCrawl/initClient.d.ts +13 -0
  178. package/deepCrawl/initClient.js +31 -2
  179. package/deepCrawl/operands.d.ts +11 -0
  180. package/deepCrawl/operands.js +13 -1
  181. package/deepCrawl/orders.d.ts +9 -0
  182. package/deepCrawl/orders.js +7 -1
  183. package/deepCrawl/reports.d.ts +11 -0
  184. package/deepCrawl/reports.js +13 -1
  185. package/environment/environments.d.ts +7 -0
  186. package/environment/environments.js +8 -1
  187. package/environment/getEnvironment.d.ts +6 -0
  188. package/environment/getEnvironment.js +42 -2
  189. package/environment/isAws.d.ts +5 -0
  190. package/environment/isAws.js +10 -2
  191. package/environment/isDevelopment.d.ts +2 -0
  192. package/environment/isDevelopment.js +9 -1
  193. package/environment/isLocalhost.d.ts +5 -0
  194. package/environment/isLocalhost.js +21 -2
  195. package/environment/isProduction.d.ts +2 -0
  196. package/environment/isProduction.js +9 -1
  197. package/environment/isStaging.d.ts +2 -0
  198. package/environment/isStaging.js +9 -1
  199. package/environment/isVercel.d.ts +5 -0
  200. package/environment/isVercel.js +6 -2
  201. package/environment/platforms.d.ts +6 -0
  202. package/environment/platforms.js +7 -1
  203. package/eskimi/ageGroups.d.ts +5 -0
  204. package/eskimi/ageGroups.js +41 -1
  205. package/eskimi/campaign.d.ts +19 -0
  206. package/eskimi/campaign.js +2 -1
  207. package/eskimi/devices.d.ts +5 -0
  208. package/eskimi/devices.js +13 -1
  209. package/eskimi/endpoints.d.ts +16 -0
  210. package/eskimi/endpoints.js +17 -2
  211. package/eskimi/genders.d.ts +5 -0
  212. package/eskimi/genders.js +13 -1
  213. package/eskimi/getAccessToken.d.ts +9 -0
  214. package/eskimi/getAccessToken.js +22 -2
  215. package/eskimi/getAgeGroup.d.ts +7 -0
  216. package/eskimi/getAgeGroup.js +16 -2
  217. package/eskimi/getCampaignIds.d.ts +7 -0
  218. package/eskimi/getCampaignIds.js +11 -2
  219. package/eskimi/getDevice.d.ts +7 -0
  220. package/eskimi/getDevice.js +16 -2
  221. package/eskimi/getGender.d.ts +7 -0
  222. package/eskimi/getGender.js +16 -2
  223. package/eskimi/request.d.ts +8 -0
  224. package/eskimi/request.js +23 -2
  225. package/google/bigQuery/initClient.d.ts +11 -0
  226. package/google/bigQuery/initClient.js +20 -2
  227. package/google/bigQuery/query.d.ts +9 -0
  228. package/google/bigQuery/query.js +9 -2
  229. package/google/getConfig.d.ts +20 -0
  230. package/google/getConfig.js +21 -3
  231. package/google/sheets/getAssociatedData.d.ts +16 -0
  232. package/google/sheets/getAssociatedData.js +52 -8
  233. package/google/sheets/getBatchData.d.ts +18 -0
  234. package/google/sheets/getBatchData.js +19 -1
  235. package/google/sheets/initClient.d.ts +11 -0
  236. package/google/sheets/initClient.js +22 -2
  237. package/google/sheets/isCellNa.d.ts +7 -0
  238. package/google/sheets/isCellNa.js +6 -2
  239. package/google/storage/initClient.d.ts +12 -0
  240. package/google/storage/initClient.js +20 -2
  241. package/google/storage/writeFile.d.ts +12 -0
  242. package/google/storage/writeFile.js +30 -2
  243. package/googleAds/getCustomer.d.ts +8 -0
  244. package/googleAds/getCustomer.js +13 -2
  245. package/googleAds/initClient.d.ts +16 -0
  246. package/googleAds/initClient.js +23 -2
  247. package/initClients.d.ts +40 -0
  248. package/initClients.js +106 -5
  249. package/json/isJson.d.ts +8 -0
  250. package/json/isJson.js +18 -2
  251. package/littleWarden/getUrlStatus.d.ts +9 -0
  252. package/littleWarden/getUrlStatus.js +20 -2
  253. package/littleWarden/isAllGood.d.ts +7 -0
  254. package/littleWarden/isAllGood.js +17 -2
  255. package/littleWarden/isDanger.d.ts +7 -0
  256. package/littleWarden/isDanger.js +17 -2
  257. package/littleWarden/isWarning.d.ts +7 -0
  258. package/littleWarden/isWarning.js +17 -2
  259. package/littleWarden/states.d.ts +7 -0
  260. package/littleWarden/states.js +8 -1
  261. package/myTarget/getAccessToken.d.ts +9 -0
  262. package/myTarget/getAccessToken.js +22 -2
  263. package/myTarget/request.d.ts +8 -0
  264. package/myTarget/request.js +23 -2
  265. package/nextAuth/isSessionReady.d.ts +4 -0
  266. package/nextAuth/isSessionReady.js +12 -1
  267. package/nextAuth/states.d.ts +7 -0
  268. package/nextAuth/states.js +8 -2
  269. package/nextJs/getIp.d.ts +7 -0
  270. package/nextJs/getIp.js +12 -2
  271. package/nextJs/getUserAgent.d.ts +7 -0
  272. package/nextJs/getUserAgent.js +6 -2
  273. package/number/getDivide.d.ts +9 -0
  274. package/number/getDivide.js +17 -2
  275. package/number/getNumber.d.ts +8 -0
  276. package/number/getNumber.js +50 -7
  277. package/number/getPercent.d.ts +9 -0
  278. package/number/getPercent.js +17 -2
  279. package/number/getPercentIncrease.d.ts +9 -0
  280. package/number/getPercentIncrease.js +17 -2
  281. package/number/getRounded.d.ts +9 -0
  282. package/number/getRounded.js +21 -2
  283. package/package.json +44 -47
  284. package/prisma/initClient.d.ts +4 -0
  285. package/prisma/initClient.js +33 -3
  286. package/snapchat/getAccessToken.d.ts +9 -0
  287. package/snapchat/getAccessToken.js +36 -2
  288. package/sorting/byNumberAscending.d.ts +8 -0
  289. package/sorting/byNumberAscending.js +16 -2
  290. package/sorting/byNumberDescending.d.ts +8 -0
  291. package/sorting/byNumberDescending.js +16 -2
  292. package/sorting/byStringAscending.d.ts +8 -0
  293. package/sorting/byStringAscending.js +20 -2
  294. package/sorting/byStringDescending.d.ts +8 -0
  295. package/sorting/byStringDescending.js +20 -2
  296. package/string/formatCapitalise.d.ts +9 -0
  297. package/string/formatCapitalise.js +14 -2
  298. package/string/getCleanFolder.d.ts +7 -0
  299. package/string/getCleanFolder.js +11 -2
  300. package/string/getString.d.ts +7 -0
  301. package/string/getString.js +35 -2
  302. package/string/getStringFromStream.d.ts +8 -0
  303. package/string/getStringFromStream.js +14 -2
  304. package/string/toProperCase.d.ts +7 -0
  305. package/string/toProperCase.js +17 -2
  306. package/swr/isAllData.d.ts +7 -0
  307. package/swr/isAllData.js +18 -2
  308. package/swr/isAnyError.d.ts +7 -0
  309. package/swr/isAnyError.js +18 -2
  310. package/swr/isAnyLoading.d.ts +7 -0
  311. package/swr/isAnyLoading.js +20 -2
  312. package/swr/isData.d.ts +7 -0
  313. package/swr/isData.js +6 -2
  314. package/swr/isError.d.ts +7 -0
  315. package/swr/isError.js +6 -2
  316. package/swr/isLoading.d.ts +7 -0
  317. package/swr/isLoading.js +11 -2
  318. package/upTimeRobot/getMonitors.d.ts +1 -0
  319. package/upTimeRobot/getMonitors.js +31 -2
  320. package/upTimeRobot/logTypes.d.ts +7 -0
  321. package/upTimeRobot/logTypes.js +9 -1
  322. package/upTimeRobot/monitorStatuses.d.ts +8 -0
  323. package/upTimeRobot/monitorStatuses.js +10 -1
  324. package/upTimeRobot/monitorSubTypes.d.ts +10 -0
  325. package/upTimeRobot/monitorSubTypes.js +12 -1
  326. package/upTimeRobot/monitorTypes.d.ts +8 -0
  327. package/upTimeRobot/monitorTypes.js +10 -1
  328. package/upTimeRobot/requestStatuses.d.ts +5 -0
  329. package/upTimeRobot/requestStatuses.js +7 -1
  330. package/url/buildParameters.d.ts +8 -0
  331. package/url/buildParameters.js +21 -2
  332. package/url/buildRelative.d.ts +8 -0
  333. package/url/buildRelative.js +12 -2
  334. package/url/buildUrl.d.ts +10 -0
  335. package/url/buildUrl.js +28 -2
  336. package/url/isAbsolute.d.ts +7 -0
  337. package/url/isAbsolute.js +14 -2
  338. package/url/isRelative.d.ts +7 -0
  339. package/url/isRelative.js +7 -2
  340. package/url/url.d.ts +6 -0
  341. package/url/url.js +2 -1
  342. package/util/defaultTo.d.ts +10 -0
  343. package/util/defaultTo.js +34 -2
  344. package/util/isUndefined.d.ts +9 -0
  345. package/util/isUndefined.js +18 -2
  346. package/util/sleep.d.ts +4 -0
  347. package/util/sleep.js +6 -1
  348. package/webWorker/states.d.ts +7 -0
  349. package/webWorker/states.js +8 -1
  350. package/xml/getXml.d.ts +4 -0
  351. package/xml/getXml.js +14 -1
  352. package/globals.d.js +0 -1
@@ -1,3 +1,116 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _uniq=_interopRequireDefault(require("lodash/uniq")),_BaseClass2=_interopRequireDefault(require("../../class/BaseClass")),_isResponse=_interopRequireDefault(require("../isResponse200"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _inherits(a,b){if("function"!=typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function");a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,writable:!0,configurable:!0}}),Object.defineProperty(a,"prototype",{writable:!1}),b&&_setPrototypeOf(a,b)}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _createSuper(a){var b=_isNativeReflectConstruct();return function(){var c,d=_getPrototypeOf(a);if(b){var e=_getPrototypeOf(this).constructor;c=Reflect.construct(d,arguments,e)}else c=d.apply(this,arguments);return _possibleConstructorReturn(this,c)}}function _possibleConstructorReturn(a,b){if(b&&("object"===_typeof(b)||"function"==typeof b))return b;if(void 0!==b)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(a)}function _assertThisInitialized(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}function _getPrototypeOf(a){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(a){return a.__proto__||Object.getPrototypeOf(a)},_getPrototypeOf(a)}function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}/**
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
- */var SimpleEmail=/*#__PURE__*/function(a){function b(a){var d,e=a.bcc,f=a.cc,g=a.from,h=a.html,i=a.subject,j=a.to;return _classCallCheck(this,b),d=c.call(this),_defineProperty(_assertThisInitialized(d),"to",[]),_defineProperty(_assertThisInitialized(d),"cc",[]),_defineProperty(_assertThisInitialized(d),"bcc",[]),e&&d.setBcc({recipient:e}),f&&d.setCc({recipient:f}),g&&d.setFrom({from:g}),h&&d.setHtml({html:h}),i&&d.setSubject({subject:i}),j&&d.setTo({recipient:j}),_possibleConstructorReturn(d,_assertThisInitialized(d))}_inherits(b,a);var c=_createSuper(b);return _createClass(b,[{key:"setFrom",value:function setFrom(a){var b=a.from;return this._setValue({input:b,fields:"from"})}},{key:"setHtml",value:function setHtml(a){var b=a.html;return this._setValue({input:b,fields:"html"})}},{key:"setSubject",value:function setSubject(a){var b=a.subject;return this._setValue({input:b,fields:"subject"})}},{key:"pushBcc",value:function pushBcc(a){var b=a.recipient;return this._push({input:b,fields:"bcc"})}},{key:"pushCc",value:function pushCc(a){var b=a.recipient;return this._push({input:b,fields:"cc"})}},{key:"pushTo",value:function pushTo(a){var b=a.recipient;return this._push({input:b,fields:"to"})}},{key:"setBcc",value:function setBcc(a){var b=a.recipient;return this._setArray({input:b,fields:"bcc"})}},{key:"setCc",value:function setCc(a){var b=a.recipient;return this._setArray({input:b,fields:"cc"})}},{key:"setTo",value:function setTo(a){var b=a.recipient;return this._setArray({input:b,fields:"to"})}},{key:"send",value:function(){function a(){return b.apply(this,arguments)}var b=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function a(){var b,c,d,e,f,g;return _regeneratorRuntime().wrap(function h(a){for(;1;)switch(a.prev=a.next){case 0:return b=require("@aws-sdk/client-ses"),c=b.SendEmailCommand,e={Destination:{BccAddresses:this._filterRecipients({field:"bcc"}),CcAddresses:this._filterRecipients({field:"cc"}),ToAddresses:this._filterRecipients({field:"to"})},Message:{Body:{Html:{Charset:"UTF-8",Data:this.html},Text:{Charset:"UTF-8",Data:this.html}},Subject:{Charset:"UTF-8",Data:this.subject}},Source:this.from},a.prev=2,f=new c(e),a.next=6,global.awsSesClient.send(f);case 6:g=a.sent,d=(0,_isResponse["default"])({apiResponse:g}),a.next=13;break;case 10:a.prev=10,a.t0=a["catch"](2),d=!1;case 13:return a.abrupt("return",d);case 14:case"end":return a.stop();}},a,this,[[2,10]])}));return a}()},{key:"_filterRecipients",value:function _filterRecipients(a){var b=a.field,c=this[b].filter(function(a){return a&&null!==a});return c=c.map(function(a){return a.toLowerCase().trim()}),c=c.filter(function(a){return""!==a}),c=(0,_uniq["default"])(c),c}}]),b}(_BaseClass2["default"]),_default=SimpleEmail;exports["default"]=_default;
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;
@@ -1,4 +1,19 @@
1
- "use strict";var _getConfig=_interopRequireDefault(require("../getConfig"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}global.awsSesClient=null;/**
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
- */var initClient=function(a){var b=a.config;if(!global.awsSesClient){var c=require("@aws-sdk/client-ses"),d=c.SESClient,e=(0,_getConfig["default"])({config:b});global.awsSesClient=new d(e)}},_default=initClient;exports["default"]=_default;
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;
@@ -1,3 +1,40 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}global.awsSsmParameters={};/**
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
- */var getParameter=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h;return _regeneratorRuntime().wrap(function i(b){for(;1;)switch(b.prev=b.next){case 0:if(c=a.name,d=a.withDecryption,e=a.isJson,void 0!==global.awsSsmParameters[c]){b.next=7;break}return f=require("@aws-sdk/client-ssm"),g=f.GetParameterCommand,b.next=5,global.awsSsmClient.send(new g({Name:c,WithDecryption:void 0===d||d}));case 5:h=b.sent,global.awsSsmParameters[c]=h.Parameter.Value?void 0===h.Parameter.Value?null:void 0===e||!0===e?JSON.parse(h.Parameter.Value)||null:h.Parameter.Value:null;case 7:return b.abrupt("return",global.awsSsmParameters[c]);case 8:case"end":return b.stop();}},b)}));return function getParameter(b){return a.apply(this,arguments)}}(),_default=getParameter;exports["default"]=_default;
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;
@@ -1,4 +1,19 @@
1
- "use strict";var _getConfig=_interopRequireDefault(require("../getConfig"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}global.awsSsmClient=null;/**
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
- */var initClient=function(a){var b=a.config;if(!global.awsSsmClient){var c=require("@aws-sdk/client-ssm"),d=c.SSMClient,e=(0,_getConfig["default"])({config:b});global.awsSsmClient=new d(e)}},_default=initClient;exports["default"]=_default;
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
@@ -0,0 +1,8 @@
1
+ export declare type Get = {
2
+ config?: object;
3
+ onError?: Function;
4
+ onSuccess?: Function;
5
+ url: string;
6
+ };
7
+ declare const get: ({ config, onError, onSuccess, url }: Get) => Promise<any>;
8
+ export default get;
package/axios/get.js CHANGED
@@ -1 +1,44 @@
1
- "use strict";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _axios=_interopRequireDefault(require("axios")),_states=_interopRequireDefault(require("../api/states"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 0)})}}var get=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h;return _regeneratorRuntime().wrap(function i(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.config,d=void 0===c?{}:c,e=a.onError,f=a.onSuccess,g=a.url,b.next=3,_axios["default"].get(g,d).then(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:if(200!==a.status){b.next=30;break}if(void 0===a.data.body||void 0===a.data.error||void 0===a.data.state){b.next=22;break}if(_states["default"].SUCCESS!==a.data.state){b.next=13;break}if(!f){b.next=9;break}return b.next=6,f(a.data.body);case 6:b.t0=b.sent,b.next=10;break;case 9:b.t0=a.data.body;case 10:return b.abrupt("return",b.t0);case 13:if(!e){b.next=19;break}return b.next=16,e(a.data.error);case 16:return b.abrupt("return",b.sent);case 19:throw new Error(a.data.error);case 20:b.next=30;break;case 22:if(!f){b.next=28;break}return b.next=25,f(a);case 25:b.t1=b.sent,b.next=29;break;case 28:b.t1=a;case 29:return b.abrupt("return",b.t1);case 30:if(!e){b.next=36;break}return b.next=33,e(a);case 33:b.t2=b.sent,b.next=37;break;case 36:b.t2=a;case 37:return b.abrupt("return",b.t2);case 38:case"end":return b.stop();}},b)}));return function(b){return a.apply(this,arguments)}}())["catch"](/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:if(!e){b.next=6;break}return b.next=3,e(a);case 3:return b.abrupt("return",b.sent);case 6:throw Error;case 7:case"end":return b.stop();}},b)}));return function(b){return a.apply(this,arguments)}}());case 3:return h=b.sent,b.abrupt("return",h);case 5:case"end":return b.stop();}},b)}));return function get(b){return a.apply(this,arguments)}}(),_default=get;exports["default"]=_default;
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;
@@ -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";function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _axios=_interopRequireDefault(require("axios")),_states=_interopRequireDefault(require("../api/states"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _regeneratorRuntime(){"use strict";/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */function a(a,b,c){return Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}),a[b]}function b(a,b,e,f){var g=b&&b.prototype instanceof d?b:d,h=Object.create(g.prototype),j=new l(f||[]);return h._invoke=function(a,b,d){var e="suspendedStart";return function(f,g){if("executing"===e)throw new Error("Generator is already running");if("completed"===e){if("throw"===f)throw g;return n()}for(d.method=f,d.arg=g;;){var h=d.delegate;if(h){var j=i(h,d);if(j){if(j===v)continue;return j}}if("next"===d.method)d.sent=d._sent=d.arg;else if("throw"===d.method){if("suspendedStart"===e)throw e="completed",d.arg;d.dispatchException(d.arg)}else"return"===d.method&&d.abrupt("return",d.arg);e="executing";var k=c(a,b,d);if("normal"===k.type){if(e=d.done?"completed":"suspendedYield",k.arg===v)continue;return{value:k.arg,done:d.done}}"throw"===k.type&&(e="completed",d.method="throw",d.arg=k.arg)}}}(a,e,j),h}function c(a,b,c){try{return{type:"normal",arg:a.call(b,c)}}catch(a){return{type:"throw",arg:a}}}function d(){}function e(){}function f(){}function g(b){["next","throw","return"].forEach(function(c){a(b,c,function(a){return this._invoke(c,a)})})}function h(a,b){function d(e,f,g,h){var i=c(a[e],a,f);if("throw"!==i.type){var j=i.arg,k=j.value;return k&&"object"==_typeof(k)&&q.call(k,"__await")?b.resolve(k.__await).then(function(a){d("next",a,g,h)},function(a){d("throw",a,g,h)}):b.resolve(k).then(function(a){j.value=a,g(j)},function(a){return d("throw",a,g,h)})}h(i.arg)}var e;this._invoke=function(a,c){function f(){return new b(function(b,e){d(a,c,b,e)})}return e=e?e.then(f,f):f()}}function i(a,b){var d=a.iterator[b.method];if(void 0===d){if(b.delegate=null,"throw"===b.method){if(a.iterator["return"]&&(b.method="return",b.arg=void 0,i(a,b),"throw"===b.method))return v;b.method="throw",b.arg=new TypeError("The iterator does not provide a 'throw' method")}return v}var e=c(d,a.iterator,b.arg);if("throw"===e.type)return b.method="throw",b.arg=e.arg,b.delegate=null,v;var f=e.arg;return f?f.done?(b[a.resultName]=f.value,b.next=a.nextLoc,"return"!==b.method&&(b.method="next",b.arg=void 0),b.delegate=null,v):f:(b.method="throw",b.arg=new TypeError("iterator result is not an object"),b.delegate=null,v)}function j(a){var b={tryLoc:a[0]};1 in a&&(b.catchLoc=a[1]),2 in a&&(b.finallyLoc=a[2],b.afterLoc=a[3]),this.tryEntries.push(b)}function k(a){var b=a.completion||{};b.type="normal",delete b.arg,a.completion=b}function l(a){this.tryEntries=[{tryLoc:"root"}],a.forEach(j,this),this.reset(!0)}function m(a){if(a){var b=a[s];if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length)){var c=-1,d=function b(){for(;++c<a.length;)if(q.call(a,c))return b.value=a[c],b.done=!1,b;return b.value=void 0,b.done=!0,b};return d.next=d}}return{next:n}}function n(){return{value:void 0,done:!0}}_regeneratorRuntime=function(){return o};var o={},p=Object.prototype,q=p.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},s=r.iterator||"@@iterator",t=r.asyncIterator||"@@asyncIterator",u=r.toStringTag||"@@toStringTag";try{a({},"")}catch(b){a=function(a,b,c){return a[b]=c}}o.wrap=b;var v={},w={};a(w,s,function(){return this});var x=Object.getPrototypeOf,y=x&&x(x(m([])));y&&y!==p&&q.call(y,s)&&(w=y);var z=f.prototype=d.prototype=Object.create(w);return e.prototype=f,a(z,"constructor",f),a(f,"constructor",e),e.displayName=a(f,u,"GeneratorFunction"),o.isGeneratorFunction=function(a){var b="function"==typeof a&&a.constructor;return!!b&&(b===e||"GeneratorFunction"===(b.displayName||b.name))},o.mark=function(b){return Object.setPrototypeOf?Object.setPrototypeOf(b,f):(b.__proto__=f,a(b,u,"GeneratorFunction")),b.prototype=Object.create(z),b},o.awrap=function(a){return{__await:a}},g(h.prototype),a(h.prototype,t,function(){return this}),o.AsyncIterator=h,o.async=function(a,c,d,e,f){void 0===f&&(f=Promise);var g=new h(b(a,c,d,e),f);return o.isGeneratorFunction(c)?g:g.next().then(function(a){return a.done?a.value:g.next()})},g(z),a(z,u,"Generator"),a(z,s,function(){return this}),a(z,"toString",function(){return"[object Generator]"}),o.keys=function(a){var b=[];for(var c in a)b.push(c);return b.reverse(),function c(){for(;b.length;){var d=b.pop();if(d in a)return c.value=d,c.done=!1,c}return c.done=!0,c}},o.values=m,l.prototype={constructor:l,reset:function reset(a){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!a)for(var b in this)"t"===b.charAt(0)&&q.call(this,b)&&!isNaN(+b.slice(1))&&(this[b]=void 0)},stop:function stop(){this.done=!0;var a=this.tryEntries[0].completion;if("throw"===a.type)throw a.arg;return this.rval},dispatchException:function dispatchException(a){function b(b,d){return f.type="throw",f.arg=a,c.next=b,d&&(c.method="next",c.arg=void 0),!!d}if(this.done)throw a;for(var c=this,d=this.tryEntries.length-1;0<=d;--d){var e=this.tryEntries[d],f=e.completion;if("root"===e.tryLoc)return b("end");if(e.tryLoc<=this.prev){var g=q.call(e,"catchLoc"),h=q.call(e,"finallyLoc");if(g&&h){if(this.prev<e.catchLoc)return b(e.catchLoc,!0);if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(!g){if(!h)throw new Error("try statement without catch or finally");if(this.prev<e.finallyLoc)return b(e.finallyLoc)}else if(this.prev<e.catchLoc)return b(e.catchLoc,!0)}}},abrupt:function abrupt(a,b){for(var c,d=this.tryEntries.length-1;0<=d;--d)if(c=this.tryEntries[d],c.tryLoc<=this.prev&&q.call(c,"finallyLoc")&&this.prev<c.finallyLoc){var e=c;break}e&&("break"===a||"continue"===a)&&e.tryLoc<=b&&b<=e.finallyLoc&&(e=null);var f=e?e.completion:{};return f.type=a,f.arg=b,e?(this.method="next",this.next=e.finallyLoc,v):this.complete(f)},complete:function complete(a,b){if("throw"===a.type)throw a.arg;return"break"===a.type||"continue"===a.type?this.next=a.arg:"return"===a.type?(this.rval=this.arg=a.arg,this.method="return",this.next="end"):"normal"===a.type&&b&&(this.next=b),v},finish:function finish(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.finallyLoc===a)return this.complete(b.completion,b.afterLoc),k(b),v},catch:function _catch(a){for(var b,c=this.tryEntries.length-1;0<=c;--c)if(b=this.tryEntries[c],b.tryLoc===a){var d=b.completion;if("throw"===d.type){var e=d.arg;k(b)}return e}throw new Error("illegal catch attempt")},delegateYield:function delegateYield(a,b,c){return this.delegate={iterator:m(a),resultName:b,nextLoc:c},"next"===this.method&&(this.arg=void 0),v}},o}function asyncGeneratorStep(a,b,c,d,e,f,g){try{var h=a[f](g),i=h.value}catch(a){return void c(a)}h.done?b(i):Promise.resolve(i).then(d,e)}function _asyncToGenerator(a){return function(){var b=this,c=arguments;return new Promise(function(d,e){function f(a){asyncGeneratorStep(h,d,e,f,g,"next",a)}function g(a){asyncGeneratorStep(h,d,e,f,g,"throw",a)}var h=a.apply(b,c);f(void 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
+ const axios_1 = __importDefault(require("axios"));
7
+ const states_1 = __importDefault(require("../api/states"));
8
+ /**
2
9
  * Make a POST request.
3
- */var post=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j;return _regeneratorRuntime().wrap(function k(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.config,d=void 0===c?{}:c,e=a.data,f=void 0===e?{}:e,g=a.onError,h=a.onSuccess,i=a.url,b.next=3,_axios["default"].post(i,f,d).then(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:if(200!==a.status){b.next=30;break}if(void 0===a.data.body||void 0===a.data.error||void 0===a.data.state){b.next=22;break}if(_states["default"].SUCCESS!==a.data.state){b.next=13;break}if(!h){b.next=9;break}return b.next=6,h(a.data.body);case 6:b.t0=b.sent,b.next=10;break;case 9:b.t0=a.data.body;case 10:return b.abrupt("return",b.t0);case 13:if(!g){b.next=19;break}return b.next=16,g(a.data.error);case 16:return b.abrupt("return",b.sent);case 19:throw new Error(a.data.error);case 20:b.next=30;break;case 22:if(!h){b.next=28;break}return b.next=25,h(a);case 25:b.t1=b.sent,b.next=29;break;case 28:b.t1=a;case 29:return b.abrupt("return",b.t1);case 30:if(!g){b.next=36;break}return b.next=33,g(a);case 33:b.t2=b.sent,b.next=37;break;case 36:b.t2=a;case 37:return b.abrupt("return",b.t2);case 38:case"end":return b.stop();}},b)}));return function(b){return a.apply(this,arguments)}}())["catch"](/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){return _regeneratorRuntime().wrap(function c(b){for(;1;)switch(b.prev=b.next){case 0:if(!g){b.next=6;break}return b.next=3,g(a);case 3:return b.abrupt("return",b.sent);case 6:throw Error;case 7:case"end":return b.stop();}},b)}));return function(b){return a.apply(this,arguments)}}());case 3:return j=b.sent,b.abrupt("return",j);case 5:case"end":return b.stop();}},b)}));return function post(b){return a.apply(this,arguments)}}(),_default=post;exports["default"]=_default;
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;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Convert an input from a variety of forms into boolean.
3
+ */
4
+ declare const getBoolean: ({ input }: {
5
+ input: any;
6
+ }) => boolean;
7
+ export default getBoolean;
@@ -1,3 +1,16 @@
1
- "use strict";var _isBoolean=_interopRequireDefault(require("lodash/isBoolean"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}/**
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
- */var getBoolean=function(a){var b=a.input;return(0,_isBoolean["default"])(b)?b:"true"===b||1===b||"1"===b||"yes"===b||"y"===b},_default=getBoolean;exports["default"]=_default;
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;
@@ -1,9 +1,50 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;var _isArray=_interopRequireDefault(require("lodash/isArray")),_set=_interopRequireDefault(require("lodash/set")),_defaultTo=_interopRequireDefault(require("../util/defaultTo"));function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}function _classCallCheck(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,c.key,c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}var BaseClass=/*#__PURE__*/function(){function a(){_classCallCheck(this,a)}return _createClass(a,[{key:"_setArray",value:/**
2
- * Shortcut to set a value to an array and return the instance.
3
- */function _setArray(a){var b=a.input,c=a.fields;return(0,_isArray["default"])(b)?(0,_set["default"])(this,c,b):(0,_set["default"])(this,c,[b]),this}/**
4
- * Shortcut to set a value and return the instance.
5
- */},{key:"_setValue",value:function _setValue(a){var b=a.input,c=a.fields;return(0,_set["default"])(this,c,b),this}/**
6
- * Shortcut to add a value to an existing array.
7
- */},{key:"_push",value:function _push(a){var b=a.input,c=a.fields,d=this._get({defaultValue:[],fields:c});return d=(0,_isArray["default"])(b)?d.concat(b):d.push(b),(0,_set["default"])(this,c,d),this}/**
8
- * Shortcut to get a value, but default if the fields don't exist.
9
- */},{key:"_get",value:function _get(a){var b=a.defaultValue,c=a.fields;return(0,_defaultTo["default"])({defaultValue:b,instance:this,keys:c})}}]),a}(),_default=BaseClass;exports["default"]=_default;
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;
@@ -0,0 +1,8 @@
1
+ export declare const actions: {
2
+ CREATE: string;
3
+ READ: string;
4
+ UPDATE: string;
5
+ DELETE: string;
6
+ };
7
+ export declare type Action = typeof actions.CREATE | typeof actions.READ | typeof actions.UPDATE | typeof actions.DELETE;
8
+ export default actions;
package/crud/actions.js CHANGED
@@ -1 +1,10 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=exports.actions=void 0;var actions={CREATE:"create",READ:"read",UPDATE:"update",DELETE:"delete"};exports.actions=actions;var _default=actions;exports["default"]=_default;
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;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Decrypt an encoding string using a salt
3
+ * Library: crypto-js
4
+ */
5
+ declare const getDecrypt: ({ appSalt, input, salt }: {
6
+ appSalt: string;
7
+ input: string;
8
+ salt: string;
9
+ }) => string;
10
+ export default getDecrypt;
@@ -1,4 +1,13 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;/**
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
- */var getDecrypt=function(a){var b=a.appSalt,c=a.input,d=a.salt,e=require("crypto-js"),f=e.AES,g=e.enc,h="".concat(b,"-").concat(d);return f.decrypt(c,h).toString(g.Utf8)},_default=getDecrypt;exports["default"]=_default;
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;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Encrypt an encoding string using a salt
3
+ * Library: crypto-js
4
+ */
5
+ declare const getEncrypt: ({ appSalt, input, salt }: {
6
+ appSalt: string;
7
+ input: string;
8
+ salt: string;
9
+ }) => string;
10
+ export default getEncrypt;