zenrows 2.0.3 → 2.2.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.
- package/README.md +105 -0
- package/dist/index.cjs +299 -27
- package/dist/index.d.cts +251 -17
- package/dist/index.d.ts +251 -17
- package/dist/index.js +296 -27
- package/package.json +7 -2
- package/tsconfig.test.json +9 -0
- package/vitest.config.ts +2 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,29 @@
|
|
|
1
1
|
import * as fetch_retry from 'fetch-retry';
|
|
2
2
|
import fastq from 'fastq';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* A server-extensible string enum: the listed values autocomplete, but the server may
|
|
6
|
+
* return values not listed (the Batch API marks these `x-extensible-enum`). Response fields
|
|
7
|
+
* use `Extensible<...>`, so callers must handle an unknown value. The named types stay closed
|
|
8
|
+
* so they keep working as request input.
|
|
9
|
+
*/
|
|
10
|
+
type Extensible<T extends string> = T | (string & {});
|
|
4
11
|
type JobType = "regular" | "scheduled";
|
|
5
12
|
type JobStatus = "open" | "closed" | "deleted";
|
|
6
13
|
type ScheduleState = "active" | "paused";
|
|
7
14
|
type RunStatus = "pending" | "running" | "completed" | "failed" | "stopped" | "deleted";
|
|
8
|
-
type TaskStatus = "pending" | "successful" | "failed";
|
|
15
|
+
type TaskStatus = "pending" | "processing" | "successful" | "failed";
|
|
9
16
|
type PauseState = "active" | "paused";
|
|
10
17
|
type IngestStatus = "pending" | "done";
|
|
11
18
|
type ExportStatus = "pending" | "running" | "completed" | "failed";
|
|
19
|
+
/**
|
|
20
|
+
* Why a run auto-failed (`status == "failed"`).
|
|
21
|
+
* - `insufficient_credits` — the account is out of credits.
|
|
22
|
+
* - `subscription_inactive` — the subscription is not active.
|
|
23
|
+
* - `api_key_cap_reached` — the job's API key reached one of its credit caps; resolves when
|
|
24
|
+
* that cap's window resets or the cap is raised. `Run.failure_detail` says which.
|
|
25
|
+
*/
|
|
26
|
+
type RunFailureReason = "insufficient_credits" | "subscription_inactive" | "api_key_cap_reached";
|
|
12
27
|
interface Spend {
|
|
13
28
|
credits: number;
|
|
14
29
|
cost: number;
|
|
@@ -53,19 +68,21 @@ interface Run {
|
|
|
53
68
|
run_id: string;
|
|
54
69
|
job_id: string;
|
|
55
70
|
run_sequence: number;
|
|
56
|
-
status: RunStatus
|
|
71
|
+
status: Extensible<RunStatus>;
|
|
57
72
|
stats: RunStats;
|
|
58
73
|
last_batch_received?: boolean;
|
|
59
74
|
pause_state?: PauseState;
|
|
60
|
-
ingest_status?: IngestStatus
|
|
61
|
-
failure_reason?:
|
|
75
|
+
ingest_status?: Extensible<IngestStatus>;
|
|
76
|
+
failure_reason?: Extensible<RunFailureReason>;
|
|
77
|
+
/** Human-readable explanation of `failure_reason` (e.g. which cap, and when it resets, UTC). */
|
|
78
|
+
failure_detail?: string | null;
|
|
62
79
|
created_at?: string;
|
|
63
80
|
updated_at?: string;
|
|
64
81
|
}
|
|
65
82
|
interface Job {
|
|
66
83
|
job_id: string;
|
|
67
84
|
type: JobType;
|
|
68
|
-
status: JobStatus
|
|
85
|
+
status: Extensible<JobStatus>;
|
|
69
86
|
format?: string;
|
|
70
87
|
zenrows_params?: Record<string, string>;
|
|
71
88
|
external_id?: string;
|
|
@@ -89,19 +106,19 @@ interface ListJobRunsResponse {
|
|
|
89
106
|
}
|
|
90
107
|
interface SubmitJobResponse {
|
|
91
108
|
job_id: string;
|
|
92
|
-
status: JobStatus
|
|
109
|
+
status: Extensible<JobStatus>;
|
|
93
110
|
latest_run?: Run;
|
|
94
111
|
accepted_tasks: number;
|
|
95
112
|
webhook?: WebhookConfig;
|
|
96
113
|
}
|
|
97
114
|
interface AddTasksResponse {
|
|
98
115
|
accepted_tasks: number;
|
|
99
|
-
job_status: JobStatus
|
|
116
|
+
job_status: Extensible<JobStatus>;
|
|
100
117
|
latest_run: Run;
|
|
101
118
|
}
|
|
102
119
|
interface RerunJobResponse {
|
|
103
120
|
job_id: string;
|
|
104
|
-
status: JobStatus
|
|
121
|
+
status: Extensible<JobStatus>;
|
|
105
122
|
latest_run: Run;
|
|
106
123
|
rerun_of?: string;
|
|
107
124
|
retried_tasks: number;
|
|
@@ -122,7 +139,7 @@ interface TaskResult {
|
|
|
122
139
|
url: string;
|
|
123
140
|
metadata?: Record<string, string>;
|
|
124
141
|
method?: "GET" | "POST";
|
|
125
|
-
status: TaskStatus
|
|
142
|
+
status: Extensible<TaskStatus>;
|
|
126
143
|
type?: string;
|
|
127
144
|
result_url?: string;
|
|
128
145
|
error?: ProblemJson;
|
|
@@ -145,13 +162,13 @@ interface TaskHistoryResponse {
|
|
|
145
162
|
}
|
|
146
163
|
interface StartExportResponse {
|
|
147
164
|
export_id: string;
|
|
148
|
-
status: ExportStatus
|
|
165
|
+
status: Extensible<ExportStatus>;
|
|
149
166
|
created_at: string;
|
|
150
167
|
expires_at: string;
|
|
151
168
|
}
|
|
152
169
|
interface Export {
|
|
153
170
|
export_id: string;
|
|
154
|
-
status: ExportStatus
|
|
171
|
+
status: Extensible<ExportStatus>;
|
|
155
172
|
error?: string;
|
|
156
173
|
download_url?: string;
|
|
157
174
|
created_at: string;
|
|
@@ -350,7 +367,7 @@ declare class RunRef {
|
|
|
350
367
|
declare class RunHandle extends RunRef {
|
|
351
368
|
readonly data: Run;
|
|
352
369
|
constructor(client: ZenRowsBatchClient, jobId: string, runId: string, data: Run);
|
|
353
|
-
get status(): RunStatus
|
|
370
|
+
get status(): Extensible<RunStatus>;
|
|
354
371
|
get stats(): RunStats;
|
|
355
372
|
}
|
|
356
373
|
declare class ExportRef {
|
|
@@ -372,7 +389,7 @@ declare class ExportRef {
|
|
|
372
389
|
declare class ExportHandle extends ExportRef {
|
|
373
390
|
readonly data: Export;
|
|
374
391
|
constructor(client: ZenRowsBatchClient, jobId: string, runId: string, exportId: string, data: Export, startResponse?: StartExportResponse);
|
|
375
|
-
get status(): ExportStatus
|
|
392
|
+
get status(): Extensible<ExportStatus>;
|
|
376
393
|
}
|
|
377
394
|
/** Operations on a job's CURRENT run, reached via `job.run`. */
|
|
378
395
|
declare class CurrentRun {
|
|
@@ -431,7 +448,7 @@ declare class JobRef {
|
|
|
431
448
|
/** Operations on the schedule — pause/resume/update (scheduled jobs only). */
|
|
432
449
|
get schedule(): ScheduleControls;
|
|
433
450
|
/** The job status from the submit response — only known on refs from a `submit*` call. */
|
|
434
|
-
get status(): JobStatus | undefined;
|
|
451
|
+
get status(): Extensible<JobStatus> | undefined;
|
|
435
452
|
get acceptedTasks(): number | undefined;
|
|
436
453
|
load(): Promise<JobHandle>;
|
|
437
454
|
close(): Promise<JobHandle>;
|
|
@@ -449,7 +466,7 @@ declare class JobRef {
|
|
|
449
466
|
lastBatch?: boolean;
|
|
450
467
|
}): Promise<{
|
|
451
468
|
accepted_tasks: number;
|
|
452
|
-
job_status: JobStatus
|
|
469
|
+
job_status: Extensible<JobStatus>;
|
|
453
470
|
latest_run: Run;
|
|
454
471
|
}>;
|
|
455
472
|
runs(pageSize?: number): AsyncGenerator<RunHandle>;
|
|
@@ -475,7 +492,7 @@ declare class JobRef {
|
|
|
475
492
|
declare class JobHandle extends JobRef {
|
|
476
493
|
readonly data: Job;
|
|
477
494
|
constructor(client: ZenRowsBatchClient, jobId: string, data: Job, submitResponse?: SubmitJobResponse);
|
|
478
|
-
get status(): JobStatus
|
|
495
|
+
get status(): Extensible<JobStatus>;
|
|
479
496
|
}
|
|
480
497
|
|
|
481
498
|
interface BatchClientConfig {
|
|
@@ -531,7 +548,16 @@ interface GetResultsOptions {
|
|
|
531
548
|
}
|
|
532
549
|
interface WaitForRunOptions {
|
|
533
550
|
runId?: string;
|
|
551
|
+
/**
|
|
552
|
+
* Statuses that resolve the wait. Defaults to every terminal status (`completed`,
|
|
553
|
+
* `stopped`, `failed`, `deleted`), so an auto-failed run resolves with its
|
|
554
|
+
* `failure_reason` / `failure_detail` instead of polling until `timeout`.
|
|
555
|
+
*/
|
|
534
556
|
targetStatuses?: Set<string>;
|
|
557
|
+
/**
|
|
558
|
+
* Statuses that reject with `WaiterFailureError`. Takes precedence over `targetStatuses`,
|
|
559
|
+
* so `new Set(["failed"])` makes a failed run throw. Empty by default.
|
|
560
|
+
*/
|
|
535
561
|
failureStatuses?: Set<string>;
|
|
536
562
|
timeout?: number;
|
|
537
563
|
pollInterval?: number;
|
|
@@ -541,6 +567,8 @@ type TaskInput = string | {
|
|
|
541
567
|
url: string;
|
|
542
568
|
external_id?: string;
|
|
543
569
|
metadata?: Record<string, unknown>;
|
|
570
|
+
/** Per-task scrape params, merged over the job-level `zenrowsParams` (task wins). */
|
|
571
|
+
zenrows_params?: Record<string, unknown>;
|
|
544
572
|
};
|
|
545
573
|
/**
|
|
546
574
|
* Client for the Zenrows Batch API (async, job/run/task model). Usable standalone
|
|
@@ -683,6 +711,187 @@ declare class ZenRowsBatchClient {
|
|
|
683
711
|
}): Promise<Job>;
|
|
684
712
|
}
|
|
685
713
|
|
|
714
|
+
/** `running` until the crawl ends; the other three are terminal. */
|
|
715
|
+
type CrawlStatus = "running" | "completed" | "stopped" | "failed";
|
|
716
|
+
/** What ended a crawl early: a limit (`status: completed`) or `stop()` (`status: stopped`). */
|
|
717
|
+
type CrawlStopReason = "max_items" | "max_pages" | "user";
|
|
718
|
+
/** Why a crawl failed (`status: failed`). */
|
|
719
|
+
type CrawlErrorCode = "insufficient_credits" | "seed_unreachable" | "domain_not_allowed" | "no_items_found" | "internal_error";
|
|
720
|
+
/** Where a kept URL's page stands, when the crawl has an `output_format`. */
|
|
721
|
+
type CrawlContentStatus = "pending" | "fetched" | "failed";
|
|
722
|
+
/** Return each kept URL's page as fetched. Absent means URLs only. */
|
|
723
|
+
type CrawlOutputFormat = "html";
|
|
724
|
+
interface CrawlCoverage {
|
|
725
|
+
pages_fetched: number;
|
|
726
|
+
pages_failed: number;
|
|
727
|
+
items_found: number;
|
|
728
|
+
}
|
|
729
|
+
/** Why a crawl failed. Part of the crawl, not an error response. */
|
|
730
|
+
interface CrawlRunError {
|
|
731
|
+
code: Extensible<CrawlErrorCode>;
|
|
732
|
+
detail: string;
|
|
733
|
+
}
|
|
734
|
+
interface Crawl {
|
|
735
|
+
crawl_id: string;
|
|
736
|
+
status: Extensible<CrawlStatus>;
|
|
737
|
+
url: string;
|
|
738
|
+
/** The depth limit the crawl was created with. Absent when it was created without one: no depth limit. */
|
|
739
|
+
depth?: number;
|
|
740
|
+
max_items: number;
|
|
741
|
+
max_pages: number;
|
|
742
|
+
coverage: CrawlCoverage;
|
|
743
|
+
created_at: string;
|
|
744
|
+
stop_reason?: Extensible<CrawlStopReason>;
|
|
745
|
+
error?: CrawlRunError;
|
|
746
|
+
include_patterns?: string[];
|
|
747
|
+
exclude_patterns?: string[];
|
|
748
|
+
output_format?: Extensible<CrawlOutputFormat>;
|
|
749
|
+
duplicates_removed?: number;
|
|
750
|
+
/** Absent while the crawl runs. */
|
|
751
|
+
finished_at?: string;
|
|
752
|
+
}
|
|
753
|
+
interface CrawlResult {
|
|
754
|
+
url: string;
|
|
755
|
+
content_status?: Extensible<CrawlContentStatus>;
|
|
756
|
+
/** The page's path, e.g. `/v1/crawls/c_x/contents/ct_y`. Present when `content_status` is `fetched`. */
|
|
757
|
+
content_url?: string;
|
|
758
|
+
}
|
|
759
|
+
interface CrawlWithResults extends Crawl {
|
|
760
|
+
results: CrawlResult[];
|
|
761
|
+
/** Never null while the crawl runs; null once it ended and this page holds its last URLs. */
|
|
762
|
+
next_cursor: string | null;
|
|
763
|
+
}
|
|
764
|
+
interface CrawlList {
|
|
765
|
+
crawls: Crawl[];
|
|
766
|
+
/** Absent on the last page. */
|
|
767
|
+
next_cursor?: string;
|
|
768
|
+
}
|
|
769
|
+
/** What `stop()` returns: where the crawl stands, without counts. */
|
|
770
|
+
interface CrawlStop {
|
|
771
|
+
crawl_id: string;
|
|
772
|
+
status: Extensible<CrawlStatus>;
|
|
773
|
+
stop_reason?: Extensible<CrawlStopReason>;
|
|
774
|
+
error?: CrawlRunError;
|
|
775
|
+
finished_at?: string;
|
|
776
|
+
}
|
|
777
|
+
/** One line of a crawl's download. */
|
|
778
|
+
interface CrawlExportLine {
|
|
779
|
+
url: string;
|
|
780
|
+
content_status?: Extensible<CrawlContentStatus>;
|
|
781
|
+
/** The page, present when `content_status` is `fetched`: HTML text, or an object for a JSON crawl. */
|
|
782
|
+
content?: string | Record<string, unknown>;
|
|
783
|
+
}
|
|
784
|
+
/** What `download()` returns. */
|
|
785
|
+
interface CrawlDownload {
|
|
786
|
+
/**
|
|
787
|
+
* The crawl's status when the file was read (`X-Crawl-Status`; undefined without it).
|
|
788
|
+
* `running` means a later download may hold more lines.
|
|
789
|
+
*/
|
|
790
|
+
status: Extensible<CrawlStatus> | undefined;
|
|
791
|
+
lines: AsyncIterable<CrawlExportLine>;
|
|
792
|
+
}
|
|
793
|
+
|
|
794
|
+
interface CrawlClientConfig {
|
|
795
|
+
/** Override the Crawl API base URL. Default `https://api.zenrows.com/v1`. */
|
|
796
|
+
baseURL?: string;
|
|
797
|
+
/**
|
|
798
|
+
* Retries for transient failures (502/503/504, network errors, 429 on reads) on idempotent
|
|
799
|
+
* requests, and for a `stop()` answered 429, 502, 503 or 504. Default 3.
|
|
800
|
+
*/
|
|
801
|
+
retries?: number;
|
|
802
|
+
/** Seconds each HTTP request may take. Default 30. Does not limit reading a `download()` body. */
|
|
803
|
+
timeout?: number;
|
|
804
|
+
}
|
|
805
|
+
interface CreateCrawlParams {
|
|
806
|
+
/** The page the crawl starts from: an absolute public `http`/`https` URL. */
|
|
807
|
+
url: string;
|
|
808
|
+
/**
|
|
809
|
+
* Link hops to follow from the start URL, 1–100000. Omit it for no depth limit: the crawl
|
|
810
|
+
* follows links until `maxPages` or `maxItems` stops it, or no link is left to open.
|
|
811
|
+
*/
|
|
812
|
+
depth?: number;
|
|
813
|
+
/** Stop once this many URLs are kept, 1–100000. Server default 100. */
|
|
814
|
+
maxItems?: number;
|
|
815
|
+
/** Stop once this many pages are fetched, 1–100000; bounds the cost. Server default 100. */
|
|
816
|
+
maxPages?: number;
|
|
817
|
+
/** Keep a URL only if it contains at least one of these substrings. */
|
|
818
|
+
includePatterns?: string[];
|
|
819
|
+
/** Drop a URL that contains any of these substrings, even if it matches an include pattern. */
|
|
820
|
+
excludePatterns?: string[];
|
|
821
|
+
/** Also fetch each kept URL's page. Absent means URLs only. */
|
|
822
|
+
outputFormat?: CrawlOutputFormat;
|
|
823
|
+
}
|
|
824
|
+
interface WaitForCrawlOptions {
|
|
825
|
+
/** Seconds to poll before returning the crawl as it stands. Default 600. */
|
|
826
|
+
timeout?: number;
|
|
827
|
+
}
|
|
828
|
+
/**
|
|
829
|
+
* Client for the Zenrows Crawl API (new): give it one start URL, read back the URLs behind it.
|
|
830
|
+
* Usable standalone (`new ZenRowsCrawlClient(apiKey)`) or via `client.crawl` on a `ZenRows`
|
|
831
|
+
* instance. A crawl runs asynchronously: `create()` returns at once, `wait()` polls until it
|
|
832
|
+
* ends, and `results()` / `download()` read what it kept.
|
|
833
|
+
* Crawl is still evolving: new features are coming, limits may be tuned, and the changelog announces each change.
|
|
834
|
+
*/
|
|
835
|
+
declare class ZenRowsCrawlClient {
|
|
836
|
+
readonly apiKey: string;
|
|
837
|
+
private readonly transport;
|
|
838
|
+
private readonly retries;
|
|
839
|
+
constructor(apiKey: string, config?: CrawlClientConfig);
|
|
840
|
+
/**
|
|
841
|
+
* Start a crawl. Sends only the fields you set. With an `idempotencyKey`, a retry returns the
|
|
842
|
+
* crawl the first request created instead of starting another, and 5xx and network failures
|
|
843
|
+
* are retried. A 429 `too_many_crawls` is never retried: it throws `ZenRowsCrawlError` with
|
|
844
|
+
* `retryAfter` set.
|
|
845
|
+
*/
|
|
846
|
+
create(params: CreateCrawlParams, opts?: {
|
|
847
|
+
idempotencyKey?: string;
|
|
848
|
+
}): Promise<Crawl>;
|
|
849
|
+
/** Read a crawl's status, coverage and one page of results (`limit` 1–10000, default 1000). */
|
|
850
|
+
get(crawlId: string, options?: {
|
|
851
|
+
cursor?: string;
|
|
852
|
+
limit?: number;
|
|
853
|
+
}): Promise<CrawlWithResults>;
|
|
854
|
+
/** One page of the account's crawls, newest first (`limit` 1–100, default 20). */
|
|
855
|
+
list(options?: {
|
|
856
|
+
cursor?: string;
|
|
857
|
+
limit?: number;
|
|
858
|
+
}): Promise<CrawlList>;
|
|
859
|
+
/**
|
|
860
|
+
* Every URL the crawl kept, following `next_cursor` (`limit` is the page size). On a running
|
|
861
|
+
* crawl it yields the URLs kept so far and returns at the first empty page; it does not poll.
|
|
862
|
+
* Call `wait()` first to read every result.
|
|
863
|
+
*/
|
|
864
|
+
results(crawlId: string, options?: {
|
|
865
|
+
limit?: number;
|
|
866
|
+
}): AsyncGenerator<CrawlResult>;
|
|
867
|
+
/**
|
|
868
|
+
* Stop a running crawl. Idempotent: a crawl that already ended answers as it ended.
|
|
869
|
+
* Because a stop is safe to repeat, `stop()` retries a 429, 502, 503 (including `crawl_busy`,
|
|
870
|
+
* which means the stop was not saved and the crawl is still running) or 504 up to `retries`
|
|
871
|
+
* times, waiting `Retry-After` seconds (at most 30; 1 when the header is missing or unusable)
|
|
872
|
+
* each time, then throws the last error.
|
|
873
|
+
*/
|
|
874
|
+
stop(crawlId: string): Promise<CrawlStop>;
|
|
875
|
+
/**
|
|
876
|
+
* One kept URL's page as fetched (HTML). Pass the content id, a `content_url`, or the
|
|
877
|
+
* `CrawlResult` itself (its `content_url` is present once `content_status` is `fetched`).
|
|
878
|
+
* Throws `TypeError` when no content id can be read.
|
|
879
|
+
*/
|
|
880
|
+
content(crawlId: string, contentId: string | CrawlResult): Promise<string>;
|
|
881
|
+
/**
|
|
882
|
+
* Every result of the crawl in one download: its `status` and the parsed lines (with the
|
|
883
|
+
* page when the crawl has an `output_format`). On a running crawl, `status` is `running` and
|
|
884
|
+
* the lines hold only what was kept so far.
|
|
885
|
+
*/
|
|
886
|
+
download(crawlId: string): Promise<CrawlDownload>;
|
|
887
|
+
/**
|
|
888
|
+
* Poll until the crawl ends (any status but `running`) or `timeout` seconds pass, and return
|
|
889
|
+
* it, without results. A `failed` crawl resolves too: read `error`. On timeout the crawl is
|
|
890
|
+
* returned with status `running` and keeps running.
|
|
891
|
+
*/
|
|
892
|
+
wait(crawlId: string, options?: WaitForCrawlOptions): Promise<Crawl>;
|
|
893
|
+
}
|
|
894
|
+
|
|
686
895
|
/**
|
|
687
896
|
* A non-2xx response from the Batch API, decoded as RFC 7807 `application/problem+json`
|
|
688
897
|
* where possible. `code` is the stable Problem `code` member (e.g. `file_input_not_found`) —
|
|
@@ -731,12 +940,35 @@ interface PollUntilOptions<T> {
|
|
|
731
940
|
*/
|
|
732
941
|
declare function pollUntil<T>(fetch: () => Promise<T> | T, { isDone, isFailure, timeout, initialInterval, maxInterval, backoff, jitter, }: PollUntilOptions<T>): Promise<T>;
|
|
733
942
|
|
|
943
|
+
/**
|
|
944
|
+
* The API's code for an account Crawl is not enabled on (403).
|
|
945
|
+
*/
|
|
946
|
+
declare const CRAWL_NOT_ENABLED_CODE = "REQS008";
|
|
947
|
+
/**
|
|
948
|
+
* A non-2xx response from the Crawl API, decoded as RFC 9457 `application/problem+json`
|
|
949
|
+
* where possible. Branch on `status` and `code` (e.g. `crawl_not_found`, `too_many_crawls`,
|
|
950
|
+
* or `REQS008` when Crawl is not enabled for the account); `code` is undefined when the body
|
|
951
|
+
* has none.
|
|
952
|
+
*/
|
|
953
|
+
declare class ZenRowsCrawlError extends Error {
|
|
954
|
+
readonly status: number;
|
|
955
|
+
readonly problem: ProblemJson | undefined;
|
|
956
|
+
readonly code: string | undefined;
|
|
957
|
+
readonly detail: string | undefined;
|
|
958
|
+
readonly extras: Record<string, unknown> | undefined;
|
|
959
|
+
/** Seconds from the `Retry-After` header, e.g. 30 on a 429 `too_many_crawls`. */
|
|
960
|
+
readonly retryAfter: number | undefined;
|
|
961
|
+
constructor(status: number, problem: ProblemJson | undefined, extras?: Record<string, unknown>, retryAfter?: number);
|
|
962
|
+
}
|
|
963
|
+
|
|
734
964
|
type HttpMethods = "GET" | "POST" | "PUT";
|
|
735
965
|
/** Extract mode — see https://docs.zenrows.com for what each mode returns. */
|
|
736
966
|
type ExtractMode = "auto" | "native" | "standard";
|
|
737
967
|
interface ClientConfig {
|
|
738
968
|
concurrency?: number;
|
|
739
969
|
retries?: number;
|
|
970
|
+
/** Config for `client.crawl`: its own `baseURL`, `retries` and `timeout`. */
|
|
971
|
+
crawl?: CrawlClientConfig;
|
|
740
972
|
}
|
|
741
973
|
interface ZenRowsConfig {
|
|
742
974
|
/** Set to "auto" to enable Adaptive Stealth Mode — Zenrows starts with the cheapest
|
|
@@ -774,6 +1006,8 @@ declare class ZenRows {
|
|
|
774
1006
|
readonly fetchWithRetry: (input: string | URL | Request, init?: (RequestInit & fetch_retry.RequestInitRetryParams<typeof fetch>) | undefined) => Promise<Response>;
|
|
775
1007
|
/** Client for the Batch API (async job/run/task model) — see `./batch.ts`. */
|
|
776
1008
|
readonly batch: ZenRowsBatchClient;
|
|
1009
|
+
/** Client for the Crawl API (new; one start URL in, the URLs behind it out). See `./crawl/client.ts`. */
|
|
1010
|
+
readonly crawl: ZenRowsCrawlClient;
|
|
777
1011
|
constructor(apiKey: string, clientConfig?: ClientConfig);
|
|
778
1012
|
/**
|
|
779
1013
|
* Fetch a URL through Zenrows — the main page-scraping product. This is the primary entry
|
|
@@ -816,4 +1050,4 @@ declare class ZenRows {
|
|
|
816
1050
|
private worker;
|
|
817
1051
|
}
|
|
818
1052
|
|
|
819
|
-
export { AUTO_MAX_CREDITS, AUTO_MIN_CREDITS, type AddTasksResponse, At, BASE_CREDITS, type BatchClientConfig, type BatchTask, type BatchWebhookConfig, type Cadence, Calendar, type CostEstimate, type CostLine, type CreateJobInputResponse, CurrentRun, DEFAULT_MAX_BYTES_PER_FILE, DEFAULT_MAX_COUNT_IN_MEMORY, DEFAULT_MAX_FILES, DEFAULT_MAX_TOTAL_BYTES_IN_MEMORY, Daily, type DownloadToDirOptions, type DownloadToMemoryOptions, type DownloadedResult, type EstimateTask, type Export, ExportHandle, ExportRef, type ExportStatus, type ExtractMode, type FileInputUploadTarget, type GetResultsOptions, type HMACKeyCreated, type HMACKeyFinalized, type HMACKeyList, type HMACKeyMeta, type IngestStatus, JS_AND_PROXY_CREDITS, JS_CREDITS, type Job, JobHandle, JobRef, type JobSchedule, type JobStatus, type JobType, type ListJobRunsResponse, type ListJobsOptions, type ListJobsResponse, type ListResultsResponse, Monthly, PREMIUM_PROXY_CREDITS, type ParamMap, type ParamValue, type PauseState, type PollUntilOptions, type ProblemJson, Rate, type RerunJobResponse, type Run, RunHandle, RunRef, type RunStats, type RunStatus, type Schedule, type ScheduleState, type Spend, type StartExportResponse, type SubmitJobOptions, type SubmitJobResponse, type SubmitTypedOptions, type TaskHistoryEvent, type TaskHistoryResponse, type TaskLike, type TaskResult, type TaskSpend, type TaskStatus, type TestWebhookResponse, type Tier, type WaitForRunOptions, WaiterFailureError, WaiterTimeoutError, type WebhookConfig, Weekly, ZenRows, ZenRowsBatchClient, ZenRowsBatchError, type ZenRowsConfig, downloadTaskToFile, downloadTaskToMemory, downloadToDir, downloadToMemory, estimateCost, parseProblem, pollUntil };
|
|
1053
|
+
export { AUTO_MAX_CREDITS, AUTO_MIN_CREDITS, type AddTasksResponse, At, BASE_CREDITS, type BatchClientConfig, type BatchTask, type BatchWebhookConfig, CRAWL_NOT_ENABLED_CODE, type Cadence, Calendar, type CostEstimate, type CostLine, type Crawl, type CrawlClientConfig, type CrawlContentStatus, type CrawlCoverage, type CrawlDownload, type CrawlErrorCode, type CrawlExportLine, type CrawlList, type CrawlOutputFormat, type CrawlResult, type CrawlRunError, type CrawlStatus, type CrawlStop, type CrawlStopReason, type CrawlWithResults, type CreateCrawlParams, type CreateJobInputResponse, CurrentRun, DEFAULT_MAX_BYTES_PER_FILE, DEFAULT_MAX_COUNT_IN_MEMORY, DEFAULT_MAX_FILES, DEFAULT_MAX_TOTAL_BYTES_IN_MEMORY, Daily, type DownloadToDirOptions, type DownloadToMemoryOptions, type DownloadedResult, type EstimateTask, type Export, ExportHandle, ExportRef, type ExportStatus, type Extensible, type ExtractMode, type FileInputUploadTarget, type GetResultsOptions, type HMACKeyCreated, type HMACKeyFinalized, type HMACKeyList, type HMACKeyMeta, type IngestStatus, JS_AND_PROXY_CREDITS, JS_CREDITS, type Job, JobHandle, JobRef, type JobSchedule, type JobStatus, type JobType, type ListJobRunsResponse, type ListJobsOptions, type ListJobsResponse, type ListResultsResponse, Monthly, PREMIUM_PROXY_CREDITS, type ParamMap, type ParamValue, type PauseState, type PollUntilOptions, type ProblemJson, Rate, type RerunJobResponse, type Run, type RunFailureReason, RunHandle, RunRef, type RunStats, type RunStatus, type Schedule, type ScheduleState, type Spend, type StartExportResponse, type SubmitJobOptions, type SubmitJobResponse, type SubmitTypedOptions, type TaskHistoryEvent, type TaskHistoryResponse, type TaskLike, type TaskResult, type TaskSpend, type TaskStatus, type TestWebhookResponse, type Tier, type WaitForCrawlOptions, type WaitForRunOptions, WaiterFailureError, WaiterTimeoutError, type WebhookConfig, Weekly, ZenRows, ZenRowsBatchClient, ZenRowsBatchError, type ZenRowsConfig, ZenRowsCrawlClient, ZenRowsCrawlError, downloadTaskToFile, downloadTaskToMemory, downloadToDir, downloadToMemory, estimateCost, parseProblem, pollUntil };
|