Skip to content

Commit cbcd8db

Browse files
feat: WIP: Configurable Viewport
1 parent 88be24c commit cbcd8db

File tree

7 files changed

+185
-22
lines changed

7 files changed

+185
-22
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
configured_endpoints: 57
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-592ab7a96084f7241d77b4cc1ce2a074795b0dc40d8247e1a0129fe3f89c1ed4.yml
3-
openapi_spec_hash: 3a23b4c9c05946251be45c5c4e7a415d
4-
config_hash: 15cd063f8e308686ac71bf9ee9634625
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-1cd328ccf61f0e888d6df27b091c30b38c392ab9ca8ce7fd0ead8f10aaf71ffa.yml
3+
openapi_spec_hash: af761c48d1955f11822f3b95f9c46750
4+
config_hash: deadfc4d2b0a947673bcf559b5db6e1b

api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Methods:
7373
- <code title="get /browsers">client.browsers.<a href="./src/resources/browsers/browsers.ts">list</a>() -> BrowserListResponse</code>
7474
- <code title="delete /browsers">client.browsers.<a href="./src/resources/browsers/browsers.ts">delete</a>({ ...params }) -> void</code>
7575
- <code title="delete /browsers/{id}">client.browsers.<a href="./src/resources/browsers/browsers.ts">deleteByID</a>(id) -> void</code>
76-
- <code title="post /browsers/{id}/extensions">client.browsers.<a href="./src/resources/browsers/browsers.ts">uploadExtensions</a>(id, { ...params }) -> void</code>
76+
- <code title="post /browsers/{id}/extensions">client.browsers.<a href="./src/resources/browsers/browsers.ts">loadExtensions</a>(id, { ...params }) -> void</code>
7777

7878
## Replays
7979

src/client.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ import {
6666
BrowserCreateResponse,
6767
BrowserDeleteParams,
6868
BrowserListResponse,
69+
BrowserLoadExtensionsParams,
6970
BrowserPersistence,
7071
BrowserRetrieveResponse,
71-
BrowserUploadExtensionsParams,
7272
Browsers,
7373
Profile,
7474
} from './resources/browsers/browsers';
@@ -899,7 +899,7 @@ export declare namespace Kernel {
899899
type BrowserListResponse as BrowserListResponse,
900900
type BrowserCreateParams as BrowserCreateParams,
901901
type BrowserDeleteParams as BrowserDeleteParams,
902-
type BrowserUploadExtensionsParams as BrowserUploadExtensionsParams,
902+
type BrowserLoadExtensionsParams as BrowserLoadExtensionsParams,
903903
};
904904

