@8ms/helpers 1.1.73 → 1.1.75
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/api/response.d.ts +8 -0
- package/api/response.js +12 -1
- package/api/states.d.ts +9 -0
- package/api/states.js +10 -1
- package/api/unexpectedError.d.ts +2 -0
- package/api/unexpectedError.js +4 -1
- package/array/contains.d.ts +8 -0
- package/array/contains.js +6 -2
- package/array/getArray.d.ts +7 -0
- package/array/getArray.js +10 -2
- package/atInternet/request.d.ts +30 -0
- package/atInternet/request.js +2 -1
- package/aws/athenaExpress/initClient.d.ts +12 -0
- package/aws/athenaExpress/initClient.js +27 -3
- package/aws/athenaExpress/query.d.ts +8 -0
- package/aws/athenaExpress/query.js +9 -2
- package/aws/getConfig.d.ts +13 -0
- package/aws/getConfig.js +26 -2
- package/aws/glue/initClient.d.ts +10 -0
- package/aws/glue/initClient.js +17 -2
- package/aws/glue/invoke.d.ts +9 -0
- package/aws/glue/invoke.js +19 -2
- package/aws/isResponse200.d.ts +7 -0
- package/aws/isResponse200.js +21 -2
- package/aws/lambda/getHandlerPath.d.ts +5 -0
- package/aws/lambda/getHandlerPath.js +7 -1
- package/aws/lambda/initClient.d.ts +10 -0
- package/aws/lambda/initClient.js +17 -2
- package/aws/lambda/invoke.d.ts +12 -0
- package/aws/lambda/invoke.js +39 -2
- package/aws/s3/copyFile.d.ts +13 -0
- package/aws/s3/copyFile.js +13 -2
- package/aws/s3/deleteFile.d.ts +9 -0
- package/aws/s3/deleteFile.js +12 -2
- package/aws/s3/deleteFiles.d.ts +9 -0
- package/aws/s3/deleteFiles.js +16 -2
- package/aws/s3/deleteFolder.d.ts +9 -0
- package/aws/s3/deleteFolder.js +35 -2
- package/aws/s3/getGlueJson.d.ts +5 -0
- package/aws/s3/getGlueJson.js +15 -2
- package/aws/s3/getPresignedPost.d.ts +20 -0
- package/aws/s3/getPresignedPost.js +16 -3
- package/aws/s3/getSignedUrl.d.ts +12 -0
- package/aws/s3/getSignedUrl.js +15 -2
- package/aws/s3/initClient.d.ts +10 -0
- package/aws/s3/initClient.js +17 -2
- package/aws/s3/isFileExists.d.ts +9 -0
- package/aws/s3/isFileExists.js +26 -2
- package/aws/s3/listFiles.d.ts +9 -0
- package/aws/s3/listFiles.js +32 -2
- package/aws/s3/listFolders.d.ts +9 -0
- package/aws/s3/listFolders.js +31 -4
- package/aws/s3/moveFile.d.ts +10 -0
- package/aws/s3/moveFile.js +20 -2
- package/aws/s3/readBuffer.d.ts +13 -0
- package/aws/s3/readBuffer.js +51 -2
- package/aws/s3/readFile.d.ts +30 -0
- package/aws/s3/readFile.js +69 -2
- package/aws/s3/writeFile.d.ts +10 -0
- package/aws/s3/writeFile.js +15 -2
- package/aws/s3/writePresignedPost.d.ts +14 -0
- package/aws/s3/writePresignedPost.js +30 -2
- package/aws/s3cache/cache.d.ts +7 -0
- package/aws/s3cache/cache.js +2 -1
- package/aws/s3cache/getCache.d.ts +12 -0
- package/aws/s3cache/getCache.js +35 -2
- package/aws/s3cache/getKey.d.ts +10 -0
- package/aws/s3cache/getKey.js +16 -2
- package/aws/s3cache/saveCache.d.ts +10 -0
- package/aws/s3cache/saveCache.js +12 -2
- package/aws/s3cache/updateCache.d.ts +10 -0
- package/aws/s3cache/updateCache.js +23 -2
- package/aws/ses/SimpleEmail.d.ts +51 -0
- package/aws/ses/SimpleEmail.js +115 -2
- package/aws/ses/initClient.d.ts +10 -0
- package/aws/ses/initClient.js +17 -2
- package/aws/ssm/getParameter.d.ts +10 -0
- package/aws/ssm/getParameter.js +39 -2
- package/aws/ssm/initClient.d.ts +10 -0
- package/aws/ssm/initClient.js +17 -2
- package/axios/get.d.ts +8 -0
- package/axios/get.js +44 -1
- package/axios/post.d.ts +12 -0
- package/axios/post.js +46 -2
- package/boolean/getBoolean.d.ts +7 -0
- package/boolean/getBoolean.js +15 -2
- package/class/BaseClass.d.ts +31 -0
- package/class/BaseClass.js +50 -9
- package/crud/actions.d.ts +8 -0
- package/crud/actions.js +10 -1
- package/crypto/getDecrypt.d.ts +10 -0
- package/crypto/getDecrypt.js +11 -2
- package/crypto/getEncrypt.d.ts +10 -0
- package/crypto/getEncrypt.js +11 -2
- package/crypto/getRandom.d.ts +8 -0
- package/crypto/getRandom.js +10 -2
- package/crypto/getSha256.d.ts +8 -0
- package/crypto/getSha256.js +15 -2
- package/date/date.d.ts +4 -0
- package/date/date.js +2 -1
- package/date/duration.d.ts +5 -0
- package/date/duration.js +2 -1
- package/date/durationComparisons.d.ts +5 -0
- package/date/durationComparisons.js +7 -1
- package/date/durations.d.ts +8 -0
- package/date/durations.js +10 -1
- package/date/financialYear.d.ts +4 -0
- package/date/financialYear.js +2 -1
- package/date/financialYearWeek.d.ts +6 -0
- package/date/financialYearWeek.js +2 -1
- package/date/format.d.ts +13 -0
- package/date/format.js +18 -2
- package/date/getDate.d.ts +12 -0
- package/date/getDate.js +96 -9
- package/date/getDatesBetween.d.ts +10 -0
- package/date/getDatesBetween.js +25 -3
- package/date/getDurationHours.d.ts +8 -0
- package/date/getDurationHours.js +25 -2
- package/date/getDurationMinutes.d.ts +8 -0
- package/date/getDurationMinutes.js +24 -2
- package/date/getFinancialYear.d.ts +9 -0
- package/date/getFinancialYear.js +48 -8
- package/date/getFinancialYearToDate.d.ts +7 -0
- package/date/getFinancialYearToDate.js +18 -2
- package/date/getFinancialYearToYesterday.d.ts +7 -0
- package/date/getFinancialYearToYesterday.js +18 -2
- package/date/getFinancialYearWeeks.d.ts +9 -0
- package/date/getFinancialYearWeeks.js +29 -2
- package/date/getLastWeek.d.ts +10 -0
- package/date/getLastWeek.js +28 -2
- package/date/getMax.d.ts +12 -0
- package/date/getMax.js +15 -2
- package/date/getMidnight.d.ts +10 -0
- package/date/getMidnight.js +12 -2
- package/date/getMin.d.ts +12 -0
- package/date/getMin.js +15 -2
- package/date/getMonday.d.ts +14 -0
- package/date/getMonday.js +32 -5
- package/date/getNumber.d.ts +11 -0
- package/date/getNumber.js +14 -2
- package/date/getPredefinedTimeframe.d.ts +9 -0
- package/date/getPredefinedTimeframe.js +23 -2
- package/date/getSunday.d.ts +14 -0
- package/date/getSunday.js +32 -5
- package/date/getThisWeek.d.ts +10 -0
- package/date/getThisWeek.js +28 -2
- package/date/getTimeZoned.d.ts +13 -0
- package/date/getTimeZoned.js +36 -5
- package/date/getToday.d.ts +9 -0
- package/date/getToday.js +39 -2
- package/date/getTwoWeeksAgo.d.ts +10 -0
- package/date/getTwoWeeksAgo.js +28 -2
- package/date/getWeeksAgo.d.ts +12 -0
- package/date/getWeeksAgo.js +16 -2
- package/date/getYesterday.d.ts +9 -0
- package/date/getYesterday.js +40 -2
- package/date/isDateValid.d.ts +7 -0
- package/date/isDateValid.js +22 -2
- package/date/isLastWeek.d.ts +6 -0
- package/date/isLastWeek.js +13 -2
- package/date/isThisWeek.d.ts +6 -0
- package/date/isThisWeek.js +13 -2
- package/date/parseExcelDate.d.ts +8 -0
- package/date/parseExcelDate.js +17 -2
- package/date/predefinedTimeframes.d.ts +7 -0
- package/date/predefinedTimeframes.js +9 -1
- package/date/timeframe.d.ts +8 -0
- package/date/timeframe.js +2 -1
- package/date/timeframes.d.ts +4 -0
- package/date/timeframes.js +7 -1
- package/deepCrawl/buildRequest.d.ts +15 -0
- package/deepCrawl/buildRequest.js +83 -4
- package/deepCrawl/filter.d.ts +5 -0
- package/deepCrawl/filter.js +2 -1
- package/deepCrawl/getData.d.ts +5 -0
- package/deepCrawl/getData.js +29 -1
- package/deepCrawl/initClient.d.ts +13 -0
- package/deepCrawl/initClient.js +31 -2
- package/deepCrawl/operands.d.ts +11 -0
- package/deepCrawl/operands.js +13 -1
- package/deepCrawl/orders.d.ts +9 -0
- package/deepCrawl/orders.js +7 -1
- package/deepCrawl/reports.d.ts +11 -0
- package/deepCrawl/reports.js +13 -1
- package/environment/environments.d.ts +7 -0
- package/environment/environments.js +8 -1
- package/environment/getEnvironment.d.ts +6 -0
- package/environment/getEnvironment.js +42 -2
- package/environment/isAws.d.ts +5 -0
- package/environment/isAws.js +10 -2
- package/environment/isDevelopment.d.ts +2 -0
- package/environment/isDevelopment.js +9 -1
- package/environment/isLocalhost.d.ts +5 -0
- package/environment/isLocalhost.js +21 -2
- package/environment/isProduction.d.ts +2 -0
- package/environment/isProduction.js +9 -1
- package/environment/isStaging.d.ts +2 -0
- package/environment/isStaging.js +9 -1
- package/environment/isVercel.d.ts +5 -0
- package/environment/isVercel.js +6 -2
- package/environment/platforms.d.ts +6 -0
- package/environment/platforms.js +7 -1
- package/eskimi/ageGroups.d.ts +5 -0
- package/eskimi/ageGroups.js +41 -1
- package/eskimi/campaign.d.ts +19 -0
- package/eskimi/campaign.js +2 -1
- package/eskimi/devices.d.ts +5 -0
- package/eskimi/devices.js +13 -1
- package/eskimi/endpoints.d.ts +16 -0
- package/eskimi/endpoints.js +17 -2
- package/eskimi/genders.d.ts +5 -0
- package/eskimi/genders.js +13 -1
- package/eskimi/getAccessToken.d.ts +9 -0
- package/eskimi/getAccessToken.js +22 -2
- package/eskimi/getAgeGroup.d.ts +7 -0
- package/eskimi/getAgeGroup.js +16 -2
- package/eskimi/getCampaignIds.d.ts +7 -0
- package/eskimi/getCampaignIds.js +11 -2
- package/eskimi/getDevice.d.ts +7 -0
- package/eskimi/getDevice.js +16 -2
- package/eskimi/getGender.d.ts +7 -0
- package/eskimi/getGender.js +16 -2
- package/eskimi/request.d.ts +8 -0
- package/eskimi/request.js +23 -2
- package/google/bigQuery/initClient.d.ts +11 -0
- package/google/bigQuery/initClient.js +20 -2
- package/google/bigQuery/query.d.ts +9 -0
- package/google/bigQuery/query.js +9 -2
- package/google/getConfig.d.ts +20 -0
- package/google/getConfig.js +21 -3
- package/google/sheets/getAssociatedData.d.ts +16 -0
- package/google/sheets/getAssociatedData.js +52 -8
- package/google/sheets/getBatchData.d.ts +18 -0
- package/google/sheets/getBatchData.js +19 -1
- package/google/sheets/initClient.d.ts +11 -0
- package/google/sheets/initClient.js +22 -2
- package/google/sheets/isCellNa.d.ts +7 -0
- package/google/sheets/isCellNa.js +6 -2
- package/google/storage/initClient.d.ts +12 -0
- package/google/storage/initClient.js +20 -2
- package/google/storage/writeFile.d.ts +12 -0
- package/google/storage/writeFile.js +30 -2
- package/googleAds/getCustomer.d.ts +8 -0
- package/googleAds/getCustomer.js +13 -2
- package/googleAds/initClient.d.ts +16 -0
- package/googleAds/initClient.js +23 -2
- package/initClients.d.ts +40 -0
- package/initClients.js +106 -5
- package/json/isJson.d.ts +8 -0
- package/json/isJson.js +18 -2
- package/littleWarden/getUrlStatus.d.ts +9 -0
- package/littleWarden/getUrlStatus.js +20 -2
- package/littleWarden/isAllGood.d.ts +7 -0
- package/littleWarden/isAllGood.js +17 -2
- package/littleWarden/isDanger.d.ts +7 -0
- package/littleWarden/isDanger.js +17 -2
- package/littleWarden/isWarning.d.ts +7 -0
- package/littleWarden/isWarning.js +17 -2
- package/littleWarden/states.d.ts +7 -0
- package/littleWarden/states.js +8 -1
- package/myTarget/getAccessToken.d.ts +9 -0
- package/myTarget/getAccessToken.js +22 -2
- package/myTarget/request.d.ts +8 -0
- package/myTarget/request.js +23 -2
- package/nextAuth/isSessionReady.d.ts +4 -0
- package/nextAuth/isSessionReady.js +12 -1
- package/nextAuth/states.d.ts +7 -0
- package/nextAuth/states.js +8 -2
- package/nextJs/getIp.d.ts +7 -0
- package/nextJs/getIp.js +12 -2
- package/nextJs/getUserAgent.d.ts +7 -0
- package/nextJs/getUserAgent.js +6 -2
- package/number/getDivide.d.ts +9 -0
- package/number/getDivide.js +17 -2
- package/number/getNumber.d.ts +8 -0
- package/number/getNumber.js +50 -7
- package/number/getPercent.d.ts +9 -0
- package/number/getPercent.js +17 -2
- package/number/getPercentIncrease.d.ts +9 -0
- package/number/getPercentIncrease.js +17 -2
- package/number/getRounded.d.ts +9 -0
- package/number/getRounded.js +21 -2
- package/package.json +44 -47
- package/prisma/initClient.d.ts +4 -0
- package/prisma/initClient.js +33 -3
- package/snapchat/getAccessToken.d.ts +9 -0
- package/snapchat/getAccessToken.js +36 -2
- package/sorting/byNumberAscending.d.ts +8 -0
- package/sorting/byNumberAscending.js +16 -2
- package/sorting/byNumberDescending.d.ts +8 -0
- package/sorting/byNumberDescending.js +16 -2
- package/sorting/byStringAscending.d.ts +8 -0
- package/sorting/byStringAscending.js +20 -2
- package/sorting/byStringDescending.d.ts +8 -0
- package/sorting/byStringDescending.js +20 -2
- package/string/formatCapitalise.d.ts +9 -0
- package/string/formatCapitalise.js +14 -2
- package/string/getCleanFolder.d.ts +7 -0
- package/string/getCleanFolder.js +11 -2
- package/string/getString.d.ts +7 -0
- package/string/getString.js +35 -2
- package/string/getStringFromStream.d.ts +8 -0
- package/string/getStringFromStream.js +14 -2
- package/string/toProperCase.d.ts +7 -0
- package/string/toProperCase.js +17 -2
- package/swr/isAllData.d.ts +7 -0
- package/swr/isAllData.js +18 -2
- package/swr/isAnyError.d.ts +7 -0
- package/swr/isAnyError.js +18 -2
- package/swr/isAnyLoading.d.ts +7 -0
- package/swr/isAnyLoading.js +20 -2
- package/swr/isData.d.ts +7 -0
- package/swr/isData.js +6 -2
- package/swr/isError.d.ts +7 -0
- package/swr/isError.js +6 -2
- package/swr/isLoading.d.ts +7 -0
- package/swr/isLoading.js +11 -2
- package/upTimeRobot/getMonitors.d.ts +1 -0
- package/upTimeRobot/getMonitors.js +31 -2
- package/upTimeRobot/logTypes.d.ts +7 -0
- package/upTimeRobot/logTypes.js +9 -1
- package/upTimeRobot/monitorStatuses.d.ts +8 -0
- package/upTimeRobot/monitorStatuses.js +10 -1
- package/upTimeRobot/monitorSubTypes.d.ts +10 -0
- package/upTimeRobot/monitorSubTypes.js +12 -1
- package/upTimeRobot/monitorTypes.d.ts +8 -0
- package/upTimeRobot/monitorTypes.js +10 -1
- package/upTimeRobot/requestStatuses.d.ts +5 -0
- package/upTimeRobot/requestStatuses.js +7 -1
- package/url/buildParameters.d.ts +8 -0
- package/url/buildParameters.js +21 -2
- package/url/buildRelative.d.ts +8 -0
- package/url/buildRelative.js +12 -2
- package/url/buildUrl.d.ts +10 -0
- package/url/buildUrl.js +28 -2
- package/url/isAbsolute.d.ts +7 -0
- package/url/isAbsolute.js +14 -2
- package/url/isRelative.d.ts +7 -0
- package/url/isRelative.js +7 -2
- package/url/url.d.ts +6 -0
- package/url/url.js +2 -1
- package/util/defaultTo.d.ts +10 -0
- package/util/defaultTo.js +34 -2
- package/util/isUndefined.d.ts +9 -0
- package/util/isUndefined.js +18 -2
- package/util/sleep.d.ts +4 -0
- package/util/sleep.js +6 -1
- package/webWorker/states.d.ts +7 -0
- package/webWorker/states.js +8 -1
- package/xml/getXml.d.ts +4 -0
- package/xml/getXml.js +14 -1
- package/globals.d.js +0 -1
package/date/getYesterday.js
CHANGED
|
@@ -1,4 +1,42 @@
|
|
|
1
|
-
"use strict";
|
|
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 (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const subDays_1 = __importDefault(require("date-fns/subDays"));
|
|
30
|
+
const getTimeZoned_1 = __importStar(require("./getTimeZoned"));
|
|
31
|
+
const getToday_1 = __importDefault(require("./getToday"));
|
|
32
|
+
/**
|
|
2
33
|
* Shortcut to get yesterday's date.
|
|
3
34
|
* Creating a date from scratch (no user input), thus needs to be London time.
|
|
4
|
-
*/
|
|
35
|
+
*/
|
|
36
|
+
const getYesterday = ({ setMidnight = true, setTimeZone = getTimeZoned_1.timeZoneLondon } = { setMidnight: true, setTimeZone: getTimeZoned_1.timeZoneLondon }) => {
|
|
37
|
+
const today = (0, getToday_1.default)({ setMidnight, setTimeZone: false });
|
|
38
|
+
let yesterday = (0, subDays_1.default)(today, 1);
|
|
39
|
+
yesterday = (0, getTimeZoned_1.default)({ input: yesterday, setTimeZone });
|
|
40
|
+
return yesterday;
|
|
41
|
+
};
|
|
42
|
+
exports.default = getYesterday;
|
package/date/isDateValid.js
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const isValid_1 = __importDefault(require("date-fns/isValid"));
|
|
7
|
+
const parseISO_1 = __importDefault(require("date-fns/parseISO"));
|
|
8
|
+
/**
|
|
2
9
|
* Ensure the date string provided is in YYYY-MM-DD format and is a valid date.
|
|
3
|
-
*/
|
|
10
|
+
*/
|
|
11
|
+
const isDateValid = ({ input }) => {
|
|
12
|
+
const cleanInput = input.trim();
|
|
13
|
+
const parsedInput = (0, parseISO_1.default)(cleanInput);
|
|
14
|
+
if ((0, isValid_1.default)(parsedInput)) {
|
|
15
|
+
const matches = cleanInput.match(/^([0-9]{4}-[0-9]{2}-[0-9]{2})$/);
|
|
16
|
+
if (matches) {
|
|
17
|
+
return matches.length ? true : false;
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
};
|
|
23
|
+
exports.default = isDateValid;
|
package/date/isLastWeek.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const getLastWeek_1 = __importDefault(require("./getLastWeek"));
|
|
7
|
+
/**
|
|
2
8
|
* Check to see if a given timeframe is Last Week.
|
|
3
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const isLastWeek = ({ end, start }) => {
|
|
11
|
+
const lastWeek = (0, getLastWeek_1.default)();
|
|
12
|
+
return start === lastWeek.start && end === lastWeek.end;
|
|
13
|
+
};
|
|
14
|
+
exports.default = isLastWeek;
|
package/date/isThisWeek.js
CHANGED
|
@@ -1,3 +1,14 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const getThisWeek_1 = __importDefault(require("./getThisWeek"));
|
|
7
|
+
/**
|
|
2
8
|
* Check to see if a given timeframe is Last Week.
|
|
3
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const isThisWeek = ({ end, start }) => {
|
|
11
|
+
const thisWeek = (0, getThisWeek_1.default)();
|
|
12
|
+
return start === thisWeek.start && end === thisWeek.end;
|
|
13
|
+
};
|
|
14
|
+
exports.default = isThisWeek;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert an excel date "e.g. 44216" into a JavaScript date object.
|
|
3
|
+
* https://stackoverflow.com/questions/16229494/converting-excel-date-serial-number-to-date-using-javascript
|
|
4
|
+
*/
|
|
5
|
+
declare const parseExcelDate: ({ serial }: {
|
|
6
|
+
serial: number;
|
|
7
|
+
}) => Date;
|
|
8
|
+
export default parseExcelDate;
|
package/date/parseExcelDate.js
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
/**
|
|
2
4
|
* Convert an excel date "e.g. 44216" into a JavaScript date object.
|
|
3
5
|
* https://stackoverflow.com/questions/16229494/converting-excel-date-serial-number-to-date-using-javascript
|
|
4
|
-
*/
|
|
6
|
+
*/
|
|
7
|
+
const parseExcelDate = ({ serial }) => {
|
|
8
|
+
const utcDates = Math.floor(serial - 25569);
|
|
9
|
+
const utcValue = utcDates * 86400;
|
|
10
|
+
const dateInfo = new Date(utcValue * 1000);
|
|
11
|
+
const fractionalDay = serial - Math.floor(serial) + 0.0000001;
|
|
12
|
+
let totalSeconds = Math.floor(86400 * fractionalDay);
|
|
13
|
+
const seconds = totalSeconds % 60;
|
|
14
|
+
totalSeconds -= seconds;
|
|
15
|
+
const hours = Math.floor(totalSeconds / (60 * 60));
|
|
16
|
+
const minutes = Math.floor(totalSeconds / 60) % 60;
|
|
17
|
+
return new Date(dateInfo.getFullYear(), dateInfo.getMonth(), dateInfo.getDate(), hours, minutes, seconds);
|
|
18
|
+
};
|
|
19
|
+
exports.default = parseExcelDate;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const predefinedTimeframes: {
|
|
2
|
+
NONE: string;
|
|
3
|
+
CUSTOM: string;
|
|
4
|
+
THIS_WEEK: string;
|
|
5
|
+
LAST_WEEK: string;
|
|
6
|
+
};
|
|
7
|
+
export declare type PredefinedTimeframes = typeof predefinedTimeframes.NONE | typeof predefinedTimeframes.CUSTOM | typeof predefinedTimeframes.LAST_WEEK | typeof predefinedTimeframes.THIS_WEEK;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.predefinedTimeframes = void 0;
|
|
4
|
+
exports.predefinedTimeframes = {
|
|
5
|
+
NONE: 'none',
|
|
6
|
+
CUSTOM: 'custom',
|
|
7
|
+
THIS_WEEK: 'thisWeek',
|
|
8
|
+
LAST_WEEK: 'lastWeek',
|
|
9
|
+
};
|
package/date/timeframe.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/date/timeframes.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.timeframes = void 0;
|
|
4
|
+
exports.timeframes = {
|
|
5
|
+
CURRENT: 'current',
|
|
6
|
+
COMPARISON: 'comparison',
|
|
7
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Filter } from './filter';
|
|
2
|
+
import { Order } from './orders';
|
|
3
|
+
export declare type Request = {
|
|
4
|
+
crawlId?: number;
|
|
5
|
+
customPath?: string;
|
|
6
|
+
filters?: Filter[];
|
|
7
|
+
limit?: number;
|
|
8
|
+
orders?: Order[];
|
|
9
|
+
page?: number;
|
|
10
|
+
projectId?: number;
|
|
11
|
+
report?: string;
|
|
12
|
+
subReport?: string;
|
|
13
|
+
};
|
|
14
|
+
declare const buildRequest: ({ crawlId, customPath, filters, limit, orders, page, projectId, report, subReport, }: Request) => string;
|
|
15
|
+
export default buildRequest;
|
|
@@ -1,4 +1,83 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
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
|
+
const reports_1 = __importDefault(require("./reports"));
|
|
7
|
+
const orders_1 = __importDefault(require("./orders"));
|
|
8
|
+
const buildRequest = ({ crawlId, customPath, filters, limit, orders, page, projectId, report, subReport, }) => {
|
|
9
|
+
let url = `https://api.deepcrawl.com/accounts/37204`;
|
|
10
|
+
// Limit must be greater than 0 but also less than 200
|
|
11
|
+
if (undefined !== limit) {
|
|
12
|
+
if (limit > 200) {
|
|
13
|
+
throw `Maximum row limit is 200.`;
|
|
14
|
+
}
|
|
15
|
+
else if (0 === limit) {
|
|
16
|
+
throw `Row limit must be greater than 0.`;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
// Set limit to 200 by default
|
|
20
|
+
else {
|
|
21
|
+
limit = 200;
|
|
22
|
+
}
|
|
23
|
+
// If a report other than List Crawls is selected, Crawl ID must be defined
|
|
24
|
+
if (undefined !== report && reports_1.default.LIST_CRAWLS !== report && undefined == crawlId) {
|
|
25
|
+
throw `Crawl ID must be defined.`;
|
|
26
|
+
}
|
|
27
|
+
switch (report) {
|
|
28
|
+
case reports_1.default.LIST_CRAWLS:
|
|
29
|
+
url += `/projects/${projectId}/crawls`;
|
|
30
|
+
break;
|
|
31
|
+
case reports_1.default.LIST_PROJECTS:
|
|
32
|
+
url += `/projects`;
|
|
33
|
+
break;
|
|
34
|
+
case reports_1.default.CUSTOM:
|
|
35
|
+
url += customPath;
|
|
36
|
+
url = url.replace('[PROJECT]', projectId.toString());
|
|
37
|
+
url = url.replace('[CRAWL]', crawlId.toString());
|
|
38
|
+
break;
|
|
39
|
+
case reports_1.default.CRAWL_STATISTICS:
|
|
40
|
+
url += `/projects/${projectId}/crawls/${crawlId}/statistics`;
|
|
41
|
+
break;
|
|
42
|
+
case reports_1.default.LIST_REPORTS:
|
|
43
|
+
url += `/projects/${projectId}/crawls/${crawlId}/reports`;
|
|
44
|
+
break;
|
|
45
|
+
case reports_1.default.REPORT_ROWS:
|
|
46
|
+
case reports_1.default.REPORT_STATISTICS:
|
|
47
|
+
case reports_1.default.REPORT_SUMMARY:
|
|
48
|
+
url += `/projects/${projectId}/crawls/${crawlId}/reports/${subReport}`;
|
|
49
|
+
if (reports_1.default.REPORT_ROWS === report) {
|
|
50
|
+
url += `/report_rows`;
|
|
51
|
+
}
|
|
52
|
+
else if (reports_1.default.REPORT_STATISTICS === report) {
|
|
53
|
+
url += `/statistics`;
|
|
54
|
+
}
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
// Specify the limit
|
|
58
|
+
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
59
|
+
url += `per_page=${limit}`;
|
|
60
|
+
// Set the page number
|
|
61
|
+
if (undefined !== page) {
|
|
62
|
+
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
63
|
+
url += `page=${page}`;
|
|
64
|
+
}
|
|
65
|
+
// Apply any filters
|
|
66
|
+
if (undefined !== filters) {
|
|
67
|
+
filters.map(filter => {
|
|
68
|
+
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
69
|
+
url += `q[${filter.field}_${filter.operand}]=${filter.value}`;
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
// Order the data
|
|
73
|
+
if (undefined !== orders) {
|
|
74
|
+
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
75
|
+
orders.map((order, index) => {
|
|
76
|
+
url += 0 === index ? 'sort=' : ',';
|
|
77
|
+
url += orders_1.default.DESCENDING === order.direction ? '-' : '';
|
|
78
|
+
url += order.field;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return url;
|
|
82
|
+
};
|
|
83
|
+
exports.default = buildRequest;
|
package/deepCrawl/filter.js
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
package/deepCrawl/getData.js
CHANGED
|
@@ -1 +1,29 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const get_1 = __importDefault(require("../axios/get"));
|
|
7
|
+
const response_1 = __importDefault(require("../api/response"));
|
|
8
|
+
const states_1 = __importDefault(require("../api/states"));
|
|
9
|
+
const getData = async ({ url }) => {
|
|
10
|
+
let response = { ...response_1.default };
|
|
11
|
+
await (0, get_1.default)({
|
|
12
|
+
config: {
|
|
13
|
+
headers: {
|
|
14
|
+
'X-AUTH-TOKEN': global.deepcrawl.token,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
onError: error => {
|
|
18
|
+
response.state = states_1.default.ERROR;
|
|
19
|
+
response.error = error.message;
|
|
20
|
+
},
|
|
21
|
+
onSuccess: success => {
|
|
22
|
+
response.state = states_1.default.SUCCESS;
|
|
23
|
+
response.body = success.data;
|
|
24
|
+
},
|
|
25
|
+
url,
|
|
26
|
+
});
|
|
27
|
+
return response;
|
|
28
|
+
};
|
|
29
|
+
exports.default = getData;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
declare type InitClient = {
|
|
2
|
+
auth: {
|
|
3
|
+
apiId: string;
|
|
4
|
+
apiKey: string;
|
|
5
|
+
};
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* http://api-docs.deepcrawl.com/
|
|
9
|
+
* Renew the DeepCrawl user token.
|
|
10
|
+
* Token lasts for 6 hours.
|
|
11
|
+
*/
|
|
12
|
+
declare const initClient: ({ auth }: InitClient) => Promise<void>;
|
|
13
|
+
export default initClient;
|
package/deepCrawl/initClient.js
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const post_1 = __importDefault(require("../axios/post"));
|
|
7
|
+
global.deepcrawl = {
|
|
8
|
+
lastUpdated: null,
|
|
9
|
+
token: null,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
2
12
|
* http://api-docs.deepcrawl.com/
|
|
3
13
|
* Renew the DeepCrawl user token.
|
|
4
14
|
* Token lasts for 6 hours.
|
|
5
|
-
*/
|
|
15
|
+
*/
|
|
16
|
+
const initClient = async ({ auth }) => {
|
|
17
|
+
// todo: Or was more than 6 hours ago
|
|
18
|
+
if (null === global.deepcrawl.token) {
|
|
19
|
+
const apiResponse = await (0, post_1.default)({
|
|
20
|
+
config: {
|
|
21
|
+
auth: {
|
|
22
|
+
username: auth.apiId,
|
|
23
|
+
password: auth.apiKey,
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
url: `https://api.deepcrawl.com/sessions`,
|
|
27
|
+
});
|
|
28
|
+
// Ensure the value exists
|
|
29
|
+
if (undefined !== apiResponse.data && undefined !== apiResponse.data.token) {
|
|
30
|
+
global.deepcrawl.token = apiResponse.data.token;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
exports.default = initClient;
|
package/deepCrawl/operands.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const operands = {
|
|
4
|
+
EQUALS: 'eql',
|
|
5
|
+
CONTAINS: 'cont',
|
|
6
|
+
LESS_THAN: 'lt',
|
|
7
|
+
LESS_THAN_OR_EQUAL: 'lte',
|
|
8
|
+
GREATER_THAN: 'gt',
|
|
9
|
+
GREATER_THAN_OR_EQUAL: 'gte',
|
|
10
|
+
REGEX: 'rgx',
|
|
11
|
+
NOT_REGEX: 'nrgx',
|
|
12
|
+
};
|
|
13
|
+
exports.default = operands;
|
package/deepCrawl/orders.js
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const orders = {
|
|
4
|
+
ASCENDING: 'asc',
|
|
5
|
+
DESCENDING: 'desc',
|
|
6
|
+
};
|
|
7
|
+
exports.default = orders;
|
package/deepCrawl/reports.js
CHANGED
|
@@ -1 +1,13 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const reports = {
|
|
4
|
+
CRAWL_STATISTICS: 'crawl_statistics',
|
|
5
|
+
CUSTOM: 'custom',
|
|
6
|
+
LIST_PROJECTS: 'list_projects',
|
|
7
|
+
LIST_CRAWLS: 'list_crawls',
|
|
8
|
+
LIST_REPORTS: 'list_reports',
|
|
9
|
+
REPORT_ROWS: 'report_rows',
|
|
10
|
+
REPORT_STATISTICS: 'report_statistics',
|
|
11
|
+
REPORT_SUMMARY: 'report_summary',
|
|
12
|
+
};
|
|
13
|
+
exports.default = reports;
|
|
@@ -1 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const environments = {
|
|
4
|
+
DEVELOPMENT: 'development',
|
|
5
|
+
STAGING: 'staging',
|
|
6
|
+
PRODUCTION: 'production',
|
|
7
|
+
};
|
|
8
|
+
exports.default = environments;
|
|
@@ -1,3 +1,43 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
+
const environments_1 = __importDefault(require("./environments"));
|
|
7
|
+
/**
|
|
2
8
|
* Determine the environment we're using.
|
|
3
|
-
*/
|
|
9
|
+
*/
|
|
10
|
+
const getEnvironment = () => {
|
|
11
|
+
let platformEnvironment = process.env.ENVIRONMENT;
|
|
12
|
+
let response;
|
|
13
|
+
// Custom - Backend/AWS
|
|
14
|
+
if (process.env.EMS_ENVIRONMENT) {
|
|
15
|
+
platformEnvironment = process.env.EMS_ENVIRONMENT;
|
|
16
|
+
}
|
|
17
|
+
// Custom - Frontend
|
|
18
|
+
else if (process.env.NEXT_PUBLIC_EMS_ENVIRONMENT) {
|
|
19
|
+
platformEnvironment = process.env.NEXT_PUBLIC_EMS_ENVIRONMENT;
|
|
20
|
+
}
|
|
21
|
+
// Vercel - Frontend
|
|
22
|
+
else if (process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF) {
|
|
23
|
+
platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
24
|
+
}
|
|
25
|
+
// Vercel - Backend
|
|
26
|
+
else if (process.env.VERCEL_GIT_COMMIT_REF) {
|
|
27
|
+
platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
|
|
28
|
+
}
|
|
29
|
+
switch (platformEnvironment) {
|
|
30
|
+
case 'development':
|
|
31
|
+
response = environments_1.default.DEVELOPMENT;
|
|
32
|
+
break;
|
|
33
|
+
case 'demo':
|
|
34
|
+
case 'preview':
|
|
35
|
+
case 'staging':
|
|
36
|
+
response = environments_1.default.STAGING;
|
|
37
|
+
break;
|
|
38
|
+
default:
|
|
39
|
+
response = environments_1.default.PRODUCTION;
|
|
40
|
+
}
|
|
41
|
+
return response;
|
|
42
|
+
};
|
|
43
|
+
exports.default = getEnvironment;
|