@8ms/helpers 2.0.0 → 2.0.2
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/.github/workflows/deploy_npmjs.yml +7 -0
- package/.yarn/install-state.gz +0 -0
- package/_class/BaseClass.d.ts +18 -0
- package/_class/BaseClass.js +53 -0
- package/_class/BaseNamespace.d.ts +9 -0
- package/_class/BaseNamespace.js +27 -0
- package/_class/index.d.ts +2 -0
- package/_class/index.js +7 -0
- package/adverity/getJobs.d.ts +15 -0
- package/adverity/getJobs.js +30 -0
- package/adverity/index.d.ts +112 -0
- package/adverity/index.js +61 -0
- package/api/ApiResponseClass.d.ts +35 -0
- package/api/ApiResponseClass.js +97 -0
- package/api/index.d.ts +22 -0
- package/api/index.js +44 -0
- package/array/index.d.ts +8 -0
- package/array/index.js +17 -0
- package/atInternet/index.d.ts +16 -0
- package/atInternet/index.js +18 -0
- package/aws/athenaExpress/AwsAthenaNamespace.d.ts +8 -0
- package/aws/athenaExpress/AwsAthenaNamespace.js +82 -0
- package/aws/athenaExpress/index.d.ts +10 -0
- package/aws/athenaExpress/index.js +40 -0
- package/aws/ec2/AwsEc2Namespace.d.ts +10 -0
- package/aws/ec2/AwsEc2Namespace.js +78 -0
- package/aws/ec2/index.d.ts +3 -0
- package/aws/ec2/index.js +16 -0
- package/aws/ecs/AwsEcsNamespace.d.ts +53 -0
- package/aws/ecs/AwsEcsNamespace.js +159 -0
- package/aws/ecs/index.d.ts +3 -0
- package/aws/ecs/index.js +16 -0
- package/aws/glue/AwsGlueNamespace.d.ts +12 -0
- package/aws/glue/AwsGlueNamespace.js +70 -0
- package/aws/glue/index.d.ts +3 -0
- package/aws/glue/index.js +16 -0
- package/aws/index.d.ts +9 -0
- package/aws/index.js +34 -0
- package/aws/isResponse200.d.ts +4 -0
- package/aws/isResponse200.js +16 -0
- package/aws/lambda/AwsLambdaNamespace.d.ts +21 -0
- package/aws/lambda/AwsLambdaNamespace.js +110 -0
- package/aws/lambda/index.d.ts +4 -0
- package/aws/lambda/index.js +21 -0
- package/aws/s3/AwsS3Namespace.d.ts +60 -0
- package/aws/s3/AwsS3Namespace.js +401 -0
- package/aws/s3/index.d.ts +25 -0
- package/aws/s3/index.js +36 -0
- package/aws/s3/payload.d.ts +42 -0
- package/aws/s3/payload.js +46 -0
- package/aws/ses/AwsSesNamespace.d.ts +18 -0
- package/aws/ses/AwsSesNamespace.js +69 -0
- package/aws/ses/SimpleEmail.d.ts +56 -0
- package/aws/ses/SimpleEmail.js +106 -0
- package/aws/ses/index.d.ts +4 -0
- package/aws/ses/index.js +18 -0
- package/aws/sqs/AwsSqsNamespace.d.ts +34 -0
- package/aws/sqs/AwsSqsNamespace.js +96 -0
- package/aws/sqs/index.d.ts +3 -0
- package/aws/sqs/index.js +16 -0
- package/aws/ssm/AwsSsmNamespace.d.ts +11 -0
- package/aws/ssm/AwsSsmNamespace.js +89 -0
- package/aws/ssm/index.d.ts +3 -0
- package/aws/ssm/index.js +16 -0
- package/axios/deleteRequest.d.ts +6 -0
- package/axios/deleteRequest.js +33 -0
- package/axios/get.d.ts +5 -0
- package/axios/get.js +31 -0
- package/axios/index.d.ts +3 -0
- package/axios/index.js +9 -0
- package/axios/post.d.ts +5 -0
- package/axios/post.js +32 -0
- package/boolean/getBoolean.d.ts +4 -0
- package/boolean/getBoolean.js +23 -0
- package/boolean/index.d.ts +1 -0
- package/boolean/index.js +5 -0
- package/brightData/index.d.ts +15 -0
- package/brightData/index.js +20 -0
- package/brightData/serpApi/buildGoogleSerpUrl.d.ts +32 -0
- package/brightData/serpApi/buildGoogleSerpUrl.js +116 -0
- package/brightData/serpApi/buildGoogleTrendsUrl.d.ts +22 -0
- package/brightData/serpApi/buildGoogleTrendsUrl.js +61 -0
- package/brightData/serpApi/getAsyncRequestId.d.ts +8 -0
- package/brightData/serpApi/getAsyncRequestId.js +36 -0
- package/brightData/serpApi/getAsyncResults.d.ts +7 -0
- package/brightData/serpApi/getAsyncResults.js +35 -0
- package/brightData/serpApi/getRealtime.d.ts +5 -0
- package/brightData/serpApi/getRealtime.js +30 -0
- package/brightData/serpApi/index.d.ts +14 -0
- package/brightData/serpApi/index.js +23 -0
- package/brightData/webScraperIde/getBatch.d.ts +7 -0
- package/brightData/webScraperIde/getBatch.js +28 -0
- package/brightData/webScraperIde/getRealtime.d.ts +7 -0
- package/brightData/webScraperIde/getRealtime.js +49 -0
- package/brightData/webScraperIde/index.d.ts +2 -0
- package/brightData/webScraperIde/index.js +7 -0
- package/cache/index.d.ts +2 -0
- package/cache/index.js +48 -0
- package/cache/test/cache.test.d.ts +1 -0
- package/cache/test/cache.test.js +10 -0
- package/crud/index.d.ts +6 -0
- package/crud/index.js +10 -0
- package/crypto/getDecrypt.d.ts +5 -0
- package/crypto/getDecrypt.js +47 -0
- package/crypto/getEncrypt.d.ts +5 -0
- package/crypto/getEncrypt.js +47 -0
- package/crypto/getRandom.d.ts +4 -0
- package/crypto/getRandom.js +12 -0
- package/crypto/getSha256.d.ts +5 -0
- package/crypto/getSha256.js +48 -0
- package/crypto/index.d.ts +4 -0
- package/crypto/index.js +11 -0
- package/date/calculation.d.ts +75 -0
- package/date/calculation.js +207 -0
- package/date/financialYear.d.ts +19 -0
- package/date/financialYear.js +85 -0
- package/date/format.d.ts +68 -0
- package/date/format.js +150 -0
- package/date/index.d.ts +35 -0
- package/date/index.js +57 -0
- package/environment/index.d.ts +32 -0
- package/environment/index.js +92 -0
- package/eskimi/getAgeGroup.d.ts +4 -0
- package/eskimi/getAgeGroup.js +15 -0
- package/eskimi/getData.d.ts +4 -0
- package/eskimi/getData.js +17 -0
- package/eskimi/getDevice.d.ts +4 -0
- package/eskimi/getDevice.js +15 -0
- package/eskimi/getGender.d.ts +4 -0
- package/eskimi/getGender.js +15 -0
- package/eskimi/index.d.ts +49 -0
- package/eskimi/index.js +96 -0
- package/file/createDirectory.d.ts +5 -0
- package/file/createDirectory.js +50 -0
- package/file/index.d.ts +1 -0
- package/file/index.js +5 -0
- package/geo/countries.d.ts +12 -0
- package/geo/countries.js +222 -0
- package/geo/index.d.ts +2 -0
- package/geo/index.js +7 -0
- package/geo/languages.d.ts +9 -0
- package/geo/languages.js +58 -0
- package/google/bigQuery/GoogleBigQueryNamespace.d.ts +51 -0
- package/google/bigQuery/GoogleBigQueryNamespace.js +165 -0
- package/google/bigQuery/index.d.ts +5 -0
- package/google/bigQuery/index.js +37 -0
- package/google/bigQuery/loadData.d.ts +19 -0
- package/google/bigQuery/loadData.js +18 -0
- package/google/index.d.ts +27 -0
- package/google/index.js +24 -0
- package/google/sheets/GoogleSheetsNamespace.d.ts +16 -0
- package/google/sheets/GoogleSheetsNamespace.js +81 -0
- package/google/sheets/getAssociatedData.d.ts +10 -0
- package/google/sheets/getAssociatedData.js +43 -0
- package/google/sheets/index.d.ts +8 -0
- package/google/sheets/index.js +37 -0
- package/google/storage/GoogleCloudStorageNamespace.d.ts +20 -0
- package/google/storage/GoogleCloudStorageNamespace.js +108 -0
- package/google/storage/index.d.ts +3 -0
- package/google/storage/index.js +30 -0
- package/googleAds/GoogleAdsNamespace.d.ts +11 -0
- package/googleAds/GoogleAdsNamespace.js +73 -0
- package/googleAds/index.d.ts +11 -0
- package/googleAds/index.js +30 -0
- package/googleAds/keywordPlanner/index.d.ts +40 -0
- package/googleAds/keywordPlanner/index.js +59 -0
- package/googlePageSpeed/GooglePageSpeedNamespace.d.ts +11 -0
- package/googlePageSpeed/GooglePageSpeedNamespace.js +35 -0
- package/googlePageSpeed/index.d.ts +17 -0
- package/googlePageSpeed/index.js +44 -0
- package/googleSearchIncidents/index.d.ts +69 -0
- package/googleSearchIncidents/index.js +46 -0
- package/greenDomain/index.d.ts +21 -0
- package/greenDomain/index.js +41 -0
- package/inngest/index.d.ts +6 -0
- package/inngest/index.js +10 -0
- package/json/getJsonNewline.d.ts +1 -0
- package/json/getJsonNewline.js +13 -0
- package/json/index.d.ts +2 -0
- package/json/index.js +7 -0
- package/json/isJson.d.ts +1 -0
- package/json/isJson.js +26 -0
- package/littleWarden/LittleWardenNamespace.d.ts +11 -0
- package/littleWarden/LittleWardenNamespace.js +38 -0
- package/littleWarden/getUrlStatus.d.ts +4 -0
- package/littleWarden/getUrlStatus.js +16 -0
- package/littleWarden/index.d.ts +29 -0
- package/littleWarden/index.js +74 -0
- package/lumar/api/buildRequest.d.ts +13 -0
- package/lumar/api/buildRequest.js +80 -0
- package/lumar/api/getData.d.ts +5 -0
- package/lumar/api/getData.js +13 -0
- package/lumar/api/index.d.ts +36 -0
- package/lumar/api/index.js +33 -0
- package/lumar/api/initClient.d.ts +6 -0
- package/lumar/api/initClient.js +26 -0
- package/lumar/graphql/columns.d.ts +28 -0
- package/lumar/graphql/columns.js +31 -0
- package/lumar/graphql/getData.d.ts +1 -0
- package/lumar/graphql/getData.js +20 -0
- package/lumar/graphql/index.d.ts +29 -0
- package/lumar/graphql/index.js +39 -0
- package/lumar/graphql/initClient.d.ts +5 -0
- package/lumar/graphql/initClient.js +25 -0
- package/lumar/graphql/queries/crawl.d.ts +5 -0
- package/lumar/graphql/queries/crawl.js +2 -0
- package/lumar/graphql/queries/getCrawls.d.ts +18 -0
- package/lumar/graphql/queries/getCrawls.js +33 -0
- package/lumar/graphql/queries/getReportDifferences.d.ts +24 -0
- package/lumar/graphql/queries/getReportDifferences.js +37 -0
- package/lumar/graphql/queries/getRows.d.ts +38 -0
- package/lumar/graphql/queries/getRows.js +57 -0
- package/lumar/graphql/queries/getTotals.d.ts +25 -0
- package/lumar/graphql/queries/getTotals.js +40 -0
- package/lumar/graphql/queries/row.d.ts +157 -0
- package/lumar/graphql/queries/row.js +2 -0
- package/lumar/graphql/reportTemplates.d.ts +67 -0
- package/lumar/graphql/reportTemplates.js +70 -0
- package/myTarget/request.d.ts +5 -0
- package/myTarget/request.js +17 -0
- package/nextAuth/index.d.ts +6 -0
- package/nextAuth/index.js +11 -0
- package/nextAuth/isSessionReady.d.ts +1 -0
- package/nextAuth/isSessionReady.js +13 -0
- package/nextJs/getIp.d.ts +6 -0
- package/nextJs/getIp.js +14 -0
- package/nextJs/getUserAgent.d.ts +6 -0
- package/nextJs/getUserAgent.js +8 -0
- package/nextJs/index.d.ts +2 -0
- package/nextJs/index.js +7 -0
- package/number/format.d.ts +12 -0
- package/number/format.js +20 -0
- package/number/formatCurrency.d.ts +5 -0
- package/number/formatCurrency.js +21 -0
- package/number/getDecimal.d.ts +4 -0
- package/number/getDecimal.js +12 -0
- package/number/getNumber.d.ts +4 -0
- package/number/getNumber.js +48 -0
- package/number/getPercentIncrease.d.ts +4 -0
- package/number/getPercentIncrease.js +16 -0
- package/number/getSafeDivide.d.ts +11 -0
- package/number/getSafeDivide.js +20 -0
- package/number/index.d.ts +6 -0
- package/number/index.js +15 -0
- package/object/index.d.ts +1 -0
- package/object/index.js +5 -0
- package/object/replaceKeys.d.ts +5 -0
- package/object/replaceKeys.js +25 -0
- package/onePassword/OnePasswordNamespace.d.ts +13 -0
- package/onePassword/OnePasswordNamespace.js +81 -0
- package/onePassword/index.d.ts +7 -0
- package/onePassword/index.js +25 -0
- package/openAi/OpenAiNamespace.d.ts +11 -0
- package/openAi/OpenAiNamespace.js +44 -0
- package/openAi/index.d.ts +5 -0
- package/openAi/index.js +30 -0
- package/package.json +2 -2
- package/prisma/PrismaNamespace.d.ts +8 -0
- package/prisma/PrismaNamespace.js +79 -0
- package/prisma/getDecimal.d.ts +4 -0
- package/prisma/getDecimal.js +23 -0
- package/prisma/index.d.ts +8 -0
- package/prisma/index.js +29 -0
- package/snapchat/SnapchatNamespace.d.ts +15 -0
- package/snapchat/SnapchatNamespace.js +30 -0
- package/snapchat/index.d.ts +7 -0
- package/snapchat/index.js +30 -0
- package/sorting/byNumberAscending.d.ts +4 -0
- package/sorting/byNumberAscending.js +19 -0
- package/sorting/byNumberDescending.d.ts +4 -0
- package/sorting/byNumberDescending.js +22 -0
- package/sorting/byStringAscending.d.ts +4 -0
- package/sorting/byStringAscending.js +16 -0
- package/sorting/byStringDescending.d.ts +4 -0
- package/sorting/byStringDescending.js +16 -0
- package/sorting/index.d.ts +4 -0
- package/sorting/index.js +11 -0
- package/stream/index.d.ts +1 -0
- package/stream/index.js +5 -0
- package/stream/sort.d.ts +13 -0
- package/stream/sort.js +51 -0
- package/string/getCapitalised.d.ts +5 -0
- package/string/getCapitalised.js +18 -0
- package/string/getClean.d.ts +18 -0
- package/string/getClean.js +51 -0
- package/string/getFolder.d.ts +4 -0
- package/string/getFolder.js +15 -0
- package/string/getProperCase.d.ts +11 -0
- package/string/getProperCase.js +25 -0
- package/string/getString.d.ts +4 -0
- package/string/getString.js +34 -0
- package/string/getStringFromStream.d.ts +5 -0
- package/string/getStringFromStream.js +17 -0
- package/string/getUnescaped.d.ts +6 -0
- package/string/getUnescaped.js +26 -0
- package/string/getWithoutAccents.d.ts +5 -0
- package/string/getWithoutAccents.js +13 -0
- package/string/getWithoutHtmlTags.d.ts +5 -0
- package/string/getWithoutHtmlTags.js +12 -0
- package/string/getWithoutPunctuation.d.ts +5 -0
- package/string/getWithoutPunctuation.js +13 -0
- package/string/getWithoutUnderscores.d.ts +4 -0
- package/string/getWithoutUnderscores.js +11 -0
- package/string/getWithoutWhitespaces.d.ts +5 -0
- package/string/getWithoutWhitespaces.js +13 -0
- package/string/index.d.ts +12 -0
- package/string/index.js +27 -0
- package/swr/index.d.ts +42 -0
- package/swr/index.js +59 -0
- package/upTimeRobot/UpTimeRobotNamespace.d.ts +31 -0
- package/upTimeRobot/UpTimeRobotNamespace.js +52 -0
- package/upTimeRobot/index.d.ts +38 -0
- package/upTimeRobot/index.js +63 -0
- package/url/index.d.ts +30 -0
- package/url/index.js +72 -0
- package/url/writeUrlContents.d.ts +6 -0
- package/url/writeUrlContents.js +75 -0
- package/util/defaultTo.d.ts +4 -0
- package/util/defaultTo.js +44 -0
- package/util/getBrotliCompressed.d.ts +5 -0
- package/util/getBrotliCompressed.js +23 -0
- package/util/getBrotliDecompressed.d.ts +5 -0
- package/util/getBrotliDecompressed.js +24 -0
- package/util/getClean.d.ts +11 -0
- package/util/getClean.js +23 -0
- package/util/getGzipCompressed.d.ts +5 -0
- package/util/getGzipCompressed.js +23 -0
- package/util/getGzipDecompressed.d.ts +5 -0
- package/util/getGzipDecompressed.js +24 -0
- package/util/getWithoutHash.d.ts +4 -0
- package/util/getWithoutHash.js +18 -0
- package/util/getWithoutParameter.d.ts +4 -0
- package/util/getWithoutParameter.js +18 -0
- package/util/index.d.ts +11 -0
- package/util/index.js +25 -0
- package/util/isUndefined.d.ts +4 -0
- package/util/isUndefined.js +13 -0
- package/util/promiseChunks.d.ts +5 -0
- package/util/promiseChunks.js +19 -0
- package/util/sleep.d.ts +1 -0
- package/util/sleep.js +7 -0
- package/webWorker/index.d.ts +5 -0
- package/webWorker/index.js +9 -0
- package/xml/getXml.d.ts +1 -0
- package/xml/getXml.js +18 -0
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AwsAthenaNamespace = void 0;
|
|
37
|
+
const _class_1 = require("../../_class");
|
|
38
|
+
class AwsAthenaNamespace extends _class_1.BaseNamespace {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.client = null;
|
|
42
|
+
this.config = null;
|
|
43
|
+
this.ensureInit = async () => {
|
|
44
|
+
if (!this.client) {
|
|
45
|
+
try {
|
|
46
|
+
const athenaExpress = await Promise.resolve().then(() => __importStar(require("athena-express")));
|
|
47
|
+
const awsSdk = await Promise.resolve().then(() => __importStar(require("aws-sdk")));
|
|
48
|
+
const formattedConfig = {
|
|
49
|
+
region: this.config.region,
|
|
50
|
+
accessKeyId: this.config.accessKeyId,
|
|
51
|
+
secretAccessKey: this.config.secretAccessKey,
|
|
52
|
+
};
|
|
53
|
+
// Set the aws authentication
|
|
54
|
+
awsSdk.config.update(formattedConfig);
|
|
55
|
+
this.client = new athenaExpress.AthenaExpress({
|
|
56
|
+
aws: awsSdk,
|
|
57
|
+
s3: `s3://${this.config.s3Bucket}/${this.config.s3Key}`,
|
|
58
|
+
db: this.config.database,
|
|
59
|
+
formatJson: true,
|
|
60
|
+
retry: 200,
|
|
61
|
+
getStats: false,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
catch (e) {
|
|
65
|
+
throw new Error("AWS Athena Client not installed");
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
this.query = async (query) => {
|
|
70
|
+
await this.ensureInit();
|
|
71
|
+
return await this.client.query(query)
|
|
72
|
+
.then(data => {
|
|
73
|
+
let subResponse = [];
|
|
74
|
+
if (undefined !== data["Items"]) {
|
|
75
|
+
subResponse = data["Items"];
|
|
76
|
+
}
|
|
77
|
+
return subResponse;
|
|
78
|
+
});
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.AwsAthenaNamespace = AwsAthenaNamespace;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { AwsAthenaNamespace } from "./AwsAthenaNamespace";
|
|
2
|
+
export type AthenaConfig = {
|
|
3
|
+
region: string;
|
|
4
|
+
accessKeyId: string;
|
|
5
|
+
secretAccessKey: string;
|
|
6
|
+
s3Bucket: string;
|
|
7
|
+
s3Key: string;
|
|
8
|
+
database: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const awsAthenaClient: (key?: string, config?: AthenaConfig, vaultId?: string, itemId?: string) => Promise<AwsAthenaNamespace>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsAthenaClient = void 0;
|
|
4
|
+
const AwsAthenaNamespace_1 = require("./AwsAthenaNamespace");
|
|
5
|
+
const onePassword_1 = require("../../onePassword");
|
|
6
|
+
const awsAthenaNamespaces = new Map();
|
|
7
|
+
const awsAthenaClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
|
+
if (awsAthenaNamespaces.has(key)) {
|
|
9
|
+
return awsAthenaNamespaces.get(key);
|
|
10
|
+
}
|
|
11
|
+
let instanceConfig;
|
|
12
|
+
if (config) {
|
|
13
|
+
instanceConfig = config;
|
|
14
|
+
}
|
|
15
|
+
else if (vaultId && itemId) {
|
|
16
|
+
instanceConfig = await (await (0, onePassword_1.onePasswordClient)())
|
|
17
|
+
.getJsonNote(vaultId, itemId);
|
|
18
|
+
}
|
|
19
|
+
else if ("default" === key && process.env.AWS_VAULT_ID && process.env.AWS_ITEM_ID) {
|
|
20
|
+
instanceConfig = await (await (0, onePassword_1.onePasswordClient)())
|
|
21
|
+
.getJsonNote(process.env.AWS_VAULT_ID, process.env.AWS_ITEM_ID);
|
|
22
|
+
}
|
|
23
|
+
else if ("default" === key && process.env.ATHENA_REGION && process.env.ATHENA_ACCESS_KEY_ID && process.env.ATHENA_SECRET_ACCESS_KEY && process.env.ATHENA_S3_BUCKET && process.env.ATHENA_S3_KEY && process.env.ATHENA_DATABASE) {
|
|
24
|
+
instanceConfig = {
|
|
25
|
+
region: process.env.ATHENA_REGION,
|
|
26
|
+
accessKeyId: process.env.ATHENA_ACCESS_KEY_ID,
|
|
27
|
+
secretAccessKey: process.env.ATHENA_SECRET_ACCESS_KEY,
|
|
28
|
+
s3Bucket: process.env.ATHENA_S3_BUCKET,
|
|
29
|
+
s3Key: process.env.ATHENA_S3_KEY,
|
|
30
|
+
database: process.env.ATHENA_DATABASE,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
throw new Error(`Config required for namespace '${key}'`);
|
|
35
|
+
}
|
|
36
|
+
const namespace = new AwsAthenaNamespace_1.AwsAthenaNamespace(key, instanceConfig);
|
|
37
|
+
awsAthenaNamespaces.set(key, namespace);
|
|
38
|
+
return namespace;
|
|
39
|
+
};
|
|
40
|
+
exports.awsAthenaClient = awsAthenaClient;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
import { AwsConfig } from "../index";
|
|
3
|
+
import type { EC2Client } from "@aws-sdk/client-ec2";
|
|
4
|
+
export declare class AwsEc2Namespace extends BaseNamespace {
|
|
5
|
+
client: EC2Client | null;
|
|
6
|
+
config: AwsConfig;
|
|
7
|
+
ensureInit: () => Promise<void>;
|
|
8
|
+
startInstances: (instanceIds: string[], additionalInfo?: string, dryRun?: boolean) => Promise<any>;
|
|
9
|
+
stopInstances: (instanceIds: string[], hibernate?: boolean, force?: boolean, dryRun?: boolean) => Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AwsEc2Namespace = void 0;
|
|
37
|
+
const _class_1 = require("../../_class");
|
|
38
|
+
class AwsEc2Namespace extends _class_1.BaseNamespace {
|
|
39
|
+
constructor() {
|
|
40
|
+
super(...arguments);
|
|
41
|
+
this.client = null;
|
|
42
|
+
this.ensureInit = async () => {
|
|
43
|
+
if (!this.client) {
|
|
44
|
+
try {
|
|
45
|
+
const { EC2Client } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ec2")));
|
|
46
|
+
this.client = new EC2Client(this.config);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
throw new Error("AWS EC2 Client not installed");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
this.startInstances = async (instanceIds, additionalInfo, dryRun) => {
|
|
54
|
+
await this.ensureInit();
|
|
55
|
+
const { StartInstancesCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ec2")));
|
|
56
|
+
const command = new StartInstancesCommand({
|
|
57
|
+
InstanceIds: instanceIds,
|
|
58
|
+
AdditionalInfo: additionalInfo,
|
|
59
|
+
DryRun: dryRun,
|
|
60
|
+
});
|
|
61
|
+
const response = await global.awsEc2Client.send(command);
|
|
62
|
+
return response;
|
|
63
|
+
};
|
|
64
|
+
this.stopInstances = async (instanceIds, hibernate, force, dryRun) => {
|
|
65
|
+
await this.ensureInit();
|
|
66
|
+
const { StopInstancesCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ec2")));
|
|
67
|
+
const command = new StopInstancesCommand({
|
|
68
|
+
InstanceIds: instanceIds,
|
|
69
|
+
Hibernate: hibernate,
|
|
70
|
+
DryRun: dryRun,
|
|
71
|
+
Force: force,
|
|
72
|
+
});
|
|
73
|
+
const response = await global.awsEc2Client.send(command);
|
|
74
|
+
return response;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.AwsEc2Namespace = AwsEc2Namespace;
|
package/aws/ec2/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsEc2Client = void 0;
|
|
4
|
+
const AwsEc2Namespace_1 = require("./AwsEc2Namespace");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const awsEc2Namespaces = new Map();
|
|
7
|
+
const awsEc2Client = async (key = "default", config, vaultId, itemId) => {
|
|
8
|
+
if (awsEc2Namespaces.has(key)) {
|
|
9
|
+
return awsEc2Namespaces.get(key);
|
|
10
|
+
}
|
|
11
|
+
const instanceConfig = await (0, index_1.getConfig)(key, config, vaultId, itemId);
|
|
12
|
+
const namespace = new AwsEc2Namespace_1.AwsEc2Namespace(key, instanceConfig);
|
|
13
|
+
awsEc2Namespaces.set(key, namespace);
|
|
14
|
+
return namespace;
|
|
15
|
+
};
|
|
16
|
+
exports.awsEc2Client = awsEc2Client;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
import { AwsConfig } from "../index";
|
|
3
|
+
import type { DesiredStatus, ECSClient, LaunchType, NetworkConfiguration, SortOrder, TaskDefinitionStatus, TaskOverride } from "@aws-sdk/client-ecs";
|
|
4
|
+
type GetTaskDefinitionsProps = {
|
|
5
|
+
familyPrefix?: string;
|
|
6
|
+
maxResults?: number;
|
|
7
|
+
sort?: SortOrder;
|
|
8
|
+
status?: TaskDefinitionStatus;
|
|
9
|
+
};
|
|
10
|
+
type GetTasksProps = {
|
|
11
|
+
cluster?: string;
|
|
12
|
+
containerInstance?: string;
|
|
13
|
+
desiredStatus?: DesiredStatus;
|
|
14
|
+
family?: string;
|
|
15
|
+
maxResults?: number;
|
|
16
|
+
serviceName?: string;
|
|
17
|
+
startedBy?: string;
|
|
18
|
+
};
|
|
19
|
+
type RunTaskProps = {
|
|
20
|
+
cluster?: string;
|
|
21
|
+
count?: number;
|
|
22
|
+
launchType?: LaunchType;
|
|
23
|
+
networkConfiguration?: NetworkConfiguration;
|
|
24
|
+
overrides?: TaskOverride;
|
|
25
|
+
taskDefinition?: string;
|
|
26
|
+
};
|
|
27
|
+
export declare class AwsEcsNamespace extends BaseNamespace {
|
|
28
|
+
client: ECSClient | null;
|
|
29
|
+
config: AwsConfig;
|
|
30
|
+
ensureInit: () => Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListClustersCommand/
|
|
33
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/ListClustersCommandInput/
|
|
34
|
+
*/
|
|
35
|
+
getClusters: (maxResults?: number) => Promise<string[]>;
|
|
36
|
+
/**
|
|
37
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListTaskDefinitionsCommand/
|
|
38
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/ListTaskDefinitionsCommandInput/
|
|
39
|
+
*/
|
|
40
|
+
getTaskDefinitions: (props: GetTaskDefinitionsProps) => Promise<string[]>;
|
|
41
|
+
/**
|
|
42
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListTasksCommand/
|
|
43
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/ListTasksCommandInput/
|
|
44
|
+
*/
|
|
45
|
+
getTasks: (props: GetTasksProps) => Promise<string[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Initialise and run a task
|
|
48
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/RunTaskCommand/
|
|
49
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/RunTaskCommandInput/
|
|
50
|
+
*/
|
|
51
|
+
runTask: (props: RunTaskProps) => Promise<boolean>;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AwsEcsNamespace = void 0;
|
|
37
|
+
const _class_1 = require("../../_class");
|
|
38
|
+
const __1 = require("../");
|
|
39
|
+
class AwsEcsNamespace extends _class_1.BaseNamespace {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.client = null;
|
|
43
|
+
this.ensureInit = async () => {
|
|
44
|
+
if (!this.client) {
|
|
45
|
+
try {
|
|
46
|
+
const { ECSClient } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ecs")));
|
|
47
|
+
this.client = new ECSClient(this.config);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new Error("AWS ECS Client not installed");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListClustersCommand/
|
|
56
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/ListClustersCommandInput/
|
|
57
|
+
*/
|
|
58
|
+
this.getClusters = async (maxResults) => {
|
|
59
|
+
await this.ensureInit();
|
|
60
|
+
const { ListClustersCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ecs")));
|
|
61
|
+
let response = [];
|
|
62
|
+
let apiResponse = null;
|
|
63
|
+
while (null === apiResponse || apiResponse?.nextToken) {
|
|
64
|
+
const listClustersCommand = new ListClustersCommand({
|
|
65
|
+
maxResults,
|
|
66
|
+
nextToken: apiResponse?.nextToken,
|
|
67
|
+
});
|
|
68
|
+
apiResponse = await this.client.send(listClustersCommand);
|
|
69
|
+
if ((0, __1.isResponse200)(apiResponse)) {
|
|
70
|
+
response = [
|
|
71
|
+
...response,
|
|
72
|
+
...apiResponse.clusterArns,
|
|
73
|
+
];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
return response;
|
|
77
|
+
};
|
|
78
|
+
/**
|
|
79
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListTaskDefinitionsCommand/
|
|
80
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/ListTaskDefinitionsCommandInput/
|
|
81
|
+
*/
|
|
82
|
+
this.getTaskDefinitions = async (props) => {
|
|
83
|
+
await this.ensureInit();
|
|
84
|
+
const { ListTaskDefinitionsCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ecs")));
|
|
85
|
+
let response = [];
|
|
86
|
+
let apiResponse = null;
|
|
87
|
+
while (null === apiResponse || apiResponse?.nextToken) {
|
|
88
|
+
const listTaskDefinitionsCommand = new ListTaskDefinitionsCommand({
|
|
89
|
+
maxResults: props?.maxResults,
|
|
90
|
+
familyPrefix: props?.familyPrefix,
|
|
91
|
+
sort: props?.sort,
|
|
92
|
+
status: props?.status,
|
|
93
|
+
nextToken: apiResponse?.nextToken,
|
|
94
|
+
});
|
|
95
|
+
apiResponse = await global.awsEcsClient.send(listTaskDefinitionsCommand);
|
|
96
|
+
if ((0, __1.isResponse200)(apiResponse)) {
|
|
97
|
+
response = [
|
|
98
|
+
...response,
|
|
99
|
+
...apiResponse.taskDefinitionArns,
|
|
100
|
+
];
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return response;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/ListTasksCommand/
|
|
107
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/ListTasksCommandInput/
|
|
108
|
+
*/
|
|
109
|
+
this.getTasks = async (props) => {
|
|
110
|
+
await this.ensureInit();
|
|
111
|
+
const { ListTasksCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ecs")));
|
|
112
|
+
let response = [];
|
|
113
|
+
let apiResponse = null;
|
|
114
|
+
while (null === apiResponse || apiResponse?.nextToken) {
|
|
115
|
+
const listTasksCommand = new ListTasksCommand({
|
|
116
|
+
cluster: props?.cluster,
|
|
117
|
+
containerInstance: props?.containerInstance,
|
|
118
|
+
desiredStatus: props?.desiredStatus,
|
|
119
|
+
family: props?.family,
|
|
120
|
+
maxResults: props?.maxResults,
|
|
121
|
+
nextToken: apiResponse?.nextToken,
|
|
122
|
+
serviceName: props?.serviceName,
|
|
123
|
+
startedBy: props?.startedBy,
|
|
124
|
+
});
|
|
125
|
+
apiResponse = await global.awsEcsClient.send(listTasksCommand);
|
|
126
|
+
if ((0, __1.isResponse200)(apiResponse)) {
|
|
127
|
+
response = [
|
|
128
|
+
...response,
|
|
129
|
+
...apiResponse.taskArns,
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return response;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Initialise and run a task
|
|
137
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/ecs/command/RunTaskCommand/
|
|
138
|
+
* https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-ecs/Interface/RunTaskCommandInput/
|
|
139
|
+
*/
|
|
140
|
+
this.runTask = async (props) => {
|
|
141
|
+
await this.ensureInit();
|
|
142
|
+
const { RunTaskCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-ecs")));
|
|
143
|
+
let response = false;
|
|
144
|
+
const runtTaskCommand = new RunTaskCommand({
|
|
145
|
+
cluster: props?.cluster,
|
|
146
|
+
launchType: props?.launchType,
|
|
147
|
+
networkConfiguration: props?.networkConfiguration,
|
|
148
|
+
overrides: props?.overrides,
|
|
149
|
+
taskDefinition: props?.taskDefinition,
|
|
150
|
+
});
|
|
151
|
+
const apiResponse = await global.awsEcsClient.send(runtTaskCommand);
|
|
152
|
+
if ((0, __1.isResponse200)(apiResponse)) {
|
|
153
|
+
response = apiResponse;
|
|
154
|
+
}
|
|
155
|
+
return response;
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
exports.AwsEcsNamespace = AwsEcsNamespace;
|
package/aws/ecs/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsEcsClient = void 0;
|
|
4
|
+
const AwsEcsNamespace_1 = require("./AwsEcsNamespace");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const awsEcsNamespaces = new Map();
|
|
7
|
+
const awsEcsClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
|
+
if (awsEcsNamespaces.has(key)) {
|
|
9
|
+
return awsEcsNamespaces.get(key);
|
|
10
|
+
}
|
|
11
|
+
const instanceConfig = await (0, index_1.getConfig)(key, config, vaultId, itemId);
|
|
12
|
+
const namespace = new AwsEcsNamespace_1.AwsEcsNamespace(key, instanceConfig);
|
|
13
|
+
awsEcsNamespaces.set(key, namespace);
|
|
14
|
+
return namespace;
|
|
15
|
+
};
|
|
16
|
+
exports.awsEcsClient = awsEcsClient;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
import { AwsConfig } from "../index";
|
|
3
|
+
import type { GlueClient } from "@aws-sdk/client-glue";
|
|
4
|
+
export declare class AwsGlueNamespace extends BaseNamespace {
|
|
5
|
+
client: GlueClient | null;
|
|
6
|
+
config: AwsConfig;
|
|
7
|
+
ensureInit: () => Promise<void>;
|
|
8
|
+
/**
|
|
9
|
+
* Invoke an AWS Glue Crawler by passing in the name of the Crawler.
|
|
10
|
+
*/
|
|
11
|
+
invoke: (crawler: string) => Promise<boolean>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.AwsGlueNamespace = void 0;
|
|
37
|
+
const _class_1 = require("../../_class");
|
|
38
|
+
const __1 = require("../");
|
|
39
|
+
class AwsGlueNamespace extends _class_1.BaseNamespace {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
this.client = null;
|
|
43
|
+
this.ensureInit = async () => {
|
|
44
|
+
if (!this.client) {
|
|
45
|
+
try {
|
|
46
|
+
const { GlueClient } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-glue")));
|
|
47
|
+
this.client = new GlueClient(this.config);
|
|
48
|
+
}
|
|
49
|
+
catch (e) {
|
|
50
|
+
throw new Error("AWS Glue Client not installed");
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Invoke an AWS Glue Crawler by passing in the name of the Crawler.
|
|
56
|
+
*/
|
|
57
|
+
this.invoke = async (crawler) => {
|
|
58
|
+
await this.ensureInit();
|
|
59
|
+
const { StartCrawlerCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-glue")));
|
|
60
|
+
const command = new StartCrawlerCommand({
|
|
61
|
+
Name: crawler,
|
|
62
|
+
});
|
|
63
|
+
// Fire the event but don't wait for it to complete
|
|
64
|
+
const apiResponse = await this.client.send(command);
|
|
65
|
+
// Success
|
|
66
|
+
return (0, __1.isResponse200)(apiResponse);
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
exports.AwsGlueNamespace = AwsGlueNamespace;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.awsGlueClient = void 0;
|
|
4
|
+
const AwsGlueNamespace_1 = require("./AwsGlueNamespace");
|
|
5
|
+
const index_1 = require("../index");
|
|
6
|
+
const awsGlueNamespaces = new Map();
|
|
7
|
+
const awsGlueClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
|
+
if (awsGlueNamespaces.has(key)) {
|
|
9
|
+
return awsGlueNamespaces.get(key);
|
|
10
|
+
}
|
|
11
|
+
const instanceConfig = await (0, index_1.getConfig)(key, config, vaultId, itemId);
|
|
12
|
+
const namespace = new AwsGlueNamespace_1.AwsGlueNamespace(key, instanceConfig);
|
|
13
|
+
awsGlueNamespaces.set(key, namespace);
|
|
14
|
+
return namespace;
|
|
15
|
+
};
|
|
16
|
+
exports.awsGlueClient = awsGlueClient;
|
package/aws/index.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type AwsConfig = {
|
|
2
|
+
region: string;
|
|
3
|
+
credentials: {
|
|
4
|
+
accessKeyId: string;
|
|
5
|
+
secretAccessKey: string;
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
export declare const getConfig: (key: any, config?: AwsConfig, vaultId?: string, itemId?: string) => Promise<AwsConfig>;
|
|
9
|
+
export { isResponse200 } from "./isResponse200";
|
package/aws/index.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isResponse200 = exports.getConfig = void 0;
|
|
4
|
+
const onePassword_1 = require("../onePassword");
|
|
5
|
+
const getConfig = async (key, config, vaultId, itemId) => {
|
|
6
|
+
let response;
|
|
7
|
+
if (config) {
|
|
8
|
+
response = config;
|
|
9
|
+
}
|
|
10
|
+
else if (vaultId && itemId) {
|
|
11
|
+
response = await (await (0, onePassword_1.onePasswordClient)())
|
|
12
|
+
.getJsonNote(vaultId, itemId);
|
|
13
|
+
}
|
|
14
|
+
else if ("default" === key && process.env.AWS_VAULT_ID && process.env.AWS_ITEM_ID) {
|
|
15
|
+
response = await (await (0, onePassword_1.onePasswordClient)())
|
|
16
|
+
.getJsonNote(process.env.AWS_VAULT_ID, process.env.AWS_ITEM_ID);
|
|
17
|
+
}
|
|
18
|
+
else if ("default" === key && process.env.AWS_ACCESS_KEY_ID && process.env.AWS_REGION && process.env.AWS_SECRET_ACCESS_KEY) {
|
|
19
|
+
response = {
|
|
20
|
+
region: process.env.AWS_REGION,
|
|
21
|
+
credentials: {
|
|
22
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
23
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
throw new Error(`Config required for namespace '${key}'`);
|
|
29
|
+
}
|
|
30
|
+
return response;
|
|
31
|
+
};
|
|
32
|
+
exports.getConfig = getConfig;
|
|
33
|
+
var isResponse200_1 = require("./isResponse200");
|
|
34
|
+
Object.defineProperty(exports, "isResponse200", { enumerable: true, get: function () { return isResponse200_1.isResponse200; } });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isResponse200 = void 0;
|
|
4
|
+
const util_1 = require("../util");
|
|
5
|
+
/**
|
|
6
|
+
* Was the API response a 200?
|
|
7
|
+
*/
|
|
8
|
+
const isResponse200 = (apiResponse) => {
|
|
9
|
+
let response = false;
|
|
10
|
+
const responseCode = (0, util_1.defaultTo)(apiResponse, ["$metadata", "httpStatusCode"], 0);
|
|
11
|
+
if (200 === responseCode) {
|
|
12
|
+
response = true;
|
|
13
|
+
}
|
|
14
|
+
return response;
|
|
15
|
+
};
|
|
16
|
+
exports.isResponse200 = isResponse200;
|