scrapfly-sdk 0.11.1 → 0.12.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 (68) hide show
  1. package/README.md +36 -3
  2. package/esm/browserconfig.d.ts +37 -5
  3. package/esm/browserconfig.d.ts.map +1 -1
  4. package/esm/browserconfig.js +51 -3
  5. package/esm/client.d.ts +118 -5
  6. package/esm/client.d.ts.map +1 -1
  7. package/esm/client.js +339 -38
  8. package/esm/crawl.d.ts +58 -1
  9. package/esm/crawl.d.ts.map +1 -1
  10. package/esm/crawl.js +55 -0
  11. package/esm/crawlerconfig.d.ts +41 -3
  12. package/esm/crawlerconfig.d.ts.map +1 -1
  13. package/esm/crawlerconfig.js +93 -2
  14. package/esm/crawlerresult.d.ts +335 -2
  15. package/esm/crawlerresult.d.ts.map +1 -1
  16. package/esm/crawlerresult.js +367 -1
  17. package/esm/errors.d.ts +12 -0
  18. package/esm/errors.d.ts.map +1 -1
  19. package/esm/errors.js +11 -0
  20. package/esm/main.d.ts +4 -4
  21. package/esm/main.d.ts.map +1 -1
  22. package/esm/main.js +3 -3
  23. package/esm/scrapeconfig.d.ts +36 -0
  24. package/esm/scrapeconfig.d.ts.map +1 -1
  25. package/esm/scrapeconfig.js +44 -2
  26. package/esm/types.d.ts.map +1 -1
  27. package/esm/webhookserver.d.ts +33 -15
  28. package/esm/webhookserver.d.ts.map +1 -1
  29. package/esm/webhookserver.js +197 -38
  30. package/package.json +1 -1
  31. package/script/browserconfig.d.ts +37 -5
  32. package/script/browserconfig.d.ts.map +1 -1
  33. package/script/browserconfig.js +51 -3
  34. package/script/client.d.ts +118 -5
  35. package/script/client.d.ts.map +1 -1
  36. package/script/client.js +338 -37
  37. package/script/crawl.d.ts +58 -1
  38. package/script/crawl.d.ts.map +1 -1
  39. package/script/crawl.js +55 -0
  40. package/script/crawlerconfig.d.ts +41 -3
  41. package/script/crawlerconfig.d.ts.map +1 -1
  42. package/script/crawlerconfig.js +94 -3
  43. package/script/crawlerresult.d.ts +335 -2
  44. package/script/crawlerresult.d.ts.map +1 -1
  45. package/script/crawlerresult.js +374 -2
  46. package/script/errors.d.ts +12 -0
  47. package/script/errors.d.ts.map +1 -1
  48. package/script/errors.js +12 -1
  49. package/script/main.d.ts +4 -4
  50. package/script/main.d.ts.map +1 -1
  51. package/script/main.js +9 -2
  52. package/script/scrapeconfig.d.ts +36 -0
  53. package/script/scrapeconfig.d.ts.map +1 -1
  54. package/script/scrapeconfig.js +44 -2
  55. package/script/types.d.ts.map +1 -1
  56. package/script/webhookserver.d.ts +33 -15
  57. package/script/webhookserver.d.ts.map +1 -1
  58. package/script/webhookserver.js +197 -38
  59. package/src/browserconfig.ts +52 -4
  60. package/src/client.ts +406 -38
  61. package/src/crawl.ts +74 -0
  62. package/src/crawlerconfig.ts +115 -5
  63. package/src/crawlerresult.ts +566 -3
  64. package/src/errors.ts +12 -0
  65. package/src/main.ts +25 -2
  66. package/src/scrapeconfig.ts +54 -2
  67. package/src/types.ts +0 -1
  68. package/src/webhookserver.ts +235 -39
package/script/crawl.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ScrapflyClient } from './client.js';
2
2
  import type { CrawlerConfig, CrawlerContentFormat } from './crawlerconfig.js';
