@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.
Files changed (208) hide show
  1. package/api/response.js +2 -2
  2. package/api/states.js +1 -1
  3. package/api/unexpectedError.js +1 -1
  4. package/array/contains.js +1 -4
  5. package/array/getArray.js +2 -5
  6. package/aws/athenaExpress/initClient.d.ts +1 -1
  7. package/aws/athenaExpress/initClient.js +6 -7
  8. package/aws/athenaExpress/query.d.ts +8 -0
  9. package/aws/athenaExpress/query.js +10 -0
  10. package/aws/getConfig.d.ts +5 -1
  11. package/aws/getConfig.js +2 -3
  12. package/aws/glue/initClient.d.ts +5 -4
  13. package/aws/glue/initClient.js +4 -5
  14. package/aws/glue/invoke.d.ts +1 -3
  15. package/aws/glue/invoke.js +12 -63
  16. package/aws/isResponse200.js +4 -5
  17. package/aws/lambda/getHandlerPath.d.ts +4 -3
  18. package/aws/lambda/getHandlerPath.js +3 -4
  19. package/aws/lambda/initClient.d.ts +5 -4
  20. package/aws/lambda/initClient.js +4 -5
  21. package/aws/lambda/invoke.d.ts +1 -3
  22. package/aws/lambda/invoke.js +29 -77
  23. package/aws/s3/copyFile.js +7 -55
  24. package/aws/s3/deleteFile.js +6 -54
  25. package/aws/s3/deleteFiles.d.ts +5 -6
  26. package/aws/s3/deleteFiles.js +10 -58
  27. package/aws/s3/deleteFolder.d.ts +5 -6
  28. package/aws/s3/deleteFolder.js +26 -76
  29. package/aws/s3/getGlueJson.d.ts +3 -2
  30. package/aws/s3/getGlueJson.js +4 -5
  31. package/aws/s3/getPresignedPost.d.ts +6 -7
  32. package/aws/s3/getPresignedPost.js +9 -56
  33. package/aws/s3/getSignedUrl.js +8 -76
  34. package/aws/s3/initClient.d.ts +5 -4
  35. package/aws/s3/initClient.js +4 -5
  36. package/aws/s3/isFileExists.js +17 -66
  37. package/aws/s3/listFiles.js +22 -69
  38. package/aws/s3/listFolders.js +21 -68
  39. package/aws/s3/moveFile.d.ts +5 -4
  40. package/aws/s3/moveFile.js +10 -58
  41. package/aws/s3/readBuffer.js +41 -89
  42. package/aws/s3/readFile.js +42 -93
  43. package/aws/s3/writeFile.js +10 -72
  44. package/aws/s3/writePresignedPost.d.ts +2 -3
  45. package/aws/s3/writePresignedPost.js +22 -93
  46. package/aws/s3cache/getCache.js +25 -69
  47. package/aws/s3cache/getKey.js +7 -8
  48. package/aws/s3cache/saveCache.js +3 -49
  49. package/aws/s3cache/updateCache.js +13 -65
  50. package/aws/ses/SimpleEmail.d.ts +10 -13
  51. package/aws/ses/SimpleEmail.js +85 -189
  52. package/aws/ses/initClient.d.ts +5 -4
  53. package/aws/ses/initClient.js +4 -5
  54. package/aws/ssm/getParameter.js +31 -78
  55. package/aws/ssm/initClient.d.ts +5 -4
  56. package/aws/ssm/initClient.js +4 -5
  57. package/axios/get.js +35 -106
  58. package/axios/post.js +35 -106
  59. package/boolean/getBoolean.js +2 -3
  60. package/class/BaseClass.js +15 -22
  61. package/crypto/getDecrypt.js +3 -4
  62. package/crypto/getEncrypt.js +3 -4
  63. package/crypto/getRandom.js +1 -2
  64. package/crypto/getSha256.js +4 -5
  65. package/date/durationComparisons.js +1 -1
  66. package/date/durations.js +1 -1
  67. package/date/format.js +7 -8
  68. package/date/getDate.js +19 -20
  69. package/date/getDatesBetween.js +8 -9
  70. package/date/getDurationHours.js +6 -7
  71. package/date/getDurationMinutes.js +6 -7
  72. package/date/getFinancialYear.js +11 -12
  73. package/date/getFinancialYearToDate.js +5 -5
  74. package/date/getFinancialYearToYesterday.js +5 -5
  75. package/date/getFinancialYearWeeks.js +10 -11
  76. package/date/getLastWeek.js +11 -12
  77. package/date/getMax.js +5 -6
  78. package/date/getMidnight.js +2 -3
  79. package/date/getMin.js +5 -6
  80. package/date/getMonday.js +10 -11
  81. package/date/getNumber.js +4 -5
  82. package/date/getPredefinedTimeframe.js +5 -6
  83. package/date/getSunday.js +10 -11
  84. package/date/getThisWeek.js +11 -12
  85. package/date/getTimeZoned.js +11 -12
  86. package/date/getToday.js +6 -7
  87. package/date/getTwoWeeksAgo.js +11 -12
  88. package/date/getWeeksAgo.js +5 -6
  89. package/date/getYesterday.js +7 -8
  90. package/date/isDateValid.js +6 -7
  91. package/date/isLastWeek.js +3 -4
  92. package/date/isThisWeek.js +3 -4
  93. package/date/parseExcelDate.js +9 -10
  94. package/deepCrawl/buildRequest.js +19 -20
  95. package/deepCrawl/getData.js +21 -79
  96. package/deepCrawl/initClient.js +17 -64
  97. package/deepCrawl/operands.js +1 -1
  98. package/deepCrawl/orders.js +1 -1
  99. package/deepCrawl/reports.js +1 -1
  100. package/environment/environments.js +1 -1
  101. package/environment/getEnvironment.js +8 -8
  102. package/environment/isAws.js +2 -2
  103. package/environment/isDevelopment.js +3 -3
  104. package/environment/isLocalhost.js +4 -4
  105. package/environment/isProduction.js +3 -3
  106. package/environment/isStaging.js +3 -3
  107. package/environment/isVercel.js +1 -1
  108. package/environment/platforms.d.ts +1 -1
  109. package/environment/platforms.js +1 -1
  110. package/eskimi/ageGroups.js +1 -1
  111. package/eskimi/devices.js +1 -1
  112. package/eskimi/endpoints.js +1 -1
  113. package/eskimi/genders.js +1 -1
  114. package/eskimi/getAccessToken.js +11 -57
  115. package/eskimi/getAgeGroup.js +3 -4
  116. package/eskimi/getCampaignIds.js +2 -3
  117. package/eskimi/getDevice.js +3 -4
  118. package/eskimi/getGender.js +3 -4
  119. package/eskimi/request.js +13 -59
  120. package/google/bigQuery/initClient.d.ts +11 -0
  121. package/google/bigQuery/initClient.js +22 -0
  122. package/google/bigQuery/query.d.ts +9 -0
  123. package/google/bigQuery/query.js +10 -0
  124. package/google/getConfig.d.ts +20 -0
  125. package/google/getConfig.js +23 -0
  126. package/google/sheets/getAssociatedData.d.ts +2 -6
  127. package/google/sheets/getAssociatedData.js +42 -89
  128. package/google/sheets/getBatchData.d.ts +1 -3
  129. package/google/sheets/getBatchData.js +15 -60
  130. package/google/sheets/initClient.d.ts +11 -0
  131. package/google/sheets/initClient.js +25 -0
  132. package/google/sheets/isCellNa.js +1 -4
  133. package/google/storage/initClient.d.ts +12 -0
  134. package/google/storage/initClient.js +23 -0
  135. package/google/storage/writeFile.d.ts +2 -1
  136. package/google/storage/writeFile.js +20 -77
  137. package/googleAds/getCustomer.js +7 -48
  138. package/googleAds/initClient.d.ts +9 -8
  139. package/googleAds/initClient.js +13 -56
  140. package/initClients.d.ts +13 -3
  141. package/initClients.js +95 -101
  142. package/json/isJson.js +1 -2
  143. package/littleWarden/getUrlStatus.js +10 -56
  144. package/littleWarden/isAllGood.js +3 -4
  145. package/littleWarden/isDanger.js +3 -4
  146. package/littleWarden/isWarning.js +3 -4
  147. package/littleWarden/states.js +1 -1
  148. package/myTarget/getAccessToken.js +11 -57
  149. package/myTarget/request.js +13 -59
  150. package/nextAuth/isSessionReady.js +2 -3
  151. package/nextAuth/states.js +1 -1
  152. package/nextJs/getIp.js +2 -3
  153. package/nextJs/getUserAgent.js +1 -4
  154. package/number/getDivide.js +4 -5
  155. package/number/getNumber.js +6 -7
  156. package/number/getPercent.js +4 -5
  157. package/number/getPercentIncrease.js +4 -5
  158. package/number/getRounded.js +5 -6
  159. package/package.json +2 -1
  160. package/prisma/initClient.js +4 -5
  161. package/snapchat/getAccessToken.js +25 -72
  162. package/sorting/byNumberAscending.js +3 -4
  163. package/sorting/byNumberDescending.js +3 -4
  164. package/sorting/byStringAscending.js +3 -4
  165. package/sorting/byStringDescending.js +3 -4
  166. package/string/formatCapitalise.js +2 -3
  167. package/string/getCleanFolder.js +3 -6
  168. package/string/getString.js +9 -10
  169. package/string/getStringFromStream.js +7 -8
  170. package/string/toProperCase.js +6 -7
  171. package/swr/isAllData.js +4 -5
  172. package/swr/isAnyError.js +4 -5
  173. package/swr/isAnyLoading.js +4 -5
  174. package/swr/isData.js +1 -4
  175. package/swr/isError.js +1 -4
  176. package/swr/isLoading.js +3 -6
  177. package/upTimeRobot/getMonitors.d.ts +1 -0
  178. package/upTimeRobot/getMonitors.js +33 -0
  179. package/upTimeRobot/logTypes.d.ts +7 -0
  180. package/upTimeRobot/logTypes.js +9 -0
  181. package/upTimeRobot/monitorStatuses.d.ts +8 -0
  182. package/upTimeRobot/monitorStatuses.js +10 -0
  183. package/upTimeRobot/monitorSubTypes.d.ts +10 -0
  184. package/upTimeRobot/monitorSubTypes.js +12 -0
  185. package/upTimeRobot/monitorTypes.d.ts +8 -0
  186. package/upTimeRobot/monitorTypes.js +10 -0
  187. package/upTimeRobot/requestStatuses.d.ts +5 -0
  188. package/upTimeRobot/requestStatuses.js +7 -0
  189. package/url/buildParameters.js +7 -8
  190. package/url/buildRelative.js +3 -4
  191. package/url/buildUrl.js +6 -7
  192. package/url/isAbsolute.js +1 -2
  193. package/url/isRelative.js +2 -5
  194. package/util/defaultTo.d.ts +6 -5
  195. package/util/defaultTo.js +6 -7
  196. package/util/isUndefined.d.ts +9 -0
  197. package/util/isUndefined.js +19 -0
  198. package/util/sleep.js +2 -3
  199. package/webWorker/states.js +1 -1
  200. package/xml/getXml.js +10 -58
  201. package/aws/athenaExpress/request.d.ts +0 -8
  202. package/aws/athenaExpress/request.js +0 -54
  203. package/aws/config.d.ts +0 -5
  204. package/aws/config.js +0 -2
  205. package/google/getCredentials.d.ts +0 -20
  206. package/google/getCredentials.js +0 -76
  207. package/google/sheets/getAuth.d.ts +0 -8
  208. package/google/sheets/getAuth.js +0 -69
