@8ms/helpers 2.1.4 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.github/workflows/deploy_npmjs.yml +19 -14
  2. package/_class/BaseClass.js +43 -52
  3. package/_class/BaseNamespace.js +17 -20
  4. package/_class/index.js +2 -7
  5. package/adverity/getJobs.js +7 -11
  6. package/adverity/index.js +51 -54
  7. package/adverity/server.js +1 -5
  8. package/api/ApiResponseClass.js +84 -88
  9. package/api/functions.js +13 -22
  10. package/api/index.js +3 -19
  11. package/api/types.js +5 -9
  12. package/array/index.js +3 -11
  13. package/atInternet/index.js +10 -13
  14. package/aws/ec2/AwsEc2Namespace.js +34 -74
  15. package/aws/ec2/server.js +5 -9
  16. package/aws/ecs/AwsEcsNamespace.js +110 -150
  17. package/aws/ecs/server.js +5 -9
  18. package/aws/glue/AwsGlueNamespace.js +26 -66
  19. package/aws/glue/server.js +5 -9
  20. package/aws/isResponse200.js +3 -7
  21. package/aws/lambda/AwsLambdaNamespace.js +62 -102
  22. package/aws/lambda/server.js +6 -11
  23. package/aws/s3/AwsS3Namespace.js +347 -390
  24. package/aws/s3/payload.js +29 -32
  25. package/aws/s3/server.js +9 -14
  26. package/aws/server.js +5 -10
  27. package/aws/ses/AwsSesNamespace.js +36 -76
  28. package/aws/ses/SimpleEmail.js +267 -304
  29. package/aws/ses/server.js +6 -11
  30. package/aws/sqs/AwsSqsNamespace.js +49 -89
  31. package/aws/sqs/server.js +5 -9
  32. package/aws/ssm/AwsSsmNamespace.js +43 -79
  33. package/aws/ssm/server.js +5 -9
  34. package/axios/deleteRequest.js +8 -15
  35. package/axios/get.js +8 -15
  36. package/axios/index.js +3 -9
  37. package/axios/post.js +8 -15
  38. package/boolean/index.js +3 -10
  39. package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
  40. package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
  41. package/brightData/serpApi/getAsyncRequestId.js +8 -12
  42. package/brightData/serpApi/getAsyncResults.js +8 -12
  43. package/brightData/serpApi/getRealtime.js +3 -7
  44. package/brightData/serpApi/server.js +6 -14
  45. package/brightData/server.js +2 -7
  46. package/brightData/webScraperIde/getBatch.js +3 -7
  47. package/brightData/webScraperIde/getRealtime.js +11 -15
  48. package/brightData/webScraperIde/server.js +2 -7
  49. package/cache/server.js +2 -7
  50. package/cache/test/cache.test.js +4 -6
  51. package/crud/index.js +1 -4
  52. package/crypto/getDecrypt.js +2 -39
  53. package/crypto/getEncrypt.js +2 -39
  54. package/crypto/getRandom.js +1 -5
  55. package/crypto/getSha256.js +4 -41
  56. package/crypto/index.js +4 -11
  57. package/date/calculation.js +70 -99
  58. package/date/financialYear.js +16 -23
  59. package/date/format.js +40 -61
  60. package/date/index.js +4 -20
  61. package/date/type.js +4 -7
  62. package/environment/index.js +15 -25
  63. package/eskimi/getAgeGroup.js +3 -7
  64. package/eskimi/getData.js +3 -7
  65. package/eskimi/getDevice.js +3 -7
  66. package/eskimi/getGender.js +3 -7
  67. package/eskimi/server.js +23 -26
  68. package/file/index.js +8 -46
  69. package/geo/countries.js +1 -4
  70. package/geo/index.js +2 -7
  71. package/geo/languages.js +1 -4
  72. package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
  73. package/google/bigQuery/loadData.js +1 -5
  74. package/google/bigQuery/server.js +8 -14
  75. package/google/server.js +1 -5
  76. package/google/sheets/GoogleSheetsNamespace.js +34 -74
  77. package/google/sheets/getAssociatedData.js +1 -5
  78. package/google/sheets/server.js +8 -14
  79. package/google/storage/GoogleCloudStorageNamespace.js +62 -102
  80. package/google/storage/server.js +6 -10
  81. package/googleAds/GoogleAdsNamespace.js +28 -68
  82. package/googleAds/keywordPlanner/server.js +32 -35
  83. package/googleAds/server.js +6 -10
  84. package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
  85. package/googlePageSpeed/server.js +8 -12
  86. package/googleSearchIncidents/server.js +28 -32
  87. package/greenDomain/server.js +17 -21
  88. package/inngest/server.js +1 -4
  89. package/json/getJsonNewline.js +3 -7
  90. package/json/index.js +2 -7
  91. package/json/isJson.js +1 -5
  92. package/littleWarden/LittleWardenNamespace.js +24 -31
  93. package/littleWarden/getUrlStatus.js +3 -7
  94. package/littleWarden/server.js +14 -22
  95. package/lumar/api/buildRequest.js +14 -18
  96. package/lumar/api/getData.js +3 -7
  97. package/lumar/api/initClient.js +3 -7
  98. package/lumar/api/server.js +6 -12
  99. package/lumar/graphql/columns.js +1 -4
  100. package/lumar/graphql/getData.js +3 -7
  101. package/lumar/graphql/initClient.js +3 -7
  102. package/lumar/graphql/queries/crawl.js +1 -2
  103. package/lumar/graphql/queries/getCrawls.js +1 -3
  104. package/lumar/graphql/queries/getReportDifferences.js +3 -5
  105. package/lumar/graphql/queries/getRows.js +1 -3
  106. package/lumar/graphql/queries/getTotals.js +1 -3
  107. package/lumar/graphql/queries/row.js +1 -2
  108. package/lumar/graphql/reportTemplates.js +1 -4
  109. package/lumar/graphql/server.js +7 -15
  110. package/myTarget/server.js +3 -7
  111. package/nextAuth/index.js +2 -6
  112. package/nextAuth/isSessionReady.js +1 -5
  113. package/nextJs/client/LazyLoad.js +5 -12
  114. package/nextJs/client.js +1 -5
  115. package/nextJs/index.js +2 -7
  116. package/number/format.js +3 -7
  117. package/number/formatCurrency.js +1 -5
  118. package/number/getDecimal.js +3 -7
  119. package/number/getNumber.js +3 -7
  120. package/number/getPercentIncrease.js +4 -8
  121. package/number/getSafeDivide.js +6 -10
  122. package/number/index.js +6 -15
  123. package/object/index.js +1 -5
  124. package/object/replaceKeys.js +3 -7
  125. package/onePassword/OnePasswordNamespace.js +36 -76
  126. package/onePassword/server.js +3 -7
  127. package/openAi/OpenAiNamespace.js +32 -39
  128. package/openAi/server.js +6 -10
  129. package/package.json +136 -120
  130. package/prisma/PrismaNamespace.d.ts +3 -3
  131. package/prisma/PrismaNamespace.js +55 -81
  132. package/prisma/getDecimal.js +5 -12
  133. package/prisma/server.d.ts +13 -0
  134. package/prisma/server.js +6 -9
  135. package/snapchat/SnapchatNamespace.js +20 -27
  136. package/snapchat/server.js +6 -10
  137. package/sorting/byNumberAscending.js +1 -5
  138. package/sorting/byNumberDescending.js +1 -5
  139. package/sorting/byStringAscending.js +1 -5
  140. package/sorting/byStringDescending.js +1 -5
  141. package/sorting/index.js +4 -11
  142. package/stream/server.js +1 -5
  143. package/stream/sort.js +1 -5
  144. package/string/getCapitalised.js +3 -7
  145. package/string/getClean.js +17 -21
  146. package/string/getFolder.js +3 -10
  147. package/string/getProperCase.js +4 -8
  148. package/string/getString.js +8 -15
  149. package/string/getStringFromStream.js +1 -5
  150. package/string/getUnescaped.js +3 -10
  151. package/string/getWithoutAccents.js +1 -5
  152. package/string/getWithoutHtmlTags.js +1 -5
  153. package/string/getWithoutPunctuation.js +1 -5
  154. package/string/getWithoutUnderscores.js +1 -5
  155. package/string/getWithoutWhitespaces.js +1 -5
  156. package/string/index.js +12 -27
  157. package/string/reservedWords.js +5 -9
  158. package/swr/index.js +9 -18
  159. package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
  160. package/upTimeRobot/server.js +11 -15
  161. package/url/index.js +12 -23
  162. package/url/server.js +1 -5
  163. package/url/writeUrlContents.js +6 -46
  164. package/util/defaultTo.js +5 -12
  165. package/util/getBrotliCompressed.js +3 -10
  166. package/util/getBrotliDecompressed.js +3 -10
  167. package/util/getClean.js +5 -9
  168. package/util/getError.js +1 -5
  169. package/util/getGzipCompressed.js +3 -10
  170. package/util/getGzipDecompressed.js +3 -10
  171. package/util/getWithoutHash.js +1 -5
  172. package/util/getWithoutParameter.js +1 -5
  173. package/util/index.js +7 -17
  174. package/util/isUndefined.js +3 -7
  175. package/util/promiseChunks.js +6 -10
  176. package/util/server.js +4 -11
  177. package/util/sleep.js +1 -5
  178. package/webWorker/index.js +1 -4
  179. package/xml/getXml.js +3 -7
  180. package/.yarn/install-state.gz +0 -0
  181. package/.yarn/releases/yarn-4.9.4.cjs +0 -942
  182. package/.yarnrc.yml +0 -3
  183. package/aws/athenaExpress/AwsAthenaNamespace.d.ts +0 -8
  184. package/aws/athenaExpress/AwsAthenaNamespace.js +0 -82
  185. package/aws/athenaExpress/server.d.ts +0 -10
  186. package/aws/athenaExpress/server.js +0 -40
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getUnescaped = void 0;
7
- const unescape_1 = __importDefault(require("lodash/unescape"));
1
+ import _unescape from "lodash/unescape";
8
2
  /**
9
3
  * Convert escaped copy into unescaped.
10
4
  * E.g. there's => there's
11
5
  * https://stackoverflow.com/a/42182294/2664955
12
6
  */