3
- import type { CrawlerArtifact, CrawlerStatus, CrawlerUrls } from './crawlerresult.js';
3
+ import type { CrawlerArtifact, CrawlerPromptEvent, CrawlerRefreshEntry, CrawlerRefreshState, CrawlerSearchMode, CrawlerSearchResponse, CrawlerStatus, CrawlerUrls } from './crawlerresult.js';
4
4
  /**
5
5
  * High-level fluent wrapper around a single crawler job lifecycle.
6
6
  *
@@ -96,6 +96,63 @@ export declare class Crawl {
96
96
  page?: number;
97
97
  per_page?: number;
98
98
  }): Promise<CrawlerUrls>;
99
+ /**
100
+ * Search this crawl's index.
101
+ *
102
+ * Sugar over `client.crawlSearch([uuid], ...)`. The cross-crawl call is the
103
+ * real endpoint; both share its implementation so single and multi-crawl
104
+ * search cannot drift.
105
+ *
106
+ * Requires the crawl to have been started with `search: true` and its index
107
+ * to have reached `READY`/`PARTIAL`; poll `CrawlerStatus.search` or
108
+ * subscribe to the `crawler_search_ready` webhook. An index that is not
109
+ * ready yet is reported in the response's `skipped` list, not as an error.
110
+ */
111
+ search(query: string, opts?: {
112
+ limit?: number;
113
+ mode?: CrawlerSearchMode;
114
+ filters?: Record<string, any>;
115
+ cursor?: string;
116
+ }): Promise<CrawlerSearchResponse>;
117
+ /**
118
+ * Ask a question answered from this crawl's content.
119
+ *
120
+ * Sugar over `client.crawlPrompt([uuid], ...)`; yields the same frames.
121
+ */
122
+ prompt(prompt: string, opts?: {
123
+ search?: {
124
+ limit?: number;
125
+ mode?: CrawlerSearchMode;
126
+ filters?: Record<string, any>;
127
+ };
128
+ model?: string;
129
+ }): AsyncGenerator<CrawlerPromptEvent, void, undefined>;
130
+ /**
131
+ * Re-scrape this crawl's URLs in place, right now.
132
+ *
133
+ * Sugar over `client.crawlRefreshNow(uuid)`. The crawl keeps its uuid, its
134
+ * artifacts and its search index; only pages whose content changed are
135
+ * re-indexed and pages that disappeared are dropped.
136
+ */
137
+ refreshNow(): Promise<CrawlerRefreshState>;
138
+ /**
139
+ * Change this crawl's refresh schedule.
140
+ *
141
+ * Sugar over `client.crawlRefreshSettings(uuid, ...)`; only what is passed
142
+ * is changed.
143
+ */
144
+ refreshSettings(settings: {
145
+ enabled?: boolean;
146
+ interval_seconds?: number;
147
+ }): Promise<CrawlerRefreshState>;
148
+ /**
149
+ * Read this crawl's refresh timeline, newest last.
150
+ *
151
+ * Sugar over `client.crawlRefreshHistory(uuid, ...)`.
152
+ */
153
+ refreshHistory(opts?: {
154
+ limit?: number;
155
+ }): Promise<CrawlerRefreshEntry[]>;
99
156
  /**
100
157
  * Read raw content for a single crawled URL using `plain=true` mode.
101
158
  *
@@ -1 +1 @@
1
- {"version":3,"file":"crawl.d.ts","sourceRoot":"","sources":["../src/crawl.ts"],"names":[],"mappings":"AAEA,OAAO,K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OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;SAAE,CAAC;QACrF,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,GACA,cAAc,CAAC,kBAAkB,EAAE,IAAI,EAAE,SAAS,CAAC;IAKtD;;;;;;OAMG;IACG,UAAU,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAKhD;;;;;OAKG;IACG,eAAe,CAAC,QAAQ,EAAE;QAAE,OAAO,CAAC,EAAE,OAAO,CAAC;QAAC,gBAAgB,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC;IAK/G;;;;OAIG;IACG,cAAc,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAK/E;;;;;;OAMG;IACG,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,GAAE,oBAA6B,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAetF;;;;OAIG;IACG,SAAS,CACb,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,GAAE,oBAAoB,EAAa,GACzC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAKlD;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAStC;;OAEG;IACG,GAAG,IAAI,OAAO,CAAC,eAAe,CAAC;CAQtC"}
package/script/crawl.js CHANGED
@@ -202,6 +202,61 @@ class Crawl {
202
202
  const uuid = this.requireUuid();
203
203
  return await this.client.crawlUrls(uuid, opts);
204
204
  }
205
+ /**
206
+ * Search this crawl's index.
207
+ *
208
+ * Sugar over `client.crawlSearch([uuid], ...)`. The cross-crawl call is the
209
+ * real endpoint; both share its implementation so single and multi-crawl
210
+ * search cannot drift.
211
+ *
212
+ * Requires the crawl to have been started with `search: true` and its index
213
+ * to have reached `READY`/`PARTIAL`; poll `CrawlerStatus.search` or
214
+ * subscribe to the `crawler_search_ready` webhook. An index that is not
215
+ * ready yet is reported in the response's `skipped` list, not as an error.
216
+ */
217
+ async search(query, opts) {
218
+ const uuid = this.requireUuid();
219
+ return await this.client.crawlSearch([uuid], query, opts);
220
+ }
221
+ /**
222
+ * Ask a question answered from this crawl's content.
223
+ *
224
+ * Sugar over `client.crawlPrompt([uuid], ...)`; yields the same frames.
225
+ */
226
+ prompt(prompt, opts) {
227
+ const uuid = this.requireUuid();
228
+ return this.client.crawlPrompt([uuid], prompt, opts);
229
+ }
230
+ /**
231
+ * Re-scrape this crawl's URLs in place, right now.
232
+ *
233
+ * Sugar over `client.crawlRefreshNow(uuid)`. The crawl keeps its uuid, its
234
+ * artifacts and its search index; only pages whose content changed are
235
+ * re-indexed and pages that disappeared are dropped.
236
+ */
237
+ async refreshNow() {
238
+ const uuid = this.requireUuid();
239
+ return await this.client.crawlRefreshNow(uuid);
240
+ }
241
+ /**
242
+ * Change this crawl's refresh schedule.
243
+ *
244
+ * Sugar over `client.crawlRefreshSettings(uuid, ...)`; only what is passed
245
+ * is changed.
246
+ */
247
+ async refreshSettings(settings) {
248
+ const uuid = this.requireUuid();
249
+ return await this.client.crawlRefreshSettings(uuid, settings);
250
+ }
251
+ /**
252
+ * Read this crawl's refresh timeline, newest last.
253
+ *
254
+ * Sugar over `client.crawlRefreshHistory(uuid, ...)`.
255
+ */
256
+ async refreshHistory(opts) {
257
+ const uuid = this.requireUuid();
258
+ return await this.client.crawlRefreshHistory(uuid, opts);
259
+ }
205
260
  /**
206
261
  * Read raw content for a single crawled URL using `plain=true` mode.
207
262
  *
@@ -14,10 +14,15 @@ export type CrawlerContentFormat = 'html' | 'clean_html' | 'markdown' | 'text' |
14
14
  /**
15
15
  * Webhook event names emitted by the crawler.
16
16
  *
17
- * Source of truth: `apps/scrapfly/scrape-engine/scrape_engine/scrape_engine/crawler/webhook_manager.py`
18
- * lines 11-20. Verified to match the public docs and the JSON example payloads.
17
+ * Event names match the wire format documented in the Crawler API webhook reference.
18
+ * Verified against the public docs and the JSON example payloads.
19
19
  */
