@8ms/helpers 2.0.0 → 2.0.1
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 +19 -0
- package/url/index.js +70 -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,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.deleteRequest = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
/**
|
|
10
|
+
* Make a DELETE request.
|
|
11
|
+
* Can't use the function name delete as it's reserved
|
|
12
|
+
*/
|
|
13
|
+
const deleteRequest = async (url, config = {}) => {
|
|
14
|
+
const response = await axios_1.default.delete(url, config)
|
|
15
|
+
.then(async (response) => {
|
|
16
|
+
// Is API response
|
|
17
|
+
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
18
|
+
return new api_1.ApiResponseClass(response.data);
|
|
19
|
+
}
|
|
20
|
+
// General success - some APIs report 201
|
|
21
|
+
else if (response.status >= 200 && response.status <= 299) {
|
|
22
|
+
return (new api_1.ApiResponseClass()).setToSuccess(response.data);
|
|
23
|
+
}
|
|
24
|
+
// Error
|
|
25
|
+
return (new api_1.ApiResponseClass()).setToError(response.data, response.statusText);
|
|
26
|
+
})
|
|
27
|
+
.catch(error => {
|
|
28
|
+
// Error
|
|
29
|
+
return (new api_1.ApiResponseClass()).setToError(null, error.message);
|
|
30
|
+
});
|
|
31
|
+
return response;
|
|
32
|
+
};
|
|
33
|
+
exports.deleteRequest = deleteRequest;
|
package/axios/get.d.ts
ADDED
package/axios/get.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.get = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
/**
|
|
10
|
+
* Make a GET request.
|
|
11
|
+
*/
|
|
12
|
+
const get = async (url, config = {}) => {
|
|
13
|
+
const response = await axios_1.default.get(url, config)
|
|
14
|
+
.then(async (response) => {
|
|
15
|
+
// Is API response
|
|
16
|
+
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
17
|
+
return new api_1.ApiResponseClass(response.data);
|
|
18
|
+
}
|
|
19
|
+
// General success - some APIs report 201
|
|
20
|
+
else if (response.status >= 200 && response.status <= 299) {
|
|
21
|
+
return (new api_1.ApiResponseClass()).setToSuccess(response.data);
|
|
22
|
+
}
|
|
23
|
+
// Error
|
|
24
|
+
return (new api_1.ApiResponseClass()).setToError(response.data, response.statusText);
|
|
25
|
+
})
|
|
26
|
+
.catch(error => {
|
|
27
|
+
return (new api_1.ApiResponseClass()).setToError(null, error.message);
|
|
28
|
+
});
|
|
29
|
+
return response;
|
|
30
|
+
};
|
|
31
|
+
exports.get = get;
|
package/axios/index.d.ts
ADDED
package/axios/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deleteRequest = exports.post = exports.get = void 0;
|
|
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; } });
|
package/axios/post.d.ts
ADDED
package/axios/post.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.post = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
/**
|
|
10
|
+
* Make a POST request.
|
|
11
|
+
*/
|
|
12
|
+
const post = async (url, data = {}, config = {}) => {
|
|
13
|
+
const response = await axios_1.default.post(url, data, config)
|
|
14
|
+
.then(async (response) => {
|
|
15
|
+
// Is API response
|
|
16
|
+
if (undefined !== response.data.body && undefined !== response.data.error && undefined !== response.data.state) {
|
|
17
|
+
return new api_1.ApiResponseClass(response.data);
|
|
18
|
+
}
|
|
19
|
+
// General success - some APIs report 201
|
|
20
|
+
else if (response.status >= 200 && response.status <= 299) {
|
|
21
|
+
return (new api_1.ApiResponseClass()).setToSuccess(response.data);
|
|
22
|
+
}
|
|
23
|
+
// Error
|
|
24
|
+
return (new api_1.ApiResponseClass()).setToError(response.data, response.statusText);
|
|
25
|
+
})
|
|
26
|
+
.catch(error => {
|
|
27
|
+
// Error
|
|
28
|
+
return (new api_1.ApiResponseClass()).setToError(null, error.message);
|
|
29
|
+
});
|
|
30
|
+
return response;
|
|
31
|
+
};
|
|
32
|
+
exports.post = post;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getBoolean = void 0;
|
|
7
|
+
const isBoolean_1 = __importDefault(require("lodash/isBoolean"));
|
|
8
|
+
/**
|
|
9
|
+
* Convert an input from a variety of forms into boolean.
|
|
10
|
+
*/
|
|
11
|
+
const getBoolean = (input, defaultValue = false) => {
|
|
12
|
+
if ((0, isBoolean_1.default)(input)) {
|
|
13
|
+
return input;
|
|
14
|
+
}
|
|
15
|
+
else if ("string" === typeof input) {
|
|
16
|
+
return "true" === input || "1" === input || "yes" === input || "y" === input;
|
|
17
|
+
}
|
|
18
|
+
else if ("number" === typeof input) {
|
|
19
|
+
return 1 === input;
|
|
20
|
+
}
|
|
21
|
+
return defaultValue;
|
|
22
|
+
};
|
|
23
|
+
exports.getBoolean = getBoolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getBoolean } from "./getBoolean";
|
package/boolean/index.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBoolean = void 0;
|
|
4
|
+
var getBoolean_1 = require("./getBoolean");
|
|
5
|
+
Object.defineProperty(exports, "getBoolean", { enumerable: true, get: function () { return getBoolean_1.getBoolean; } });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Auth = {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
host: string;
|
|
4
|
+
port: string;
|
|
5
|
+
username: string;
|
|
6
|
+
password: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Return the Zone based on the username.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getZone: (auth: Auth) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Return the customer Id based on the username.
|
|
14
|
+
*/
|
|
15
|
+
export declare const getCustomerId: (auth: Auth, prefix?: string) => string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCustomerId = exports.getZone = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Return the Zone based on the username.
|
|
6
|
+
*/
|
|
7
|
+
const getZone = (auth) => {
|
|
8
|
+
const segments = auth.username.split("-");
|
|
9
|
+
return segments[segments.length - 1];
|
|
10
|
+
};
|
|
11
|
+
exports.getZone = getZone;
|
|
12
|
+
/**
|
|
13
|
+
* Return the customer Id based on the username.
|
|
14
|
+
*/
|
|
15
|
+
const getCustomerId = (auth, prefix) => {
|
|
16
|
+
const segments = auth.username.split("-")[2];
|
|
17
|
+
const customerId = segments[2].replace("hl_", "");
|
|
18
|
+
return (prefix || "") + customerId;
|
|
19
|
+
};
|
|
20
|
+
exports.getCustomerId = getCustomerId;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
type BuildGoogleSerpUrl = {
|
|
2
|
+
country?: string;
|
|
3
|
+
device?: "mobile" | "android" | "androidTablet" | "iphone" | "ipad";
|
|
4
|
+
language?: string;
|
|
5
|
+
geoLocation?: string;
|
|
6
|
+
hotel?: {
|
|
7
|
+
dates?: string;
|
|
8
|
+
occupancy?: number;
|
|
9
|
+
};
|
|
10
|
+
pagination?: {
|
|
11
|
+
offset?: number;
|
|
12
|
+
perPage?: number;
|
|
13
|
+
};
|
|
14
|
+
searchType?: "images" | "jobs" | "news" | "shopping" | "video";
|
|
15
|
+
query: string;
|
|
16
|
+
googleDomain: string;
|
|
17
|
+
output?: "html" | "json";
|
|
18
|
+
returnType: "url" | "json";
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Construct the Google SERP url using Bright Data's API:
|
|
22
|
+
* https://brightdata.com/cp/serp_api/api/google/search?id=c_2cef083f
|
|
23
|
+
*
|
|
24
|
+
* For geolocation use value from:
|
|
25
|
+
* https://developers.google.com/google-ads/api/data/geotargets
|
|
26
|
+
*/
|
|
27
|
+
export declare const buildGoogleSerpUrl: (props: BuildGoogleSerpUrl) => string | {
|
|
28
|
+
query: {
|
|
29
|
+
q: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export {};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildGoogleSerpUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Construct the Google SERP url using Bright Data's API:
|
|
6
|
+
* https://brightdata.com/cp/serp_api/api/google/search?id=c_2cef083f
|
|
7
|
+
*
|
|
8
|
+
* For geolocation use value from:
|
|
9
|
+
* https://developers.google.com/google-ads/api/data/geotargets
|
|
10
|
+
*/
|
|
11
|
+
const buildGoogleSerpUrl = (props) => {
|
|
12
|
+
let url = new URL(`https://www.${props.googleDomain}/search`);
|
|
13
|
+
let params = {
|
|
14
|
+
query: {
|
|
15
|
+
q: props.query,
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
url.searchParams.append("q", props.query);
|
|
19
|
+
// Two-letter country code used to define the country of search
|
|
20
|
+
if (props?.country) {
|
|
21
|
+
params.query["gl"] = props.country;
|
|
22
|
+
url.searchParams.append("gl", props.country);
|
|
23
|
+
}
|
|
24
|
+
// Define what device type to be represented in user-agent - Default desktop
|
|
25
|
+
switch (props?.device) {
|
|
26
|
+
case "mobile":
|
|
27
|
+
params.query["brd_mobile"] = "1";
|
|
28
|
+
url.searchParams.append("brd_mobile", "1");
|
|
29
|
+
break;
|
|
30
|
+
case "android":
|
|
31
|
+
params.query["brd_mobile"] = "android";
|
|
32
|
+
url.searchParams.append("brd_mobile", "android");
|
|
33
|
+
break;
|
|
34
|
+
case "androidTablet":
|
|
35
|
+
params.query["brd_mobile"] = "android_tablet";
|
|
36
|
+
url.searchParams.append("brd_mobile", "android_tablet");
|
|
37
|
+
break;
|
|
38
|
+
case "ipad":
|
|
39
|
+
params.query["brd_mobile"] = "ipad";
|
|
40
|
+
url.searchParams.append("brd_mobile", "ipad");
|
|
41
|
+
break;
|
|
42
|
+
case "iphone":
|
|
43
|
+
params.query["brd_mobile"] = "ios";
|
|
44
|
+
url.searchParams.append("brd_mobile", "ios");
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
// Stands for the encoded location you want to use for your search
|
|
48
|
+
if (props?.geoLocation) {
|
|
49
|
+
params.query["uule"] = props.geoLocation;
|
|
50
|
+
url.searchParams.append("uule", props.geoLocation);
|
|
51
|
+
}
|
|
52
|
+
if (props?.hotel) {
|
|
53
|
+
if (props.hotel?.dates) {
|
|
54
|
+
params.query["hotel_dates"] = props.hotel.dates.toString();
|
|
55
|
+
url.searchParams.append("hotel_dates", props.hotel.dates);
|
|
56
|
+
}
|
|
57
|
+
if (props.hotel?.occupancy) {
|
|
58
|
+
params.query["hotel_occupancy"] = props.hotel.occupancy.toString();
|
|
59
|
+
url.searchParams.append("hotel_occupancy", props.hotel.occupancy.toString());
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Two-letter language code used to define the page language
|
|
63
|
+
if (props?.language) {
|
|
64
|
+
params.query["uule"] = props.language;
|
|
65
|
+
url.searchParams.append("hl", props.language);
|
|
66
|
+
}
|
|
67
|
+
// Define search type. For regular search
|
|
68
|
+
switch (props?.searchType) {
|
|
69
|
+
case "images":
|
|
70
|
+
params.query["tbm"] = "isch";
|
|
71
|
+
url.searchParams.append("tbm", "isch");
|
|
72
|
+
break;
|
|
73
|
+
case "jobs":
|
|
74
|
+
params.query["ibp"] = "htl;jobs";
|
|
75
|
+
url.searchParams.append("ibp", "htl;jobs");
|
|
76
|
+
break;
|
|
77
|
+
case "news":
|
|
78
|
+
params.query["tbm"] = "nws";
|
|
79
|
+
url.searchParams.append("tbm", "nws");
|
|
80
|
+
break;
|
|
81
|
+
case "shopping":
|
|
82
|
+
params.query["tbm"] = "shop";
|
|
83
|
+
url.searchParams.append("tbm", "shop");
|
|
84
|
+
break;
|
|
85
|
+
case "video":
|
|
86
|
+
params.query["tbm"] = "vid";
|
|
87
|
+
url.searchParams.append("tbm", "vid");
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
if (props?.pagination) {
|
|
91
|
+
// Define the result offset
|
|
92
|
+
if (props.pagination?.offset) {
|
|
93
|
+
params.query["start"] = props.pagination.offset.toString();
|
|
94
|
+
url.searchParams.append("start", props.pagination.offset.toString());
|
|
95
|
+
}
|
|
96
|
+
// Defines the number of results to return
|
|
97
|
+
if (props.pagination?.perPage) {
|
|
98
|
+
params.query["num"] = props.pagination.offset.toString();
|
|
99
|
+
url.searchParams.append("num", props.pagination.perPage.toString());
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Specify the output type
|
|
103
|
+
if ("json" === props.output) {
|
|
104
|
+
params["brd_json"] = "1";
|
|
105
|
+
url.searchParams.append("brn_json", "1");
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
params["brd_json"] = "html";
|
|
109
|
+
url.searchParams.append("brn_json", "html");
|
|
110
|
+
}
|
|
111
|
+
if ("json" === props.returnType) {
|
|
112
|
+
return params;
|
|
113
|
+
}
|
|
114
|
+
return url.toString();
|
|
115
|
+
};
|
|
116
|
+
exports.buildGoogleSerpUrl = buildGoogleSerpUrl;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
type BuildGoogleTrendsUrl = {
|
|
2
|
+
country?: string;
|
|
3
|
+
language?: string;
|
|
4
|
+
category?: string;
|
|
5
|
+
date?: string;
|
|
6
|
+
searchType?: "images" | "news" | "shopping" | "youtube";
|
|
7
|
+
query: string;
|
|
8
|
+
returnType: "url" | "json";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Construct the Google Trends url using Bright Data's API:
|
|
12
|
+
* https://brightdata.com/cp/serp_api/api/google/trends?id=c_2cef083f
|
|
13
|
+
*
|
|
14
|
+
* For category use value from:
|
|
15
|
+
* https://trends.google.com/trends/api/explore/pickers/category?lang=en-US&tz=240
|
|
16
|
+
*/
|
|
17
|
+
export declare const buildGoogleTrendsUrl: (props: BuildGoogleTrendsUrl) => string | {
|
|
18
|
+
query: {
|
|
19
|
+
q: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildGoogleTrendsUrl = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Construct the Google Trends url using Bright Data's API:
|
|
6
|
+
* https://brightdata.com/cp/serp_api/api/google/trends?id=c_2cef083f
|
|
7
|
+
*
|
|
8
|
+
* For category use value from:
|
|
9
|
+
* https://trends.google.com/trends/api/explore/pickers/category?lang=en-US&tz=240
|
|
10
|
+
*/
|
|
11
|
+
const buildGoogleTrendsUrl = (props) => {
|
|
12
|
+
let url = new URL(`http://trends.google.com/trends/explore`);
|
|
13
|
+
url.searchParams.append("q", props.query);
|
|
14
|
+
let params = {
|
|
15
|
+
query: {
|
|
16
|
+
q: props.query,
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
// Location of interest, two-letter country code
|
|
20
|
+
if (props?.country) {
|
|
21
|
+
params.query['geo'] = props.country;
|
|
22
|
+
url.searchParams.append("geo", props.country);
|
|
23
|
+
}
|
|
24
|
+
// Preferred language, two-letter language code
|
|
25
|
+
if (props?.language) {
|
|
26
|
+
params.query['hl'] = props.language;
|
|
27
|
+
url.searchParams.append("hl", props.language);
|
|
28
|
+
}
|
|
29
|
+
if (props?.category) {
|
|
30
|
+
params.query['cat'] = props.category;
|
|
31
|
+
url.searchParams.append("cat", props.category);
|
|
32
|
+
}
|
|
33
|
+
if (props?.date) {
|
|
34
|
+
params.query['date'] = props.date;
|
|
35
|
+
url.searchParams.append("date", props.date);
|
|
36
|
+
}
|
|
37
|
+
// Define search type. For regular search
|
|
38
|
+
switch (props?.searchType) {
|
|
39
|
+
case "images":
|
|
40
|
+
params.query['group'] = "images";
|
|
41
|
+
url.searchParams.append("gprop", "images");
|
|
42
|
+
break;
|
|
43
|
+
case "news":
|
|
44
|
+
params.query['group'] = "news";
|
|
45
|
+
url.searchParams.append("gprop", "news");
|
|
46
|
+
break;
|
|
47
|
+
case "shopping":
|
|
48
|
+
params.query['group'] = "froogle";
|
|
49
|
+
url.searchParams.append("gprop", "froogle");
|
|
50
|
+
break;
|
|
51
|
+
case "youtube":
|
|
52
|
+
params.query['group'] = "youtube";
|
|
53
|
+
url.searchParams.append("gprop", "youtube");
|
|
54
|
+
break;
|
|
55
|
+
}
|
|
56
|
+
if ("json" === props.returnType) {
|
|
57
|
+
return params;
|
|
58
|
+
}
|
|
59
|
+
return url.toString();
|
|
60
|
+
};
|
|
61
|
+
exports.buildGoogleTrendsUrl = buildGoogleTrendsUrl;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Auth } from "../";
|
|
2
|
+
import { BrightDataSerpApiType } from "./";
|
|
3
|
+
/**
|
|
4
|
+
* Make an async request to the SERP API using the Bright Data proxy.
|
|
5
|
+
* Returns a request ID used with getAsyncResults
|
|
6
|
+
* https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
|
|
7
|
+
*/
|
|
8
|
+
export declare const getAsyncRequestId: (auth: Auth, data: {}, type: BrightDataSerpApiType) => Promise<string>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAsyncRequestId = void 0;
|
|
4
|
+
const axios_1 = require("../../axios");
|
|
5
|
+
const __1 = require("../");
|
|
6
|
+
const _1 = require("./");
|
|
7
|
+
/**
|
|
8
|
+
* Make an async request to the SERP API using the Bright Data proxy.
|
|
9
|
+
* Returns a request ID used with getAsyncResults
|
|
10
|
+
* https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
|
|
11
|
+
*/
|
|
12
|
+
const getAsyncRequestId = async (auth, data = {}, type) => {
|
|
13
|
+
let url = "";
|
|
14
|
+
let response = "";
|
|
15
|
+
// Prevent auth requests getting blocked
|
|
16
|
+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
17
|
+
const customerId = (0, __1.getCustomerId)(auth);
|
|
18
|
+
const zone = (0, __1.getZone)(auth);
|
|
19
|
+
switch (type) {
|
|
20
|
+
case _1.BrightDataSerpApiType.GOOGLE_TRENDS:
|
|
21
|
+
url = `https://api.brightdata.com/serp/trends?customer=${customerId}&zone=${zone}`;
|
|
22
|
+
break;
|
|
23
|
+
default:
|
|
24
|
+
url = `https://api.brightdata.com/serp/req?customer=${customerId}&zone=${zone}`;
|
|
25
|
+
}
|
|
26
|
+
const requestResponse = await (0, axios_1.post)(url, data, {
|
|
27
|
+
headers: {
|
|
28
|
+
Authorization: `Bearer ${auth.apiKey}`
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
if (requestResponse.isSuccess()) {
|
|
32
|
+
response = requestResponse.getBodyDefaultTo(["response_id"], "");
|
|
33
|
+
}
|
|
34
|
+
return response;
|
|
35
|
+
};
|
|
36
|
+
exports.getAsyncRequestId = getAsyncRequestId;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Auth } from "../";
|
|
2
|
+
import { ApiResponseClass } from "../../api";
|
|
3
|
+
/**
|
|
4
|
+
* Using the request ID from getAsyncRequestId fetch to see if the data is available.
|
|
5
|
+
* https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
|
|
6
|
+
*/
|
|
7
|
+
export declare const getAsyncResults: (auth: Auth, requestId: string) => Promise<ApiResponseClass<any, any>>;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAsyncResults = void 0;
|
|
4
|
+
const axios_1 = require("../../axios");
|
|
5
|
+
const __1 = require("../");
|
|
6
|
+
const api_1 = require("../../api");
|
|
7
|
+
/**
|
|
8
|
+
* Using the request ID from getAsyncRequestId fetch to see if the data is available.
|
|
9
|
+
* https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
|
|
10
|
+
*/
|
|
11
|
+
const getAsyncResults = async (auth, requestId) => {
|
|
12
|
+
let response = (new api_1.ApiResponseClass());
|
|
13
|
+
// Prevent auth requests getting blocked
|
|
14
|
+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
15
|
+
const customerId = (0, __1.getCustomerId)(auth);
|
|
16
|
+
const zone = (0, __1.getZone)(auth);
|
|
17
|
+
const requestResponse = await (0, axios_1.get)(`https://api.brightdata.com/serp/get_result?customer=${customerId}&zone=${zone}&response_id=${requestId}`, {
|
|
18
|
+
headers: {
|
|
19
|
+
Authorization: `Bearer ${auth.apiKey}`
|
|
20
|
+
},
|
|
21
|
+
});
|
|
22
|
+
if (requestResponse.isSuccess()) {
|
|
23
|
+
if ("Request is pending" === requestResponse.getBody()) {
|
|
24
|
+
response.setToPending();
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
response.setToSuccess(requestResponse.getBody());
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
response.setToError(null, "Error in request");
|
|
32
|
+
}
|
|
33
|
+
return response;
|
|
34
|
+
};
|
|
35
|
+
exports.getAsyncResults = getAsyncResults;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRealtime = void 0;
|
|
4
|
+
const axios_1 = require("../../axios");
|
|
5
|
+
/**
|
|
6
|
+
* Make a request to the SERP API using the Bright Data proxy
|
|
7
|
+
*/
|
|
8
|
+
const getRealtime = async (auth, url) => {
|
|
9
|
+
let response = {};
|
|
10
|
+
// Prevent auth requests getting blocked
|
|
11
|
+
process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
|
|
12
|
+
// Use fetch with the agent option to make an HTTP request through the proxy
|
|
13
|
+
// Replace <target_url> with the URL you want to request
|
|
14
|
+
const apiResponse = await (0, axios_1.get)(url, {
|
|
15
|
+
proxy: {
|
|
16
|
+
protocol: "http",
|
|
17
|
+
host: auth.host,
|
|
18
|
+
port: auth.port,
|
|
19
|
+
auth: {
|
|
20
|
+
username: auth.username,
|
|
21
|
+
password: auth.password,
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
if (apiResponse.isSuccess()) {
|
|
26
|
+
response = apiResponse.getBody();
|
|
27
|
+
}
|
|
28
|
+
return response;
|
|
29
|
+
};
|
|
30
|
+
exports.getRealtime = getRealtime;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare enum BrightDataSerpApiType {
|
|
2
|
+
GOOGLE_FLIGHTS = "GOOGLE_FLIGHTS",
|
|
3
|
+
GOOGLE_HOTELS = "GOOGLE_HOTELS",
|
|
4
|
+
GOOGLE_LENS = "GOOGLE_LENS",
|
|
5
|
+
GOOGLE_MAPS = "GOOGLE_MAPS",
|
|
6
|
+
GOOGLE_REVIEWS = "GOOGLE_REVIEWS",
|
|
7
|
+
GOOGLE_SEARCH = "GOOGLE_SEARCH",
|
|
8
|
+
GOOGLE_TRENDS = "GOOGLE_TRENDS"
|
|
9
|
+
}
|
|
10
|
+
export { buildGoogleSerpUrl } from "./buildGoogleSerpUrl";
|
|
11
|
+
export { buildGoogleTrendsUrl } from "./buildGoogleTrendsUrl";
|
|
12
|
+
export { getAsyncRequestId } from "./getAsyncRequestId";
|
|
13
|
+
export { getAsyncResults } from "./getAsyncResults";
|
|
14
|
+
export { getRealtime } from "./getRealtime";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRealtime = exports.getAsyncResults = exports.getAsyncRequestId = exports.buildGoogleTrendsUrl = exports.buildGoogleSerpUrl = exports.BrightDataSerpApiType = void 0;
|
|
4
|
+
var BrightDataSerpApiType;
|
|
5
|
+
(function (BrightDataSerpApiType) {
|
|
6
|
+
BrightDataSerpApiType["GOOGLE_FLIGHTS"] = "GOOGLE_FLIGHTS";
|
|
7
|
+
BrightDataSerpApiType["GOOGLE_HOTELS"] = "GOOGLE_HOTELS";
|
|
8
|
+
BrightDataSerpApiType["GOOGLE_LENS"] = "GOOGLE_LENS";
|
|
9
|
+
BrightDataSerpApiType["GOOGLE_MAPS"] = "GOOGLE_MAPS";
|
|
10
|
+
BrightDataSerpApiType["GOOGLE_REVIEWS"] = "GOOGLE_REVIEWS";
|
|
11
|
+
BrightDataSerpApiType["GOOGLE_SEARCH"] = "GOOGLE_SEARCH";
|
|
12
|
+
BrightDataSerpApiType["GOOGLE_TRENDS"] = "GOOGLE_TRENDS";
|
|
13
|
+
})(BrightDataSerpApiType || (exports.BrightDataSerpApiType = BrightDataSerpApiType = {}));
|
|
14
|
+
var buildGoogleSerpUrl_1 = require("./buildGoogleSerpUrl");
|
|
15
|
+
Object.defineProperty(exports, "buildGoogleSerpUrl", { enumerable: true, get: function () { return buildGoogleSerpUrl_1.buildGoogleSerpUrl; } });
|
|
16
|
+
var buildGoogleTrendsUrl_1 = require("./buildGoogleTrendsUrl");
|
|
17
|
+
Object.defineProperty(exports, "buildGoogleTrendsUrl", { enumerable: true, get: function () { return buildGoogleTrendsUrl_1.buildGoogleTrendsUrl; } });
|
|
18
|
+
var getAsyncRequestId_1 = require("./getAsyncRequestId");
|
|
19
|
+
Object.defineProperty(exports, "getAsyncRequestId", { enumerable: true, get: function () { return getAsyncRequestId_1.getAsyncRequestId; } });
|
|
20
|
+
var getAsyncResults_1 = require("./getAsyncResults");
|
|
21
|
+
Object.defineProperty(exports, "getAsyncResults", { enumerable: true, get: function () { return getAsyncResults_1.getAsyncResults; } });
|
|
22
|
+
var getRealtime_1 = require("./getRealtime");
|
|
23
|
+
Object.defineProperty(exports, "getRealtime", { enumerable: true, get: function () { return getRealtime_1.getRealtime; } });
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getBatch = void 0;
|
|
4
|
+
const axios_1 = require("../../axios");
|
|
5
|
+
/**
|
|
6
|
+
* Depends on the Scraper setup!
|
|
7
|
+
*
|
|
8
|
+
* Make the request to trigger the scraper and let it do its job.
|
|
9
|
+
*/
|
|
10
|
+
const getBatch = async (auth, scraperId, data = {}, isDev = false) => {
|
|
11
|
+
let response = false;
|
|
12
|
+
const requestUrl = new URL("https://api.brightdata.com/dca/trigger");
|
|
13
|
+
requestUrl.searchParams.append("collector", scraperId);
|
|
14
|
+
requestUrl.searchParams.append("queue_next", "1");
|
|
15
|
+
if (isDev) {
|
|
16
|
+
requestUrl.searchParams.append("version", "dev");
|
|
17
|
+
}
|
|
18
|
+
const requestResponse = await (0, axios_1.post)(requestUrl.toString(), data, {
|
|
19
|
+
headers: {
|
|
20
|
+
Authorization: `Bearer ${auth.apiKey}`
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
if (requestResponse.isSuccess()) {
|
|
24
|
+
response = true;
|
|
25
|
+
}
|
|
26
|
+
return response;
|
|
27
|
+
};
|
|
28
|
+
exports.getBatch = getBatch;
|