@stack0/sdk 0.2.0 → 0.2.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/dist/index.d.mts +17 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +626 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +626 -9
- package/dist/index.mjs.map +1 -1
- package/dist/mail/index.js +1 -8
- package/dist/mail/index.js.map +1 -1
- package/dist/mail/index.mjs +1 -8
- package/dist/mail/index.mjs.map +1 -1
- package/dist/webdata/index.d.mts +696 -0
- package/dist/webdata/index.d.ts +696 -0
- package/dist/webdata/index.js +693 -0
- package/dist/webdata/index.js.map +1 -0
- package/dist/webdata/index.mjs +691 -0
- package/dist/webdata/index.mjs.map +1 -0
- package/package.json +7 -2
|
@@ -0,0 +1,696 @@
|
|
|
1
|
+
import { H as HttpClientConfig } from '../http-client-Wr9lXo9_.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Type definitions for Stack0 Webdata API
|
|
5
|
+
*/
|
|
6
|
+
type Environment = "sandbox" | "production";
|
|
7
|
+
type ScreenshotStatus = "pending" | "processing" | "completed" | "failed";
|
|
8
|
+
type ScreenshotFormat = "png" | "jpeg" | "webp" | "pdf";
|
|
9
|
+
type DeviceType = "desktop" | "tablet" | "mobile";
|
|
10
|
+
interface Screenshot {
|
|
11
|
+
id: string;
|
|
12
|
+
organizationId: string;
|
|
13
|
+
projectId: string | null;
|
|
14
|
+
environment: Environment;
|
|
15
|
+
url: string;
|
|
16
|
+
format: ScreenshotFormat;
|
|
17
|
+
quality: number | null;
|
|
18
|
+
fullPage: boolean;
|
|
19
|
+
deviceType: DeviceType;
|
|
20
|
+
viewportWidth: number | null;
|
|
21
|
+
viewportHeight: number | null;
|
|
22
|
+
status: ScreenshotStatus;
|
|
23
|
+
imageUrl: string | null;
|
|
24
|
+
imageSize: number | null;
|
|
25
|
+
imageWidth: number | null;
|
|
26
|
+
imageHeight: number | null;
|
|
27
|
+
error: string | null;
|
|
28
|
+
processingTimeMs: number | null;
|
|
29
|
+
metadata: Record<string, unknown> | null;
|
|
30
|
+
createdAt: Date;
|
|
31
|
+
completedAt: Date | null;
|
|
32
|
+
}
|
|
33
|
+
type ResourceType = "image" | "stylesheet" | "script" | "font" | "media" | "xhr" | "fetch" | "websocket";
|
|
34
|
+
interface Clip {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
width: number;
|
|
38
|
+
height: number;
|
|
39
|
+
}
|
|
40
|
+
interface CreateScreenshotRequest {
|
|
41
|
+
url: string;
|
|
42
|
+
environment?: Environment;
|
|
43
|
+
projectId?: string;
|
|
44
|
+
format?: ScreenshotFormat;
|
|
45
|
+
quality?: number;
|
|
46
|
+
fullPage?: boolean;
|
|
47
|
+
deviceType?: DeviceType;
|
|
48
|
+
viewportWidth?: number;
|
|
49
|
+
viewportHeight?: number;
|
|
50
|
+
deviceScaleFactor?: number;
|
|
51
|
+
waitForSelector?: string;
|
|
52
|
+
waitForTimeout?: number;
|
|
53
|
+
blockAds?: boolean;
|
|
54
|
+
blockCookieBanners?: boolean;
|
|
55
|
+
blockChatWidgets?: boolean;
|
|
56
|
+
blockTrackers?: boolean;
|
|
57
|
+
blockUrls?: string[];
|
|
58
|
+
blockResources?: ResourceType[];
|
|
59
|
+
darkMode?: boolean;
|
|
60
|
+
customCss?: string;
|
|
61
|
+
customJs?: string;
|
|
62
|
+
headers?: Record<string, string>;
|
|
63
|
+
cookies?: Array<{
|
|
64
|
+
name: string;
|
|
65
|
+
value: string;
|
|
66
|
+
domain?: string;
|
|
67
|
+
}>;
|
|
68
|
+
selector?: string;
|
|
69
|
+
hideSelectors?: string[];
|
|
70
|
+
clickSelector?: string;
|
|
71
|
+
omitBackground?: boolean;
|
|
72
|
+
userAgent?: string;
|
|
73
|
+
clip?: Clip;
|
|
74
|
+
thumbnailWidth?: number;
|
|
75
|
+
thumbnailHeight?: number;
|
|
76
|
+
cacheKey?: string;
|
|
77
|
+
cacheTtl?: number;
|
|
78
|
+
webhookUrl?: string;
|
|
79
|
+
webhookSecret?: string;
|
|
80
|
+
metadata?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
interface CreateScreenshotResponse {
|
|
83
|
+
id: string;
|
|
84
|
+
status: ScreenshotStatus;
|
|
85
|
+
}
|
|
86
|
+
interface GetScreenshotRequest {
|
|
87
|
+
id: string;
|
|
88
|
+
environment?: Environment;
|
|
89
|
+
projectId?: string;
|
|
90
|
+
}
|
|
91
|
+
interface ListScreenshotsRequest {
|
|
92
|
+
environment?: Environment;
|
|
93
|
+
projectId?: string;
|
|
94
|
+
status?: ScreenshotStatus;
|
|
95
|
+
url?: string;
|
|
96
|
+
limit?: number;
|
|
97
|
+
cursor?: string;
|
|
98
|
+
}
|
|
99
|
+
interface ListScreenshotsResponse {
|
|
100
|
+
items: Screenshot[];
|
|
101
|
+
nextCursor?: string;
|
|
102
|
+
}
|
|
103
|
+
type ExtractionStatus = "pending" | "processing" | "completed" | "failed";
|
|
104
|
+
type ExtractionMode = "auto" | "schema" | "markdown" | "raw";
|
|
105
|
+
interface PageMetadata {
|
|
106
|
+
title?: string;
|
|
107
|
+
description?: string;
|
|
108
|
+
ogImage?: string;
|
|
109
|
+
favicon?: string;
|
|
110
|
+
links?: string[];
|
|
111
|
+
images?: string[];
|
|
112
|
+
}
|
|
113
|
+
interface Extraction {
|
|
114
|
+
id: string;
|
|
115
|
+
organizationId: string;
|
|
116
|
+
projectId: string | null;
|
|
117
|
+
environment: Environment;
|
|
118
|
+
url: string;
|
|
119
|
+
mode: string;
|
|
120
|
+
status: ExtractionStatus;
|
|
121
|
+
extractedData: Record<string, unknown> | null;
|
|
122
|
+
markdown: string | null;
|
|
123
|
+
rawHtml: string | null;
|
|
124
|
+
pageMetadata: PageMetadata | null;
|
|
125
|
+
error: string | null;
|
|
126
|
+
processingTimeMs: number | null;
|
|
127
|
+
tokensUsed: number | null;
|
|
128
|
+
metadata: Record<string, unknown> | null;
|
|
129
|
+
createdAt: Date;
|
|
130
|
+
completedAt: Date | null;
|
|
131
|
+
}
|
|
132
|
+
interface CreateExtractionRequest {
|
|
133
|
+
url: string;
|
|
134
|
+
environment?: Environment;
|
|
135
|
+
projectId?: string;
|
|
136
|
+
mode?: ExtractionMode;
|
|
137
|
+
schema?: Record<string, unknown>;
|
|
138
|
+
prompt?: string;
|
|
139
|
+
includeLinks?: boolean;
|
|
140
|
+
includeImages?: boolean;
|
|
141
|
+
includeMetadata?: boolean;
|
|
142
|
+
waitForSelector?: string;
|
|
143
|
+
waitForTimeout?: number;
|
|
144
|
+
headers?: Record<string, string>;
|
|
145
|
+
cookies?: Array<{
|
|
146
|
+
name: string;
|
|
147
|
+
value: string;
|
|
148
|
+
domain?: string;
|
|
149
|
+
}>;
|
|
150
|
+
webhookUrl?: string;
|
|
151
|
+
webhookSecret?: string;
|
|
152
|
+
metadata?: Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
interface CreateExtractionResponse {
|
|
155
|
+
id: string;
|
|
156
|
+
status: ExtractionStatus;
|
|
157
|
+
}
|
|
158
|
+
interface GetExtractionRequest {
|
|
159
|
+
id: string;
|
|
160
|
+
environment?: Environment;
|
|
161
|
+
projectId?: string;
|
|
162
|
+
}
|
|
163
|
+
interface ListExtractionsRequest {
|
|
164
|
+
environment?: Environment;
|
|
165
|
+
projectId?: string;
|
|
166
|
+
status?: ExtractionStatus;
|
|
167
|
+
url?: string;
|
|
168
|
+
limit?: number;
|
|
169
|
+
cursor?: string;
|
|
170
|
+
}
|
|
171
|
+
interface ListExtractionsResponse {
|
|
172
|
+
items: Extraction[];
|
|
173
|
+
nextCursor?: string;
|
|
174
|
+
}
|
|
175
|
+
type ScheduleFrequency = "hourly" | "daily" | "weekly" | "monthly";
|
|
176
|
+
type ScheduleType = "screenshot" | "extraction";
|
|
177
|
+
interface Schedule {
|
|
178
|
+
id: string;
|
|
179
|
+
organizationId: string;
|
|
180
|
+
projectId: string | null;
|
|
181
|
+
environment: Environment;
|
|
182
|
+
name: string;
|
|
183
|
+
url: string;
|
|
184
|
+
type: ScheduleType;
|
|
185
|
+
frequency: ScheduleFrequency;
|
|
186
|
+
config: Record<string, unknown>;
|
|
187
|
+
isActive: boolean;
|
|
188
|
+
detectChanges: boolean;
|
|
189
|
+
changeThreshold: number | null;
|
|
190
|
+
webhookUrl: string | null;
|
|
191
|
+
totalRuns: number;
|
|
192
|
+
successfulRuns: number;
|
|
193
|
+
failedRuns: number;
|
|
194
|
+
lastRunAt: Date | null;
|
|
195
|
+
nextRunAt: Date | null;
|
|
196
|
+
metadata: Record<string, unknown> | null;
|
|
197
|
+
createdAt: Date;
|
|
198
|
+
updatedAt: Date;
|
|
199
|
+
}
|
|
200
|
+
interface CreateScheduleRequest {
|
|
201
|
+
name: string;
|
|
202
|
+
url: string;
|
|
203
|
+
type: ScheduleType;
|
|
204
|
+
environment?: Environment;
|
|
205
|
+
projectId?: string;
|
|
206
|
+
frequency?: ScheduleFrequency;
|
|
207
|
+
config: Record<string, unknown>;
|
|
208
|
+
detectChanges?: boolean;
|
|
209
|
+
changeThreshold?: number;
|
|
210
|
+
webhookUrl?: string;
|
|
211
|
+
webhookSecret?: string;
|
|
212
|
+
metadata?: Record<string, unknown>;
|
|
213
|
+
}
|
|
214
|
+
interface CreateScheduleResponse {
|
|
215
|
+
id: string;
|
|
216
|
+
}
|
|
217
|
+
interface UpdateScheduleRequest {
|
|
218
|
+
id: string;
|
|
219
|
+
environment?: Environment;
|
|
220
|
+
projectId?: string;
|
|
221
|
+
name?: string;
|
|
222
|
+
frequency?: ScheduleFrequency;
|
|
223
|
+
config?: Record<string, unknown>;
|
|
224
|
+
isActive?: boolean;
|
|
225
|
+
detectChanges?: boolean;
|
|
226
|
+
changeThreshold?: number;
|
|
227
|
+
webhookUrl?: string | null;
|
|
228
|
+
webhookSecret?: string | null;
|
|
229
|
+
metadata?: Record<string, unknown>;
|
|
230
|
+
}
|
|
231
|
+
interface GetScheduleRequest {
|
|
232
|
+
id: string;
|
|
233
|
+
environment?: Environment;
|
|
234
|
+
projectId?: string;
|
|
235
|
+
}
|
|
236
|
+
interface ListSchedulesRequest {
|
|
237
|
+
environment?: Environment;
|
|
238
|
+
projectId?: string;
|
|
239
|
+
type?: ScheduleType;
|
|
240
|
+
isActive?: boolean;
|
|
241
|
+
limit?: number;
|
|
242
|
+
cursor?: string;
|
|
243
|
+
}
|
|
244
|
+
interface ListSchedulesResponse {
|
|
245
|
+
items: Schedule[];
|
|
246
|
+
nextCursor?: string;
|
|
247
|
+
}
|
|
248
|
+
interface Usage {
|
|
249
|
+
periodStart: Date;
|
|
250
|
+
periodEnd: Date;
|
|
251
|
+
screenshotsTotal: number;
|
|
252
|
+
screenshotsSuccessful: number;
|
|
253
|
+
screenshotsFailed: number;
|
|
254
|
+
screenshotCreditsUsed: number;
|
|
255
|
+
extractionsTotal: number;
|
|
256
|
+
extractionsSuccessful: number;
|
|
257
|
+
extractionsFailed: number;
|
|
258
|
+
extractionCreditsUsed: number;
|
|
259
|
+
extractionTokensUsed: number;
|
|
260
|
+
batchJobsTotal: number;
|
|
261
|
+
batchUrlsProcessed: number;
|
|
262
|
+
}
|
|
263
|
+
interface GetUsageRequest {
|
|
264
|
+
environment?: Environment;
|
|
265
|
+
periodStart?: string;
|
|
266
|
+
periodEnd?: string;
|
|
267
|
+
}
|
|
268
|
+
type BatchJobStatus = "pending" | "processing" | "completed" | "failed" | "cancelled";
|
|
269
|
+
type BatchJobType = "screenshot" | "extraction";
|
|
270
|
+
interface BatchJob {
|
|
271
|
+
id: string;
|
|
272
|
+
organizationId: string;
|
|
273
|
+
projectId: string | null;
|
|
274
|
+
environment: Environment;
|
|
275
|
+
type: BatchJobType;
|
|
276
|
+
name: string | null;
|
|
277
|
+
status: BatchJobStatus;
|
|
278
|
+
urls: string[];
|
|
279
|
+
config: Record<string, unknown>;
|
|
280
|
+
totalUrls: number;
|
|
281
|
+
processedUrls: number;
|
|
282
|
+
successfulUrls: number;
|
|
283
|
+
failedUrls: number;
|
|
284
|
+
webhookUrl: string | null;
|
|
285
|
+
metadata: Record<string, unknown> | null;
|
|
286
|
+
createdAt: Date;
|
|
287
|
+
startedAt: Date | null;
|
|
288
|
+
completedAt: Date | null;
|
|
289
|
+
}
|
|
290
|
+
interface CreateBatchScreenshotsRequest {
|
|
291
|
+
urls: string[];
|
|
292
|
+
environment?: Environment;
|
|
293
|
+
projectId?: string;
|
|
294
|
+
name?: string;
|
|
295
|
+
config?: {
|
|
296
|
+
format?: ScreenshotFormat;
|
|
297
|
+
quality?: number;
|
|
298
|
+
fullPage?: boolean;
|
|
299
|
+
deviceType?: DeviceType;
|
|
300
|
+
viewportWidth?: number;
|
|
301
|
+
viewportHeight?: number;
|
|
302
|
+
blockAds?: boolean;
|
|
303
|
+
blockCookieBanners?: boolean;
|
|
304
|
+
waitForSelector?: string;
|
|
305
|
+
waitForTimeout?: number;
|
|
306
|
+
};
|
|
307
|
+
webhookUrl?: string;
|
|
308
|
+
webhookSecret?: string;
|
|
309
|
+
metadata?: Record<string, unknown>;
|
|
310
|
+
}
|
|
311
|
+
interface CreateBatchExtractionsRequest {
|
|
312
|
+
urls: string[];
|
|
313
|
+
environment?: Environment;
|
|
314
|
+
projectId?: string;
|
|
315
|
+
name?: string;
|
|
316
|
+
config?: {
|
|
317
|
+
mode?: ExtractionMode;
|
|
318
|
+
schema?: Record<string, unknown>;
|
|
319
|
+
prompt?: string;
|
|
320
|
+
includeLinks?: boolean;
|
|
321
|
+
includeImages?: boolean;
|
|
322
|
+
includeMetadata?: boolean;
|
|
323
|
+
waitForSelector?: string;
|
|
324
|
+
waitForTimeout?: number;
|
|
325
|
+
};
|
|
326
|
+
webhookUrl?: string;
|
|
327
|
+
webhookSecret?: string;
|
|
328
|
+
metadata?: Record<string, unknown>;
|
|
329
|
+
}
|
|
330
|
+
interface CreateBatchResponse {
|
|
331
|
+
id: string;
|
|
332
|
+
status: BatchJobStatus;
|
|
333
|
+
totalUrls: number;
|
|
334
|
+
}
|
|
335
|
+
interface GetBatchJobRequest {
|
|
336
|
+
id: string;
|
|
337
|
+
environment?: Environment;
|
|
338
|
+
projectId?: string;
|
|
339
|
+
}
|
|
340
|
+
interface ListBatchJobsRequest {
|
|
341
|
+
environment?: Environment;
|
|
342
|
+
projectId?: string;
|
|
343
|
+
status?: BatchJobStatus;
|
|
344
|
+
type?: BatchJobType;
|
|
345
|
+
limit?: number;
|
|
346
|
+
cursor?: string;
|
|
347
|
+
}
|
|
348
|
+
interface ListBatchJobsResponse {
|
|
349
|
+
items: BatchJob[];
|
|
350
|
+
nextCursor?: string;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/**
|
|
354
|
+
* Stack0 Webdata Client
|
|
355
|
+
* Capture screenshots and extract data from web pages
|
|
356
|
+
*/
|
|
357
|
+
|
|
358
|
+
declare class Webdata {
|
|
359
|
+
private http;
|
|
360
|
+
constructor(config: HttpClientConfig);
|
|
361
|
+
/**
|
|
362
|
+
* Capture a screenshot of a URL
|
|
363
|
+
*
|
|
364
|
+
* @example
|
|
365
|
+
* ```typescript
|
|
366
|
+
* const { id, status } = await webdata.screenshot({
|
|
367
|
+
* url: 'https://example.com',
|
|
368
|
+
* format: 'png',
|
|
369
|
+
* fullPage: true,
|
|
370
|
+
* deviceType: 'desktop',
|
|
371
|
+
* });
|
|
372
|
+
*
|
|
373
|
+
* // Poll for completion
|
|
374
|
+
* const screenshot = await webdata.getScreenshot({ id });
|
|
375
|
+
* console.log(screenshot.imageUrl);
|
|
376
|
+
* ```
|
|
377
|
+
*/
|
|
378
|
+
screenshot(request: CreateScreenshotRequest): Promise<CreateScreenshotResponse>;
|
|
379
|
+
/**
|
|
380
|
+
* Get a screenshot by ID
|
|
381
|
+
*
|
|
382
|
+
* @example
|
|
383
|
+
* ```typescript
|
|
384
|
+
* const screenshot = await webdata.getScreenshot({ id: 'screenshot-id' });
|
|
385
|
+
* if (screenshot.status === 'completed') {
|
|
386
|
+
* console.log(screenshot.imageUrl);
|
|
387
|
+
* }
|
|
388
|
+
* ```
|
|
389
|
+
*/
|
|
390
|
+
getScreenshot(request: GetScreenshotRequest): Promise<Screenshot>;
|
|
391
|
+
/**
|
|
392
|
+
* List screenshots with pagination and filters
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```typescript
|
|
396
|
+
* const { items, nextCursor } = await webdata.listScreenshots({
|
|
397
|
+
* status: 'completed',
|
|
398
|
+
* limit: 20,
|
|
399
|
+
* });
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
listScreenshots(request?: ListScreenshotsRequest): Promise<ListScreenshotsResponse>;
|
|
403
|
+
/**
|
|
404
|
+
* Delete a screenshot
|
|
405
|
+
*
|
|
406
|
+
* @example
|
|
407
|
+
* ```typescript
|
|
408
|
+
* await webdata.deleteScreenshot({ id: 'screenshot-id' });
|
|
409
|
+
* ```
|
|
410
|
+
*/
|
|
411
|
+
deleteScreenshot(request: GetScreenshotRequest): Promise<{
|
|
412
|
+
success: boolean;
|
|
413
|
+
}>;
|
|
414
|
+
/**
|
|
415
|
+
* Capture a screenshot and wait for completion
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* const screenshot = await webdata.screenshotAndWait({
|
|
420
|
+
* url: 'https://example.com',
|
|
421
|
+
* format: 'png',
|
|
422
|
+
* });
|
|
423
|
+
* console.log(screenshot.imageUrl);
|
|
424
|
+
* ```
|
|
425
|
+
*/
|
|
426
|
+
screenshotAndWait(request: CreateScreenshotRequest, options?: {
|
|
427
|
+
pollInterval?: number;
|
|
428
|
+
timeout?: number;
|
|
429
|
+
}): Promise<Screenshot>;
|
|
430
|
+
/**
|
|
431
|
+
* Extract content from a URL
|
|
432
|
+
*
|
|
433
|
+
* @example
|
|
434
|
+
* ```typescript
|
|
435
|
+
* const { id, status } = await webdata.extract({
|
|
436
|
+
* url: 'https://example.com/article',
|
|
437
|
+
* mode: 'markdown',
|
|
438
|
+
* includeMetadata: true,
|
|
439
|
+
* });
|
|
440
|
+
*
|
|
441
|
+
* // Poll for completion
|
|
442
|
+
* const extraction = await webdata.getExtraction({ id });
|
|
443
|
+
* console.log(extraction.markdown);
|
|
444
|
+
* ```
|
|
445
|
+
*/
|
|
446
|
+
extract(request: CreateExtractionRequest): Promise<CreateExtractionResponse>;
|
|
447
|
+
/**
|
|
448
|
+
* Get an extraction by ID
|
|
449
|
+
*
|
|
450
|
+
* @example
|
|
451
|
+
* ```typescript
|
|
452
|
+
* const extraction = await webdata.getExtraction({ id: 'extraction-id' });
|
|
453
|
+
* if (extraction.status === 'completed') {
|
|
454
|
+
* console.log(extraction.markdown);
|
|
455
|
+
* console.log(extraction.pageMetadata);
|
|
456
|
+
* }
|
|
457
|
+
* ```
|
|
458
|
+
*/
|
|
459
|
+
getExtraction(request: GetExtractionRequest): Promise<Extraction>;
|
|
460
|
+
/**
|
|
461
|
+
* List extractions with pagination and filters
|
|
462
|
+
*
|
|
463
|
+
* @example
|
|
464
|
+
* ```typescript
|
|
465
|
+
* const { items, nextCursor } = await webdata.listExtractions({
|
|
466
|
+
* status: 'completed',
|
|
467
|
+
* limit: 20,
|
|
468
|
+
* });
|
|
469
|
+
* ```
|
|
470
|
+
*/
|
|
471
|
+
listExtractions(request?: ListExtractionsRequest): Promise<ListExtractionsResponse>;
|
|
472
|
+
/**
|
|
473
|
+
* Delete an extraction
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```typescript
|
|
477
|
+
* await webdata.deleteExtraction({ id: 'extraction-id' });
|
|
478
|
+
* ```
|
|
479
|
+
*/
|
|
480
|
+
deleteExtraction(request: GetExtractionRequest): Promise<{
|
|
481
|
+
success: boolean;
|
|
482
|
+
}>;
|
|
483
|
+
/**
|
|
484
|
+
* Extract content and wait for completion
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```typescript
|
|
488
|
+
* const extraction = await webdata.extractAndWait({
|
|
489
|
+
* url: 'https://example.com/article',
|
|
490
|
+
* mode: 'markdown',
|
|
491
|
+
* });
|
|
492
|
+
* console.log(extraction.markdown);
|
|
493
|
+
* ```
|
|
494
|
+
*/
|
|
495
|
+
extractAndWait(request: CreateExtractionRequest, options?: {
|
|
496
|
+
pollInterval?: number;
|
|
497
|
+
timeout?: number;
|
|
498
|
+
}): Promise<Extraction>;
|
|
499
|
+
/**
|
|
500
|
+
* Create a scheduled screenshot or extraction job
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* ```typescript
|
|
504
|
+
* const { id } = await webdata.createSchedule({
|
|
505
|
+
* name: 'Daily homepage screenshot',
|
|
506
|
+
* url: 'https://example.com',
|
|
507
|
+
* type: 'screenshot',
|
|
508
|
+
* frequency: 'daily',
|
|
509
|
+
* config: { format: 'png', fullPage: true },
|
|
510
|
+
* });
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
createSchedule(request: CreateScheduleRequest): Promise<CreateScheduleResponse>;
|
|
514
|
+
/**
|
|
515
|
+
* Update a schedule
|
|
516
|
+
*
|
|
517
|
+
* @example
|
|
518
|
+
* ```typescript
|
|
519
|
+
* await webdata.updateSchedule({
|
|
520
|
+
* id: 'schedule-id',
|
|
521
|
+
* frequency: 'weekly',
|
|
522
|
+
* isActive: false,
|
|
523
|
+
* });
|
|
524
|
+
* ```
|
|
525
|
+
*/
|
|
526
|
+
updateSchedule(request: UpdateScheduleRequest): Promise<{
|
|
527
|
+
success: boolean;
|
|
528
|
+
}>;
|
|
529
|
+
/**
|
|
530
|
+
* Get a schedule by ID
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```typescript
|
|
534
|
+
* const schedule = await webdata.getSchedule({ id: 'schedule-id' });
|
|
535
|
+
* console.log(schedule.nextRunAt);
|
|
536
|
+
* ```
|
|
537
|
+
*/
|
|
538
|
+
getSchedule(request: GetScheduleRequest): Promise<Schedule>;
|
|
539
|
+
/**
|
|
540
|
+
* List schedules with pagination and filters
|
|
541
|
+
*
|
|
542
|
+
* @example
|
|
543
|
+
* ```typescript
|
|
544
|
+
* const { items, nextCursor } = await webdata.listSchedules({
|
|
545
|
+
* type: 'screenshot',
|
|
546
|
+
* isActive: true,
|
|
547
|
+
* });
|
|
548
|
+
* ```
|
|
549
|
+
*/
|
|
550
|
+
listSchedules(request?: ListSchedulesRequest): Promise<ListSchedulesResponse>;
|
|
551
|
+
/**
|
|
552
|
+
* Delete a schedule
|
|
553
|
+
*
|
|
554
|
+
* @example
|
|
555
|
+
* ```typescript
|
|
556
|
+
* await webdata.deleteSchedule({ id: 'schedule-id' });
|
|
557
|
+
* ```
|
|
558
|
+
*/
|
|
559
|
+
deleteSchedule(request: GetScheduleRequest): Promise<{
|
|
560
|
+
success: boolean;
|
|
561
|
+
}>;
|
|
562
|
+
/**
|
|
563
|
+
* Toggle a schedule on or off
|
|
564
|
+
*
|
|
565
|
+
* @example
|
|
566
|
+
* ```typescript
|
|
567
|
+
* const { isActive } = await webdata.toggleSchedule({ id: 'schedule-id' });
|
|
568
|
+
* console.log(`Schedule is now ${isActive ? 'active' : 'paused'}`);
|
|
569
|
+
* ```
|
|
570
|
+
*/
|
|
571
|
+
toggleSchedule(request: GetScheduleRequest): Promise<{
|
|
572
|
+
isActive: boolean;
|
|
573
|
+
}>;
|
|
574
|
+
/**
|
|
575
|
+
* Get usage statistics
|
|
576
|
+
*
|
|
577
|
+
* @example
|
|
578
|
+
* ```typescript
|
|
579
|
+
* const usage = await webdata.getUsage({
|
|
580
|
+
* periodStart: '2024-01-01T00:00:00Z',
|
|
581
|
+
* periodEnd: '2024-01-31T23:59:59Z',
|
|
582
|
+
* });
|
|
583
|
+
* console.log(`Screenshots: ${usage.screenshotsTotal}`);
|
|
584
|
+
* console.log(`Extractions: ${usage.extractionsTotal}`);
|
|
585
|
+
* ```
|
|
586
|
+
*/
|
|
587
|
+
getUsage(request?: GetUsageRequest): Promise<Usage>;
|
|
588
|
+
/**
|
|
589
|
+
* Create a batch screenshot job for multiple URLs
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
* ```typescript
|
|
593
|
+
* const { id, totalUrls } = await webdata.batchScreenshots({
|
|
594
|
+
* urls: [
|
|
595
|
+
* 'https://example.com',
|
|
596
|
+
* 'https://example.org',
|
|
597
|
+
* ],
|
|
598
|
+
* config: { format: 'png', fullPage: true },
|
|
599
|
+
* });
|
|
600
|
+
*
|
|
601
|
+
* // Poll for completion
|
|
602
|
+
* const job = await webdata.getBatchJob({ id });
|
|
603
|
+
* console.log(`Progress: ${job.processedUrls}/${job.totalUrls}`);
|
|
604
|
+
* ```
|
|
605
|
+
*/
|
|
606
|
+
batchScreenshots(request: CreateBatchScreenshotsRequest): Promise<CreateBatchResponse>;
|
|
607
|
+
/**
|
|
608
|
+
* Create a batch extraction job for multiple URLs
|
|
609
|
+
*
|
|
610
|
+
* @example
|
|
611
|
+
* ```typescript
|
|
612
|
+
* const { id, totalUrls } = await webdata.batchExtractions({
|
|
613
|
+
* urls: [
|
|
614
|
+
* 'https://example.com/article1',
|
|
615
|
+
* 'https://example.com/article2',
|
|
616
|
+
* ],
|
|
617
|
+
* config: { mode: 'markdown' },
|
|
618
|
+
* });
|
|
619
|
+
* ```
|
|
620
|
+
*/
|
|
621
|
+
batchExtractions(request: CreateBatchExtractionsRequest): Promise<CreateBatchResponse>;
|
|
622
|
+
/**
|
|
623
|
+
* Get a batch job by ID
|
|
624
|
+
*
|
|
625
|
+
* @example
|
|
626
|
+
* ```typescript
|
|
627
|
+
* const job = await webdata.getBatchJob({ id: 'batch-id' });
|
|
628
|
+
* console.log(`Status: ${job.status}`);
|
|
629
|
+
* console.log(`Progress: ${job.processedUrls}/${job.totalUrls}`);
|
|
630
|
+
* ```
|
|
631
|
+
*/
|
|
632
|
+
getBatchJob(request: GetBatchJobRequest): Promise<BatchJob>;
|
|
633
|
+
/**
|
|
634
|
+
* List batch jobs with pagination and filters
|
|
635
|
+
*
|
|
636
|
+
* @example
|
|
637
|
+
* ```typescript
|
|
638
|
+
* const { items, nextCursor } = await webdata.listBatchJobs({
|
|
639
|
+
* status: 'completed',
|
|
640
|
+
* type: 'screenshot',
|
|
641
|
+
* limit: 20,
|
|
642
|
+
* });
|
|
643
|
+
* ```
|
|
644
|
+
*/
|
|
645
|
+
listBatchJobs(request?: ListBatchJobsRequest): Promise<ListBatchJobsResponse>;
|
|
646
|
+
/**
|
|
647
|
+
* Cancel a batch job
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* ```typescript
|
|
651
|
+
* await webdata.cancelBatchJob({ id: 'batch-id' });
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
cancelBatchJob(request: GetBatchJobRequest): Promise<{
|
|
655
|
+
success: boolean;
|
|
656
|
+
}>;
|
|
657
|
+
/**
|
|
658
|
+
* Create a batch screenshot job and wait for completion
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* const job = await webdata.batchScreenshotsAndWait({
|
|
663
|
+
* urls: ['https://example.com', 'https://example.org'],
|
|
664
|
+
* config: { format: 'png' },
|
|
665
|
+
* });
|
|
666
|
+
* console.log(`Completed: ${job.successfulUrls} successful, ${job.failedUrls} failed`);
|
|
667
|
+
* ```
|
|
668
|
+
*/
|
|
669
|
+
batchScreenshotsAndWait(request: CreateBatchScreenshotsRequest, options?: {
|
|
670
|
+
pollInterval?: number;
|
|
671
|
+
timeout?: number;
|
|
672
|
+
}): Promise<BatchJob>;
|
|
673
|
+
/**
|
|
674
|
+
* Create a batch extraction job and wait for completion
|
|
675
|
+
*
|
|
676
|
+
* @example
|
|
677
|
+
* ```typescript
|
|
678
|
+
* const job = await webdata.batchExtractionsAndWait({
|
|
679
|
+
* urls: ['https://example.com/article1', 'https://example.com/article2'],
|
|
680
|
+
* config: { mode: 'markdown' },
|
|
681
|
+
* });
|
|
682
|
+
* console.log(`Completed: ${job.successfulUrls} successful`);
|
|
683
|
+
* ```
|
|
684
|
+
*/
|
|
685
|
+
batchExtractionsAndWait(request: CreateBatchExtractionsRequest, options?: {
|
|
686
|
+
pollInterval?: number;
|
|
687
|
+
timeout?: number;
|
|
688
|
+
}): Promise<BatchJob>;
|
|
689
|
+
private convertScreenshotDates;
|
|
690
|
+
private convertExtractionDates;
|
|
691
|
+
private convertScheduleDates;
|
|
692
|
+
private convertUsageDates;
|
|
693
|
+
private convertBatchJobDates;
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
export { type BatchJob, type BatchJobStatus, type BatchJobType, type Clip, type CreateBatchExtractionsRequest, type CreateBatchResponse, type CreateBatchScreenshotsRequest, type CreateExtractionRequest, type CreateExtractionResponse, type CreateScheduleRequest, type CreateScheduleResponse, type CreateScreenshotRequest, type CreateScreenshotResponse, type DeviceType, type Environment, type Extraction, type ExtractionMode, type ExtractionStatus, type GetBatchJobRequest, type GetExtractionRequest, type GetScheduleRequest, type GetScreenshotRequest, type GetUsageRequest, type ListBatchJobsRequest, type ListBatchJobsResponse, type ListExtractionsRequest, type ListExtractionsResponse, type ListSchedulesRequest, type ListSchedulesResponse, type ListScreenshotsRequest, type ListScreenshotsResponse, type PageMetadata, type ResourceType, type Schedule, type ScheduleFrequency, type ScheduleType, type Screenshot, type ScreenshotFormat, type ScreenshotStatus, type UpdateScheduleRequest, type Usage, Webdata };
|