20
- export type CrawlerWebhookEventName = 'crawler_started' | 'crawler_url_visited' | 'crawler_url_skipped' | 'crawler_url_discovered' | 'crawler_url_failed' | 'crawler_stopped' | 'crawler_cancelled' | 'crawler_finished';
20
+ export type CrawlerWebhookEventName = 'crawler_started' | 'crawler_url_visited' | 'crawler_url_skipped' | 'crawler_url_discovered' | 'crawler_url_failed' | 'crawler_stopped' | 'crawler_cancelled' | 'crawler_finished' | 'crawler_search_ready' | 'crawler_search_failed' | 'crawler_updated';
21
+ /**
22
+ * Auto-refresh interval bounds, in seconds (1 hour to 90 days).
23
+ */
24
+ export declare const REFRESH_MIN_INTERVAL = 3600;
25
+ export declare const REFRESH_MAX_INTERVAL: number;
21
26
  /**
22
27
  * Constructor options for {@link CrawlerConfig}.
23
28
  *
@@ -52,6 +57,20 @@ export type CrawlerConfigOptions = {
52
57
  cache_clear?: boolean;
53
58
  content_formats?: CrawlerContentFormat[];
54
59
  extraction_rules?: Rec<any>;
60
+ search?: boolean;
61
+ refresh?: boolean;
62
+ refresh_interval?: number;
63
+ /**
64
+ * Anti-bot bypass. The current name for what used to be called `asp`.
65
+ * Sent in the `POST /crawl` body as `asp`; only the SDK-facing name changed.
66
+ */
67
+ unblocker?: boolean;
68
+ /**
69
+ * @deprecated Use {@link CrawlerConfigOptions.unblocker}. `asp` is a
70
+ * permanently supported alias and keeps working forever. When both are
71
+ * supplied `asp` wins, so existing code cannot have its meaning changed by a
72
+ * later `unblocker`.
73
+ */
55
74
  asp?: boolean;
