@bctrl/sdk 1.0.2 → 1.0.4

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.
@@ -1,24 +0,0 @@
1
- import type { V2HttpClient } from './http.js';
2
- import type { V2RuntimeInvocationsClient } from './invocations.js';
3
- import { V2RuntimeConnectionResource, V2RuntimeResource } from './runtimes.js';
4
- import { V2RunResource } from './runs.js';
5
- import type { BrowserLaunchOptions, V2Runtime, V2RuntimeConnectionCreateOptions } from './types.js';
6
- export declare class V2BrowserResource {
7
- private readonly http;
8
- private readonly spaceId;
9
- readonly runtime: V2RuntimeResource;
10
- constructor(http: V2HttpClient, spaceId: string, runtime: V2RuntimeResource);
11
- get id(): string;
12
- get data(): V2Runtime;
13
- get invocations(): V2RuntimeInvocationsClient;
14
- connect(request?: V2RuntimeConnectionCreateOptions): Promise<V2RuntimeConnectionResource>;
15
- run(): Promise<V2RunResource>;
16
- stop(): Promise<V2Runtime>;
17
- refresh(): Promise<V2BrowserResource>;
18
- }
19
- export declare class V2SpaceBrowsersClient {
20
- private readonly http;
21
- private readonly spaceId;
22
- constructor(http: V2HttpClient, spaceId: string);
23
- launch(options: BrowserLaunchOptions): Promise<V2BrowserResource>;
24
- }
package/dist/browsers.js DELETED
@@ -1,82 +0,0 @@
1
- import { BctrlValidationError } from './errors.js';
2
- import { V2RuntimesClient, } from './runtimes.js';
3
- export class V2BrowserResource {
4
- http;
5
- spaceId;
6
- runtime;
7
- constructor(http, spaceId, runtime) {
8
- this.http = http;
9
- this.spaceId = spaceId;
10
- this.runtime = runtime;
11
- }
12
- get id() {
13
- return this.runtime.id;
14
- }
15
- get data() {
16
- return this.runtime.data;
17
- }
18
- get invocations() {
19
- return this.runtime.invocations;
20
- }
21
- connect(request) {
22
- return this.runtime.connect(request);
23
- }
24
- async run() {
25
- return this.runtime.run();
26
- }
27
- stop() {
28
- return this.runtime.stop();
29
- }
30
- async refresh() {
31
- const runtime = await new V2RuntimesClient(this.http).get(this.id);
32
- return new V2BrowserResource(this.http, this.spaceId, runtime);
33
- }
34
- }
35
- export class V2SpaceBrowsersClient {
36
- http;
37
- spaceId;
38
- constructor(http, spaceId) {
39
- this.http = http;
40
- this.spaceId = spaceId;
41
- }
42
- async launch(options) {
43
- const request = browserLaunchToRuntimeCreate(options);
44
- const runtime = await new V2RuntimesClient(this.http).createInSpace(this.spaceId, request);
45
- const started = await runtime.start();
46
- return new V2BrowserResource(this.http, this.spaceId, started.runtime);
47
- }
48
- }
49
- function browserLaunchToRuntimeCreate(options) {
50
- const state = options.state ?? 'ephemeral';
51
- if (!options.name?.trim()) {
52
- throw new BctrlValidationError('Browser name is required', 'browser.name_required');
53
- }
54
- if (state === 'profile') {
55
- const unsupported = [
56
- ['stealth', options.stealth],
57
- ['proxy', options.proxy],
58
- ['fingerprint', options.fingerprint],
59
- ['extensions', options.extensions],
60
- ]
61
- .filter(([, value]) => value !== undefined)
62
- .map(([key]) => key);
63
- if (unsupported.length > 0) {
64
- throw new BctrlValidationError('Profile-backed browser launch only supports lifecycle config right now', 'browser.profile_config_unsupported', { unsupported });
65
- }
66
- }
67
- return {
68
- type: 'browser',
69
- name: options.name,
70
- metadata: options.metadata,
71
- config: {
72
- browser: {
73
- profile: state === 'profile',
74
- },
75
- ...(options.lifecycle ? { lifecycle: options.lifecycle } : {}),
76
- ...(state === 'ephemeral' && options.stealth ? { stealth: options.stealth } : {}),
77
- ...(state === 'ephemeral' && options.proxy !== undefined ? { proxy: options.proxy } : {}),
78
- ...(state === 'ephemeral' && options.fingerprint ? { fingerprint: options.fingerprint } : {}),
79
- ...(state === 'ephemeral' && options.extensions ? { extensions: options.extensions } : {}),
80
- },
81
- };
82
- }