@@ -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
- var isValid_1 = __importDefault(require("date-fns/isValid"));
7
- var parseISO_1 = __importDefault(require("date-fns/parseISO"));
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
- var isDateValid = function (_a) {
12
- var input = _a.input;
13
- var cleanInput = input.trim();
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
- var matches = cleanInput.match(/^([0-9]{4}-[0-9]{2}-[0-9]{2})$/);
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
  }
@@ -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
- var getLastWeek_1 = __importDefault(require("./getLastWeek"));
6
+ const getLastWeek_1 = __importDefault(require("./getLastWeek"));
7
7
  /**
8
8
  * Check to see if a given timeframe is Last Week.
9
9
  */
10
- var isLastWeek = function (_a) {
11
- var end = _a.end, start = _a.start;
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;
@@ -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
- var getThisWeek_1 = __importDefault(require("./getThisWeek"));
6
+ const getThisWeek_1 = __importDefault(require("./getThisWeek"));
7
7
  /**
8
8
  * Check to see if a given timeframe is Last Week.
9
9
  */
10
- var isThisWeek = function (_a) {
11
- var end = _a.end, start = _a.start;
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;
@@ -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
- var parseExcelDate = function (_a) {
8
- var serial = _a.serial;
9
- var utcDates = Math.floor(serial - 25569);
10
- var utcValue = utcDates * 86400;
11
- var dateInfo = new Date(utcValue * 1000);
12
- var fractionalDay = serial - Math.floor(serial) + 0.0000001;
13
- var totalSeconds = Math.floor(86400 * fractionalDay);
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
- var hours = Math.floor(totalSeconds / (60 * 60));
17
- var minutes = Math.floor(totalSeconds / 60) % 60;
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
- var reports_1 = __importDefault(require("./reports"));
7
- var orders_1 = __importDefault(require("./orders"));
8
- var buildRequest = function (_a) {
9
- var crawlId = _a.crawlId, customPath = _a.customPath, filters = _a.filters, limit = _a.limit, orders = _a.orders, page = _a.page, projectId = _a.projectId, report = _a.report, subReport = _a.subReport;
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 "Maximum row limit is 200.";
13
+ throw `Maximum row limit is 200.`;
15
14
  }
16
15
  else if (0 === limit) {
17
- throw "Row limit must be greater than 0.";
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 "Crawl ID must be defined.";
25
+ throw `Crawl ID must be defined.`;
27
26
  }
28
27
  switch (report) {
29
28
  case reports_1.default.LIST_CRAWLS:
30
- url += "/projects/".concat(projectId, "/crawls");
29
+ url += `/projects/${projectId}/crawls`;
31
30
  break;
32
31
  case reports_1.default.LIST_PROJECTS:
33
- url += "/projects";
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 += "/projects/".concat(projectId, "/crawls/").concat(crawlId, "/statistics");
40
+ url += `/projects/${projectId}/crawls/${crawlId}/statistics`;
42
41
  break;
43
42
  case reports_1.default.LIST_REPORTS:
44
- url += "/projects/".concat(projectId, "/crawls/").concat(crawlId, "/reports");
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 += "/projects/".concat(projectId, "/crawls/").concat(crawlId, "/reports/").concat(subReport);
48
+ url += `/projects/${projectId}/crawls/${crawlId}/reports/${subReport}`;
50
49
  if (reports_1.default.REPORT_ROWS === report) {
51
- url += "/report_rows";
50
+ url += `/report_rows`;
52
51
  }
53
52
  else if (reports_1.default.REPORT_STATISTICS === report) {
54
- url += "/statistics";
53
+ url += `/statistics`;
55
54
  }
56
55
  break;
57
56
  }
58
57
  // Specify the limit
59
58
  url += -1 === url.indexOf('?') ? '?' : '&';
60
- url += "per_page=".concat(limit);
59
+ url += `per_page=${limit}`;
61
60
  // Set the page number
62
61
  if (undefined !== page) {
63
62
  url += -1 === url.indexOf('?') ? '?' : '&';
64
- url += "page=".concat(page);
63
+ url += `page=${page}`;
65
64
  }
66
65
  // Apply any filters
67
66
  if (undefined !== filters) {
68
- filters.map(function (filter) {
67
+ filters.map(filter => {
69
68
  url += -1 === url.indexOf('?') ? '?' : '&';
70
- url += "q[".concat(filter.field, "_").concat(filter.operand, "]=").concat(filter.value);
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(function (order, index) {
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;
@@ -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
- var get_1 = __importDefault(require("../axios/get"));
54
- var response_1 = __importDefault(require("../api/response"));
55
- var states_1 = __importDefault(require("../api/states"));
56
- var getData = function (_a) {
57
- var url = _a.url;
58
- return __awaiter(void 0, void 0, void 0, function () {
59
- var response;
60
- return __generator(this, function (_b) {
61
- switch (_b.label) {
62
- case 0:
63
- response = __assign({}, response_1.default);
64
- return [4 /*yield*/, (0, get_1.default)({
65
- config: {
66
- headers: {
67
- 'X-AUTH-TOKEN': global.deepcrawl.token,
68
- },
69
- },
70
- onError: function (error) {
71
- response.state = states_1.default.ERROR;
72
- response.error = error.message;
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;
@@ -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
- var post_1 = __importDefault(require("../axios/post"));
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
- var initClient = function (_a) {
53
- var auth = _a.auth;
54
- return __awaiter(void 0, void 0, void 0, function () {
55
- var apiResponse;
56
- return __generator(this, function (_b) {
57
- switch (_b.label) {
58
- case 0:
59
- if (!(null === global.deepcrawl.token)) return [3 /*break*/, 2];
60
- return [4 /*yield*/, (0, post_1.default)({
61
- config: {
62
- auth: {
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;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var operands = {
3
+ const operands = {
4
4
  EQUALS: 'eql',
5
5
  CONTAINS: 'cont',
6
6
  LESS_THAN: 'lt',
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var orders = {
3
+ const orders = {
4
4
  ASCENDING: 'asc',
5
5
  DESCENDING: 'desc',
6
6
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var reports = {
3
+ const reports = {
4
4
  CRAWL_STATISTICS: 'crawl_statistics',
5
5
  CUSTOM: 'custom',
6
6
  LIST_PROJECTS: 'list_projects',
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var environments = {
3
+ const environments = {
4
4
  DEVELOPMENT: 'development',
5
5
  STAGING: 'staging',
6
6
  PRODUCTION: 'production',
@@ -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
- var environments_1 = __importDefault(require("./environments"));
6
+ const environments_1 = __importDefault(require("./environments"));
7
7
  /**
8
8
  * Determine the environment we're using.
9
9
  */
10
- var getEnvironment = function () {
11
- var platformEnvironment = process.env.ENVIRONMENT;
12
- var response;
10
+ const getEnvironment = () => {
11
+ let platformEnvironment = process.env.ENVIRONMENT;
12
+ let response;
13
13
  // Custom - Backend/AWS
14
- if (undefined !== process.env.EMS_ENVIRONMENT) {
14
+ if (process.env.EMS_ENVIRONMENT) {
15
15
  platformEnvironment = process.env.EMS_ENVIRONMENT;
16
16
  }
17
17
  // Custom - Frontend
18
- else if (undefined !== process.env.NEXT_PUBLIC_EMS_ENVIRONMENT) {
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 (undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF) {
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 (undefined !== process.env.VERCEL_GIT_COMMIT_REF) {
26
+ else if (process.env.VERCEL_GIT_COMMIT_REF) {
27
27
  platformEnvironment = process.env.VERCEL_GIT_COMMIT_REF;
28
28
  }
29
29
  switch (platformEnvironment) {
@@ -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
- var platforms_1 = __importDefault(require("./platforms"));
6
+ const platforms_1 = __importDefault(require("./platforms"));
7
7
  /**
8
8
  * Check to see if we are working on AWS Lambda.
9
9
  */
10
- var isAws = function () { return platforms_1.default.AWS === process.env['EMS_PLATFORM']; };
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
- var environments_1 = __importDefault(require("./environments"));
7
- var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
- var isDevelopment = function () { return environments_1.default.DEVELOPMENT === (0, getEnvironment_1.default)(); };
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
- var isAws_1 = __importDefault(require("./isAws"));
7
- var isVercel_1 = __importDefault(require("./isVercel"));
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
- var isLocalhost = function () {
12
- var response = false;
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
- var environments_1 = __importDefault(require("./environments"));
7
- var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
- var isProduction = function () { return environments_1.default.PRODUCTION === (0, getEnvironment_1.default)(); };
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;
@@ -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
- var environments_1 = __importDefault(require("./environments"));
7
- var getEnvironment_1 = __importDefault(require("./getEnvironment"));
8
- var isStaging = function () { return environments_1.default.STAGING === (0, getEnvironment_1.default)(); };
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;
@@ -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
- var isVercel = function () { return undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF; };
6
+ const isVercel = () => undefined !== process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_REF;
7
7
  exports.default = isVercel;
@@ -2,5 +2,5 @@ declare const platforms: {
2
2
  AWS: string;
3
3
  VERCEL: string;
4
4
  };
5
- export declare type Platforms = typeof platforms.AWS | typeof platforms.VERCEL;
5
+ export declare type Platform = typeof platforms.AWS | typeof platforms.VERCEL;
6
6
  export default platforms;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var platforms = {
3
+ const platforms = {
4
4
  AWS: 'aws',
5
5
  VERCEL: 'vercel',
6
6
  };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var ageGroups = [
3
+ const ageGroups = [
4
4
  {
5
5
  "id": 0,
6
6
  "name": "0-17",
package/eskimi/devices.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var devices = [
3
+ const devices = [
4
4
  {
5
5
  "id": 2,
6
6
  "name": "Personal Computer",
@@ -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
- var endpoints = {
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',
package/eskimi/genders.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- var genders = [
3
+ const genders = [
4
4
  {
5
5
  "id": 1,
6
6
  "name": "Male",