@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
package/swr/index.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { ApiState } from "../api";
|
|
2
|
+
export type Swr = {
|
|
3
|
+
data: any;
|
|
4
|
+
onSuccess?: Function;
|
|
5
|
+
skipFetch?: boolean;
|
|
6
|
+
url: string;
|
|
7
|
+
};
|
|
8
|
+
export type SwrResponse = {
|
|
9
|
+
data: any;
|
|
10
|
+
error: any;
|
|
11
|
+
fetcher: Function;
|
|
12
|
+
mutate: {
|
|
13
|
+
data: any;
|
|
14
|
+
url: string;
|
|
15
|
+
};
|
|
16
|
+
state?: ApiState;
|
|
17
|
+
swrMutate: Function;
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Check to see if a single SWR has an error.
|
|
21
|
+
*/
|
|
22
|
+
export declare const isData: (swr: SwrResponse) => boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Check to see if a single SWR is loading.
|
|
25
|
+
*/
|
|
26
|
+
export declare const isLoading: (swr: SwrResponse) => boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Check to see if a single SWR has an error.
|
|
29
|
+
*/
|
|
30
|
+
export declare const isError: (swr: SwrResponse) => boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Are any of SWRs loading
|
|
33
|
+
*/
|
|
34
|
+
export declare const isAnyLoading: (swrs: SwrResponse[]) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Are any of the SWRs marked as an error.
|
|
37
|
+
*/
|
|
38
|
+
export declare const isAnyError: (swrs: SwrResponse[]) => boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Are all SWRs data ready.
|
|
41
|
+
*/
|
|
42
|
+
export declare const isAllData: (swrs: SwrResponse[]) => boolean;
|
package/swr/index.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAllData = exports.isAnyError = exports.isAnyLoading = exports.isError = exports.isLoading = exports.isData = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Check to see if a single SWR has an error.
|
|
6
|
+
*/
|
|
7
|
+
const isData = (swr) => (undefined === swr.error || null === swr.error) &&
|
|
8
|
+
"undefined" !== typeof swr.data &&
|
|
9
|
+
"undefined" !== swr.data;
|
|
10
|
+
exports.isData = isData;
|
|
11
|
+
/**
|
|
12
|
+
* Check to see if a single SWR is loading.
|
|
13
|
+
*/
|
|
14
|
+
const isLoading = (swr) => !(0, exports.isError)(swr) && !(0, exports.isData)(swr);
|
|
15
|
+
exports.isLoading = isLoading;
|
|
16
|
+
/**
|
|
17
|
+
* Check to see if a single SWR has an error.
|
|
18
|
+
*/
|
|
19
|
+
const isError = (swr) => undefined !== swr.error && null !== swr.error;
|
|
20
|
+
exports.isError = isError;
|
|
21
|
+
/**
|
|
22
|
+
* Are any of SWRs loading
|
|
23
|
+
*/
|
|
24
|
+
const isAnyLoading = (swrs) => {
|
|
25
|
+
let counter = 0;
|
|
26
|
+
for (const swr in swrs) {
|
|
27
|
+
if ((0, exports.isLoading)(swrs[swr])) {
|
|
28
|
+
counter++;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return counter > 0;
|
|
32
|
+
};
|
|
33
|
+
exports.isAnyLoading = isAnyLoading;
|
|
34
|
+
/**
|
|
35
|
+
* Are any of the SWRs marked as an error.
|
|
36
|
+
*/
|
|
37
|
+
const isAnyError = (swrs) => {
|
|
38
|
+
let counter = 0;
|
|
39
|
+
for (const swr in swrs) {
|
|
40
|
+
if ((0, exports.isError)(swrs[swr])) {
|
|
41
|
+
counter++;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return counter > 0;
|
|
45
|
+
};
|
|
46
|
+
exports.isAnyError = isAnyError;
|
|
47
|
+
/**
|
|
48
|
+
* Are all SWRs data ready.
|
|
49
|
+
*/
|
|
50
|
+
const isAllData = (swrs) => {
|
|
51
|
+
let counter = 0;
|
|
52
|
+
for (const swr in swrs) {
|
|
53
|
+
if ((0, exports.isData)(swrs[swr])) {
|
|
54
|
+
counter++;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return counter === Object.keys(swrs).length;
|
|
58
|
+
};
|
|
59
|
+
exports.isAllData = isAllData;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { UpTimeRobotConfig } from "./index";
|
|
2
|
+
import { BaseNamespace } from "../_class";
|
|
3
|
+
type GetReportProps = {
|
|
4
|
+
custom_uptime_ranges?: string;
|
|
5
|
+
logs?: boolean;
|
|
6
|
+
logs_start_date?: string;
|
|
7
|
+
logs_end_date?: string;
|
|
8
|
+
monitors?: string | string[];
|
|
9
|
+
response_times?: boolean;
|
|
10
|
+
response_times_start_date?: string;
|
|
11
|
+
response_times_end_date?: string;
|
|
12
|
+
search?: string;
|
|
13
|
+
statuses?: number | number[];
|
|
14
|
+
types?: number | number[];
|
|
15
|
+
limit?: number;
|
|
16
|
+
offset?: number;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Use the Up Time Robot API to retrieve up to 50 monitors at a time.
|
|
20
|
+
* https://uptimerobot.com/api/
|
|
21
|
+
*/
|
|
22
|
+
export declare class UpTimeRobotNamespace extends BaseNamespace {
|
|
23
|
+
client: boolean | null;
|
|
24
|
+
config: UpTimeRobotConfig | null;
|
|
25
|
+
/**
|
|
26
|
+
* Renew the access token as it expires every 3 hours.
|
|
27
|
+
*/
|
|
28
|
+
ensureInit: () => Promise<void>;
|
|
29
|
+
getReport: (props?: GetReportProps) => Promise<any>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
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.UpTimeRobotNamespace = void 0;
|
|
7
|
+
const _class_1 = require("../_class");
|
|
8
|
+
const axios_1 = require("../axios");
|
|
9
|
+
const isArray_1 = __importDefault(require("lodash/isArray"));
|
|
10
|
+
/**
|
|
11
|
+
* Use the Up Time Robot API to retrieve up to 50 monitors at a time.
|
|
12
|
+
* https://uptimerobot.com/api/
|
|
13
|
+
*/
|
|
14
|
+
class UpTimeRobotNamespace extends _class_1.BaseNamespace {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.client = null;
|
|
18
|
+
this.config = null;
|
|
19
|
+
/**
|
|
20
|
+
* Renew the access token as it expires every 3 hours.
|
|
21
|
+
*/
|
|
22
|
+
this.ensureInit = async () => {
|
|
23
|
+
if (!this.client) {
|
|
24
|
+
this.client = true;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
this.getReport = async (props) => {
|
|
28
|
+
let response = null;
|
|
29
|
+
let finalParams = {};
|
|
30
|
+
if (undefined !== props) {
|
|
31
|
+
finalParams = {
|
|
32
|
+
...props,
|
|
33
|
+
};
|
|
34
|
+
if (undefined !== props.monitors && (0, isArray_1.default)(props.monitors)) {
|
|
35
|
+
finalParams["monitors"] = props.monitors.join("-");
|
|
36
|
+
}
|
|
37
|
+
if (undefined !== props.statuses && (0, isArray_1.default)(props.statuses)) {
|
|
38
|
+
finalParams["statuses"] = props.statuses.join("-");
|
|
39
|
+
}
|
|
40
|
+
if (undefined !== props.types && (0, isArray_1.default)(props.types)) {
|
|
41
|
+
finalParams["types"] = props.types.join("-");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
const apiResponse = await (0, axios_1.post)(`https://api.uptimerobot.com/v2/getMonitors?api_key=${this.config.apiKey}`, finalParams);
|
|
45
|
+
if (apiResponse.isSuccess()) {
|
|
46
|
+
response = apiResponse.getBody();
|
|
47
|
+
}
|
|
48
|
+
return response;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.UpTimeRobotNamespace = UpTimeRobotNamespace;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { LittleWardenNamespace } from "../littleWarden/LittleWardenNamespace";
|
|
2
|
+
export type UpTimeRobotConfig = {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
};
|
|
5
|
+
export declare const upTimeRobotClient: (key?: string, config?: UpTimeRobotConfig, vaultId?: string, itemId?: string) => Promise<LittleWardenNamespace>;
|
|
6
|
+
export declare const logTypes: {
|
|
7
|
+
DOWN: number;
|
|
8
|
+
UP: number;
|
|
9
|
+
PAUSED: number;
|
|
10
|
+
STARTED: number;
|
|
11
|
+
};
|
|
12
|
+
export declare const monitorStatuses: {
|
|
13
|
+
PAUSED: number;
|
|
14
|
+
NOT_CHECKED: number;
|
|
15
|
+
UP: number;
|
|
16
|
+
SEEMS_DOWN: number;
|
|
17
|
+
DOWN: number;
|
|
18
|
+
};
|
|
19
|
+
export declare const monitorSubTypes: {
|
|
20
|
+
HTTP: number;
|
|
21
|
+
HTTPS: number;
|
|
22
|
+
FTP: number;
|
|
23
|
+
SMTP: number;
|
|
24
|
+
POP3: number;
|
|
25
|
+
IMAP: number;
|
|
26
|
+
CUSTOM_PORT: number;
|
|
27
|
+
};
|
|
28
|
+
export declare const monitorTypes: {
|
|
29
|
+
HTTPS: number;
|
|
30
|
+
KEYWORD: number;
|
|
31
|
+
PING: number;
|
|
32
|
+
PORT: number;
|
|
33
|
+
HEARTBEAT: number;
|
|
34
|
+
};
|
|
35
|
+
export declare const requestStatuses: {
|
|
36
|
+
ERROR: string;
|
|
37
|
+
SUCCESS: string;
|
|
38
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestStatuses = exports.monitorTypes = exports.monitorSubTypes = exports.monitorStatuses = exports.logTypes = exports.upTimeRobotClient = void 0;
|
|
4
|
+
const LittleWardenNamespace_1 = require("../littleWarden/LittleWardenNamespace");
|
|
5
|
+
const onePassword_1 = require("../onePassword");
|
|
6
|
+
const upTimeRobotNamespaces = new Map();
|
|
7
|
+
const upTimeRobotClient = async (key = "default", config, vaultId, itemId) => {
|
|
8
|
+
if (upTimeRobotNamespaces.has(key)) {
|
|
9
|
+
return upTimeRobotNamespaces.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.UP_TIME_ROBOT_VAULT_ID && process.env.UP_TIME_ROBOT_ITEM_ID) {
|
|
20
|
+
instanceConfig = await (await (0, onePassword_1.onePasswordClient)())
|
|
21
|
+
.getJsonNote(process.env.UP_TIME_ROBOT_VAULT_ID, process.env.UP_TIME_ROBOT_ITEM_ID);
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
throw new Error(`Config required for namespace '${key}'`);
|
|
25
|
+
}
|
|
26
|
+
const namespace = new LittleWardenNamespace_1.LittleWardenNamespace(key, instanceConfig);
|
|
27
|
+
upTimeRobotNamespaces.set(key, namespace);
|
|
28
|
+
return namespace;
|
|
29
|
+
};
|
|
30
|
+
exports.upTimeRobotClient = upTimeRobotClient;
|
|
31
|
+
exports.logTypes = {
|
|
32
|
+
DOWN: 1,
|
|
33
|
+
UP: 2,
|
|
34
|
+
PAUSED: 99,
|
|
35
|
+
STARTED: 98,
|
|
36
|
+
};
|
|
37
|
+
exports.monitorStatuses = {
|
|
38
|
+
PAUSED: 0,
|
|
39
|
+
NOT_CHECKED: 1,
|
|
40
|
+
UP: 2,
|
|
41
|
+
SEEMS_DOWN: 8,
|
|
42
|
+
DOWN: 9,
|
|
43
|
+
};
|
|
44
|
+
exports.monitorSubTypes = {
|
|
45
|
+
HTTP: 1,
|
|
46
|
+
HTTPS: 2,
|
|
47
|
+
FTP: 3,
|
|
48
|
+
SMTP: 4,
|
|
49
|
+
POP3: 5,
|
|
50
|
+
IMAP: 6,
|
|
51
|
+
CUSTOM_PORT: 99,
|
|
52
|
+
};
|
|
53
|
+
exports.monitorTypes = {
|
|
54
|
+
HTTPS: 1,
|
|
55
|
+
KEYWORD: 2,
|
|
56
|
+
PING: 3,
|
|
57
|
+
PORT: 4,
|
|
58
|
+
HEARTBEAT: 5,
|
|
59
|
+
};
|
|
60
|
+
exports.requestStatuses = {
|
|
61
|
+
ERROR: 'fail',
|
|
62
|
+
SUCCESS: 'ok',
|
|
63
|
+
};
|
package/url/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export type EnvironmentUrl = {
|
|
2
|
+
localhost: string;
|
|
3
|
+
development: string;
|
|
4
|
+
staging: string;
|
|
5
|
+
production: string;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Does the URL begin with HTTP or HTTPS?
|
|
9
|
+
*/
|
|
10
|
+
export declare const isAbsolute: (input: string) => boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Does the URL begin with a slash.
|
|
13
|
+
*/
|
|
14
|
+
export declare const isRelative: (input: string) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Take an object and return the parameter for a given URL irrespective of path.
|
|
17
|
+
*/
|
|
18
|
+
export declare const buildParameters: (existing?: object, updated?: object) => string;
|
|
19
|
+
/**
|
|
20
|
+
* Create a new relative URL based on the current path.
|
|
21
|
+
*/
|
|
22
|
+
export declare const buildRelative: ({ router, updated }: {
|
|
23
|
+
router: any;
|
|
24
|
+
updated: object;
|
|
25
|
+
}) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Get the current base url.
|
|
28
|
+
*/
|
|
29
|
+
export declare const buildEnvironmentUrl: (path: string, url: EnvironmentUrl) => string;
|
|
30
|
+
export { writeUrlContents } from "./writeUrlContents";
|
package/url/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
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.writeUrlContents = exports.buildEnvironmentUrl = exports.buildRelative = exports.buildParameters = exports.isRelative = exports.isAbsolute = void 0;
|
|
7
|
+
const environment_1 = require("../environment");
|
|
8
|
+
const merge_1 = __importDefault(require("lodash/merge"));
|
|
9
|
+
/**
|
|
10
|
+
* Does the URL begin with HTTP or HTTPS?
|
|
11
|
+
*/
|
|
12
|
+
const isAbsolute = (input) => {
|
|
13
|
+
try {
|
|
14
|
+
new URL(input);
|
|
15
|
+
}
|
|
16
|
+
catch (error) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
exports.isAbsolute = isAbsolute;
|
|
22
|
+
/**
|
|
23
|
+
* Does the URL begin with a slash.
|
|
24
|
+
*/
|
|
25
|
+
const isRelative = (input) => "/" === input.trim()
|
|
26
|
+
.charAt(0);
|
|
27
|
+
exports.isRelative = isRelative;
|
|
28
|
+
/**
|
|
29
|
+
* Take an object and return the parameter for a given URL irrespective of path.
|
|
30
|
+
*/
|
|
31
|
+
const buildParameters = (existing = {}, updated = {}) => {
|
|
32
|
+
const merged = (0, merge_1.default)(existing, updated);
|
|
33
|
+
let response = "";
|
|
34
|
+
if (Object.values(merged).length) {
|
|
35
|
+
for (const key in merged) {
|
|
36
|
+
const value = undefined === updated[key] ? existing[key] : updated[key];
|
|
37
|
+
response += "" === response ? "?" : "&";
|
|
38
|
+
response += `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
43
|
+
exports.buildParameters = buildParameters;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new relative URL based on the current path.
|
|
46
|
+
*/
|
|
47
|
+
const buildRelative = ({ router, updated }) => {
|
|
48
|
+
return `${router.pathname}${(0, exports.buildParameters)({ existing: router.query, updated: updated || {} })}`;
|
|
49
|
+
};
|
|
50
|
+
exports.buildRelative = buildRelative;
|
|
51
|
+
/**
|
|
52
|
+
* Get the current base url.
|
|
53
|
+
*/
|
|
54
|
+
const buildEnvironmentUrl = (path, url) => {
|
|
55
|
+
let response;
|
|
56
|
+
if ((0, environment_1.isDevelopment)() && (0, environment_1.isLocalhost)()) {
|
|
57
|
+
response = url.localhost;
|
|
58
|
+
}
|
|
59
|
+
else if ((0, environment_1.isStaging)()) {
|
|
60
|
+
response = url.staging;
|
|
61
|
+
}
|
|
62
|
+
else if ((0, environment_1.isProduction)()) {
|
|
63
|
+
response = url.production;
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
response = url.development;
|
|
67
|
+
}
|
|
68
|
+
return response + path || "";
|
|
69
|
+
};
|
|
70
|
+
exports.buildEnvironmentUrl = buildEnvironmentUrl;
|
|
71
|
+
var writeUrlContents_1 = require("./writeUrlContents");
|
|
72
|
+
Object.defineProperty(exports, "writeUrlContents", { enumerable: true, get: function () { return writeUrlContents_1.writeUrlContents; } });
|
|
@@ -0,0 +1,75 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.writeUrlContents = void 0;
|
|
40
|
+
const axios_1 = __importDefault(require("axios"));
|
|
41
|
+
const file_1 = require("../file");
|
|
42
|
+
/**
|
|
43
|
+
* Downloads a given URL's contents to a local file.
|
|
44
|
+
*
|
|
45
|
+
* Requires fs-extra
|
|
46
|
+
*/
|
|
47
|
+
const writeUrlContents = async (filePath, url) => {
|
|
48
|
+
const fs = await Promise.resolve().then(() => __importStar(require("fs-extra")));
|
|
49
|
+
await (0, file_1.createDirectory)(filePath);
|
|
50
|
+
const writer = fs.createWriteStream(filePath);
|
|
51
|
+
await (0, axios_1.default)({
|
|
52
|
+
method: "get",
|
|
53
|
+
url,
|
|
54
|
+
responseType: "stream"
|
|
55
|
+
})
|
|
56
|
+
.then(response => {
|
|
57
|
+
return new Promise(async (resolve, reject) => {
|
|
58
|
+
response.data.pipe(writer);
|
|
59
|
+
let error = null;
|
|
60
|
+
writer.on("error", err => {
|
|
61
|
+
error = err;
|
|
62
|
+
writer.close();
|
|
63
|
+
reject(err);
|
|
64
|
+
});
|
|
65
|
+
writer.on("close", () => {
|
|
66
|
+
if (!error) {
|
|
67
|
+
resolve(true);
|
|
68
|
+
}
|
|
69
|
+
//no need to call the reject here, as it will have been called in the
|
|
70
|
+
//'error' stream;
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
};
|
|
75
|
+
exports.writeUrlContents = writeUrlContents;
|
|
@@ -0,0 +1,44 @@
|
|
|
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.defaultTo = void 0;
|
|
7
|
+
const isObject_1 = __importDefault(require("lodash/isObject"));
|
|
8
|
+
const array_1 = require("../array");
|
|
9
|
+
/**
|
|
10
|
+
* Function to default to a value, whilst filtering through an instance
|
|
11
|
+
*/
|
|
12
|
+
const defaultTo = (instance, keys, defaultValue = null) => {
|
|
13
|
+
const keysArray = (0, array_1.getArray)(keys);
|
|
14
|
+
let found = true;
|
|
15
|
+
let pointer = instance;
|
|
16
|
+
// Instance is undefined or is null
|
|
17
|
+
if ("undefined" === typeof instance || null === pointer) {
|
|
18
|
+
found = false;
|
|
19
|
+
}
|
|
20
|
+
// Instance exists
|
|
21
|
+
else {
|
|
22
|
+
keysArray.forEach(key => {
|
|
23
|
+
if (found) {
|
|
24
|
+
// Sub key doesn't exist
|
|
25
|
+
if ((0, isObject_1.default)(pointer)) {
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
if (undefined === pointer[key] || null === pointer[key]) {
|
|
28
|
+
found = false;
|
|
29
|
+
}
|
|
30
|
+
// Sub key exists, update pointer
|
|
31
|
+
else {
|
|
32
|
+
// @ts-ignore
|
|
33
|
+
pointer = pointer[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
found = false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return found ? pointer : defaultValue;
|
|
43
|
+
};
|
|
44
|
+
exports.defaultTo = defaultTo;
|
|
@@ -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.getBrotliCompressed = void 0;
|
|
7
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
8
|
+
/**
|
|
9
|
+
* Compress a given input using Brotli.
|
|
10
|
+
*/
|
|
11
|
+
const getBrotliCompressed = async (input, options = {}) => {
|
|
12
|
+
return new Promise(async (resolve, reject) => {
|
|
13
|
+
zlib_1.default.brotliCompress(input || "", options || {}, (err, data) => {
|
|
14
|
+
if (err) {
|
|
15
|
+
reject(`Error compressing - ${err.message}`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
resolve(data.toString("base64"));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.getBrotliCompressed = getBrotliCompressed;
|
|
@@ -0,0 +1,24 @@
|
|
|
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.getBrotliDecompressed = void 0;
|
|
7
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
8
|
+
/**
|
|
9
|
+
* Decompress a given Brotli input into a string.
|
|
10
|
+
*/
|
|
11
|
+
const getBrotliDecompressed = async (input, options = {}) => {
|
|
12
|
+
return new Promise(async (resolve, reject) => {
|
|
13
|
+
const compressedData = Buffer.from(input || '', "base64");
|
|
14
|
+
zlib_1.default.brotliDecompress(compressedData, options || {}, (err, data) => {
|
|
15
|
+
if (err) {
|
|
16
|
+
reject(`Error decompressing - ${err.message}`);
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
resolve(data.toString('utf8'));
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
exports.getBrotliDecompressed = getBrotliDecompressed;
|
package/util/getClean.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getClean = void 0;
|
|
4
|
+
const getWithoutParameter_1 = require("./getWithoutParameter");
|
|
5
|
+
const getWithoutHash_1 = require("./getWithoutHash");
|
|
6
|
+
/**
|
|
7
|
+
* Return a clean URL with a few options.
|
|
8
|
+
*/
|
|
9
|
+
const getClean = (props) => {
|
|
10
|
+
let response = props.input.toString()
|
|
11
|
+
.trim();
|
|
12
|
+
if (props.parameter) {
|
|
13
|
+
response = (0, getWithoutParameter_1.getWithoutParameter)(response);
|
|
14
|
+
}
|
|
15
|
+
if (props.hash) {
|
|
16
|
+
response = (0, getWithoutHash_1.getWithoutHash)(response);
|
|
17
|
+
}
|
|
18
|
+
if (props.lowercase) {
|
|
19
|
+
response = response.toLowerCase();
|
|
20
|
+
}
|
|
21
|
+
return response;
|
|
22
|
+
};
|
|
23
|
+
exports.getClean = getClean;
|
|
@@ -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.getGzipCompressed = void 0;
|
|
7
|
+
const zlib_1 = __importDefault(require("zlib"));
|
|
8
|
+
/**
|
|
9
|
+
* Compress a given input using Gzip.
|
|
10
|
+
*/
|
|
11
|
+
const getGzipCompressed = async (input, options = {}) => {
|
|
12
|
+
return new Promise(async (resolve, reject) => {
|
|
13
|
+
zlib_1.default.gzip(input || "", options || {}, (err, data) => {
|
|
14
|
+
if (err) {
|
|
15
|
+
reject(`Error compressing - ${err.message}`);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
resolve(data.toString("base64"));
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
exports.getGzipCompressed = getGzipCompressed;
|