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
@@ -1,3 +1,4 @@
1
+ import { ScrapflyCrawlerError } from './errors.js';
1
2
  import { writeFile } from './polyfill.js';
2
3
  /**
3
4
  * Pull a required field out of an API response body and fail loud if it's
@@ -76,6 +77,23 @@ export class CrawlerStatus {
76
77
  writable: true,
77
78
  value: void 0
78
79
  });
80
+ /**
81
+ * `null` unless the crawl was started with `search: true`. Polling this is
82
+ * the webhook-free way to learn when the index became queryable.
83
+ */
84
+ Object.defineProperty(this, "search", {
85
+ enumerable: true,
86
+ configurable: true,
87
+ writable: true,
88
+ value: void 0
89
+ });
90
+ /** `null` unless the crawl re-scrapes itself on a period. */
91
+ Object.defineProperty(this, "refresh", {
92
+ enumerable: true,
93
+ configurable: true,
94
+ writable: true,
95
+ value: void 0
96
+ });
79
97
  // Canonical API field name is `crawler_uuid`; accept short `uuid` as a
80
98
  // legacy fallback but throw if neither is present.
81
99
  if ('crawler_uuid' in data && typeof data.crawler_uuid === 'string' && data.crawler_uuid) {
@@ -111,6 +129,14 @@ export class CrawlerStatus {
111
129
  stop_time: optionalField(state, 'stop_time', 'number', 'CrawlerStatus.state'),
112
130
  stop_reason: optionalField(state, 'stop_reason', 'string', 'CrawlerStatus.state'),
113
131
  };
132
+ // Both blocks go through their field whitelist rather than a cast to the
133
+ // interface. A cast is a compile-time claim only: raw JSON rides through
134
+ // it, so a field the model never declared still reaches the caller and a
135
+ // field the model lost still looks decoded.
136
+ const search = optionalField(data, 'search', 'object', 'CrawlerStatus');
137
+ this.search = search ? parseCrawlerSearchState(search) : null;
138
+ const refresh = optionalField(data, 'refresh', 'object', 'CrawlerStatus');
139
+ this.refresh = refresh ? parseCrawlerRefreshState(refresh) : null;
114
140
  }
115
141
  /** True while the crawler is still working (PENDING or RUNNING). */
116
142
  get isRunning() {
@@ -136,6 +162,343 @@ export class CrawlerStatus {
136
162
  return this.state.urls_extracted > 0 ? (this.state.urls_visited / this.state.urls_extracted) * 100 : 0;
137
163
  }
138
164
  }
