|
1 | 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
2 | 2 |
|
3 | | -import { APIResource } from '../core/resource'; |
4 | | -import * as BrowsersAPI from './browsers'; |
5 | | -import { APIPromise } from '../core/api-promise'; |
6 | | -import { buildHeaders } from '../internal/headers'; |
7 | | -import { RequestOptions } from '../internal/request-options'; |
8 | | -import { path } from '../internal/utils/path'; |
9 | | - |
10 | | -export class Browsers extends APIResource { |
11 | | - /** |
12 | | - * Create a new browser session from within an action. |
13 | | - * |
14 | | - * @example |
15 | | - * ```ts |
16 | | - * const browser = await client.browsers.create(); |
17 | | - * ``` |
18 | | - */ |
19 | | - create( |
20 | | - body: BrowserCreateParams | null | undefined = {}, |
21 | | - options?: RequestOptions, |
22 | | - ): APIPromise<BrowserCreateResponse> { |
23 | | - return this._client.post('/browsers', { body, ...options }); |
24 | | - } |
25 | | - |
26 | | - /** |
27 | | - * Get information about a browser session. |
28 | | - * |
29 | | - * @example |
30 | | - * ```ts |
31 | | - * const browser = await client.browsers.retrieve( |
32 | | - * 'htzv5orfit78e1m2biiifpbv', |
33 | | - * ); |
34 | | - * ``` |
35 | | - */ |
36 | | - retrieve(id: string, options?: RequestOptions): APIPromise<BrowserRetrieveResponse> { |
37 | | - return this._client.get(path`/browsers/${id}`, options); |
38 | | - } |
39 | | - |
40 | | - /** |
41 | | - * List active browser sessions |
42 | | - * |
43 | | - * @example |
44 | | - * ```ts |
45 | | - * const browsers = await client.browsers.list(); |
46 | | - * ``` |
47 | | - */ |
48 | | - list(options?: RequestOptions): APIPromise<BrowserListResponse> { |
49 | | - return this._client.get('/browsers', options); |
50 | | - } |
51 | | - |
52 | | - /** |
53 | | - * Delete a persistent browser session by its persistent_id. |
54 | | - * |
55 | | - * @example |
56 | | - * ```ts |
57 | | - * await client.browsers.delete({ |
58 | | - * persistent_id: 'persistent_id', |
59 | | - * }); |
60 | | - * ``` |
61 | | - */ |
62 | | - delete(params: BrowserDeleteParams, options?: RequestOptions): APIPromise<void> { |
63 | | - const { persistent_id } = params; |
64 | | - return this._client.delete('/browsers', { |
65 | | - query: { persistent_id }, |
66 | | - ...options, |
67 | | - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), |
68 | | - }); |
69 | | - } |
70 | | - |
71 | | - /** |
72 | | - * Delete a browser session by ID |
73 | | - * |
74 | | - * @example |
75 | | - * ```ts |
76 | | - * await client.browsers.deleteByID( |
77 | | - * 'htzv5orfit78e1m2biiifpbv', |
78 | | - * ); |
79 | | - * ``` |
80 | | - */ |
81 | | - deleteByID(id: string, options?: RequestOptions): APIPromise<void> { |
82 | | - return this._client.delete(path`/browsers/${id}`, { |
83 | | - ...options, |
84 | | - headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), |
85 | | - }); |
86 | | - } |
87 | | - |
88 | | - /** |
89 | | - * Get browser session replay. |
90 | | - * |
91 | | - * @example |
92 | | - * ```ts |
93 | | - * const response = await client.browsers.retrieveReplay( |
94 | | - * 'htzv5orfit78e1m2biiifpbv', |
95 | | - * ); |
96 | | - * |
97 | | - * const content = await response.blob(); |
98 | | - * console.log(content); |
99 | | - * ``` |
100 | | - */ |
101 | | - retrieveReplay(id: string, options?: RequestOptions): APIPromise<Response> { |
102 | | - return this._client.get(path`/browsers/${id}/replay`, { |
103 | | - ...options, |
104 | | - headers: buildHeaders([{ Accept: 'video/mp4' }, options?.headers]), |
105 | | - __binaryResponse: true, |
106 | | - }); |
107 | | - } |
108 | | -} |
109 | | - |
110 | | -/** |
111 | | - * Optional persistence configuration for the browser session. |
112 | | - */ |
113 | | -export interface BrowserPersistence { |
114 | | - /** |
115 | | - * Unique identifier for the persistent browser session. |
116 | | - */ |
117 | | - id: string; |
118 | | -} |
119 | | - |
120 | | -export interface BrowserCreateResponse { |
121 | | - /** |
122 | | - * Websocket URL for Chrome DevTools Protocol connections to the browser session |
123 | | - */ |
124 | | - cdp_ws_url: string; |
125 | | - |
126 | | - /** |
127 | | - * Unique identifier for the browser session |
128 | | - */ |
129 | | - session_id: string; |
130 | | - |
131 | | - /** |
132 | | - * Remote URL for live viewing the browser session. Only available for non-headless |
133 | | - * browsers. |
134 | | - */ |
135 | | - browser_live_view_url?: string; |
136 | | - |
137 | | - /** |
138 | | - * Optional persistence configuration for the browser session. |
139 | | - */ |
140 | | - persistence?: BrowserPersistence; |
141 | | - |
142 | | - /** |
143 | | - * Remote URL for viewing the browser session replay if enabled |
144 | | - */ |
145 | | - replay_view_url?: string; |
146 | | -} |
147 | | - |
148 | | -export interface BrowserRetrieveResponse { |
149 | | - /** |
150 | | - * Websocket URL for Chrome DevTools Protocol connections to the browser session |
151 | | - */ |
152 | | - cdp_ws_url: string; |
153 | | - |
154 | | - /** |
155 | | - * Unique identifier for the browser session |
156 | | - */ |
157 | | - session_id: string; |
158 | | - |
159 | | - /** |
160 | | - * Remote URL for live viewing the browser session. Only available for non-headless |
161 | | - * browsers. |
162 | | - */ |
163 | | - browser_live_view_url?: string; |
164 | | - |
165 | | - /** |
166 | | - * Optional persistence configuration for the browser session. |
167 | | - */ |
168 | | - persistence?: BrowserPersistence; |
169 | | - |
170 | | - /** |
171 | | - * Remote URL for viewing the browser session replay if enabled |
172 | | - */ |
173 | | - replay_view_url?: string; |
174 | | -} |
175 | | - |
176 | | -export type BrowserListResponse = Array<BrowserListResponse.BrowserListResponseItem>; |
177 | | - |
178 | | -export namespace BrowserListResponse { |
179 | | - export interface BrowserListResponseItem { |
180 | | - /** |
181 | | - * Websocket URL for Chrome DevTools Protocol connections to the browser session |
182 | | - */ |
183 | | - cdp_ws_url: string; |
184 | | - |
185 | | - /** |
186 | | - * Unique identifier for the browser session |
187 | | - */ |
188 | | - session_id: string; |
189 | | - |
190 | | - /** |
191 | | - * Remote URL for live viewing the browser session. Only available for non-headless |
192 | | - * browsers. |
193 | | - */ |
194 | | - browser_live_view_url?: string; |
195 | | - |
196 | | - /** |
197 | | - * Optional persistence configuration for the browser session. |
198 | | - */ |
199 | | - persistence?: BrowsersAPI.BrowserPersistence; |
200 | | - |
201 | | - /** |
202 | | - * Remote URL for viewing the browser session replay if enabled |
203 | | - */ |
204 | | - replay_view_url?: string; |
205 | | - } |
206 | | -} |
207 | | - |
208 | | -export interface BrowserCreateParams { |
209 | | - /** |
210 | | - * If true, launches the browser using a headless image (no VNC/GUI). Defaults to |
211 | | - * false. |
212 | | - */ |
213 | | - headless?: boolean; |
214 | | - |
215 | | - /** |
216 | | - * action invocation ID |
217 | | - */ |
218 | | - invocation_id?: string; |
219 | | - |
220 | | - /** |
221 | | - * Optional persistence configuration for the browser session. |
222 | | - */ |
223 | | - persistence?: BrowserPersistence; |
224 | | - |
225 | | - /** |
226 | | - * If true, enables replay recording of the browser session. Defaults to false. |
227 | | - */ |
228 | | - replay?: boolean; |
229 | | - |
230 | | - /** |
231 | | - * If true, launches the browser in stealth mode to reduce detection by anti-bot |
232 | | - * mechanisms. |
233 | | - */ |
234 | | - stealth?: boolean; |
235 | | -} |
236 | | - |
237 | | -export interface BrowserDeleteParams { |
238 | | - /** |
239 | | - * Persistent browser identifier |
240 | | - */ |
241 | | - persistent_id: string; |
242 | | -} |
243 | | - |
244 | | -export declare namespace Browsers { |
245 | | - export { |
246 | | - type BrowserPersistence as BrowserPersistence, |
247 | | - type BrowserCreateResponse as BrowserCreateResponse, |
248 | | - type BrowserRetrieveResponse as BrowserRetrieveResponse, |
249 | | - type BrowserListResponse as BrowserListResponse, |
250 | | - type BrowserCreateParams as BrowserCreateParams, |
251 | | - type BrowserDeleteParams as BrowserDeleteParams, |
252 | | - }; |
253 | | -} |
| 3 | +export * from './browsers/index'; |
0 commit comments