905905
export {

src/resources/browsers/browsers.ts

Lines changed: 172 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ export class Browsers extends APIResource {
143143
*
144144
* @example
145145
* ```ts
146-
* await client.browsers.uploadExtensions('id', {
146+
* await client.browsers.loadExtensions('id', {
147147
* extensions: [
148148
* {
149149
* name: 'name',
@@ -153,11 +153,7 @@ export class Browsers extends APIResource {
153153
* });
154154
* ```
155155
*/
156-
uploadExtensions(
157-
id: string,
158-
body: BrowserUploadExtensionsParams,
159-
options?: RequestOptions,
160-
): APIPromise<void> {
156+
loadExtensions(id: string, body: BrowserLoadExtensionsParams, options?: RequestOptions): APIPromise<void> {
161157
return this._client.post(
162158
path`/browsers/${id}/extensions`,
163159
multipartFormRequestOptions(
@@ -259,6 +255,48 @@ export interface BrowserCreateResponse {
259255
* ID of the proxy associated with this browser session, if any.
260256
*/
261257
proxy_id?: string;
258+
259+
/**
260+
* Initial browser window size in pixels with optional refresh rate. If omitted,
261+
* image defaults apply (commonly 1024x768@60). Only specific viewport
262+
* configurations are supported. The server will reject unsupported combinations.
263+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
264+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
265+
* automatically determined from the width and height if they match a supported
266+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
267+
* live view browser
268+
*/
269+
viewport?: BrowserCreateResponse.Viewport;
270+
}
271+
272+
export namespace BrowserCreateResponse {
273+
/**
274+
* Initial browser window size in pixels with optional refresh rate. If omitted,
275+
* image defaults apply (commonly 1024x768@60). Only specific viewport
276+
* configurations are supported. The server will reject unsupported combinations.
277+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
278+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
279+
* automatically determined from the width and height if they match a supported
280+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
281+
* live view browser
282+
*/
283+
export interface Viewport {
284+
/**
285+
* Browser window height in pixels.
286+
*/
287+
height: number;
288+
289+
/**
290+
* Browser window width in pixels.
291+
*/
292+
width: number;
293+
294+
/**
295+
* Display refresh rate in Hz. If omitted, automatically determined from width and
296+
* height.
297+
*/
298+
refresh_rate?: number;
299+
}
262300
}
263301

264302
export interface BrowserRetrieveResponse {
@@ -312,6 +350,48 @@ export interface BrowserRetrieveResponse {
312350
* ID of the proxy associated with this browser session, if any.
313351
*/
314352
proxy_id?: string;
353+
354+
/**
355+
* Initial browser window size in pixels with optional refresh rate. If omitted,
356+
* image defaults apply (commonly 1024x768@60). Only specific viewport
357+
* configurations are supported. The server will reject unsupported combinations.
358+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
359+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
360+
* automatically determined from the width and height if they match a supported
361+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
362+
* live view browser
363+
*/
364+
viewport?: BrowserRetrieveResponse.Viewport;
365+
}
366+
367+
export namespace BrowserRetrieveResponse {
368+
/**
369+
* Initial browser window size in pixels with optional refresh rate. If omitted,
370+
* image defaults apply (commonly 1024x768@60). Only specific viewport
371+
* configurations are supported. The server will reject unsupported combinations.
372+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
373+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
374+
* automatically determined from the width and height if they match a supported
375+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
376+
* live view browser
377+
*/
378+
export interface Viewport {
379+
/**
380+
* Browser window height in pixels.
381+
*/
382+
height: number;
383+
384+
/**
385+
* Browser window width in pixels.
386+
*/
387+
width: number;
388+
389+
/**
390+
* Display refresh rate in Hz. If omitted, automatically determined from width and
391+
* height.
392+
*/
393+
refresh_rate?: number;
394+
}
315395
}
316396

317397
export type BrowserListResponse = Array<BrowserListResponse.BrowserListResponseItem>;
@@ -368,6 +448,48 @@ export namespace BrowserListResponse {
368448
* ID of the proxy associated with this browser session, if any.
369449
*/
370450
proxy_id?: string;
451+
452+
/**
453+
* Initial browser window size in pixels with optional refresh rate. If omitted,
454+
* image defaults apply (commonly 1024x768@60). Only specific viewport
455+
* configurations are supported. The server will reject unsupported combinations.
456+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
457+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
458+
* automatically determined from the width and height if they match a supported
459+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
460+
* live view browser
461+
*/
462+
viewport?: BrowserListResponseItem.Viewport;
463+
}
464+
465+
export namespace BrowserListResponseItem {
466+
/**
467+
* Initial browser window size in pixels with optional refresh rate. If omitted,
468+
* image defaults apply (commonly 1024x768@60). Only specific viewport
469+
* configurations are supported. The server will reject unsupported combinations.
470+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
471+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
472+
* automatically determined from the width and height if they match a supported
473+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
474+
* live view browser
475+
*/
476+
export interface Viewport {
477+
/**
478+
* Browser window height in pixels.
479+
*/
480+
height: number;
481+
482+
/**
483+
* Browser window width in pixels.
484+
*/
485+
width: number;
486+
487+
/**
488+
* Display refresh rate in Hz. If omitted, automatically determined from width and
489+
* height.
490+
*/
491+
refresh_rate?: number;
492+
}
371493
}
372494
}
373495

@@ -421,6 +543,18 @@ export interface BrowserCreateParams {
421543
* specified value.
422544
*/
423545
timeout_seconds?: number;
546+
547+
/**
548+
* Initial browser window size in pixels with optional refresh rate. If omitted,
549+
* image defaults apply (commonly 1024x768@60). Only specific viewport
550+
* configurations are supported. The server will reject unsupported combinations.
551+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
552+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
553+
* automatically determined from the width and height if they match a supported
554+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
555+
* live view browser
556+
*/
557+
viewport?: BrowserCreateParams.Viewport;
424558
}
425559

426560
export namespace BrowserCreateParams {
@@ -464,6 +598,34 @@ export namespace BrowserCreateParams {
464598
*/
465599
save_changes?: boolean;
466600
}
601+
602+
/**
603+
* Initial browser window size in pixels with optional refresh rate. If omitted,
604+
* image defaults apply (commonly 1024x768@60). Only specific viewport
605+
* configurations are supported. The server will reject unsupported combinations.
606+
* Supported resolutions are: 2560x1440@10, 1920x1080@25, 1920x1200@25,
607+
* 1440x900@25, 1024x768@60 If refresh_rate is not provided, it will be
608+
* automatically determined from the width and height if they match a supported
609+
* configuration exactly. Note: Higher resolutions may affect the responsiveness of
610+
* live view browser
611+
*/
612+
export interface Viewport {
613+
/**
614+
* Browser window height in pixels.
615+
*/
616+
height: number;
617+
618+
/**
619+
* Browser window width in pixels.
620+
*/
621+
width: number;
622+
623+
/**
624+
* Display refresh rate in Hz. If omitted, automatically determined from width and
625+
* height.
626+
*/
627+
refresh_rate?: number;
628+
}
467629
}
468630

469631
export interface BrowserDeleteParams {
@@ -473,14 +635,14 @@ export interface BrowserDeleteParams {
473635
persistent_id: string;
474636
}
475637

476-
export interface BrowserUploadExtensionsParams {
638+
export interface BrowserLoadExtensionsParams {
477639
/**
478640
* List of extensions to upload and activate
479641
*/
480-
extensions: Array<BrowserUploadExtensionsParams.Extension>;
642+
extensions: Array<BrowserLoadExtensionsParams.Extension>;
481643
}
482644

483-
export namespace BrowserUploadExtensionsParams {
645+
export namespace BrowserLoadExtensionsParams {
484646
export interface Extension {
485647
/**
486648
* Folder name to place the extension under /home/kernel/extensions/<name>
@@ -509,7 +671,7 @@ export declare namespace Browsers {
509671
type BrowserListResponse as BrowserListResponse,
510672
type BrowserCreateParams as BrowserCreateParams,
511673
type BrowserDeleteParams as BrowserDeleteParams,
512-
type BrowserUploadExtensionsParams as BrowserUploadExtensionsParams,
674+
type BrowserLoadExtensionsParams as BrowserLoadExtensionsParams,
513675
};
514676

515677
export {

src/resources/browsers/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export {
99
type BrowserListResponse,
1010
type BrowserCreateParams,
1111
type BrowserDeleteParams,
12-
type BrowserUploadExtensionsParams,
12+
type BrowserLoadExtensionsParams,
1313
} from './browsers';
1414
export {
1515
Fs,

src/resources/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export {
1111
type BrowserListResponse,
1212
type BrowserCreateParams,
1313
type BrowserDeleteParams,
14-
type BrowserUploadExtensionsParams,
14+
type BrowserLoadExtensionsParams,
1515
} from './browsers/browsers';
1616
export {
1717
Deployments,

tests/api-resources/browsers/browsers.test.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ describe('resource browsers', () => {
3434
proxy_id: 'proxy_id',
3535
stealth: true,
3636
timeout_seconds: 10,
37+
viewport: { height: 800, width: 1280, refresh_rate: 60 },
3738
},
3839
{ path: '/_stainless_unknown_path' },
3940
),
@@ -94,8 +95,8 @@ describe('resource browsers', () => {
9495
});
9596

9697
// Prism tests are disabled
97-
test.skip('uploadExtensions: only required params', async () => {
98-
const responsePromise = client.browsers.uploadExtensions('id', {
98+
test.skip('loadExtensions: only required params', async () => {
99+
const responsePromise = client.browsers.loadExtensions('id', {
99100
extensions: [{ name: 'name', zip_file: await toFile(Buffer.from('# my file contents'), 'README.md') }],
100101
});
101102
const rawResponse = await responsePromise.asResponse();
@@ -108,8 +109,8 @@ describe('resource browsers', () => {
108109
});
109110

110111
// Prism tests are disabled
111-
test.skip('uploadExtensions: required and optional params', async () => {
112-
const response = await client.browsers.uploadExtensions('id', {
112+
test.skip('loadExtensions: required and optional params', async () => {
113+
const response = await client.browsers.loadExtensions('id', {
113114
extensions: [{ name: 'name', zip_file: await toFile(Buffer.from('# my file contents'), 'README.md') }],
114115
});
115116
});

0 commit comments

Comments
 (0)