165
+ /** Pages a run actually touched. Zero means the site stood still. */
166
+ export function refreshChanged(entry) {
167
+ return (entry?.added ?? 0) + (entry?.updated ?? 0) + (entry?.removed ?? 0);
168
+ }
169
+ /**
170
+ * Normalize a refresh envelope.
171
+ *
172
+ * The three refresh endpoints answer with the state at the top level;
173
+ * `GET /status` nests it under `refresh`. Accepting both means the SDK never
174
+ * has to guess which call produced the payload.
175
+ *
176
+ * This is a field whitelist, not a spread: a key that is not named here never
177
+ * reaches the caller, whatever the interface declares.
178
+ */
179
+ export function parseCrawlerRefreshState(data) {
180
+ const block = data && typeof data.refresh === 'object' && data.refresh !== null ? data.refresh : data;
181
+ return {
182
+ enabled: block.enabled === true,
183
+ interval_seconds: typeof block.interval_seconds === 'number' ? block.interval_seconds : 0,
184
+ status: block.status ?? 'DISABLED',
185
+ generation: block.generation,
186
+ last_run_at: block.last_run_at ?? undefined,
187
+ next_run_at: block.next_run_at ?? undefined,
188
+ error: block.error ?? undefined,
189
+ started_at: block.started_at ?? undefined,
190
+ consecutive_failures: block.consecutive_failures ?? undefined,
191
+ history: Array.isArray(block.history) ? block.history : [],
192
+ };
193
+ }
194
+ /** True when the index can answer a query right now. */
195
+ export function isSearchable(state) {
196
+ return state?.status === 'READY' || state?.status === 'PARTIAL';
197
+ }
198
+ /**
199
+ * Normalize a search envelope.
200
+ *
201
+ * `GET /status` nests the block under `search` and so do the two search
202
+ * webhooks; taking the block on its own as well means a caller holding either
203
+ * envelope decodes the same way.
204
+ *
205
+ * This is a field whitelist, not a spread: a key that is not named here never
206
+ * reaches the caller, whatever the interface declares. `status` is the one
207
+ * field with no sane absent value, so a block without it reads as DISABLED.
208
+ */
209
+ export function parseCrawlerSearchState(data) {
210
+ const block = data && typeof data.search === 'object' && data.search !== null ? data.search : data;
211
+ return {
212
+ status: block.status ?? 'DISABLED',
213
+ manifest: block.manifest ?? undefined,
214
+ documents: block.documents ?? undefined,
215
+ vectors: block.vectors ?? undefined,
216
+ dropped: block.dropped ?? undefined,
217
+ queue_depth: block.queue_depth ?? undefined,
218
+ fragments: block.fragments ?? undefined,
219
+ error: block.error ?? undefined,
220
+ built_at: block.built_at ?? undefined,
221
+ index: block.index ?? undefined,
222
+ generation: block.generation ?? undefined,
223
+ };
224
+ }
225
+ /**
226
+ * Wraps the JSON response of `POST /crawl/search`.
227
+ *
228
+ * The envelope states its own completeness: `exact` with most crawls unopened
229
+ * is the normal outcome, because the fan-out proves via an admissible bound
230
+ * that the unopened crawls held nothing better. `partial` means the deadline
231
+ * cut the fan-out short.
232
+ *
233
+ * Strict on the fields the contract always carries, lenient on the rest, so
234
+ * drift in the ranking envelope surfaces at parse time rather than as an
235
+ * empty result list.
236
+ */
237
+ export class CrawlerSearchResponse {
238
+ constructor(data) {
239
+ Object.defineProperty(this, "query", {
240
+ enumerable: true,
241
+ configurable: true,
242
+ writable: true,
243
+ value: void 0
244
+ });
245
+ Object.defineProperty(this, "mode", {
246
+ enumerable: true,
247
+ configurable: true,
248
+ writable: true,
249
+ value: void 0
250
+ });
251
+ Object.defineProperty(this, "limit", {
252
+ enumerable: true,
253
+ configurable: true,
254
+ writable: true,
255
+ value: void 0
256
+ });
257
+ Object.defineProperty(this, "completeness", {
258
+ enumerable: true,
259
+ configurable: true,
260
+ writable: true,
261
+ value: void 0
262
+ });
263
+ Object.defineProperty(this, "results", {
264
+ enumerable: true,
265
+ configurable: true,
266
+ writable: true,
267
+ value: void 0
268
+ });
269
+ Object.defineProperty(this, "crawls", {
270
+ enumerable: true,
271
+ configurable: true,
272
+ writable: true,
273
+ value: void 0
274
+ });
275
+ Object.defineProperty(this, "skipped", {
276
+ enumerable: true,
277
+ configurable: true,
278
+ writable: true,
279
+ value: void 0
280
+ });
281
+ Object.defineProperty(this, "stats", {
282
+ enumerable: true,
283
+ configurable: true,
284
+ writable: true,
285
+ value: void 0
286
+ });
287
+ Object.defineProperty(this, "crawls_requested", {
288
+ enumerable: true,
289
+ configurable: true,
290
+ writable: true,
291
+ value: void 0
292
+ });
293
+ Object.defineProperty(this, "crawls_searched", {
294
+ enumerable: true,
295
+ configurable: true,
296
+ writable: true,
297
+ value: void 0
298
+ });
299
+ Object.defineProperty(this, "crawls_pruned_exact", {
300
+ enumerable: true,
301
+ configurable: true,
302
+ writable: true,
303
+ value: void 0
304
+ });
305
+ /**
306
+ * The crawls the deadline cut, and the crawls whose index could not be read,
307
+ * named rather than counted: a caller told "3 failed" cannot retry them.
308
+ */
309
+ Object.defineProperty(this, "crawls_skipped_deadline", {
310
+ enumerable: true,
311
+ configurable: true,
312
+ writable: true,
313
+ value: void 0
314
+ });
315
+ Object.defineProperty(this, "crawls_failed", {
316
+ enumerable: true,
317
+ configurable: true,
318
+ writable: true,
319
+ value: void 0
320
+ });
321
+ /**
322
+ * `null` until a crawl has actually been opened. Zero is a different claim:
323
+ * it says the best unsearched score was 0, not that no bound exists.
324
+ */
325
+ Object.defineProperty(this, "theta", {
326
+ enumerable: true,
327
+ configurable: true,
328
+ writable: true,
329
+ value: void 0
330
+ });
331
+ Object.defineProperty(this, "max_ub_unsearched", {
332
+ enumerable: true,
333
+ configurable: true,
334
+ writable: true,
335
+ value: void 0
336
+ });
337
+ /**
338
+ * Opaque token for the next page, `null` on the last one. Paging is
339
+ * cursor-based: an offset over a partial fan-out would re-run the legs and
340
+ * shift ranks.
341
+ */
342
+ Object.defineProperty(this, "cursor", {
343
+ enumerable: true,
344
+ configurable: true,
345
+ writable: true,
346
+ value: void 0
347
+ });
348
+ this.query = requireField(data, 'query', 'string', 'CrawlerSearchResponse');
349
+ this.mode = requireField(data, 'mode', 'string', 'CrawlerSearchResponse');
350
+ this.limit = requireField(data, 'limit', 'number', 'CrawlerSearchResponse');
351
+ this.completeness = requireField(data, 'completeness', 'string', 'CrawlerSearchResponse');
352
+ const results = requireField(data, 'results', 'array', 'CrawlerSearchResponse');
353
+ this.results = results.map((r, i) => {
354
+ const context = `CrawlerSearchResponse.results[${i}]`;
355
+ return {
356
+ rank: requireField(r, 'rank', 'number', context),
357
+ score: requireField(r, 'score', 'number', context),
358
+ scores: optionalField(r, 'scores', 'object', context) ?? {},
359
+ crawler_uuid: requireField(r, 'crawler_uuid', 'string', context),
360
+ url: requireField(r, 'url', 'string', context),
361
+ title: optionalField(r, 'title', 'string', context),
362
+ source_format: optionalField(r, 'source_format', 'string', context),
363
+ content_type: optionalField(r, 'content_type', 'string', context),
364
+ chunk_id: requireField(r, 'chunk_id', 'number', context),
365
+ text: requireField(r, 'text', 'string', context),
366
+ warc_offset: optionalField(r, 'warc_offset', 'number', context),
367
+ warc_end: optionalField(r, 'warc_end', 'number', context),
368
+ contents_url: optionalField(r, 'contents_url', 'string', context),
369
+ };
370
+ });
371
+ this.crawls = optionalField(data, 'crawls', 'array', 'CrawlerSearchResponse') ?? [];
372
+ this.skipped = optionalField(data, 'skipped', 'array', 'CrawlerSearchResponse') ?? [];
373
+ this.stats = optionalField(data, 'stats', 'object', 'CrawlerSearchResponse') ?? {};
374
+ this.crawls_requested = optionalField(data, 'crawls_requested', 'number', 'CrawlerSearchResponse');
375
+ this.crawls_searched = optionalField(data, 'crawls_searched', 'number', 'CrawlerSearchResponse');
376
+ this.crawls_pruned_exact = optionalField(data, 'crawls_pruned_exact', 'number', 'CrawlerSearchResponse');
377
+ this.crawls_skipped_deadline = optionalField(data, 'crawls_skipped_deadline', 'array', 'CrawlerSearchResponse');
378
+ this.crawls_failed = optionalField(data, 'crawls_failed', 'array', 'CrawlerSearchResponse');
379
+ this.theta = optionalField(data, 'theta', 'number', 'CrawlerSearchResponse');
380
+ this.max_ub_unsearched = optionalField(data, 'max_ub_unsearched', 'number', 'CrawlerSearchResponse');
381
+ this.cursor = optionalField(data, 'cursor', 'string', 'CrawlerSearchResponse');
382
+ }
383
+ /** True when the ranking is provably complete for the requested crawls. */
384
+ get isExact() {
385
+ return this.completeness === 'exact';
386
+ }
387
+ }
388
+ /**
389
+ * Decode the `POST /crawl/prompt` SSE body into typed frames.
390
+ *
391
+ * Only `event:` and `data:` lines matter; `:keepalive` comment frames exist
392
+ * to keep intermediaries from closing an idle connection and carry nothing.
393
+ * Token payloads are JSON strings; every other frame is a JSON object.
394
+ *
395
+ * An `event: error` frame throws rather than yields: the caller is already
396
+ * inside a `for await` and a yielded error object is too easy to ignore after
397
+ * tokens have started arriving.
398
+ *
399
+ * Decoding is explicitly UTF-8 with `stream: true`, because a multi-byte
400
+ * character can straddle two chunks of the body.
401
+ * EOF before a complete `done` frame throws, even after tokens were delivered.
402
+ */
403
+ export async function* parseCrawlerPromptStream(body) {
404
+ const reader = body.getReader();
405
+ const decoder = new TextDecoder('utf-8');
406
+ let buffer = '';
407
+ let eventName = '';
408
+ let data = [];
409
+ const decodeFrame = (name, raw) => {
410
+ if (name === 'token') {
411
+ let token;
412
+ try {
413
+ token = JSON.parse(raw);
414
+ }
415
+ catch {
416
+ // A server sending bare text instead of a JSON string is still
417
+ // sending a token; do not drop the answer over the quoting.
418
+ token = raw;
419
+ }
420
+ return { event: 'token', data: token };
421
+ }
422
+ if (name === 'source') {
423
+ return { event: 'source', data: JSON.parse(raw) };
424
+ }
425
+ if (name === 'done') {
426
+ const payload = JSON.parse(raw);
427
+ // Build the public result explicitly: a TypeScript cast does not remove
428
+ // legacy model, token or provider-cost fields from the runtime object.
429
+ return {
430
+ event: 'done',
431
+ data: {
432
+ sources_used: optionalField(payload, 'sources_used', 'array', 'CrawlerPromptDone') ?? undefined,
433
+ sources_dropped: optionalField(payload, 'sources_dropped', 'number', 'CrawlerPromptDone') ?? undefined,
434
+ truncated: optionalField(payload, 'truncated', 'boolean', 'CrawlerPromptDone') ?? undefined,
435
+ api_credit: optionalField(payload, 'api_credit', 'number', 'CrawlerPromptDone') ?? undefined,
436
+ },
437
+ };
438
+ }
439
+ if (name === 'error') {
440
+ let payload = {};
441
+ try {
442
+ payload = JSON.parse(raw);
443
+ }
444
+ catch {
445
+ payload = { message: raw };
446
+ }
447
+ throw new ScrapflyCrawlerError(payload.message ?? raw, {
448
+ code: (payload.code ?? 'ERR::CRAWLER::UNKNOWN'),
449
+ });
450
+ }
451
+ return null;
452
+ };
453
+ try {
454
+ for (;;) {
455
+ const { done, value } = await reader.read();
456
+ if (value !== undefined) {
457
+ buffer += decoder.decode(value, { stream: true });
458
+ }
459
+ if (done) {
460
+ buffer += decoder.decode();
461
+ }
462
+ let newline = buffer.indexOf('\n');
463
+ while (newline !== -1) {
464
+ const line = buffer.slice(0, newline).replace(/\r$/, '');
465
+ buffer = buffer.slice(newline + 1);
466
+ newline = buffer.indexOf('\n');
467
+ if (line.startsWith(':'))
468
+ continue;
469
+ // A blank line terminates a frame.
470
+ if (line === '') {
471
+ if (eventName !== '' && data.length > 0) {
472
+ const event = decodeFrame(eventName, data.join('\n'));
473
+ if (event !== null) {
474
+ yield event;
475
+ if (event.event === 'done')
476
+ return;
477
+ }
478
+ }
479
+ eventName = '';
480
+ data = [];
481
+ continue;
482
+ }
483
+ if (line.startsWith('event:')) {
484
+ eventName = line.slice('event:'.length).trim();
485
+ }
486
+ else if (line.startsWith('data:')) {
487
+ data.push(line.slice('data:'.length).replace(/^ /, ''));
488
+ }
489
+ }
490
+ if (done) {
491
+ throw new ScrapflyCrawlerError('Prompt stream ended before the done frame', {
492
+ code: 'ERR::CRAWLER::PROMPT_GENERATION_FAILED',
493
+ });
494
+ }
495
+ }
496
+ }
497
+ finally {
498
+ // Covers both exhaustion and an early `break` out of the caller's loop.
499
+ await reader.cancel().catch(() => { });
500
+ }
501
+ }
139
502
  /**
140
503
  * Wraps the streaming text response of `GET /crawl/{uuid}/urls`.
141
504
  *
@@ -317,7 +680,10 @@ export function parseCrawlerWebhook(body) {
317
680
  event === 'crawler_url_visited' ||
318
681
  event === 'crawler_url_skipped' ||
319
682
  event === 'crawler_url_discovered' ||
320
- event === 'crawler_url_failed') {
683
+ event === 'crawler_url_failed' ||
684
+ event === 'crawler_search_ready' ||
685
+ event === 'crawler_search_failed' ||
686
+ event === 'crawler_updated') {
321
687
  // The body has already been validated to have an `event` and `payload`. The
322
688
  // narrower per-event field shapes are runtime-checked by the discriminated union
323
689
  // — TypeScript users get the typed view; runtime users get a permissive bag.
package/esm/errors.d.ts CHANGED
@@ -68,6 +68,18 @@ export declare class ScrapflyThrottleError extends HttpError {
68
68
  /** Raised when Scrapfly failed to bypass anti-scraping protection on the target. */
