@8ms/helpers 2.3.26 → 2.3.28

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 (148) hide show
  1. package/dist/_class/index.d.mts +2 -0
  2. package/dist/_class/index.mjs +61 -0
  3. package/dist/adverity/index.d.mts +2 -0
  4. package/dist/adverity/index.mjs +64 -0
  5. package/dist/adverity/server/index.d.mts +18 -0
  6. package/dist/adverity/server/index.mjs +25 -0
  7. package/dist/api/index.d.mts +2 -0
  8. package/dist/api/index.mjs +3 -0
  9. package/dist/api-DGKJDAfb.mjs +139 -0
  10. package/dist/array/index.d.mts +11 -0
  11. package/dist/array/index.mjs +12 -0
  12. package/dist/atInternet/index.d.mts +20 -0
  13. package/dist/atInternet/index.mjs +18 -0
  14. package/dist/aws/ec2/server/index.d.mts +18 -0
  15. package/dist/aws/ec2/server/index.mjs +48 -0
  16. package/dist/aws/ecs/server/index.d.mts +59 -0
  17. package/dist/aws/ecs/server/index.mjs +113 -0
  18. package/dist/aws/glue/server/index.d.mts +19 -0
  19. package/dist/aws/glue/server/index.mjs +36 -0
  20. package/dist/aws/lambda/server/index.d.mts +28 -0
  21. package/dist/aws/lambda/server/index.mjs +57 -0
  22. package/dist/aws/s3/server/index.d.mts +124 -0
  23. package/dist/aws/s3/server/index.mjs +360 -0
  24. package/dist/aws/server/index.d.mts +2 -0
  25. package/dist/aws/server/index.mjs +3 -0
  26. package/dist/aws/ses/server/index.d.mts +105 -0
  27. package/dist/aws/ses/server/index.mjs +268 -0
  28. package/dist/aws/sqs/server/index.d.mts +41 -0
  29. package/dist/aws/sqs/server/index.mjs +56 -0
  30. package/dist/aws/ssm/server/index.d.mts +18 -0
  31. package/dist/aws/ssm/server/index.mjs +47 -0
  32. package/dist/axios/index.d.mts +22 -0
  33. package/dist/axios/index.mjs +50 -0
  34. package/dist/boolean/index.d.mts +7 -0
  35. package/dist/boolean/index.mjs +13 -0
  36. package/dist/brightData/serpApi/server/index.d.mts +93 -0
  37. package/dist/brightData/serpApi/server/index.mjs +229 -0
  38. package/dist/brightData/server/index.d.mts +2 -0
  39. package/dist/brightData/server/index.mjs +18 -0
  40. package/dist/brightData/webScraperIde/server/index.d.mts +19 -0
  41. package/dist/brightData/webScraperIde/server/index.mjs +50 -0
  42. package/dist/cache/server/index.d.mts +10 -0
  43. package/dist/cache/server/index.mjs +31 -0
  44. package/dist/chunk-DDarj8oW.mjs +7 -0
  45. package/dist/crud/index.d.mts +10 -0
  46. package/dist/crud/index.mjs +10 -0
  47. package/dist/crypto/index.d.mts +25 -0
  48. package/dist/crypto/index.mjs +57 -0
  49. package/dist/date/index.d.mts +2 -0
  50. package/dist/date/index.mjs +471 -0
  51. package/dist/drizzle/server/index.d.mts +22 -0
  52. package/dist/drizzle/server/index.mjs +69 -0
  53. package/dist/environment/index.d.mts +37 -0
  54. package/dist/environment/index.mjs +60 -0
  55. package/dist/eskimi/index.d.mts +52 -0
  56. package/dist/eskimi/index.mjs +90 -0
  57. package/dist/eskimi/server/index.d.mts +25 -0
  58. package/dist/eskimi/server/index.mjs +50 -0
  59. package/dist/file/index.d.mts +7 -0
  60. package/dist/file/index.mjs +20 -0
  61. package/dist/file/server/index.d.mts +8 -0
  62. package/dist/file/server/index.mjs +16 -0
  63. package/dist/geo/index.d.mts +26 -0
  64. package/dist/geo/index.mjs +1591 -0
  65. package/dist/getDecimal-CafxtLhH.mjs +40 -0
  66. package/dist/googleAds/keywordPlanner/server/index.d.mts +45 -0
  67. package/dist/googleAds/keywordPlanner/server/index.mjs +51 -0
  68. package/dist/googleAds/server/index.d.mts +27 -0
  69. package/dist/googleAds/server/index.mjs +48 -0
  70. package/dist/googleCloud/bigquery/server/index.d.mts +82 -0
  71. package/dist/googleCloud/bigquery/server/index.mjs +133 -0
  72. package/dist/googleCloud/server/index.d.mts +2 -0
  73. package/dist/googleCloud/server/index.mjs +24 -0
  74. package/dist/googleCloud/sheets/server/index.d.mts +22 -0
  75. package/dist/googleCloud/sheets/server/index.mjs +31 -0
  76. package/dist/googleCloud/storage/server/index.d.mts +31 -0
  77. package/dist/googleCloud/storage/server/index.mjs +79 -0
  78. package/dist/googlePageSpeed/server/index.d.mts +34 -0
  79. package/dist/googlePageSpeed/server/index.mjs +53 -0
  80. package/dist/googleSearchIncidents/server/index.d.mts +73 -0
  81. package/dist/googleSearchIncidents/server/index.mjs +55 -0
  82. package/dist/greenDomain/server/index.d.mts +25 -0
  83. package/dist/greenDomain/server/index.mjs +31 -0
  84. package/dist/index-1fBbJGQz.d.mts +246 -0
  85. package/dist/index-BHuvb_7y.d.mts +116 -0
  86. package/dist/index-BfyGIdDD.d.mts +18 -0
  87. package/dist/index-CqTOMR8f.d.mts +17 -0
  88. package/dist/index-DW9yJLtI.d.mts +67 -0
  89. package/dist/index-DmCSxHCc.d.mts +32 -0
  90. package/dist/index-DwB8X1lz.d.mts +32 -0
  91. package/dist/inngest/index.d.mts +10 -0
  92. package/dist/inngest/index.mjs +10 -0
  93. package/dist/json/index.d.mts +7 -0
  94. package/dist/json/index.mjs +27 -0
  95. package/dist/littleWarden/server/index.d.mts +56 -0
  96. package/dist/littleWarden/server/index.mjs +79 -0
  97. package/dist/lodash/index.d.mts +45 -0
  98. package/dist/lodash/index.mjs +177 -0
  99. package/dist/lumar/api/server/index.d.mts +66 -0
  100. package/dist/lumar/api/server/index.mjs +111 -0
  101. package/dist/lumar/graphql/server/index.d.mts +308 -0
  102. package/dist/lumar/graphql/server/index.mjs +172 -0
  103. package/dist/myTarget/server/index.d.mts +9 -0
  104. package/dist/myTarget/server/index.mjs +16 -0
  105. package/dist/nextAuth/index.d.mts +12 -0
  106. package/dist/nextAuth/index.mjs +15 -0
  107. package/dist/nextJs/client/index.d.mts +10 -0
  108. package/dist/nextJs/client/index.mjs +12 -0
  109. package/dist/nextJs/index.d.mts +19 -0
  110. package/dist/nextJs/index.mjs +12 -0
  111. package/dist/number/index.d.mts +54 -0
  112. package/dist/number/index.mjs +75 -0
  113. package/dist/object/index.d.mts +8 -0
  114. package/dist/object/index.mjs +22 -0
  115. package/dist/onePassword/server/index.d.mts +24 -0
  116. package/dist/onePassword/server/index.mjs +50 -0
  117. package/dist/openAi/server/index.d.mts +20 -0
  118. package/dist/openAi/server/index.mjs +46 -0
  119. package/dist/prisma/index.d.mts +7 -0
  120. package/dist/prisma/index.mjs +15 -0
  121. package/dist/prisma/server/index.d.mts +31 -0
  122. package/dist/prisma/server/index.mjs +64 -0
  123. package/dist/server-Bwy4JI8Z.mjs +33 -0
  124. package/dist/snapchat/server/index.d.mts +25 -0
  125. package/dist/snapchat/server/index.mjs +39 -0
  126. package/dist/sorting/index.d.mts +25 -0
  127. package/dist/sorting/index.mjs +50 -0
  128. package/dist/stream/server/index.d.mts +15 -0
  129. package/dist/stream/server/index.mjs +48 -0
  130. package/dist/string/index.d.mts +107 -0
  131. package/dist/string/index.mjs +187 -0
  132. package/dist/swr/client/index.d.mts +46 -0
  133. package/dist/swr/client/index.mjs +40 -0
  134. package/dist/upTimeRobot/server/index.d.mts +72 -0
  135. package/dist/upTimeRobot/server/index.mjs +82 -0
  136. package/dist/url/index.d.mts +29 -0
  137. package/dist/url/index.mjs +52 -0
  138. package/dist/url/server/index.d.mts +9 -0
  139. package/dist/url/server/index.mjs +35 -0
  140. package/dist/util/index.d.mts +50 -0
  141. package/dist/util/index.mjs +107 -0
  142. package/dist/util/server/index.d.mts +27 -0
  143. package/dist/util/server/index.mjs +61 -0
  144. package/dist/webWorker/index.d.mts +11 -0
  145. package/dist/webWorker/index.mjs +11 -0
  146. package/dist/xml/server/index.d.mts +4 -0
  147. package/dist/xml/server/index.mjs +17 -0
  148. package/package.json +189 -118
