@8ms/helpers 2.2.9 → 2.2.10
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/_class/BaseClass.js +43 -52
- package/_class/BaseNamespace.js +17 -20
- package/_class/index.js +2 -7
- package/adverity/getJobs.js +7 -11
- package/adverity/index.js +51 -54
- package/adverity/server.js +1 -5
- package/api/ApiResponseClass.js +84 -88
- package/api/functions.js +13 -22
- package/api/index.js +3 -19
- package/api/types.js +5 -9
- package/array/index.js +3 -11
- package/atInternet/index.js +10 -13
- package/aws/ec2/AwsEc2Namespace.js +34 -74
- package/aws/ec2/server.js +5 -9
- package/aws/ecs/AwsEcsNamespace.js +110 -150
- package/aws/ecs/server.js +5 -9
- package/aws/glue/AwsGlueNamespace.js +26 -66
- package/aws/glue/server.js +5 -9
- package/aws/isResponse200.js +3 -7
- package/aws/lambda/AwsLambdaNamespace.js +62 -102
- package/aws/lambda/server.js +6 -11
- package/aws/s3/AwsS3Namespace.js +347 -390
- package/aws/s3/payload.js +29 -32
- package/aws/s3/server.js +9 -14
- package/aws/server.js +5 -10
- package/aws/ses/AwsSesNamespace.js +36 -76
- package/aws/ses/SimpleEmail.js +267 -304
- package/aws/ses/server.js +6 -11
- package/aws/sqs/AwsSqsNamespace.js +49 -89
- package/aws/sqs/server.js +5 -9
- package/aws/ssm/AwsSsmNamespace.js +43 -79
- package/aws/ssm/server.js +5 -9
- package/axios/deleteRequest.js +8 -15
- package/axios/get.js +8 -15
- package/axios/index.js +3 -9
- package/axios/post.js +8 -15
- package/boolean/index.js +3 -10
- package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
- package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
- package/brightData/serpApi/getAsyncRequestId.js +8 -12
- package/brightData/serpApi/getAsyncResults.js +8 -12
- package/brightData/serpApi/getRealtime.js +3 -7
- package/brightData/serpApi/server.js +6 -14
- package/brightData/server.js +2 -7
- package/brightData/webScraperIde/getBatch.js +3 -7
- package/brightData/webScraperIde/getRealtime.js +11 -15
- package/brightData/webScraperIde/server.js +2 -7
- package/cache/server.js +2 -7
- package/cache/test/cache.test.js +4 -6
- package/crud/index.js +1 -4
- package/crypto/getDecrypt.js +2 -39
- package/crypto/getEncrypt.js +2 -39
- package/crypto/getRandom.js +1 -5
- package/crypto/getSha256.js +4 -41
- package/crypto/index.js +4 -11
- package/date/calculation.js +70 -99
- package/date/financialYear.js +16 -23
- package/date/format.js +40 -61
- package/date/index.js +4 -20
- package/date/type.js +4 -7
- package/environment/index.js +15 -25
- package/eskimi/getAgeGroup.js +3 -7
- package/eskimi/getData.js +3 -7
- package/eskimi/getDevice.js +3 -7
- package/eskimi/getGender.js +3 -7
- package/eskimi/server.js +23 -26
- package/file/index.js +8 -46
- package/geo/countries.js +1 -4
- package/geo/index.js +2 -7
- package/geo/languages.js +1 -4
- package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
- package/google/bigQuery/loadData.js +1 -5
- package/google/bigQuery/server.js +8 -14
- package/google/server.js +1 -5
- package/google/sheets/GoogleSheetsNamespace.js +34 -74
- package/google/sheets/getAssociatedData.js +1 -5
- package/google/sheets/server.js +8 -14
- package/google/storage/GoogleCloudStorageNamespace.js +62 -102
- package/google/storage/server.js +6 -10
- package/googleAds/GoogleAdsNamespace.js +28 -68
- package/googleAds/keywordPlanner/server.js +32 -35
- package/googleAds/server.js +6 -10
- package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
- package/googlePageSpeed/server.js +8 -12
- package/googleSearchIncidents/server.js +28 -32
- package/greenDomain/server.js +17 -21
- package/inngest/server.js +1 -4
- package/json/getJsonNewline.js +3 -7
- package/json/index.js +2 -7
- package/json/isJson.js +1 -5
- package/littleWarden/LittleWardenNamespace.js +24 -31
- package/littleWarden/getUrlStatus.js +3 -7
- package/littleWarden/server.js +14 -22
- package/lumar/api/buildRequest.js +14 -18
- package/lumar/api/getData.js +3 -7
- package/lumar/api/initClient.js +3 -7
- package/lumar/api/server.js +6 -12
- package/lumar/graphql/columns.js +1 -4
- package/lumar/graphql/getData.js +3 -7
- package/lumar/graphql/initClient.js +3 -7
- package/lumar/graphql/queries/crawl.js +1 -2
- package/lumar/graphql/queries/getCrawls.js +1 -3
- package/lumar/graphql/queries/getReportDifferences.js +3 -5
- package/lumar/graphql/queries/getRows.js +1 -3
- package/lumar/graphql/queries/getTotals.js +1 -3
- package/lumar/graphql/queries/row.js +1 -2
- package/lumar/graphql/reportTemplates.js +1 -4
- package/lumar/graphql/server.js +7 -15
- package/myTarget/server.js +3 -7
- package/nextAuth/index.js +2 -6
- package/nextAuth/isSessionReady.js +1 -5
- package/nextJs/client/LazyLoad.js +5 -12
- package/nextJs/client.js +1 -5
- package/nextJs/index.js +2 -7
- package/number/format.js +3 -7
- package/number/formatCurrency.js +1 -5
- package/number/getDecimal.js +3 -7
- package/number/getNumber.js +3 -7
- package/number/getPercentIncrease.js +4 -8
- package/number/getSafeDivide.js +6 -10
- package/number/index.js +6 -15
- package/object/index.js +1 -5
- package/object/replaceKeys.js +3 -7
- package/onePassword/OnePasswordNamespace.js +36 -76
- package/onePassword/server.js +3 -7
- package/openAi/OpenAiNamespace.js +32 -39
- package/openAi/server.js +6 -10
- package/package.json +7 -1
- package/prisma/PrismaNamespace.js +53 -93
- package/prisma/getDecimal.js +5 -12
- package/prisma/server.js +4 -9
- package/snapchat/SnapchatNamespace.js +20 -27
- package/snapchat/server.js +6 -10
- package/sorting/byNumberAscending.js +1 -5
- package/sorting/byNumberDescending.js +1 -5
- package/sorting/byStringAscending.js +1 -5
- package/sorting/byStringDescending.js +1 -5
- package/sorting/index.js +4 -11
- package/stream/server.js +1 -5
- package/stream/sort.js +1 -5
- package/string/getCapitalised.js +3 -7
- package/string/getClean.js +17 -21
- package/string/getFolder.js +3 -10
- package/string/getProperCase.js +4 -8
- package/string/getString.js +8 -15
- package/string/getStringFromStream.js +1 -5
- package/string/getUnescaped.js +3 -10
- package/string/getWithoutAccents.js +1 -5
- package/string/getWithoutHtmlTags.js +1 -5
- package/string/getWithoutPunctuation.js +1 -5
- package/string/getWithoutUnderscores.js +1 -5
- package/string/getWithoutWhitespaces.js +1 -5
- package/string/index.js +12 -27
- package/string/reservedWords.js +5 -9
- package/swr/index.js +9 -18
- package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
- package/upTimeRobot/server.js +11 -15
- package/url/index.js +12 -23
- package/url/server.js +1 -5
- package/url/writeUrlContents.js +6 -46
- package/util/defaultTo.js +5 -12
- package/util/getBrotliCompressed.js +3 -10
- package/util/getBrotliDecompressed.js +3 -10
- package/util/getClean.js +5 -9
- package/util/getError.js +1 -5
- package/util/getGzipCompressed.js +3 -10
- package/util/getGzipDecompressed.js +3 -10
- package/util/getWithoutHash.js +1 -5
- package/util/getWithoutParameter.js +1 -5
- package/util/index.js +7 -17
- package/util/isUndefined.js +3 -7
- package/util/promiseChunks.js +6 -10
- package/util/server.js +4 -11
- package/util/sleep.js +1 -5
- package/webWorker/index.js +1 -4
- package/xml/getXml.js +3 -7
|
@@ -1,95 +1,55 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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.AwsSqsNamespace = void 0;
|
|
37
|
-
const _class_1 = require("../../_class");
|
|
38
|
-
class AwsSqsNamespace extends _class_1.BaseNamespace {
|
|
39
|
-
constructor() {
|
|
40
|
-
super(...arguments);
|
|
41
|
-
this.ensureInit = async () => {
|
|
42
|
-
if (!this.client) {
|
|
43
|
-
try {
|
|
44
|
-
const { SQSClient } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-sqs")));
|
|
45
|
-
this.client = new SQSClient(this.config);
|
|
46
|
-
}
|
|
47
|
-
catch (e) {
|
|
48
|
-
throw new Error("AWS SQS Client not installed");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
this.addToQueue = async (props) => {
|
|
53
|
-
await this.ensureInit();
|
|
54
|
-
const { SendMessageCommand } = await Promise.resolve().then(() => __importStar(require("@aws-sdk/client-sqs")));
|
|
55
|
-
let params = {
|
|
56
|
-
MessageBody: JSON.stringify({
|
|
57
|
-
queueId: props.queueId,
|
|
58
|
-
data: props.data,
|
|
59
|
-
}),
|
|
60
|
-
QueueUrl: props.queueUrl,
|
|
61
|
-
};
|
|
62
|
-
// Required for FIFO
|
|
63
|
-
if (undefined !== props?.dedupeId) {
|
|
64
|
-
params["MessageDeduplicationId"] = props.dedupeId;
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
export class AwsSqsNamespace extends BaseNamespace {
|
|
3
|
+
ensureInit = async () => {
|
|
4
|
+
if (!this.client) {
|
|
5
|
+
try {
|
|
6
|
+
const { SQSClient } = await import("@aws-sdk/client-sqs");
|
|
7
|
+
this.client = new SQSClient(this.config);
|
|
65
8
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
params["MessageGroupId"] = props.dedupeId;
|
|
9
|
+
catch (e) {
|
|
10
|
+
throw new Error("AWS SQS Client not installed");
|
|
69
11
|
}
|
|
70
|
-
|
|
71
|
-
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
addToQueue = async (props) => {
|
|
15
|
+
await this.ensureInit();
|
|
16
|
+
const { SendMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
17
|
+
let params = {
|
|
18
|
+
MessageBody: JSON.stringify({
|
|
19
|
+
queueId: props.queueId,
|
|
20
|
+
data: props.data,
|
|
21
|
+
}),
|
|
22
|
+
QueueUrl: props.queueUrl,
|
|
72
23
|
};
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
24
|
+
// Required for FIFO
|
|
25
|
+
if (undefined !== props?.dedupeId) {
|
|
26
|
+
params["MessageDeduplicationId"] = props.dedupeId;
|
|
27
|
+
}
|
|
28
|
+
// Required for FIFO
|
|
29
|
+
if (undefined !== props?.groupId) {
|
|
30
|
+
params["MessageGroupId"] = props.dedupeId;
|
|
31
|
+
}
|
|
32
|
+
const sendData = await this.client.send(new SendMessageCommand(params));
|
|
33
|
+
return sendData;
|
|
34
|
+
};
|
|
35
|
+
deleteFromQueue = async (queueUrl, recipientHandle) => {
|
|
36
|
+
await this.ensureInit();
|
|
37
|
+
const { DeleteMessageCommand } = await import("@aws-sdk/client-sqs");
|
|
38
|
+
const params = {
|
|
39
|
+
QueueUrl: queueUrl,
|
|
40
|
+
ReceiptHandle: recipientHandle,
|
|
82
41
|
};
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
42
|
+
const sendData = await this.client.send(new DeleteMessageCommand(params));
|
|
43
|
+
return sendData;
|
|
44
|
+
};
|
|
45
|
+
isEventSqs = async (event) => {
|
|
46
|
+
await this.ensureInit();
|
|
47
|
+
let response = false;
|
|
48
|
+
if (undefined !== event["Records"]) {
|
|
49
|
+
for (let i = 0; i < event['Records'].length; i++) {
|
|
50
|
+
// todo: Complete
|
|
90
51
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
52
|
+
}
|
|
53
|
+
return response;
|
|
54
|
+
};
|
|
94
55
|
}
|
|
95
|
-
exports.AwsSqsNamespace = AwsSqsNamespace;
|
package/aws/sqs/server.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.awsSqsClient = void 0;
|
|
4
|
-
const AwsSqsNamespace_1 = require("./AwsSqsNamespace");
|
|
5
|
-
const server_1 = require("../server");
|
|
1
|
+
import { AwsSqsNamespace } from "./AwsSqsNamespace";
|
|
2
|
+
import { getConfig } from "../server";
|
|
6
3
|
const awsSqsNamespaces = new Map();
|
|
7
|
-
const awsSqsClient = async (key = "default", config, vaultId, itemId) => {
|
|
4
|
+
export const awsSqsClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
5
|
if (awsSqsNamespaces.has(key)) {
|
|
9
6
|
return awsSqsNamespaces.get(key);
|
|
10
7
|
}
|
|
11
|
-
const instanceConfig = await
|
|
12
|
-
const namespace = new
|
|
8
|
+
const instanceConfig = await getConfig(key, config, vaultId, itemId);
|
|
9
|
+
const namespace = new AwsSqsNamespace(key, instanceConfig);
|
|
13
10
|
awsSqsNamespaces.set(key, namespace);
|
|
14
11
|
return namespace;
|
|
15
12
|
};
|
|
16
|
-
exports.awsSqsClient = awsSqsClient;
|
|
@@ -1,88 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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.AwsSsmNamespace = void 0;
|
|
37
|
-
const _class_1 = require("../../_class");
|
|
38
|
-
class AwsSsmNamespace extends _class_1.BaseNamespace {
|
|
1
|
+
import { BaseNamespace } from "../../_class";
|
|
2
|
+
export class AwsSsmNamespace extends BaseNamespace {
|
|
3
|
+
parameters;
|
|
39
4
|
constructor(key, config) {
|
|
40
5
|
super(key, config);
|
|
41
|
-
this.
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
6
|
+
this.parameters = new Map();
|
|
7
|
+
}
|
|
8
|
+
ensureInit = async () => {
|
|
9
|
+
if (!this.client) {
|
|
10
|
+
try {
|
|
11
|
+
const { SSMClient } = await import("@aws-sdk/client-ssm");
|
|
12
|
+
this.client = new SSMClient(this.config);
|
|
13
|
+
}
|
|
14
|
+
catch (e) {
|
|
15
|
+
throw new Error("AWS SSM Client not installed");
|
|
50
16
|
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
getParameter = async (name, withDecryption = false, isJson = true) => {
|
|
20
|
+
await this.ensureInit();
|
|
21
|
+
if (!this.parameters.has(name)) {
|
|
22
|
+
const { GetParameterCommand } = await import("@aws-sdk/client-ssm");
|
|
23
|
+
const apiResponse = await this.client.send(new GetParameterCommand({
|
|
24
|
+
Name: name,
|
|
25
|
+
WithDecryption: undefined === withDecryption ? true : withDecryption,
|
|
26
|
+
}));
|
|
27
|
+
if (apiResponse.Parameter.Value) {
|
|
28
|
+
// Value is undefined
|
|
29
|
+
if (undefined === apiResponse.Parameter.Value) {
|
|
30
|
+
this.parameters.set(name, null);
|
|
31
|
+
}
|
|
32
|
+
// Value is defined
|
|
33
|
+
else {
|
|
34
|
+
// isJson is default - decode
|
|
35
|
+
if (undefined === isJson || true === isJson) {
|
|
36
|
+
this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
|
|
64
37
|
}
|
|
65
|
-
//
|
|
38
|
+
// Not JSON don't decode
|
|
66
39
|
else {
|
|
67
|
-
|
|
68
|
-
if (undefined === isJson || true === isJson) {
|
|
69
|
-
this.parameters.set(name, JSON.parse(apiResponse.Parameter.Value) || null);
|
|
70
|
-
}
|
|
71
|
-
// Not JSON don't decode
|
|
72
|
-
else {
|
|
73
|
-
this.parameters.set(name, apiResponse.Parameter.Value);
|
|
74
|
-
}
|
|
40
|
+
this.parameters.set(name, apiResponse.Parameter.Value);
|
|
75
41
|
}
|
|
76
42
|
}
|
|
77
|
-
// Value not found (null so it can be sent from server to front end)
|
|
78
|
-
else {
|
|
79
|
-
this.parameters.set(name, null);
|
|
80
|
-
}
|
|
81
43
|
}
|
|
82
|
-
//
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
44
|
+
// Value not found (null so it can be sent from server to front end)
|
|
45
|
+
else {
|
|
46
|
+
this.parameters.set(name, null);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
// Return the loaded result
|
|
50
|
+
return this.parameters.get(name);
|
|
51
|
+
};
|
|
87
52
|
}
|
|
88
|
-
exports.AwsSsmNamespace = AwsSsmNamespace;
|
package/aws/ssm/server.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.awsSsmClient = void 0;
|
|
4
|
-
const AwsSsmNamespace_1 = require("./AwsSsmNamespace");
|
|
5
|
-
const server_1 = require("../server");
|
|
1
|
+
import { AwsSsmNamespace } from "./AwsSsmNamespace";
|
|
2
|
+
import { getConfig } from "../server";
|
|
6
3
|
const awsSsmNamespaces = new Map();
|
|
7
|
-
const awsSsmClient = async (key = "default", config, vaultId, itemId) => {
|
|
4
|
+
export const awsSsmClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
5
|
if (awsSsmNamespaces.has(key)) {
|
|
9
6
|
return awsSsmNamespaces.get(key);
|
|
10
7
|
}
|
|
11
|
-
const instanceConfig = await
|
|
12
|
-
const namespace = new
|
|
8
|
+
const instanceConfig = await getConfig(key, config, vaultId, itemId);
|
|
9
|
+
const namespace = new AwsSsmNamespace(key, instanceConfig);
|
|
13
10
|
awsSsmNamespaces.set(key, namespace);
|
|
14
11
|
return namespace;
|
|
15
12
|
};
|
|
16
|
-
exports.awsSsmClient = awsSsmClient;
|
package/axios/deleteRequest.js
CHANGED
|
@@ -1,33 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.deleteRequest = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const api_1 = require("../api");
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { ApiResponseClass } from "../api";
|
|
9
3
|
/**
|
|
10
4
|
* Make a DELETE request.
|
|
11
5
|
* Can't use the function name delete as it's reserved
|
|
12
6
|
*/
|
|
13
|
-
const deleteRequest = async (url, config = {}) => {
|
|
14
|
-
const response = await
|
|
7
|
+
export const deleteRequest = async (url, config = {}) => {
|
|
8
|
+
const response = await axios.delete(url, config)
|
|
15
9
|
.then(async (response) => {
|
|
16
10
|
// Is API response
|
|
17
11
|
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
18
|
-
return new
|
|
12
|
+
return new ApiResponseClass(response.data);
|
|
19
13
|
}
|
|
20
14
|
// General success - some APIs report 201
|
|
21
15
|
else if (response.status >= 200 && response.status <= 299) {
|
|
22
|
-
return (new
|
|
16
|
+
return (new ApiResponseClass()).setToSuccess(response.data);
|
|
23
17
|
}
|
|
24
18
|
// Error
|
|
25
|
-
return (new
|
|
19
|
+
return (new ApiResponseClass()).setToError(response.data, response.statusText);
|
|
26
20
|
})
|
|
27
21
|
.catch(error => {
|
|
28
22
|
// Error
|
|
29
|
-
return (new
|
|
23
|
+
return (new ApiResponseClass()).setToError(null, error.message);
|
|
30
24
|
});
|
|
31
25
|
return response;
|
|
32
26
|
};
|
|
33
|
-
exports.deleteRequest = deleteRequest;
|
package/axios/get.js
CHANGED
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.get = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const api_1 = require("../api");
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { ApiResponseClass } from "../api";
|
|
9
3
|
/**
|
|
10
4
|
* Make a GET request.
|
|
11
5
|
*/
|
|
12
|
-
const get = async (url, config = {}) => {
|
|
13
|
-
const response = await
|
|
6
|
+
export const get = async (url, config = {}) => {
|
|
7
|
+
const response = await axios.get(url, config)
|
|
14
8
|
.then(async (response) => {
|
|
15
9
|
// Is API response
|
|
16
10
|
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
17
|
-
return new
|
|
11
|
+
return new ApiResponseClass(response.data);
|
|
18
12
|
}
|
|
19
13
|
// General success - some APIs report 201
|
|
20
14
|
else if (response.status >= 200 && response.status <= 299) {
|
|
21
|
-
return (new
|
|
15
|
+
return (new ApiResponseClass()).setToSuccess(response.data);
|
|
22
16
|
}
|
|
23
17
|
// Error
|
|
24
|
-
return (new
|
|
18
|
+
return (new ApiResponseClass()).setToError(response.data, response.statusText);
|
|
25
19
|
})
|
|
26
20
|
.catch(error => {
|
|
27
|
-
return (new
|
|
21
|
+
return (new ApiResponseClass()).setToError(null, error.message);
|
|
28
22
|
});
|
|
29
23
|
return response;
|
|
30
24
|
};
|
|
31
|
-
exports.get = get;
|
package/axios/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var get_1 = require("./get");
|
|
5
|
-
Object.defineProperty(exports, "get", { enumerable: true, get: function () { return get_1.get; } });
|
|
6
|
-
var post_1 = require("./post");
|
|
7
|
-
Object.defineProperty(exports, "post", { enumerable: true, get: function () { return post_1.post; } });
|
|
8
|
-
var deleteRequest_1 = require("./deleteRequest");
|
|
9
|
-
Object.defineProperty(exports, "deleteRequest", { enumerable: true, get: function () { return deleteRequest_1.deleteRequest; } });
|
|
1
|
+
export { get } from "./get";
|
|
2
|
+
export { post } from "./post";
|
|
3
|
+
export { deleteRequest } from "./deleteRequest";
|
package/axios/post.js
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.post = void 0;
|
|
7
|
-
const axios_1 = __importDefault(require("axios"));
|
|
8
|
-
const api_1 = require("../api");
|
|
1
|
+
import axios from "axios";
|
|
2
|
+
import { ApiResponseClass } from "../api";
|
|
9
3
|
/**
|
|
10
4
|
* Make a POST request.
|
|
11
5
|
*/
|
|
12
|
-
const post = async (url, data = {}, config = {}) => {
|
|
13
|
-
const response = await
|
|
6
|
+
export const post = async (url, data = {}, config = {}) => {
|
|
7
|
+
const response = await axios.post(url, data, config)
|
|
14
8
|
.then(async (response) => {
|
|
15
9
|
// Is API response
|
|
16
10
|
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
17
|
-
return new
|
|
11
|
+
return new ApiResponseClass(response.data);
|
|
18
12
|
}
|
|
19
13
|
// General success - some APIs report 201
|
|
20
14
|
else if (response.status >= 200 && response.status <= 299) {
|
|
21
|
-
return (new
|
|
15
|
+
return (new ApiResponseClass()).setToSuccess(response.data);
|
|
22
16
|
}
|
|
23
17
|
// Error
|
|
24
|
-
return (new
|
|
18
|
+
return (new ApiResponseClass()).setToError(response.data, response.statusText);
|
|
25
19
|
})
|
|
26
20
|
.catch(error => {
|
|
27
21
|
// Error
|
|
28
|
-
return (new
|
|
22
|
+
return (new ApiResponseClass()).setToError(null, error.message);
|
|
29
23
|
});
|
|
30
24
|
return response;
|
|
31
25
|
};
|
|
32
|
-
exports.post = post;
|
package/boolean/index.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
|
|
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
|
-
exports.getBoolean = void 0;
|
|
7
|
-
const isBoolean_1 = __importDefault(require("lodash/isBoolean"));
|
|
1
|
+
import isBoolean from "lodash/isBoolean";
|
|
8
2
|
/**
|
|
9
3
|
* Convert an input from a variety of forms into boolean.
|
|
10
4
|
*/
|
|
11
|
-
const getBoolean = (input, defaultValue = false) => {
|
|
12
|
-
if ((
|
|
5
|
+
export const getBoolean = (input, defaultValue = false) => {
|
|
6
|
+
if (isBoolean(input)) {
|
|
13
7
|
return input;
|
|
14
8
|
}
|
|
15
9
|
else if ("string" === typeof input) {
|
|
@@ -20,4 +14,3 @@ const getBoolean = (input, defaultValue = false) => {
|
|
|
20
14
|
}
|
|
21
15
|
return defaultValue;
|
|
22
16
|
};
|
|
23
|
-
exports.getBoolean = getBoolean;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildGoogleSerpUrl = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Construct the Google SERP url using Bright Data's API:
|
|
6
3
|
* https://brightdata.com/cp/serp_api/api/google/search?id=c_2cef083f
|
|
@@ -8,7 +5,7 @@ exports.buildGoogleSerpUrl = void 0;
|
|
|
8
5
|
* For geolocation use value from:
|
|
9
6
|
* https://developers.google.com/google-ads/api/data/geotargets
|
|
10
7
|
*/
|
|
11
|
-
const buildGoogleSerpUrl = (props) => {
|
|
8
|
+
export const buildGoogleSerpUrl = (props) => {
|
|
12
9
|
let url = new URL(`https://www.${props.googleDomain}/search`);
|
|
13
10
|
let params = {
|
|
14
11
|
query: {
|
|
@@ -113,4 +110,3 @@ const buildGoogleSerpUrl = (props) => {
|
|
|
113
110
|
}
|
|
114
111
|
return url.toString();
|
|
115
112
|
};
|
|
116
|
-
exports.buildGoogleSerpUrl = buildGoogleSerpUrl;
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildGoogleTrendsUrl = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Construct the Google Trends url using Bright Data's API:
|
|
6
3
|
* https://brightdata.com/cp/serp_api/api/google/trends?id=c_2cef083f
|
|
@@ -8,7 +5,7 @@ exports.buildGoogleTrendsUrl = void 0;
|
|
|
8
5
|
* For category use value from:
|
|
9
6
|
* https://trends.google.com/trends/api/explore/pickers/category?lang=en-US&tz=240
|
|
10
7
|
*/
|
|
11
|
-
const buildGoogleTrendsUrl = (props) => {
|
|
8
|
+
export const buildGoogleTrendsUrl = (props) => {
|
|
12
9
|
let url = new URL(`http://trends.google.com/trends/explore`);
|
|
13
10
|
url.searchParams.append("q", props.query);
|
|
14
11
|
let params = {
|
|
@@ -58,4 +55,3 @@ const buildGoogleTrendsUrl = (props) => {
|
|
|
58
55
|
}
|
|
59
56
|
return url.toString();
|
|
60
57
|
};
|
|
61
|
-
exports.buildGoogleTrendsUrl = buildGoogleTrendsUrl;
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
5
|
-
const server_1 = require("../server");
|
|
6
|
-
const server_2 = require("./server");
|
|
1
|
+
import { post } from "../../axios";
|
|
2
|
+
import { getCustomerId, getZone } from "../server";
|
|
3
|
+
import { BrightDataSerpApiType } from "./server";
|
|
7
4
|
/**
|
|
8
5
|
* Make an async request to the SERP API using the Bright Data proxy.
|
|
9
6
|
* Returns a request ID used with getAsyncResults
|
|
10
7
|
* https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
|
|
11
8
|
*/
|
|
12
|
-
const getAsyncRequestId = async (auth, data = {}, type) => {
|
|
9
|
+
export const getAsyncRequestId = async (auth, data = {}, type) => {
|
|
13
10
|
let url = "";
|
|
14
11
|
let response = "";
|
|
15
12
|
// Prevent auth requests getting blocked
|
|
16
13
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
17
|
-
const customerId =
|
|
18
|
-
const zone =
|
|
14
|
+
const customerId = getCustomerId(auth);
|
|
15
|
+
const zone = getZone(auth);
|
|
19
16
|
switch (type) {
|
|
20
|
-
case
|
|
17
|
+
case BrightDataSerpApiType.GOOGLE_TRENDS:
|
|
21
18
|
url = `https://api.brightdata.com/serp/trends?customer=${customerId}&zone=${zone}`;
|
|
22
19
|
break;
|
|
23
20
|
default:
|
|
24
21
|
url = `https://api.brightdata.com/serp/req?customer=${customerId}&zone=${zone}`;
|
|
25
22
|
}
|
|
26
|
-
const requestResponse = await
|
|
23
|
+
const requestResponse = await post(url, data, {
|
|
27
24
|
headers: {
|
|
28
25
|
Authorization: `Bearer ${auth.apiKey}`
|
|
29
26
|
},
|
|
@@ -33,4 +30,3 @@ const getAsyncRequestId = async (auth, data = {}, type) => {
|
|
|
33
30
|
}
|
|
34
31
|
return response;
|
|
35
32
|
};
|
|
36
|
-
exports.getAsyncRequestId = getAsyncRequestId;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
5
|
-
const server_1 = require("../server");
|
|
6
|
-
const api_1 = require("../../api");
|
|
1
|
+
import { get } from "../../axios";
|
|
2
|
+
import { getCustomerId, getZone } from "../server";
|
|
3
|
+
import { ApiResponseClass } from "../../api";
|
|
7
4
|
/**
|
|
8
5
|
* Using the request ID from getAsyncRequestId fetch to see if the data is available.
|
|
9
6
|
* https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
|
|
10
7
|
*/
|
|
11
|
-
const getAsyncResults = async (auth, requestId) => {
|
|
12
|
-
let response = (new
|
|
8
|
+
export const getAsyncResults = async (auth, requestId) => {
|
|
9
|
+
let response = (new ApiResponseClass());
|
|
13
10
|
// Prevent auth requests getting blocked
|
|
14
11
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
15
|
-
const customerId =
|
|
16
|
-
const zone =
|
|
17
|
-
const requestResponse = await
|
|
12
|
+
const customerId = getCustomerId(auth);
|
|
13
|
+
const zone = getZone(auth);
|
|
14
|
+
const requestResponse = await get(`https://api.brightdata.com/serp/get_result?customer=${customerId}&zone=${zone}&response_id=${requestId}`, {
|
|
18
15
|
headers: {
|
|
19
16
|
Authorization: `Bearer ${auth.apiKey}`
|
|
20
17
|
},
|
|
@@ -32,4 +29,3 @@ const getAsyncResults = async (auth, requestId) => {
|
|
|
32
29
|
}
|
|
33
30
|
return response;
|
|
34
31
|
};
|
|
35
|
-
exports.getAsyncResults = getAsyncResults;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRealtime = void 0;
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
1
|
+
import { get } from "../../axios";
|
|
5
2
|
/**
|
|
6
3
|
* Make a request to the SERP API using the Bright Data proxy
|
|
7
4
|
*/
|
|
8
|
-
const getRealtime = async (auth, url) => {
|
|
5
|
+
export const getRealtime = async (auth, url) => {
|
|
9
6
|
let response = {};
|
|
10
7
|
// Prevent auth requests getting blocked
|
|
11
8
|
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
12
9
|
// Use fetch with the agent option to make an HTTP request through the proxy
|
|
13
10
|
// Replace <target_url> with the URL you want to request
|
|
14
|
-
const apiResponse = await
|
|
11
|
+
const apiResponse = await get(url, {
|
|
15
12
|
proxy: {
|
|
16
13
|
protocol: "http",
|
|
17
14
|
host: auth.host,
|
|
@@ -27,4 +24,3 @@ const getRealtime = async (auth, url) => {
|
|
|
27
24
|
}
|
|
28
25
|
return response;
|
|
29
26
|
};
|
|
30
|
-
exports.getRealtime = getRealtime;
|