@stack0/sdk 0.2.8 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +200 -0
- package/dist/cdn/index.d.mts +185 -2
- package/dist/cdn/index.d.ts +185 -2
- package/dist/cdn/index.js +138 -0
- package/dist/cdn/index.js.map +1 -1
- package/dist/cdn/index.mjs +138 -0
- package/dist/cdn/index.mjs.map +1 -1
- package/dist/extraction/index.d.mts +374 -0
- package/dist/extraction/index.d.ts +374 -0
- package/dist/extraction/index.js +455 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/extraction/index.mjs +453 -0
- package/dist/extraction/index.mjs.map +1 -0
- package/dist/http-client-DjrRWvXA.d.mts +24 -0
- package/dist/http-client-DjrRWvXA.d.ts +24 -0
- package/dist/index.d.mts +546 -6
- package/dist/index.d.ts +546 -6
- package/dist/index.js +1188 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1186 -1
- package/dist/index.mjs.map +1 -1
- package/dist/mail/index.d.mts +1 -1
- package/dist/mail/index.d.ts +1 -1
- package/dist/screenshots/index.d.mts +377 -0
- package/dist/screenshots/index.d.ts +377 -0
- package/dist/screenshots/index.js +423 -0
- package/dist/screenshots/index.js.map +1 -0
- package/dist/screenshots/index.mjs +421 -0
- package/dist/screenshots/index.mjs.map +1 -0
- package/dist/shared-types-B0PyC7cF.d.mts +40 -0
- package/dist/shared-types-B0PyC7cF.d.ts +40 -0
- package/dist/webdata/index.d.mts +1 -1
- package/dist/webdata/index.d.ts +1 -1
- package/package.json +20 -1
- package/dist/http-client-Wr9lXo9_.d.mts +0 -10
- package/dist/http-client-Wr9lXo9_.d.ts +0 -10
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { a as HttpClientConfig } from '../http-client-DjrRWvXA.mjs';
|
|
2
|
+
import { E as Environment, B as BatchJobStatus, S as ScheduleFrequency, C as CreateBatchResponse, G as GetBatchJobRequest, L as ListBatchJobsRequest, c as CreateScheduleResponse, a as GetScheduleRequest, b as ListSchedulesRequest } from '../shared-types-B0PyC7cF.mjs';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type definitions for Stack0 Screenshot API
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
type ScreenshotStatus = "pending" | "processing" | "completed" | "failed";
|
|
9
|
+
type ScreenshotFormat = "png" | "jpeg" | "webp" | "pdf";
|
|
10
|
+
type DeviceType = "desktop" | "tablet" | "mobile";
|
|
11
|
+
type ResourceType = "image" | "stylesheet" | "script" | "font" | "media" | "xhr" | "fetch" | "websocket";
|
|
12
|
+
interface Screenshot {
|
|
13
|
+
id: string;
|
|
14
|
+
organizationId: string;
|
|
15
|
+
projectId: string | null;
|
|
16
|
+
environment: Environment;
|
|
17
|
+
url: string;
|
|
18
|
+
format: ScreenshotFormat;
|
|
19
|
+
quality: number | null;
|
|
20
|
+
fullPage: boolean;
|
|
21
|
+
deviceType: DeviceType;
|
|
22
|
+
viewportWidth: number | null;
|
|
23
|
+
viewportHeight: number | null;
|
|
24
|
+
status: ScreenshotStatus;
|
|
25
|
+
imageUrl: string | null;
|
|
26
|
+
imageSize: number | null;
|
|
27
|
+
imageWidth: number | null;
|
|
28
|
+
imageHeight: number | null;
|
|
29
|
+
error: string | null;
|
|
30
|
+
processingTimeMs: number | null;
|
|
31
|
+
metadata: Record<string, unknown> | null;
|
|
32
|
+
createdAt: Date;
|
|
33
|
+
completedAt: Date | null;
|
|
34
|
+
}
|
|
35
|
+
interface Clip {
|
|
36
|
+
x: number;
|
|
37
|
+
y: number;
|
|
38
|
+
width: number;
|
|
39
|
+
height: number;
|
|
40
|
+
}
|
|
41
|
+
interface CreateScreenshotRequest {
|
|
42
|
+
url: string;
|
|
43
|
+
environment?: Environment;
|
|
44
|
+
projectId?: string;
|
|
45
|
+
format?: ScreenshotFormat;
|
|
46
|
+
quality?: number;
|
|
47
|
+
fullPage?: boolean;
|
|
48
|
+
deviceType?: DeviceType;
|
|
49
|
+
viewportWidth?: number;
|
|
50
|
+
viewportHeight?: number;
|
|
51
|
+
deviceScaleFactor?: number;
|
|
52
|
+
waitForSelector?: string;
|
|
53
|
+
waitForTimeout?: number;
|
|
54
|
+
blockAds?: boolean;
|
|
55
|
+
blockCookieBanners?: boolean;
|
|
56
|
+
blockChatWidgets?: boolean;
|
|
57
|
+
blockTrackers?: boolean;
|
|
58
|
+
blockUrls?: string[];
|
|
59
|
+
blockResources?: ResourceType[];
|
|
60
|
+
darkMode?: boolean;
|
|
61
|
+
customCss?: string;
|
|
62
|
+
customJs?: string;
|
|
63
|
+
headers?: Record<string, string>;
|
|
64
|
+
cookies?: Array<{
|
|
65
|
+
name: string;
|
|
66
|
+
value: string;
|
|
67
|
+
domain?: string;
|
|
68
|
+
}>;
|
|
69
|
+
selector?: string;
|
|
70
|
+
hideSelectors?: string[];
|
|
71
|
+
clickSelector?: string;
|
|
72
|
+
omitBackground?: boolean;
|
|
73
|
+
userAgent?: string;
|
|
74
|
+
clip?: Clip;
|
|
75
|
+
thumbnailWidth?: number;
|
|
76
|
+
thumbnailHeight?: number;
|
|
77
|
+
cacheKey?: string;
|
|
78
|
+
cacheTtl?: number;
|
|
79
|
+
webhookUrl?: string;
|
|
80
|
+
webhookSecret?: string;
|
|
81
|
+
metadata?: Record<string, unknown>;
|
|
82
|
+
}
|
|
83
|
+
interface CreateScreenshotResponse {
|
|
84
|
+
id: string;
|
|
85
|
+
status: ScreenshotStatus;
|
|
86
|
+
}
|
|
87
|
+
interface GetScreenshotRequest {
|
|
88
|
+
id: string;
|
|
89
|
+
environment?: Environment;
|
|
90
|
+
projectId?: string;
|
|
91
|
+
}
|
|
92
|
+
interface ListScreenshotsRequest {
|
|
93
|
+
environment?: Environment;
|
|
94
|
+
projectId?: string;
|
|
95
|
+
status?: ScreenshotStatus;
|
|
96
|
+
url?: string;
|
|
97
|
+
limit?: number;
|
|
98
|
+
cursor?: string;
|
|
99
|
+
}
|
|
100
|
+
interface ListScreenshotsResponse {
|
|
101
|
+
items: Screenshot[];
|
|
102
|
+
nextCursor?: string;
|
|
103
|
+
}
|
|
104
|
+
interface BatchScreenshotJob {
|
|
105
|
+
id: string;
|
|
106
|
+
organizationId: string;
|
|
107
|
+
projectId: string | null;
|
|
108
|
+
environment: Environment;
|
|
109
|
+
type: "screenshot";
|
|
110
|
+
name: string | null;
|
|
111
|
+
status: BatchJobStatus;
|
|
112
|
+
urls: string[];
|
|
113
|
+
config: Record<string, unknown>;
|
|
114
|
+
totalUrls: number;
|
|
115
|
+
processedUrls: number;
|
|
116
|
+
successfulUrls: number;
|
|
117
|
+
failedUrls: number;
|
|
118
|
+
webhookUrl: string | null;
|
|
119
|
+
metadata: Record<string, unknown> | null;
|
|
120
|
+
createdAt: Date;
|
|
121
|
+
startedAt: Date | null;
|
|
122
|
+
completedAt: Date | null;
|
|
123
|
+
}
|
|
124
|
+
interface CreateBatchScreenshotsRequest {
|
|
125
|
+
urls: string[];
|
|
126
|
+
environment?: Environment;
|
|
127
|
+
projectId?: string;
|
|
128
|
+
name?: string;
|
|
129
|
+
config?: {
|
|
130
|
+
format?: ScreenshotFormat;
|
|
131
|
+
quality?: number;
|
|
132
|
+
fullPage?: boolean;
|
|
133
|
+
deviceType?: DeviceType;
|
|
134
|
+
viewportWidth?: number;
|
|
135
|
+
viewportHeight?: number;
|
|
136
|
+
blockAds?: boolean;
|
|
137
|
+
blockCookieBanners?: boolean;
|
|
138
|
+
waitForSelector?: string;
|
|
139
|
+
waitForTimeout?: number;
|
|
140
|
+
};
|
|
141
|
+
webhookUrl?: string;
|
|
142
|
+
webhookSecret?: string;
|
|
143
|
+
metadata?: Record<string, unknown>;
|
|
144
|
+
}
|
|
145
|
+
interface ScreenshotBatchJobsResponse {
|
|
146
|
+
items: BatchScreenshotJob[];
|
|
147
|
+
nextCursor?: string;
|
|
148
|
+
}
|
|
149
|
+
interface ScreenshotSchedule {
|
|
150
|
+
id: string;
|
|
151
|
+
organizationId: string;
|
|
152
|
+
projectId: string | null;
|
|
153
|
+
environment: Environment;
|
|
154
|
+
name: string;
|
|
155
|
+
url: string;
|
|
156
|
+
type: "screenshot";
|
|
157
|
+
frequency: ScheduleFrequency;
|
|
158
|
+
config: Record<string, unknown>;
|
|
159
|
+
isActive: boolean;
|
|
160
|
+
detectChanges: boolean;
|
|
161
|
+
changeThreshold: number | null;
|
|
162
|
+
webhookUrl: string | null;
|
|
163
|
+
totalRuns: number;
|
|
164
|
+
successfulRuns: number;
|
|
165
|
+
failedRuns: number;
|
|
166
|
+
lastRunAt: Date | null;
|
|
167
|
+
nextRunAt: Date | null;
|
|
168
|
+
metadata: Record<string, unknown> | null;
|
|
169
|
+
createdAt: Date;
|
|
170
|
+
updatedAt: Date;
|
|
171
|
+
}
|
|
172
|
+
interface CreateScreenshotScheduleRequest {
|
|
173
|
+
name: string;
|
|
174
|
+
url: string;
|
|
175
|
+
environment?: Environment;
|
|
176
|
+
projectId?: string;
|
|
177
|
+
frequency?: ScheduleFrequency;
|
|
178
|
+
config: {
|
|
179
|
+
format?: ScreenshotFormat;
|
|
180
|
+
quality?: number;
|
|
181
|
+
fullPage?: boolean;
|
|
182
|
+
deviceType?: DeviceType;
|
|
183
|
+
viewportWidth?: number;
|
|
184
|
+
viewportHeight?: number;
|
|
185
|
+
blockAds?: boolean;
|
|
186
|
+
blockCookieBanners?: boolean;
|
|
187
|
+
waitForSelector?: string;
|
|
188
|
+
waitForTimeout?: number;
|
|
189
|
+
};
|
|
190
|
+
detectChanges?: boolean;
|
|
191
|
+
changeThreshold?: number;
|
|
192
|
+
webhookUrl?: string;
|
|
193
|
+
webhookSecret?: string;
|
|
194
|
+
metadata?: Record<string, unknown>;
|
|
195
|
+
}
|
|
196
|
+
interface UpdateScreenshotScheduleRequest {
|
|
197
|
+
id: string;
|
|
198
|
+
environment?: Environment;
|
|
199
|
+
projectId?: string;
|
|
200
|
+
name?: string;
|
|
201
|
+
frequency?: ScheduleFrequency;
|
|
202
|
+
config?: Record<string, unknown>;
|
|
203
|
+
isActive?: boolean;
|
|
204
|
+
detectChanges?: boolean;
|
|
205
|
+
changeThreshold?: number;
|
|
206
|
+
webhookUrl?: string | null;
|
|
207
|
+
webhookSecret?: string | null;
|
|
208
|
+
metadata?: Record<string, unknown>;
|
|
209
|
+
}
|
|
210
|
+
interface ScreenshotSchedulesResponse {
|
|
211
|
+
items: ScreenshotSchedule[];
|
|
212
|
+
nextCursor?: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Stack0 Screenshots Client
|
|
217
|
+
* Capture high-quality screenshots of any webpage
|
|
218
|
+
*/
|
|
219
|
+
|
|
220
|
+
declare class Screenshots {
|
|
221
|
+
private http;
|
|
222
|
+
constructor(config: HttpClientConfig);
|
|
223
|
+
/**
|
|
224
|
+
* Capture a screenshot of a URL
|
|
225
|
+
*
|
|
226
|
+
* @example
|
|
227
|
+
* ```typescript
|
|
228
|
+
* const { id, status } = await screenshots.capture({
|
|
229
|
+
* url: 'https://example.com',
|
|
230
|
+
* format: 'png',
|
|
231
|
+
* fullPage: true,
|
|
232
|
+
* deviceType: 'desktop',
|
|
233
|
+
* });
|
|
234
|
+
*
|
|
235
|
+
* // Poll for completion
|
|
236
|
+
* const screenshot = await screenshots.get({ id });
|
|
237
|
+
* console.log(screenshot.imageUrl);
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
capture(request: CreateScreenshotRequest): Promise<CreateScreenshotResponse>;
|
|
241
|
+
/**
|
|
242
|
+
* Get a screenshot by ID
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const screenshot = await screenshots.get({ id: 'screenshot-id' });
|
|
247
|
+
* if (screenshot.status === 'completed') {
|
|
248
|
+
* console.log(screenshot.imageUrl);
|
|
249
|
+
* }
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
get(request: GetScreenshotRequest): Promise<Screenshot>;
|
|
253
|
+
/**
|
|
254
|
+
* List screenshots with pagination and filters
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* const { items, nextCursor } = await screenshots.list({
|
|
259
|
+
* status: 'completed',
|
|
260
|
+
* limit: 20,
|
|
261
|
+
* });
|
|
262
|
+
* ```
|
|
263
|
+
*/
|
|
264
|
+
list(request?: ListScreenshotsRequest): Promise<ListScreenshotsResponse>;
|
|
265
|
+
/**
|
|
266
|
+
* Delete a screenshot
|
|
267
|
+
*
|
|
268
|
+
* @example
|
|
269
|
+
* ```typescript
|
|
270
|
+
* await screenshots.delete({ id: 'screenshot-id' });
|
|
271
|
+
* ```
|
|
272
|
+
*/
|
|
273
|
+
delete(request: GetScreenshotRequest): Promise<{
|
|
274
|
+
success: boolean;
|
|
275
|
+
}>;
|
|
276
|
+
/**
|
|
277
|
+
* Capture a screenshot and wait for completion
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* ```typescript
|
|
281
|
+
* const screenshot = await screenshots.captureAndWait({
|
|
282
|
+
* url: 'https://example.com',
|
|
283
|
+
* format: 'png',
|
|
284
|
+
* });
|
|
285
|
+
* console.log(screenshot.imageUrl);
|
|
286
|
+
* ```
|
|
287
|
+
*/
|
|
288
|
+
captureAndWait(request: CreateScreenshotRequest, options?: {
|
|
289
|
+
pollInterval?: number;
|
|
290
|
+
timeout?: number;
|
|
291
|
+
}): Promise<Screenshot>;
|
|
292
|
+
/**
|
|
293
|
+
* Create a batch screenshot job for multiple URLs
|
|
294
|
+
*
|
|
295
|
+
* @example
|
|
296
|
+
* ```typescript
|
|
297
|
+
* const { id, totalUrls } = await screenshots.batch({
|
|
298
|
+
* urls: [
|
|
299
|
+
* 'https://example.com',
|
|
300
|
+
* 'https://example.org',
|
|
301
|
+
* ],
|
|
302
|
+
* config: { format: 'png', fullPage: true },
|
|
303
|
+
* });
|
|
304
|
+
*
|
|
305
|
+
* // Poll for completion
|
|
306
|
+
* const job = await screenshots.getBatchJob({ id });
|
|
307
|
+
* console.log(`Progress: ${job.processedUrls}/${job.totalUrls}`);
|
|
308
|
+
* ```
|
|
309
|
+
*/
|
|
310
|
+
batch(request: CreateBatchScreenshotsRequest): Promise<CreateBatchResponse>;
|
|
311
|
+
/**
|
|
312
|
+
* Get a batch job by ID
|
|
313
|
+
*/
|
|
314
|
+
getBatchJob(request: GetBatchJobRequest): Promise<BatchScreenshotJob>;
|
|
315
|
+
/**
|
|
316
|
+
* List batch jobs with pagination and filters
|
|
317
|
+
*/
|
|
318
|
+
listBatchJobs(request?: ListBatchJobsRequest): Promise<ScreenshotBatchJobsResponse>;
|
|
319
|
+
/**
|
|
320
|
+
* Cancel a batch job
|
|
321
|
+
*/
|
|
322
|
+
cancelBatchJob(request: GetBatchJobRequest): Promise<{
|
|
323
|
+
success: boolean;
|
|
324
|
+
}>;
|
|
325
|
+
/**
|
|
326
|
+
* Create a batch screenshot job and wait for completion
|
|
327
|
+
*/
|
|
328
|
+
batchAndWait(request: CreateBatchScreenshotsRequest, options?: {
|
|
329
|
+
pollInterval?: number;
|
|
330
|
+
timeout?: number;
|
|
331
|
+
}): Promise<BatchScreenshotJob>;
|
|
332
|
+
/**
|
|
333
|
+
* Create a scheduled screenshot job
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* const { id } = await screenshots.createSchedule({
|
|
338
|
+
* name: 'Daily homepage screenshot',
|
|
339
|
+
* url: 'https://example.com',
|
|
340
|
+
* frequency: 'daily',
|
|
341
|
+
* config: { format: 'png', fullPage: true },
|
|
342
|
+
* });
|
|
343
|
+
* ```
|
|
344
|
+
*/
|
|
345
|
+
createSchedule(request: CreateScreenshotScheduleRequest): Promise<CreateScheduleResponse>;
|
|
346
|
+
/**
|
|
347
|
+
* Update a schedule
|
|
348
|
+
*/
|
|
349
|
+
updateSchedule(request: UpdateScreenshotScheduleRequest): Promise<{
|
|
350
|
+
success: boolean;
|
|
351
|
+
}>;
|
|
352
|
+
/**
|
|
353
|
+
* Get a schedule by ID
|
|
354
|
+
*/
|
|
355
|
+
getSchedule(request: GetScheduleRequest): Promise<ScreenshotSchedule>;
|
|
356
|
+
/**
|
|
357
|
+
* List schedules with pagination and filters
|
|
358
|
+
*/
|
|
359
|
+
listSchedules(request?: ListSchedulesRequest): Promise<ScreenshotSchedulesResponse>;
|
|
360
|
+
/**
|
|
361
|
+
* Delete a schedule
|
|
362
|
+
*/
|
|
363
|
+
deleteSchedule(request: GetScheduleRequest): Promise<{
|
|
364
|
+
success: boolean;
|
|
365
|
+
}>;
|
|
366
|
+
/**
|
|
367
|
+
* Toggle a schedule on or off
|
|
368
|
+
*/
|
|
369
|
+
toggleSchedule(request: GetScheduleRequest): Promise<{
|
|
370
|
+
isActive: boolean;
|
|
371
|
+
}>;
|
|
372
|
+
private convertDates;
|
|
373
|
+
private convertBatchJobDates;
|
|
374
|
+
private convertScheduleDates;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
export { type BatchScreenshotJob, type Clip, type CreateBatchScreenshotsRequest, type CreateScreenshotRequest, type CreateScreenshotResponse, type CreateScreenshotScheduleRequest, type DeviceType, type GetScreenshotRequest, type ListScreenshotsRequest, type ListScreenshotsResponse, type ResourceType, type Screenshot, type ScreenshotBatchJobsResponse, type ScreenshotFormat, type ScreenshotSchedule, type ScreenshotSchedulesResponse, type ScreenshotStatus, Screenshots, type UpdateScreenshotScheduleRequest };
|