scrapfly-sdk 0.12.1 → 1.0.0

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 (42) hide show
  1. package/README.md +34 -33
  2. package/esm/client.d.ts +5 -3
  3. package/esm/client.d.ts.map +1 -1
  4. package/esm/client.js +5 -1
  5. package/esm/crawlerconfig.d.ts +5 -13
  6. package/esm/crawlerconfig.d.ts.map +1 -1
  7. package/esm/crawlerconfig.js +1 -4
  8. package/esm/main.d.ts +3 -2
  9. package/esm/main.d.ts.map +1 -1
  10. package/esm/main.js +2 -2
  11. package/esm/result.d.ts +8 -8
  12. package/esm/result.d.ts.map +1 -1
  13. package/esm/scrapeconfig.d.ts +43 -31
  14. package/esm/scrapeconfig.d.ts.map +1 -1
  15. package/esm/scrapeconfig.js +26 -31
  16. package/esm/screenshotconfig.d.ts +3 -4
  17. package/esm/screenshotconfig.d.ts.map +1 -1
  18. package/esm/screenshotconfig.js +1 -1
  19. package/package.json +1 -1
  20. package/script/client.d.ts +5 -3
  21. package/script/client.d.ts.map +1 -1
  22. package/script/client.js +5 -1
  23. package/script/crawlerconfig.d.ts +5 -13
  24. package/script/crawlerconfig.d.ts.map +1 -1
  25. package/script/crawlerconfig.js +1 -4
  26. package/script/main.d.ts +3 -2
  27. package/script/main.d.ts.map +1 -1
  28. package/script/main.js +2 -2
  29. package/script/result.d.ts +8 -8
  30. package/script/result.d.ts.map +1 -1
  31. package/script/scrapeconfig.d.ts +43 -31
  32. package/script/scrapeconfig.d.ts.map +1 -1
  33. package/script/scrapeconfig.js +26 -31
  34. package/script/screenshotconfig.d.ts +3 -4
  35. package/script/screenshotconfig.d.ts.map +1 -1
  36. package/script/screenshotconfig.js +1 -1
  37. package/src/client.ts +8 -3
  38. package/src/crawlerconfig.ts +5 -13
  39. package/src/main.ts +3 -2
  40. package/src/result.ts +4 -8
  41. package/src/scrapeconfig.ts +62 -40
  42. package/src/screenshotconfig.ts +3 -4
@@ -1 +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J,SAAS,CAAC,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI;gBAEhB,OAAO,EAAE,CAAC,GAAG,cAAc,CAAC,CAAC,CAAC;IAmG1C;;;;;;;;;OASG;IACH,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,EAE3B;IAED;;;;OAIG;IACH,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,CAA+C;IAExF,OAAO,CAAC,eAAe;IASvB,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CA0L3D"}
@@ -44,6 +44,11 @@ var FormatOption;
44
44
  /** Keep only the "content" section (drop navigation, sidebars, footers). */
45
45
  FormatOption["ONLY_CONTENT"] = "only_content";
46
46
  })(FormatOption || (exports.FormatOption = FormatOption = {}));
