@8ms/helpers 2.2.9 → 2.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/_class/BaseClass.js +43 -52
  2. package/_class/BaseNamespace.js +17 -20
  3. package/_class/index.js +2 -7
  4. package/adverity/getJobs.js +7 -11
  5. package/adverity/index.js +51 -54
  6. package/adverity/server.js +1 -5
  7. package/api/ApiResponseClass.js +84 -88
  8. package/api/functions.js +13 -22
  9. package/api/index.js +3 -19
  10. package/api/types.js +5 -9
  11. package/array/index.js +3 -11
  12. package/atInternet/index.js +10 -13
  13. package/aws/ec2/AwsEc2Namespace.js +34 -74
  14. package/aws/ec2/server.js +5 -9
  15. package/aws/ecs/AwsEcsNamespace.js +110 -150
  16. package/aws/ecs/server.js +5 -9
  17. package/aws/glue/AwsGlueNamespace.js +26 -66
  18. package/aws/glue/server.js +5 -9
  19. package/aws/isResponse200.js +3 -7
  20. package/aws/lambda/AwsLambdaNamespace.js +62 -102
  21. package/aws/lambda/server.js +6 -11
  22. package/aws/s3/AwsS3Namespace.js +347 -390
  23. package/aws/s3/payload.js +29 -32
  24. package/aws/s3/server.js +9 -14
  25. package/aws/server.js +5 -10
  26. package/aws/ses/AwsSesNamespace.js +36 -76
  27. package/aws/ses/SimpleEmail.js +267 -304
  28. package/aws/ses/server.js +6 -11
  29. package/aws/sqs/AwsSqsNamespace.js +49 -89
  30. package/aws/sqs/server.js +5 -9
  31. package/aws/ssm/AwsSsmNamespace.js +43 -79
  32. package/aws/ssm/server.js +5 -9
  33. package/axios/deleteRequest.js +8 -15
  34. package/axios/get.js +8 -15
  35. package/axios/index.js +3 -9
  36. package/axios/post.js +8 -15
  37. package/boolean/index.js +3 -10
  38. package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
  39. package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
  40. package/brightData/serpApi/getAsyncRequestId.js +8 -12
  41. package/brightData/serpApi/getAsyncResults.js +8 -12
  42. package/brightData/serpApi/getRealtime.js +3 -7
  43. package/brightData/serpApi/server.js +6 -14
  44. package/brightData/server.js +2 -7
  45. package/brightData/webScraperIde/getBatch.js +3 -7
  46. package/brightData/webScraperIde/getRealtime.js +11 -15
  47. package/brightData/webScraperIde/server.js +2 -7
  48. package/cache/server.js +2 -7
  49. package/cache/test/cache.test.js +4 -6
  50. package/crud/index.js +1 -4
  51. package/crypto/getDecrypt.js +2 -39
  52. package/crypto/getEncrypt.js +2 -39
  53. package/crypto/getRandom.js +1 -5
  54. package/crypto/getSha256.js +4 -41
  55. package/crypto/index.js +4 -11
  56. package/date/calculation.js +70 -99
  57. package/date/financialYear.js +16 -23
  58. package/date/format.js +40 -61
  59. package/date/index.js +4 -20
  60. package/date/type.js +4 -7
  61. package/environment/index.js +15 -25
  62. package/eskimi/getAgeGroup.js +3 -7
  63. package/eskimi/getData.js +3 -7
  64. package/eskimi/getDevice.js +3 -7
  65. package/eskimi/getGender.js +3 -7
  66. package/eskimi/server.js +23 -26
  67. package/file/index.js +8 -46
  68. package/geo/countries.js +1 -4
  69. package/geo/index.js +2 -7
  70. package/geo/languages.js +1 -4
  71. package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
  72. package/google/bigQuery/loadData.js +1 -5
  73. package/google/bigQuery/server.js +8 -14
  74. package/google/server.js +1 -5
  75. package/google/sheets/GoogleSheetsNamespace.js +34 -74
  76. package/google/sheets/getAssociatedData.js +1 -5
  77. package/google/sheets/server.js +8 -14
  78. package/google/storage/GoogleCloudStorageNamespace.js +62 -102
  79. package/google/storage/server.js +6 -10
  80. package/googleAds/GoogleAdsNamespace.js +28 -68
  81. package/googleAds/keywordPlanner/server.js +32 -35
  82. package/googleAds/server.js +6 -10
  83. package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
  84. package/googlePageSpeed/server.js +8 -12
  85. package/googleSearchIncidents/server.js +28 -32
  86. package/greenDomain/server.js +17 -21
  87. package/inngest/server.js +1 -4
  88. package/json/getJsonNewline.js +3 -7
  89. package/json/index.js +2 -7
  90. package/json/isJson.js +1 -5
  91. package/littleWarden/LittleWardenNamespace.js +24 -31
  92. package/littleWarden/getUrlStatus.js +3 -7
  93. package/littleWarden/server.js +14 -22
  94. package/lumar/api/buildRequest.js +14 -18
  95. package/lumar/api/getData.js +3 -7
  96. package/lumar/api/initClient.js +3 -7
  97. package/lumar/api/server.js +6 -12
  98. package/lumar/graphql/columns.js +1 -4
  99. package/lumar/graphql/getData.js +3 -7
  100. package/lumar/graphql/initClient.js +3 -7
  101. package/lumar/graphql/queries/crawl.js +1 -2
  102. package/lumar/graphql/queries/getCrawls.js +1 -3
  103. package/lumar/graphql/queries/getReportDifferences.js +3 -5
  104. package/lumar/graphql/queries/getRows.js +1 -3
  105. package/lumar/graphql/queries/getTotals.js +1 -3
  106. package/lumar/graphql/queries/row.js +1 -2
  107. package/lumar/graphql/reportTemplates.js +1 -4
  108. package/lumar/graphql/server.js +7 -15
  109. package/myTarget/server.js +3 -7
  110. package/nextAuth/index.js +2 -6
  111. package/nextAuth/isSessionReady.js +1 -5
  112. package/nextJs/client/LazyLoad.js +5 -12
  113. package/nextJs/client.js +1 -5
  114. package/nextJs/index.js +2 -7
  115. package/number/format.js +3 -7
  116. package/number/formatCurrency.js +1 -5
  117. package/number/getDecimal.js +3 -7
  118. package/number/getNumber.js +3 -7
  119. package/number/getPercentIncrease.js +4 -8
  120. package/number/getSafeDivide.js +6 -10
  121. package/number/index.js +6 -15
  122. package/object/index.js +1 -5
  123. package/object/replaceKeys.js +3 -7
  124. package/onePassword/OnePasswordNamespace.js +36 -76
  125. package/onePassword/server.js +3 -7
  126. package/openAi/OpenAiNamespace.js +32 -39
  127. package/openAi/server.js +6 -10
  128. package/package.json +7 -1
  129. package/prisma/PrismaNamespace.js +53 -93
  130. package/prisma/getDecimal.js +5 -12
  131. package/prisma/server.js +4 -9
  132. package/snapchat/SnapchatNamespace.js +20 -27
  133. package/snapchat/server.js +6 -10
  134. package/sorting/byNumberAscending.js +1 -5
  135. package/sorting/byNumberDescending.js +1 -5
  136. package/sorting/byStringAscending.js +1 -5
  137. package/sorting/byStringDescending.js +1 -5
  138. package/sorting/index.js +4 -11
  139. package/stream/server.js +1 -5
  140. package/stream/sort.js +1 -5
  141. package/string/getCapitalised.js +3 -7
  142. package/string/getClean.js +17 -21
  143. package/string/getFolder.js +3 -10
  144. package/string/getProperCase.js +4 -8
  145. package/string/getString.js +8 -15
  146. package/string/getStringFromStream.js +1 -5
  147. package/string/getUnescaped.js +3 -10
  148. package/string/getWithoutAccents.js +1 -5
  149. package/string/getWithoutHtmlTags.js +1 -5
  150. package/string/getWithoutPunctuation.js +1 -5
  151. package/string/getWithoutUnderscores.js +1 -5
  152. package/string/getWithoutWhitespaces.js +1 -5
  153. package/string/index.js +12 -27
  154. package/string/reservedWords.js +5 -9
  155. package/swr/index.js +9 -18
  156. package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
  157. package/upTimeRobot/server.js +11 -15
  158. package/url/index.js +12 -23
  159. package/url/server.js +1 -5
  160. package/url/writeUrlContents.js +6 -46
  161. package/util/defaultTo.js +5 -12
  162. package/util/getBrotliCompressed.js +3 -10
  163. package/util/getBrotliDecompressed.js +3 -10
  164. package/util/getClean.js +5 -9
  165. package/util/getError.js +1 -5
  166. package/util/getGzipCompressed.js +3 -10
  167. package/util/getGzipDecompressed.js +3 -10
  168. package/util/getWithoutHash.js +1 -5
  169. package/util/getWithoutParameter.js +1 -5
  170. package/util/index.js +7 -17
  171. package/util/isUndefined.js +3 -7
  172. package/util/promiseChunks.js +6 -10
  173. package/util/server.js +4 -11
  174. package/util/sleep.js +1 -5
  175. package/webWorker/index.js +1 -4
  176. package/xml/getXml.js +3 -7
