scrapebadger 0.46.0 → 0.47.1
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.
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +26 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,7 @@ import { EventEmitter } from 'events';
|
|
|
3
3
|
import WebSocket from 'ws';
|
|
4
4
|
|
|
5
5
|
// src/internal/version.ts
|
|
6
|
-
var SDK_VERSION = "0.
|
|
6
|
+
var SDK_VERSION = "0.47.1";
|
|
7
7
|
|
|
8
8
|
// src/internal/exceptions.ts
|
|
9
9
|
var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
|
|
@@ -205,8 +205,27 @@ var BaseClient = class _BaseClient {
|
|
|
205
205
|
async executeWithRetry(url, options) {
|
|
206
206
|
let lastError;
|
|
207
207
|
for (let attempt = 0; attempt <= this.config.maxRetries; attempt++) {
|
|
208
|
+
let retryAfterMs = 0;
|
|
208
209
|
try {
|
|
209
210
|
const httpResponse = await this.fetchWithTimeout(url, options);
|
|
211
|
+
const retryAfter = httpResponse.headers.get("Retry-After")?.trim();
|
|
212
|
+
if (retryAfter) {
|
|
213
|
+
let requestedDelay = 0;
|
|
214
|
+
if (/^\d+$/.test(retryAfter)) {
|
|
215
|
+
requestedDelay = Number(retryAfter) * 1e3;
|
|
216
|
+
} else if (/^(?:(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun), \d{2} [A-Z][a-z]{2} \d{4}|(?:Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), \d{2}-[A-Z][a-z]{2}-\d{2}) \d{2}:\d{2}:\d{2} GMT$/.test(
|
|
217
|
+
retryAfter
|
|
218
|
+
)) {
|
|
219
|
+
requestedDelay = Date.parse(retryAfter) - Date.now();
|
|
220
|
+
} else if (/^(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun) [A-Z][a-z]{2} [ \d]\d \d{2}:\d{2}:\d{2} \d{4}$/.test(
|
|
221
|
+
retryAfter
|
|
222
|
+
)) {
|
|
223
|
+
requestedDelay = Date.parse(`${retryAfter} GMT`) - Date.now();
|
|
224
|
+
}
|
|
225
|
+
if (requestedDelay > 0 && requestedDelay <= 2147483647) {
|
|
226
|
+
retryAfterMs = requestedDelay;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
210
229
|
const data = await this.handleResponse(httpResponse);
|
|
211
230
|
const rateLimit = this.parseRateLimitHeaders(httpResponse.headers);
|
|
212
231
|
return { data, rateLimit };
|
|
@@ -218,7 +237,7 @@ var BaseClient = class _BaseClient {
|
|
|
218
237
|
if (attempt === this.config.maxRetries) {
|
|
219
238
|
break;
|
|
220
239
|
}
|
|
221
|
-
const delay = this.config.retryDelay * Math.pow(2, attempt);
|
|
240
|
+
const delay = Math.max(this.config.retryDelay * Math.pow(2, attempt), retryAfterMs);
|
|
222
241
|
const delaySec = Math.round(delay / 1e3);
|
|
223
242
|
const attemptNum = attempt + 1;
|
|
224
243
|
const maxRetries = this.config.maxRetries;
|
|
@@ -229,7 +248,7 @@ var BaseClient = class _BaseClient {
|
|
|
229
248
|
if (error.retryAfter) {
|
|
230
249
|
const retryDelay = (error.retryAfter - Date.now() / 1e3) * 1e3;
|
|
231
250
|
if (retryDelay > 0 && retryDelay < 6e4) {
|
|
232
|
-
await this.sleep(retryDelay);
|
|
251
|
+
await this.sleep(Math.max(retryDelay, retryAfterMs));
|
|
233
252
|
continue;
|
|
234
253
|
}
|
|
235
254
|
}
|
|
@@ -2968,6 +2987,10 @@ var VintedClient = class {
|
|
|
2968
2987
|
async readVintedMobileData(operation, body, params = {}) {
|
|
2969
2988
|
return this._gen.request(`/v1/vinted/mobile/${operation}`, { method: "POST", params, body });
|
|
2970
2989
|
}
|
|
2990
|
+
/** Search by image. Generated from the OpenAPI spec; returns the raw response object. */
|
|
2991
|
+
async searchByImage(body, params = {}) {
|
|
2992
|
+
return this._gen.request("/v1/vinted/search_by_image", { method: "POST", params, body });
|
|
2993
|
+
}
|
|
2971
2994
|
// --- END generated by sdk/codegen/facade ---
|
|
2972
2995
|
};
|
|
2973
2996
|
|