56
75
  proxy_pool?: string;
57
76
  country?: string;
@@ -101,12 +120,31 @@ export declare class CrawlerConfig {
101
120
  cache_clear?: boolean;
102
121
  content_formats?: CrawlerContentFormat[];
103
122
  extraction_rules?: Rec<any>;
123
+ search?: boolean;
124
+ refresh?: boolean;
125
+ refresh_interval?: number;
126
+ /**
127
+ * Storage for the anti-bot bypass toggle, under its deprecated name.
128
+ * `unblocker` is an accessor over this same field — see below.
129
+ *
130
+ * @deprecated Use {@link CrawlerConfig.unblocker}. `asp` keeps working forever.
131
+ */
104
132
  asp?: boolean;
105
133
  proxy_pool?: string;
106
134
  country?: string;
107
135
  webhook_name?: string;
108
136
  webhook_events?: CrawlerWebhookEventName[];
109
137
  constructor(options: CrawlerConfigOptions);
138
+ /**
139
+ * Anti-bot bypass toggle — the current name for what used to be `asp`.
140
+ *
141
+ * An accessor over the single `asp` field rather than a second stored
142
+ * property: one storage slot means the two names can never disagree, and
143
+ * `toApiParams` keeps serializing the one field under the wire key `asp`.
144
+ * `undefined` propagates in both directions, so "unset" stays unset.
145
+ */
146
+ get unblocker(): boolean | undefined;
147
+ set unblocker(value: boolean | undefined);
110
148
  private validateOptions;
111
149
  /**
112
150
  * Serialize to a flat object suitable for `JSON.stringify()` as a `POST /crawl` body.
@@ -1 +1 @@
1
- {"version":3,"file":"crawlerconfig.d.ts","sourceRoot":"","sources":["../src/crawlerconfig.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,YAAY,GACZ,UAAU,GACV,MAAM,GACN,MAAM,GACN,gBAAgB,GAChB,eAAe,CAAC;AAYpB;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAC/B,iBAAiB,GACjB,qBAAqB,GACrB,qBAAqB,GACrB,wBAAwB,GACxB,oBAAoB,GACpB,iBAAiB,GACjB,mBAAmB,GACnB,kBAAkB,CAAC;AAavB;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG;IAIjC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IAGzB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAA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AAG,SAAS,CAEnC;IAED,IAAI,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,EAEvC;IAED,OAAO,CAAC,eAAe;IA8CvB;;;;;;;;;OASG;IACH,WAAW,IAAI,GAAG,CAAC,GAAG,CAAC;CAqExB"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CrawlerConfig = void 0;
3
+ exports.CrawlerConfig = exports.REFRESH_MAX_INTERVAL = exports.REFRESH_MIN_INTERVAL = void 0;
4
4
  const errors_js_1 = require("./errors.js");
5
5
  const VALID_CONTENT_FORMATS = new Set([
6
6
  'html',
@@ -11,6 +11,11 @@ const VALID_CONTENT_FORMATS = new Set([
11
11
  'extracted_data',
12
12
  'page_metadata',
13
13
  ]);
14
+ /**
15
+ * Auto-refresh interval bounds, in seconds (1 hour to 90 days).
16
+ */
17
+ exports.REFRESH_MIN_INTERVAL = 3600;
18
+ exports.REFRESH_MAX_INTERVAL = 90 * 24 * 3600;
14
19
  const VALID_WEBHOOK_EVENTS = new Set([
15
20
  'crawler_started',
16
21
  'crawler_url_visited',
@@ -20,6 +25,9 @@ const VALID_WEBHOOK_EVENTS = new Set([
20
25
  'crawler_stopped',
21
26
  'crawler_cancelled',
22
27
  'crawler_finished',
28
+ 'crawler_search_ready',
29
+ 'crawler_search_failed',
30
+ 'crawler_updated',
23
31
  ]);
24
32
  /**
25
33
  * Configuration for a Scrapfly Crawler API job.
@@ -200,6 +208,30 @@ class CrawlerConfig {
200
208
  writable: true,
201
209
  value: void 0
202
210
  });
211
+ Object.defineProperty(this, "search", {
212
+ enumerable: true,
213
+ configurable: true,
214
+ writable: true,
215
+ value: void 0
216
+ });
217
+ Object.defineProperty(this, "refresh", {
218
+ enumerable: true,
219
+ configurable: true,
220
+ writable: true,
221
+ value: void 0
222
+ });
223
+ Object.defineProperty(this, "refresh_interval", {
224
+ enumerable: true,
225
+ configurable: true,
226
+ writable: true,
227
+ value: void 0
228
+ });
229
+ /**
230
+ * Storage for the anti-bot bypass toggle, under its deprecated name.
231
+ * `unblocker` is an accessor over this same field — see below.
232
+ *
233
+ * @deprecated Use {@link CrawlerConfig.unblocker}. `asp` keeps working forever.
234
+ */
203
235
  Object.defineProperty(this, "asp", {
204
236
  enumerable: true,
205
237
  configurable: true,
@@ -285,6 +317,16 @@ class CrawlerConfig {
285
317
  if (options.allowed_internal_subdomains && options.allowed_internal_subdomains.length > 250) {
286
318
  throw new errors_js_1.CrawlerConfigError('allowed_internal_subdomains is limited to 250 entries');
287
319
  }
320
+ // The floor decides the cost: a crawl refreshing every minute re-scrapes
321
+ // the whole site 1,440 times a day.
322
+ if (options.refresh_interval !== undefined &&
323
+ (options.refresh_interval < exports.REFRESH_MIN_INTERVAL || options.refresh_interval > exports.REFRESH_MAX_INTERVAL)) {
324
+ throw new errors_js_1.CrawlerConfigError(`refresh_interval must be between ${exports.REFRESH_MIN_INTERVAL} and ${exports.REFRESH_MAX_INTERVAL} (seconds, 1 hour to 90 days)`);
325
+ }
326
+ // A period with the feature off would silently never run.
327
+ if (options.refresh_interval !== undefined && !options.refresh) {
328
+ throw new errors_js_1.CrawlerConfigError('refresh_interval requires refresh: true');
329
+ }
288
330
  // Validate content_formats values
289
331
  if (options.content_formats) {
290
332
  for (const fmt of options.content_formats) {
@@ -326,12 +368,34 @@ class CrawlerConfig {
326
368
  this.cache_clear = options.cache_clear;
327
369
  this.content_formats = options.content_formats;
328
370
  this.extraction_rules = options.extraction_rules;
329
- this.asp = options.asp;
371
+ this.search = options.search;
372
+ this.refresh = options.refresh;
373
+ this.refresh_interval = options.refresh_interval;
374
+ // An explicitly supplied `asp` always wins; the deprecated alias is only
375
+ // superseded by `unblocker` when it was not supplied at all. `??` and not
376
+ // `||`, so an explicit `false` on either name still reaches the server.
377
+ // Both unset stays `undefined`, which toApiParams drops so the server
378
+ // applies its own default.
379
+ this.asp = options.asp ?? options.unblocker;
330
380
  this.proxy_pool = options.proxy_pool;
331
381
  this.country = options.country;
332
382
  this.webhook_name = options.webhook_name;
333
383
  this.webhook_events = options.webhook_events;
334
384
  }
385
+ /**
386
+ * Anti-bot bypass toggle — the current name for what used to be `asp`.
387
+ *
388
+ * An accessor over the single `asp` field rather than a second stored
389
+ * property: one storage slot means the two names can never disagree, and
390
+ * `toApiParams` keeps serializing the one field under the wire key `asp`.
391
+ * `undefined` propagates in both directions, so "unset" stays unset.
392
+ */
393
+ get unblocker() {
394
+ return this.asp;
395
+ }
396
+ set unblocker(value) {
397
+ this.asp = value;
398
+ }
335
399
  validateOptions(options) {
336
400
  const validKeys = new Set([
337
401
  'url',
@@ -361,6 +425,10 @@ class CrawlerConfig {
361
425
  'cache_clear',
362
426
  'content_formats',
363
427
  'extraction_rules',
428
+ 'search',
429
+ 'refresh',
430
+ 'refresh_interval',
431
+ 'unblocker',
364
432
  'asp',
365
433
  'proxy_pool',
366
434
  'country',
@@ -413,7 +481,9 @@ class CrawlerConfig {
413
481
  'cache_clear',
414
482
  'content_formats',
415
483
  'extraction_rules',
416
- 'asp',
484
+ 'search',
485
+ 'refresh',
486
+ 'refresh_interval',
417
487
  'proxy_pool',
418
488
  'country',
419
489
  'webhook_name',
@@ -425,6 +495,27 @@ class CrawlerConfig {
425
495
  params[key] = v;
426
496
  }
427
497
  }
498
+ // The anti-bot toggle is serialized apart from the loop above because it is
499
+ // the one field where `false` and "not supplied" must collapse.
500
+ //
501
+ // The key is `asp` and never `unblocker`: the wire key is unchanged for
502
+ // both names. A published package version is immutable and upgraded per
503
+ // installation, so emitting `unblocker` against an API deployment that has
504
+ // not learned that name yet would silently drop a paid feature — the crawl
505
+ // runs, is billed, and comes back blocked. Renaming the emitted key is a
506
+ // separate, later release.
507
+ //
508
+ // Only `true` is emitted. CROSS-SDK SHAPE: the Python, Go and Rust SDKs all
509
+ // omit the key when the feature is off (Python's `asp` is a plain `bool`,
510
+ // Go's is a `bool`, Rust's carries `skip_serializing_if = "is_false"`), so
511
+ // carrying an explicit `asp: false` here would make the same customer
512
+ // intent produce two different POST /crawl bodies depending on which SDK
513
+ // they picked. The API cannot tell the two apart either: it resolves a
514
+ // present-false and an absent pair to the same `false`, so an explicit
515
+ // `asp: false` on the wire buys nothing. One shape, all four SDKs.
516
+ if (this.asp === true) {
517
+ params.asp = true;
518
+ }
428
519
  return params;
429
520
  }
430
521
  }