-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtypes.py
More file actions
349 lines (274 loc) · 13.3 KB
/
Copy pathtypes.py
File metadata and controls
349 lines (274 loc) · 13.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
"""
Type definitions for Stack0 Screenshot API
"""
from __future__ import annotations
from datetime import datetime
from typing import Any, Literal
from pydantic import BaseModel, ConfigDict, Field
from .._types import BatchJobStatus, Environment, ScheduleFrequency
ScreenshotStatus = Literal["pending", "processing", "completed", "failed"]
ScreenshotFormat = Literal["png", "jpeg", "webp", "pdf"]
DeviceType = Literal["desktop", "tablet", "mobile"]
ResourceType = Literal["image", "stylesheet", "script", "font", "media", "xhr", "fetch", "websocket"]
class Clip(BaseModel):
"""Clip region for screenshot"""
model_config = ConfigDict(populate_by_name=True)
x: int
y: int
width: int
height: int
class Cookie(BaseModel):
"""Cookie for screenshot request"""
model_config = ConfigDict(populate_by_name=True)
name: str
value: str
domain: str | None = None
class Screenshot(BaseModel):
"""Screenshot result"""
model_config = ConfigDict(populate_by_name=True)
id: str
organization_id: str = Field(alias="organizationId")
project_id: str | None = Field(default=None, alias="projectId")
environment: Environment
url: str
format: ScreenshotFormat
quality: int | None = None
full_page: bool = Field(alias="fullPage")
device_type: DeviceType = Field(alias="deviceType")
viewport_width: int | None = Field(default=None, alias="viewportWidth")
viewport_height: int | None = Field(default=None, alias="viewportHeight")
status: ScreenshotStatus
image_url: str | None = Field(default=None, alias="imageUrl")
image_size: int | None = Field(default=None, alias="imageSize")
image_width: int | None = Field(default=None, alias="imageWidth")
image_height: int | None = Field(default=None, alias="imageHeight")
error: str | None = None
processing_time_ms: int | None = Field(default=None, alias="processingTimeMs")
metadata: dict[str, Any] | None = None
created_at: datetime = Field(alias="createdAt")
completed_at: datetime | None = Field(default=None, alias="completedAt")
class CreateScreenshotRequest(BaseModel):
"""Request to create a screenshot"""
model_config = ConfigDict(populate_by_name=True)
url: str
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
format: ScreenshotFormat | None = None
quality: int | None = None
full_page: bool | None = Field(default=None, alias="fullPage")
device_type: DeviceType | None = Field(default=None, alias="deviceType")
viewport_width: int | None = Field(default=None, alias="viewportWidth")
viewport_height: int | None = Field(default=None, alias="viewportHeight")
device_scale_factor: float | None = Field(default=None, alias="deviceScaleFactor")
wait_for_selector: str | None = Field(default=None, alias="waitForSelector")
wait_for_timeout: int | None = Field(default=None, alias="waitForTimeout")
block_ads: bool | None = Field(default=None, alias="blockAds")
block_cookie_banners: bool | None = Field(default=None, alias="blockCookieBanners")
block_chat_widgets: bool | None = Field(default=None, alias="blockChatWidgets")
block_trackers: bool | None = Field(default=None, alias="blockTrackers")
block_urls: list[str] | None = Field(default=None, alias="blockUrls")
block_resources: list[ResourceType] | None = Field(default=None, alias="blockResources")
dark_mode: bool | None = Field(default=None, alias="darkMode")
custom_css: str | None = Field(default=None, alias="customCss")
custom_js: str | None = Field(default=None, alias="customJs")
headers: dict[str, str] | None = None
cookies: list[Cookie] | None = None
selector: str | None = None
hide_selectors: list[str] | None = Field(default=None, alias="hideSelectors")
click_selector: str | None = Field(default=None, alias="clickSelector")
omit_background: bool | None = Field(default=None, alias="omitBackground")
user_agent: str | None = Field(default=None, alias="userAgent")
clip: Clip | None = None
thumbnail_width: int | None = Field(default=None, alias="thumbnailWidth")
thumbnail_height: int | None = Field(default=None, alias="thumbnailHeight")
cache_key: str | None = Field(default=None, alias="cacheKey")
cache_ttl: int | None = Field(default=None, alias="cacheTtl")
webhook_url: str | None = Field(default=None, alias="webhookUrl")
webhook_secret: str | None = Field(default=None, alias="webhookSecret")
metadata: dict[str, Any] | None = None
class CreateScreenshotResponse(BaseModel):
"""Response from creating a screenshot"""
model_config = ConfigDict(populate_by_name=True)
id: str
status: ScreenshotStatus
class GetScreenshotRequest(BaseModel):
"""Request to get a screenshot"""
model_config = ConfigDict(populate_by_name=True)
id: str
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
class ListScreenshotsRequest(BaseModel):
"""Request to list screenshots"""
model_config = ConfigDict(populate_by_name=True)
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
status: ScreenshotStatus | None = None
url: str | None = None
limit: int | None = None
cursor: str | None = None
class ListScreenshotsResponse(BaseModel):
"""Response from listing screenshots"""
model_config = ConfigDict(populate_by_name=True)
items: list[Screenshot]
next_cursor: str | None = Field(default=None, alias="nextCursor")
# Batch types
class BatchScreenshotConfig(BaseModel):
"""Configuration for batch screenshots"""
model_config = ConfigDict(populate_by_name=True)
format: ScreenshotFormat | None = None
quality: int | None = None
full_page: bool | None = Field(default=None, alias="fullPage")
device_type: DeviceType | None = Field(default=None, alias="deviceType")
viewport_width: int | None = Field(default=None, alias="viewportWidth")
viewport_height: int | None = Field(default=None, alias="viewportHeight")
block_ads: bool | None = Field(default=None, alias="blockAds")
block_cookie_banners: bool | None = Field(default=None, alias="blockCookieBanners")
wait_for_selector: str | None = Field(default=None, alias="waitForSelector")
wait_for_timeout: int | None = Field(default=None, alias="waitForTimeout")
class BatchScreenshotJob(BaseModel):
"""Batch screenshot job"""
model_config = ConfigDict(populate_by_name=True)
id: str
organization_id: str = Field(alias="organizationId")
project_id: str | None = Field(default=None, alias="projectId")
environment: Environment
type: Literal["screenshot"]
name: str | None = None
status: BatchJobStatus
urls: list[str]
config: dict[str, Any]
total_urls: int = Field(alias="totalUrls")
processed_urls: int = Field(alias="processedUrls")
successful_urls: int = Field(alias="successfulUrls")
failed_urls: int = Field(alias="failedUrls")
webhook_url: str | None = Field(default=None, alias="webhookUrl")
metadata: dict[str, Any] | None = None
created_at: datetime = Field(alias="createdAt")
started_at: datetime | None = Field(default=None, alias="startedAt")
completed_at: datetime | None = Field(default=None, alias="completedAt")
class CreateBatchScreenshotsRequest(BaseModel):
"""Request to create batch screenshots"""
model_config = ConfigDict(populate_by_name=True)
urls: list[str]
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
name: str | None = None
config: BatchScreenshotConfig | None = None
webhook_url: str | None = Field(default=None, alias="webhookUrl")
webhook_secret: str | None = Field(default=None, alias="webhookSecret")
metadata: dict[str, Any] | None = None
class CreateBatchResponse(BaseModel):
"""Response from creating batch job"""
model_config = ConfigDict(populate_by_name=True)
id: str
status: BatchJobStatus
total_urls: int = Field(alias="totalUrls")
class GetBatchJobRequest(BaseModel):
"""Request to get a batch job"""
model_config = ConfigDict(populate_by_name=True)
id: str
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
class ListBatchJobsRequest(BaseModel):
"""Request to list batch jobs"""
model_config = ConfigDict(populate_by_name=True)
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
status: BatchJobStatus | None = None
limit: int | None = None
cursor: str | None = None
class ScreenshotBatchJobsResponse(BaseModel):
"""Response from listing batch jobs"""
model_config = ConfigDict(populate_by_name=True)
items: list[BatchScreenshotJob]
next_cursor: str | None = Field(default=None, alias="nextCursor")
# Schedule types
class ScreenshotScheduleConfig(BaseModel):
"""Configuration for scheduled screenshots"""
model_config = ConfigDict(populate_by_name=True)
format: ScreenshotFormat | None = None
quality: int | None = None
full_page: bool | None = Field(default=None, alias="fullPage")
device_type: DeviceType | None = Field(default=None, alias="deviceType")
viewport_width: int | None = Field(default=None, alias="viewportWidth")
viewport_height: int | None = Field(default=None, alias="viewportHeight")
block_ads: bool | None = Field(default=None, alias="blockAds")
block_cookie_banners: bool | None = Field(default=None, alias="blockCookieBanners")
wait_for_selector: str | None = Field(default=None, alias="waitForSelector")
wait_for_timeout: int | None = Field(default=None, alias="waitForTimeout")
class ScreenshotSchedule(BaseModel):
"""Screenshot schedule"""
model_config = ConfigDict(populate_by_name=True)
id: str
organization_id: str = Field(alias="organizationId")
project_id: str | None = Field(default=None, alias="projectId")
environment: Environment
name: str
url: str
type: Literal["screenshot"]
frequency: ScheduleFrequency
config: dict[str, Any]
is_active: bool = Field(alias="isActive")
detect_changes: bool = Field(alias="detectChanges")
change_threshold: float | None = Field(default=None, alias="changeThreshold")
webhook_url: str | None = Field(default=None, alias="webhookUrl")
total_runs: int = Field(alias="totalRuns")
successful_runs: int = Field(alias="successfulRuns")
failed_runs: int = Field(alias="failedRuns")
last_run_at: datetime | None = Field(default=None, alias="lastRunAt")
next_run_at: datetime | None = Field(default=None, alias="nextRunAt")
metadata: dict[str, Any] | None = None
created_at: datetime = Field(alias="createdAt")
updated_at: datetime = Field(alias="updatedAt")
class CreateScreenshotScheduleRequest(BaseModel):
"""Request to create screenshot schedule"""
model_config = ConfigDict(populate_by_name=True)
name: str
url: str
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
frequency: ScheduleFrequency | None = None
config: ScreenshotScheduleConfig
detect_changes: bool | None = Field(default=None, alias="detectChanges")
change_threshold: float | None = Field(default=None, alias="changeThreshold")
webhook_url: str | None = Field(default=None, alias="webhookUrl")
webhook_secret: str | None = Field(default=None, alias="webhookSecret")
metadata: dict[str, Any] | None = None
class CreateScheduleResponse(BaseModel):
"""Response from creating schedule"""
model_config = ConfigDict(populate_by_name=True)
id: str
class GetScheduleRequest(BaseModel):
"""Request to get a schedule"""
model_config = ConfigDict(populate_by_name=True)
id: str
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
class ListSchedulesRequest(BaseModel):
"""Request to list schedules"""
model_config = ConfigDict(populate_by_name=True)
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
is_active: bool | None = Field(default=None, alias="isActive")
limit: int | None = None
cursor: str | None = None
class UpdateScreenshotScheduleRequest(BaseModel):
"""Request to update screenshot schedule"""
model_config = ConfigDict(populate_by_name=True)
id: str
environment: Environment | None = None
project_id: str | None = Field(default=None, alias="projectId")
name: str | None = None
frequency: ScheduleFrequency | None = None
config: dict[str, Any] | None = None
is_active: bool | None = Field(default=None, alias="isActive")
detect_changes: bool | None = Field(default=None, alias="detectChanges")
change_threshold: float | None = Field(default=None, alias="changeThreshold")
webhook_url: str | None = Field(default=None, alias="webhookUrl")
webhook_secret: str | None = Field(default=None, alias="webhookSecret")
metadata: dict[str, Any] | None = None
class ScreenshotSchedulesResponse(BaseModel):
"""Response from listing schedules"""
model_config = ConfigDict(populate_by_name=True)
items: list[ScreenshotSchedule]
next_cursor: str | None = Field(default=None, alias="nextCursor")