@scrapa/sdk 0.1.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/LICENSE +21 -0
- package/README.md +232 -0
- package/dist/client.d.ts +47 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +182 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +50 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +56 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated/contract.d.ts +470 -0
- package/dist/generated/contract.d.ts.map +1 -0
- package/dist/generated/contract.js +161 -0
- package/dist/generated/contract.js.map +1 -0
- package/dist/generated/operations.d.ts +213 -0
- package/dist/generated/operations.d.ts.map +1 -0
- package/dist/generated/operations.js +220 -0
- package/dist/generated/operations.js.map +1 -0
- package/dist/generated/params.d.ts +420 -0
- package/dist/generated/params.d.ts.map +1 -0
- package/dist/generated/params.js +7 -0
- package/dist/generated/params.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -0
- package/src/client.ts +227 -0
- package/src/errors.ts +83 -0
- package/src/generated/contract.ts +564 -0
- package/src/generated/operations.ts +293 -0
- package/src/generated/params.ts +437 -0
- package/src/index.ts +9 -0
|
@@ -0,0 +1,437 @@
|
|
|
1
|
+
// GENERATED FILE — do not edit. Run `bun run sdk:gen`.
|
|
2
|
+
// Source: apps/api/src/operations/*.ts (zod input schemas)
|
|
3
|
+
//
|
|
4
|
+
// What each call takes. These are the same schemas the API validates with, so a
|
|
5
|
+
// value TypeScript accepts here is a value the server accepts too.
|
|
6
|
+
|
|
7
|
+
/** Arguments for `scrape()`. */
|
|
8
|
+
export interface ScrapeParams {
|
|
9
|
+
/** The page to read. An http(s) URL — private and loopback hosts are refused. */
|
|
10
|
+
url: string;
|
|
11
|
+
/** How to read it. "fetch" is a plain HTTP request; "browser" renders the page in a real
|
|
12
|
+
* Chromium; "auto" fetches first and escalates to the browser when the body turns out to be a
|
|
13
|
+
* JavaScript shell, billing whichever engine answered. */
|
|
14
|
+
engine?: "auto" | "fetch" | "browser";
|
|
15
|
+
/** Whether to try again a different way when the first attempt is blocked. `false` stops after
|
|
16
|
+
* one try — the site's refusal is your answer, and it costs nothing. It is how you bound a
|
|
17
|
+
* call: with `auto`, trying again is what charges the browser price instead of the fetch one. */
|
|
18
|
+
escalate?: boolean;
|
|
19
|
+
/** How many extra tries to give a page the site blocks, each from a different address. 0 (the
|
|
20
|
+
* default) takes the site's first no as the answer. A blocked page costs nothing, so a try
|
|
21
|
+
* that is blocked again is free — but it takes as long as the first one did, so the call can
|
|
22
|
+
* run that many times longer. */
|
|
23
|
+
retry?: number;
|
|
24
|
+
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
25
|
+
* asking for both costs no more than one. */
|
|
26
|
+
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf")[];
|
|
27
|
+
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
28
|
+
* that comes back — a maintenance notice, a "checking your browser" page, a login form — is
|
|
29
|
+
* then not your answer. It costs nothing, and we try again from another address instead of
|
|
30
|
+
* handing you a page you cannot parse. Without it, whatever the page returns is your answer. */
|
|
31
|
+
expect?: "json";
|
|
32
|
+
/** Where the request leaves from. Defaults to the managed residential pool. */
|
|
33
|
+
proxy?: {
|
|
34
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
35
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
36
|
+
pool?: "residential" | "custom";
|
|
37
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
38
|
+
* for the managed one. */
|
|
39
|
+
server?: string;
|
|
40
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
41
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
42
|
+
* languages follow it on every pool. */
|
|
43
|
+
country?: string;
|
|
44
|
+
};
|
|
45
|
+
/** How to render it. Only the browser engine reads these — with `auto` they apply if the page
|
|
46
|
+
* turns out to need one. */
|
|
47
|
+
browser?: {
|
|
48
|
+
/** When the page counts as loaded. "load" (the default) waits for images and stylesheets;
|
|
49
|
+
* "domcontentloaded" is the fastest and stops at the HTML; "networkidle" waits until the
|
|
50
|
+
* page stops asking for things. Every page gets a short settle after this whichever you
|
|
51
|
+
* pick. */
|
|
52
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
53
|
+
/** Wait until this CSS selector is on the page — the dependable way to read something a
|
|
54
|
+
* script draws. If it never shows up the call comes back as a timeout at no charge, rather
|
|
55
|
+
* than the half-built page. */
|
|
56
|
+
waitForSelector?: string;
|
|
57
|
+
/** Wait this many milliseconds after the page settles, for the scripts no selector
|
|
58
|
+
* describes. It comes out of `timeoutMs`, never on top of it. */
|
|
59
|
+
waitMs?: number;
|
|
60
|
+
/** The window size the page is rendered in, 1280×800 unless you say. Set it when a site
|
|
61
|
+
* serves a different layout by width. */
|
|
62
|
+
viewport?: {
|
|
63
|
+
width: number;
|
|
64
|
+
height: number;
|
|
65
|
+
};
|
|
66
|
+
/** Screenshot the whole scrollable page instead of just the window. A long page makes a
|
|
67
|
+
* large answer — the image comes back as base64 inside the response. */
|
|
68
|
+
fullPage?: boolean;
|
|
69
|
+
};
|
|
70
|
+
/** Extra request headers to send to the page — an authorization token, a cookie, a custom user
|
|
71
|
+
* agent. The connection's own headers cannot be set. */
|
|
72
|
+
headers?: Record<string, string>;
|
|
73
|
+
/** How long to give the page before giving up, in milliseconds. A page that never arrives is a
|
|
74
|
+
* free outcome. */
|
|
75
|
+
timeoutMs?: number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Arguments for `quote()`. */
|
|
79
|
+
export interface QuoteScrapeParams {
|
|
80
|
+
/** The page to read. An http(s) URL — private and loopback hosts are refused. */
|
|
81
|
+
url: string;
|
|
82
|
+
/** How to read it. "fetch" is a plain HTTP request; "browser" renders the page in a real
|
|
83
|
+
* Chromium; "auto" fetches first and escalates to the browser when the body turns out to be a
|
|
84
|
+
* JavaScript shell, billing whichever engine answered. */
|
|
85
|
+
engine?: "auto" | "fetch" | "browser";
|
|
86
|
+
/** Whether to try again a different way when the first attempt is blocked. `false` stops after
|
|
87
|
+
* one try — the site's refusal is your answer, and it costs nothing. It is how you bound a
|
|
88
|
+
* call: with `auto`, trying again is what charges the browser price instead of the fetch one. */
|
|
89
|
+
escalate?: boolean;
|
|
90
|
+
/** How many extra tries to give a page the site blocks, each from a different address. 0 (the
|
|
91
|
+
* default) takes the site's first no as the answer. A blocked page costs nothing, so a try
|
|
92
|
+
* that is blocked again is free — but it takes as long as the first one did, so the call can
|
|
93
|
+
* run that many times longer. */
|
|
94
|
+
retry?: number;
|
|
95
|
+
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
96
|
+
* asking for both costs no more than one. */
|
|
97
|
+
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf")[];
|
|
98
|
+
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
99
|
+
* that comes back — a maintenance notice, a "checking your browser" page, a login form — is
|
|
100
|
+
* then not your answer. It costs nothing, and we try again from another address instead of
|
|
101
|
+
* handing you a page you cannot parse. Without it, whatever the page returns is your answer. */
|
|
102
|
+
expect?: "json";
|
|
103
|
+
/** Where the request leaves from. Defaults to the managed residential pool. */
|
|
104
|
+
proxy?: {
|
|
105
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
106
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
107
|
+
pool?: "residential" | "custom";
|
|
108
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
109
|
+
* for the managed one. */
|
|
110
|
+
server?: string;
|
|
111
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
112
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
113
|
+
* languages follow it on every pool. */
|
|
114
|
+
country?: string;
|
|
115
|
+
};
|
|
116
|
+
/** How to render it. Only the browser engine reads these — with `auto` they apply if the page
|
|
117
|
+
* turns out to need one. */
|
|
118
|
+
browser?: {
|
|
119
|
+
/** When the page counts as loaded. "load" (the default) waits for images and stylesheets;
|
|
120
|
+
* "domcontentloaded" is the fastest and stops at the HTML; "networkidle" waits until the
|
|
121
|
+
* page stops asking for things. Every page gets a short settle after this whichever you
|
|
122
|
+
* pick. */
|
|
123
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
124
|
+
/** Wait until this CSS selector is on the page — the dependable way to read something a
|
|
125
|
+
* script draws. If it never shows up the call comes back as a timeout at no charge, rather
|
|
126
|
+
* than the half-built page. */
|
|
127
|
+
waitForSelector?: string;
|
|
128
|
+
/** Wait this many milliseconds after the page settles, for the scripts no selector
|
|
129
|
+
* describes. It comes out of `timeoutMs`, never on top of it. */
|
|
130
|
+
waitMs?: number;
|
|
131
|
+
/** The window size the page is rendered in, 1280×800 unless you say. Set it when a site
|
|
132
|
+
* serves a different layout by width. */
|
|
133
|
+
viewport?: {
|
|
134
|
+
width: number;
|
|
135
|
+
height: number;
|
|
136
|
+
};
|
|
137
|
+
/** Screenshot the whole scrollable page instead of just the window. A long page makes a
|
|
138
|
+
* large answer — the image comes back as base64 inside the response. */
|
|
139
|
+
fullPage?: boolean;
|
|
140
|
+
};
|
|
141
|
+
/** Extra request headers to send to the page — an authorization token, a cookie, a custom user
|
|
142
|
+
* agent. The connection's own headers cannot be set. */
|
|
143
|
+
headers?: Record<string, string>;
|
|
144
|
+
/** How long to give the page before giving up, in milliseconds. A page that never arrives is a
|
|
145
|
+
* free outcome. */
|
|
146
|
+
timeoutMs?: number;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/** Arguments for `search()`. */
|
|
150
|
+
export interface SearchParams {
|
|
151
|
+
/** What to search for, in plain words — the same thing you would type. */
|
|
152
|
+
query: string;
|
|
153
|
+
/** How many results to hand back at most, 1–20. Billed per 10, so asking for more than 10 costs
|
|
154
|
+
* a second row. Fewer can come back than you asked for — an index has what it has, and
|
|
155
|
+
* `includeDomains` filters what it returns. */
|
|
156
|
+
limit?: number;
|
|
157
|
+
/** What kind of results. "general" is the web; "news" is dated journalism, and the only topic
|
|
158
|
+
* that reliably carries `publishedAt`. */
|
|
159
|
+
topic?: "general" | "news";
|
|
160
|
+
/** Only pages from the last day, week, month or year. Absent is any time. */
|
|
161
|
+
timeRange?: "day" | "week" | "month" | "year";
|
|
162
|
+
/** Only results on these hosts, bare (`linkedin.com`) — subdomains included. Asked of the
|
|
163
|
+
* search front AND enforced on the answer, so what comes back is on your list whatever the
|
|
164
|
+
* front did with it. */
|
|
165
|
+
includeDomains?: string[];
|
|
166
|
+
/** Also write a short paragraph answering the query from the results, in the query's language.
|
|
167
|
+
* Costs one extra credit; leave it off when your own model reads the snippets. */
|
|
168
|
+
answer?: boolean;
|
|
169
|
+
/** Where the search leaves from. `country` picks the exit AND the market the front answers for
|
|
170
|
+
* — `br` gets Brazilian results in Portuguese. */
|
|
171
|
+
proxy?: {
|
|
172
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
173
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
174
|
+
pool?: "residential" | "custom";
|
|
175
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
176
|
+
* for the managed one. */
|
|
177
|
+
server?: string;
|
|
178
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
179
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
180
|
+
* languages follow it on every pool. */
|
|
181
|
+
country?: string;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** Arguments for `batches.create()`. */
|
|
186
|
+
export interface CreateBatchParams {
|
|
187
|
+
/** How to read it. "fetch" is a plain HTTP request; "browser" renders the page in a real
|
|
188
|
+
* Chromium; "auto" fetches first and escalates to the browser when the body turns out to be a
|
|
189
|
+
* JavaScript shell, billing whichever engine answered. */
|
|
190
|
+
engine?: "auto" | "fetch" | "browser";
|
|
191
|
+
/** Whether to try again a different way when the first attempt is blocked. `false` stops after
|
|
192
|
+
* one try — the site's refusal is your answer, and it costs nothing. It is how you bound a
|
|
193
|
+
* call: with `auto`, trying again is what charges the browser price instead of the fetch one. */
|
|
194
|
+
escalate?: boolean;
|
|
195
|
+
/** How many extra tries to give a page the site blocks, each from a different address. 0 (the
|
|
196
|
+
* default) takes the site's first no as the answer. A blocked page costs nothing, so a try
|
|
197
|
+
* that is blocked again is free — but it takes as long as the first one did, so the call can
|
|
198
|
+
* run that many times longer. */
|
|
199
|
+
retry?: number;
|
|
200
|
+
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
201
|
+
* asking for both costs no more than one. */
|
|
202
|
+
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf")[];
|
|
203
|
+
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
204
|
+
* that comes back — a maintenance notice, a "checking your browser" page, a login form — is
|
|
205
|
+
* then not your answer. It costs nothing, and we try again from another address instead of
|
|
206
|
+
* handing you a page you cannot parse. Without it, whatever the page returns is your answer. */
|
|
207
|
+
expect?: "json";
|
|
208
|
+
/** Where the request leaves from. Defaults to the managed residential pool. */
|
|
209
|
+
proxy?: {
|
|
210
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
211
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
212
|
+
pool?: "residential" | "custom";
|
|
213
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
214
|
+
* for the managed one. */
|
|
215
|
+
server?: string;
|
|
216
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
217
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
218
|
+
* languages follow it on every pool. */
|
|
219
|
+
country?: string;
|
|
220
|
+
};
|
|
221
|
+
/** How to render it. Only the browser engine reads these — with `auto` they apply if the page
|
|
222
|
+
* turns out to need one. */
|
|
223
|
+
browser?: {
|
|
224
|
+
/** When the page counts as loaded. "load" (the default) waits for images and stylesheets;
|
|
225
|
+
* "domcontentloaded" is the fastest and stops at the HTML; "networkidle" waits until the
|
|
226
|
+
* page stops asking for things. Every page gets a short settle after this whichever you
|
|
227
|
+
* pick. */
|
|
228
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
229
|
+
/** Wait until this CSS selector is on the page — the dependable way to read something a
|
|
230
|
+
* script draws. If it never shows up the call comes back as a timeout at no charge, rather
|
|
231
|
+
* than the half-built page. */
|
|
232
|
+
waitForSelector?: string;
|
|
233
|
+
/** Wait this many milliseconds after the page settles, for the scripts no selector
|
|
234
|
+
* describes. It comes out of `timeoutMs`, never on top of it. */
|
|
235
|
+
waitMs?: number;
|
|
236
|
+
/** The window size the page is rendered in, 1280×800 unless you say. Set it when a site
|
|
237
|
+
* serves a different layout by width. */
|
|
238
|
+
viewport?: {
|
|
239
|
+
width: number;
|
|
240
|
+
height: number;
|
|
241
|
+
};
|
|
242
|
+
/** Screenshot the whole scrollable page instead of just the window. A long page makes a
|
|
243
|
+
* large answer — the image comes back as base64 inside the response. */
|
|
244
|
+
fullPage?: boolean;
|
|
245
|
+
};
|
|
246
|
+
/** Extra request headers to send to the page — an authorization token, a cookie, a custom user
|
|
247
|
+
* agent. The connection's own headers cannot be set. */
|
|
248
|
+
headers?: Record<string, string>;
|
|
249
|
+
/** How long to give the page before giving up, in milliseconds. A page that never arrives is a
|
|
250
|
+
* free outcome. */
|
|
251
|
+
timeoutMs?: number;
|
|
252
|
+
/** The pages to read, in the order you want them back. How many one batch may carry depends on
|
|
253
|
+
* your plan. Duplicates are kept: position, not URL, is what lines results up against what you
|
|
254
|
+
* submitted. */
|
|
255
|
+
urls: string[];
|
|
256
|
+
/** Call this URL instead of making you poll. The signing secret is returned once, when the
|
|
257
|
+
* batch is created. */
|
|
258
|
+
webhook?: {
|
|
259
|
+
/** Where to POST when something happens. An https URL you control; private and loopback
|
|
260
|
+
* hosts are refused, the same as any other URL we fetch. */
|
|
261
|
+
url: string;
|
|
262
|
+
/** What to call about. "batch.completed" fires once, when every URL has a verdict.
|
|
263
|
+
* "batch.item.completed" fires per URL — one request from us per item, which is what makes
|
|
264
|
+
* a long batch usable before it ends, so ask for it deliberately. */
|
|
265
|
+
events?: ("batch.completed" | "batch.item.completed")[];
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/** Arguments for `batches.quote()`. */
|
|
270
|
+
export interface QuoteBatchParams {
|
|
271
|
+
/** How to read it. "fetch" is a plain HTTP request; "browser" renders the page in a real
|
|
272
|
+
* Chromium; "auto" fetches first and escalates to the browser when the body turns out to be a
|
|
273
|
+
* JavaScript shell, billing whichever engine answered. */
|
|
274
|
+
engine?: "auto" | "fetch" | "browser";
|
|
275
|
+
/** Whether to try again a different way when the first attempt is blocked. `false` stops after
|
|
276
|
+
* one try — the site's refusal is your answer, and it costs nothing. It is how you bound a
|
|
277
|
+
* call: with `auto`, trying again is what charges the browser price instead of the fetch one. */
|
|
278
|
+
escalate?: boolean;
|
|
279
|
+
/** How many extra tries to give a page the site blocks, each from a different address. 0 (the
|
|
280
|
+
* default) takes the site's first no as the answer. A blocked page costs nothing, so a try
|
|
281
|
+
* that is blocked again is free — but it takes as long as the first one did, so the call can
|
|
282
|
+
* run that many times longer. */
|
|
283
|
+
retry?: number;
|
|
284
|
+
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
285
|
+
* asking for both costs no more than one. */
|
|
286
|
+
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf")[];
|
|
287
|
+
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
288
|
+
* that comes back — a maintenance notice, a "checking your browser" page, a login form — is
|
|
289
|
+
* then not your answer. It costs nothing, and we try again from another address instead of
|
|
290
|
+
* handing you a page you cannot parse. Without it, whatever the page returns is your answer. */
|
|
291
|
+
expect?: "json";
|
|
292
|
+
/** Where the request leaves from. Defaults to the managed residential pool. */
|
|
293
|
+
proxy?: {
|
|
294
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
295
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
296
|
+
pool?: "residential" | "custom";
|
|
297
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
298
|
+
* for the managed one. */
|
|
299
|
+
server?: string;
|
|
300
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
301
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
302
|
+
* languages follow it on every pool. */
|
|
303
|
+
country?: string;
|
|
304
|
+
};
|
|
305
|
+
/** How to render it. Only the browser engine reads these — with `auto` they apply if the page
|
|
306
|
+
* turns out to need one. */
|
|
307
|
+
browser?: {
|
|
308
|
+
/** When the page counts as loaded. "load" (the default) waits for images and stylesheets;
|
|
309
|
+
* "domcontentloaded" is the fastest and stops at the HTML; "networkidle" waits until the
|
|
310
|
+
* page stops asking for things. Every page gets a short settle after this whichever you
|
|
311
|
+
* pick. */
|
|
312
|
+
waitUntil?: "load" | "domcontentloaded" | "networkidle";
|
|
313
|
+
/** Wait until this CSS selector is on the page — the dependable way to read something a
|
|
314
|
+
* script draws. If it never shows up the call comes back as a timeout at no charge, rather
|
|
315
|
+
* than the half-built page. */
|
|
316
|
+
waitForSelector?: string;
|
|
317
|
+
/** Wait this many milliseconds after the page settles, for the scripts no selector
|
|
318
|
+
* describes. It comes out of `timeoutMs`, never on top of it. */
|
|
319
|
+
waitMs?: number;
|
|
320
|
+
/** The window size the page is rendered in, 1280×800 unless you say. Set it when a site
|
|
321
|
+
* serves a different layout by width. */
|
|
322
|
+
viewport?: {
|
|
323
|
+
width: number;
|
|
324
|
+
height: number;
|
|
325
|
+
};
|
|
326
|
+
/** Screenshot the whole scrollable page instead of just the window. A long page makes a
|
|
327
|
+
* large answer — the image comes back as base64 inside the response. */
|
|
328
|
+
fullPage?: boolean;
|
|
329
|
+
};
|
|
330
|
+
/** Extra request headers to send to the page — an authorization token, a cookie, a custom user
|
|
331
|
+
* agent. The connection's own headers cannot be set. */
|
|
332
|
+
headers?: Record<string, string>;
|
|
333
|
+
/** How long to give the page before giving up, in milliseconds. A page that never arrives is a
|
|
334
|
+
* free outcome. */
|
|
335
|
+
timeoutMs?: number;
|
|
336
|
+
/** The pages to read, in the order you want them back. How many one batch may carry depends on
|
|
337
|
+
* your plan. Duplicates are kept: position, not URL, is what lines results up against what you
|
|
338
|
+
* submitted. */
|
|
339
|
+
urls: string[];
|
|
340
|
+
/** Call this URL instead of making you poll. The signing secret is returned once, when the
|
|
341
|
+
* batch is created. */
|
|
342
|
+
webhook?: {
|
|
343
|
+
/** Where to POST when something happens. An https URL you control; private and loopback
|
|
344
|
+
* hosts are refused, the same as any other URL we fetch. */
|
|
345
|
+
url: string;
|
|
346
|
+
/** What to call about. "batch.completed" fires once, when every URL has a verdict.
|
|
347
|
+
* "batch.item.completed" fires per URL — one request from us per item, which is what makes
|
|
348
|
+
* a long batch usable before it ends, so ask for it deliberately. */
|
|
349
|
+
events?: ("batch.completed" | "batch.item.completed")[];
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** Arguments for `batches.list()`. */
|
|
354
|
+
export interface ListBatchesParams {
|
|
355
|
+
/** How many to return, newest first. Up to 100; 20 by default. */
|
|
356
|
+
limit?: number;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Arguments for `batches.get()`. */
|
|
360
|
+
export interface GetBatchParams {
|
|
361
|
+
/** The batch's id, as create returned it. */
|
|
362
|
+
id: string;
|
|
363
|
+
/** Also return the results themselves, in the order you submitted them. Off by default: most
|
|
364
|
+
* polls only want to know whether the batch has finished. */
|
|
365
|
+
items?: boolean;
|
|
366
|
+
/** Start the results at this position. Up to 200 come back at a time, so read the next page
|
|
367
|
+
* with `from` plus however many you just got, and stop when you reach `total`. */
|
|
368
|
+
from?: number;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
/** Arguments for `batches.cancel()`. */
|
|
372
|
+
export interface CancelBatchParams {
|
|
373
|
+
/** The batch's id, as create returned it. */
|
|
374
|
+
id: string;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/** Arguments for `sessions.create()`. */
|
|
378
|
+
export interface CreateSessionParams {
|
|
379
|
+
/** How long to hold the browser, in minutes. Credits for the whole window are reserved when the
|
|
380
|
+
* session starts and the unused minutes are handed back when it closes, so asking for longer
|
|
381
|
+
* than you need costs nothing extra. Defaults to 10; your plan sets the ceiling. */
|
|
382
|
+
timeoutMin?: number;
|
|
383
|
+
/** Where the session leaves from, fixed for its whole life. Defaults to the managed residential
|
|
384
|
+
* pool. */
|
|
385
|
+
proxy?: {
|
|
386
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
387
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
388
|
+
pool?: "residential" | "custom";
|
|
389
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
390
|
+
* for the managed one. */
|
|
391
|
+
server?: string;
|
|
392
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
393
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
394
|
+
* languages follow it on every pool. */
|
|
395
|
+
country?: string;
|
|
396
|
+
};
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** Arguments for `sessions.quote()`. */
|
|
400
|
+
export interface QuoteSessionParams {
|
|
401
|
+
/** How long to hold the browser, in minutes. Credits for the whole window are reserved when the
|
|
402
|
+
* session starts and the unused minutes are handed back when it closes, so asking for longer
|
|
403
|
+
* than you need costs nothing extra. Defaults to 10; your plan sets the ceiling. */
|
|
404
|
+
timeoutMin?: number;
|
|
405
|
+
/** Where the session leaves from, fixed for its whole life. Defaults to the managed residential
|
|
406
|
+
* pool. */
|
|
407
|
+
proxy?: {
|
|
408
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
409
|
+
* "custom" is your own proxy — free on every plan, bytes never billed. */
|
|
410
|
+
pool?: "residential" | "custom";
|
|
411
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
412
|
+
* for the managed one. */
|
|
413
|
+
server?: string;
|
|
414
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`); `us`
|
|
415
|
+
* unless you say. On the managed pool it also picks the exit; the browser's clock and
|
|
416
|
+
* languages follow it on every pool. */
|
|
417
|
+
country?: string;
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/** Arguments for `sessions.list()`. */
|
|
422
|
+
export interface ListSessionsParams {
|
|
423
|
+
/** How many to return, newest first. Up to 100; 20 by default. */
|
|
424
|
+
limit?: number;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/** Arguments for `sessions.get()`. */
|
|
428
|
+
export interface GetSessionParams {
|
|
429
|
+
/** The session's id, as create returned it. */
|
|
430
|
+
id: string;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
/** Arguments for `sessions.close()`. */
|
|
434
|
+
export interface CloseSessionParams {
|
|
435
|
+
/** The session's id, as create returned it. */
|
|
436
|
+
id: string;
|
|
437
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// The published surface of `@scrapa/sdk`.
|
|
2
|
+
export { Scrapa } from "./client.ts";
|
|
3
|
+
export type { RequestOptions, RequestSpec, ScrapaOptions } from "./client.ts";
|
|
4
|
+
export { ScrapaError } from "./errors.ts";
|
|
5
|
+
export type { ClientErrorCode, ScrapaErrorInit } from "./errors.ts";
|
|
6
|
+
export { DEFAULT_BASE_URL, SDK_VERSION } from "./generated/operations.ts";
|
|
7
|
+
// Every DTO, error code and header the API speaks.
|
|
8
|
+
export * from "./generated/contract.ts";
|
|
9
|
+
export type * from "./generated/params.ts";
|