@8ms/helpers 2.3.26 → 2.3.27

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 +176 -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,93 @@
1
+ import { f as ApiResponseClass } from "../../../index-DW9yJLtI.mjs";
2
+ import { t as Auth } from "../../../index-BfyGIdDD.mjs";
3
+
4
+ //#region src/brightData/serpApi/server/brightDataSerpApi.d.ts
5
+ declare const brightDataSerpApiType: {
6
+ readonly GOOGLE_FLIGHTS: "GOOGLE_FLIGHTS";
7
+ readonly GOOGLE_HOTELS: "GOOGLE_HOTELS";
8
+ readonly GOOGLE_LENS: "GOOGLE_LENS";
9
+ readonly GOOGLE_MAPS: "GOOGLE_MAPS";
10
+ readonly GOOGLE_REVIEWS: "GOOGLE_REVIEWS";
11
+ readonly GOOGLE_SEARCH: "GOOGLE_SEARCH";
12
+ readonly GOOGLE_TRENDS: "GOOGLE_TRENDS";
13
+ };
14
+ type BrightDataSerpApiType = typeof brightDataSerpApiType[keyof typeof brightDataSerpApiType];
15
+ //#endregion
16
+ //#region src/brightData/serpApi/server/buildGoogleSerpUrl.d.ts
17
+ type BuildGoogleSerpUrl = {
18
+ country?: string;
19
+ device?: "mobile" | "android" | "androidTablet" | "iphone" | "ipad";
20
+ language?: string;
21
+ geoLocation?: string;
22
+ hotel?: {
23
+ dates?: string;
24
+ occupancy?: number;
25
+ };
26
+ pagination?: {
27
+ offset?: number;
28
+ perPage?: number;
29
+ };
30
+ searchType?: "images" | "jobs" | "news" | "shopping" | "video";
31
+ query: string;
32
+ googleDomain: string;
33
+ output?: "html" | "json";
34
+ returnType: "url" | "json";
35
+ };
36
+ /**
37
+ * Construct the Google SERP url using Bright Data's API:
38
+ * https://brightdata.com/cp/serp_api/api/google/search?id=c_2cef083f
39
+ *
40
+ * For geolocation use value from:
41
+ * https://developers.google.com/google-ads/api/data/geotargets
42
+ */
43
+ declare const buildGoogleSerpUrl: (props: BuildGoogleSerpUrl) => string | {
44
+ query: {
45
+ q: string;
46
+ };
47
+ };
48
+ //#endregion
49
+ //#region src/brightData/serpApi/server/buildGoogleTrendsUrl.d.ts
50
+ type BuildGoogleTrendsUrl = {
51
+ country?: string;
52
+ language?: string;
53
+ category?: string;
54
+ date?: string;
55
+ searchType?: "images" | "news" | "shopping" | "youtube";
56
+ query: string;
57
+ returnType: "url" | "json";
58
+ };
59
+ /**
60
+ * Construct the Google Trends url using Bright Data's API:
61
+ * https://brightdata.com/cp/serp_api/api/google/trends?id=c_2cef083f
62
+ *
63
+ * For category use value from:
64
+ * https://trends.google.com/trends/api/explore/pickers/category?lang=en-US&tz=240
65
+ */
66
+ declare const buildGoogleTrendsUrl: (props: BuildGoogleTrendsUrl) => string | {
67
+ query: {
68
+ q: string;
69
+ };
70
+ };
71
+ //#endregion
72
+ //#region src/brightData/serpApi/server/getAsyncResults.d.ts
73
+ /**
74
+ * Using the request ID from getAsyncRequestId fetch to see if the data is available.
75
+ * https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
76
+ */
77
+ declare const getAsyncResults: (auth: Auth, requestId: string) => Promise<ApiResponseClass<any, any>>;
78
+ //#endregion
79
+ //#region src/brightData/serpApi/server/getAsyncRequestId.d.ts
80
+ /**
81
+ * Make an async request to the SERP API using the Bright Data proxy.
82
+ * Returns a request ID used with getAsyncResults
83
+ * https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
84
+ */
85
+ declare const getAsyncRequestId: (auth: Auth, data: {}, type: BrightDataSerpApiType) => Promise<string>;
86
+ //#endregion
87
+ //#region src/brightData/serpApi/server/getRealtime.d.ts
88
+ /**
89
+ * Make a request to the SERP API using the Bright Data proxy
90
+ */
91
+ declare const getRealtime: (auth: Auth, url: string) => Promise<{}>;
92
+ //#endregion
93
+ export { BrightDataSerpApiType, brightDataSerpApiType, buildGoogleSerpUrl, buildGoogleTrendsUrl, getAsyncRequestId, getAsyncResults, getRealtime };
@@ -0,0 +1,229 @@
1
+ import { u as ApiResponseClass } from "../../../api-DGKJDAfb.mjs";
2
+ import { get, post } from "../../../axios/index.mjs";
3
+ import { getCustomerId, getZone } from "../../server/index.mjs";
4
+
5
+ //#region src/brightData/serpApi/server/brightDataSerpApi.ts
6
+ const brightDataSerpApiType = {
7
+ GOOGLE_FLIGHTS: "GOOGLE_FLIGHTS",
8
+ GOOGLE_HOTELS: "GOOGLE_HOTELS",
9
+ GOOGLE_LENS: "GOOGLE_LENS",
10
+ GOOGLE_MAPS: "GOOGLE_MAPS",
11
+ GOOGLE_REVIEWS: "GOOGLE_REVIEWS",
12
+ GOOGLE_SEARCH: "GOOGLE_SEARCH",
13
+ GOOGLE_TRENDS: "GOOGLE_TRENDS"
14
+ };
15
+
16
+ //#endregion
17
+ //#region src/brightData/serpApi/server/buildGoogleSerpUrl.ts
18
+ /**
19
+ * Construct the Google SERP url using Bright Data's API:
20
+ * https://brightdata.com/cp/serp_api/api/google/search?id=c_2cef083f
21
+ *
22
+ * For geolocation use value from:
23
+ * https://developers.google.com/google-ads/api/data/geotargets
24
+ */
25
+ const buildGoogleSerpUrl = (props) => {
26
+ let url = new URL(`https://www.${props.googleDomain}/search`);
27
+ let params = { query: { q: props.query } };
28
+ url.searchParams.append("q", props.query);
29
+ if (props?.country) {
30
+ params.query["gl"] = props.country;
31
+ url.searchParams.append("gl", props.country);
32
+ }
33
+ switch (props?.device) {
34
+ case "mobile":
35
+ params.query["brd_mobile"] = "1";
36
+ url.searchParams.append("brd_mobile", "1");
37
+ break;
38
+ case "android":
39
+ params.query["brd_mobile"] = "android";
40
+ url.searchParams.append("brd_mobile", "android");
41
+ break;
42
+ case "androidTablet":
43
+ params.query["brd_mobile"] = "android_tablet";
44
+ url.searchParams.append("brd_mobile", "android_tablet");
45
+ break;
46
+ case "ipad":
47
+ params.query["brd_mobile"] = "ipad";
48
+ url.searchParams.append("brd_mobile", "ipad");
49
+ break;
50
+ case "iphone":
51
+ params.query["brd_mobile"] = "ios";
52
+ url.searchParams.append("brd_mobile", "ios");
53
+ break;
54
+ }
55
+ if (props?.geoLocation) {
56
+ params.query["uule"] = props.geoLocation;
57
+ url.searchParams.append("uule", props.geoLocation);
58
+ }
59
+ if (props?.hotel) {
60
+ if (props.hotel?.dates) {
61
+ params.query["hotel_dates"] = props.hotel.dates.toString();
62
+ url.searchParams.append("hotel_dates", props.hotel.dates);
63
+ }
64
+ if (props.hotel?.occupancy) {
65
+ params.query["hotel_occupancy"] = props.hotel.occupancy.toString();
66
+ url.searchParams.append("hotel_occupancy", props.hotel.occupancy.toString());
67
+ }
68
+ }
69
+ if (props?.language) {
70
+ params.query["uule"] = props.language;
71
+ url.searchParams.append("hl", props.language);
72
+ }
73
+ switch (props?.searchType) {
74
+ case "images":
75
+ params.query["tbm"] = "isch";
76
+ url.searchParams.append("tbm", "isch");
77
+ break;
78
+ case "jobs":
79
+ params.query["ibp"] = "htl;jobs";
80
+ url.searchParams.append("ibp", "htl;jobs");
81
+ break;
82
+ case "news":
83
+ params.query["tbm"] = "nws";
84
+ url.searchParams.append("tbm", "nws");
85
+ break;
86
+ case "shopping":
87
+ params.query["tbm"] = "shop";
88
+ url.searchParams.append("tbm", "shop");
89
+ break;
90
+ case "video":
91
+ params.query["tbm"] = "vid";
92
+ url.searchParams.append("tbm", "vid");
93
+ break;
94
+ }
95
+ if (props?.pagination) {
96
+ if (props.pagination?.offset) {
97
+ params.query["start"] = props.pagination.offset.toString();
98
+ url.searchParams.append("start", props.pagination.offset.toString());
99
+ }
100
+ if (props.pagination?.perPage) {
101
+ params.query["num"] = props.pagination.offset.toString();
102
+ url.searchParams.append("num", props.pagination.perPage.toString());
103
+ }
104
+ }
105
+ if ("json" === props.output) {
106
+ params["brd_json"] = "1";
107
+ url.searchParams.append("brn_json", "1");
108
+ } else {
109
+ params["brd_json"] = "html";
110
+ url.searchParams.append("brn_json", "html");
111
+ }
112
+ if ("json" === props.returnType) return params;
113
+ return url.toString();
114
+ };
115
+
116
+ //#endregion
117
+ //#region src/brightData/serpApi/server/buildGoogleTrendsUrl.ts
118
+ /**
119
+ * Construct the Google Trends url using Bright Data's API:
120
+ * https://brightdata.com/cp/serp_api/api/google/trends?id=c_2cef083f
121
+ *
122
+ * For category use value from:
123
+ * https://trends.google.com/trends/api/explore/pickers/category?lang=en-US&tz=240
124
+ */
125
+ const buildGoogleTrendsUrl = (props) => {
126
+ let url = new URL(`http://trends.google.com/trends/explore`);
127
+ url.searchParams.append("q", props.query);
128
+ let params = { query: { q: props.query } };
129
+ if (props?.country) {
130
+ params.query["geo"] = props.country;
131
+ url.searchParams.append("geo", props.country);
132
+ }
133
+ if (props?.language) {
134
+ params.query["hl"] = props.language;
135
+ url.searchParams.append("hl", props.language);
136
+ }
137
+ if (props?.category) {
138
+ params.query["cat"] = props.category;
139
+ url.searchParams.append("cat", props.category);
140
+ }
141
+ if (props?.date) {
142
+ params.query["date"] = props.date;
143
+ url.searchParams.append("date", props.date);
144
+ }
145
+ switch (props?.searchType) {
146
+ case "images":
147
+ params.query["group"] = "images";
148
+ url.searchParams.append("gprop", "images");
149
+ break;
150
+ case "news":
151
+ params.query["group"] = "news";
152
+ url.searchParams.append("gprop", "news");
153
+ break;
154
+ case "shopping":
155
+ params.query["group"] = "froogle";
156
+ url.searchParams.append("gprop", "froogle");
157
+ break;
158
+ case "youtube":
159
+ params.query["group"] = "youtube";
160
+ url.searchParams.append("gprop", "youtube");
161
+ break;
162
+ }
163
+ if ("json" === props.returnType) return params;
164
+ return url.toString();
165
+ };
166
+
167
+ //#endregion
168
+ //#region src/brightData/serpApi/server/getAsyncResults.ts
169
+ /**
170
+ * Using the request ID from getAsyncRequestId fetch to see if the data is available.
171
+ * https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
172
+ */
173
+ const getAsyncResults = async (auth, requestId) => {
174
+ let response = new ApiResponseClass();
175
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
176
+ const requestResponse = await get(`https://api.brightdata.com/serp/get_result?customer=${getCustomerId(auth)}&zone=${getZone(auth)}&response_id=${requestId}`, { headers: { Authorization: `Bearer ${auth.apiKey}` } });
177
+ if (requestResponse.isSuccess()) if ("Request is pending" === requestResponse.getBody()) response.setToPending();
178
+ else response.setToSuccess(requestResponse.getBody());
179
+ else response.setToError(null, "Error in request");
180
+ return response;
181
+ };
182
+
183
+ //#endregion
184
+ //#region src/brightData/serpApi/server/getAsyncRequestId.ts
185
+ /**
186
+ * Make an async request to the SERP API using the Bright Data proxy.
187
+ * Returns a request ID used with getAsyncResults
188
+ * https://docs.brightdata.com/scraping-automation/serp-api/asynchronous-requests
189
+ */
190
+ const getAsyncRequestId = async (auth, data = {}, type) => {
191
+ let url = "";
192
+ let response = "";
193
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
194
+ const customerId = getCustomerId(auth);
195
+ const zone = getZone(auth);
196
+ switch (type) {
197
+ case brightDataSerpApiType.GOOGLE_TRENDS:
198
+ url = `https://api.brightdata.com/serp/trends?customer=${customerId}&zone=${zone}`;
199
+ break;
200
+ default: url = `https://api.brightdata.com/serp/req?customer=${customerId}&zone=${zone}`;
201
+ }
202
+ const requestResponse = await post(url, data, { headers: { Authorization: `Bearer ${auth.apiKey}` } });
203
+ if (requestResponse.isSuccess()) response = requestResponse.getBodyDefaultTo(["response_id"], "");
204
+ return response;
205
+ };
206
+
207
+ //#endregion
208
+ //#region src/brightData/serpApi/server/getRealtime.ts
209
+ /**
210
+ * Make a request to the SERP API using the Bright Data proxy
211
+ */
212
+ const getRealtime = async (auth, url) => {
213
+ let response = {};
214
+ process.env["NODE_TLS_REJECT_UNAUTHORIZED"] = "0";
215
+ const apiResponse = await get(url, { proxy: {
216
+ protocol: "http",
217
+ host: auth.host,
218
+ port: auth.port,
219
+ auth: {
220
+ username: auth.username,
221
+ password: auth.password
222
+ }
223
+ } });
224
+ if (apiResponse.isSuccess()) response = apiResponse.getBody();
225
+ return response;
226
+ };
227
+
228
+ //#endregion
229
+ export { brightDataSerpApiType, buildGoogleSerpUrl, buildGoogleTrendsUrl, getAsyncRequestId, getAsyncResults, getRealtime };
@@ -0,0 +1,2 @@
1
+ import { n as getCustomerId, r as getZone, t as Auth } from "../../index-BfyGIdDD.mjs";
2
+ export { Auth, getCustomerId, getZone };
@@ -0,0 +1,18 @@
1
+ //#region src/brightData/server/brightData.ts
2
+ /**
3
+ * Return the Zone based on the username.
4
+ */
5
+ const getZone = (auth) => {
6
+ const segments = auth.username.split("-");
7
+ return segments[segments.length - 1];
8
+ };
9
+ /**
10
+ * Return the customer Id based on the username.
11
+ */
12
+ const getCustomerId = (auth, prefix) => {
13
+ const customerId = auth.username.split("-")[2][2].replace("hl_", "");
14
+ return (prefix || "") + customerId;
15
+ };
16
+
17
+ //#endregion
18
+ export { getCustomerId, getZone };
@@ -0,0 +1,19 @@
1
+ import { t as Auth } from "../../../index-BfyGIdDD.mjs";
2
+
3
+ //#region src/brightData/webScraperIde/server/getBatch.d.ts
4
+ /**
5
+ * Depends on the Scraper setup!
6
+ *
7
+ * Make the request to trigger the scraper and let it do its job.
8
+ */
9
+ declare const getBatch: (auth: Auth, scraperId: string, data?: {}, isDev?: boolean) => Promise<boolean>;
10
+ //#endregion
11
+ //#region src/brightData/webScraperIde/server/getRealtime.d.ts
12
+ /**
13
+ * Depends on the Scraper setup!
14
+ *
15
+ * Make the request and pool the response until the data is available.
16
+ */
17
+ declare const getRealtime: (auth: Auth, scraperId: string, data?: {}) => Promise<{}>;
18
+ //#endregion
19
+ export { getBatch, getRealtime };
@@ -0,0 +1,50 @@
1
+ import { sleep } from "../../../util/index.mjs";
2
+ import { s as apiState } from "../../../api-DGKJDAfb.mjs";
3
+ import { get, post } from "../../../axios/index.mjs";
4
+
5
+ //#region src/brightData/webScraperIde/server/getBatch.ts
6
+ /**
7
+ * Depends on the Scraper setup!
8
+ *
9
+ * Make the request to trigger the scraper and let it do its job.
10
+ */
11
+ const getBatch = async (auth, scraperId, data = {}, isDev = false) => {
12
+ let response = false;
13
+ const requestUrl = new URL("https://api.brightdata.com/dca/trigger");
14
+ requestUrl.searchParams.append("collector", scraperId);
15
+ requestUrl.searchParams.append("queue_next", "1");
16
+ if (isDev) requestUrl.searchParams.append("version", "dev");
17
+ if ((await post(requestUrl.toString(), data, { headers: { Authorization: `Bearer ${auth.apiKey}` } })).isSuccess()) response = true;
18
+ return response;
19
+ };
20
+
21
+ //#endregion
22
+ //#region src/brightData/webScraperIde/server/getRealtime.ts
23
+ /**
24
+ * Depends on the Scraper setup!
25
+ *
26
+ * Make the request and pool the response until the data is available.
27
+ */
28
+ const getRealtime = async (auth, scraperId, data = {}) => {
29
+ let response = {};
30
+ const requestResponse = await post(`https://api.brightdata.com/dca/trigger_immediate?collector=${scraperId}`, data, { headers: { Authorization: `Bearer ${auth.apiKey}` } });
31
+ if (requestResponse.isSuccess()) {
32
+ const responseId = requestResponse.getBodyDefaultTo(["response_id"], "");
33
+ if ("" !== responseId) {
34
+ let state = apiState.PENDING;
35
+ while (apiState.PENDING === state) {
36
+ const resultResponse = await get(`https://api.brightdata.com/dca/get_result?response_id=${responseId}`, { headers: { Authorization: `Bearer ${auth.apiKey}` } });
37
+ if (resultResponse.isSuccess()) if (void 0 !== resultResponse.body.pending && true === resultResponse.body.pending) state = apiState.PENDING;
38
+ else {
39
+ state = apiState.SUCCESS;
40
+ response = resultResponse.getBody();
41
+ }
42
+ await sleep(1);
43
+ }
44
+ }
45
+ }
46
+ return response;
47
+ };
48
+
49
+ //#endregion
50
+ export { getBatch, getRealtime };
@@ -0,0 +1,10 @@
1
+ //#region src/cache/server/cache.d.ts
2
+ type CacheEntry = {
3
+ data: any;
4
+ expires: number;
5
+ insertedAt: number;
6
+ };
7
+ declare const getCache: (key: string) => any;
8
+ declare const setCache: (key: string, data: any, expires?: number, force?: boolean) => any;
9
+ //#endregion
10
+ export { CacheEntry, getCache, setCache };
@@ -0,0 +1,31 @@
1
+ //#region src/cache/server/cache.ts
2
+ const cache = /* @__PURE__ */ new Map();
3
+ const getCache = (key) => {
4
+ let response = null;
5
+ if (cache.has(key)) {
6
+ const cacheItem = cache.get(key);
7
+ if (cacheItem.expires > 0) {
8
+ const expiresAt = Math.floor(cacheItem.insertedAt / 1e3) + cacheItem.expires;
9
+ if (Math.floor(Date.now() / 1e3) < expiresAt) response = cacheItem;
10
+ } else response = cacheItem;
11
+ }
12
+ return response;
13
+ };
14
+ const setCache = (key, data, expires = 0, force = false) => {
15
+ const now = Math.floor(Date.now() / 1e3);
16
+ if (cache.has(key) && !force) {
17
+ const cacheItem = cache.get(key);
18
+ if (cacheItem.expires > 0) {
19
+ if (now < Math.floor(cacheItem.insertedAt / 1e3) + cacheItem.expires) return cacheItem;
20
+ }
21
+ }
22
+ cache.set(key, {
23
+ data,
24
+ expires,
25
+ insertedAt: now
26
+ });
27
+ return data;
28
+ };
29
+
30
+ //#endregion
31
+ export { getCache, setCache };
@@ -0,0 +1,7 @@
1
+ import { createRequire } from "node:module";
2
+
3
+ //#region \0rolldown/runtime.js
4
+ var __require = /* @__PURE__ */ createRequire(import.meta.url);
5
+
6
+ //#endregion
7
+ export { __require as t };
@@ -0,0 +1,10 @@
1
+ //#region src/crud/crud.d.ts
2
+ declare const crudState: {
3
+ readonly CREATE: "CREATE";
4
+ readonly READ: "READ";
5
+ readonly UPDATE: "UPDATE";
6
+ readonly DELETE: "DELETE";
7
+ };
8
+ type CrudState = typeof crudState[keyof typeof crudState];
9
+ //#endregion
10
+ export { CrudState, crudState };
@@ -0,0 +1,10 @@
1
+ //#region src/crud/crud.ts
2
+ const crudState = {
3
+ CREATE: "CREATE",
4
+ READ: "READ",
5
+ UPDATE: "UPDATE",
6
+ DELETE: "DELETE"
7
+ };
8
+
9
+ //#endregion
10
+ export { crudState };
@@ -0,0 +1,25 @@
1
+ //#region src/crypto/getDecrypt.d.ts
2
+ /**
3
+ * Decrypt an encoding string using a salt.
4
+ */
5
+ declare const getDecrypt: (appSalt: string, input: string, salt: string) => Promise<string>;
6
+ //#endregion
7
+ //#region src/crypto/getEncrypt.d.ts
8
+ /**
9
+ * Encrypt an encoding string using a salt.
10
+ */
11
+ declare const getEncrypt: (appSalt: string, input: string, salt: string) => Promise<string>;
12
+ //#endregion
13
+ //#region src/crypto/getRandom.d.ts
14
+ /**
15
+ * Create a random string and return a number of characters from it.
16
+ */
17
+ declare const getRandom: (length: number) => string;
18
+ //#endregion
19
+ //#region src/crypto/getSha256.d.ts
20
+ /**
21
+ * Encrypt a string using sha256.
22
+ */
23
+ declare const getSha256: (input: any) => Promise<string>;
24
+ //#endregion
25
+ export { getDecrypt, getEncrypt, getRandom, getSha256 };
@@ -0,0 +1,57 @@
1
+ import { t as __require } from "../chunk-DDarj8oW.mjs";
2
+ import { getString } from "../string/index.mjs";
3
+
4
+ //#region src/crypto/getDecrypt.ts
5
+ /**
6
+ * Decrypt an encoding string using a salt.
7
+ */
8
+ const getDecrypt = async (appSalt, input, salt) => {
9
+ const crypto = __require("crypto");
10
+ const ALGORITHM = "aes-256-cbc";
11
+ const customSalt = `${appSalt}-${salt}`;
12
+ const [ivHex, encryptedHex] = input.split(":");
13
+ const key = crypto.scryptSync(customSalt, "salt", 32);
14
+ const iv = Buffer.from(ivHex, "hex");
15
+ const encrypted = Buffer.from(encryptedHex, "hex");
16
+ const decipher = crypto.createDecipheriv(ALGORITHM, key, iv);
17
+ return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
18
+ };
19
+
20
+ //#endregion
21
+ //#region src/crypto/getEncrypt.ts
22
+ /**
23
+ * Encrypt an encoding string using a salt.
24
+ */
25
+ const getEncrypt = async (appSalt, input, salt) => {
26
+ const crypto = __require("crypto");
27
+ const ALGORITHM = "aes-256-cbc";
28
+ const customSalt = `${appSalt}-${salt}`;
29
+ const key = crypto.scryptSync(customSalt, "salt", 32);
30
+ const iv = crypto.randomBytes(16);
31
+ const cipher = crypto.createCipheriv(ALGORITHM, key, iv);
32
+ const encrypted = Buffer.concat([cipher.update(input, "utf8"), cipher.final()]);
33
+ return iv.toString("hex") + ":" + encrypted.toString("hex");
34
+ };
35
+
36
+ //#endregion
37
+ //#region src/crypto/getRandom.ts
38
+ /**
39
+ * Create a random string and return a number of characters from it.
40
+ */
41
+ const getRandom = (length) => {
42
+ return Math.random().toString(36).substr(0, length);
43
+ };
44
+
45
+ //#endregion
46
+ //#region src/crypto/getSha256.ts
47
+ /**
48
+ * Encrypt a string using sha256.
49
+ */
50
+ const getSha256 = async (input) => {
51
+ const crypto = __require("crypto");
52
+ const inputString = getString(input);
53
+ return crypto.createHash("sha256").update(inputString).digest("hex");
54
+ };
55
+
56
+ //#endregion
57
+ export { getDecrypt, getEncrypt, getRandom, getSha256 };
@@ -0,0 +1,2 @@
1
+ import { $ as defaultDate, A as getMonday, B as isLastWeek, C as differenceInBusinessDays, D as getLuxonDate, E as getLastWeek, F as getTwoWeeksAgo, G as isThursday, H as isSaturday, I as getUnix, J as isWeekend, K as isTuesday, L as getWeeksAgo, M as getSunday, N as getThisWeek, O as getMax, P as getToday, Q as Timeframe, R as getYesterday, S as getFinancialYearWeeks, T as getDatesBetween, U as isSunday, V as isMonday, W as isThisWeek, X as InputDate, Y as FinancialWeek, Z as Month, _ as getYmdNumber, a as getFullDate, b as getFinancialYearToDate, c as getMonthYearString, d as getTodayYmdNumber, et as defaultDateNumber, f as getTodayYmdString, g as getYmdHisString, h as getYmdHisNumber, i as getDurationMinutes, j as getMonthsBetween, k as getMin, l as getTodayYmdHisNumber, m as getYearNumber, n as getDayNumber, nt as month, o as getFullDateTime, p as getYearMonthString, q as isWednesday, r as getDurationHours, s as getLuxonDateFromExcel, t as format, tt as defaultDateTime, u as getTodayYmdHisString, v as getYmdString, w as differenceInMinutes, x as getFinancialYearToYesterday, y as getFinancialYear, z as isFriday } from "../index-1fBbJGQz.mjs";
2
+ export { FinancialWeek, InputDate, Month, Timeframe, defaultDate, defaultDateNumber, defaultDateTime, differenceInBusinessDays, differenceInMinutes, format, getDatesBetween, getDayNumber, getDurationHours, getDurationMinutes, getFinancialYear, getFinancialYearToDate, getFinancialYearToYesterday, getFinancialYearWeeks, getFullDate, getFullDateTime, getLastWeek, getLuxonDate, getLuxonDateFromExcel, getMax, getMin, getMonday, getMonthYearString, getMonthsBetween, getSunday, getThisWeek, getToday, getTodayYmdHisNumber, getTodayYmdHisString, getTodayYmdNumber, getTodayYmdString, getTwoWeeksAgo, getUnix, getWeeksAgo, getYearMonthString, getYearNumber, getYesterday, getYmdHisNumber, getYmdHisString, getYmdNumber, getYmdString, isFriday, isLastWeek, isMonday, isSaturday, isSunday, isThisWeek, isThursday, isTuesday, isWednesday, isWeekend, month };