@decodo/sdk-ts 2.7.0 → 3.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.
@@ -1,3 +1,7 @@
1
+ import * as z from 'zod';
2
+ /**
3
+ * Fields other than these are dropped before the upstream call.
4
+ */
1
5
  export interface RunSearchRequest {
2
6
  query: string;
3
7
  url?: string;
@@ -6,11 +10,20 @@ export interface RunSearchRequest {
6
10
  geo?: string;
7
11
  locale?: string;
8
12
  input_encoding?: string;
13
+ /**
14
+ * Not checked to be an integer; forwarded as given.
15
+ */
9
16
  page?: number;
10
17
  [k: string]: unknown;
11
18
  }
12
19
  export type RunSearchResponse = {
20
+ /**
21
+ * Set by the vendor, not by scraper-api. Failures arrive as ScrapeFailed or a 500 UpstreamError instead.
22
+ */
13
23
  status?: 'done';
24
+ /**
25
+ * Observed as an empty string.
26
+ */
14
27
  url?: string;
15
28
  organic?: {
16
29
  link?: string;
@@ -21,10 +34,16 @@ export type RunSearchResponse = {
21
34
  rank?: number;
22
35
  [k: string]: unknown;
23
36
  }[];
37
+ /**
38
+ * An array on the wire, empty when the query has no news; scraper-api's own type calls it an object.
39
+ */
24
40
  top_stories?: {
25
41
  title?: string;
26
42
  link?: string;
27
43
  site?: string;
44
+ /**
45
+ * Relative age as the search engine shows it, for example 3 hours ago.
46
+ */
28
47
  ago?: string;
29
48
  rank?: number;
30
49
  [k: string]: unknown;
@@ -39,6 +58,9 @@ export type RunSearchResponse = {
39
58
  link?: string;
40
59
  [k: string]: unknown;
41
60
  }[];
61
+ /**
62
+ * Observed empty; populated shape not seen.
63
+ */
42
64
  answer_box?: {
43
65
  [k: string]: unknown;
44
66
  };
@@ -58,7 +80,13 @@ export type RunSearchResponse = {
58
80
  [k: string]: unknown;
59
81
  };
60
82
  export interface MapSiteRequest {
83
+ /**
84
+ * Absolute http or https URL to map.
85
+ */
61
86
  url: string;
87
+ /**
88
+ * Maximum links to return. Zero, negative or above 147700 all become 147700; nothing is rejected.
89
+ */
62
90
  limit?: number;
63
91
  sitemap?: 'include' | 'only' | 'skip';
64
92
  domain_filter?: 'domain' | 'subdomain' | 'all';
@@ -66,27 +94,51 @@ export interface MapSiteRequest {
66
94
  locale?: string;
67
95
  JS_rendering?: boolean;
68
96
  follow_redirects?: boolean;
97
+ /**
98
+ * Either one pattern or a list of them. Each must compile as a Go regular expression.
99
+ */
69
100
  select_paths?: string | string[];
101
+ /**
102
+ * Either one pattern or a list of them. Each must compile as a Go regular expression.
103
+ */
70
104
  exclude_paths?: string | string[];
71
105
  [k: string]: unknown;
72
106
  }
73
107
  export interface MapSiteResponse {
108
+ /**
109
+ * Always exactly one element.
110
+ */
74
111
  results: {
75
112
  content: {
76
113
  links: {
77
114
  url: string;
78
115
  }[];
79
116
  };
117
+ /**
118
+ * Always 200. Not the status of the mapped site.
119
+ */
80
120
  status_code: number;
81
121
  url: string;
82
122
  sitemap_status: 'include' | 'only' | 'skip';
83
123
  map_id: string;
124
+ /**
125
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
126
+ */
84
127
  created_at: string;
128
+ /**
129
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
130
+ */
85
131
  updated_at: string;
86
132
  }[];
87
133
  }
88
134
  export interface ListCrawlsQuery {
135
+ /**
136
+ * Only crawls in this state. Not validated; an unknown value matches nothing.
137
+ */
89
138
  status?: 'pending' | 'done' | 'faulted' | 'cancelled' | 'truncated';
139
+ /**
140
+ * The cursor field from the previous page. Omit for the first page.
141
+ */
90
142
  cursor?: string;
91
143
  }
92
144
  export interface ListCrawlsResponse {
@@ -94,86 +146,191 @@ export interface ListCrawlsResponse {
94
146
  id: string;
95
147
  url: string;
96
148
  status: string;
149
+ /**
150
+ * The format the crawl's pages are saved in.
151
+ */
97
152
  output: 'markdown' | 'html';
98
153
  }[];
154
+ /**
155
+ * Present whenever the page was full. The next page may be empty.
156
+ */
99
157
  cursor?: string;
100
158
  }
101
159
  export interface StartCrawlRequest {
160
+ /**
161
+ * An http or https URL with a host. URLs carrying credentials (user:pass@) are refused.
162
+ */
102
163
  url: string;
103
164
  limit?: number;
104
165
  max_depth?: number;
105
166
  sitemap?: 'include' | 'only' | 'skip';
106
167
  domain_filter?: 'domain' | 'subdomain' | 'all';
107
168
  output?: 'markdown' | 'html';
169
+ /**
170
+ * Letters, spaces, dots, apostrophes and hyphens, 2 to 60 characters.
171
+ */
108
172
  geo?: string;
173
+ /**
174
+ * BCP 47 style, for example en or de-DE.
175
+ */
109
176
  locale?: string;
110
177
  follow_redirects?: boolean;
111
178
  JS_retry?: boolean;
179
+ /**
180
+ * Seconds. 0 means the server default. Rejected above the server's ceiling, 4 hours by default; the ceiling is configurable per environment.
181
+ */
112
182
  max_duration?: number;
183
+ /**
184
+ * http or https URL called when the crawl settles. Internal addresses are refused.
185
+ */
113
186
  callback_url?: string;
187
+ /**
188
+ * Opaque value echoed back on the callback, at most 8192 bytes. Redacted in logs.
189
+ */
114
190
  passthrough?: string;
191
+ /**
192
+ * Either one pattern or a list of them. Each must compile as a Go regular expression.
193
+ */
115
194
  select_paths?: string | string[];
195
+ /**
196
+ * Either one pattern or a list of them. Each must compile as a Go regular expression.
197
+ */
116
198
  exclude_paths?: string | string[];
117
199
  [k: string]: unknown;
118
200
  }
119
201
  export interface StartCrawlResponse {
120
202
  target: 'crawl';
121
203
  url: string;
204
+ /**
205
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
206
+ */
122
207
  created_at: string;
123
208
  crawl_id: string;
124
209
  status: 'pending' | 'done' | 'faulted' | 'cancelled' | 'truncated';
210
+ /**
211
+ * Absolute URL of this crawl's status endpoint.
212
+ */
125
213
  crawl_status: string;
214
+ /**
215
+ * Absolute URL of the per-page metadata listing.
216
+ */
126
217
  results_tasks: string;
218
+ /**
219
+ * Absolute URL of the same listing with page content included.
220
+ */
127
221
  results_content: string;
128
222
  }
129
223
  export interface ListCrawlPagesQuery {
224
+ /**
225
+ * Pass content to include each page's body. Any other value selects metadata mode.
226
+ */
130
227
  type?: string;
228
+ /**
229
+ * Page token. Take it from the next URL of the previous page rather than building it; the first page needs none.
230
+ */
131
231
  cursor?: string;
132
232
  }
133
233
  export interface ListCrawlPagesResponse {
134
234
  crawl_id: string;
235
+ /**
236
+ * The crawled pages. Named url, not results.
237
+ */
135
238
  url: {
136
239
  task_id?: string;
137
240
  status: 'pending' | 'done' | 'faulted';
241
+ /**
242
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
243
+ */
138
244
  created_at: string;
245
+ /**
246
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
247
+ */
139
248
  updated_at: string;
140
249
  url: string;
141
250
  depth: number;
142
251
  parent_url?: string;
143
252
  result_key?: string;
253
+ /**
254
+ * Present only when type=content was requested.
255
+ */
144
256
  content?: string;
257
+ /**
258
+ * Why this page has no content, when fetching it failed.
259
+ */
145
260
  content_error?: string;
261
+ /**
262
+ * Absolute URL of this crawl's status endpoint.
263
+ */
146
264
  crawl_status: string;
265
+ /**
266
+ * Absolute URL of the per-page metadata listing.
267
+ */
147
268
  results_tasks: string;
269
+ /**
270
+ * Absolute URL of the same listing with page content included.
271
+ */
148
272
  results_content: string;
149
273
  }[];
274
+ /**
275
+ * Absolute URL of the next page. Absent on the last page.
276
+ */
150
277
  next?: string;
278
+ /**
279
+ * Present only on the first page in content mode.
280
+ */
151
281
  total?: number;
152
282
  }
153
283
  export interface GetCrawlStatusResponse {
154
284
  target: 'crawl';
155
285
  url: string;
286
+ /**
287
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
288
+ */
156
289
  created_at: string;
157
290
  crawl_id: string;
158
291
  status: 'pending' | 'done' | 'faulted' | 'cancelled' | 'truncated';
292
+ /**
293
+ * Why the crawl stopped early. On truncated, max_duration is the deadline and vendor_limit means the vendor kept refusing the account's submissions, quota or request rate. On faulted, no_pages_found means the crawl found nothing to crawl, for example sitemap only on a site without a sitemap.
294
+ */
159
295
  reason?: 'max_duration' | 'vendor_limit' | 'no_pages_found';
160
296
  sitemap_status: 'include' | 'only' | 'skip';
297
+ /**
298
+ * The format the crawl's pages are saved in.
299
+ */
161
300
  output: 'markdown' | 'html';
162
301
  discovered: number;
163
302
  completed: number;
164
303
  failed: number;
165
304
  in_flight: number;
305
+ /**
306
+ * Sitemap files fetched for this crawl, sitemap indexes included. 0 when sitemap is skip.
307
+ */
166
308
  sitemaps: number;
309
+ /**
310
+ * Scrape requests the vendor accepted for this crawl, the billed work. Counts pages, JavaScript retries and sitemap fetches; not results reads.
311
+ */
167
312
  requests: number;
168
313
  }
169
314
  export interface CancelCrawlResponse {
170
315
  target: 'crawl';
171
316
  url: string;
317
+ /**
318
+ * UTC timestamp formatted as "YYYY-MM-DD HH:MM:SS". Not RFC 3339.
319
+ */
172
320
  created_at: string;
173
321
  crawl_id: string;
174
322
  status: 'pending' | 'done' | 'faulted' | 'cancelled' | 'truncated';
323
+ /**
324
+ * Absolute URL of this crawl's status endpoint.
325
+ */
175
326
  crawl_status: string;
327
+ /**
328
+ * Absolute URL of the per-page metadata listing.
329
+ */
176
330
  results_tasks: string;
331
+ /**
332
+ * Absolute URL of the same listing with page content included.
333
+ */
177
334
  results_content: string;
178
335
  }
179
336
  export declare const dataApiEndpoints: {
@@ -207,3 +364,8 @@ export declare const dataApiEndpoints: {
207
364
  };
208
365
  };
209
366
  export type DataApiEndpoint = keyof typeof dataApiEndpoints;
367
+ export declare const dataApiRequestSchemas: {
368
+ runSearch: z.ZodObject;
369
+ mapSite: z.ZodObject;
370
+ startCrawl: z.ZodObject;
371
+ };
@@ -1,4 +1,5 @@
1
1
  // Auto-generated by src/codegen/data-api/generate-data-api.ts — do not edit
2
+ import * as z from 'zod';
2
3
  export const dataApiEndpoints = {
3
4
  runSearch: { method: "POST", path: "/v1/search" },
4
5
  mapSite: { method: "POST", path: "/v1/map" },
@@ -8,3 +9,234 @@ export const dataApiEndpoints = {
8
9
  getCrawlStatus: { method: "GET", path: "/v1/crawl/{id}/status" },
9
10
  cancelCrawl: { method: "POST", path: "/v1/crawl/{id}/cancel" },
10
11
  };
12
+ const dataApiRequestJsonSchemas = {
13
+ runSearch: {
14
+ "type": "object",
15
+ "required": [
16
+ "query"
17
+ ],
18
+ "description": "Fields other than these are dropped before the upstream call.",
19
+ "properties": {
20
+ "query": {
21
+ "type": "string",
22
+ "minLength": 1
23
+ },
24
+ "url": {
25
+ "type": "string",
26
+ "minLength": 1
27
+ },
28
+ "uule": {
29
+ "type": "string"
30
+ },
31
+ "gl": {
32
+ "type": "string"
33
+ },
34
+ "geo": {
35
+ "type": "string"
36
+ },
37
+ "locale": {
38
+ "type": "string"
39
+ },
40
+ "input_encoding": {
41
+ "type": "string"
42
+ },
43
+ "page": {
44
+ "type": "number",
45
+ "minimum": 1,
46
+ "description": "Not checked to be an integer; forwarded as given."
47
+ }
48
+ }
49
+ },
50
+ mapSite: {
51
+ "type": "object",
52
+ "required": [
53
+ "url"
54
+ ],
55
+ "properties": {
56
+ "url": {
57
+ "type": "string",
58
+ "description": "Absolute http or https URL to map."
59
+ },
60
+ "limit": {
61
+ "type": "integer",
62
+ "description": "Maximum links to return. Zero, negative or above 147700 all become 147700; nothing is rejected.",
63
+ "default": 147700
64
+ },
65
+ "sitemap": {
66
+ "type": "string",
67
+ "enum": [
68
+ "include",
69
+ "only",
70
+ "skip"
71
+ ],
72
+ "default": "include"
73
+ },
74
+ "domain_filter": {
75
+ "type": "string",
76
+ "enum": [
77
+ "domain",
78
+ "subdomain",
79
+ "all"
80
+ ],
81
+ "default": "domain"
82
+ },
83
+ "geo": {
84
+ "type": "string"
85
+ },
86
+ "locale": {
87
+ "type": "string"
88
+ },
89
+ "JS_rendering": {
90
+ "type": "boolean",
91
+ "default": false
92
+ },
93
+ "follow_redirects": {
94
+ "type": "boolean",
95
+ "default": true
96
+ },
97
+ "select_paths": {
98
+ "description": "Either one pattern or a list of them. Each must compile as a Go regular expression.",
99
+ "oneOf": [
100
+ {
101
+ "type": "string"
102
+ },
103
+ {
104
+ "type": "array",
105
+ "items": {
106
+ "type": "string"
107
+ }
108
+ }
109
+ ]
110
+ },
111
+ "exclude_paths": {
112
+ "description": "Either one pattern or a list of them. Each must compile as a Go regular expression.",
113
+ "oneOf": [
114
+ {
115
+ "type": "string"
116
+ },
117
+ {
118
+ "type": "array",
119
+ "items": {
120
+ "type": "string"
121
+ }
122
+ }
123
+ ]
124
+ }
125
+ }
126
+ },
127
+ startCrawl: {
128
+ "type": "object",
129
+ "required": [
130
+ "url"
131
+ ],
132
+ "properties": {
133
+ "url": {
134
+ "type": "string",
135
+ "description": "An http or https URL with a host. URLs carrying credentials (user:pass@) are refused."
136
+ },
137
+ "limit": {
138
+ "type": "integer",
139
+ "minimum": 1,
140
+ "maximum": 10000,
141
+ "default": 10
142
+ },
143
+ "max_depth": {
144
+ "type": "integer",
145
+ "minimum": 1,
146
+ "maximum": 10000,
147
+ "default": 5
148
+ },
149
+ "sitemap": {
150
+ "type": "string",
151
+ "enum": [
152
+ "include",
153
+ "only",
154
+ "skip"
155
+ ],
156
+ "default": "include"
157
+ },
158
+ "domain_filter": {
159
+ "type": "string",
160
+ "enum": [
161
+ "domain",
162
+ "subdomain",
163
+ "all"
164
+ ],
165
+ "default": "domain"
166
+ },
167
+ "output": {
168
+ "type": "string",
169
+ "enum": [
170
+ "markdown",
171
+ "html"
172
+ ],
173
+ "default": "markdown"
174
+ },
175
+ "geo": {
176
+ "type": "string",
177
+ "pattern": "^[A-Za-z][A-Za-z .'-]{0,58}[A-Za-z]$",
178
+ "description": "Letters, spaces, dots, apostrophes and hyphens, 2 to 60 characters."
179
+ },
180
+ "locale": {
181
+ "type": "string",
182
+ "pattern": "^[A-Za-z]{2,3}(-[A-Za-z0-9]{2,8})*$",
183
+ "description": "BCP 47 style, for example en or de-DE."
184
+ },
185
+ "follow_redirects": {
186
+ "type": "boolean"
187
+ },
188
+ "JS_retry": {
189
+ "type": "boolean"
190
+ },
191
+ "max_duration": {
192
+ "type": "integer",
193
+ "minimum": 0,
194
+ "maximum": 14400,
195
+ "description": "Seconds. 0 means the server default. Rejected above the server's ceiling, 4 hours by default; the ceiling is configurable per environment.",
196
+ "default": 3600
197
+ },
198
+ "callback_url": {
199
+ "type": "string",
200
+ "description": "http or https URL called when the crawl settles. Internal addresses are refused."
201
+ },
202
+ "passthrough": {
203
+ "type": "string",
204
+ "maxLength": 8192,
205
+ "description": "Opaque value echoed back on the callback, at most 8192 bytes. Redacted in logs."
206
+ },
207
+ "select_paths": {
208
+ "description": "Either one pattern or a list of them. Each must compile as a Go regular expression.",
209
+ "oneOf": [
210
+ {
211
+ "type": "string"
212
+ },
213
+ {
214
+ "type": "array",
215
+ "items": {
216
+ "type": "string"
217
+ }
218
+ }
219
+ ]
220
+ },
221
+ "exclude_paths": {
222
+ "description": "Either one pattern or a list of them. Each must compile as a Go regular expression.",
223
+ "oneOf": [
224
+ {
225
+ "type": "string"
226
+ },
227
+ {
228
+ "type": "array",
229
+ "items": {
230
+ "type": "string"
231
+ }
232
+ }
233
+ ]
234
+ }
235
+ }
236
+ },
237
+ };
238
+ export const dataApiRequestSchemas = {
239
+ runSearch: z.fromJSONSchema(dataApiRequestJsonSchemas.runSearch),
240
+ mapSite: z.fromJSONSchema(dataApiRequestJsonSchemas.mapSite),
241
+ startCrawl: z.fromJSONSchema(dataApiRequestJsonSchemas.startCrawl),
242
+ };
@@ -1,7 +1,6 @@
1
1
  // Auto-generated by src/codegen/web-scraping-api/generate-parameters.ts — do not edit
2
2
  export const parameterMeta = {
3
3
  "360": { type: "boolean" },
4
- callback_url: { type: "string" },
5
4
  query: { type: "string", maxLength: 2048 },
6
5
  headless: { type: "string", enum: ["html", "png"] },
7
6
  locale: { type: "string" },
@@ -18,24 +17,18 @@ export const parameterMeta = {
18
17
  xhr: { type: "boolean" },
19
18
  markdown: { type: "boolean" },
20
19
  page_count: { type: "number", minimum: 1, maximum: 10 },
20
+ callback_url: { type: "string" },
21
21
  date_range: { type: "string" },
22
22
  stars: { type: "number" },
23
23
  adults: { type: "number", minimum: 1, maximum: 3 },
24
24
  children: { type: "number", minimum: 1, maximum: 3 },
25
- search_type: { type: "string" },
26
- date_start: { type: "string" },
27
- date_end: { type: "string" },
28
25
  url: { type: "string", maxLength: 2056 },
29
- hotel_occupancy: { type: "string" },
30
26
  domain: { type: "string" },
31
- language_code: { type: "string" },
32
- transcript_origin: { type: "string" },
33
27
  autoselect_variant: { type: "boolean" },
34
28
  currency: { type: "string" },
35
29
  category: { type: "string" },
36
30
  merchant: { type: "string" },
37
31
  sort_by: { type: "string" },
38
- parser_type: { type: "string" },
39
32
  product_id: { type: "string" },
40
33
  fulfillment_type: { type: "string" },
41
34
  walmart_store_id: { type: "string" },
@@ -43,11 +36,6 @@ export const parameterMeta = {
43
36
  store_id: { type: "string" },
44
37
  delivery_type: { type: "string" },
45
38
  target_store_id: { type: "string" },
46
- lowes_store_id: { type: "string" },
47
- user_agent_type: { type: "string" },
48
- free_delivery: { type: "boolean" },
49
- pickup_today: { type: "boolean" },
50
- delivery_today_tomorrow: { type: "boolean" },
51
39
  payload: { type: "string" },
52
40
  proxy_pool: { type: "string", enum: ["standard", "premium"] },
53
41
  http_method: { type: "string" },
@@ -59,6 +47,7 @@ export const parameterMeta = {
59
47
  prompt: { type: "string", maxLength: 8192 },
60
48
  search: { type: "boolean" },
61
49
  country: { type: "string" },
50
+ user_agent_type: { type: "string" },
62
51
  sort: { type: "string" },
63
52
  upload_date: { type: "string" },
64
53
  type: { type: "string" },
@@ -74,6 +63,7 @@ export const parameterMeta = {
74
63
  location: { type: "boolean" },
75
64
  purchased: { type: "boolean" },
76
65
  subtitles: { type: "boolean" },
66
+ language_code: { type: "string" },
77
67
  subtitle_origin: { type: "string" },
78
68
  limit: { type: "number", minimum: 0, maximum: 100 },
79
69
  };