@@ -0,0 +1,35 @@
1
+ import { createDirectory } from "../../file/server/index.mjs";
2
+ import axios from "axios";
3
+
4
+ //#region src/url/server/writeUrlContents.ts
5
+ /**
6
+ * Downloads a given URL's contents to a local file.
7
+ *
8
+ * Requires fs-extra
9
+ */
10
+ const writeUrlContents = async (filePath, url) => {
11
+ const fs = await import("fs-extra");
12
+ await createDirectory(filePath);
13
+ const writer = fs.createWriteStream(filePath);
14
+ await axios({
15
+ method: "get",
16
+ url,
17
+ responseType: "stream"
18
+ }).then((response) => {
19
+ return new Promise(async (resolve, reject) => {
20
+ response.data.pipe(writer);
21
+ let error = null;
22
+ writer.on("error", (err) => {
23
+ error = err;
24
+ writer.close();
25
+ reject(err);
26
+ });
27
+ writer.on("close", () => {
28
+ if (!error) resolve(true);
29
+ });
30
+ });
31
+ });
32
+ };
33
+
34
+ //#endregion
35
+ export { writeUrlContents };
@@ -0,0 +1,50 @@
1
+ //#region src/util/defaultTo.d.ts
2
+ /**
3
+ * Function to default to a value, whilst filtering through an instance
4
+ */
5
+ declare const defaultTo: (instance: any, keys: any | any[], defaultValue?: any) => any;
6
+ //#endregion
7
+ //#region src/util/getClean.d.ts
8
+ type GetClean = {
9
+ hash?: boolean;
10
+ input: any;
11
+ lowercase?: boolean;
12
+ parameter?: boolean;
13
+ };
14
+ /**
15
+ * Return a clean URL with a few options.
16
+ */
17
+ declare const getClean: (props: GetClean) => string;
18
+ //#endregion
19
+ //#region src/util/getError.d.ts
20
+ declare const getError: (error: any) => string;
21
+ //#endregion
22
+ //#region src/util/getWithoutHash.d.ts
23
+ /**
24
+ * Get a URL without the parameter query.
25
+ */
26
+ declare const getWithoutHash: (input: string) => string;
27
+ //#endregion
28
+ //#region src/util/getWithoutParameter.d.ts
29
+ /**
30
+ * Get a URL without the parameter query.
31
+ */
32
+ declare const getWithoutParameter: (input: string) => string;
33
+ //#endregion
34
+ //#region src/util/isUndefined.d.ts
35
+ /**
36
+ * Check to see if a value is undefined.
37
+ */
38
+ declare const isUndefined: (instance: any, keys: any | any[]) => boolean;
39
+ //#endregion
40
+ //#region src/util/promiseChunks.d.ts
41
+ /**
42
+ * Chunk a queue of promises into controlled chunks to prevent overloading.
43
+ * https://stackoverflow.com/a/53964407
44
+ */
45
+ declare const promiseChunks: (promises: Promise<any>[], size: number, sleepSeconds?: number, callbackFunction?: Function) => Promise<unknown[]>;
46
+ //#endregion
47
+ //#region src/util/sleep.d.ts
48
+ declare const sleep: (seconds: number) => Promise<void>;
49
+ //#endregion
50
+ export { defaultTo, getClean, getError, getWithoutHash, getWithoutParameter, isUndefined, promiseChunks, sleep };
@@ -0,0 +1,107 @@
1
+ import { chunk, flatten, isObject } from "../lodash/index.mjs";
2
+ import { getArray } from "../array/index.mjs";
3
+
4
+ //#region src/util/defaultTo.ts
5
+ /**
6
+ * Function to default to a value, whilst filtering through an instance
7
+ */
8
+ const defaultTo = (instance, keys, defaultValue = null) => {
9
+ const keysArray = getArray(keys);
10
+ let found = true;
11
+ let pointer = instance;
12
+ if ("undefined" === typeof instance || null === pointer) found = false;
13
+ else keysArray.forEach((key) => {
14
+ if (found) if (isObject(pointer)) if (void 0 === pointer[key] || null === pointer[key]) found = false;
15
+ else pointer = pointer[key];
16
+ else found = false;
17
+ });
18
+ return found ? pointer : defaultValue;
19
+ };
20
+
21
+ //#endregion
22
+ //#region src/util/getWithoutParameter.ts
23
+ /**
24
+ * Get a URL without the parameter query.
25
+ */
26
+ const getWithoutParameter = (input) => {
27
+ let response = input;
28
+ if (-1 !== response.indexOf("?")) {
29
+ const split = response.split("?");
30
+ if (split.length > 1) response = split[0];
31
+ }
32
+ return response;
33
+ };
34
+
35
+ //#endregion
36
+ //#region src/util/getWithoutHash.ts
37
+ /**
38
+ * Get a URL without the parameter query.
39
+ */
40
+ const getWithoutHash = (input) => {
41
+ let response = input;
42
+ if (-1 !== response.indexOf("#")) {
43
+ const split = response.split("#");
44
+ if (split.length > 1) response = split[0];
45
+ }
46
+ return response;
47
+ };
48
+
49
+ //#endregion
50
+ //#region src/util/getClean.ts
51
+ /**
52
+ * Return a clean URL with a few options.
53
+ */
54
+ const getClean = (props) => {
55
+ let response = props.input.toString().trim();
56
+ if (props.parameter) response = getWithoutParameter(response);
57
+ if (props.hash) response = getWithoutHash(response);
58
+ if (props.lowercase) response = response.toLowerCase();
59
+ return response;
60
+ };
61
+
62
+ //#endregion
63
+ //#region src/util/getError.ts
64
+ const getError = (error) => {
65
+ let response = "";
66
+ if (typeof error === "string") response = error.toUpperCase();
67
+ else if (error instanceof Error) response = error.message;
68
+ return response;
69
+ };
70
+
71
+ //#endregion
72
+ //#region src/util/isUndefined.ts
73
+ const undefinedValue = "__!!UNDEFINED!!__";
74
+ /**
75
+ * Check to see if a value is undefined.
76
+ */
77
+ const isUndefined = (instance, keys) => {
78
+ return undefinedValue === defaultTo(instance, keys, undefinedValue);
79
+ };
80
+
81
+ //#endregion
82
+ //#region src/util/sleep.ts
83
+ const sleep = (seconds) => {
84
+ return new Promise((resolve) => setTimeout(resolve, seconds * 1e3));
85
+ };
86
+
87
+ //#endregion
88
+ //#region src/util/promiseChunks.ts
89
+ /**
90
+ * Chunk a queue of promises into controlled chunks to prevent overloading.
91
+ * https://stackoverflow.com/a/53964407
92
+ */
93
+ const promiseChunks = async (promises, size, sleepSeconds = 0, callbackFunction) => {
94
+ const batches = chunk(promises, size);
95
+ let results = [];
96
+ while (batches.length) {
97
+ const batch = batches.shift();
98
+ const result = await Promise.all(batch);
99
+ results.push(result);
100
+ if (callbackFunction) await callbackFunction(result);
101
+ await sleep(sleepSeconds);
102
+ }
103
+ return flatten(results);
104
+ };
105
+
106
+ //#endregion
107
+ export { defaultTo, getClean, getError, getWithoutHash, getWithoutParameter, isUndefined, promiseChunks, sleep };
@@ -0,0 +1,27 @@
1
+ import { BrotliOptions, ZlibOptions } from "zlib";
2
+
3
+ //#region src/util/server/getBrotliCompressed.d.ts
4
+ /**
5
+ * Compress a given input using Brotli.
6
+ */
7
+ declare const getBrotliCompressed: (input: any, options?: BrotliOptions) => Promise<unknown>;
8
+ //#endregion
9
+ //#region src/util/server/getBrotliDecompressed.d.ts
10
+ /**
11
+ * Decompress a given Brotli input into a string.
12
+ */
13
+ declare const getBrotliDecompressed: (input: any, options?: BrotliOptions) => Promise<unknown>;
14
+ //#endregion
15
+ //#region src/util/server/getGzipCompressed.d.ts
16
+ /**
17
+ * Compress a given input using Gzip.
18
+ */
19
+ declare const getGzipCompressed: (input: any, options?: ZlibOptions) => Promise<string>;
20
+ //#endregion
21
+ //#region src/util/server/getGzipDecompressed.d.ts
22
+ /**
23
+ * Decompress a given Gzip input into a string.
24
+ */
25
+ declare const getGzipDecompressed: (input: any, options?: ZlibOptions) => Promise<unknown>;
26
+ //#endregion
27
+ export { getBrotliCompressed, getBrotliDecompressed, getGzipCompressed, getGzipDecompressed };
@@ -0,0 +1,61 @@
1
+ import zlib from "zlib";
2
+
3
+ //#region src/util/server/getBrotliCompressed.ts
4
+ /**
5
+ * Compress a given input using Brotli.
6
+ */
7
+ const getBrotliCompressed = async (input, options = {}) => {
8
+ return new Promise(async (resolve, reject) => {
9
+ zlib.brotliCompress(input || "", options || {}, (err, data) => {
10
+ if (err) reject(`Error compressing - ${err.message}`);
11
+ else resolve(data.toString("base64"));
12
+ });
13
+ });
14
+ };
15
+
16
+ //#endregion
17
+ //#region src/util/server/getBrotliDecompressed.ts
18
+ /**
19
+ * Decompress a given Brotli input into a string.
20
+ */
21
+ const getBrotliDecompressed = async (input, options = {}) => {
22
+ return new Promise(async (resolve, reject) => {
23
+ const compressedData = Buffer.from(input || "", "base64");
24
+ zlib.brotliDecompress(compressedData, options || {}, (err, data) => {
25
+ if (err) reject(`Error decompressing - ${err.message}`);
26
+ else resolve(data.toString("utf8"));
27
+ });
28
+ });
29
+ };
30
+
31
+ //#endregion
32
+ //#region src/util/server/getGzipCompressed.ts
33
+ /**
34
+ * Compress a given input using Gzip.
35
+ */
36
+ const getGzipCompressed = async (input, options = {}) => {
37
+ return new Promise(async (resolve, reject) => {
38
+ zlib.gzip(input || "", options || {}, (err, data) => {
39
+ if (err) reject(`Error compressing - ${err.message}`);
40
+ else resolve(data.toString("base64"));
41
+ });
42
+ });
43
+ };
44
+
45
+ //#endregion
46
+ //#region src/util/server/getGzipDecompressed.ts
47
+ /**
48
+ * Decompress a given Gzip input into a string.
49
+ */
50
+ const getGzipDecompressed = async (input, options = {}) => {
51
+ return new Promise(async (resolve, reject) => {
52
+ const compressedData = Buffer.from(input || "", "base64");
53
+ zlib.gunzip(compressedData, options || {}, (err, data) => {
54
+ if (err) reject(`Error decompressing - ${err.message}`);
55
+ else resolve(data.toString("utf8"));
56
+ });
57
+ });
58
+ };
59
+
60
+ //#endregion
61
+ export { getBrotliCompressed, getBrotliDecompressed, getGzipCompressed, getGzipDecompressed };
@@ -0,0 +1,11 @@
1
+ //#region src/webWorker/webWorker.d.ts
2
+ declare const WebWorkerState: {
3
+ IDLE: string;
4
+ CANCELLED: string;
5
+ PENDING: string;
6
+ ERROR: string;
7
+ SUCCESS: string;
8
+ };
9
+ type WebWorkerState = typeof WebWorkerState[keyof typeof WebWorkerState];
10
+ //#endregion
11
+ export { WebWorkerState };
@@ -0,0 +1,11 @@
1
+ //#region src/webWorker/webWorker.ts
2
+ const WebWorkerState = {
3
+ IDLE: "IDLE",
4
+ CANCELLED: "CANCELLED",
5
+ PENDING: "PENDING",
6
+ ERROR: "ERROR",
7
+ SUCCESS: "SUCCESS"
8
+ };
9
+
10
+ //#endregion
11
+ export { WebWorkerState };
@@ -0,0 +1,4 @@
1
+ //#region src/xml/server/getXml.d.ts
2
+ declare const getXml: (url: string) => Promise<string>;
3
+ //#endregion
4
+ export { getXml };
@@ -0,0 +1,17 @@
1
+ import "../../api-DGKJDAfb.mjs";
2
+ import { get } from "../../axios/index.mjs";
3
+
4
+ //#region src/xml/server/getXml.ts
5
+ const getXml = async (url) => {
6
+ let response = "";
7
+ const apiResponse = await get(url);
8
+ if (apiResponse.isSuccess()) {
9
+ response = apiResponse.getBody().toString();
10
+ response = response.trim();
11
+ response = response.replace(/[ ]{2}|\r\n|\n|\r|\t/gm, "");
12
+ }
13
+ return response;
14
+ };
15
+
16
+ //#endregion
17
+ export { getXml };