@upcrawl/sdk 1.3.1 → 1.4.1
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 +214 -65
- package/dist/index.d.mts +355 -225
- package/dist/index.d.ts +355 -225
- package/dist/index.js +311 -0
- package/dist/index.mjs +290 -0
- package/package.json +9 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,236 +1,349 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { AxiosInstance } from 'axios';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Upcrawl SDK Types
|
|
3
6
|
* Type definitions for all API requests and responses
|
|
7
|
+
* Powered by Zod schemas — single source of truth for types, validation, and docs
|
|
4
8
|
*/
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
summary
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
waitUntil
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
error
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
9
|
+
|
|
10
|
+
declare const UpcrawlConfigSchema: z.ZodObject<{
|
|
11
|
+
apiKey: z.ZodOptional<z.ZodString>;
|
|
12
|
+
baseUrl: z.ZodOptional<z.ZodString>;
|
|
13
|
+
timeout: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
}, z.core.$strip>;
|
|
15
|
+
type UpcrawlConfig = z.infer<typeof UpcrawlConfigSchema>;
|
|
16
|
+
declare const SummaryQuerySchema: z.ZodObject<{
|
|
17
|
+
query: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type SummaryQuery = z.infer<typeof SummaryQuerySchema>;
|
|
20
|
+
declare const ScrapeOptionsSchema: z.ZodObject<{
|
|
21
|
+
url: z.ZodString;
|
|
22
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
23
|
+
html: "html";
|
|
24
|
+
markdown: "markdown";
|
|
25
|
+
}>>;
|
|
26
|
+
onlyMainContent: z.ZodOptional<z.ZodBoolean>;
|
|
27
|
+
extractMetadata: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
summary: z.ZodOptional<z.ZodObject<{
|
|
29
|
+
query: z.ZodString;
|
|
30
|
+
}, z.core.$strip>>;
|
|
31
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
32
|
+
waitUntil: z.ZodOptional<z.ZodEnum<{
|
|
33
|
+
load: "load";
|
|
34
|
+
domcontentloaded: "domcontentloaded";
|
|
35
|
+
networkidle: "networkidle";
|
|
36
|
+
}>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
type ScrapeOptions = z.infer<typeof ScrapeOptionsSchema>;
|
|
39
|
+
declare const ScrapeMetadataSchema: z.ZodObject<{
|
|
40
|
+
title: z.ZodOptional<z.ZodString>;
|
|
41
|
+
description: z.ZodOptional<z.ZodString>;
|
|
42
|
+
canonicalUrl: z.ZodOptional<z.ZodString>;
|
|
43
|
+
finalUrl: z.ZodOptional<z.ZodString>;
|
|
44
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
45
|
+
contentLength: z.ZodOptional<z.ZodNumber>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
type ScrapeMetadata = z.infer<typeof ScrapeMetadataSchema>;
|
|
48
|
+
declare const ScrapeResponseSchema: z.ZodObject<{
|
|
49
|
+
url: z.ZodString;
|
|
50
|
+
html: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
51
|
+
markdown: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
+
statusCode: z.ZodNullable<z.ZodNumber>;
|
|
53
|
+
success: z.ZodBoolean;
|
|
54
|
+
error: z.ZodOptional<z.ZodString>;
|
|
55
|
+
timestamp: z.ZodString;
|
|
56
|
+
loadTimeMs: z.ZodNumber;
|
|
57
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
58
|
+
title: z.ZodOptional<z.ZodString>;
|
|
59
|
+
description: z.ZodOptional<z.ZodString>;
|
|
60
|
+
canonicalUrl: z.ZodOptional<z.ZodString>;
|
|
61
|
+
finalUrl: z.ZodOptional<z.ZodString>;
|
|
62
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
63
|
+
contentLength: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
}, z.core.$strip>>;
|
|
65
|
+
retryCount: z.ZodNumber;
|
|
66
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
68
|
+
}, z.core.$strip>;
|
|
69
|
+
type ScrapeResponse = z.infer<typeof ScrapeResponseSchema>;
|
|
70
|
+
declare const BatchScrapeOptionsSchema: z.ZodObject<{
|
|
71
|
+
urls: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
72
|
+
url: z.ZodString;
|
|
73
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
74
|
+
html: "html";
|
|
75
|
+
markdown: "markdown";
|
|
76
|
+
}>>;
|
|
77
|
+
onlyMainContent: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
extractMetadata: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
summary: z.ZodOptional<z.ZodObject<{
|
|
80
|
+
query: z.ZodString;
|
|
81
|
+
}, z.core.$strip>>;
|
|
82
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
83
|
+
waitUntil: z.ZodOptional<z.ZodEnum<{
|
|
84
|
+
load: "load";
|
|
85
|
+
domcontentloaded: "domcontentloaded";
|
|
86
|
+
networkidle: "networkidle";
|
|
87
|
+
}>>;
|
|
88
|
+
}, z.core.$strip>]>>;
|
|
89
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
90
|
+
html: "html";
|
|
91
|
+
markdown: "markdown";
|
|
92
|
+
}>>;
|
|
93
|
+
onlyMainContent: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
summary: z.ZodOptional<z.ZodObject<{
|
|
95
|
+
query: z.ZodString;
|
|
96
|
+
}, z.core.$strip>>;
|
|
97
|
+
batchTimeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
98
|
+
failFast: z.ZodOptional<z.ZodBoolean>;
|
|
99
|
+
}, z.core.$strip>;
|
|
100
|
+
type BatchScrapeOptions = z.infer<typeof BatchScrapeOptionsSchema>;
|
|
101
|
+
declare const BatchScrapeResponseSchema: z.ZodObject<{
|
|
102
|
+
results: z.ZodArray<z.ZodObject<{
|
|
103
|
+
url: z.ZodString;
|
|
104
|
+
html: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
105
|
+
markdown: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
106
|
+
statusCode: z.ZodNullable<z.ZodNumber>;
|
|
107
|
+
success: z.ZodBoolean;
|
|
108
|
+
error: z.ZodOptional<z.ZodString>;
|
|
109
|
+
timestamp: z.ZodString;
|
|
110
|
+
loadTimeMs: z.ZodNumber;
|
|
111
|
+
metadata: z.ZodOptional<z.ZodObject<{
|
|
112
|
+
title: z.ZodOptional<z.ZodString>;
|
|
113
|
+
description: z.ZodOptional<z.ZodString>;
|
|
114
|
+
canonicalUrl: z.ZodOptional<z.ZodString>;
|
|
115
|
+
finalUrl: z.ZodOptional<z.ZodString>;
|
|
116
|
+
contentType: z.ZodOptional<z.ZodString>;
|
|
117
|
+
contentLength: z.ZodOptional<z.ZodNumber>;
|
|
118
|
+
}, z.core.$strip>>;
|
|
119
|
+
retryCount: z.ZodNumber;
|
|
120
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
121
|
+
content: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
122
|
+
}, z.core.$strip>>;
|
|
123
|
+
total: z.ZodNumber;
|
|
124
|
+
successful: z.ZodNumber;
|
|
125
|
+
failed: z.ZodNumber;
|
|
126
|
+
totalTimeMs: z.ZodNumber;
|
|
127
|
+
timestamp: z.ZodString;
|
|
128
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
129
|
+
}, z.core.$strip>;
|
|
130
|
+
type BatchScrapeResponse = z.infer<typeof BatchScrapeResponseSchema>;
|
|
131
|
+
declare const SearchOptionsSchema: z.ZodObject<{
|
|
132
|
+
queries: z.ZodArray<z.ZodString>;
|
|
133
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
location: z.ZodOptional<z.ZodString>;
|
|
135
|
+
includeDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
136
|
+
excludeDomains: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
type SearchOptions = z.infer<typeof SearchOptionsSchema>;
|
|
139
|
+
declare const SearchResultWebSchema: z.ZodObject<{
|
|
140
|
+
url: z.ZodString;
|
|
141
|
+
title: z.ZodString;
|
|
142
|
+
description: z.ZodString;
|
|
143
|
+
}, z.core.$strip>;
|
|
144
|
+
type SearchResultWeb = z.infer<typeof SearchResultWebSchema>;
|
|
145
|
+
declare const SearchResultItemSchema: z.ZodObject<{
|
|
146
|
+
query: z.ZodString;
|
|
147
|
+
success: z.ZodBoolean;
|
|
148
|
+
results: z.ZodArray<z.ZodObject<{
|
|
149
|
+
url: z.ZodString;
|
|
150
|
+
title: z.ZodString;
|
|
151
|
+
description: z.ZodString;
|
|
152
|
+
}, z.core.$strip>>;
|
|
153
|
+
error: z.ZodOptional<z.ZodString>;
|
|
154
|
+
loadTimeMs: z.ZodOptional<z.ZodNumber>;
|
|
155
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
156
|
+
}, z.core.$strip>;
|
|
157
|
+
type SearchResultItem = z.infer<typeof SearchResultItemSchema>;
|
|
158
|
+
declare const SearchResponseSchema: z.ZodObject<{
|
|
159
|
+
results: z.ZodArray<z.ZodObject<{
|
|
160
|
+
query: z.ZodString;
|
|
161
|
+
success: z.ZodBoolean;
|
|
162
|
+
results: z.ZodArray<z.ZodObject<{
|
|
163
|
+
url: z.ZodString;
|
|
164
|
+
title: z.ZodString;
|
|
165
|
+
description: z.ZodString;
|
|
166
|
+
}, z.core.$strip>>;
|
|
167
|
+
error: z.ZodOptional<z.ZodString>;
|
|
168
|
+
loadTimeMs: z.ZodOptional<z.ZodNumber>;
|
|
169
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
170
|
+
}, z.core.$strip>>;
|
|
171
|
+
total: z.ZodNumber;
|
|
172
|
+
successful: z.ZodNumber;
|
|
173
|
+
failed: z.ZodNumber;
|
|
174
|
+
totalTimeMs: z.ZodNumber;
|
|
175
|
+
timestamp: z.ZodString;
|
|
176
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
177
|
+
}, z.core.$strip>;
|
|
178
|
+
type SearchResponse = z.infer<typeof SearchResponseSchema>;
|
|
179
|
+
declare const PdfMarginSchema: z.ZodObject<{
|
|
180
|
+
top: z.ZodOptional<z.ZodString>;
|
|
181
|
+
right: z.ZodOptional<z.ZodString>;
|
|
182
|
+
bottom: z.ZodOptional<z.ZodString>;
|
|
183
|
+
left: z.ZodOptional<z.ZodString>;
|
|
184
|
+
}, z.core.$strip>;
|
|
185
|
+
type PdfMargin = z.infer<typeof PdfMarginSchema>;
|
|
186
|
+
declare const GeneratePdfOptionsSchema: z.ZodObject<{
|
|
187
|
+
html: z.ZodString;
|
|
188
|
+
title: z.ZodOptional<z.ZodString>;
|
|
189
|
+
pageSize: z.ZodOptional<z.ZodEnum<{
|
|
190
|
+
A4: "A4";
|
|
191
|
+
Letter: "Letter";
|
|
192
|
+
Legal: "Legal";
|
|
193
|
+
}>>;
|
|
194
|
+
landscape: z.ZodOptional<z.ZodBoolean>;
|
|
195
|
+
margin: z.ZodOptional<z.ZodObject<{
|
|
196
|
+
top: z.ZodOptional<z.ZodString>;
|
|
197
|
+
right: z.ZodOptional<z.ZodString>;
|
|
198
|
+
bottom: z.ZodOptional<z.ZodString>;
|
|
199
|
+
left: z.ZodOptional<z.ZodString>;
|
|
200
|
+
}, z.core.$strip>>;
|
|
201
|
+
printBackground: z.ZodOptional<z.ZodBoolean>;
|
|
202
|
+
skipChartWait: z.ZodOptional<z.ZodBoolean>;
|
|
203
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
204
|
+
}, z.core.$strip>;
|
|
205
|
+
type GeneratePdfOptions = z.infer<typeof GeneratePdfOptionsSchema>;
|
|
206
|
+
declare const GeneratePdfFromUrlOptionsSchema: z.ZodObject<{
|
|
207
|
+
url: z.ZodString;
|
|
208
|
+
title: z.ZodOptional<z.ZodString>;
|
|
209
|
+
pageSize: z.ZodOptional<z.ZodEnum<{
|
|
210
|
+
A4: "A4";
|
|
211
|
+
Letter: "Letter";
|
|
212
|
+
Legal: "Legal";
|
|
213
|
+
}>>;
|
|
214
|
+
landscape: z.ZodOptional<z.ZodBoolean>;
|
|
215
|
+
margin: z.ZodOptional<z.ZodObject<{
|
|
216
|
+
top: z.ZodOptional<z.ZodString>;
|
|
217
|
+
right: z.ZodOptional<z.ZodString>;
|
|
218
|
+
bottom: z.ZodOptional<z.ZodString>;
|
|
219
|
+
left: z.ZodOptional<z.ZodString>;
|
|
220
|
+
}, z.core.$strip>>;
|
|
221
|
+
printBackground: z.ZodOptional<z.ZodBoolean>;
|
|
222
|
+
timeoutMs: z.ZodOptional<z.ZodNumber>;
|
|
223
|
+
}, z.core.$strip>;
|
|
224
|
+
type GeneratePdfFromUrlOptions = z.infer<typeof GeneratePdfFromUrlOptionsSchema>;
|
|
225
|
+
declare const PdfResponseSchema: z.ZodObject<{
|
|
226
|
+
success: z.ZodBoolean;
|
|
227
|
+
url: z.ZodOptional<z.ZodString>;
|
|
228
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
229
|
+
blobName: z.ZodOptional<z.ZodString>;
|
|
230
|
+
error: z.ZodOptional<z.ZodString>;
|
|
231
|
+
durationMs: z.ZodNumber;
|
|
232
|
+
}, z.core.$strip>;
|
|
233
|
+
type PdfResponse = z.infer<typeof PdfResponseSchema>;
|
|
234
|
+
declare const ExecuteCodeOptionsSchema: z.ZodObject<{
|
|
235
|
+
code: z.ZodString;
|
|
236
|
+
language: z.ZodOptional<z.ZodEnum<{
|
|
237
|
+
python: "python";
|
|
238
|
+
}>>;
|
|
239
|
+
}, z.core.$strip>;
|
|
240
|
+
type ExecuteCodeOptions = z.infer<typeof ExecuteCodeOptionsSchema>;
|
|
241
|
+
declare const ExecuteCodeResponseSchema: z.ZodObject<{
|
|
242
|
+
stdout: z.ZodString;
|
|
243
|
+
stderr: z.ZodString;
|
|
244
|
+
exitCode: z.ZodNumber;
|
|
245
|
+
executionTimeMs: z.ZodNumber;
|
|
246
|
+
timedOut: z.ZodBoolean;
|
|
247
|
+
memoryUsageMb: z.ZodOptional<z.ZodNumber>;
|
|
248
|
+
error: z.ZodOptional<z.ZodString>;
|
|
249
|
+
cost: z.ZodOptional<z.ZodNumber>;
|
|
250
|
+
}, z.core.$strip>;
|
|
251
|
+
type ExecuteCodeResponse = z.infer<typeof ExecuteCodeResponseSchema>;
|
|
252
|
+
declare const UpcrawlErrorResponseSchema: z.ZodObject<{
|
|
253
|
+
error: z.ZodObject<{
|
|
254
|
+
code: z.ZodString;
|
|
255
|
+
message: z.ZodString;
|
|
256
|
+
}, z.core.$strip>;
|
|
257
|
+
statusCode: z.ZodOptional<z.ZodNumber>;
|
|
258
|
+
}, z.core.$strip>;
|
|
259
|
+
type UpcrawlErrorResponse = z.infer<typeof UpcrawlErrorResponseSchema>;
|
|
229
260
|
declare class UpcrawlError extends Error {
|
|
230
261
|
readonly status: number;
|
|
231
262
|
readonly code: string;
|
|
232
263
|
constructor(message: string, status: number, code?: string);
|
|
233
264
|
}
|
|
265
|
+
declare const CreateBrowserSessionOptionsSchema: z.ZodObject<{
|
|
266
|
+
width: z.ZodOptional<z.ZodNumber>;
|
|
267
|
+
height: z.ZodOptional<z.ZodNumber>;
|
|
268
|
+
headless: z.ZodOptional<z.ZodBoolean>;
|
|
269
|
+
}, z.core.$strip>;
|
|
270
|
+
type CreateBrowserSessionOptions = z.infer<typeof CreateBrowserSessionOptionsSchema>;
|
|
271
|
+
declare const BrowserSessionSchema: z.ZodObject<{
|
|
272
|
+
sessionId: z.ZodString;
|
|
273
|
+
wsEndpoint: z.ZodString;
|
|
274
|
+
vncUrl: z.ZodNullable<z.ZodString>;
|
|
275
|
+
affinityCookie: z.ZodOptional<z.ZodString>;
|
|
276
|
+
createdAt: z.ZodDate;
|
|
277
|
+
width: z.ZodNumber;
|
|
278
|
+
height: z.ZodNumber;
|
|
279
|
+
}, z.core.$strip>;
|
|
280
|
+
type BrowserSession = z.infer<typeof BrowserSessionSchema>;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Upcrawl Browser Namespace
|
|
284
|
+
* Manage browser sessions for remote control with Playwright/Puppeteer
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```typescript
|
|
288
|
+
* import Upcrawl from '@upcrawl/sdk';
|
|
289
|
+
* import playwright from 'playwright-core';
|
|
290
|
+
*
|
|
291
|
+
* const upcrawl = new Upcrawl('uc-your-api-key');
|
|
292
|
+
*
|
|
293
|
+
* // Create a browser session
|
|
294
|
+
* const session = await upcrawl.browser.create({
|
|
295
|
+
* width: 1280,
|
|
296
|
+
* height: 720,
|
|
297
|
+
* headless: true
|
|
298
|
+
* });
|
|
299
|
+
*
|
|
300
|
+
* // Connect with Playwright
|
|
301
|
+
* const browser = await playwright.connect(session.wsEndpoint);
|
|
302
|
+
* const page = await browser.newPage();
|
|
303
|
+
* await page.goto('https://example.com');
|
|
304
|
+
*
|
|
305
|
+
* // Close the session when done
|
|
306
|
+
* await upcrawl.browser.close(session.sessionId);
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
declare class Browser {
|
|
311
|
+
private createClient;
|
|
312
|
+
constructor(createClient: () => AxiosInstance);
|
|
313
|
+
/**
|
|
314
|
+
* Create a new browser session for remote control
|
|
315
|
+
* @param options - Session options including viewport size and headless mode
|
|
316
|
+
* @returns Promise with session details including WebSocket URL
|
|
317
|
+
*
|
|
318
|
+
* @example
|
|
319
|
+
* ```typescript
|
|
320
|
+
* const session = await upcrawl.browser.create({
|
|
321
|
+
* width: 1280,
|
|
322
|
+
* height: 720,
|
|
323
|
+
* headless: true
|
|
324
|
+
* });
|
|
325
|
+
*
|
|
326
|
+
* console.log(session.wsEndpoint); // WebSocket URL for Playwright
|
|
327
|
+
* console.log(session.vncUrl); // VNC URL for viewing (if available)
|
|
328
|
+
* ```
|
|
329
|
+
*/
|
|
330
|
+
create(options?: CreateBrowserSessionOptions): Promise<BrowserSession>;
|
|
331
|
+
/**
|
|
332
|
+
* Close a browser session
|
|
333
|
+
* @param sessionId - The session ID to close
|
|
334
|
+
* @returns Promise that resolves when session is closed
|
|
335
|
+
*
|
|
336
|
+
* @example
|
|
337
|
+
* ```typescript
|
|
338
|
+
* await upcrawl.browser.close(session.sessionId);
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
close(sessionId: string): Promise<void>;
|
|
342
|
+
/**
|
|
343
|
+
* Handle API errors and convert to UpcrawlError
|
|
344
|
+
*/
|
|
345
|
+
private handleError;
|
|
346
|
+
}
|
|
234
347
|
|
|
235
348
|
/**
|
|
236
349
|
* Upcrawl API Client
|
|
@@ -525,10 +638,27 @@ declare const Upcrawl: {
|
|
|
525
638
|
* @returns Promise with execution response (stdout, stderr, exit code, memory usage)
|
|
526
639
|
*/
|
|
527
640
|
readonly executeCode: typeof executeCode;
|
|
641
|
+
/**
|
|
642
|
+
* Browser session management
|
|
643
|
+
* Create and manage browser sessions for remote control with Playwright/Puppeteer
|
|
644
|
+
*
|
|
645
|
+
* @example
|
|
646
|
+
* ```typescript
|
|
647
|
+
* const session = await Upcrawl.browser.create({
|
|
648
|
+
* width: 1280,
|
|
649
|
+
* height: 720,
|
|
650
|
+
* headless: true
|
|
651
|
+
* });
|
|
652
|
+
*
|
|
653
|
+
* const browser = await playwright.connect(session.wsEndpoint);
|
|
654
|
+
* await upcrawl.browser.close(session.sessionId);
|
|
655
|
+
* ```
|
|
656
|
+
*/
|
|
657
|
+
readonly browser: Browser;
|
|
528
658
|
/**
|
|
529
659
|
* Error class for Upcrawl API errors
|
|
530
660
|
*/
|
|
531
661
|
readonly UpcrawlError: typeof UpcrawlError;
|
|
532
662
|
};
|
|
533
663
|
|
|
534
|
-
export { type BatchScrapeOptions, type BatchScrapeResponse, type ExecuteCodeOptions, type ExecuteCodeResponse, type GeneratePdfFromUrlOptions, type GeneratePdfOptions, type PdfMargin, type PdfResponse, type ScrapeMetadata, type ScrapeOptions, type ScrapeResponse, type SearchOptions, type SearchResponse, type SearchResultItem, type SearchResultWeb, type SummaryQuery, type UpcrawlConfig, UpcrawlError, type UpcrawlErrorResponse, batchScrape, configure, Upcrawl as default, executeCode, generatePdf, generatePdfFromUrl, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
|
|
664
|
+
export { type BatchScrapeOptions, BatchScrapeOptionsSchema, type BatchScrapeResponse, BatchScrapeResponseSchema, Browser, type BrowserSession, BrowserSessionSchema, type CreateBrowserSessionOptions, CreateBrowserSessionOptionsSchema, type ExecuteCodeOptions, ExecuteCodeOptionsSchema, type ExecuteCodeResponse, ExecuteCodeResponseSchema, type GeneratePdfFromUrlOptions, GeneratePdfFromUrlOptionsSchema, type GeneratePdfOptions, GeneratePdfOptionsSchema, type PdfMargin, PdfMarginSchema, type PdfResponse, PdfResponseSchema, type ScrapeMetadata, ScrapeMetadataSchema, type ScrapeOptions, ScrapeOptionsSchema, type ScrapeResponse, ScrapeResponseSchema, type SearchOptions, SearchOptionsSchema, type SearchResponse, SearchResponseSchema, type SearchResultItem, SearchResultItemSchema, type SearchResultWeb, SearchResultWebSchema, type SummaryQuery, SummaryQuerySchema, type UpcrawlConfig, UpcrawlConfigSchema, UpcrawlError, type UpcrawlErrorResponse, UpcrawlErrorResponseSchema, batchScrape, configure, Upcrawl as default, executeCode, generatePdf, generatePdfFromUrl, getConfig, resetConfig, scrape, search, setApiKey, setBaseUrl, setTimeout };
|