@8ms/helpers 1.1.73 → 1.1.77

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 +99 -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,13 @@
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)})}}/**
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
2
4
  * Delete a single file.
3
- */var deleteFile=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.bucket,d=a.key,e=require("@aws-sdk/client-s3"),f=e.DeleteObjectCommand,b.next=4,global.awsS3Client.send(new f({Bucket:c,Key:d}));case 4:case"end":return b.stop();}},b)}));return function deleteFile(b){return a.apply(this,arguments)}}(),_default=deleteFile;exports["default"]=_default;
5
+ */
6
+ const deleteFile = async ({ bucket, key }) => {
7
+ const { DeleteObjectCommand } = require('@aws-sdk/client-s3');
8
+ await global.awsS3Client.send(new DeleteObjectCommand({
9
+ Bucket: bucket,
10
+ Key: key,
11
+ }));
12
+ };
13
+ exports.default = deleteFile;
@@ -0,0 +1,9 @@
1
+ declare type DeleteFiles = {
2
+ bucket: string;
3
+ keys: string[];
4
+ };
5
+ /**
6
+ * Delete multiple files.
7
+ */
8
+ declare const deleteFiles: ({ bucket, keys }: DeleteFiles) => Promise<void>;
9
+ export default deleteFiles;
@@ -1,3 +1,17 @@
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)})}}/**
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
2
4
  * Delete multiple files.
3
- */var deleteFiles=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f;return _regeneratorRuntime().wrap(function g(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.bucket,d=a.keys,e=require("@aws-sdk/client-s3"),f=e.DeleteObjectsCommand,b.next=4,global.awsS3Client.send(new f({Bucket:c,Delete:{Objects:d.map(function(a){return{Key:a}})}}));case 4:case"end":return b.stop();}},b)}));return function deleteFiles(b){return a.apply(this,arguments)}}(),_default=deleteFiles;exports["default"]=_default;
5
+ */
6
+ const deleteFiles = async ({ bucket, keys }) => {
7
+ const { DeleteObjectsCommand } = require('@aws-sdk/client-s3');
8
+ await global.awsS3Client.send(new DeleteObjectsCommand({
9
+ Bucket: bucket,
10
+ Delete: {
11
+ Objects: keys.map(key => ({
12
+ Key: key,
13
+ })),
14
+ },
15
+ }));
16
+ };
17
+ exports.default = deleteFiles;
@@ -0,0 +1,9 @@
1
+ declare type DeleteFolder = {
2
+ bucket: string;
3
+ folder: string;
4
+ };
5
+ /**
6
+ * Iteratively delete all the files within a directory and delete the directory.
7
+ */
8
+ declare const deleteFolder: ({ bucket, folder }: DeleteFolder) => Promise<void>;
9
+ export default deleteFolder;
@@ -1,3 +1,36 @@
1
- "use strict";var _getCleanFolder=_interopRequireDefault(require("../../string/getCleanFolder"));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 _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 getCleanFolder_1 = __importDefault(require("../../string/getCleanFolder"));
7
+ /**
2
8
  * Iteratively delete all the files within a directory and delete the directory.
3
- */var deleteFolder=/*#__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.bucket,d=a.folder,e=(0,_getCleanFolder["default"])({input:d}),f=require("@aws-sdk/client-s3"),g=f.ListObjectsV2Command,h=f.DeleteObjectsCommand,b.next=5,global.awsS3Client.send(new g({Bucket:c,Prefix:""===e?"":e+"/"}));case 5:if(i=b.sent,0!==i.Contents.length){b.next=8;break}return b.abrupt("return");case 8:return j=i.Contents.map(function(a){return{Key:a.Key}}),b.next=11,global.awsS3Client.send(new h({Bucket:c,Delete:{Objects:j}}));case 11:if(!i.IsTruncated){b.next=14;break}return b.next=14,deleteFolder({bucket:c,folder:d});case 14:case"end":return b.stop();}},b)}));return function deleteFolder(b){return a.apply(this,arguments)}}(),_default=deleteFolder;exports["default"]=_default;
9
+ */
10
+ const deleteFolder = async ({ bucket, folder }) => {
11
+ const cleanFolder = (0, getCleanFolder_1.default)({ input: folder });
12
+ const { ListObjectsV2Command, DeleteObjectsCommand } = require('@aws-sdk/client-s3');
13
+ // Get a list of all files to be deleted
14
+ const apiResponse = await global.awsS3Client.send(new ListObjectsV2Command({
15
+ Bucket: bucket,
16
+ Prefix: ('' === cleanFolder ? '' : cleanFolder + '/'),
17
+ }));
18
+ // No files to be deleted
19
+ if (apiResponse.Contents.length === 0) {
20
+ return;
21
+ }
22
+ // Map each of the files
23
+ const keys = apiResponse.Contents.map(file => ({ Key: file.Key }));
24
+ // Delete the files
25
+ await global.awsS3Client.send(new DeleteObjectsCommand({
26
+ Bucket: bucket,
27
+ Delete: {
28
+ Objects: keys,
29
+ },
30
+ }));
31
+ // If we didn't get all files, run it again
32
+ if (apiResponse.IsTruncated) {
33
+ await deleteFolder({ bucket, folder });
34
+ }
35
+ };
36
+ exports.default = deleteFolder;
@@ -0,0 +1,5 @@
1
+ declare type GetGlueJson = {
2
+ data: any;
3
+ };
4
+ declare const getGlueJson: ({ data }: GetGlueJson) => string;
5
+ export default getGlueJson;
@@ -1,2 +1,15 @@
1
- "use strict";var _getArray=_interopRequireDefault(require("../../array/getArray"));Object.defineProperty(exports,"__esModule",{value:!0}),exports["default"]=void 0;function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}var getGlueJson=function(a){var b=a.data,c=(0,_getArray["default"])({input:b}),d=c.map(function(a){return JSON.stringify(a)});// Combine each row with a line separator
2
- return d.join("\n")},_default=getGlueJson;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 getArray_1 = __importDefault(require("../../array/getArray"));
7
+ const getGlueJson = ({ data }) => {
8
+ // Must be an array
9
+ const inputArray = (0, getArray_1.default)({ input: data });
10
+ // For each array row convert the row
11
+ const stringRows = inputArray.map(row => JSON.stringify(row));
12
+ // Combine each row with a line separator
13
+ return stringRows.join("\n");
14
+ };
15
+ exports.default = getGlueJson;
@@ -0,0 +1,20 @@
1
+ declare type PresignedPost = {
2
+ url: string;
3
+ fields: any;
4
+ };
5
+ declare type GetPresignedPost = {
6
+ bucket: string;
7
+ conditions: any[];
8
+ expires: number;
9
+ fields: {
10
+ [key: string]: string;
11
+ };
12
+ key: string;
13
+ };
14
+ /**
15
+ * Returns a presigned post to upload a file directly to S3.
16
+ * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_s3_presigned_post.html
17
+ * https://github.com/8millionstories-organisation/test-vercel-upload-2/blob/50eb12fcb3870a59ab455811bfaa1bdcb886edf2/pages/api/upload-url.js
18
+ */
19
+ declare const getPresignedPost: ({ bucket, conditions, expires, fields, key }: GetPresignedPost) => Promise<PresignedPost>;
20
+ export default getPresignedPost;
@@ -1,6 +1,19 @@
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)})}}/**
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
2
4
  * Returns a presigned post to upload a file directly to S3.
3
5
  * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_s3_presigned_post.html
4
6
  * https://github.com/8millionstories-organisation/test-vercel-upload-2/blob/50eb12fcb3870a59ab455811bfaa1bdcb886edf2/pages/api/upload-url.js
5
- */var getPresignedPost=/*#__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.bucket,d=a.conditions,e=a.expires,f=a.fields,g=a.key,h=require("@aws-sdk/client-s3"),i=h.createPresignedPost,b.next=4,i(global.awsS3Client,{Bucket:c,Key:g,Conditions:void 0===d?[]:d,Fields:void 0===f?{}:f,Expires:void 0===e?60:e// Seconds
6
- });case 4:return j=b.sent,b.abrupt("return",j);case 6:case"end":return b.stop();}},b)}));return function getPresignedPost(b){return a.apply(this,arguments)}}(),_default=getPresignedPost;exports["default"]=_default;
7
+ */
8
+ const getPresignedPost = async ({ bucket, conditions, expires, fields, key }) => {
9
+ const { createPresignedPost } = require('@aws-sdk/client-s3');
10
+ const apiResponse = await createPresignedPost(global.awsS3Client, {
11
+ Bucket: bucket,
12
+ Key: key,
13
+ Conditions: undefined === conditions ? [] : conditions,
14
+ Fields: undefined === fields ? {} : fields,
15
+ Expires: undefined === expires ? 60 : expires, // Seconds
16
+ });
17
+ return apiResponse;
18
+ };
19
+ exports.default = getPresignedPost;
@@ -0,0 +1,12 @@
1
+ import { Response } from '../../api/response';
2
+ declare type GetSignedUrl = {
3
+ bucket: string;
4
+ expires: number;
5
+ key: string;
6
+ };
7
+ /**
8
+ * Returns a signed for URL to allow download of private buckets for a given duration.
9
+ * Library: @aws-sdk/s3-request-presigner
10
+ */
11
+ declare const getSignedUrl: ({ bucket, expires, key }: GetSignedUrl) => Promise<Response>;
12
+ export default getSignedUrl;
@@ -1,4 +1,17 @@
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)})}}/**
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /**
2
4
  * Returns a signed for URL to allow download of private buckets for a given duration.
3
5
  * Library: @aws-sdk/s3-request-presigner
4
- */var getSignedUrl=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k;return _regeneratorRuntime().wrap(function l(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.bucket,d=a.expires,e=a.key,f=require("@aws-sdk/client-s3"),g=f.GetObjectCommand,h=require("@aws-sdk/s3-request-presigner"),i=h.getSignedUrl,j=new g({Bucket:c,Key:e}),b.next=6,i(global.awsS3Client,j,{expiresIn:d});case 6:return k=b.sent,b.abrupt("return",k);case 8:case"end":return b.stop();}},b)}));return function getSignedUrl(b){return a.apply(this,arguments)}}(),_default=getSignedUrl;exports["default"]=_default;
6
+ */
7
+ const getSignedUrl = async ({ bucket, expires, key }) => {
8
+ const { GetObjectCommand } = require('@aws-sdk/client-s3');
9
+ const { getSignedUrl } = require('@aws-sdk/s3-request-presigner');
10
+ const command = new GetObjectCommand({
11
+ Bucket: bucket,
12
+ Key: key,
13
+ });
14
+ const response = await getSignedUrl(global.awsS3Client, command, { expiresIn: expires });
15
+ return response;
16
+ };
17
+ exports.default = getSignedUrl;
@@ -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-s3
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.awsS3Client=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.awsS3Client = null;
8
+ /**
2
9
  * Shorthand function to get the Lambda Client.
3
10
  * Library: @aws-sdk/client-s3
4
- */var initClient=function(a){var b=a.config;if(!global.awsS3Client){var c=require("@aws-sdk/client-s3"),d=c.S3Client,e=(0,_getConfig["default"])({config:b});global.awsS3Client=new d(e)}},_default=initClient;exports["default"]=_default;
11
+ */
12
+ const initClient = ({ config }) => {
13
+ if (!global.awsS3Client) {
14
+ const { S3Client } = require('@aws-sdk/client-s3');
15
+ const formattedConfig = (0, getConfig_1.default)({ config });
16
+ global.awsS3Client = new S3Client(formattedConfig);
17
+ }
18
+ };
19
+ exports.default = initClient;
@@ -0,0 +1,9 @@
1
+ declare type IsFileExists = {
2
+ bucket: string;
3
+ key: string;
4
+ };
5
+ /**
6
+ * Check to see if a file exists but don't get the contents.
7
+ */
8
+ declare const isFileExists: ({ bucket, key }: IsFileExists) => Promise<boolean>;
9
+ export default isFileExists;
@@ -1,3 +1,27 @@
1
- "use strict";var _isResponse=_interopRequireDefault(require("../isResponse200"));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 _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 isResponse200_1 = __importDefault(require("../isResponse200"));
7
+ /**
2
8
  * Check to see if a file exists but don't get the contents.
3
- */var isFileExists=/*#__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.bucket,d=a.key,e=!1,b.prev=2,f=require("@aws-sdk/client-s3"),g=f.HeadObjectCommand,b.next=6,global.awsS3Client.send(new g({Bucket:c,Key:d}));case 6:h=b.sent,e=(0,_isResponse["default"])({apiResponse:h}),b.next=13;break;case 10:b.prev=10,b.t0=b["catch"](2),e=!1;case 13:return b.abrupt("return",e);case 14:case"end":return b.stop();}},b,null,[[2,10]])}));return function isFileExists(b){return a.apply(this,arguments)}}(),_default=isFileExists;exports["default"]=_default;
9
+ */
10
+ const isFileExists = async ({ bucket, key }) => {
11
+ let response = false;
12
+ try {
13
+ const { HeadObjectCommand } = require('@aws-sdk/client-s3');
14
+ // Fetch from S3
15
+ const apiResponse = await global.awsS3Client.send(new HeadObjectCommand({
16
+ Bucket: bucket,
17
+ Key: key,
18
+ }));
19
+ // If the status is 200 then it does exist
20
+ response = (0, isResponse200_1.default)({ apiResponse });
21
+ }
22
+ catch (exception) {
23
+ response = false;
24
+ }
25
+ return response;
26
+ };
27
+ exports.default = isFileExists;
@@ -0,0 +1,9 @@
1
+ declare type ListFiles = {
2
+ bucket: string;
3
+ folder: string;
4
+ };
5
+ /**
6
+ * List the files in the given bucket and option folder
7
+ */
8
+ declare const listFiles: ({ bucket, folder }: ListFiles) => Promise<string[]>;
9
+ export default listFiles;
@@ -1,3 +1,33 @@
1
- "use strict";var _getCleanFolder=_interopRequireDefault(require("../../string/getCleanFolder"));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 _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 getCleanFolder_1 = __importDefault(require("../../string/getCleanFolder"));
7
+ /**
2
8
  * List the files in the given bucket and option folder
3
- */var listFiles=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i,j,k;return _regeneratorRuntime().wrap(function l(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.bucket,d=a.folder,e=void 0===d?"":d,f=(0,_getCleanFolder["default"])({input:e}),g=[],h=[],i=require("@aws-sdk/client-s3"),j=i.ListObjectsV2Command,b.next=7,global.awsS3Client.send(new j({Bucket:c,Delimiter:"/",Prefix:""===f?"":f+"/"}));case 7:return k=b.sent,void 0!==k.Contents&&(h=k.Contents.filter(function(a){var b=a.Key.split("/");return-1<b[b.length-1].indexOf(".")}),h.length&&(g=h.map(function(a){return a.Key}))),b.abrupt("return",g);case 10:case"end":return b.stop();}},b)}));return function listFiles(b){return a.apply(this,arguments)}}(),_default=listFiles;exports["default"]=_default;
9
+ */
10
+ const listFiles = async ({ bucket, folder = '' }) => {
11
+ const cleanFolder = (0, getCleanFolder_1.default)({ input: folder });
12
+ let response = [];
13
+ let valid = [];
14
+ const { ListObjectsV2Command } = require('@aws-sdk/client-s3');
15
+ const apiResponse = await global.awsS3Client.send(new ListObjectsV2Command({
16
+ Bucket: bucket,
17
+ Delimiter: '/',
18
+ Prefix: ('' === cleanFolder ? '' : cleanFolder + '/'),
19
+ }));
20
+ // Ensure the data exists
21
+ if (undefined !== apiResponse['Contents']) {
22
+ // Return an array of files
23
+ valid = apiResponse['Contents'].filter(content => {
24
+ const keyExploded = content['Key'].split('/');
25
+ return keyExploded[keyExploded.length - 1].indexOf('.') > -1;
26
+ });
27
+ if (valid.length) {
28
+ response = valid.map(entry => entry['Key']);
29
+ }
30
+ }
31
+ return response;
32
+ };
33
+ exports.default = listFiles;
@@ -0,0 +1,9 @@
1
+ declare type ListFolders = {
2
+ bucket: string;
3
+ folder: string;
4
+ };
5
+ /**
6
+ * List the files in the given bucket and option folder.
7
+ */
8
+ declare const listFolders: ({ bucket, folder }: ListFolders) => Promise<string[]>;
9
+ export default listFolders;
@@ -1,5 +1,32 @@
1
- "use strict";var _getCleanFolder=_interopRequireDefault(require("../../string/getCleanFolder"));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 _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 getCleanFolder_1 = __importDefault(require("../../string/getCleanFolder"));
7
+ /**
2
8
  * List the files in the given bucket and option folder.
3
- */var listFolders=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d,e,f,g,h,i;return _regeneratorRuntime().wrap(function j(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.bucket,d=a.folder,e=(0,_getCleanFolder["default"])({input:d}),f=[],g=require("@aws-sdk/client-s3"),h=g.ListObjectsV2Command,b.next=6,global.awsS3Client.send(new h({Bucket:c,Delimiter:"/",Prefix:""===e?"":e+"/"}));case 6:return i=b.sent,void 0!==i.CommonPrefixes&&(f=i.CommonPrefixes.map(function(a){// Remove the trailing slash then split by slash
4
- var b=a.Prefix.slice(0,-1).split("/");// Return the last folder without a trailing slash
5
- return b[b.length-1]})),b.abrupt("return",f);case 9:case"end":return b.stop();}},b)}));return function listFolders(b){return a.apply(this,arguments)}}(),_default=listFolders;exports["default"]=_default;
9
+ */
10
+ const listFolders = async ({ bucket, folder }) => {
11
+ const cleanFolder = (0, getCleanFolder_1.default)({ input: folder });
12
+ let response = [];
13
+ const { ListObjectsV2Command } = require('@aws-sdk/client-s3');
14
+ const apiResponse = await global.awsS3Client.send(new ListObjectsV2Command({
15
+ Bucket: bucket,
16
+ Delimiter: '/',
17
+ Prefix: ('' === cleanFolder ? '' : cleanFolder + '/'),
18
+ }));
19
+ // Ensure the data exists
20
+ if (undefined !== apiResponse['CommonPrefixes']) {
21
+ // Return an array of folders removing the trailing folder
22
+ response = apiResponse['CommonPrefixes'].map(prefix => {
23
+ // Remove the trailing slash then split by slash
24
+ const fileFolders = prefix.Prefix.slice(0, -1)
25
+ .split('/');
26
+ // Return the last folder without a trailing slash
27
+ return fileFolders[fileFolders.length - 1];
28
+ });
29
+ }
30
+ return response;
31
+ };
32
+ exports.default = listFolders;
@@ -0,0 +1,10 @@
1
+ import { File } from './copyFile';
2
+ declare type MoveFiles = {
3
+ from: File;
4
+ to: File;
5
+ };
6
+ /**
7
+ * It's not possible to just move or rename a file, you must copy then delete the old file.
8
+ */
9
+ declare const moveFile: ({ from, to }: MoveFiles) => Promise<void>;
10
+ export default moveFile;
@@ -1,3 +1,21 @@
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 _copyFile=_interopRequireDefault(require("./copyFile")),_deleteFile=_interopRequireDefault(require("./deleteFile"));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 copyFile_1 = __importDefault(require("./copyFile"));
7
+ const deleteFile_1 = __importDefault(require("./deleteFile"));
8
+ /**
2
9
  * It's not possible to just move or rename a file, you must copy then delete the old file.
3
- */var moveFile=/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function b(a){var c,d;return _regeneratorRuntime().wrap(function e(b){for(;1;)switch(b.prev=b.next){case 0:return c=a.from,d=a.to,b.next=3,(0,_copyFile["default"])({from:c,to:d});case 3:return b.next=5,(0,_deleteFile["default"])({bucket:c.bucket,key:c.key});case 5:case"end":return b.stop();}},b)}));return function moveFile(b){return a.apply(this,arguments)}}(),_default=moveFile;exports["default"]=_default;
10
+ */
11
+ const moveFile = async ({ from, to }) => {
12
+ await (0, copyFile_1.default)({
13
+ from,
14
+ to,
15
+ });
16
+ await (0, deleteFile_1.default)({
17
+ bucket: from.bucket,
18
+ key: from.key,
19
+ });
20
+ };
21
+ exports.default = moveFile;
@@ -0,0 +1,13 @@
1
+ import { Modified } from './readFile';
2
+ export declare type ReadBufferResponse = Modified & {
3
+ buffer: any;
4
+ };
5
+ declare type ReadBuffer = {
6
+ bucket: string;
7
+ key: string;
8
+ };
9
+ /**
10
+ * Similar function to reading the S3 file, but instead of a text file return a buffer.
11
+ */
12
+ declare const readBuffer: ({ bucket, key }: ReadBuffer) => Promise<ReadBufferResponse>;
13
+ export default readBuffer;