@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,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.buildRequest = void 0;
|
|
4
|
-
const server_1 = require("./server");
|
|
5
|
-
const buildRequest = (props) => {
|
|
1
|
+
import { orders, reports } from "./server";
|
|
2
|
+
export const buildRequest = (props) => {
|
|
6
3
|
let url = `https://api.deepcrawl.com/accounts/37204`;
|
|
7
4
|
// Limit must be greater than 0 but also less than 200
|
|
8
5
|
if (undefined !== props.limit) {
|
|
@@ -18,35 +15,35 @@ const buildRequest = (props) => {
|
|
|
18
15
|
props.limit = 200;
|
|
19
16
|
}
|
|
20
17
|
// If a report other than List Crawls is selected, Crawl ID must be defined
|
|
21
|
-
if (undefined !== props.report &&
|
|
18
|
+
if (undefined !== props.report && reports.LIST_CRAWLS !== props.report && undefined == props.crawlId) {
|
|
22
19
|
throw `Crawl ID must be defined.`;
|
|
23
20
|
}
|
|
24
21
|
switch (props.report) {
|
|
25
|
-
case
|
|
22
|
+
case reports.LIST_CRAWLS:
|
|
26
23
|
url += `/projects/${props.projectId}/crawls`;
|
|
27
24
|
break;
|
|
28
|
-
case
|
|
25
|
+
case reports.LIST_PROJECTS:
|
|
29
26
|
url += `/projects`;
|
|
30
27
|
break;
|
|
31
|
-
case
|
|
28
|
+
case reports.CUSTOM:
|
|
32
29
|
url += props.customPath;
|
|
33
30
|
url = url.replace("[PROJECT]", props.projectId.toString());
|
|
34
31
|
url = url.replace("[CRAWL]", props.crawlId.toString());
|
|
35
32
|
break;
|
|
36
|
-
case
|
|
33
|
+
case reports.CRAWL_STATISTICS:
|
|
37
34
|
url += `/projects/${props.projectId}/crawls/${props.crawlId}/statistics`;
|
|
38
35
|
break;
|
|
39
|
-
case
|
|
36
|
+
case reports.LIST_REPORTS:
|
|
40
37
|
url += `/projects/${props.projectId}/crawls/${props.crawlId}/reports`;
|
|
41
38
|
break;
|
|
42
|
-
case
|
|
43
|
-
case
|
|
44
|
-
case
|
|
39
|
+
case reports.REPORT_ROWS:
|
|
40
|
+
case reports.REPORT_STATISTICS:
|
|
41
|
+
case reports.REPORT_SUMMARY:
|
|
45
42
|
url += `/projects/${props.projectId}/crawls/${props.crawlId}/reports/${props.subReport}`;
|
|
46
|
-
if (
|
|
43
|
+
if (reports.REPORT_ROWS === props.report) {
|
|
47
44
|
url += `/report_rows`;
|
|
48
45
|
}
|
|
49
|
-
else if (
|
|
46
|
+
else if (reports.REPORT_STATISTICS === props.report) {
|
|
50
47
|
url += `/statistics`;
|
|
51
48
|
}
|
|
52
49
|
break;
|
|
@@ -71,10 +68,9 @@ const buildRequest = (props) => {
|
|
|
71
68
|
url += -1 === url.indexOf("?") ? "?" : "&";
|
|
72
69
|
props.orders.map((order, index) => {
|
|
73
70
|
url += 0 === index ? "sort=" : ",";
|
|
74
|
-
url +=
|
|
71
|
+
url += orders.DESCENDING === order.direction ? "-" : "";
|
|
75
72
|
url += order.field;
|
|
76
73
|
});
|
|
77
74
|
}
|
|
78
75
|
return url;
|
|
79
76
|
};
|
|
80
|
-
exports.buildRequest = buildRequest;
|
package/lumar/api/getData.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
5
|
-
const getData = async ({ url }) => {
|
|
6
|
-
const apiResponse = await (0, axios_1.get)(url, {
|
|
1
|
+
import { get } from "../../axios";
|
|
2
|
+
export const getData = async ({ url }) => {
|
|
3
|
+
const apiResponse = await get(url, {
|
|
7
4
|
headers: {
|
|
8
5
|
"X-AUTH-TOKEN": global.deepcrawlApi.token,
|
|
9
6
|
},
|
|
10
7
|
});
|
|
11
8
|
return apiResponse;
|
|
12
9
|
};
|
|
13
|
-
exports.getData = getData;
|
package/lumar/api/initClient.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initClient = void 0;
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
1
|
+
import { post } from "../../axios";
|
|
5
2
|
const lumarApis = new Map();
|
|
6
3
|
/**
|
|
7
4
|
* http://api-docs.deepcrawl.com/
|
|
8
5
|
* Renew the Lumar user token.
|
|
9
6
|
* Token lasts for 6 hours.
|
|
10
7
|
*/
|
|
11
|
-
const initClient = async (apiId, apiKey) => {
|
|
8
|
+
export const initClient = async (apiId, apiKey) => {
|
|
12
9
|
if (lumarApis.has(apiId)) {
|
|
13
10
|
return lumarApis.get(apiId);
|
|
14
11
|
}
|
|
15
|
-
const apiResponse = await
|
|
12
|
+
const apiResponse = await post(`https://api.deepcrawl.com/sessions`, {
|
|
16
13
|
auth: {
|
|
17
14
|
username: apiId,
|
|
18
15
|
password: apiKey,
|
|
@@ -23,4 +20,3 @@ const initClient = async (apiId, apiKey) => {
|
|
|
23
20
|
lumarApis.set(apiId, token);
|
|
24
21
|
return token;
|
|
25
22
|
};
|
|
26
|
-
exports.initClient = initClient;
|
package/lumar/api/server.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initClient = exports.getData = exports.buildRequest = exports.reports = exports.orders = exports.operands = void 0;
|
|
4
|
-
exports.operands = {
|
|
1
|
+
export const operands = {
|
|
5
2
|
EQUALS: 'eql',
|
|
6
3
|
CONTAINS: 'cont',
|
|
7
4
|
LESS_THAN: 'lt',
|
|
@@ -11,11 +8,11 @@ exports.operands = {
|
|
|
11
8
|
REGEX: 'rgx',
|
|
12
9
|
NOT_REGEX: 'nrgx',
|
|
13
10
|
};
|
|
14
|
-
|
|
11
|
+
export const orders = {
|
|
15
12
|
ASCENDING: 'asc',
|
|
16
13
|
DESCENDING: 'desc',
|
|
17
14
|
};
|
|
18
|
-
|
|
15
|
+
export const reports = {
|
|
19
16
|
CRAWL_STATISTICS: 'crawl_statistics',
|
|
20
17
|
CUSTOM: 'custom',
|
|
21
18
|
LIST_PROJECTS: 'list_projects',
|
|
@@ -25,9 +22,6 @@ exports.reports = {
|
|
|
25
22
|
REPORT_STATISTICS: 'report_statistics',
|
|
26
23
|
REPORT_SUMMARY: 'report_summary',
|
|
27
24
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
Object.defineProperty(exports, "getData", { enumerable: true, get: function () { return getData_1.getData; } });
|
|
32
|
-
var initClient_1 = require("./initClient");
|
|
33
|
-
Object.defineProperty(exports, "initClient", { enumerable: true, get: function () { return initClient_1.initClient; } });
|
|
25
|
+
export { buildRequest } from "./buildRequest";
|
|
26
|
+
export { getData } from "./getData";
|
|
27
|
+
export { initClient } from "./initClient";
|
package/lumar/graphql/columns.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.columns = void 0;
|
|
4
|
-
exports.columns = {
|
|
1
|
+
export const columns = {
|
|
5
2
|
CUSTOM_EXTRACTION_1: 'customExtraction1',
|
|
6
3
|
CUSTOM_EXTRACTION_2: 'customExtraction2',
|
|
7
4
|
DEEP_RANK: 'deepRank',
|
package/lumar/graphql/getData.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getData = void 0;
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
5
|
-
const getData = async (query, variables = {}) => {
|
|
1
|
+
import { post } from "../../axios";
|
|
2
|
+
export const getData = async (query, variables = {}) => {
|
|
6
3
|
let queryClean = query.trim();
|
|
7
4
|
queryClean = queryClean.replace(/\n/g, " ");
|
|
8
5
|
queryClean = queryClean.replace(/\t/g, " ");
|
|
9
6
|
queryClean = queryClean.replace(/ /g, " ");
|
|
10
|
-
const apiResponse = await
|
|
7
|
+
const apiResponse = await post("https://api.lumar.io/graphql", {
|
|
11
8
|
query: queryClean,
|
|
12
9
|
variables,
|
|
13
10
|
}, {
|
|
@@ -17,4 +14,3 @@ const getData = async (query, variables = {}) => {
|
|
|
17
14
|
});
|
|
18
15
|
return apiResponse;
|
|
19
16
|
};
|
|
20
|
-
exports.getData = getData;
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initClient = void 0;
|
|
4
|
-
const axios_1 = require("../../axios");
|
|
1
|
+
import { post } from "../../axios";
|
|
5
2
|
const lumarGraphQls = new Map();
|
|
6
3
|
/**
|
|
7
4
|
* https://api-docs.lumar.io/graphql/explorer/
|
|
8
5
|
* Renew the Lumar user token.
|
|
9
6
|
*/
|
|
10
|
-
const initClient = async (id, secret) => {
|
|
7
|
+
export const initClient = async (id, secret) => {
|
|
11
8
|
if (lumarGraphQls.has(id)) {
|
|
12
9
|
return lumarGraphQls.get(id);
|
|
13
10
|
}
|
|
14
|
-
const apiResponse = await
|
|
11
|
+
const apiResponse = await post(`https://api.lumar.io/graphql`, {
|
|
15
12
|
query: "mutation LoginWithUserKey($secret: String!, $userKeyId: ObjectID!) { createSessionUsingUserKey(input: {userKeyId: $userKeyId, secret: $secret}) { token }}",
|
|
16
13
|
variables: {
|
|
17
14
|
userKeyId: id,
|
|
@@ -22,4 +19,3 @@ const initClient = async (id, secret) => {
|
|
|
22
19
|
lumarGraphQls.set(id, token);
|
|
23
20
|
return token;
|
|
24
21
|
};
|
|
25
|
-
exports.initClient = initClient;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/**
|
|
4
2
|
* For a given Project ID return all the crawls that were completed in descending order.
|
|
5
3
|
*/
|
|
@@ -30,4 +28,4 @@ const getCrawls = ({ first, projectId }) => ({
|
|
|
30
28
|
projectId,
|
|
31
29
|
},
|
|
32
30
|
});
|
|
33
|
-
|
|
31
|
+
export default getCrawls;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const server_1 = require("../server");
|
|
1
|
+
import { reportTypes } from "../server";
|
|
4
2
|
/**
|
|
5
3
|
* Used to return the number for: Basic, Added, Missing, Removed for a given report.
|
|
6
4
|
*/
|
|
@@ -30,8 +28,8 @@ const getReportDifferences = ({ crawlId, filter, reportTemplateCode }) => ({
|
|
|
30
28
|
input: {
|
|
31
29
|
crawlId,
|
|
32
30
|
reportTemplateCode,
|
|
33
|
-
reportTypeCode:
|
|
31
|
+
reportTypeCode: reportTypes.BASIC,
|
|
34
32
|
},
|
|
35
33
|
},
|
|
36
34
|
});
|
|
37
|
-
|
|
35
|
+
export default getReportDifferences;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const getRows = ({ after, before, crawlId, filter, first, last, orderBy, reportTemplateCode, reportTypeCode }) => ({
|
|
4
2
|
id: `get-rows-${crawlId}-${reportTemplateCode}-${reportTypeCode}`.toLowerCase(),
|
|
5
3
|
after,
|
|
@@ -54,4 +52,4 @@ const getRows = ({ after, before, crawlId, filter, first, last, orderBy, reportT
|
|
|
54
52
|
orderBy: orderBy || null,
|
|
55
53
|
},
|
|
56
54
|
});
|
|
57
|
-
|
|
55
|
+
export default getRows;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
const getTotals = ({ crawlId, filter, filterKey, reportTemplateCode, reportTypeCode }) => ({
|
|
4
2
|
id: `get-totals-${crawlId}-${reportTemplateCode}-${reportTypeCode}`.toLowerCase(),
|
|
5
3
|
crawlId,
|
|
@@ -37,4 +35,4 @@ const getTotals = ({ crawlId, filter, filterKey, reportTemplateCode, reportTypeC
|
|
|
37
35
|
},
|
|
38
36
|
},
|
|
39
37
|
});
|
|
40
|
-
|
|
38
|
+
export default getTotals;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reportTemplates = void 0;
|
|
4
|
-
exports.reportTemplates = {
|
|
1
|
+
export const reportTemplates = {
|
|
5
2
|
"200_PAGES": "200_pages",
|
|
6
3
|
"301_REDIRECTS": "301_redirects",
|
|
7
4
|
"4XX_ERRORS": "4xx_errors",
|
package/lumar/graphql/server.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.initClient = exports.getData = exports.reportTemplates = exports.columns = exports.getReportKey = exports.reportTypes = exports.operands = void 0;
|
|
4
|
-
exports.operands = {
|
|
1
|
+
export const operands = {
|
|
5
2
|
CONTAINS: "contains",
|
|
6
3
|
DOESNT_CONTAIN: "notContains",
|
|
7
4
|
DOESNT_MATCH_REGEX: "notMatchesRegex",
|
|
@@ -16,7 +13,7 @@ exports.operands = {
|
|
|
16
13
|
NOT_EQUALS: "ne",
|
|
17
14
|
STARTS_WITH: "beginsWith",
|
|
18
15
|
};
|
|
19
|
-
|
|
16
|
+
export const reportTypes = {
|
|
20
17
|
ADDED: "Added",
|
|
21
18
|
BASIC: "Basic",
|
|
22
19
|
MISSING: "Missing",
|
|
@@ -25,15 +22,10 @@ exports.reportTypes = {
|
|
|
25
22
|
/**
|
|
26
23
|
* Shorthand function to return the report key.
|
|
27
24
|
*/
|
|
28
|
-
const getReportKey = (templateCode, typeCode) => {
|
|
25
|
+
export const getReportKey = (templateCode, typeCode) => {
|
|
29
26
|
return `${templateCode}-${typeCode}`.toLowerCase();
|
|
30
27
|
};
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(exports, "reportTemplates", { enumerable: true, get: function () { return reportTemplates_1.reportTemplates; } });
|
|
36
|
-
var getData_1 = require("./getData");
|
|
37
|
-
Object.defineProperty(exports, "getData", { enumerable: true, get: function () { return getData_1.getData; } });
|
|
38
|
-
var initClient_1 = require("./initClient");
|
|
39
|
-
Object.defineProperty(exports, "initClient", { enumerable: true, get: function () { return initClient_1.initClient; } });
|
|
28
|
+
export { columns } from "./columns";
|
|
29
|
+
export { reportTemplates } from "./reportTemplates";
|
|
30
|
+
export { getData } from "./getData";
|
|
31
|
+
export { initClient } from "./initClient";
|
package/myTarget/server.js
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.request = void 0;
|
|
4
|
-
const axios_1 = require("../axios");
|
|
1
|
+
import { post } from "../axios";
|
|
5
2
|
/**
|
|
6
3
|
* Make the request to MyTarget API using the access token.
|
|
7
4
|
*/
|
|
8
|
-
const request = async (data, url) => {
|
|
9
|
-
const response = await
|
|
5
|
+
export const request = async (data, url) => {
|
|
6
|
+
const response = await post(url, data, {
|
|
10
7
|
headers: {
|
|
11
8
|
Authorization: `Bearer ${global.myTargetAccessToken}`,
|
|
12
9
|
"Content-Type": "application/json",
|
|
@@ -14,4 +11,3 @@ const request = async (data, url) => {
|
|
|
14
11
|
});
|
|
15
12
|
return response;
|
|
16
13
|
};
|
|
17
|
-
exports.request = request;
|
package/nextAuth/index.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NextAuthState = exports.isSessionReady = void 0;
|
|
4
|
-
var isSessionReady_1 = require("./isSessionReady");
|
|
5
|
-
Object.defineProperty(exports, "isSessionReady", { enumerable: true, get: function () { return isSessionReady_1.isSessionReady; } });
|
|
6
|
-
exports.NextAuthState = {
|
|
1
|
+
export { isSessionReady } from "./isSessionReady";
|
|
2
|
+
export const NextAuthState = {
|
|
7
3
|
AUTHENTICATED: "authenticated",
|
|
8
4
|
PENDING: "loading", // Defined by NextAuth
|
|
9
5
|
UNAUTHENTICATED: "unauthenticated",
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isSessionReady = void 0;
|
|
4
|
-
const isSessionReady = (session) => {
|
|
1
|
+
export const isSessionReady = (session) => {
|
|
5
2
|
let response = false;
|
|
6
3
|
if (undefined !== session && null !== session) {
|
|
7
4
|
if (undefined !== session.user && null !== session.user) {
|
|
@@ -10,4 +7,3 @@ const isSessionReady = (session) => {
|
|
|
10
7
|
}
|
|
11
8
|
return response;
|
|
12
9
|
};
|
|
13
|
-
exports.isSessionReady = isSessionReady;
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.LazyLoad = void 0;
|
|
7
|
-
const react_intersection_observer_1 = require("react-intersection-observer");
|
|
8
|
-
const react_1 = __importDefault(require("react"));
|
|
9
|
-
const LazyLoad = (props) => {
|
|
1
|
+
import { useInView } from "react-intersection-observer";
|
|
2
|
+
import React from "react";
|
|
3
|
+
export const LazyLoad = (props) => {
|
|
10
4
|
const { children, ...propsRest } = props;
|
|
11
|
-
const { ref, inView } =
|
|
12
|
-
return (
|
|
5
|
+
const { ref, inView } = useInView(propsRest);
|
|
6
|
+
return (React.createElement("div", { ref: ref }, inView && children));
|
|
13
7
|
};
|
|
14
|
-
exports.LazyLoad = LazyLoad;
|
package/nextJs/client.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LazyLoad = void 0;
|
|
4
|
-
var LazyLoad_1 = require("./client/LazyLoad");
|
|
5
|
-
Object.defineProperty(exports, "LazyLoad", { enumerable: true, get: function () { return LazyLoad_1.LazyLoad; } });
|
|
1
|
+
export { LazyLoad } from "./client/LazyLoad";
|
package/nextJs/index.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getUserAgent = exports.getIp = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Get the user's remote IP Address
|
|
6
3
|
*/
|
|
7
|
-
const getIp = ({ req }) => {
|
|
4
|
+
export const getIp = ({ req }) => {
|
|
8
5
|
let response = 'unset';
|
|
9
6
|
if (undefined !== req.headers['x-real-ip']) {
|
|
10
7
|
response = String(req.headers['x-real-ip']);
|
|
11
8
|
}
|
|
12
9
|
return response;
|
|
13
10
|
};
|
|
14
|
-
exports.getIp = getIp;
|
|
15
11
|
/**
|
|
16
12
|
* Get the user's User Agent
|
|
17
13
|
*/
|
|
18
|
-
const getUserAgent = ({ req }) => req.headers['user-agent'] || 'unset';
|
|
19
|
-
exports.getUserAgent = getUserAgent;
|
|
14
|
+
export const getUserAgent = ({ req }) => req.headers['user-agent'] || 'unset';
|
package/number/format.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.format = void 0;
|
|
4
|
-
const getNumber_1 = require("./getNumber");
|
|
1
|
+
import { getNumber } from "./getNumber";
|
|
5
2
|
/**
|
|
6
3
|
* Take a given number and format it.
|
|
7
4
|
*/
|
|
8
|
-
const format = (props) => {
|
|
5
|
+
export const format = (props) => {
|
|
9
6
|
const minDp = props?.minDp ?? 0;
|
|
10
7
|
const maxDp = props?.maxDp ?? 2;
|
|
11
8
|
const compact = props?.compact || false;
|
|
12
|
-
const inputValue =
|
|
9
|
+
const inputValue = getNumber(props.input);
|
|
13
10
|
return Intl.NumberFormat(props?.locale || "en-GB", {
|
|
14
11
|
minimumFractionDigits: minDp,
|
|
15
12
|
maximumFractionDigits: maxDp,
|
|
@@ -17,4 +14,3 @@ const format = (props) => {
|
|
|
17
14
|
})
|
|
18
15
|
.format(inputValue);
|
|
19
16
|
};
|
|
20
|
-
exports.format = format;
|
package/number/formatCurrency.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatCurrency = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Use the International number formatting to return the currency value.
|
|
6
3
|
* https://www.freecodecamp.org/news/how-to-format-number-as-currency-in-javascript-one-line-of-code/
|
|
7
4
|
*/
|
|
8
|
-
const formatCurrency = (input, locale = "en-GB", currency = "GBP") => {
|
|
5
|
+
export const formatCurrency = (input, locale = "en-GB", currency = "GBP") => {
|
|
9
6
|
const value = Number(input);
|
|
10
7
|
const currencyClean = currency.toUpperCase()
|
|
11
8
|
.trim();
|
|
@@ -18,4 +15,3 @@ const formatCurrency = (input, locale = "en-GB", currency = "GBP") => {
|
|
|
18
15
|
}
|
|
19
16
|
return formatted;
|
|
20
17
|
};
|
|
21
|
-
exports.formatCurrency = formatCurrency;
|
package/number/getDecimal.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getDecimal = void 0;
|
|
4
|
-
const getNumber_1 = require("./getNumber");
|
|
1
|
+
import { getNumber } from "./getNumber";
|
|
5
2
|
/**
|
|
6
3
|
* Return a decimal number after rounding.
|
|
7
4
|
*/
|
|
8
|
-
const getDecimal = (input, dp = 2) => {
|
|
9
|
-
const number =
|
|
5
|
+
export const getDecimal = (input, dp = 2) => {
|
|
6
|
+
const number = getNumber(input);
|
|
10
7
|
return Number(number.toFixed(dp));
|
|
11
8
|
};
|
|
12
|
-
exports.getDecimal = getDecimal;
|
package/number/getNumber.js
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNumber = void 0;
|
|
4
|
-
const json_1 = require("../json");
|
|
1
|
+
import { isJson } from "../json";
|
|
5
2
|
/**
|
|
6
3
|
* Take an input and return a number.
|
|
7
4
|
*/
|
|
8
|
-
const getNumber = (input, defaultValue = 0) => {
|
|
5
|
+
export const getNumber = (input, defaultValue = 0) => {
|
|
9
6
|
// Handle null/undefined inputs
|
|
10
7
|
if (input == null) {
|
|
11
8
|
return defaultValue;
|
|
12
9
|
}
|
|
13
10
|
let response = input;
|
|
14
11
|
// JSON - Decode the value if it's a JSON string
|
|
15
|
-
if (typeof input === "string" &&
|
|
12
|
+
if (typeof input === "string" && isJson(input)) {
|
|
16
13
|
try {
|
|
17
14
|
response = JSON.parse(input);
|
|
18
15
|
}
|
|
@@ -45,4 +42,3 @@ const getNumber = (input, defaultValue = 0) => {
|
|
|
45
42
|
const converted = Number(response);
|
|
46
43
|
return isNaN(converted) ? defaultValue : converted;
|
|
47
44
|
};
|
|
48
|
-
exports.getNumber = getNumber;
|
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getPercentIncrease = void 0;
|
|
4
|
-
const getNumber_1 = require("./getNumber");
|
|
1
|
+
import { getNumber } from "./getNumber";
|
|
5
2
|
/**
|
|
6
3
|
* Formula to work out the percentage increase/decrease.
|
|
7
4
|
*/
|
|
8
|
-
const getPercentIncrease = (current, comparison, defaultValue) => {
|
|
9
|
-
const currentValue =
|
|
10
|
-
const comparisonValue =
|
|
5
|
+
export const getPercentIncrease = (current, comparison, defaultValue) => {
|
|
6
|
+
const currentValue = getNumber(current);
|
|
7
|
+
const comparisonValue = getNumber(comparison);
|
|
11
8
|
if (0 === comparisonValue) {
|
|
12
9
|
return defaultValue;
|
|
13
10
|
}
|
|
14
11
|
return (currentValue - comparisonValue) / comparisonValue * 100;
|
|
15
12
|
};
|
|
16
|
-
exports.getPercentIncrease = getPercentIncrease;
|
package/number/getSafeDivide.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getSafeDivide = void 0;
|
|
4
|
-
const getNumber_1 = require("./getNumber");
|
|
5
|
-
const getDecimal_1 = require("./getDecimal");
|
|
1
|
+
import { getNumber } from "./getNumber";
|
|
2
|
+
import { getDecimal } from "./getDecimal";
|
|
6
3
|
/**
|
|
7
4
|
* Shorthand function to divide number, but fallback if the divisor is 0.
|
|
8
5
|
*/
|
|
9
|
-
const getSafeDivide = (props) => {
|
|
10
|
-
const numeratorInt =
|
|
6
|
+
export const getSafeDivide = (props) => {
|
|
7
|
+
const numeratorInt = getNumber(props.numerator);
|
|
11
8
|
if (numeratorInt === 0) {
|
|
12
9
|
return 0;
|
|
13
10
|
}
|
|
14
|
-
const divisorInt =
|
|
11
|
+
const divisorInt = getNumber(props.divisor);
|
|
15
12
|
if (divisorInt === 0 || !Number.isFinite(divisorInt)) {
|
|
16
13
|
return props?.defaultValue ?? 0;
|
|
17
14
|
}
|
|
18
|
-
return
|
|
15
|
+
return getDecimal(numeratorInt / divisorInt, props?.dp);
|
|
19
16
|
};
|
|
20
|
-
exports.getSafeDivide = getSafeDivide;
|
package/number/index.js
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "formatCurrency", { enumerable: true, get: function () { return formatCurrency_1.formatCurrency; } });
|
|
8
|
-
var getDecimal_1 = require("./getDecimal");
|
|
9
|
-
Object.defineProperty(exports, "getDecimal", { enumerable: true, get: function () { return getDecimal_1.getDecimal; } });
|
|
10
|
-
var getSafeDivide_1 = require("./getSafeDivide");
|
|
11
|
-
Object.defineProperty(exports, "getSafeDivide", { enumerable: true, get: function () { return getSafeDivide_1.getSafeDivide; } });
|
|
12
|
-
var getNumber_1 = require("./getNumber");
|
|
13
|
-
Object.defineProperty(exports, "getNumber", { enumerable: true, get: function () { return getNumber_1.getNumber; } });
|
|
14
|
-
var getPercentIncrease_1 = require("./getPercentIncrease");
|
|
15
|
-
Object.defineProperty(exports, "getPercentIncrease", { enumerable: true, get: function () { return getPercentIncrease_1.getPercentIncrease; } });
|
|
1
|
+
export { format } from "./format";
|
|
2
|
+
export { formatCurrency } from "./formatCurrency";
|
|
3
|
+
export { getDecimal } from "./getDecimal";
|
|
4
|
+
export { getSafeDivide } from "./getSafeDivide";
|
|
5
|
+
export { getNumber } from "./getNumber";
|
|
6
|
+
export { getPercentIncrease } from "./getPercentIncrease";
|
package/object/index.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceKeys = void 0;
|
|
4
|
-
var replaceKeys_1 = require("./replaceKeys");
|
|
5
|
-
Object.defineProperty(exports, "replaceKeys", { enumerable: true, get: function () { return replaceKeys_1.replaceKeys; } });
|
|
1
|
+
export { replaceKeys } from "./replaceKeys";
|
package/object/replaceKeys.js
CHANGED
|
@@ -1,25 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.replaceKeys = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Iteratively replace all the keys in an object.
|
|
6
3
|
* https://www.techighness.com/post/replace-all-keys-of-deeply-nested-objects-or-array-of-objects/
|
|
7
4
|
*/
|
|
8
|
-
const replaceKeys = (instance, getNewKey) => {
|
|
5
|
+
export const replaceKeys = (instance, getNewKey) => {
|
|
9
6
|
let response = instance;
|
|
10
7
|
if (Array.isArray(instance)) {
|
|
11
8
|
response = [];
|
|
12
9
|
for (let i = 0; i < instance.length; i++) {
|
|
13
|
-
response[i] =
|
|
10
|
+
response[i] = replaceKeys(instance[i], getNewKey);
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
13
|
else if ("object" === typeof instance) {
|
|
17
14
|
response = {};
|
|
18
15
|
for (const key in instance) {
|
|
19
16
|
const newKey = getNewKey(key);
|
|
20
|
-
response[newKey] =
|
|
17
|
+
response[newKey] = replaceKeys(instance[key], getNewKey);
|
|
21
18
|
}
|
|
22
19
|
}
|
|
23
20
|
return response;
|
|
24
21
|
};
|
|
25
|
-
exports.replaceKeys = replaceKeys;
|