69
69
  export declare class ScrapflyAspError extends HttpError {
70
70
  }
71
+ /**
72
+ * Raised when the unblocker (formerly "ASP") could not get through the target's
73
+ * anti-bot protection.
74
+ *
75
+ * This is the SAME class as {@link ScrapflyAspError}, not a subclass and not a
76
+ * second class, so `instanceof ScrapflyUnblockerError` and `instanceof
77
+ * ScrapflyAspError` are interchangeable and customer code written against
78
+ * either name keeps working. The class is still selected by the literal `ASP`
79
+ * segment of the `ERR::ASP::*` codes the API sends.
80
+ */
81
+ export declare const ScrapflyUnblockerError: typeof ScrapflyAspError;
82
+ export type ScrapflyUnblockerError = ScrapflyAspError;
71
83
  /** Raised when a scheduled scrape cannot be created or fulfilled. */
72
84
  export declare class ScrapflyScheduleError extends HttpError {
73
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,qBAAa,aAAc,SAAQ,KAAK;IACtC,+FAA+F;IAC/F,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE1B;;;OAGG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;CAI5D;AAED,yEAAyE;AACzE,qBAAa,iBAAkB,SAAQ,aAAa;CAAG;AACvD,6EAA6E;AAC7E,qBAAa,qBAAsB,SAAQ,aAAa;CAAG;AAC3D,8EAA8E;AAC9E,qBAAa,qBAAsB,SAAQ,aAAa;CAAG;AAC3D,0EAA0E;AAC1E,qBAAa,kBAAmB,SAAQ,aAAa;CAAG;AAExD,sEAAsE;AACtE,qBAAa,WAAY,SAAQ,aAAa;CAAG;AACjD,gFAAgF;AAChF,qBAAa,gBAAiB,SAAQ,aAAa;CAAG;AAEtD,mEAAmE;AACnE,qBAAa,SAAU,SAAQ,aAAa;CAAG;AAC/C,qEAAqE;AACrE,qBAAa,iBAAkB,SAAQ,SAAS;CAAG;AACnD,mEAAmE;AACnE,qBAAa,uBAAwB,SAAQ,iBAAiB;CAAG;AACjE,mEAAmE;AACnE,qBAAa,uBAAwB,SAAQ,uBAAuB;CAAG;AAEvE,uEAAuE;AACvE,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,sFAAsF;AACtF,qBAAa,cAAe,SAAQ,kBAAkB;CAAG;AAEzD,0DAA0D;AAC1D,qBAAa,eAAgB,SAAQ,SAAS;CAAG;AACjD,gEAAgE;AAChE,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,6FAA6F;AAC7F,qBAAa,mBAAoB,SAAQ,SAAS;CAAG;AACrD,2GAA2G;AAC3G,qBAAa,kBAAmB,SAA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package/esm/errors.js CHANGED
@@ -76,6 +76,17 @@ export class ScrapflyThrottleError extends HttpError {
76
76
  /** Raised when Scrapfly failed to bypass anti-scraping protection on the target. */
77
77
  export class ScrapflyAspError extends HttpError {
78
78
  }
79
+ /**
80
+ * Raised when the unblocker (formerly "ASP") could not get through the target's
81
+ * anti-bot protection.
82
+ *
83
+ * This is the SAME class as {@link ScrapflyAspError}, not a subclass and not a
84
+ * second class, so `instanceof ScrapflyUnblockerError` and `instanceof
85
+ * ScrapflyAspError` are interchangeable and customer code written against
86
+ * either name keeps working. The class is still selected by the literal `ASP`
87
+ * segment of the `ERR::ASP::*` codes the API sends.
88
+ */
89
+ export const ScrapflyUnblockerError = ScrapflyAspError;
79
90
  /** Raised when a scheduled scrape cannot be created or fulfilled. */
80
91
  export class ScrapflyScheduleError extends HttpError {
81
92
  }
package/esm/main.d.ts CHANGED
@@ -14,7 +14,7 @@
14
14
  * const result = await client.scrape(new ScrapeConfig({
15
15
  * url: 'https://web-scraping.dev/products',
16
16
  * render_js: true,
17
- * asp: true,
17
+ * unblocker: true,
18
18
  * }));
19
19
  * console.log(result.content);
20
20
  * ```
@@ -38,11 +38,11 @@ export type { AccountData, ClassifyOptions, ClassifyResult, ConfigData, ContextD
38
38
  export { CrawlerConfig } from './crawlerconfig.js';
39
39
  export type { CrawlerConfigOptions, CrawlerContentFormat, CrawlerWebhookEventName } from './crawlerconfig.js';
40
40
  export { Crawl } from './crawl.js';
41
- export { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls, parseCrawlerWebhook, } from './crawlerresult.js';
42
- export type { CrawlerArtifactType, CrawlerLifecycleWebhook, CrawlerState, CrawlerStatusValue, CrawlerStopReason, CrawlerUrlDiscoveredWebhook, CrawlerUrlEntry, CrawlerUrlFailedWebhook, CrawlerUrlSkippedWebhook, CrawlerUrlVisitedWebhook, CrawlerWebhookCommon, CrawlerWebhookPayload, } from './crawlerresult.js';
41
+ export { CrawlerArtifact, CrawlerContents, CrawlerSearchResponse, CrawlerStatus, CrawlerUrls, isSearchable, parseCrawlerPromptStream, parseCrawlerRefreshState, parseCrawlerSearchState, parseCrawlerWebhook, refreshChanged, } from './crawlerresult.js';
42
+ export type { CrawlerArtifactType, CrawlerLifecycleWebhook, CrawlerPromptDone, CrawlerPromptEvent, CrawlerPromptSource, CrawlerRefreshEntry, CrawlerRefreshState, CrawlerRefreshStatus, CrawlerSearchCrawl, CrawlerSearchMode, CrawlerSearchResult, CrawlerSearchScores, CrawlerSearchSkipped, CrawlerSearchState, CrawlerSearchStats, CrawlerSearchStatus, CrawlerSearchWebhook, CrawlerSkipReason, CrawlerState, CrawlerStatusValue, CrawlerStopReason, CrawlerUpdatedWebhook, CrawlerUrlDiscoveredWebhook, CrawlerUrlEntry, CrawlerUrlFailedWebhook, CrawlerUrlSkippedWebhook, CrawlerUrlVisitedWebhook, CrawlerWebhookCommon, CrawlerWebhookPayload, } from './crawlerresult.js';
43
43
  export type { CloudBrowserMonitoringOptions, MonitoringAggregation, MonitoringDataFormat, MonitoringMetricsOptions, MonitoringPeriod, MonitoringTargetMetricsOptions, } from './monitoringconfig.js';
44
44
  export { ScheduleAPIError } from './schedule.js';
45
45
  export type { CreateScheduleRequest, ListSchedulesOptions, Schedule, ScheduleEnd, ScheduleRecurrence, UpdateScheduleRequest, } from './schedule.js';
46
46
  export { log } from './logger.js';
47
- export { createServer, verifySignature } from './webhookserver.js';
47
+ export { createServer, ResourceType, verifySignature } from './webhookserver.js';
48
48
  //# sourceMappingURL=main.d.ts.map
package/esm/main.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,m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AAe,EAAE,MAAM,oBAAoB,CAAC"}
package/esm/main.js CHANGED
@@ -14,7 +14,7 @@
14
14
  * const result = await client.scrape(new ScrapeConfig({
15
15
  * url: 'https://web-scraping.dev/products',
16
16
  * render_js: true,
17
- * asp: true,
17
+ * unblocker: true,
18
18
  * }));
19
19
  * console.log(result.content);
20
20
  * ```
@@ -35,7 +35,7 @@ export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
35
35
  // Crawler API
36
36
  export { CrawlerConfig } from './crawlerconfig.js';
37
37
  export { Crawl } from './crawl.js';
38
- export { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls, parseCrawlerWebhook, } from './crawlerresult.js';
38
+ export { CrawlerArtifact, CrawlerContents, CrawlerSearchResponse, CrawlerStatus, CrawlerUrls, isSearchable, parseCrawlerPromptStream, parseCrawlerRefreshState, parseCrawlerSearchState, parseCrawlerWebhook, refreshChanged, } from './crawlerresult.js';
39
39
  export { ScheduleAPIError } from './schedule.js';
40
40
  export { log } from './logger.js';
41
- export { createServer, verifySignature } from './webhookserver.js';
41
+ export { createServer, ResourceType, verifySignature } from './webhookserver.js';
@@ -47,6 +47,18 @@ type ScrapeConfigOptions = {
47
47
  cost_budget?: number;
48
48
  ssl?: boolean;
49
49
  dns?: boolean;
50
+ /**
51
+ * Anti-bot bypass. The current name for what used to be called `asp`.
52
+ * Sent to the API as the `asp` query parameter; only the SDK-facing name
53
+ * changed.
54
+ */
55
+ unblocker?: boolean;
56
+ /**
57
+ * @deprecated Use {@link unblocker}. `asp` is a permanently supported alias
58
+ * and keeps working forever; only the documented name changed. When both are
59
+ * supplied `asp` wins, so existing code cannot have its meaning changed by a
60
+ * later `unblocker`.
61
+ */
50
62
  asp?: boolean;
51
63
  debug?: boolean;
52
64
  raise_on_upstream_error?: boolean;
@@ -115,6 +127,12 @@ export declare class ScrapeConfig {
115
127
  cost_budget?: number;
116
128
  ssl: boolean;
117
129
  dns: boolean;
130
+ /**
131
+ * Storage for the anti-bot bypass toggle, under its deprecated name.
132
+ * `unblocker` is an accessor over this same field — see below.
133
+ *
134
+ * @deprecated Use {@link ScrapeConfig.unblocker}. `asp` keeps working forever.
135
+ */
118
136
  asp: boolean;
119
137
  debug: boolean;
120
138
  raise_on_upstream_error: boolean;
@@ -150,6 +168,24 @@ export declare class ScrapeConfig {
150
168
  rendering_stage?: 'complete' | 'domcontentloaded';
151
169
  geolocation?: string;
152
170
  constructor(options: ScrapeConfigOptions);
171
+ /**
172
+ * Anti-bot bypass toggle — the current name for what used to be `asp`.
173
+ *
174
+ * An accessor over the single `asp` field rather than a second stored
175
+ * property: one storage slot means the two names can never disagree, so
176
+ * `config.unblocker = true` after construction is exactly `config.asp = true`
177
+ * and `toApiParams` has one value to read. It also keeps `unblocker` out of
178
+ * the instance's own keys, so serializers that iterate them do not sprout a
179
+ * duplicate of `asp`.
180
+ */
181
+ get unblocker(): boolean;
182
+ set unblocker(value: boolean);
183
+ /**
184
+ * Option names the constructor accepts that are not own properties of the
185
+ * instance. `unblocker` is an accessor, so it lives on the prototype and the
186
+ * `Object.keys(this)` allow-list below never sees it.
187
+ */
188
+ private static readonly ALIAS_OPTION_KEYS;
153
189
  private validateOptions;
154
190
  toApiParams(options: {
155
191
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"scrapeconfig.d.ts","sourceRoot":"","sources":["../src/scrapeconfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGlD,oBAAY,eAAe;IACzB;;;;;;;QAOI;IACJ,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;CAC9B;AAED,uDAAuD;AACvD,oBAAY,MAAM;IAChB,uBAAuB;IACvB,IAAI,SAAS;IACb,uCAAuC;IACvC,IAAI,SAAS;IACb,sCAAsC;IACtC,QAAQ,aAAa;IACrB,gCAAgC;IAChC,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E,MAAM,EAAE,CAAC;IAChB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,eAAe,CAAC,EAAE,UAAU,GAAG,kBAAkB,CAAC;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;gBAET,OAAO,EAAE,mBAAmB;IAmGxC;;;;;;;;;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"}
@@ -103,6 +103,12 @@ export class ScrapeConfig {
103
103
  writable: true,
104
104
  value: false
105
105
  });
106
+ /**
107
+ * Storage for the anti-bot bypass toggle, under its deprecated name.
108
+ * `unblocker` is an accessor over this same field — see below.
109
+ *
110
+ * @deprecated Use {@link ScrapeConfig.unblocker}. `asp` keeps working forever.
111
+ */
106
112
  Object.defineProperty(this, "asp", {
107
113
  enumerable: true,
108
114
  configurable: true,
@@ -335,7 +341,11 @@ export class ScrapeConfig {
335
341
  this.cache = options.cache ?? this.cache;
336
342
  this.cache_clear = options.cache_clear ?? this.cache_clear;
337
343
  this.cost_budget = options.cost_budget ?? this.cost_budget;
338
- this.asp = options.asp ?? this.asp;
344
+ // `asp` is the deprecated alias of `unblocker` and an explicitly supplied
345
+ // `asp` always wins; `unblocker` applies only when `asp` was not supplied.
346
+ // `??` and not `||`, so an explicit `false` on either name turns the
347
+ // feature off instead of falling through to the other name.
348
+ this.asp = options.asp ?? options.unblocker ?? this.asp;
339
349
  this.headers = options.headers
340
350
  ? Object.fromEntries(Object.entries(options.headers).map(([k, v]) => [k.toLowerCase(), v]))
341
351
  : {};
@@ -400,10 +410,26 @@ export class ScrapeConfig {
400
410
  }
401
411
  }
402
412
  }
413
+ /**
414
+ * Anti-bot bypass toggle — the current name for what used to be `asp`.
415
+ *
416
+ * An accessor over the single `asp` field rather than a second stored
417
+ * property: one storage slot means the two names can never disagree, so
418
+ * `config.unblocker = true` after construction is exactly `config.asp = true`
419
+ * and `toApiParams` has one value to read. It also keeps `unblocker` out of
420
+ * the instance's own keys, so serializers that iterate them do not sprout a
421
+ * duplicate of `asp`.
422
+ */
423
+ get unblocker() {
424
+ return this.asp;
425
+ }
426
+ set unblocker(value) {
427
+ this.asp = value;
428
+ }
403
429
  validateOptions(options) {
404
430
  const validKeys = new Set(Object.keys(this));
405
431
  for (const key in options) {
406
- if (!validKeys.has(key)) {
432
+ if (!validKeys.has(key) && !ScrapeConfig.ALIAS_OPTION_KEYS.has(key)) {
407
433
  throw new ScrapeConfigError(`Invalid option provided: ${key}`);
408
434
  }
409
435
  }
@@ -502,6 +528,11 @@ export class ScrapeConfig {
502
528
  log.warn('Params "rendering_wait" is ignored. Works only if render_js is enabled');
503
529
  }
504
530
  }
531
+ // The wire key stays `asp` for both names. A published package version is
532
+ // immutable and upgraded per installation, so emitting `unblocker` against
533
+ // an API deployment that has not learned that name yet would silently drop
534
+ // a paid feature: the scrape succeeds, is billed, and returns a blocked
535
+ // page. Renaming the emitted key is a separate, later release.
505
536
  if (this.asp === true) {
506
537
  params.asp = true;
507
538
  }
@@ -603,3 +634,14 @@ Object.defineProperty(ScrapeConfig, "PUBLIC_TOR_POOL", {
603
634
  writable: true,
604
635
  value: 'public_tor_pool'
605
636
  });
637
+ /**
638
+ * Option names the constructor accepts that are not own properties of the
639
+ * instance. `unblocker` is an accessor, so it lives on the prototype and the
640
+ * `Object.keys(this)` allow-list below never sees it.
641
+ */
642
+ Object.defineProperty(ScrapeConfig, "ALIAS_OPTION_KEYS", {
643
+ enumerable: true,
644
+ configurable: true,
645
+ writable: true,
646
+ value: new Set(['unblocker'])
647
+ });