@8ms/helpers 1.1.67 → 1.1.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/response.js +1 -12
- package/api/states.js +1 -10
- package/api/unexpectedError.js +1 -4
- package/array/contains.js +2 -9
- package/array/getArray.js +2 -13
- package/atInternet/request.js +1 -2
- package/aws/athenaExpress/initClient.js +3 -28
- package/aws/athenaExpress/query.js +3 -0
- package/aws/getConfig.js +2 -27
- package/aws/glue/initClient.js +2 -18
- package/aws/glue/invoke.js +2 -73
- package/aws/isResponse200.js +2 -22
- package/aws/lambda/getHandlerPath.js +1 -8
- package/aws/lambda/initClient.js +2 -18
- package/aws/lambda/invoke.js +2 -87
- package/aws/s3/copyFile.js +2 -61
- package/aws/s3/deleteFile.js +2 -60
- package/aws/s3/deleteFiles.js +2 -64
- package/aws/s3/deleteFolder.js +2 -85
- package/aws/s3/getGlueJson.js +2 -16
- package/aws/s3/getPresignedPost.js +3 -63
- package/aws/s3/getSignedUrl.js +2 -83
- package/aws/s3/initClient.js +2 -18
- package/aws/s3/isFileExists.js +2 -75
- package/aws/s3/listFiles.js +2 -79
- package/aws/s3/listFolders.js +4 -78
- package/aws/s3/moveFile.js +2 -68
- package/aws/s3/readBuffer.js +2 -99
- package/aws/s3/readFile.js +2 -120
- package/aws/s3/writeFile.js +2 -77
- package/aws/s3/writePresignedPost.js +2 -101
- package/aws/s3cache/cache.js +1 -2
- package/aws/s3cache/getCache.js +2 -79
- package/aws/s3cache/getKey.js +2 -17
- package/aws/s3cache/saveCache.js +2 -58
- package/aws/s3cache/updateCache.js +2 -75
- package/aws/ses/SimpleEmail.js +2 -219
- package/aws/ses/initClient.js +2 -18
- package/aws/ssm/getParameter.js +2 -86
- package/aws/ssm/initClient.js +2 -18
- package/axios/get.js +1 -115
- package/axios/post.js +2 -117
- package/boolean/getBoolean.js +2 -16
- package/class/BaseClass.js +9 -57
- package/crud/actions.js +1 -10
- package/crypto/getDecrypt.js +2 -12
- package/crypto/getEncrypt.js +2 -12
- package/crypto/getRandom.js +2 -11
- package/crypto/getSha256.js +2 -16
- package/date/date.js +1 -2
- package/date/duration.js +1 -2
- package/date/durationComparisons.js +1 -7
- package/date/durations.js +1 -10
- package/date/financialYear.js +1 -2
- package/date/financialYearWeek.js +1 -2
- package/date/format.js +2 -19
- package/date/getDate.js +9 -97
- package/date/getDatesBetween.js +3 -26
- package/date/getDurationHours.js +2 -26
- package/date/getDurationMinutes.js +2 -25
- package/date/getFinancialYear.js +8 -49
- package/date/getFinancialYearToDate.js +2 -18
- package/date/getFinancialYearToYesterday.js +2 -18
- package/date/getFinancialYearWeeks.js +2 -30
- package/date/getLastWeek.js +2 -29
- package/date/getMax.js +2 -16
- package/date/getMidnight.js +2 -13
- package/date/getMin.js +2 -16
- package/date/getMonday.js +5 -33
- package/date/getNumber.js +2 -15
- package/date/getPredefinedTimeframe.js +2 -24
- package/date/getSunday.js +5 -33
- package/date/getThisWeek.js +2 -29
- package/date/getTimeZoned.js +5 -37
- package/date/getToday.js +2 -40
- package/date/getTwoWeeksAgo.js +2 -29
- package/date/getWeeksAgo.js +2 -17
- package/date/getYesterday.js +2 -41
- package/date/isDateValid.js +2 -23
- package/date/isLastWeek.js +2 -14
- package/date/isThisWeek.js +2 -14
- package/date/parseExcelDate.js +2 -18
- package/date/predefinedTimeframes.js +1 -9
- package/date/timeframe.js +1 -2
- package/date/timeframes.js +1 -7
- package/deepCrawl/buildRequest.js +4 -84
- package/deepCrawl/filter.js +1 -2
- package/deepCrawl/getData.js +1 -87
- package/deepCrawl/initClient.js +2 -78
- package/deepCrawl/operands.js +1 -13
- package/deepCrawl/orders.js +1 -7
- package/deepCrawl/reports.js +1 -13
- package/environment/environments.js +1 -8
- package/environment/getEnvironment.js +2 -42
- package/environment/isAws.js +2 -10
- package/environment/isDevelopment.js +1 -9
- package/environment/isLocalhost.js +2 -21
- package/environment/isProduction.js +1 -9
- package/environment/isStaging.js +1 -9
- package/environment/isVercel.js +2 -6
- package/environment/platforms.js +1 -7
- package/eskimi/ageGroups.js +1 -41
- package/eskimi/campaign.js +1 -2
- package/eskimi/devices.js +1 -13
- package/eskimi/endpoints.js +2 -17
- package/eskimi/genders.js +1 -13
- package/eskimi/getAccessToken.js +2 -68
- package/eskimi/getAgeGroup.js +2 -17
- package/eskimi/getCampaignIds.js +2 -12
- package/eskimi/getDevice.js +2 -17
- package/eskimi/getGender.js +2 -17
- package/eskimi/request.js +2 -69
- package/globals.d.js +1 -0
- package/google/bigQuery/initClient.js +4 -0
- package/google/bigQuery/query.js +3 -0
- package/google/getConfig.js +5 -0
- package/google/sheets/getAssociatedData.js +8 -99
- package/google/sheets/getBatchData.js +1 -64
- package/google/sheets/initClient.js +5 -0
- package/google/sheets/isCellNa.js +2 -9
- package/google/storage/initClient.js +5 -0
- package/google/storage/writeFile.js +2 -87
- package/googleAds/getCustomer.js +2 -55
- package/googleAds/initClient.js +2 -67
- package/initClients.js +5 -112
- package/json/isJson.js +2 -19
- package/littleWarden/getUrlStatus.js +2 -66
- package/littleWarden/isAllGood.js +2 -18
- package/littleWarden/isDanger.js +2 -18
- package/littleWarden/isWarning.js +2 -18
- package/littleWarden/states.js +1 -8
- package/myTarget/getAccessToken.js +2 -68
- package/myTarget/request.js +2 -69
- package/nextAuth/isSessionReady.js +1 -13
- package/nextAuth/states.js +2 -8
- package/nextJs/getIp.js +2 -13
- package/nextJs/getUserAgent.js +2 -9
- package/number/getDivide.js +2 -18
- package/number/getNumber.js +7 -51
- package/number/getPercent.js +2 -18
- package/number/getPercentIncrease.js +2 -18
- package/number/getRounded.js +2 -22
- package/package.json +47 -43
- package/prisma/initClient.js +3 -34
- package/snapchat/getAccessToken.js +2 -83
- package/sorting/byNumberAscending.js +2 -17
- package/sorting/byNumberDescending.js +2 -17
- package/sorting/byStringAscending.js +2 -21
- package/sorting/byStringDescending.js +2 -21
- package/string/formatCapitalise.js +2 -15
- package/string/getCleanFolder.js +2 -14
- package/string/getString.js +2 -36
- package/string/getStringFromStream.js +2 -15
- package/string/toProperCase.js +2 -18
- package/swr/isAllData.js +2 -19
- package/swr/isAnyError.js +2 -19
- package/swr/isAnyLoading.js +2 -21
- package/swr/isData.js +2 -9
- package/swr/isError.js +2 -9
- package/swr/isLoading.js +2 -14
- package/upTimeRobot/getMonitors.js +2 -87
- package/upTimeRobot/logTypes.js +1 -9
- package/upTimeRobot/monitorStatuses.js +1 -10
- package/upTimeRobot/monitorSubTypes.js +1 -12
- package/upTimeRobot/monitorTypes.js +1 -10
- package/upTimeRobot/requestStatuses.js +1 -7
- package/url/buildParameters.js +2 -22
- package/url/buildRelative.js +2 -13
- package/url/buildUrl.js +2 -29
- package/url/isAbsolute.js +2 -15
- package/url/isRelative.js +2 -10
- package/url/url.js +1 -2
- package/util/defaultTo.js +2 -35
- package/util/isUndefined.js +3 -0
- package/util/sleep.js +1 -7
- package/webWorker/states.js +1 -8
- package/xml/getXml.js +1 -62
- package/api/response.d.ts +0 -8
- package/api/states.d.ts +0 -9
- package/api/unexpectedError.d.ts +0 -2
- package/array/contains.d.ts +0 -8
- package/array/getArray.d.ts +0 -7
- package/atInternet/request.d.ts +0 -30
- package/aws/athenaExpress/initClient.d.ts +0 -12
- package/aws/athenaExpress/request.d.ts +0 -8
- package/aws/athenaExpress/request.js +0 -54
- package/aws/config.d.ts +0 -5
- package/aws/config.js +0 -2
- package/aws/getConfig.d.ts +0 -9
- package/aws/glue/initClient.d.ts +0 -9
- package/aws/glue/invoke.d.ts +0 -11
- package/aws/isResponse200.d.ts +0 -7
- package/aws/lambda/getHandlerPath.d.ts +0 -4
- package/aws/lambda/initClient.d.ts +0 -9
- package/aws/lambda/invoke.d.ts +0 -14
- package/aws/s3/copyFile.d.ts +0 -13
- package/aws/s3/deleteFile.d.ts +0 -9
- package/aws/s3/deleteFiles.d.ts +0 -10
- package/aws/s3/deleteFolder.d.ts +0 -10
- package/aws/s3/getGlueJson.d.ts +0 -4
- package/aws/s3/getPresignedPost.d.ts +0 -21
- package/aws/s3/getSignedUrl.d.ts +0 -12
- package/aws/s3/initClient.d.ts +0 -9
- package/aws/s3/isFileExists.d.ts +0 -9
- package/aws/s3/listFiles.d.ts +0 -9
- package/aws/s3/listFolders.d.ts +0 -9
- package/aws/s3/moveFile.d.ts +0 -9
- package/aws/s3/readBuffer.d.ts +0 -13
- package/aws/s3/readFile.d.ts +0 -30
- package/aws/s3/writeFile.d.ts +0 -10
- package/aws/s3/writePresignedPost.d.ts +0 -15
- package/aws/s3cache/cache.d.ts +0 -7
- package/aws/s3cache/getCache.d.ts +0 -12
- package/aws/s3cache/getKey.d.ts +0 -10
- package/aws/s3cache/saveCache.d.ts +0 -10
- package/aws/s3cache/updateCache.d.ts +0 -10
- package/aws/ses/SimpleEmail.d.ts +0 -54
- package/aws/ses/initClient.d.ts +0 -9
- package/aws/ssm/getParameter.d.ts +0 -10
- package/aws/ssm/initClient.d.ts +0 -9
- package/axios/get.d.ts +0 -8
- package/axios/post.d.ts +0 -12
- package/boolean/getBoolean.d.ts +0 -7
- package/class/BaseClass.d.ts +0 -31
- package/crud/actions.d.ts +0 -8
- package/crypto/getDecrypt.d.ts +0 -10
- package/crypto/getEncrypt.d.ts +0 -10
- package/crypto/getRandom.d.ts +0 -8
- package/crypto/getSha256.d.ts +0 -8
- package/date/date.d.ts +0 -4
- package/date/duration.d.ts +0 -5
- package/date/durationComparisons.d.ts +0 -5
- package/date/durations.d.ts +0 -8
- package/date/financialYear.d.ts +0 -4
- package/date/financialYearWeek.d.ts +0 -6
- package/date/format.d.ts +0 -13
- package/date/getDate.d.ts +0 -12
- package/date/getDatesBetween.d.ts +0 -10
- package/date/getDurationHours.d.ts +0 -8
- package/date/getDurationMinutes.d.ts +0 -8
- package/date/getFinancialYear.d.ts +0 -9
- package/date/getFinancialYearToDate.d.ts +0 -7
- package/date/getFinancialYearToYesterday.d.ts +0 -7
- package/date/getFinancialYearWeeks.d.ts +0 -9
- package/date/getLastWeek.d.ts +0 -10
- package/date/getMax.d.ts +0 -12
- package/date/getMidnight.d.ts +0 -10
- package/date/getMin.d.ts +0 -12
- package/date/getMonday.d.ts +0 -14
- package/date/getNumber.d.ts +0 -11
- package/date/getPredefinedTimeframe.d.ts +0 -9
- package/date/getSunday.d.ts +0 -14
- package/date/getThisWeek.d.ts +0 -10
- package/date/getTimeZoned.d.ts +0 -13
- package/date/getToday.d.ts +0 -9
- package/date/getTwoWeeksAgo.d.ts +0 -10
- package/date/getWeeksAgo.d.ts +0 -12
- package/date/getYesterday.d.ts +0 -9
- package/date/isDateValid.d.ts +0 -7
- package/date/isLastWeek.d.ts +0 -6
- package/date/isThisWeek.d.ts +0 -6
- package/date/parseExcelDate.d.ts +0 -8
- package/date/predefinedTimeframes.d.ts +0 -7
- package/date/timeframe.d.ts +0 -8
- package/date/timeframes.d.ts +0 -4
- package/deepCrawl/buildRequest.d.ts +0 -15
- package/deepCrawl/filter.d.ts +0 -5
- package/deepCrawl/getData.d.ts +0 -5
- package/deepCrawl/initClient.d.ts +0 -13
- package/deepCrawl/operands.d.ts +0 -11
- package/deepCrawl/orders.d.ts +0 -9
- package/deepCrawl/reports.d.ts +0 -11
- package/environment/environments.d.ts +0 -7
- package/environment/getEnvironment.d.ts +0 -6
- package/environment/isAws.d.ts +0 -5
- package/environment/isDevelopment.d.ts +0 -2
- package/environment/isLocalhost.d.ts +0 -5
- package/environment/isProduction.d.ts +0 -2
- package/environment/isStaging.d.ts +0 -2
- package/environment/isVercel.d.ts +0 -5
- package/environment/platforms.d.ts +0 -6
- package/eskimi/ageGroups.d.ts +0 -5
- package/eskimi/campaign.d.ts +0 -19
- package/eskimi/devices.d.ts +0 -5
- package/eskimi/endpoints.d.ts +0 -16
- package/eskimi/genders.d.ts +0 -5
- package/eskimi/getAccessToken.d.ts +0 -9
- package/eskimi/getAgeGroup.d.ts +0 -7
- package/eskimi/getCampaignIds.d.ts +0 -7
- package/eskimi/getDevice.d.ts +0 -7
- package/eskimi/getGender.d.ts +0 -7
- package/eskimi/request.d.ts +0 -8
- package/google/getCredentials.d.ts +0 -20
- package/google/getCredentials.js +0 -76
- package/google/sheets/getAssociatedData.d.ts +0 -20
- package/google/sheets/getAuth.d.ts +0 -8
- package/google/sheets/getAuth.js +0 -69
- package/google/sheets/getBatchData.d.ts +0 -20
- package/google/sheets/isCellNa.d.ts +0 -7
- package/google/storage/writeFile.d.ts +0 -11
- package/googleAds/getCustomer.d.ts +0 -7
- package/googleAds/initClient.d.ts +0 -15
- package/initClients.d.ts +0 -30
- package/json/isJson.d.ts +0 -8
- package/littleWarden/getUrlStatus.d.ts +0 -9
- package/littleWarden/isAllGood.d.ts +0 -7
- package/littleWarden/isDanger.d.ts +0 -7
- package/littleWarden/isWarning.d.ts +0 -7
- package/littleWarden/states.d.ts +0 -7
- package/myTarget/getAccessToken.d.ts +0 -9
- package/myTarget/request.d.ts +0 -8
- package/nextAuth/isSessionReady.d.ts +0 -4
- package/nextAuth/states.d.ts +0 -7
- package/nextJs/getIp.d.ts +0 -7
- package/nextJs/getUserAgent.d.ts +0 -7
- package/number/getDivide.d.ts +0 -9
- package/number/getNumber.d.ts +0 -8
- package/number/getPercent.d.ts +0 -9
- package/number/getPercentIncrease.d.ts +0 -9
- package/number/getRounded.d.ts +0 -9
- package/prisma/initClient.d.ts +0 -4
- package/snapchat/getAccessToken.d.ts +0 -9
- package/sorting/byNumberAscending.d.ts +0 -8
- package/sorting/byNumberDescending.d.ts +0 -8
- package/sorting/byStringAscending.d.ts +0 -8
- package/sorting/byStringDescending.d.ts +0 -8
- package/string/formatCapitalise.d.ts +0 -9
- package/string/getCleanFolder.d.ts +0 -7
- package/string/getString.d.ts +0 -7
- package/string/getStringFromStream.d.ts +0 -8
- package/string/toProperCase.d.ts +0 -7
- package/swr/isAllData.d.ts +0 -7
- package/swr/isAnyError.d.ts +0 -7
- package/swr/isAnyLoading.d.ts +0 -7
- package/swr/isData.d.ts +0 -7
- package/swr/isError.d.ts +0 -7
- package/swr/isLoading.d.ts +0 -7
- package/upTimeRobot/getMonitors.d.ts +0 -1
- package/upTimeRobot/logTypes.d.ts +0 -7
- package/upTimeRobot/monitorStatuses.d.ts +0 -8
- package/upTimeRobot/monitorSubTypes.d.ts +0 -10
- package/upTimeRobot/monitorTypes.d.ts +0 -8
- package/upTimeRobot/requestStatuses.d.ts +0 -5
- package/url/buildParameters.d.ts +0 -8
- package/url/buildRelative.d.ts +0 -8
- package/url/buildUrl.d.ts +0 -10
- package/url/isAbsolute.d.ts +0 -7
- package/url/isRelative.d.ts +0 -7
- package/url/url.d.ts +0 -6
- package/util/defaultTo.d.ts +0 -9
- package/util/sleep.d.ts +0 -4
- package/webWorker/states.d.ts +0 -7
- package/xml/getXml.d.ts +0 -4
package/aws/s3/deleteFiles.js
CHANGED
|
@@ -1,65 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
/**
|
|
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)})}}/**
|
|
40
2
|
* Delete multiple files.
|
|
41
|
-
*/
|
|
42
|
-
var deleteFiles = function (_a) {
|
|
43
|
-
var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, keys = _a.keys;
|
|
44
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var DeleteObjectsCommand;
|
|
46
|
-
return __generator(this, function (_b) {
|
|
47
|
-
switch (_b.label) {
|
|
48
|
-
case 0:
|
|
49
|
-
DeleteObjectsCommand = require('@aws-sdk/client-s3').DeleteObjectsCommand;
|
|
50
|
-
return [4 /*yield*/, global.awsS3Client.send(new DeleteObjectsCommand({
|
|
51
|
-
Bucket: bucket,
|
|
52
|
-
Delete: {
|
|
53
|
-
Objects: keys.map(function (key) { return ({
|
|
54
|
-
Key: key,
|
|
55
|
-
}); }),
|
|
56
|
-
},
|
|
57
|
-
}))];
|
|
58
|
-
case 1:
|
|
59
|
-
_b.sent();
|
|
60
|
-
return [2 /*return*/];
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
exports.default = deleteFiles;
|
|
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;
|
package/aws/s3/deleteFolder.js
CHANGED
|
@@ -1,86 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var getCleanFolder_1 = __importDefault(require("../../string/getCleanFolder"));
|
|
43
|
-
/**
|
|
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)})}}/**
|
|
44
2
|
* Iteratively delete all the files within a directory and delete the directory.
|
|
45
|
-
*/
|
|
46
|
-
var deleteFolder = function (_a) {
|
|
47
|
-
var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, folder = _a.folder;
|
|
48
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var cleanFolder, _b, ListObjectsV2Command, DeleteObjectsCommand, apiResponse, keys;
|
|
50
|
-
return __generator(this, function (_c) {
|
|
51
|
-
switch (_c.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
cleanFolder = (0, getCleanFolder_1.default)({ input: folder });
|
|
54
|
-
_b = require('@aws-sdk/client-s3'), ListObjectsV2Command = _b.ListObjectsV2Command, DeleteObjectsCommand = _b.DeleteObjectsCommand;
|
|
55
|
-
return [4 /*yield*/, global.awsS3Client.send(new ListObjectsV2Command({
|
|
56
|
-
Bucket: bucket,
|
|
57
|
-
Prefix: ('' === cleanFolder ? '' : cleanFolder + '/'),
|
|
58
|
-
}))];
|
|
59
|
-
case 1:
|
|
60
|
-
apiResponse = _c.sent();
|
|
61
|
-
// No files to be deleted
|
|
62
|
-
if (apiResponse.Contents.length === 0) {
|
|
63
|
-
return [2 /*return*/];
|
|
64
|
-
}
|
|
65
|
-
keys = apiResponse.Contents.map(function (file) { return ({ Key: file.Key }); });
|
|
66
|
-
// Delete the files
|
|
67
|
-
return [4 /*yield*/, global.awsS3Client.send(new DeleteObjectsCommand({
|
|
68
|
-
Bucket: bucket,
|
|
69
|
-
Delete: {
|
|
70
|
-
Objects: keys,
|
|
71
|
-
},
|
|
72
|
-
}))];
|
|
73
|
-
case 2:
|
|
74
|
-
// Delete the files
|
|
75
|
-
_c.sent();
|
|
76
|
-
if (!apiResponse.IsTruncated) return [3 /*break*/, 4];
|
|
77
|
-
return [4 /*yield*/, deleteFolder({ S3Lib: S3Lib, bucket: bucket, client: client, folder: folder })];
|
|
78
|
-
case 3:
|
|
79
|
-
_c.sent();
|
|
80
|
-
_c.label = 4;
|
|
81
|
-
case 4: return [2 /*return*/];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
exports.default = deleteFolder;
|
|
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;
|
package/aws/s3/getGlueJson.js
CHANGED
|
@@ -1,16 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var getArray_1 = __importDefault(require("../../array/getArray"));
|
|
7
|
-
var getGlueJson = function (_a) {
|
|
8
|
-
var data = _a.data;
|
|
9
|
-
// Must be an array
|
|
10
|
-
var inputArray = (0, getArray_1.default)({ input: data });
|
|
11
|
-
// For each array row convert the row
|
|
12
|
-
var stringRows = inputArray.map(function (row) { return JSON.stringify(row); });
|
|
13
|
-
// Combine each row with a line separator
|
|
14
|
-
return stringRows.join("\n");
|
|
15
|
-
};
|
|
16
|
-
exports.default = getGlueJson;
|
|
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,66 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
/**
|
|
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)})}}/**
|
|
40
2
|
* Returns a presigned post to upload a file directly to S3.
|
|
41
3
|
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/modules/_aws_sdk_s3_presigned_post.html
|
|
42
4
|
* https://github.com/8millionstories-organisation/test-vercel-upload-2/blob/50eb12fcb3870a59ab455811bfaa1bdcb886edf2/pages/api/upload-url.js
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
var S3Lib = _a.S3Lib, bucket = _a.bucket, client = _a.client, conditions = _a.conditions, expires = _a.expires, fields = _a.fields, key = _a.key;
|
|
46
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
47
|
-
var createPresignedPost, apiResponse;
|
|
48
|
-
return __generator(this, function (_b) {
|
|
49
|
-
switch (_b.label) {
|
|
50
|
-
case 0:
|
|
51
|
-
createPresignedPost = require('@aws-sdk/client-s3').createPresignedPost;
|
|
52
|
-
return [4 /*yield*/, createPresignedPost(global.awsS3Client, {
|
|
53
|
-
Bucket: bucket,
|
|
54
|
-
Key: key,
|
|
55
|
-
Conditions: undefined === conditions ? [] : conditions,
|
|
56
|
-
Fields: undefined === fields ? {} : fields,
|
|
57
|
-
Expires: undefined === expires ? 60 : expires, // Seconds
|
|
58
|
-
})];
|
|
59
|
-
case 1:
|
|
60
|
-
apiResponse = _b.sent();
|
|
61
|
-
return [2 /*return*/, apiResponse];
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
exports.default = getPresignedPost;
|
|
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;
|
package/aws/s3/getSignedUrl.js
CHANGED
|
@@ -1,85 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var response_1 = __importDefault(require("../../api/response"));
|
|
54
|
-
var states_1 = __importDefault(require("../../api/states"));
|
|
55
|
-
/**
|
|
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)})}}/**
|
|
56
2
|
* Returns a signed for URL to allow download of private buckets for a given duration.
|
|
57
3
|
* Library: @aws-sdk/s3-request-presigner
|
|
58
|
-
*/
|
|
59
|
-
var getSignedUrl = function (_a) {
|
|
60
|
-
var bucket = _a.bucket, expires = _a.expires, key = _a.key;
|
|
61
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var response, GetObjectCommand, getSignedUrl, command, awsResponse;
|
|
63
|
-
return __generator(this, function (_b) {
|
|
64
|
-
switch (_b.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
response = __assign({}, response_1.default);
|
|
67
|
-
GetObjectCommand = require('@aws-sdk/client-s3').GetObjectCommand;
|
|
68
|
-
getSignedUrl = require('@aws-sdk/s3-request-presigner').getSignedUrl;
|
|
69
|
-
command = new GetObjectCommand({
|
|
70
|
-
Bucket: bucket,
|
|
71
|
-
Key: key,
|
|
72
|
-
});
|
|
73
|
-
return [4 /*yield*/, getSignedUrl(global.awsS3Client, command, { expiresIn: expires })];
|
|
74
|
-
case 1:
|
|
75
|
-
awsResponse = _b.sent();
|
|
76
|
-
if (awsResponse && 'string' === typeof awsResponse) {
|
|
77
|
-
response.state = states_1.default.SUCCESS;
|
|
78
|
-
response.body = awsResponse;
|
|
79
|
-
}
|
|
80
|
-
return [2 /*return*/, response];
|
|
81
|
-
}
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
};
|
|
85
|
-
exports.default = getSignedUrl;
|
|
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;
|
package/aws/s3/initClient.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
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
|
-
var getConfig_1 = __importDefault(require("../getConfig"));
|
|
7
|
-
global.awsS3Client = null;
|
|
8
|
-
/**
|
|
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;/**
|
|
9
2
|
* Shorthand function to get the Lambda Client.
|
|
10
3
|
* Library: @aws-sdk/client-s3
|
|
11
|
-
*/
|
|
12
|
-
var initClient = function (_a) {
|
|
13
|
-
var config = _a.config;
|
|
14
|
-
if (!global.awsS3Client) {
|
|
15
|
-
var S3Client = require('@aws-sdk/client-s3').S3Client;
|
|
16
|
-
var formattedConfig = (0, getConfig_1.default)({ config: config });
|
|
17
|
-
global.awsS3Client = new S3Client(formattedConfig);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
exports.default = initClient;
|
|
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;
|
package/aws/s3/isFileExists.js
CHANGED
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
-
};
|
|
41
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
var isResponse200_1 = __importDefault(require("../isResponse200"));
|
|
43
|
-
/**
|
|
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)})}}/**
|
|
44
2
|
* Check to see if a file exists but don't get the contents.
|
|
45
|
-
*/
|
|
46
|
-
var isFileExists = function (_a) {
|
|
47
|
-
var bucket = _a.bucket, key = _a.key;
|
|
48
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var response, HeadObjectCommand, apiResponse, exception_1;
|
|
50
|
-
return __generator(this, function (_b) {
|
|
51
|
-
switch (_b.label) {
|
|
52
|
-
case 0:
|
|
53
|
-
response = false;
|
|
54
|
-
_b.label = 1;
|
|
55
|
-
case 1:
|
|
56
|
-
_b.trys.push([1, 3, , 4]);
|
|
57
|
-
HeadObjectCommand = require('@aws-sdk/client-s3').HeadObjectCommand;
|
|
58
|
-
return [4 /*yield*/, global.awsS3Client.send(new HeadObjectCommand({
|
|
59
|
-
Bucket: bucket,
|
|
60
|
-
Key: key,
|
|
61
|
-
}))];
|
|
62
|
-
case 2:
|
|
63
|
-
apiResponse = _b.sent();
|
|
64
|
-
// If the status is 200 then it does exist
|
|
65
|
-
response = (0, isResponse200_1.default)({ apiResponse: apiResponse });
|
|
66
|
-
return [3 /*break*/, 4];
|
|
67
|
-
case 3:
|
|
68
|
-
exception_1 = _b.sent();
|
|
69
|
-
response = false;
|
|
70
|
-
return [3 /*break*/, 4];
|
|
71
|
-
case 4: return [2 /*return*/, response];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
exports.default = isFileExists;
|
|
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;
|