@8ms/helpers 1.1.66 → 1.1.71
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.js +2 -2
- package/api/states.js +1 -1
- package/api/unexpectedError.js +1 -1
- package/array/contains.js +1 -4
- package/array/getArray.js +2 -5
- package/aws/athenaExpress/initClient.d.ts +1 -1
- package/aws/athenaExpress/initClient.js +6 -7
- package/aws/athenaExpress/query.d.ts +8 -0
- package/aws/athenaExpress/query.js +10 -0
- package/aws/getConfig.d.ts +5 -1
- package/aws/getConfig.js +2 -3
- package/aws/glue/initClient.d.ts +5 -4
- package/aws/glue/initClient.js +4 -5
- package/aws/glue/invoke.d.ts +1 -3
- package/aws/glue/invoke.js +12 -63
- package/aws/isResponse200.js +4 -5
- package/aws/lambda/getHandlerPath.d.ts +4 -3
- package/aws/lambda/getHandlerPath.js +3 -4
- package/aws/lambda/initClient.d.ts +5 -4
- package/aws/lambda/initClient.js +4 -5
- package/aws/lambda/invoke.d.ts +1 -3
- package/aws/lambda/invoke.js +29 -77
- package/aws/s3/copyFile.js +7 -55
- package/aws/s3/deleteFile.js +6 -54
- package/aws/s3/deleteFiles.d.ts +5 -6
- package/aws/s3/deleteFiles.js +10 -58
- package/aws/s3/deleteFolder.d.ts +5 -6
- package/aws/s3/deleteFolder.js +26 -76
- package/aws/s3/getGlueJson.d.ts +3 -2
- package/aws/s3/getGlueJson.js +4 -5
- package/aws/s3/getPresignedPost.d.ts +6 -7
- package/aws/s3/getPresignedPost.js +9 -56
- package/aws/s3/getSignedUrl.js +8 -76
- package/aws/s3/initClient.d.ts +5 -4
- package/aws/s3/initClient.js +4 -5
- package/aws/s3/isFileExists.js +17 -66
- package/aws/s3/listFiles.js +22 -69
- package/aws/s3/listFolders.js +21 -68
- package/aws/s3/moveFile.d.ts +5 -4
- package/aws/s3/moveFile.js +10 -58
- package/aws/s3/readBuffer.js +41 -89
- package/aws/s3/readFile.js +42 -93
- package/aws/s3/writeFile.js +10 -72
- package/aws/s3/writePresignedPost.d.ts +2 -3
- package/aws/s3/writePresignedPost.js +22 -93
- package/aws/s3cache/getCache.js +25 -69
- package/aws/s3cache/getKey.js +7 -8
- package/aws/s3cache/saveCache.js +3 -49
- package/aws/s3cache/updateCache.js +13 -65
- package/aws/ses/SimpleEmail.d.ts +10 -13
- package/aws/ses/SimpleEmail.js +85 -189
- package/aws/ses/initClient.d.ts +5 -4
- package/aws/ses/initClient.js +4 -5
- package/aws/ssm/getParameter.js +31 -78
- package/aws/ssm/initClient.d.ts +5 -4
- package/aws/ssm/initClient.js +4 -5
- package/axios/get.js +35 -106
- package/axios/post.js +35 -106
- package/boolean/getBoolean.js +2 -3
- package/class/BaseClass.js +15 -22
- package/crypto/getDecrypt.js +3 -4
- package/crypto/getEncrypt.js +3 -4
- package/crypto/getRandom.js +1 -2
- package/crypto/getSha256.js +4 -5
- package/date/durationComparisons.js +1 -1
- package/date/durations.js +1 -1
- package/date/format.js +7 -8
- package/date/getDate.js +19 -20
- package/date/getDatesBetween.js +8 -9
- package/date/getDurationHours.js +6 -7
- package/date/getDurationMinutes.js +6 -7
- package/date/getFinancialYear.js +11 -12
- package/date/getFinancialYearToDate.js +5 -5
- package/date/getFinancialYearToYesterday.js +5 -5
- package/date/getFinancialYearWeeks.js +10 -11
- package/date/getLastWeek.js +11 -12
- package/date/getMax.js +5 -6
- package/date/getMidnight.js +2 -3
- package/date/getMin.js +5 -6
- package/date/getMonday.js +10 -11
- package/date/getNumber.js +4 -5
- package/date/getPredefinedTimeframe.js +5 -6
- package/date/getSunday.js +10 -11
- package/date/getThisWeek.js +11 -12
- package/date/getTimeZoned.js +11 -12
- package/date/getToday.js +6 -7
- package/date/getTwoWeeksAgo.js +11 -12
- package/date/getWeeksAgo.js +5 -6
- package/date/getYesterday.js +7 -8
- package/date/isDateValid.js +6 -7
- package/date/isLastWeek.js +3 -4
- package/date/isThisWeek.js +3 -4
- package/date/parseExcelDate.js +9 -10
- package/deepCrawl/buildRequest.js +19 -20
- package/deepCrawl/getData.js +21 -79
- package/deepCrawl/initClient.js +17 -64
- package/deepCrawl/operands.js +1 -1
- package/deepCrawl/orders.js +1 -1
- package/deepCrawl/reports.js +1 -1
- package/environment/environments.js +1 -1
- package/environment/getEnvironment.js +8 -8
- package/environment/isAws.js +2 -2
- package/environment/isDevelopment.js +3 -3
- package/environment/isLocalhost.js +4 -4
- package/environment/isProduction.js +3 -3
- package/environment/isStaging.js +3 -3
- package/environment/isVercel.js +1 -1
- package/environment/platforms.d.ts +1 -1
- package/environment/platforms.js +1 -1
- package/eskimi/ageGroups.js +1 -1
- package/eskimi/devices.js +1 -1
- package/eskimi/endpoints.js +1 -1
- package/eskimi/genders.js +1 -1
- package/eskimi/getAccessToken.js +11 -57
- package/eskimi/getAgeGroup.js +3 -4
- package/eskimi/getCampaignIds.js +2 -3
- package/eskimi/getDevice.js +3 -4
- package/eskimi/getGender.js +3 -4
- package/eskimi/request.js +13 -59
- package/google/bigQuery/initClient.d.ts +11 -0
- package/google/bigQuery/initClient.js +22 -0
- package/google/bigQuery/query.d.ts +9 -0
- package/google/bigQuery/query.js +10 -0
- package/google/getConfig.d.ts +20 -0
- package/google/getConfig.js +23 -0
- package/google/sheets/getAssociatedData.d.ts +2 -6
- package/google/sheets/getAssociatedData.js +42 -89
- package/google/sheets/getBatchData.d.ts +1 -3
- package/google/sheets/getBatchData.js +15 -60
- package/google/sheets/initClient.d.ts +11 -0
- package/google/sheets/initClient.js +25 -0
- package/google/sheets/isCellNa.js +1 -4
- package/google/storage/initClient.d.ts +12 -0
- package/google/storage/initClient.js +23 -0
- package/google/storage/writeFile.d.ts +2 -1
- package/google/storage/writeFile.js +20 -77
- package/googleAds/getCustomer.js +7 -48
- package/googleAds/initClient.d.ts +9 -8
- package/googleAds/initClient.js +13 -56
- package/initClients.d.ts +13 -3
- package/initClients.js +95 -101
- package/json/isJson.js +1 -2
- package/littleWarden/getUrlStatus.js +10 -56
- package/littleWarden/isAllGood.js +3 -4
- package/littleWarden/isDanger.js +3 -4
- package/littleWarden/isWarning.js +3 -4
- package/littleWarden/states.js +1 -1
- package/myTarget/getAccessToken.js +11 -57
- package/myTarget/request.js +13 -59
- package/nextAuth/isSessionReady.js +2 -3
- package/nextAuth/states.js +1 -1
- package/nextJs/getIp.js +2 -3
- package/nextJs/getUserAgent.js +1 -4
- package/number/getDivide.js +4 -5
- package/number/getNumber.js +6 -7
- package/number/getPercent.js +4 -5
- package/number/getPercentIncrease.js +4 -5
- package/number/getRounded.js +5 -6
- package/package.json +2 -1
- package/prisma/initClient.js +4 -5
- package/snapchat/getAccessToken.js +25 -72
- package/sorting/byNumberAscending.js +3 -4
- package/sorting/byNumberDescending.js +3 -4
- package/sorting/byStringAscending.js +3 -4
- package/sorting/byStringDescending.js +3 -4
- package/string/formatCapitalise.js +2 -3
- package/string/getCleanFolder.js +3 -6
- package/string/getString.js +9 -10
- package/string/getStringFromStream.js +7 -8
- package/string/toProperCase.js +6 -7
- package/swr/isAllData.js +4 -5
- package/swr/isAnyError.js +4 -5
- package/swr/isAnyLoading.js +4 -5
- package/swr/isData.js +1 -4
- package/swr/isError.js +1 -4
- package/swr/isLoading.js +3 -6
- package/upTimeRobot/getMonitors.d.ts +1 -0
- package/upTimeRobot/getMonitors.js +33 -0
- package/upTimeRobot/logTypes.d.ts +7 -0
- package/upTimeRobot/logTypes.js +9 -0
- package/upTimeRobot/monitorStatuses.d.ts +8 -0
- package/upTimeRobot/monitorStatuses.js +10 -0
- package/upTimeRobot/monitorSubTypes.d.ts +10 -0
- package/upTimeRobot/monitorSubTypes.js +12 -0
- package/upTimeRobot/monitorTypes.d.ts +8 -0
- package/upTimeRobot/monitorTypes.js +10 -0
- package/upTimeRobot/requestStatuses.d.ts +5 -0
- package/upTimeRobot/requestStatuses.js +7 -0
- package/url/buildParameters.js +7 -8
- package/url/buildRelative.js +3 -4
- package/url/buildUrl.js +6 -7
- package/url/isAbsolute.js +1 -2
- package/url/isRelative.js +2 -5
- package/util/defaultTo.d.ts +6 -5
- package/util/defaultTo.js +6 -7
- package/util/isUndefined.d.ts +9 -0
- package/util/isUndefined.js +19 -0
- package/util/sleep.js +2 -3
- package/webWorker/states.js +1 -1
- package/xml/getXml.js +10 -58
- package/aws/athenaExpress/request.d.ts +0 -8
- package/aws/athenaExpress/request.js +0 -54
- package/aws/config.d.ts +0 -5
- package/aws/config.js +0 -2
- package/google/getCredentials.d.ts +0 -20
- package/google/getCredentials.js +0 -76
- package/google/sheets/getAuth.d.ts +0 -8
- package/google/sheets/getAuth.js +0 -69
package/date/isDateValid.js
CHANGED
|
@@ -3,17 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const isValid_1 = __importDefault(require("date-fns/isValid"));
|
|
7
|
+
const parseISO_1 = __importDefault(require("date-fns/parseISO"));
|
|
8
8
|
/**
|
|
9
9
|
* Ensure the date string provided is in YYYY-MM-DD format and is a valid date.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var parsedInput = (0, parseISO_1.default)(cleanInput);
|
|
11
|
+
const isDateValid = ({ input }) => {
|
|
12
|
+
const cleanInput = input.trim();
|
|
13
|
+
const parsedInput = (0, parseISO_1.default)(cleanInput);
|
|
15
14
|
if ((0, isValid_1.default)(parsedInput)) {
|
|
16
|
-
|
|
15
|
+
const matches = cleanInput.match(/^([0-9]{4}-[0-9]{2}-[0-9]{2})$/);
|
|
17
16
|
if (matches) {
|
|
18
17
|
return matches.length ? true : false;
|
|
19
18
|
}
|
package/date/isLastWeek.js
CHANGED
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const getLastWeek_1 = __importDefault(require("./getLastWeek"));
|
|
7
7
|
/**
|
|
8
8
|
* Check to see if a given timeframe is Last Week.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var lastWeek = (0, getLastWeek_1.default)();
|
|
10
|
+
const isLastWeek = ({ end, start }) => {
|
|
11
|
+
const lastWeek = (0, getLastWeek_1.default)();
|
|
13
12
|
return start === lastWeek.start && end === lastWeek.end;
|
|
14
13
|
};
|
|
15
14
|
exports.default = isLastWeek;
|
package/date/isThisWeek.js
CHANGED
|
@@ -3,13 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const getThisWeek_1 = __importDefault(require("./getThisWeek"));
|
|
7
7
|
/**
|
|
8
8
|
* Check to see if a given timeframe is Last Week.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var thisWeek = (0, getThisWeek_1.default)();
|
|
10
|
+
const isThisWeek = ({ end, start }) => {
|
|
11
|
+
const thisWeek = (0, getThisWeek_1.default)();
|
|
13
12
|
return start === thisWeek.start && end === thisWeek.end;
|
|
14
13
|
};
|
|
15
14
|
exports.default = isThisWeek;
|
package/date/parseExcelDate.js
CHANGED
|
@@ -4,17 +4,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
4
4
|
* Convert an excel date "e.g. 44216" into a JavaScript date object.
|
|
5
5
|
* https://stackoverflow.com/questions/16229494/converting-excel-date-serial-number-to-date-using-javascript
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var seconds = totalSeconds % 60;
|
|
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;
|
|
15
14
|
totalSeconds -= seconds;
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const hours = Math.floor(totalSeconds / (60 * 60));
|
|
16
|
+
const minutes = Math.floor(totalSeconds / 60) % 60;
|
|
18
17
|
return new Date(dateInfo.getFullYear(), dateInfo.getMonth(), dateInfo.getDate(), hours, minutes, seconds);
|
|
19
18
|
};
|
|
20
19
|
exports.default = parseExcelDate;
|
|
@@ -3,18 +3,17 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var url = "https://api.deepcrawl.com/accounts/37204";
|
|
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`;
|
|
11
10
|
// Limit must be greater than 0 but also less than 200
|
|
12
11
|
if (undefined !== limit) {
|
|
13
12
|
if (limit > 200) {
|
|
14
|
-
throw
|
|
13
|
+
throw `Maximum row limit is 200.`;
|
|
15
14
|
}
|
|
16
15
|
else if (0 === limit) {
|
|
17
|
-
throw
|
|
16
|
+
throw `Row limit must be greater than 0.`;
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
// Set limit to 200 by default
|
|
@@ -23,14 +22,14 @@ var buildRequest = function (_a) {
|
|
|
23
22
|
}
|
|
24
23
|
// If a report other than List Crawls is selected, Crawl ID must be defined
|
|
25
24
|
if (undefined !== report && reports_1.default.LIST_CRAWLS !== report && undefined == crawlId) {
|
|
26
|
-
throw
|
|
25
|
+
throw `Crawl ID must be defined.`;
|
|
27
26
|
}
|
|
28
27
|
switch (report) {
|
|
29
28
|
case reports_1.default.LIST_CRAWLS:
|
|
30
|
-
url +=
|
|
29
|
+
url += `/projects/${projectId}/crawls`;
|
|
31
30
|
break;
|
|
32
31
|
case reports_1.default.LIST_PROJECTS:
|
|
33
|
-
url +=
|
|
32
|
+
url += `/projects`;
|
|
34
33
|
break;
|
|
35
34
|
case reports_1.default.CUSTOM:
|
|
36
35
|
url += customPath;
|
|
@@ -38,42 +37,42 @@ var buildRequest = function (_a) {
|
|
|
38
37
|
url = url.replace('[CRAWL]', crawlId.toString());
|
|
39
38
|
break;
|
|
40
39
|
case reports_1.default.CRAWL_STATISTICS:
|
|
41
|
-
url +=
|
|
40
|
+
url += `/projects/${projectId}/crawls/${crawlId}/statistics`;
|
|
42
41
|
break;
|
|
43
42
|
case reports_1.default.LIST_REPORTS:
|
|
44
|
-
url +=
|
|
43
|
+
url += `/projects/${projectId}/crawls/${crawlId}/reports`;
|
|
45
44
|
break;
|
|
46
45
|
case reports_1.default.REPORT_ROWS:
|
|
47
46
|
case reports_1.default.REPORT_STATISTICS:
|
|
48
47
|
case reports_1.default.REPORT_SUMMARY:
|
|
49
|
-
url +=
|
|
48
|
+
url += `/projects/${projectId}/crawls/${crawlId}/reports/${subReport}`;
|
|
50
49
|
if (reports_1.default.REPORT_ROWS === report) {
|
|
51
|
-
url +=
|
|
50
|
+
url += `/report_rows`;
|
|
52
51
|
}
|
|
53
52
|
else if (reports_1.default.REPORT_STATISTICS === report) {
|
|
54
|
-
url +=
|
|
53
|
+
url += `/statistics`;
|
|
55
54
|
}
|
|
56
55
|
break;
|
|
57
56
|
}
|
|
58
57
|
// Specify the limit
|
|
59
58
|
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
60
|
-
url +=
|
|
59
|
+
url += `per_page=${limit}`;
|
|
61
60
|
// Set the page number
|
|
62
61
|
if (undefined !== page) {
|
|
63
62
|
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
64
|
-
url +=
|
|
63
|
+
url += `page=${page}`;
|
|
65
64
|
}
|
|
66
65
|
// Apply any filters
|
|
67
66
|
if (undefined !== filters) {
|
|
68
|
-
filters.map(
|
|
67
|
+
filters.map(filter => {
|
|
69
68
|
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
70
|
-
url +=
|
|
69
|
+
url += `q[${filter.field}_${filter.operand}]=${filter.value}`;
|
|
71
70
|
});
|
|
72
71
|
}
|
|
73
72
|
// Order the data
|
|
74
73
|
if (undefined !== orders) {
|
|
75
74
|
url += -1 === url.indexOf('?') ? '?' : '&';
|
|
76
|
-
orders.map(
|
|
75
|
+
orders.map((order, index) => {
|
|
77
76
|
url += 0 === index ? 'sort=' : ',';
|
|
78
77
|
url += orders_1.default.DESCENDING === order.direction ? '-' : '';
|
|
79
78
|
url += order.field;
|
package/deepCrawl/getData.js
CHANGED
|
@@ -1,87 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
4
|
};
|
|
52
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
},
|
|
74
|
-
onSuccess: function (success) {
|
|
75
|
-
response.state = states_1.default.SUCCESS;
|
|
76
|
-
response.body = success.data;
|
|
77
|
-
},
|
|
78
|
-
url: url,
|
|
79
|
-
})];
|
|
80
|
-
case 1:
|
|
81
|
-
_b.sent();
|
|
82
|
-
return [2 /*return*/, response];
|
|
83
|
-
}
|
|
84
|
-
});
|
|
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,
|
|
85
26
|
});
|
|
27
|
+
return response;
|
|
86
28
|
};
|
|
87
29
|
exports.default = getData;
|
package/deepCrawl/initClient.js
CHANGED
|
@@ -1,45 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
|
|
6
|
+
const post_1 = __importDefault(require("../axios/post"));
|
|
43
7
|
global.deepcrawl = {
|
|
44
8
|
lastUpdated: null,
|
|
45
9
|
token: null,
|
|
@@ -49,33 +13,22 @@ global.deepcrawl = {
|
|
|
49
13
|
* Renew the DeepCrawl user token.
|
|
50
14
|
* Token lasts for 6 hours.
|
|
51
15
|
*/
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
username: auth.apiId,
|
|
64
|
-
password: auth.apiKey,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
url: "https://api.deepcrawl.com/sessions",
|
|
68
|
-
})];
|
|
69
|
-
case 1:
|
|
70
|
-
apiResponse = _b.sent();
|
|
71
|
-
// Ensure the value exists
|
|
72
|
-
if (undefined !== apiResponse.data && undefined !== apiResponse.data.token) {
|
|
73
|
-
global.deepcrawl.token = apiResponse.data.token;
|
|
74
|
-
}
|
|
75
|
-
_b.label = 2;
|
|
76
|
-
case 2: return [2 /*return*/];
|
|
77
|
-
}
|
|
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`,
|
|
78
27
|
});
|
|
79
|
-
|
|
28
|
+
// Ensure the value exists
|
|
29
|
+
if (undefined !== apiResponse.data && undefined !== apiResponse.data.token) {
|
|
30
|
+
global.deepcrawl.token = apiResponse.data.token;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
80
33
|
};
|
|
81
34
|
exports.default = initClient;
|
package/deepCrawl/operands.js
CHANGED
package/deepCrawl/orders.js
CHANGED
package/deepCrawl/reports.js
CHANGED
|
@@ -3,27 +3,27 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const environments_1 = __importDefault(require("./environments"));
|
|
7
7
|
/**
|
|
8
8
|
* Determine the environment we're using.
|
|
9
9
|
*/
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const getEnvironment = () => {
|
|
11
|
+
let platformEnvironment = process.env.ENVIRONMENT;
|
|
12
|
+
let response;
|
|
13
13
|
// Custom - Backend/AWS
|
|
14
|
-
if (
|
|
14
|
+
if (process.env.EMS_ENVIRONMENT) {
|
|
15
15
|
platformEnvironment = process.env.EMS_ENVIRONMENT;
|
|
16
16
|
}
|
|
17
17
|
// Custom - Frontend
|
|
18
|
-
else if (
|
|
18
|
+
else if (process.env.NEXT_PUBLIC_EMS_ENVIRONMENT) {
|
|
19
19
|
platformEnvironment = process.env.NEXT_PUBLIC_EMS_ENVIRONMENT;
|
|
20
20
|
}
|
|
21
21
|
// Vercel - Frontend
|
|
22
|
-
else if (
|
|
22
|
+
else if (process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF) {
|
|
23
23
|
platformEnvironment = process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
24
24
|
}
|
|
25
25
|
// Vercel - Backend
|
|
26
|
-
else if (
|
|
26
|
+
else if (process.env.VERCEL_GIT_COMMIT_REF) {
|
|
27
27
|
platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
|
|
28
28
|
}
|
|
29
29
|
switch (platformEnvironment) {
|
package/environment/isAws.js
CHANGED
|
@@ -3,9 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
6
|
+
const platforms_1 = __importDefault(require("./platforms"));
|
|
7
7
|
/**
|
|
8
8
|
* Check to see if we are working on AWS Lambda.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
const isAws = () => platforms_1.default.AWS === process.env['EMS_PLATFORM'];
|
|
11
11
|
exports.default = isAws;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const environments_1 = __importDefault(require("./environments"));
|
|
7
|
+
const getEnvironment_1 = __importDefault(require("./getEnvironment"));
|
|
8
|
+
const isDevelopment = () => environments_1.default.DEVELOPMENT === (0, getEnvironment_1.default)();
|
|
9
9
|
exports.default = isDevelopment;
|
|
@@ -3,13 +3,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const isAws_1 = __importDefault(require("./isAws"));
|
|
7
|
+
const isVercel_1 = __importDefault(require("./isVercel"));
|
|
8
8
|
/**
|
|
9
9
|
* Check to see if we are developing locally or on the hosted platform.
|
|
10
10
|
*/
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const isLocalhost = () => {
|
|
12
|
+
let response = false;
|
|
13
13
|
if ((0, isAws_1.default)()) {
|
|
14
14
|
response = 'true' === process.env['AWS_SAM_LOCAL'];
|
|
15
15
|
}
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const environments_1 = __importDefault(require("./environments"));
|
|
7
|
+
const getEnvironment_1 = __importDefault(require("./getEnvironment"));
|
|
8
|
+
const isProduction = () => environments_1.default.PRODUCTION === (0, getEnvironment_1.default)();
|
|
9
9
|
exports.default = isProduction;
|
package/environment/isStaging.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const environments_1 = __importDefault(require("./environments"));
|
|
7
|
+
const getEnvironment_1 = __importDefault(require("./getEnvironment"));
|
|
8
|
+
const isStaging = () => environments_1.default.STAGING === (0, getEnvironment_1.default)();
|
|
9
9
|
exports.default = isStaging;
|
package/environment/isVercel.js
CHANGED
|
@@ -3,5 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
/**
|
|
4
4
|
* Check to see if we are working on Vercel.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const isVercel = () => undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
|
|
7
7
|
exports.default = isVercel;
|
package/environment/platforms.js
CHANGED
package/eskimi/ageGroups.js
CHANGED
package/eskimi/devices.js
CHANGED
package/eskimi/endpoints.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
/**
|
|
4
4
|
* https://dsp-api.eskimi.com/docs/api/v1/#api-Report-GetCampaignReportByAgeGroups
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
const endpoints = {
|
|
7
7
|
campaign: {
|
|
8
8
|
age: 'https://dsp-api.eskimi.com/api/v1/report/ageGroups/get',
|
|
9
9
|
gender: 'https://dsp-api.eskimi.com/api/v1/report/genders/get',
|