scrapebadger 0.24.0 → 0.24.2

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.
@@ -76,6 +76,14 @@ declare class BaseClient {
76
76
  * Handle HTTP response and convert errors.
77
77
  */
78
78
  private handleResponse;
79
+ /**
80
+ * Whether a failed request is worth another attempt.
81
+ *
82
+ * Retryable: transient server failures (500/502/503/504), request timeouts,
83
+ * rate limits, and raw network faults thrown by `fetch` itself. Everything
84
+ * else — auth, validation, not-found, conflict — is final.
85
+ */
86
+ private static isRetryable;
79
87
  /**
80
88
  * Sleep for a given duration.
81
89
  */
@@ -76,6 +76,14 @@ declare class BaseClient {
76
76
  * Handle HTTP response and convert errors.
77
77
  */
78
78
  private handleResponse;
79
+ /**
80
+ * Whether a failed request is worth another attempt.
81
+ *
82
+ * Retryable: transient server failures (500/502/503/504), request timeouts,
83
+ * rate limits, and raw network faults thrown by `fetch` itself. Everything
84
+ * else — auth, validation, not-found, conflict — is final.
85
+ */
86
+ private static isRetryable;
79
87
  /**
80
88
  * Sleep for a given duration.
81
89
  */
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BaseClient, T as TwitterClient, S as ScrapeBadgerConfig } from './index-CIZUd1Zr.cjs';
2
- export { e as AccountRestrictedError, a3 as ApiResponse, $ as Article, A as AuthenticationError, aj as BillingLog, ak as BillingLogList, a2 as Broadcast, j as CommunitiesClient, K as Community, F as CommunityBanner, O as CommunityMember, a0 as CommunityNote, J as CommunityRule, q as CommunityTweetType, C as ConflictError, al as ConnectOptions, ab as ConnectedEvent, a8 as CreateMonitorParams, ah as DeliveryLog, ai as DeliveryLogList, ae as ErrorEvent, ao as FilterRuleCreate, at as FilterRuleDeliveryLog, au as FilterRuleDeliveryLogListResponse, ar as FilterRuleListResponse, aq as FilterRulePricingTier, av as FilterRulePricingTiersResponse, an as FilterRuleResponse, am as FilterRuleStatus, ap as FilterRuleUpdate, as as FilterRuleValidateResponse, G as GeoClient, l as GeoSearchOptions, H as Hashtag, I as InsufficientCreditsError, g as IteratorOptions, E as List, a4 as ListResponse, L as ListsClient, Y as Location, M as Media, a5 as MonitorStatus, N as NotFoundError, P as PaginatedResponse, f as PaginationOptions, ac as PingEvent, _ as Place, Z as PlaceTrends, s as Poll, r as PollOption, Q as QueryType, b as RateLimitError, R as ResolvedConfig, a as ScrapeBadgerError, c as ServerError, a1 as Space, o as SpacesClient, m as StreamClient, n as StreamEmitter, af as StreamEvent, ag as StreamEventType, a6 as StreamMonitor, a7 as StreamMonitorList, aa as StreamTweet, d as TimeoutError, X as Trend, p as TrendCategory, k as TrendsClient, x as Tweet, ad as TweetEvent, w as TweetPlace, i as TweetsClient, a9 as UpdateMonitorParams, t as Url, y as User, z as UserAbout, D as UserIds, u as UserMention, U as UsersClient, V as ValidationError, W as WebSocketStreamError, h as collectAll, v as verifyWebhookSignature } from './index-CIZUd1Zr.cjs';
1
+ import { B as BaseClient, T as TwitterClient, S as ScrapeBadgerConfig } from './index-jp8WyFsJ.cjs';
2
+ export { e as AccountRestrictedError, a3 as ApiResponse, $ as Article, A as AuthenticationError, aj as BillingLog, ak as BillingLogList, a2 as Broadcast, j as CommunitiesClient, K as Community, F as CommunityBanner, O as CommunityMember, a0 as CommunityNote, J as CommunityRule, q as CommunityTweetType, C as ConflictError, al as ConnectOptions, ab as ConnectedEvent, a8 as CreateMonitorParams, ah as DeliveryLog, ai as DeliveryLogList, ae as ErrorEvent, ao as FilterRuleCreate, at as FilterRuleDeliveryLog, au as FilterRuleDeliveryLogListResponse, ar as FilterRuleListResponse, aq as FilterRulePricingTier, av as FilterRulePricingTiersResponse, an as FilterRuleResponse, am as FilterRuleStatus, ap as FilterRuleUpdate, as as FilterRuleValidateResponse, G as GeoClient, l as GeoSearchOptions, H as Hashtag, I as InsufficientCreditsError, g as IteratorOptions, E as List, a4 as ListResponse, L as ListsClient, Y as Location, M as Media, a5 as MonitorStatus, N as NotFoundError, P as PaginatedResponse, f as PaginationOptions, ac as PingEvent, _ as Place, Z as PlaceTrends, s as Poll, r as PollOption, Q as QueryType, b as RateLimitError, R as ResolvedConfig, a as ScrapeBadgerError, c as ServerError, a1 as Space, o as SpacesClient, m as StreamClient, n as StreamEmitter, af as StreamEvent, ag as StreamEventType, a6 as StreamMonitor, a7 as StreamMonitorList, aa as StreamTweet, d as TimeoutError, X as Trend, p as TrendCategory, k as TrendsClient, x as Tweet, ad as TweetEvent, w as TweetPlace, i as TweetsClient, a9 as UpdateMonitorParams, t as Url, y as User, z as UserAbout, D as UserIds, u as UserMention, U as UsersClient, V as ValidationError, W as WebSocketStreamError, h as collectAll, v as verifyWebhookSignature } from './index-jp8WyFsJ.cjs';
3
3
  import 'node:events';
4
4
 
5
5
  /**
@@ -1688,8 +1688,10 @@ declare class JobsClient {
1688
1688
  * Client for Google Lens visual search by image URL.
1689
1689
  *
1690
1690
  * Response carries `lens_results` (Scrapingdog-parity alias) with
1691
- * `title`, `source`, `source_favicon`, `thumbnail`, optional `tag`
1692
- * price chip and `in_stock`, plus `related_searches` chips. Legacy
1691
+ * `title`, `source`, `source_favicon`, `thumbnail`, `rating`,
1692
+ * `reviews` and `in_stock`. Shoppable matches also carry `price`
1693
+ * (`{value, currency, extracted}`) plus the raw `tag` chip it is
1694
+ * parsed from. `related_searches` chips come alongside. Legacy
1693
1695
  * `results` alias retained for backwards compat.
1694
1696
  *
1695
1697
  * @example
@@ -1699,7 +1701,7 @@ declare class JobsClient {
1699
1701
  * product: true, // bias towards shoppable matches
1700
1702
  * });
1701
1703
  * for (const match of out.lens_results) {
1702
- * console.log(match.title, match.tag);
1704
+ * console.log(match.title, match.price?.value, match.price?.currency);
1703
1705
  * }
1704
1706
  * ```
1705
1707
  */
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { B as BaseClient, T as TwitterClient, S as ScrapeBadgerConfig } from './index-CIZUd1Zr.js';
2
- export { e as AccountRestrictedError, a3 as ApiResponse, $ as Article, A as AuthenticationError, aj as BillingLog, ak as BillingLogList, a2 as Broadcast, j as CommunitiesClient, K as Community, F as CommunityBanner, O as CommunityMember, a0 as CommunityNote, J as CommunityRule, q as CommunityTweetType, C as ConflictError, al as ConnectOptions, ab as ConnectedEvent, a8 as CreateMonitorParams, ah as DeliveryLog, ai as DeliveryLogList, ae as ErrorEvent, ao as FilterRuleCreate, at as FilterRuleDeliveryLog, au as FilterRuleDeliveryLogListResponse, ar as FilterRuleListResponse, aq as FilterRulePricingTier, av as FilterRulePricingTiersResponse, an as FilterRuleResponse, am as FilterRuleStatus, ap as FilterRuleUpdate, as as FilterRuleValidateResponse, G as GeoClient, l as GeoSearchOptions, H as Hashtag, I as InsufficientCreditsError, g as IteratorOptions, E as List, a4 as ListResponse, L as ListsClient, Y as Location, M as Media, a5 as MonitorStatus, N as NotFoundError, P as PaginatedResponse, f as PaginationOptions, ac as PingEvent, _ as Place, Z as PlaceTrends, s as Poll, r as PollOption, Q as QueryType, b as RateLimitError, R as ResolvedConfig, a as ScrapeBadgerError, c as ServerError, a1 as Space, o as SpacesClient, m as StreamClient, n as StreamEmitter, af as StreamEvent, ag as StreamEventType, a6 as StreamMonitor, a7 as StreamMonitorList, aa as StreamTweet, d as TimeoutError, X as Trend, p as TrendCategory, k as TrendsClient, x as Tweet, ad as TweetEvent, w as TweetPlace, i as TweetsClient, a9 as UpdateMonitorParams, t as Url, y as User, z as UserAbout, D as UserIds, u as UserMention, U as UsersClient, V as ValidationError, W as WebSocketStreamError, h as collectAll, v as verifyWebhookSignature } from './index-CIZUd1Zr.js';
1
+ import { B as BaseClient, T as TwitterClient, S as ScrapeBadgerConfig } from './index-jp8WyFsJ.js';
2
+ export { e as AccountRestrictedError, a3 as ApiResponse, $ as Article, A as AuthenticationError, aj as BillingLog, ak as BillingLogList, a2 as Broadcast, j as CommunitiesClient, K as Community, F as CommunityBanner, O as CommunityMember, a0 as CommunityNote, J as CommunityRule, q as CommunityTweetType, C as ConflictError, al as ConnectOptions, ab as ConnectedEvent, a8 as CreateMonitorParams, ah as DeliveryLog, ai as DeliveryLogList, ae as ErrorEvent, ao as FilterRuleCreate, at as FilterRuleDeliveryLog, au as FilterRuleDeliveryLogListResponse, ar as FilterRuleListResponse, aq as FilterRulePricingTier, av as FilterRulePricingTiersResponse, an as FilterRuleResponse, am as FilterRuleStatus, ap as FilterRuleUpdate, as as FilterRuleValidateResponse, G as GeoClient, l as GeoSearchOptions, H as Hashtag, I as InsufficientCreditsError, g as IteratorOptions, E as List, a4 as ListResponse, L as ListsClient, Y as Location, M as Media, a5 as MonitorStatus, N as NotFoundError, P as PaginatedResponse, f as PaginationOptions, ac as PingEvent, _ as Place, Z as PlaceTrends, s as Poll, r as PollOption, Q as QueryType, b as RateLimitError, R as ResolvedConfig, a as ScrapeBadgerError, c as ServerError, a1 as Space, o as SpacesClient, m as StreamClient, n as StreamEmitter, af as StreamEvent, ag as StreamEventType, a6 as StreamMonitor, a7 as StreamMonitorList, aa as StreamTweet, d as TimeoutError, X as Trend, p as TrendCategory, k as TrendsClient, x as Tweet, ad as TweetEvent, w as TweetPlace, i as TweetsClient, a9 as UpdateMonitorParams, t as Url, y as User, z as UserAbout, D as UserIds, u as UserMention, U as UsersClient, V as ValidationError, W as WebSocketStreamError, h as collectAll, v as verifyWebhookSignature } from './index-jp8WyFsJ.js';
3
3
  import 'node:events';
4
4
 
5
5
  /**
@@ -1688,8 +1688,10 @@ declare class JobsClient {
1688
1688
  * Client for Google Lens visual search by image URL.
1689
1689
  *
1690
1690
  * Response carries `lens_results` (Scrapingdog-parity alias) with
1691
- * `title`, `source`, `source_favicon`, `thumbnail`, optional `tag`
1692
- * price chip and `in_stock`, plus `related_searches` chips. Legacy
1691
+ * `title`, `source`, `source_favicon`, `thumbnail`, `rating`,
1692
+ * `reviews` and `in_stock`. Shoppable matches also carry `price`
1693
+ * (`{value, currency, extracted}`) plus the raw `tag` chip it is
1694
+ * parsed from. `related_searches` chips come alongside. Legacy
1693
1695
  * `results` alias retained for backwards compat.
1694
1696
  *
1695
1697
  * @example
@@ -1699,7 +1701,7 @@ declare class JobsClient {
1699
1701
  * product: true, // bias towards shoppable matches
1700
1702
  * });
1701
1703
  * for (const match of out.lens_results) {
1702
- * console.log(match.title, match.tag);
1704
+ * console.log(match.title, match.price?.value, match.price?.currency);
1703
1705
  * }
1704
1706
  * ```
1705
1707
  */
package/dist/index.js CHANGED
@@ -9,7 +9,7 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
9
9
  var WebSocket__default = /*#__PURE__*/_interopDefault(WebSocket);
10
10
 
11
11
  // src/internal/version.ts
12
- var SDK_VERSION = "0.24.0";
12
+ var SDK_VERSION = "0.24.2";
13
13
 
14
14
  // src/internal/exceptions.ts
15
15
  var ScrapeBadgerError = class _ScrapeBadgerError extends Error {
@@ -124,7 +124,8 @@ var WebSocketStreamError = class _WebSocketStreamError extends ScrapeBadgerError
124
124
  };
125
125
 
126
126
  // src/internal/client.ts
127
- var BaseClient = class {
127
+ var RETRYABLE_STATUS_CODES = [500, 502, 503, 504];
128
+ var BaseClient = class _BaseClient {
128
129
  config;
129
130
  constructor(config) {
130
131
  this.config = config;
@@ -184,7 +185,7 @@ var BaseClient = class {
184
185
  return { data, rateLimit };
185
186
  } catch (error) {
186
187
  lastError = error;
187
- if (error instanceof ScrapeBadgerError && !(error instanceof RateLimitError)) {
188
+ if (!_BaseClient.isRetryable(error)) {
188
189
  throw error;
189
190
  }
190
191
  if (attempt === this.config.maxRetries) {
@@ -311,6 +312,22 @@ var BaseClient = class {
311
312
  throw new ScrapeBadgerError(message);
312
313
  }
313
314
  }
315
+ /**
316
+ * Whether a failed request is worth another attempt.
317
+ *
318
+ * Retryable: transient server failures (500/502/503/504), request timeouts,
319
+ * rate limits, and raw network faults thrown by `fetch` itself. Everything
320
+ * else — auth, validation, not-found, conflict — is final.
321
+ */
322
+ static isRetryable(error) {
323
+ if (error instanceof ServerError) {
324
+ return RETRYABLE_STATUS_CODES.includes(error.statusCode);
325
+ }
326
+ if (error instanceof RateLimitError || error instanceof TimeoutError) {
327
+ return true;
328
+ }
329
+ return !(error instanceof ScrapeBadgerError);
330
+ }
314
331
  /**
315
332
  * Sleep for a given duration.
316
333
  */