package/sorting/index.js CHANGED
@@ -1,11 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byStringDescending = exports.byStringAscending = exports.byNumberDescending = exports.byNumberAscending = void 0;
4
- var byNumberAscending_1 = require("./byNumberAscending");
5
- Object.defineProperty(exports, "byNumberAscending", { enumerable: true, get: function () { return byNumberAscending_1.byNumberAscending; } });
6
- var byNumberDescending_1 = require("./byNumberDescending");
7
- Object.defineProperty(exports, "byNumberDescending", { enumerable: true, get: function () { return byNumberDescending_1.byNumberDescending; } });
8
- var byStringAscending_1 = require("./byStringAscending");
9
- Object.defineProperty(exports, "byStringAscending", { enumerable: true, get: function () { return byStringAscending_1.byStringAscending; } });
10
- var byStringDescending_1 = require("./byStringDescending");
11
- Object.defineProperty(exports, "byStringDescending", { enumerable: true, get: function () { return byStringDescending_1.byStringDescending; } });
1
+ export { byNumberAscending } from "./byNumberAscending";
2
+ export { byNumberDescending } from "./byNumberDescending";
3
+ export { byStringAscending } from "./byStringAscending";
4
+ export { byStringDescending } from "./byStringDescending";
package/stream/server.js CHANGED
@@ -1,5 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sort = void 0;
4
- var sort_1 = require("./sort");
5
- Object.defineProperty(exports, "sort", { enumerable: true, get: function () { return sort_1.sort; } });
1
+ export { sort } from "./sort";
package/stream/sort.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sort = void 0;
4
1
  const Transform = require("stream").Transform;