13
- const getUnescaped = (input) => {
7
+ export const getUnescaped = (input) => {
14
8
  let response = input;
15
9
  // Only works if DOM exists
16
10
  if ("undefined" !== typeof document) {
@@ -19,8 +13,7 @@ const getUnescaped = (input) => {
19
13
  response = el.value;
20
14
  }
21
15
  else {
22
- response = (0, unescape_1.default)(response);
16
+ response = _unescape(response);
23
17
  }
24
18
  return response;
25
19
  };
26
- exports.getUnescaped = getUnescaped;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWithoutAccents = void 0;
4
1
  /**
5
2
  * Remove the accents from a string.
6
3
  * https://stackoverflow.com/a/37511463
7
4
  */
8
- const getWithoutAccents = (input) => {
5
+ export const getWithoutAccents = (input) => {
9
6
  return input
10
7
  .normalize("NFD")
11
8
  .replace(/[\u0300-\u036f]/g, "");
12
9
  };
13
- exports.getWithoutAccents = getWithoutAccents;
@@ -1,12 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWithoutHtmlTags = void 0;
4
1
  /**
5
2
  * Removes all HTML tags from an input.
6
3
  * https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
7
4
  */
8
- const getWithoutHtmlTags = (input) => {
5
+ export const getWithoutHtmlTags = (input) => {
9
6
  return input
10
7
  .replace(/(<([^>]+)>)/gi, "");
11
8
  };
12
- exports.getWithoutHtmlTags = getWithoutHtmlTags;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWithoutPunctuation = void 0;
4
1
  /**
5
2
  * Remove all punctuation from a string and replace with a space.
6
3
  * https://stackoverflow.com/a/25575009
7
4
  */
8
- const getWithoutPunctuation = (input) => {
5
+ export const getWithoutPunctuation = (input) => {
9
6
  return input
10
7
  .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g, "")
11
8
  .replace(/\s+/g, " ");
12
9
  };
13
- exports.getWithoutPunctuation = getWithoutPunctuation;
@@ -1,11 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWithoutUnderscores = void 0;
4
1
  /**
5
2
  * Replace all underscores with a space.
6
3
  */
7
- const getWithoutUnderscores = (input) => {
4
+ export const getWithoutUnderscores = (input) => {
8
5
  return input
9
6
  .replace("_", " ");
10
7
  };
11
- exports.getWithoutUnderscores = getWithoutUnderscores;
@@ -1,13 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWithoutWhitespaces = void 0;
4
1
  /**
5
2
  * Remove all new lines, tabs multiple spaces, with a single space.
6
3
  * https://stackoverflow.com/a/45029224
7
4
  */
8
- const getWithoutWhitespaces = (input) => {
5
+ export const getWithoutWhitespaces = (input) => {
9
6
  return input
10
7
  .replace(/\s+/g, " ")
11
8
  .trim();
12
9
  };
13
- exports.getWithoutWhitespaces = getWithoutWhitespaces;
package/string/index.js CHANGED
@@ -1,27 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWithoutWhitespaces = exports.getWithoutUnderscores = exports.getWithoutPunctuation = exports.getWithoutHtmlTags = exports.getWithoutAccents = exports.getUnescaped = exports.getStringFromStream = exports.getString = exports.getProperCase = exports.getFolder = exports.getClean = exports.getCapitalised = void 0;
4
- var getCapitalised_1 = require("./getCapitalised");
5
- Object.defineProperty(exports, "getCapitalised", { enumerable: true, get: function () { return getCapitalised_1.getCapitalised; } });
6
- var getClean_1 = require("./getClean");
7
- Object.defineProperty(exports, "getClean", { enumerable: true, get: function () { return getClean_1.getClean; } });
8
- var getFolder_1 = require("./getFolder");
9
- Object.defineProperty(exports, "getFolder", { enumerable: true, get: function () { return getFolder_1.getFolder; } });
10
- var getProperCase_1 = require("./getProperCase");
11
- Object.defineProperty(exports, "getProperCase", { enumerable: true, get: function () { return getProperCase_1.getProperCase; } });
12
- var getString_1 = require("./getString");
13
- Object.defineProperty(exports, "getString", { enumerable: true, get: function () { return getString_1.getString; } });
14
- var getStringFromStream_1 = require("./getStringFromStream");
15
- Object.defineProperty(exports, "getStringFromStream", { enumerable: true, get: function () { return getStringFromStream_1.getStringFromStream; } });
16
- var getUnescaped_1 = require("./getUnescaped");
17
- Object.defineProperty(exports, "getUnescaped", { enumerable: true, get: function () { return getUnescaped_1.getUnescaped; } });
18
- var getWithoutAccents_1 = require("./getWithoutAccents");
19
- Object.defineProperty(exports, "getWithoutAccents", { enumerable: true, get: function () { return getWithoutAccents_1.getWithoutAccents; } });
20
- var getWithoutHtmlTags_1 = require("./getWithoutHtmlTags");
21
- Object.defineProperty(exports, "getWithoutHtmlTags", { enumerable: true, get: function () { return getWithoutHtmlTags_1.getWithoutHtmlTags; } });
22
- var getWithoutPunctuation_1 = require("./getWithoutPunctuation");
23
- Object.defineProperty(exports, "getWithoutPunctuation", { enumerable: true, get: function () { return getWithoutPunctuation_1.getWithoutPunctuation; } });
24
- var getWithoutUnderscores_1 = require("./getWithoutUnderscores");
25
- Object.defineProperty(exports, "getWithoutUnderscores", { enumerable: true, get: function () { return getWithoutUnderscores_1.getWithoutUnderscores; } });
26
- var getWithoutWhitespaces_1 = require("./getWithoutWhitespaces");
27
- Object.defineProperty(exports, "getWithoutWhitespaces", { enumerable: true, get: function () { return getWithoutWhitespaces_1.getWithoutWhitespaces; } });
1
+ export { getCapitalised } from "./getCapitalised";
2
+ export { getClean } from "./getClean";
3
+ export { getFolder } from "./getFolder";
4
+ export { getProperCase } from "./getProperCase";
5
+ export { getString } from "./getString";
6
+ export { getStringFromStream } from "./getStringFromStream";
7
+ export { getUnescaped } from "./getUnescaped";
8
+ export { getWithoutAccents } from "./getWithoutAccents";
9
+ export { getWithoutHtmlTags } from "./getWithoutHtmlTags";
10
+ export { getWithoutPunctuation } from "./getWithoutPunctuation";
11
+ export { getWithoutUnderscores } from "./getWithoutUnderscores";
12
+ export { getWithoutWhitespaces } from "./getWithoutWhitespaces";
@@ -1,7 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isReservedWord = exports.reservedWords = void 0;
4
- exports.reservedWords = [
1
+ export const reservedWords = [
5
2
  "AI",
6
3
  "GA4",
7
4
  "GSC",
@@ -13,14 +10,13 @@ exports.reservedWords = [
13
10
  /**
14
11
  * Check if its a reserved word, the casing may be specific eg, OpenAI.
15
12
  */
16
- const isReservedWord = (word) => {
13
+ export const isReservedWord = (word) => {
17
14
  let response = null;
18
- for (let i = 0; i < exports.reservedWords.length; i++) {
19
- if (exports.reservedWords[i].toLowerCase() === word.toLowerCase()) {
20
- response = exports.reservedWords[i];
15
+ for (let i = 0; i < reservedWords.length; i++) {
16
+ if (reservedWords[i].toLowerCase() === word.toLowerCase()) {
17
+ response = reservedWords[i];
21
18
  break;
22
19
  }
23
20
  }
24
21
  return response;
25
22
  };
26
- exports.isReservedWord = isReservedWord;
package/swr/index.js CHANGED
@@ -1,59 +1,50 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isAllData = exports.isAnyError = exports.isAnyLoading = exports.isError = exports.isLoading = exports.isData = void 0;
4
1
  /**
5
2
  * Check to see if a single SWR has an error.
6
3
  */
7
- const isData = (swr) => (undefined === swr.error || null === swr.error) &&
4
+ export const isData = (swr) => (undefined === swr.error || null === swr.error) &&
8
5
  "undefined" !== typeof swr.data &&
9
6
  "undefined" !== swr.data;
10
- exports.isData = isData;
11
7
  /**
12
8
  * Check to see if a single SWR is loading.
13
9
  */
14
- const isLoading = (swr) => !(0, exports.isError)(swr) && !(0, exports.isData)(swr);
15
- exports.isLoading = isLoading;
10
+ export const isLoading = (swr) => !isError(swr) && !isData(swr);
16
11
  /**
17
12
  * Check to see if a single SWR has an error.
18
13
  */
19
- const isError = (swr) => undefined !== swr.error && null !== swr.error;
20
- exports.isError = isError;
14
+ export const isError = (swr) => undefined !== swr.error && null !== swr.error;
21
15
  /**
22
16
  * Are any of SWRs loading
23
17
  */
24
- const isAnyLoading = (swrs) => {
18
+ export const isAnyLoading = (swrs) => {
25
19
  let counter = 0;
26
20
  for (const swr in swrs) {
27
- if ((0, exports.isLoading)(swrs[swr])) {
21
+ if (isLoading(swrs[swr])) {
28
22
  counter++;
29
23
  }
30
24
  }
31
25
  return counter > 0;
32
26
  };
33
- exports.isAnyLoading = isAnyLoading;
34
27
  /**
35
28
  * Are any of the SWRs marked as an error.
36
29
  */
37
- const isAnyError = (swrs) => {
30
+ export const isAnyError = (swrs) => {
38
31
  let counter = 0;
39
32
  for (const swr in swrs) {
40
- if ((0, exports.isError)(swrs[swr])) {
33
+ if (isError(swrs[swr])) {
41
34
  counter++;
42
35
  }
43
36
  }
44
37
  return counter > 0;
45
38
  };
46
- exports.isAnyError = isAnyError;
47
39
  /**
48
40
  * Are all SWRs data ready.
49
41
  */
50
- const isAllData = (swrs) => {
42
+ export const isAllData = (swrs) => {
51
43
  let counter = 0;
52
44
  for (const swr in swrs) {
53
- if ((0, exports.isData)(swrs[swr])) {
45
+ if (isData(swrs[swr])) {
54
46
  counter++;
55
47
  }
56
48
  }
57
49
  return counter === Object.keys(swrs).length;
58
50
  };
59
- exports.isAllData = isAllData;
@@ -1,50 +1,40 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.UpTimeRobotNamespace = void 0;
7
- const _class_1 = require("../_class");
8
- const axios_1 = require("../axios");
9
- const isArray_1 = __importDefault(require("lodash/isArray"));
1
+ import { BaseNamespace } from "../_class";
2
+ import { post } from "../axios";
3
+ import isArray from "lodash/isArray";
10
4
  /**
11
5
  * Use the Up Time Robot API to retrieve up to 50 monitors at a time.
12
6
  * https://uptimerobot.com/api/
13
7
  */
14
- class UpTimeRobotNamespace extends _class_1.BaseNamespace {
15
- constructor() {
16
- super(...arguments);
17
- /**
18
- * Renew the access token as it expires every 3 hours.
19
- */
20
- this.ensureInit = async () => {
21
- if (!this.client) {
22
- this.client = true;
8
+ export class UpTimeRobotNamespace extends BaseNamespace {
9
+ /**
10
+ * Renew the access token as it expires every 3 hours.
11
+ */
12
+ ensureInit = async () => {
13
+ if (!this.client) {
14
+ this.client = true;
15
+ }
16
+ };
17
+ getReport = async (props) => {
18
+ let response = null;
19
+ let finalParams = {};
20
+ if (undefined !== props) {
21
+ finalParams = {
22
+ ...props,
23
+ };
24
+ if (undefined !== props.monitors && isArray(props.monitors)) {
25
+ finalParams["monitors"] = props.monitors.join("-");
23
26
  }
24
- };
25
- this.getReport = async (props) => {
26
- let response = null;
27
- let finalParams = {};
28
- if (undefined !== props) {
29
- finalParams = {
30
- ...props,
31
- };
32
- if (undefined !== props.monitors && (0, isArray_1.default)(props.monitors)) {
33
- finalParams["monitors"] = props.monitors.join("-");
34
- }
35
- if (undefined !== props.statuses && (0, isArray_1.default)(props.statuses)) {
36
- finalParams["statuses"] = props.statuses.join("-");
37
- }
38
- if (undefined !== props.types && (0, isArray_1.default)(props.types)) {
39
- finalParams["types"] = props.types.join("-");
40
- }
27
+ if (undefined !== props.statuses && isArray(props.statuses)) {
28
+ finalParams["statuses"] = props.statuses.join("-");
41
29
  }
42
- const apiResponse = await (0, axios_1.post)(`https://api.uptimerobot.com/v2/getMonitors?api_key=${this.config.apiKey}`, finalParams);
43
- if (apiResponse.isSuccess()) {
44
- response = apiResponse.getBody();
30
+ if (undefined !== props.types && isArray(props.types)) {
31
+ finalParams["types"] = props.types.join("-");
45
32
  }
46
- return response;
47
- };
48
- }
33
+ }
34
+ const apiResponse = await post(`https://api.uptimerobot.com/v2/getMonitors?api_key=${this.config.apiKey}`, finalParams);
35
+ if (apiResponse.isSuccess()) {
36
+ response = apiResponse.getBody();
37
+ }
38
+ return response;
39
+ };
49
40
  }
50
- exports.UpTimeRobotNamespace = UpTimeRobotNamespace;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.requestStatuses = exports.monitorTypes = exports.monitorSubTypes = exports.monitorStatuses = exports.logTypes = exports.upTimeRobotClient = void 0;
4
- const UpTimeRobotNamespace_1 = require("./UpTimeRobotNamespace");
5
- const server_1 = require("../onePassword/server");
1
+ import { UpTimeRobotNamespace } from "./UpTimeRobotNamespace";
2
+ import { onePasswordClient } from "../onePassword/server";
6
3
  const upTimeRobotNamespaces = new Map();
7
- const upTimeRobotClient = async (key = "default", config, vaultId, itemId) => {
4
+ export const upTimeRobotClient = async (key = "default", config, vaultId, itemId) => {
8
5
  if (upTimeRobotNamespaces.has(key)) {
9
6
  return upTimeRobotNamespaces.get(key);
10
7
  }
@@ -13,35 +10,34 @@ const upTimeRobotClient = async (key = "default", config, vaultId, itemId) => {
13
10
  instanceConfig = config;
14
11
  }
15
12
  else if (vaultId && itemId) {
16
- instanceConfig = await (await (0, server_1.onePasswordClient)())
13
+ instanceConfig = await (await onePasswordClient())
17
14
  .getJsonNote(vaultId, itemId);
18
15
  }
19
16
  else if (process.env.UP_TIME_ROBOT_VAULT_ID && process.env.UP_TIME_ROBOT_ITEM_ID) {
20
- instanceConfig = await (await (0, server_1.onePasswordClient)())
17
+ instanceConfig = await (await onePasswordClient())
21
18
  .getJsonNote(process.env.UP_TIME_ROBOT_VAULT_ID, process.env.UP_TIME_ROBOT_ITEM_ID);
22
19
  }
23
20
  else {
24
21
  throw new Error(`Config required for namespace '${key}'`);
25
22
  }
26
- const namespace = new UpTimeRobotNamespace_1.UpTimeRobotNamespace(key, instanceConfig);
23
+ const namespace = new UpTimeRobotNamespace(key, instanceConfig);
27
24
  upTimeRobotNamespaces.set(key, namespace);
28
25
  return namespace;
29
26
  };
30
- exports.upTimeRobotClient = upTimeRobotClient;
31
- exports.logTypes = {
27
+ export const logTypes = {
32
28
  DOWN: 1,
33
29
  UP: 2,
34
30
  PAUSED: 99,
35
31
  STARTED: 98,
36
32
  };
37
- exports.monitorStatuses = {
33
+ export const monitorStatuses = {
38
34
  PAUSED: 0,
39
35
  NOT_CHECKED: 1,
40
36
  UP: 2,
41
37
  SEEMS_DOWN: 8,
42
38
  DOWN: 9,
43
39
  };
44
- exports.monitorSubTypes = {
40
+ export const monitorSubTypes = {
45
41
  HTTP: 1,
46
42
  HTTPS: 2,
47
43
  FTP: 3,
@@ -50,14 +46,14 @@ exports.monitorSubTypes = {
50
46
  IMAP: 6,
51
47
  CUSTOM_PORT: 99,
52
48
  };
53
- exports.monitorTypes = {
49
+ export const monitorTypes = {
54
50
  HTTPS: 1,
55
51
  KEYWORD: 2,
56
52
  PING: 3,
57
53
  PORT: 4,
58
54
  HEARTBEAT: 5,
59
55
  };
60
- exports.requestStatuses = {
56
+ export const requestStatuses = {
61
57
  ERROR: 'fail',
62
58
  SUCCESS: 'ok',
63
59
  };
package/url/index.js CHANGED
@@ -1,15 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.buildEnvironmentUrl = exports.buildRelative = exports.buildParameters = exports.isRelative = exports.isAbsolute = void 0;
7
- const environment_1 = require("../environment");
8
- const merge_1 = __importDefault(require("lodash/merge"));
1
+ import { isDevelopment, isLocalhost, isProduction, isStaging } from "../environment";
2
+ import merge from "lodash/merge";
9
3
  /**
10
4
  * Does the URL begin with HTTP or HTTPS?
11
5
  */
12
- const isAbsolute = (input) => {
6
+ export const isAbsolute = (input) => {
13
7
  try {
14
8
  new URL(input);
15
9
  }
@@ -18,18 +12,16 @@ const isAbsolute = (input) => {
18
12
  }
19
13
  return true;
20
14
  };
21
- exports.isAbsolute = isAbsolute;
22
15
  /**
23
16
  * Does the URL begin with a slash.
24
17
  */
25
- const isRelative = (input) => "/" === input.trim()
18
+ export const isRelative = (input) => "/" === input.trim()
26
19
  .charAt(0);
27
- exports.isRelative = isRelative;
28
20
  /**
29
21
  * Take an object and return the parameter for a given URL irrespective of path.
30
22
  */
31
- const buildParameters = (existing = {}, updated = {}) => {
32
- const merged = (0, merge_1.default)(existing, updated);
23
+ export const buildParameters = (existing = {}, updated = {}) => {
24
+ const merged = merge(existing, updated);
33
25
  let response = "";
34
26
  if (Object.values(merged).length) {
35
27
  for (const key in merged) {
@@ -40,26 +32,24 @@ const buildParameters = (existing = {}, updated = {}) => {
40
32
  }
41
33
  return response;
42
34
  };
43
- exports.buildParameters = buildParameters;
44
35
  /**
45
36
  * Create a new relative URL based on the current path.
46
37
  */
47
- const buildRelative = (router, updated = {}) => {
48
- return `${router.pathname}${(0, exports.buildParameters)(router.query, updated || {})}`;
38
+ export const buildRelative = (router, updated = {}) => {
39
+ return `${router.pathname}${buildParameters(router.query, updated || {})}`;
49
40
  };
50
- exports.buildRelative = buildRelative;
51
41
  /**
52
42
  * Get the current base url.
53
43
  */
54
- const buildEnvironmentUrl = (path, url) => {
44
+ export const buildEnvironmentUrl = (path, url) => {
55
45
  let response;
56
- if ((0, environment_1.isDevelopment)() && (0, environment_1.isLocalhost)()) {
46
+ if (isDevelopment() && isLocalhost()) {
57
47
  response = url.localhost;
58
48
  }
59
- else if ((0, environment_1.isStaging)()) {
49
+ else if (isStaging()) {
60
50
  response = url.staging;
61
51
  }
62
- else if ((0, environment_1.isProduction)()) {
52
+ else if (isProduction()) {
63
53
  response = url.production;
64
54
  }
65
55
  else {
@@ -67,4 +57,3 @@ const buildEnvironmentUrl = (path, url) => {
67
57
  }
68
58
  return response + path || "";
69
59
  };
70
- exports.buildEnvironmentUrl = buildEnvironmentUrl;
package/url/server.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writeUrlContents = void 0;
4
- var writeUrlContents_1 = require("./writeUrlContents");
5
- Object.defineProperty(exports, "writeUrlContents", { enumerable: true, get: function () { return writeUrlContents_1.writeUrlContents; } });
1
+ export { writeUrlContents } from "./writeUrlContents";
@@ -1,54 +1,15 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __importDefault = (this && this.__importDefault) || function (mod) {
36
- return (mod && mod.__esModule) ? mod : { "default": mod };
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.writeUrlContents = void 0;
40
- const axios_1 = __importDefault(require("axios"));
41
- const file_1 = require("../file");
1
+ import axios from "axios";
2
+ import { createDirectory } from "../file";
42
3
  /**
43
4
  * Downloads a given URL's contents to a local file.
44
5
  *
45
6
  * Requires fs-extra
46
7
  */
47
- const writeUrlContents = async (filePath, url) => {
48
- const fs = await Promise.resolve().then(() => __importStar(require("fs-extra")));
49
- await (0, file_1.createDirectory)(filePath);
8
+ export const writeUrlContents = async (filePath, url) => {
9
+ const fs = await import("fs-extra");
10
+ await createDirectory(filePath);
50
11
  const writer = fs.createWriteStream(filePath);
51
- await (0, axios_1.default)({
12
+ await axios({
52
13
  method: "get",
53
14
  url,
54
15
  responseType: "stream"
@@ -72,4 +33,3 @@ const writeUrlContents = async (filePath, url) => {
72
33
  });
73
34
  });
74
35
  };
75
- exports.writeUrlContents = writeUrlContents;
package/util/defaultTo.js CHANGED
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.defaultTo = void 0;
7
- const isObject_1 = __importDefault(require("lodash/isObject"));
8
- const array_1 = require("../array");
1
+ import isObject from "lodash/isObject";
2
+ import { getArray } from "../array";
9
3
  /**
10
4
  * Function to default to a value, whilst filtering through an instance
11
5
  */
12
- const defaultTo = (instance, keys, defaultValue = null) => {
13
- const keysArray = (0, array_1.getArray)(keys);
6
+ export const defaultTo = (instance, keys, defaultValue = null) => {
7
+ const keysArray = getArray(keys);
14
8
  let found = true;
15
9
  let pointer = instance;
16
10
  // Instance is undefined or is null
@@ -22,7 +16,7 @@ const defaultTo = (instance, keys, defaultValue = null) => {
22
16
  keysArray.forEach(key => {
23
17
  if (found) {
24
18
  // Sub key doesn't exist
25
- if ((0, isObject_1.default)(pointer)) {
19
+ if (isObject(pointer)) {
26
20
  // @ts-ignore
27
21
  if (undefined === pointer[key] || null === pointer[key]) {
28
22
  found = false;
@@ -41,4 +35,3 @@ const defaultTo = (instance, keys, defaultValue = null) => {
41
35
  }
42
36
  return found ? pointer : defaultValue;
43
37
  };
44
- exports.defaultTo = defaultTo;
@@ -1,16 +1,10 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBrotliCompressed = void 0;
7
- const zlib_1 = __importDefault(require("zlib"));
1
+ import zlib from "zlib";
8
2
  /**
9
3
  * Compress a given input using Brotli.
10
4
  */
11
- const getBrotliCompressed = async (input, options = {}) => {
5
+ export const getBrotliCompressed = async (input, options = {}) => {
12
6
  return new Promise(async (resolve, reject) => {
13
- zlib_1.default.brotliCompress(input || "", options || {}, (err, data) => {
7
+ zlib.brotliCompress(input || "", options || {}, (err, data) => {
14
8
  if (err) {
15
9
  reject(`Error compressing - ${err.message}`);
16
10
  }
@@ -20,4 +14,3 @@ const getBrotliCompressed = async (input, options = {}) => {
20
14
  });
21
15
  });
22
16
  };
23
- exports.getBrotliCompressed = getBrotliCompressed;
@@ -1,17 +1,11 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.getBrotliDecompressed = void 0;
7
- const zlib_1 = __importDefault(require("zlib"));
1
+ import zlib from "zlib";
8
2
  /**
9
3
  * Decompress a given Brotli input into a string.
10
4
  */
11
- const getBrotliDecompressed = async (input, options = {}) => {
5
+ export const getBrotliDecompressed = async (input, options = {}) => {
12
6
  return new Promise(async (resolve, reject) => {
13
7
  const compressedData = Buffer.from(input || '', "base64");
14
- zlib_1.default.brotliDecompress(compressedData, options || {}, (err, data) => {
8
+ zlib.brotliDecompress(compressedData, options || {}, (err, data) => {
15
9
  if (err) {
16
10
  reject(`Error decompressing - ${err.message}`);
17
11
  }
@@ -21,4 +15,3 @@ const getBrotliDecompressed = async (input, options = {}) => {
21
15
  });
22
16
  });
23
17
  };
24
- exports.getBrotliDecompressed = getBrotliDecompressed;