@8ms/helpers 1.1.66 → 1.1.71
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/response.js +2 -2
- package/api/states.js +1 -1
- package/api/unexpectedError.js +1 -1
- package/array/contains.js +1 -4
- package/array/getArray.js +2 -5
- package/aws/athenaExpress/initClient.d.ts +1 -1
- package/aws/athenaExpress/initClient.js +6 -7
- package/aws/athenaExpress/query.d.ts +8 -0
- package/aws/athenaExpress/query.js +10 -0
- package/aws/getConfig.d.ts +5 -1
- package/aws/getConfig.js +2 -3
- package/aws/glue/initClient.d.ts +5 -4
- package/aws/glue/initClient.js +4 -5
- package/aws/glue/invoke.d.ts +1 -3
- package/aws/glue/invoke.js +12 -63
- package/aws/isResponse200.js +4 -5
- package/aws/lambda/getHandlerPath.d.ts +4 -3
- package/aws/lambda/getHandlerPath.js +3 -4
- package/aws/lambda/initClient.d.ts +5 -4
- package/aws/lambda/initClient.js +4 -5
- package/aws/lambda/invoke.d.ts +1 -3
- package/aws/lambda/invoke.js +29 -77
- package/aws/s3/copyFile.js +7 -55
- package/aws/s3/deleteFile.js +6 -54
- package/aws/s3/deleteFiles.d.ts +5 -6
- package/aws/s3/deleteFiles.js +10 -58
- package/aws/s3/deleteFolder.d.ts +5 -6
- package/aws/s3/deleteFolder.js +26 -76
- package/aws/s3/getGlueJson.d.ts +3 -2
- package/aws/s3/getGlueJson.js +4 -5
- package/aws/s3/getPresignedPost.d.ts +6 -7
- package/aws/s3/getPresignedPost.js +9 -56
- package/aws/s3/getSignedUrl.js +8 -76
- package/aws/s3/initClient.d.ts +5 -4
- package/aws/s3/initClient.js +4 -5
- package/aws/s3/isFileExists.js +17 -66
- package/aws/s3/listFiles.js +22 -69
- package/aws/s3/listFolders.js +21 -68
- package/aws/s3/moveFile.d.ts +5 -4
- package/aws/s3/moveFile.js +10 -58
- package/aws/s3/readBuffer.js +41 -89
- package/aws/s3/readFile.js +42 -93
- package/aws/s3/writeFile.js +10 -72
- package/aws/s3/writePresignedPost.d.ts +2 -3
- package/aws/s3/writePresignedPost.js +22 -93
- package/aws/s3cache/getCache.js +25 -69
- package/aws/s3cache/getKey.js +7 -8
- package/aws/s3cache/saveCache.js +3 -49
- package/aws/s3cache/updateCache.js +13 -65
- package/aws/ses/SimpleEmail.d.ts +10 -13
- package/aws/ses/SimpleEmail.js +85 -189
- package/aws/ses/initClient.d.ts +5 -4
- package/aws/ses/initClient.js +4 -5
- package/aws/ssm/getParameter.js +31 -78
- package/aws/ssm/initClient.d.ts +5 -4
- package/aws/ssm/initClient.js +4 -5
- package/axios/get.js +35 -106
- package/axios/post.js +35 -106
- package/boolean/getBoolean.js +2 -3
- package/class/BaseClass.js +15 -22
- package/crypto/getDecrypt.js +3 -4
- package/crypto/getEncrypt.js +3 -4
- package/crypto/getRandom.js +1 -2
- package/crypto/getSha256.js +4 -5
- package/date/durationComparisons.js +1 -1
- package/date/durations.js +1 -1
- package/date/format.js +7 -8
- package/date/getDate.js +19 -20
- package/date/getDatesBetween.js +8 -9
- package/date/getDurationHours.js +6 -7
- package/date/getDurationMinutes.js +6 -7
- package/date/getFinancialYear.js +11 -12
- package/date/getFinancialYearToDate.js +5 -5
- package/date/getFinancialYearToYesterday.js +5 -5
- package/date/getFinancialYearWeeks.js +10 -11
- package/date/getLastWeek.js +11 -12
- package/date/getMax.js +5 -6
- package/date/getMidnight.js +2 -3
- package/date/getMin.js +5 -6
- package/date/getMonday.js +10 -11
- package/date/getNumber.js +4 -5
- package/date/getPredefinedTimeframe.js +5 -6
- package/date/getSunday.js +10 -11
- package/date/getThisWeek.js +11 -12
- package/date/getTimeZoned.js +11 -12
- package/date/getToday.js +6 -7
- package/date/getTwoWeeksAgo.js +11 -12
- package/date/getWeeksAgo.js +5 -6
- package/date/getYesterday.js +7 -8
- package/date/isDateValid.js +6 -7
- package/date/isLastWeek.js +3 -4
- package/date/isThisWeek.js +3 -4
- package/date/parseExcelDate.js +9 -10
- package/deepCrawl/buildRequest.js +19 -20
- package/deepCrawl/getData.js +21 -79
- package/deepCrawl/initClient.js +17 -64
- package/deepCrawl/operands.js +1 -1
- package/deepCrawl/orders.js +1 -1
- package/deepCrawl/reports.js +1 -1
- package/environment/environments.js +1 -1
- package/environment/getEnvironment.js +8 -8
- package/environment/isAws.js +2 -2
- package/environment/isDevelopment.js +3 -3
- package/environment/isLocalhost.js +4 -4
- package/environment/isProduction.js +3 -3
- package/environment/isStaging.js +3 -3
- package/environment/isVercel.js +1 -1
- package/environment/platforms.d.ts +1 -1
- package/environment/platforms.js +1 -1
- package/eskimi/ageGroups.js +1 -1
- package/eskimi/devices.js +1 -1
- package/eskimi/endpoints.js +1 -1
- package/eskimi/genders.js +1 -1
- package/eskimi/getAccessToken.js +11 -57
- package/eskimi/getAgeGroup.js +3 -4
- package/eskimi/getCampaignIds.js +2 -3
- package/eskimi/getDevice.js +3 -4
- package/eskimi/getGender.js +3 -4
- package/eskimi/request.js +13 -59
- package/google/bigQuery/initClient.d.ts +11 -0
- package/google/bigQuery/initClient.js +22 -0
- package/google/bigQuery/query.d.ts +9 -0
- package/google/bigQuery/query.js +10 -0
- package/google/getConfig.d.ts +20 -0
- package/google/getConfig.js +23 -0
- package/google/sheets/getAssociatedData.d.ts +2 -6
- package/google/sheets/getAssociatedData.js +42 -89
- package/google/sheets/getBatchData.d.ts +1 -3
- package/google/sheets/getBatchData.js +15 -60
- package/google/sheets/initClient.d.ts +11 -0
- package/google/sheets/initClient.js +25 -0
- package/google/sheets/isCellNa.js +1 -4
- package/google/storage/initClient.d.ts +12 -0
- package/google/storage/initClient.js +23 -0
- package/google/storage/writeFile.d.ts +2 -1
- package/google/storage/writeFile.js +20 -77
- package/googleAds/getCustomer.js +7 -48
- package/googleAds/initClient.d.ts +9 -8
- package/googleAds/initClient.js +13 -56
- package/initClients.d.ts +13 -3
- package/initClients.js +95 -101
- package/json/isJson.js +1 -2
- package/littleWarden/getUrlStatus.js +10 -56
- package/littleWarden/isAllGood.js +3 -4
- package/littleWarden/isDanger.js +3 -4
- package/littleWarden/isWarning.js +3 -4
- package/littleWarden/states.js +1 -1
- package/myTarget/getAccessToken.js +11 -57
- package/myTarget/request.js +13 -59
- package/nextAuth/isSessionReady.js +2 -3
- package/nextAuth/states.js +1 -1
- package/nextJs/getIp.js +2 -3
- package/nextJs/getUserAgent.js +1 -4
- package/number/getDivide.js +4 -5
- package/number/getNumber.js +6 -7
- package/number/getPercent.js +4 -5
- package/number/getPercentIncrease.js +4 -5
- package/number/getRounded.js +5 -6
- package/package.json +2 -1
- package/prisma/initClient.js +4 -5
- package/snapchat/getAccessToken.js +25 -72
- package/sorting/byNumberAscending.js +3 -4
- package/sorting/byNumberDescending.js +3 -4
- package/sorting/byStringAscending.js +3 -4
- package/sorting/byStringDescending.js +3 -4
- package/string/formatCapitalise.js +2 -3
- package/string/getCleanFolder.js +3 -6
- package/string/getString.js +9 -10
- package/string/getStringFromStream.js +7 -8
- package/string/toProperCase.js +6 -7
- package/swr/isAllData.js +4 -5
- package/swr/isAnyError.js +4 -5
- package/swr/isAnyLoading.js +4 -5
- package/swr/isData.js +1 -4
- package/swr/isError.js +1 -4
- package/swr/isLoading.js +3 -6
- package/upTimeRobot/getMonitors.d.ts +1 -0
- package/upTimeRobot/getMonitors.js +33 -0
- package/upTimeRobot/logTypes.d.ts +7 -0
- package/upTimeRobot/logTypes.js +9 -0
- package/upTimeRobot/monitorStatuses.d.ts +8 -0
- package/upTimeRobot/monitorStatuses.js +10 -0
- package/upTimeRobot/monitorSubTypes.d.ts +10 -0
- package/upTimeRobot/monitorSubTypes.js +12 -0
- package/upTimeRobot/monitorTypes.d.ts +8 -0
- package/upTimeRobot/monitorTypes.js +10 -0
- package/upTimeRobot/requestStatuses.d.ts +5 -0
- package/upTimeRobot/requestStatuses.js +7 -0
- package/url/buildParameters.js +7 -8
- package/url/buildRelative.js +3 -4
- package/url/buildUrl.js +6 -7
- package/url/isAbsolute.js +1 -2
- package/url/isRelative.js +2 -5
- package/util/defaultTo.d.ts +6 -5
- package/util/defaultTo.js +6 -7
- package/util/isUndefined.d.ts +9 -0
- package/util/isUndefined.js +19 -0
- package/util/sleep.js +2 -3
- package/webWorker/states.js +1 -1
- package/xml/getXml.js +10 -58
- 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/google/getCredentials.d.ts +0 -20
- package/google/getCredentials.js +0 -76
- package/google/sheets/getAuth.d.ts +0 -8
- package/google/sheets/getAuth.js +0 -69
package/xml/getXml.js
CHANGED
|
@@ -1,62 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
response = _b.sent();
|
|
50
|
-
return [4 /*yield*/, response.text()];
|
|
51
|
-
case 2:
|
|
52
|
-
xml = _b.sent();
|
|
53
|
-
// Trim the contents
|
|
54
|
-
xml = xml.trim();
|
|
55
|
-
// Remove tabs, new lines, double spaces
|
|
56
|
-
xml = xml.replace(/[ ]{2}|\r\n|\n|\r|\t/gm, '');
|
|
57
|
-
return [2 /*return*/, xml];
|
|
58
|
-
}
|
|
59
|
-
});
|
|
60
|
-
});
|
|
3
|
+
const getXml = async ({ url }) => {
|
|
4
|
+
const fetch = require('node-fetch');
|
|
5
|
+
const response = await fetch(url);
|
|
6
|
+
// Get the response as text (not JSON)
|
|
7
|
+
let xml = await response.text();
|
|
8
|
+
// Trim the contents
|
|
9
|
+
xml = xml.trim();
|
|
10
|
+
// Remove tabs, new lines, double spaces
|
|
11
|
+
xml = xml.replace(/[ ]{2}|\r\n|\n|\r|\t/gm, '');
|
|
12
|
+
return xml;
|
|
61
13
|
};
|
|
62
14
|
exports.default = getXml;
|
|
@@ -1,54 +0,0 @@
|
|
|
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
|
-
/**
|
|
40
|
-
* Build the query and return the data.
|
|
41
|
-
*/
|
|
42
|
-
var request = function (_a) {
|
|
43
|
-
var query = _a.query;
|
|
44
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
return __generator(this, function (_b) {
|
|
46
|
-
switch (_b.label) {
|
|
47
|
-
case 0: return [4 /*yield*/, global.awsAthenaExpressClient.query(query)
|
|
48
|
-
.then(function (data) { return undefined === data['Items'] ? [] : data['Items']; })];
|
|
49
|
-
case 1: return [2 /*return*/, _b.sent()];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
exports.default = request;
|
package/aws/config.d.ts
DELETED
package/aws/config.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare type GetCredentials = {
|
|
2
|
-
parameterName: string;
|
|
3
|
-
};
|
|
4
|
-
export declare type Credentials = {
|
|
5
|
-
type: string;
|
|
6
|
-
project_id: string;
|
|
7
|
-
private_key_id: string;
|
|
8
|
-
private_key: string;
|
|
9
|
-
client_email: string;
|
|
10
|
-
client_id: string;
|
|
11
|
-
auth_uri: string;
|
|
12
|
-
token_uri: string;
|
|
13
|
-
auth_provider_x509_cert_url: string;
|
|
14
|
-
client_x509_cert_url: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Fetch the data from Parameter Store and return the data ready to be used with Google API.
|
|
18
|
-
*/
|
|
19
|
-
declare const getCredentials: ({ parameterName }: GetCredentials) => Promise<Credentials>;
|
|
20
|
-
export default getCredentials;
|
package/google/getCredentials.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
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 getParameter_1 = __importDefault(require("../aws/ssm/getParameter"));
|
|
43
|
-
/**
|
|
44
|
-
* Fetch the data from Parameter Store and return the data ready to be used with Google API.
|
|
45
|
-
*/
|
|
46
|
-
var getCredentials = function (_a) {
|
|
47
|
-
var parameterName = _a.parameterName;
|
|
48
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
49
|
-
var parameter, privateKey;
|
|
50
|
-
return __generator(this, function (_b) {
|
|
51
|
-
switch (_b.label) {
|
|
52
|
-
case 0: return [4 /*yield*/, (0, getParameter_1.default)({
|
|
53
|
-
name: parameterName,
|
|
54
|
-
withDecryption: true,
|
|
55
|
-
isJson: true,
|
|
56
|
-
})];
|
|
57
|
-
case 1:
|
|
58
|
-
parameter = _b.sent();
|
|
59
|
-
privateKey = parameter['private_key'].replace(/\\n/g, '\n');
|
|
60
|
-
return [2 /*return*/, {
|
|
61
|
-
type: parameter['type'],
|
|
62
|
-
project_id: parameter['project_id'],
|
|
63
|
-
private_key_id: parameter['private_key_id'],
|
|
64
|
-
private_key: privateKey,
|
|
65
|
-
client_email: parameter['client_email'],
|
|
66
|
-
client_id: parameter['client_id'],
|
|
67
|
-
auth_uri: parameter['auth_uri'],
|
|
68
|
-
token_uri: parameter['token_uri'],
|
|
69
|
-
auth_provider_x509_cert_url: parameter['auth_provider_x509_cert_url'],
|
|
70
|
-
client_x509_cert_url: parameter['client_x509_cert_url'],
|
|
71
|
-
}];
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
};
|
|
76
|
-
exports.default = getCredentials;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { GetCredentials } from '../getCredentials';
|
|
2
|
-
/**
|
|
3
|
-
* Initialise the Google Sheets instance using the separate service method.
|
|
4
|
-
* https://github.com/googleapis/google-api-nodejs-client
|
|
5
|
-
* Library: @googleapis/sheets
|
|
6
|
-
*/
|
|
7
|
-
declare const getAuth: ({ parameterName }: GetCredentials) => Promise<any>;
|
|
8
|
-
export default getAuth;
|
package/google/sheets/getAuth.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
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 getCredentials_1 = __importDefault(require("../getCredentials"));
|
|
43
|
-
/**
|
|
44
|
-
* Initialise the Google Sheets instance using the separate service method.
|
|
45
|
-
* https://github.com/googleapis/google-api-nodejs-client
|
|
46
|
-
* Library: @googleapis/sheets
|
|
47
|
-
*/
|
|
48
|
-
var getAuth = function (_a) {
|
|
49
|
-
var parameterName = _a.parameterName;
|
|
50
|
-
return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
-
var credentials, sheetsLib, auth;
|
|
52
|
-
return __generator(this, function (_b) {
|
|
53
|
-
switch (_b.label) {
|
|
54
|
-
case 0: return [4 /*yield*/, (0, getCredentials_1.default)({ parameterName: parameterName })];
|
|
55
|
-
case 1:
|
|
56
|
-
credentials = _b.sent();
|
|
57
|
-
sheetsLib = require('@googleapis/sheets');
|
|
58
|
-
auth = new sheetsLib.auth.GoogleAuth({
|
|
59
|
-
credentials: credentials,
|
|
60
|
-
scopes: [
|
|
61
|
-
'https://www.googleapis.com/auth/spreadsheets',
|
|
62
|
-
],
|
|
63
|
-
});
|
|
64
|
-
return [2 /*return*/, auth];
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
};
|
|
69
|
-
exports.default = getAuth;
|