5
2
  const batch = 15000;
6
3
  /**
@@ -44,8 +41,7 @@ class SortStreamer extends Transform {
44
41
  this.push(null);
45
42
  }
46
43
  }
47
- const sort = (comp, options) => {
44
+ export const sort = (comp, options) => {
48
45
  options = options || { objectMode: true };
49
46
  return new SortStreamer(options, comp);
50
47
  };
51
- exports.sort = sort;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCapitalised = void 0;
4
- const reservedWords_1 = require("./reservedWords");
1
+ import { isReservedWord } from "./reservedWords";
5
2
  /**
6
3
  * Convert a string into Capitalised Text.
7
4
  * https://stackoverflow.com/a/196991/2664955
8
5
  */
9
- const getCapitalised = (input, split = "_") => {
6
+ export const getCapitalised = (input, split = "_") => {
10
7
  const regex = new RegExp(split || "_", "g");
11
8
  return input
12
9
  .replace(regex, " ")
13
10
  .replace(/\w\S*/g, function (txt) {
14
11
  // Check if individual word is reserved
15
- const reservedWord = (0, reservedWords_1.isReservedWord)(txt);
12
+ const reservedWord = isReservedWord(txt);
16
13
  if (reservedWord) {
17
14
  return reservedWord;
18
15
  }
@@ -22,4 +19,3 @@ const getCapitalised = (input, split = "_") => {
22
19
  .toLowerCase();
23
20
  });
24
21
  };
25
- exports.getCapitalised = getCapitalised;
@@ -1,42 +1,39 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClean = void 0;
4
- const getString_1 = require("./getString");
5
- const getWithoutHtmlTags_1 = require("./getWithoutHtmlTags");
6
- const getWithoutAccents_1 = require("./getWithoutAccents");
7
- const getProperCase_1 = require("./getProperCase");
8
- const getWithoutWhitespaces_1 = require("./getWithoutWhitespaces");
9
- const getWithoutPunctuation_1 = require("./getWithoutPunctuation");
10
- const getWithoutUnderscores_1 = require("./getWithoutUnderscores");
11
- const getUnescaped_1 = require("./getUnescaped");
1
+ import { getString } from "./getString";
2
+ import { getWithoutHtmlTags } from "./getWithoutHtmlTags";
3
+ import { getWithoutAccents } from "./getWithoutAccents";
4
+ import { getProperCase } from "./getProperCase";
5
+ import { getWithoutWhitespaces } from "./getWithoutWhitespaces";
6
+ import { getWithoutPunctuation } from "./getWithoutPunctuation";
7
+ import { getWithoutUnderscores } from "./getWithoutUnderscores";
8
+ import { getUnescaped } from "./getUnescaped";
12
9
  /**
13
10
  * Shorthand function to get a clean version of a string.
14
11
  */
15
- const getClean = (props) => {
16
- let response = (0, getString_1.getString)(props.input);
12
+ export const getClean = (props) => {
13
+ let response = getString(props.input);
17
14
  if (props.decoded) {
18
- response = (0, getUnescaped_1.getUnescaped)(response);
15
+ response = getUnescaped(response);
19
16
  }
20
17
  if (props.accents) {
21
- response = (0, getWithoutAccents_1.getWithoutAccents)(response);
18
+ response = getWithoutAccents(response);
22
19
  }
23
20
  if (props.htmlTags) {
24
- response = (0, getWithoutHtmlTags_1.getWithoutHtmlTags)(response);
21
+ response = getWithoutHtmlTags(response);
25
22
  }
26
23
  if (props.underscores) {
27
- response = (0, getWithoutUnderscores_1.getWithoutUnderscores)(response);
24
+ response = getWithoutUnderscores(response);
28
25
  }
29
26
  if (props.punctuation) {
30
- response = (0, getWithoutPunctuation_1.getWithoutPunctuation)(response);
27
+ response = getWithoutPunctuation(response);
31
28
  }
32
29
  if (props.whitespace) {
33
- response = (0, getWithoutWhitespaces_1.getWithoutWhitespaces)(response);
30
+ response = getWithoutWhitespaces(response);
34
31
  }
35
32
  if (props.lowercase) {
36
33
  response = response.toLowerCase();
37
34
  }
38
35
  if (props.propercase) {
39
- response = (0, getProperCase_1.getProperCase)({
36
+ response = getProperCase({
40
37
  input: response,
41
38
  });
42
39
  }
@@ -48,4 +45,3 @@ const getClean = (props) => {
48
45
  }
49
46
  return response;
50
47
  };
51
- exports.getClean = getClean;
@@ -1,15 +1,8 @@
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.getFolder = void 0;
7
- const trim_1 = __importDefault(require("lodash/trim"));
1
+ import trim from "lodash/trim";
8
2
  /**
9
3
  * Take an input that may have a / before or after the input and return just the folder.
10
4
  */
11
- const getFolder = (input) => {
12
- return (0, trim_1.default)(input, "/")
5
+ export const getFolder = (input) => {
6
+ return trim(input, "/")
13
7
  .trim();
14
8
  };
15
- exports.getFolder = getFolder;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProperCase = void 0;
4
- const reservedWords_1 = require("./reservedWords");
1
+ import { isReservedWord, reservedWords } from "./reservedWords";
5
2
  /**
6
3
  * Return a string "With Proper Casing".
7
4
  */
8
- const getProperCase = (props) => {
5
+ export const getProperCase = (props) => {
9
6
  const cleanInput = props.input.toString()
10
7
  .trim();
11
8
  // Don't process if the entire input is a reserved word
12
- if (reservedWords_1.reservedWords.includes(cleanInput.toUpperCase())) {
9
+ if (reservedWords.includes(cleanInput.toUpperCase())) {
13
10
  return cleanInput;
14
11
  }
15
12
  // Build the split pattern - always include spaces
@@ -33,7 +30,7 @@ const getProperCase = (props) => {
33
30
  .filter(word => word.length > 0) // Remove empty strings
34
31
  .map(word => {
35
32
  // Check if individual word is reserved
36
- const reservedWord = (0, reservedWords_1.isReservedWord)(word);
33
+ const reservedWord = isReservedWord(word);
37
34
  if (reservedWord) {
38
35
  return reservedWord;
39
36
  }
@@ -44,4 +41,3 @@ const getProperCase = (props) => {
44
41
  });
45
42
  return words.join(' ');
46
43
  };
47
- exports.getProperCase = getProperCase;
@@ -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.getString = void 0;
7
- const isArray_1 = __importDefault(require("lodash/isArray"));
8
- const isDate_1 = __importDefault(require("lodash/isDate"));
9
- const isObject_1 = __importDefault(require("lodash/isObject"));
10
- const date_1 = require("../date");
1
+ import isArray from "lodash/isArray";
2
+ import isDate from "lodash/isDate";
3
+ import isObject from "lodash/isObject";
4
+ import { getYmdString } from "../date";
11
5
  /**
12
6
  * Convert into string.
13
7
  */
14
- const getString = (input) => {
8
+ export const getString = (input) => {
15
9
  let string = "";
16
10
  // Already a string
17
11
  if ("string" === typeof input) {
@@ -22,13 +16,12 @@ const getString = (input) => {
22
16
  string = input.toString();
23
17
  }
24
18
  // Object or array to JSON
25
- else if ((0, isObject_1.default)(input) || (0, isArray_1.default)(input)) {
19
+ else if (isObject(input) || isArray(input)) {
26
20
  string = JSON.stringify(input);
27
21
  }
28
22
  // Date
29
- else if ((0, isDate_1.default)(input)) {
30
- string = (0, date_1.getYmdString)(input);
23
+ else if (isDate(input)) {
24
+ string = getYmdString(input);
31
25
  }
32
26
  return string;
33
27
  };
34
- exports.getString = getString;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStringFromStream = void 0;
4
1
  /**
5
2
  * Converts a stream into a string.
6
3
  * https://stackoverflow.com/a/49428486
7
4
  */
8
- const getStringFromStream = (stream) => {
5
+ export const getStringFromStream = (stream) => {
9
6
  const chunks = [];
10
7
  return new Promise((resolve, reject) => {
11
8
  stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
@@ -14,4 +11,3 @@ const getStringFromStream = (stream) => {
14
11
  .toString("utf8")));
15
12
  });
16
13
  };
17
- exports.getStringFromStream = getStringFromStream;
@@ -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
  };