47
+ /**
48
+ * `O` is the options the config was built from, inferred by `new ScrapeConfig({...})`: it only types what
49
+ * `ScrapflyClient.scrape` answers. A plain `ScrapeConfig` takes any of them and answers either one; type a
50
+ * variable that holds both proxified and plain configs as plain `ScrapeConfig`.
51
+ */
47
52
  class ScrapeConfig {
48
53
  constructor(options) {
49
54
  Object.defineProperty(this, "url", {
@@ -110,7 +115,7 @@ class ScrapeConfig {
110
115
  * Storage for the anti-bot bypass toggle, under its deprecated name.
111
116
  * `unblocker` is an accessor over this same field — see below.
112
117
  *
113
- * @deprecated Use `proxy_pool` (`ScrapeConfig.UNBLOCKER_ULTRA` for the Unblocker).
118
+ * @deprecated Use {@link ScrapeConfig.unblocker}. `asp` keeps working forever.
114
119
  */
115
120
  Object.defineProperty(this, "asp", {
116
121
  enumerable: true,
@@ -137,12 +142,8 @@ class ScrapeConfig {
137
142
  value: void 0
138
143
  });
139
144
  /**
140
- * Proxy pool: `basic` (datacenter proxies, Unblocker off), `unblocker`
141
- * (residential proxies and the Unblocker), `unblocker_ultra` (residential
142
- * proxies and the Unblocker, the only pool accepted by the targets and
143
- * anti-bot protections that have a price of their own) or `auto` (the API
144
- * picks the pool from the target's profile), see {@link ScrapeConfig.BASIC}.
145
- * Each sets the Unblocker itself.
145
+ * Proxy pool: `ScrapeConfig.PUBLIC_DATACENTER_POOL` (the default),
146
+ * `ScrapeConfig.PUBLIC_RESIDENTIAL_POOL` or `ScrapeConfig.PUBLIC_TOR_POOL`.
146
147
  */
147
148
  Object.defineProperty(this, "proxy_pool", {
148
149
  enumerable: true,
@@ -423,9 +424,6 @@ class ScrapeConfig {
423
424
  }
424
425
  /**
425
426
  * The Unblocker toggle, the current name for what used to be `asp`.
426
- * Deprecated: use `proxy_pool` (`ScrapeConfig.UNBLOCKER_ULTRA` for the
427
- * Unblocker). The migration guide covers requests written before the proxy
428
- * pools: https://scrapfly.io/new-pricing#legacy-spellings
429
427
  *
430
428
  * An accessor over the single `asp` field rather than a second stored
431
429
  * property: one storage slot means the two names can never disagree, so
@@ -631,54 +629,51 @@ class ScrapeConfig {
631
629
  }
632
630
  }
633
631
  exports.ScrapeConfig = ScrapeConfig;
634
- // Proxy pools, sent as `proxy_pool`. Each sets both the proxies and the
635
- // Unblocker. AUTO lets the API pick the pool before the request, from the
636
- // target's profile: the Unblocker on datacenter proxies, or the pool the
637
- // target needs, priced as the pool it runs on.
638
- Object.defineProperty(ScrapeConfig, "BASIC", {
632
+ // Proxy pools, sent as `proxy_pool`. Datacenter proxies are the default.
633
+ Object.defineProperty(ScrapeConfig, "PUBLIC_DATACENTER_POOL", {
639
634
  enumerable: true,
640
635
  configurable: true,
641
636
  writable: true,
642
- value: 'basic'
637
+ value: 'public_datacenter_pool'
643
638
  });
644
- Object.defineProperty(ScrapeConfig, "UNBLOCKER", {
639
+ Object.defineProperty(ScrapeConfig, "PUBLIC_RESIDENTIAL_POOL", {
645
640
  enumerable: true,
646
641
  configurable: true,
647
642
  writable: true,
648
- value: 'unblocker'
643
+ value: 'public_residential_pool'
649
644
  });
650
- Object.defineProperty(ScrapeConfig, "UNBLOCKER_ULTRA", {
645
+ // The Tor network, the only pool that reaches .onion hidden services.
646
+ Object.defineProperty(ScrapeConfig, "PUBLIC_TOR_POOL", {
651
647
  enumerable: true,
652
648
  configurable: true,
653
649
  writable: true,
654
- value: 'unblocker_ultra'
650
+ value: 'public_tor_pool'
655
651
  });
656
- Object.defineProperty(ScrapeConfig, "AUTO", {
652
+ // Pool names the API does not accept yet: a request naming one fails with
653
+ // ERR::PROXY::POOL_NOT_FOUND.
654
+ Object.defineProperty(ScrapeConfig, "BASIC", {
657
655
  enumerable: true,
658
656
  configurable: true,
659
657
  writable: true,
660
- value: 'auto'
658
+ value: 'basic'
661
659
  });
662
- // The Tor network, the only pool that reaches .onion hidden services.
663
- Object.defineProperty(ScrapeConfig, "PUBLIC_TOR_POOL", {
660
+ Object.defineProperty(ScrapeConfig, "UNBLOCKER", {
664
661
  enumerable: true,
665
662
  configurable: true,
666
663
  writable: true,
667
- value: 'public_tor_pool'
664
+ value: 'unblocker'
668
665
  });
669
- // Pool names written before the proxy pools, still accepted. The migration
670
- // guide covers them: https://scrapfly.io/new-pricing#legacy-spellings
671
- Object.defineProperty(ScrapeConfig, "PUBLIC_DATACENTER_POOL", {
666
+ Object.defineProperty(ScrapeConfig, "UNBLOCKER_ULTRA", {
672
667
  enumerable: true,
673
668
  configurable: true,
674
669
  writable: true,
675
- value: 'public_datacenter_pool'
670
+ value: 'unblocker_ultra'
676
671
  });
677
- Object.defineProperty(ScrapeConfig, "PUBLIC_RESIDENTIAL_POOL", {
672
+ Object.defineProperty(ScrapeConfig, "AUTO", {
678
673
  enumerable: true,
679
674
  configurable: true,
680
675
  writable: true,
681
- value: 'public_residential_pool'
676
+ value: 'auto'
682
677
  });
683
678
  /**
684
679
  * Option names the constructor accepts that are not own properties of the
@@ -77,9 +77,8 @@ type ScreenshotConfigOptions = {
77
77
  /** Webhook name to notify when the screenshot completes. */
78
78
  webhook?: string;
79
79
  /**
80
- * Proxy pool: `basic`, `unblocker`, `unblocker_ultra` or `auto` (see
81
- * `ScrapeConfig.BASIC`); any other value is ignored here. Unset, the API's
82
- * screenshot defaults apply. The screenshot price is the same on every pool.
80
+ * Sent as `proxy_pool`. The Screenshot API picks its pool itself and ignores
81
+ * this value.
83
82
  */
84
83
  proxy_pool?: string;
85
84
  };
@@ -111,7 +110,7 @@ export declare class ScreenshotConfig {
111
110
  cache_clear?: boolean;
112
111
  vision_deficiency?: 'deuteranopia' | 'protanopia' | 'tritanopia' | 'achromatopsia' | 'blurredVision' | 'reducedContrast' | VisionDeficiency;
113
112
  webhook?: string;
114
- /** Proxy pool: `basic`, `unblocker`, `unblocker_ultra` or `auto`; any other value is ignored here. */
113
+ /** Sent as `proxy_pool`; the Screenshot API picks its pool itself and ignores it. */
115
114
  proxy_pool?: string;
116
115
  constructor(options: ScreenshotConfigOptions);
117
116
  private validateOptions;
@@ -1 +1 @@
1
- {"version":3,"file":"screenshotconfig.d.ts","sourceRoot":"","sources":["../src/screenshotconfig.ts"],"names":[],"mappings":"AAIA,6DAA6D;AAC7D,oBAAY,OAAO;IACjB,qEAAqE;IACrE,WAAW,gBAAgB;IAC3B,oCAAoC;IACpC,SAAS,cAAc;IACvB,+EAA+E;IAC/E,aAAa,kBAAkB;IAC/B,qDAAqD;IACrD,kBAAkB,uBAAuB;CAC1C;AAED,6CAA6C;AAC7C,oBAAY,MAAM;IAChB,qBAAqB;IACrB,GAAG,QAAQ;IACX,oBAAoB;IACpB,GAAG,QAAQ;IACX,qBAAqB;IACrB,IAAI,SAAS;IACb,kCAAkC;IAClC,GAAG,QAAQ;CACZ;AAED;;;GAGG;AACH,oBAAY,gBAAgB;IAC1B,0EAA0E;IAC1E,YAAY,iBAAiB;IAC7B,gEAAgE;IAChE,UAAU,eAAe;IACzB,sEAAsE;IACtE,UAAU,eAAe;IACzB,wDAAwD;IACxD,aAAa,kBAAkB;IAC/B,2CAA2C;IAC3C,gBAAgB,oBAAoB;IACpC,sDAAsD;IACtD,cAAc,kBAAk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E,MAAM,CAAC;IACjB,qFAAqF;IACrF,UAAU,CAAC,EAAE,MAAM,CAAC;gBAER,OAAO,EAAE,uBAAuB;IAgC5C,OAAO,CAAC,eAAe;IASvB;;;;;;OAMG;IACH,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CA6E3D"}
@@ -156,7 +156,7 @@ class ScreenshotConfig {
156
156
  writable: true,
157
157
  value: void 0
158
158
  });
159
- /** Proxy pool: `basic`, `unblocker`, `unblocker_ultra` or `auto`; any other value is ignored here. */
159
+ /** Sent as `proxy_pool`; the Screenshot API picks its pool itself and ignores it. */
160
160
  Object.defineProperty(this, "proxy_pool", {
161
161
  enumerable: true,
162
162
  configurable: true,
package/src/client.ts CHANGED
@@ -2,7 +2,7 @@ import { path } from './deps.js';
2
2
  import { mkdir, writeFile, readFileSync } from './polyfill.js';
3
3
  import { fetchRetry } from './utils.js';
4
4
  import * as errors from './errors.js';
5
- import type { ScrapeConfig } from './scrapeconfig.js';
5
+ import type { ScrapeAnswer, ScrapeConfig, ScrapeConfigOptions } from './scrapeconfig.js';
6
6
  import type { ScreenshotConfig } from './screenshotconfig.js';
7
7
  import type { ExtractionConfig } from './extractionconfig.js';
8
8
  import { BrowserConfig } from './browserconfig.js';
@@ -515,9 +515,14 @@ export class ScrapflyClient {
515
515
  }
516
516
 
517
517
  /**
518
- * Issue a single scrape command from a given scrape configuration
518
+ * Issue a single scrape command from a given scrape configuration. It answers a `ScrapeResult`, or the
519
+ * raw `Response` with `proxified_response: true`; the type says which when the config's options do.
519
520
  */
520
- async scrape(config: ScrapeConfig): Promise<ScrapeResult | Response> {
521
+ async scrape<O extends ScrapeConfigOptions = ScrapeConfigOptions>(config: ScrapeConfig<O>): Promise<ScrapeAnswer<O>> {
522
+ return (await this.scrapeAnswer(config)) as ScrapeAnswer<O>;
523
+ }
524
+
525
+ private async scrapeAnswer(config: ScrapeConfig): Promise<ScrapeResult | Response> {
521
526
  log.debug('scraping', { method: config.method, url: config.url });
522
527
  let response;
523
528
  try {
@@ -136,23 +136,18 @@ export type CrawlerConfigOptions = {
136
136
  * The Unblocker (anti-bot bypass), the current name for what used to be
137
137
  * called `asp`. Sent in the `POST /crawl` body as `asp`; only the SDK-facing
138
138
  * name changed.
139
- *
140
- * @deprecated Use `proxy_pool` (`'unblocker_ultra'` for the Unblocker). The
141
- * migration guide covers requests written before the proxy pools:
142
- * https://scrapfly.io/new-pricing#legacy-spellings
143
139
  */
144
140
  unblocker?: boolean;
145
141
  /**
146
- * @deprecated Alias of {@link CrawlerConfigOptions.unblocker}: use
147
- * `proxy_pool` (`'unblocker_ultra'` for the Unblocker). When both are
142
+ * @deprecated Use {@link CrawlerConfigOptions.unblocker}. `asp` is a
143
+ * permanently supported alias and keeps working forever. When both are
148
144
  * supplied `asp` wins, so existing code cannot have its meaning changed by a
149
145
  * later `unblocker`.
150
146
  */
151
147
  asp?: boolean;
152
148
  /**
153
- * Proxy pool for every crawled page: `basic`, `unblocker`, `unblocker_ultra`
154
- * or `auto` (see ScrapeConfig.BASIC), each of which sets the Unblocker
155
- * itself.
149
+ * Proxy pool for every crawled page: `public_datacenter_pool` (the default),
150
+ * `public_residential_pool` or `public_tor_pool`.
156
151
  */
157
152
  proxy_pool?: string;
158
153
  country?: string;
@@ -222,7 +217,7 @@ export class CrawlerConfig {
222
217
  * Storage for the anti-bot bypass toggle, under its deprecated name.
223
218
  * `unblocker` is an accessor over this same field — see below.
224
219
  *
225
- * @deprecated Use `proxy_pool` (`'unblocker_ultra'` for the Unblocker).
220
+ * @deprecated Use {@link CrawlerConfig.unblocker}. `asp` keeps working forever.
226
221
  */
227
222
  asp?: boolean;
228
223
  proxy_pool?: string;
@@ -362,9 +357,6 @@ export class CrawlerConfig {
362
357
 
363
358
  /**
364
359
  * The Unblocker toggle, the current name for what used to be `asp`.
365
- * Deprecated: use `proxy_pool` (`'unblocker_ultra'` for the Unblocker). The
366
- * migration guide covers requests written before the proxy pools:
367
- * https://scrapfly.io/new-pricing#legacy-spellings
368
360
  *
369
361
  * An accessor over the single `asp` field rather than a second stored
370
362
  * property: one storage slot means the two names can never disagree, and
package/src/main.ts CHANGED
@@ -13,9 +13,9 @@
13
13
  * const client = new ScrapflyClient({ key: 'your-api-key' });
14
14
  * const result = await client.scrape(new ScrapeConfig({
15
15
  * url: 'https://web-scraping.dev/products',
16
- * proxy_pool: ScrapeConfig.UNBLOCKER,
16
+ * unblocker: true,
17
17
  * }));
18
- * console.log(result.content);
18
+ * console.log(result.result.content);
19
19
  * ```
20
20
  *
21
21
  * See the [Scrapfly docs](https://scrapfly.io/docs) for the full API
@@ -30,6 +30,7 @@ export {
30
30
  ScrapeConfig,
31
31
  ScreenshotFlags,
32
32
  } from './scrapeconfig.js';
33
+ export type { ScrapeAnswer, ScrapeConfigOptions } from './scrapeconfig.js';
33
34
  export {
34
35
  Format as ScreenshotFormat,
35
36
  Options as ScreenshotOptions,
package/src/result.ts CHANGED
@@ -17,13 +17,7 @@ export type ConfigData = {
17
17
  debug: boolean;
18
18
  raise_on_upstream_error: boolean;
19
19
  cache_ttl: number;
20
- /**
21
- * The pool the request asked for, the way the account reads it: Tor reads `public_tor_pool` and one of the
22
- * account's own pools its name. Otherwise, when the Unblocker ran (asked, or forced by a target that requires
23
- * it), `basic` and `unblocker` read `unblocker` and any other pool `unblocker_ultra`. Without the Unblocker a
24
- * Scrapfly pool reads by its network (`basic`, `unblocker`, `mobile`, `isp`) and any other name as sent.
25
- * `context.proxy.pool` reads the same.
26
- */
20
+ /** The proxy pool the request ran on. */
27
21
  proxy_pool: string;
28
22
  session?: string;
29
23
  tags: Set<string>;
@@ -81,7 +75,7 @@ export type ContextData = {
81
75
  country: string;
82
76
  identity: string;
83
77
  network: string;
84
- /** The same name as {@link ConfigData.proxy_pool}. */
78
+ /** The proxy pool the request ran on. */
85
79
  pool: string;
86
80
  };
87
81
  redirects: Array<string>;
@@ -166,6 +160,8 @@ export type ResultData = {
166
160
  retryable: boolean;
167
161
  doc_url?: string;
168
162
  };
163
+ /** Present when the scrape ran an extraction (`extraction_model`, `extraction_prompt` or a template). */
164
+ extracted_data?: { data: any; content_type: string; data_quality?: any } | null;
169
165
  format: string;
170
166
  iframes: Array<{
171
167
  url: string;
@@ -2,6 +2,7 @@ import { urlsafe_b64encode } from './utils.js';
2
2
  import { log } from './logger.js';
3
3
  import type { HttpMethod, Rec } from './types.js';
4
4
  import { ScrapeConfigError } from './errors.js';
5
+ import type { ScrapeResult } from './result.js';
5
6
 
6
7
  export enum ScreenshotFlags {
7
8
  /**
@@ -43,7 +44,7 @@ export enum FormatOption {
43
44
  ONLY_CONTENT = 'only_content',
44
45
  }
45
46
 
46
- type ScrapeConfigOptions = {
47
+ export type ScrapeConfigOptions = {
47
48
  url: string;
48
49
  retry?: boolean;
49
50
  method?: HttpMethod;
@@ -58,30 +59,21 @@ type ScrapeConfigOptions = {
58
59
  * The Unblocker (anti-bot bypass), the current name for what used to be
59
60
  * called `asp`. Sent to the API as the `asp` query parameter; only the
60
61
  * SDK-facing name changed.
61
- *
62
- * @deprecated Use `proxy_pool` (`ScrapeConfig.UNBLOCKER_ULTRA` for the
63
- * Unblocker). The migration guide covers requests written before the proxy
64
- * pools: https://scrapfly.io/new-pricing#legacy-spellings
65
62
  */
66
63
  unblocker?: boolean;
67
64
  /**
68
- * @deprecated Alias of {@link unblocker}: use `proxy_pool`
69
- * (`ScrapeConfig.UNBLOCKER_ULTRA` for the Unblocker). When both are supplied
70
- * `asp` wins, so existing code cannot have its meaning changed by a later
71
- * `unblocker`.
65
+ * @deprecated Use {@link unblocker}. `asp` is a permanently supported alias
66
+ * and keeps working forever. When both are supplied `asp` wins, so existing
67
+ * code cannot have its meaning changed by a later `unblocker`.
72
68
  */
73
69
  asp?: boolean;
74
70
  debug?: boolean;
75
71
  raise_on_upstream_error?: boolean;
76
72
  cache_ttl?: number;
77
73
  /**
78
- * Proxy pool: `basic` (datacenter proxies, Unblocker off), `unblocker`
79
- * (residential proxies and the Unblocker), `unblocker_ultra` (residential
80
- * proxies and the Unblocker, the only pool accepted by the targets and
81
- * anti-bot protections that have a price of their own: they refuse `basic`
82
- * and `unblocker` with `ERR::PROXY::UNBLOCKER_ULTRA_REQUIRED`) or `auto`
83
- * (the API picks the pool from the target's profile), see
84
- * {@link ScrapeConfig.BASIC}. Each sets the Unblocker itself.
74
+ * Proxy pool: `ScrapeConfig.PUBLIC_DATACENTER_POOL` (the default),
75
+ * `ScrapeConfig.PUBLIC_RESIDENTIAL_POOL` or `ScrapeConfig.PUBLIC_TOR_POOL`.
76
+ * The anti-bot bypass is a parameter of its own: {@link unblocker}.
85
77
  */
86
78
  proxy_pool?: string;
87
79
  session?: string;
@@ -135,23 +127,57 @@ type ScrapeConfigOptions = {
135
127
  geolocation?: string;
136
128
  };
137
129
 
138
- export class ScrapeConfig {
139
- // Proxy pools, sent as `proxy_pool`. Each sets both the proxies and the
140
- // Unblocker. AUTO lets the API pick the pool before the request, from the
141
- // target's profile: the Unblocker on datacenter proxies, or the pool the
142
- // target needs, priced as the pool it runs on.
143
- static BASIC = 'basic';
144
- static UNBLOCKER = 'unblocker';
145
- static UNBLOCKER_ULTRA = 'unblocker_ultra';
146
- static AUTO = 'auto';
130
+ /**
131
+ * An option the constructor does not take: a typo fails to compile, as the constructor refuses it when it
132
+ * runs. Options built with an index signature (computed keys) are left to that runtime check.
133
+ */
134
+ type NoExtraOptions<O> = string extends keyof O ? unknown
135
+ : { [K in Exclude<keyof O, keyof ScrapeConfigOptions>]: never };
147
136
 
148
- // The Tor network, the only pool that reaches .onion hidden services.
149
- static PUBLIC_TOR_POOL = 'public_tor_pool';
137
+ /**
138
+ * `proxified_response` as options `O` set it: `false` when absent, `boolean` when unknown (`any`, a variable, an
139
+ * optional key, options that are a union of literals from a ternary or a conditional spread).
140
+ */
141
+ type ProxifiedOf<O> = 0 extends (1 & O) ? boolean
142
+ : O extends unknown ? (
143
+ 'proxified_response' extends keyof O
144
+ ? ({} extends Pick<O, 'proxified_response' & keyof O> ? false : never)
145
+ | KnownBoolean<Exclude<O['proxified_response' & keyof O], undefined>>
146
+ : false
147
+ )
148
+ : never;
149
+
150
+ /** `any` (an `undefined` value without strict null checks widens to it) says nothing: `boolean`. */
151
+ type KnownBoolean<V> = 0 extends (1 & V) ? boolean : V;
152
+
153
+ /**
154
+ * What `ScrapflyClient.scrape` answers for a config built from options `O`: the raw `Response` with
155
+ * `proxified_response: true`, a `ScrapeResult` without it or with `false`, either one when the options
156
+ * do not say which (a `boolean` variable, `any`, or a config typed as plain `ScrapeConfig`).
157
+ */
158
+ export type ScrapeAnswer<O> = [ProxifiedOf<O>] extends [never] ? ScrapeResult
159
+ : [ProxifiedOf<O>] extends [true] ? Response
160
+ : [ProxifiedOf<O>] extends [false] ? ScrapeResult
161
+ : ScrapeResult | Response;
150
162
 
151
- // Pool names written before the proxy pools, still accepted. The migration
152
- // guide covers them: https://scrapfly.io/new-pricing#legacy-spellings
163
+ /**
164
+ * `O` is the options the config was built from, inferred by `new ScrapeConfig({...})`: it only types what
165
+ * `ScrapflyClient.scrape` answers. A plain `ScrapeConfig` takes any of them and answers either one; type a
166
+ * variable that holds both proxified and plain configs as plain `ScrapeConfig`.
167
+ */
168
+ export class ScrapeConfig<O extends ScrapeConfigOptions = ScrapeConfigOptions> {
169
+ // Proxy pools, sent as `proxy_pool`. Datacenter proxies are the default.
153
170
  static PUBLIC_DATACENTER_POOL = 'public_datacenter_pool';
154
171
  static PUBLIC_RESIDENTIAL_POOL = 'public_residential_pool';
172
+ // The Tor network, the only pool that reaches .onion hidden services.
173
+ static PUBLIC_TOR_POOL = 'public_tor_pool';
174
+
175
+ // Pool names the API does not accept yet: a request naming one fails with
176
+ // ERR::PROXY::POOL_NOT_FOUND.
177
+ static BASIC = 'basic';
178
+ static UNBLOCKER = 'unblocker';
179
+ static UNBLOCKER_ULTRA = 'unblocker_ultra';
180
+ static AUTO = 'auto';
155
181
 
156
182
  url: string;
157
183
  retry = true;
@@ -167,19 +193,15 @@ export class ScrapeConfig {
167
193
  * Storage for the anti-bot bypass toggle, under its deprecated name.
168
194
  * `unblocker` is an accessor over this same field — see below.
169
195
  *
170
- * @deprecated Use `proxy_pool` (`ScrapeConfig.UNBLOCKER_ULTRA` for the Unblocker).
196
+ * @deprecated Use {@link ScrapeConfig.unblocker}. `asp` keeps working forever.
171
197
  */
172
198
  asp = false;
173
199
  debug = false;
174
200
  raise_on_upstream_error = true;
175
201
  cache_ttl?: number;
176
202
  /**
177
- * Proxy pool: `basic` (datacenter proxies, Unblocker off), `unblocker`
178
- * (residential proxies and the Unblocker), `unblocker_ultra` (residential
179
- * proxies and the Unblocker, the only pool accepted by the targets and
180
- * anti-bot protections that have a price of their own) or `auto` (the API
181
- * picks the pool from the target's profile), see {@link ScrapeConfig.BASIC}.
182
- * Each sets the Unblocker itself.
203
+ * Proxy pool: `ScrapeConfig.PUBLIC_DATACENTER_POOL` (the default),
204
+ * `ScrapeConfig.PUBLIC_RESIDENTIAL_POOL` or `ScrapeConfig.PUBLIC_TOR_POOL`.
183
205
  */
184
206
  proxy_pool?: string;
185
207
  session?: string;
@@ -213,7 +235,10 @@ export class ScrapeConfig {
213
235
  rendering_stage?: 'complete' | 'domcontentloaded';
214
236
  geolocation?: string;
215
237
 
216
- constructor(options: ScrapeConfigOptions) {
238
+ /** Type-level only, never defined: carries `O` to `ScrapflyClient.scrape`. A method, so configs of any options stay assignable to each other. */
239
+ __options?(options: O): void;
240
+
241
+ constructor(options: O & NoExtraOptions<O>) {
217
242
  this.validateOptions(options);
218
243
  if (options.format && !Object.values(Format).includes(options.format as Format)) {
219
244
  throw new ScrapeConfigError(`Invalid Format param value: ${options.format}`);
@@ -314,9 +339,6 @@ export class ScrapeConfig {
314
339
 
315
340
  /**
316
341
  * The Unblocker toggle, the current name for what used to be `asp`.
317
- * Deprecated: use `proxy_pool` (`ScrapeConfig.UNBLOCKER_ULTRA` for the
318
- * Unblocker). The migration guide covers requests written before the proxy
319
- * pools: https://scrapfly.io/new-pricing#legacy-spellings
320
342
  *
321
343
  * An accessor over the single `asp` field rather than a second stored
322
344
  * property: one storage slot means the two names can never disagree, so
@@ -84,9 +84,8 @@ type ScreenshotConfigOptions = {
84
84
  /** Webhook name to notify when the screenshot completes. */
85
85
  webhook?: string;
86
86
  /**
87
- * Proxy pool: `basic`, `unblocker`, `unblocker_ultra` or `auto` (see
88
- * `ScrapeConfig.BASIC`); any other value is ignored here. Unset, the API's
89
- * screenshot defaults apply. The screenshot price is the same on every pool.
87
+ * Sent as `proxy_pool`. The Screenshot API picks its pool itself and ignores
88
+ * this value.
90
89
  */
91
90
  proxy_pool?: string;
92
91
  };
@@ -119,7 +118,7 @@ export class ScreenshotConfig {
119
118
  cache_clear?: boolean;
120
119
  vision_deficiency?: 'deuteranopia' | 'protanopia' | 'tritanopia' | 'achromatopsia' | 'blurredVision' | 'reducedContrast' | VisionDeficiency;
121
120
  webhook?: string;
122
- /** Proxy pool: `basic`, `unblocker`, `unblocker_ultra` or `auto`; any other value is ignored here. */
121
+ /** Sent as `proxy_pool`; the Screenshot API picks its pool itself and ignores it. */
123
122
  proxy_pool?: string;
124
123
 
125
124
  constructor(options: ScreenshotConfigOptions) {