@bctrl/sdk 1.0.1 → 1.0.2
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 +24 -29
- package/dist/bctrl.d.ts +22 -36
- package/dist/bctrl.js +40 -75
- package/dist/browsers.d.ts +24 -0
- package/dist/browsers.js +82 -0
- package/dist/errors.d.ts +49 -43
- package/dist/errors.js +83 -120
- package/dist/files.d.ts +31 -0
- package/dist/files.js +97 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.js +135 -0
- package/dist/index.d.ts +9 -12
- package/dist/index.js +8 -23
- package/dist/invocations.d.ts +24 -0
- package/dist/invocations.js +66 -0
- package/dist/pagination.d.ts +2 -0
- package/dist/pagination.js +13 -0
- package/dist/runs.d.ts +38 -0
- package/dist/runs.js +99 -0
- package/dist/runtimes.d.ts +73 -0
- package/dist/runtimes.js +205 -0
- package/dist/spaces.d.ts +41 -0
- package/dist/spaces.js +96 -0
- package/dist/types.d.ts +386 -0
- package/dist/types.js +1 -0
- package/dist/utils.d.ts +4 -0
- package/dist/utils.js +27 -0
- package/dist/version.js +2 -2
- package/package.json +12 -31
- package/dist/agents/browser-use/index.d.ts +0 -1
- package/dist/agents/browser-use/index.js +0 -9
- package/dist/agents/browser-use/namespace.d.ts +0 -39
- package/dist/agents/browser-use/namespace.js +0 -93
- package/dist/agents/index.d.ts +0 -2
- package/dist/agents/index.js +0 -17
- package/dist/agents/stagehand/core.d.ts +0 -93
- package/dist/agents/stagehand/core.js +0 -144
- package/dist/agents/stagehand/index.d.ts +0 -3
- package/dist/agents/stagehand/index.js +0 -24
- package/dist/agents/stagehand/namespace.d.ts +0 -51
- package/dist/agents/stagehand/namespace.js +0 -65
- package/dist/ai-credentials/client.d.ts +0 -12
- package/dist/ai-credentials/client.js +0 -70
- package/dist/ai-credentials/index.d.ts +0 -1
- package/dist/ai-credentials/index.js +0 -1
- package/dist/base/event-binding.d.ts +0 -7
- package/dist/base/event-binding.js +0 -23
- package/dist/base/types.d.ts +0 -109
- package/dist/base/types.js +0 -4
- package/dist/browser-extensions/client.d.ts +0 -15
- package/dist/browser-extensions/client.js +0 -72
- package/dist/browser-extensions/index.d.ts +0 -2
- package/dist/browser-extensions/index.js +0 -1
- package/dist/browser-profiles/client.d.ts +0 -11
- package/dist/browser-profiles/client.js +0 -63
- package/dist/browser-profiles/index.d.ts +0 -1
- package/dist/browser-profiles/index.js +0 -1
- package/dist/captcha/index.d.ts +0 -1
- package/dist/captcha/index.js +0 -1
- package/dist/captcha/namespace.d.ts +0 -34
- package/dist/captcha/namespace.js +0 -41
- package/dist/client/index.d.ts +0 -1
- package/dist/client/index.js +0 -1
- package/dist/client/rpc.d.ts +0 -83
- package/dist/client/rpc.js +0 -354
- package/dist/config.d.ts +0 -5
- package/dist/config.js +0 -28
- package/dist/constants/browser.d.ts +0 -2
- package/dist/constants/browser.js +0 -1
- package/dist/contracts/agent-tools.d.ts +0 -45
- package/dist/contracts/agent-tools.js +0 -31
- package/dist/contracts/automation.d.ts +0 -265
- package/dist/contracts/automation.js +0 -109
- package/dist/contracts/browser-management.d.ts +0 -179
- package/dist/contracts/browser-management.js +0 -95
- package/dist/contracts/browser-use.d.ts +0 -136
- package/dist/contracts/browser-use.js +0 -93
- package/dist/contracts/captcha.d.ts +0 -114
- package/dist/contracts/captcha.js +0 -40
- package/dist/contracts/desktop.d.ts +0 -223
- package/dist/contracts/desktop.js +0 -121
- package/dist/contracts/drivers/playwright.d.ts +0 -2008
- package/dist/contracts/drivers/playwright.js +0 -2033
- package/dist/contracts/drivers/puppeteer.d.ts +0 -1221
- package/dist/contracts/drivers/puppeteer.js +0 -941
- package/dist/contracts/drivers/selenium.d.ts +0 -156
- package/dist/contracts/drivers/selenium.js +0 -61
- package/dist/contracts/drivers/stagehand.d.ts +0 -155
- package/dist/contracts/drivers/stagehand.js +0 -7
- package/dist/contracts/extensions.d.ts +0 -13
- package/dist/contracts/extensions.js +0 -9
- package/dist/contracts/index.d.ts +0 -13
- package/dist/contracts/index.js +0 -13
- package/dist/contracts/public-api.d.ts +0 -360
- package/dist/contracts/public-api.js +0 -17
- package/dist/contracts/runtime.d.ts +0 -81
- package/dist/contracts/runtime.js +0 -16
- package/dist/contracts/stagehand.d.ts +0 -253
- package/dist/contracts/stagehand.js +0 -145
- package/dist/contracts/storage.d.ts +0 -51
- package/dist/contracts/storage.js +0 -56
- package/dist/contracts/vault.d.ts +0 -119
- package/dist/contracts/vault.js +0 -112
- package/dist/contracts/version.d.ts +0 -3
- package/dist/contracts/version.js +0 -16
- package/dist/desktop.d.ts +0 -2
- package/dist/desktop.js +0 -3
- package/dist/drivers/desktop/index.d.ts +0 -65
- package/dist/drivers/desktop/index.js +0 -68
- package/dist/drivers/desktop/session.d.ts +0 -313
- package/dist/drivers/desktop/session.js +0 -432
- package/dist/drivers/playwright/event-emitter.d.ts +0 -160
- package/dist/drivers/playwright/event-emitter.js +0 -297
- package/dist/drivers/playwright/generated/api-request-context.d.ts +0 -137
- package/dist/drivers/playwright/generated/api-request-context.js +0 -154
- package/dist/drivers/playwright/generated/api-response.d.ts +0 -119
- package/dist/drivers/playwright/generated/api-response.js +0 -123
- package/dist/drivers/playwright/generated/browser-context.d.ts +0 -284
- package/dist/drivers/playwright/generated/browser-context.js +0 -458
- package/dist/drivers/playwright/generated/browser.d.ts +0 -120
- package/dist/drivers/playwright/generated/browser.js +0 -151
- package/dist/drivers/playwright/generated/clock.d.ts +0 -80
- package/dist/drivers/playwright/generated/clock.js +0 -94
- package/dist/drivers/playwright/generated/console-message.d.ts +0 -94
- package/dist/drivers/playwright/generated/console-message.js +0 -89
- package/dist/drivers/playwright/generated/coverage.d.ts +0 -57
- package/dist/drivers/playwright/generated/coverage.js +0 -66
- package/dist/drivers/playwright/generated/dialog.d.ts +0 -79
- package/dist/drivers/playwright/generated/dialog.js +0 -80
- package/dist/drivers/playwright/generated/element-handle.d.ts +0 -399
- package/dist/drivers/playwright/generated/element-handle.js +0 -501
- package/dist/drivers/playwright/generated/frame-locator.d.ts +0 -34
- package/dist/drivers/playwright/generated/frame-locator.js +0 -63
- package/dist/drivers/playwright/generated/frame.d.ts +0 -557
- package/dist/drivers/playwright/generated/frame.js +0 -634
- package/dist/drivers/playwright/generated/js-handle.d.ts +0 -72
- package/dist/drivers/playwright/generated/js-handle.js +0 -92
- package/dist/drivers/playwright/generated/keyboard.d.ts +0 -103
- package/dist/drivers/playwright/generated/keyboard.js +0 -113
- package/dist/drivers/playwright/generated/locator.d.ts +0 -795
- package/dist/drivers/playwright/generated/locator.js +0 -974
- package/dist/drivers/playwright/generated/mouse.d.ts +0 -97
- package/dist/drivers/playwright/generated/mouse.js +0 -109
- package/dist/drivers/playwright/generated/page.d.ts +0 -762
- package/dist/drivers/playwright/generated/page.js +0 -988
- package/dist/drivers/playwright/generated/touchscreen.d.ts +0 -34
- package/dist/drivers/playwright/generated/touchscreen.js +0 -37
- package/dist/drivers/playwright/generated/tracing.d.ts +0 -78
- package/dist/drivers/playwright/generated/tracing.js +0 -80
- package/dist/drivers/playwright/generated/worker.d.ts +0 -53
- package/dist/drivers/playwright/generated/worker.js +0 -59
- package/dist/drivers/playwright/index.d.ts +0 -19
- package/dist/drivers/playwright/index.js +0 -20
- package/dist/drivers/playwright/remote-base.d.ts +0 -62
- package/dist/drivers/playwright/remote-base.js +0 -86
- package/dist/drivers/playwright/types.d.ts +0 -148
- package/dist/drivers/playwright/types.js +0 -8
- package/dist/drivers/puppeteer/errors.d.ts +0 -50
- package/dist/drivers/puppeteer/errors.js +0 -71
- package/dist/drivers/puppeteer/event-emitter.d.ts +0 -145
- package/dist/drivers/puppeteer/event-emitter.js +0 -259
- package/dist/drivers/puppeteer/generated/accessibility.d.ts +0 -77
- package/dist/drivers/puppeteer/generated/accessibility.js +0 -74
- package/dist/drivers/puppeteer/generated/browser-context.d.ts +0 -116
- package/dist/drivers/puppeteer/generated/browser-context.js +0 -168
- package/dist/drivers/puppeteer/generated/browser.d.ts +0 -169
- package/dist/drivers/puppeteer/generated/browser.js +0 -246
- package/dist/drivers/puppeteer/generated/console-message.d.ts +0 -54
- package/dist/drivers/puppeteer/generated/console-message.js +0 -69
- package/dist/drivers/puppeteer/generated/coverage.d.ts +0 -49
- package/dist/drivers/puppeteer/generated/coverage.js +0 -57
- package/dist/drivers/puppeteer/generated/dialog.d.ts +0 -46
- package/dist/drivers/puppeteer/generated/dialog.js +0 -60
- package/dist/drivers/puppeteer/generated/element-handle.d.ts +0 -261
- package/dist/drivers/puppeteer/generated/element-handle.js +0 -341
- package/dist/drivers/puppeteer/generated/file-chooser.d.ts +0 -34
- package/dist/drivers/puppeteer/generated/file-chooser.js +0 -43
- package/dist/drivers/puppeteer/generated/frame.d.ts +0 -221
- package/dist/drivers/puppeteer/generated/frame.js +0 -302
- package/dist/drivers/puppeteer/generated/http-request.d.ts +0 -195
- package/dist/drivers/puppeteer/generated/http-request.js +0 -243
- package/dist/drivers/puppeteer/generated/http-response.d.ts +0 -142
- package/dist/drivers/puppeteer/generated/http-response.js +0 -169
- package/dist/drivers/puppeteer/generated/js-handle.d.ts +0 -104
- package/dist/drivers/puppeteer/generated/js-handle.js +0 -125
- package/dist/drivers/puppeteer/generated/keyboard.d.ts +0 -79
- package/dist/drivers/puppeteer/generated/keyboard.js +0 -89
- package/dist/drivers/puppeteer/generated/locator.d.ts +0 -141
- package/dist/drivers/puppeteer/generated/locator.js +0 -164
- package/dist/drivers/puppeteer/generated/mouse.d.ts +0 -74
- package/dist/drivers/puppeteer/generated/mouse.js +0 -94
- package/dist/drivers/puppeteer/generated/page.d.ts +0 -604
- package/dist/drivers/puppeteer/generated/page.js +0 -776
- package/dist/drivers/puppeteer/generated/target.d.ts +0 -105
- package/dist/drivers/puppeteer/generated/target.js +0 -123
- package/dist/drivers/puppeteer/generated/touchscreen.d.ts +0 -87
- package/dist/drivers/puppeteer/generated/touchscreen.js +0 -103
- package/dist/drivers/puppeteer/generated/tracing.d.ts +0 -38
- package/dist/drivers/puppeteer/generated/tracing.js +0 -43
- package/dist/drivers/puppeteer/generated/web-worker.d.ts +0 -63
- package/dist/drivers/puppeteer/generated/web-worker.js +0 -73
- package/dist/drivers/puppeteer/index.d.ts +0 -21
- package/dist/drivers/puppeteer/index.js +0 -23
- package/dist/drivers/puppeteer/remote-base.d.ts +0 -57
- package/dist/drivers/puppeteer/remote-base.js +0 -79
- package/dist/drivers/puppeteer/types.d.ts +0 -178
- package/dist/drivers/puppeteer/types.js +0 -8
- package/dist/drivers/selenium/driver.d.ts +0 -28
- package/dist/drivers/selenium/driver.js +0 -169
- package/dist/drivers/selenium/element.d.ts +0 -34
- package/dist/drivers/selenium/element.js +0 -73
- package/dist/drivers/selenium/index.d.ts +0 -3
- package/dist/drivers/selenium/index.js +0 -5
- package/dist/drivers/selenium/types.d.ts +0 -2
- package/dist/drivers/selenium/types.js +0 -12
- package/dist/drivers/stagehand/generated/context.d.ts +0 -127
- package/dist/drivers/stagehand/generated/context.js +0 -153
- package/dist/drivers/stagehand/generated/locator.d.ts +0 -324
- package/dist/drivers/stagehand/generated/locator.js +0 -368
- package/dist/drivers/stagehand/generated/page.d.ts +0 -377
- package/dist/drivers/stagehand/generated/page.js +0 -439
- package/dist/drivers/stagehand/generated/response.d.ts +0 -197
- package/dist/drivers/stagehand/generated/response.js +0 -232
- package/dist/drivers/stagehand/index.d.ts +0 -5
- package/dist/drivers/stagehand/index.js +0 -8
- package/dist/drivers/stagehand/types.d.ts +0 -1
- package/dist/drivers/stagehand/types.js +0 -7
- package/dist/extensions/client.d.ts +0 -47
- package/dist/extensions/client.js +0 -154
- package/dist/extensions/index.d.ts +0 -1
- package/dist/extensions/index.js +0 -1
- package/dist/internal/dev-client.d.ts +0 -5
- package/dist/internal/dev-client.js +0 -9
- package/dist/internal/rpc-targets.d.ts +0 -17
- package/dist/internal/rpc-targets.js +0 -58
- package/dist/internal/serialization.d.ts +0 -32
- package/dist/internal/serialization.js +0 -42
- package/dist/internal/transport.d.ts +0 -24
- package/dist/internal/transport.js +0 -29
- package/dist/playwright.d.ts +0 -1
- package/dist/playwright.js +0 -2
- package/dist/puppeteer.d.ts +0 -1
- package/dist/puppeteer.js +0 -2
- package/dist/selenium.d.ts +0 -1
- package/dist/selenium.js +0 -2
- package/dist/stagehand.d.ts +0 -1
- package/dist/stagehand.js +0 -2
- package/dist/storage/client.d.ts +0 -151
- package/dist/storage/client.js +0 -329
- package/dist/storage/index.d.ts +0 -2
- package/dist/storage/index.js +0 -4
- package/dist/telemetry.d.ts +0 -18
- package/dist/telemetry.js +0 -93
- package/dist/updates/client.d.ts +0 -8
- package/dist/updates/client.js +0 -128
- package/dist/updates/index.d.ts +0 -1
- package/dist/updates/index.js +0 -1
- package/dist/utils/http.d.ts +0 -39
- package/dist/utils/http.js +0 -88
- package/dist/utils/index.d.ts +0 -4
- package/dist/utils/index.js +0 -4
- package/dist/utils/logger.d.ts +0 -27
- package/dist/utils/logger.js +0 -74
- package/dist/utils/schema.d.ts +0 -17
- package/dist/utils/schema.js +0 -31
- package/dist/utils/url.d.ts +0 -5
- package/dist/utils/url.js +0 -7
- package/dist/vault/client.d.ts +0 -43
- package/dist/vault/client.js +0 -123
- package/dist/vault/index.d.ts +0 -1
- package/dist/vault/index.js +0 -1
- package/dist/workspaces/browser-runtime.d.ts +0 -251
- package/dist/workspaces/browser-runtime.js +0 -1025
- package/dist/workspaces/client.d.ts +0 -48
- package/dist/workspaces/client.js +0 -222
- package/dist/workspaces/index.d.ts +0 -2
- package/dist/workspaces/index.js +0 -2
- package/dist/workspaces/runtime-event-pump.d.ts +0 -65
- package/dist/workspaces/runtime-event-pump.js +0 -716
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export class V2InvocationResource {
|
|
2
|
+
http;
|
|
3
|
+
data;
|
|
4
|
+
constructor(http, data) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
this.data = data;
|
|
7
|
+
}
|
|
8
|
+
get id() {
|
|
9
|
+
return this.data.id;
|
|
10
|
+
}
|
|
11
|
+
refresh() {
|
|
12
|
+
return this.http
|
|
13
|
+
.request(`/invocations/${encodeURIComponent(this.id)}`)
|
|
14
|
+
.then((response) => response.data);
|
|
15
|
+
}
|
|
16
|
+
wait(request) {
|
|
17
|
+
return this.http.request(`/invocations/${encodeURIComponent(this.id)}/wait`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: request ?? {},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
cancel() {
|
|
23
|
+
return this.http
|
|
24
|
+
.request(`/invocations/${encodeURIComponent(this.id)}/cancel`, {
|
|
25
|
+
method: 'POST',
|
|
26
|
+
})
|
|
27
|
+
.then((response) => response.data);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export class V2InvocationsClient {
|
|
31
|
+
http;
|
|
32
|
+
constructor(http) {
|
|
33
|
+
this.http = http;
|
|
34
|
+
}
|
|
35
|
+
async get(id) {
|
|
36
|
+
const response = await this.http.request(`/invocations/${encodeURIComponent(id)}`);
|
|
37
|
+
return new V2InvocationResource(this.http, response.data);
|
|
38
|
+
}
|
|
39
|
+
wait(id, request) {
|
|
40
|
+
return this.http.request(`/invocations/${encodeURIComponent(id)}/wait`, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: request ?? {},
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
async cancel(id) {
|
|
46
|
+
const response = await this.http.request(`/invocations/${encodeURIComponent(id)}/cancel`, {
|
|
47
|
+
method: 'POST',
|
|
48
|
+
});
|
|
49
|
+
return new V2InvocationResource(this.http, response.data);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class V2RuntimeInvocationsClient {
|
|
53
|
+
http;
|
|
54
|
+
runtimeId;
|
|
55
|
+
constructor(http, runtimeId) {
|
|
56
|
+
this.http = http;
|
|
57
|
+
this.runtimeId = runtimeId;
|
|
58
|
+
}
|
|
59
|
+
async create(request) {
|
|
60
|
+
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/invocations`, {
|
|
61
|
+
method: 'POST',
|
|
62
|
+
body: request,
|
|
63
|
+
});
|
|
64
|
+
return new V2InvocationResource(this.http, response.data);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export async function* iterateV2Pages(initialQuery, fetchPage) {
|
|
2
|
+
let cursor = initialQuery.cursor;
|
|
3
|
+
for (;;) {
|
|
4
|
+
const page = await fetchPage({ ...initialQuery, cursor });
|
|
5
|
+
for (const item of page.data) {
|
|
6
|
+
yield item;
|
|
7
|
+
}
|
|
8
|
+
if (!page.nextCursor) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
cursor = page.nextCursor;
|
|
12
|
+
}
|
|
13
|
+
}
|
package/dist/runs.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { V2HttpClient } from './http.js';
|
|
2
|
+
import { V2RunFilesClient } from './files.js';
|
|
3
|
+
import type { V2ListEnvelope, V2Run, V2RunCommand, V2RunCommandsListQuery, V2RunEvent, V2RunEventsListQuery, V2RunEventsWaitRequest, V2RunEventsWaitResponse, V2RunListQuery, V2RunLiveRequest, V2RunLiveResponse, V2RunRecordingRequest, V2RunRecordingResponse } from './types.js';
|
|
4
|
+
export declare class V2RunEventsClient {
|
|
5
|
+
private readonly http;
|
|
6
|
+
private readonly runId;
|
|
7
|
+
constructor(http: V2HttpClient, runId: string);
|
|
8
|
+
list(query?: V2RunEventsListQuery): Promise<V2ListEnvelope<V2RunEvent>>;
|
|
9
|
+
iter(query?: V2RunEventsListQuery): AsyncGenerator<V2RunEvent, void, undefined>;
|
|
10
|
+
wait(request?: V2RunEventsWaitRequest): Promise<V2RunEventsWaitResponse>;
|
|
11
|
+
streamUrl(query?: Pick<V2RunEventsListQuery, 'type' | 'category' | 'connectionId'>): string;
|
|
12
|
+
}
|
|
13
|
+
export declare class V2RunCommandsClient {
|
|
14
|
+
private readonly http;
|
|
15
|
+
private readonly runId;
|
|
16
|
+
constructor(http: V2HttpClient, runId: string);
|
|
17
|
+
list(query?: V2RunCommandsListQuery): Promise<V2ListEnvelope<V2RunCommand>>;
|
|
18
|
+
iter(query?: V2RunCommandsListQuery): AsyncGenerator<V2RunCommand, void, undefined>;
|
|
19
|
+
}
|
|
20
|
+
export declare class V2RunResource {
|
|
21
|
+
private readonly http;
|
|
22
|
+
readonly data: V2Run;
|
|
23
|
+
readonly events: V2RunEventsClient;
|
|
24
|
+
readonly commands: V2RunCommandsClient;
|
|
25
|
+
readonly files: V2RunFilesClient;
|
|
26
|
+
constructor(http: V2HttpClient, data: V2Run);
|
|
27
|
+
get id(): string;
|
|
28
|
+
refresh(): Promise<V2RunResource>;
|
|
29
|
+
live(request?: V2RunLiveRequest): Promise<V2RunLiveResponse>;
|
|
30
|
+
recording(request?: V2RunRecordingRequest): Promise<V2RunRecordingResponse>;
|
|
31
|
+
}
|
|
32
|
+
export declare class V2RunsClient {
|
|
33
|
+
private readonly http;
|
|
34
|
+
constructor(http: V2HttpClient);
|
|
35
|
+
list(query?: V2RunListQuery): Promise<V2ListEnvelope<V2Run>>;
|
|
36
|
+
iter(query?: V2RunListQuery): AsyncGenerator<V2Run, void, undefined>;
|
|
37
|
+
get(id: string): Promise<V2RunResource>;
|
|
38
|
+
}
|
package/dist/runs.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { iterateV2Pages } from './pagination.js';
|
|
2
|
+
import { V2RunFilesClient } from './files.js';
|
|
3
|
+
export class V2RunEventsClient {
|
|
4
|
+
http;
|
|
5
|
+
runId;
|
|
6
|
+
constructor(http, runId) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
this.runId = runId;
|
|
9
|
+
}
|
|
10
|
+
list(query = {}) {
|
|
11
|
+
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events`, { query });
|
|
12
|
+
}
|
|
13
|
+
iter(query = {}) {
|
|
14
|
+
return iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
|
|
15
|
+
}
|
|
16
|
+
wait(request) {
|
|
17
|
+
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/events/wait`, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
body: request ?? {},
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
streamUrl(query = {}) {
|
|
23
|
+
const url = new URL(`${this.http.baseUrl}/runs/${encodeURIComponent(this.runId)}/events/stream`);
|
|
24
|
+
for (const [key, value] of Object.entries(query)) {
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
if (Array.isArray(value)) {
|
|
28
|
+
for (const item of value)
|
|
29
|
+
url.searchParams.append(key, item);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
url.searchParams.set(key, value);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return url.toString();
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
export class V2RunCommandsClient {
|
|
39
|
+
http;
|
|
40
|
+
runId;
|
|
41
|
+
constructor(http, runId) {
|
|
42
|
+
this.http = http;
|
|
43
|
+
this.runId = runId;
|
|
44
|
+
}
|
|
45
|
+
list(query = {}) {
|
|
46
|
+
return this.http.request(`/runs/${encodeURIComponent(this.runId)}/commands`, { query });
|
|
47
|
+
}
|
|
48
|
+
iter(query = {}) {
|
|
49
|
+
return iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
export class V2RunResource {
|
|
53
|
+
http;
|
|
54
|
+
data;
|
|
55
|
+
events;
|
|
56
|
+
commands;
|
|
57
|
+
files;
|
|
58
|
+
constructor(http, data) {
|
|
59
|
+
this.http = http;
|
|
60
|
+
this.data = data;
|
|
61
|
+
this.events = new V2RunEventsClient(http, data.id);
|
|
62
|
+
this.commands = new V2RunCommandsClient(http, data.id);
|
|
63
|
+
this.files = new V2RunFilesClient(http, data.id);
|
|
64
|
+
}
|
|
65
|
+
get id() {
|
|
66
|
+
return this.data.id;
|
|
67
|
+
}
|
|
68
|
+
refresh() {
|
|
69
|
+
return new V2RunsClient(this.http).get(this.id);
|
|
70
|
+
}
|
|
71
|
+
live(request) {
|
|
72
|
+
return this.http.request(`/runs/${encodeURIComponent(this.id)}/live`, {
|
|
73
|
+
method: 'POST',
|
|
74
|
+
body: request ?? {},
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
recording(request) {
|
|
78
|
+
return this.http.request(`/runs/${encodeURIComponent(this.id)}/recording`, {
|
|
79
|
+
method: 'POST',
|
|
80
|
+
body: request ?? {},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export class V2RunsClient {
|
|
85
|
+
http;
|
|
86
|
+
constructor(http) {
|
|
87
|
+
this.http = http;
|
|
88
|
+
}
|
|
89
|
+
list(query = {}) {
|
|
90
|
+
return this.http.request('/runs', { query });
|
|
91
|
+
}
|
|
92
|
+
iter(query = {}) {
|
|
93
|
+
return iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
|
|
94
|
+
}
|
|
95
|
+
async get(id) {
|
|
96
|
+
const run = await this.http.request(`/runs/${encodeURIComponent(id)}`);
|
|
97
|
+
return new V2RunResource(this.http, run);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { V2HttpClient } from './http.js';
|
|
2
|
+
import { V2RuntimeInvocationsClient } from './invocations.js';
|
|
3
|
+
import { V2RunResource } from './runs.js';
|
|
4
|
+
import type { V2ListEnvelope, V2File, V2Runtime, V2RuntimeConnection, V2RuntimeConnectionCreateOptions, V2RuntimeConnectionCreateResponse, V2RuntimeCreateRequest, V2RuntimeFileCollectRequest, V2RuntimeFileStageRequest, V2RuntimeFileUploadRequest, V2RuntimeFileUploadResponse, V2RuntimeStagedFile, V2RuntimeListQuery, V2RuntimeRunListQuery, V2RunSummary, V2SpaceRuntimeCreateRequest } from './types.js';
|
|
5
|
+
export declare class V2RuntimeConnectionResource {
|
|
6
|
+
private readonly http;
|
|
7
|
+
private readonly runtimeId;
|
|
8
|
+
readonly data: V2RuntimeConnectionCreateResponse;
|
|
9
|
+
constructor(http: V2HttpClient, runtimeId: string, data: V2RuntimeConnectionCreateResponse);
|
|
10
|
+
get id(): string;
|
|
11
|
+
get endpoint(): V2RuntimeConnectionCreateResponse['endpoint'];
|
|
12
|
+
get wsUrl(): string | undefined;
|
|
13
|
+
close(): Promise<V2RuntimeConnection>;
|
|
14
|
+
}
|
|
15
|
+
export declare class V2RuntimeConnectionsClient {
|
|
16
|
+
private readonly http;
|
|
17
|
+
private readonly runtimeId;
|
|
18
|
+
constructor(http: V2HttpClient, runtimeId: string);
|
|
19
|
+
create(request?: V2RuntimeConnectionCreateOptions): Promise<V2RuntimeConnectionResource>;
|
|
20
|
+
list(query?: {
|
|
21
|
+
status?: string | string[];
|
|
22
|
+
limit?: number;
|
|
23
|
+
}): Promise<V2ListEnvelope<V2RuntimeConnection>>;
|
|
24
|
+
delete(connectionId: string): Promise<V2RuntimeConnection>;
|
|
25
|
+
}
|
|
26
|
+
export declare class V2RuntimeRunsClient {
|
|
27
|
+
private readonly http;
|
|
28
|
+
private readonly runtimeId;
|
|
29
|
+
constructor(http: V2HttpClient, runtimeId: string);
|
|
30
|
+
list(query?: V2RuntimeRunListQuery): Promise<V2ListEnvelope<V2RunSummary>>;
|
|
31
|
+
iter(query?: V2RuntimeRunListQuery): AsyncGenerator<V2RunSummary, void, undefined>;
|
|
32
|
+
}
|
|
33
|
+
export declare class V2RuntimeFilesClient {
|
|
34
|
+
private readonly http;
|
|
35
|
+
private readonly runtimeId;
|
|
36
|
+
constructor(http: V2HttpClient, runtimeId: string);
|
|
37
|
+
upload(request: V2RuntimeFileUploadRequest): Promise<V2RuntimeFileUploadResponse>;
|
|
38
|
+
stage(request: V2RuntimeFileStageRequest): Promise<V2RuntimeStagedFile>;
|
|
39
|
+
collect(request: V2RuntimeFileCollectRequest): Promise<V2File>;
|
|
40
|
+
}
|
|
41
|
+
export declare class V2RuntimeResource {
|
|
42
|
+
private readonly http;
|
|
43
|
+
readonly data: V2Runtime;
|
|
44
|
+
readonly connections: V2RuntimeConnectionsClient;
|
|
45
|
+
readonly files: V2RuntimeFilesClient;
|
|
46
|
+
readonly runs: V2RuntimeRunsClient;
|
|
47
|
+
readonly invocations: V2RuntimeInvocationsClient;
|
|
48
|
+
constructor(http: V2HttpClient, data: V2Runtime);
|
|
49
|
+
get id(): string;
|
|
50
|
+
get activeRunId(): string | null;
|
|
51
|
+
refresh(): Promise<V2RuntimeResource>;
|
|
52
|
+
connect(request?: V2RuntimeConnectionCreateOptions): Promise<V2RuntimeConnectionResource>;
|
|
53
|
+
start(): Promise<{
|
|
54
|
+
runtime: V2RuntimeResource;
|
|
55
|
+
run: V2RunResource;
|
|
56
|
+
}>;
|
|
57
|
+
stop(): Promise<V2Runtime>;
|
|
58
|
+
run(): Promise<V2RunResource>;
|
|
59
|
+
}
|
|
60
|
+
export declare class V2RuntimesClient {
|
|
61
|
+
private readonly http;
|
|
62
|
+
constructor(http: V2HttpClient);
|
|
63
|
+
list(query?: V2RuntimeListQuery): Promise<V2ListEnvelope<V2Runtime>>;
|
|
64
|
+
iter(query?: V2RuntimeListQuery): AsyncGenerator<V2Runtime, void, undefined>;
|
|
65
|
+
create(request: V2RuntimeCreateRequest): Promise<V2RuntimeResource>;
|
|
66
|
+
createInSpace(spaceId: string, request: V2SpaceRuntimeCreateRequest): Promise<V2RuntimeResource>;
|
|
67
|
+
get(id: string): Promise<V2RuntimeResource>;
|
|
68
|
+
stop(id: string): Promise<V2Runtime>;
|
|
69
|
+
start(id: string): Promise<{
|
|
70
|
+
runtime: V2RuntimeResource;
|
|
71
|
+
run: V2RunResource;
|
|
72
|
+
}>;
|
|
73
|
+
}
|
package/dist/runtimes.js
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { BctrlValidationError } from './errors.js';
|
|
2
|
+
import { V2RuntimeInvocationsClient } from './invocations.js';
|
|
3
|
+
import { iterateV2Pages } from './pagination.js';
|
|
4
|
+
import { V2RunResource } from './runs.js';
|
|
5
|
+
export class V2RuntimeConnectionResource {
|
|
6
|
+
http;
|
|
7
|
+
runtimeId;
|
|
8
|
+
data;
|
|
9
|
+
constructor(http, runtimeId, data) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
this.runtimeId = runtimeId;
|
|
12
|
+
this.data = data;
|
|
13
|
+
}
|
|
14
|
+
get id() {
|
|
15
|
+
return this.data.id;
|
|
16
|
+
}
|
|
17
|
+
get endpoint() {
|
|
18
|
+
return this.data.endpoint;
|
|
19
|
+
}
|
|
20
|
+
get wsUrl() {
|
|
21
|
+
return this.data.endpoint.type === 'websocket' ? this.data.endpoint.url : undefined;
|
|
22
|
+
}
|
|
23
|
+
close() {
|
|
24
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections/${encodeURIComponent(this.id)}`, { method: 'DELETE' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export class V2RuntimeConnectionsClient {
|
|
28
|
+
http;
|
|
29
|
+
runtimeId;
|
|
30
|
+
constructor(http, runtimeId) {
|
|
31
|
+
this.http = http;
|
|
32
|
+
this.runtimeId = runtimeId;
|
|
33
|
+
}
|
|
34
|
+
async create(request = {}) {
|
|
35
|
+
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
body: {
|
|
38
|
+
protocol: request.protocol ?? 'cdp',
|
|
39
|
+
...request,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
return new V2RuntimeConnectionResource(this.http, this.runtimeId, response);
|
|
43
|
+
}
|
|
44
|
+
list(query = {}) {
|
|
45
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections`, { query });
|
|
46
|
+
}
|
|
47
|
+
delete(connectionId) {
|
|
48
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/connections/${encodeURIComponent(connectionId)}`, { method: 'DELETE' });
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export class V2RuntimeRunsClient {
|
|
52
|
+
http;
|
|
53
|
+
runtimeId;
|
|
54
|
+
constructor(http, runtimeId) {
|
|
55
|
+
this.http = http;
|
|
56
|
+
this.runtimeId = runtimeId;
|
|
57
|
+
}
|
|
58
|
+
list(query = {}) {
|
|
59
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/runs`, { query });
|
|
60
|
+
}
|
|
61
|
+
iter(query = {}) {
|
|
62
|
+
return iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
export class V2RuntimeFilesClient {
|
|
66
|
+
http;
|
|
67
|
+
runtimeId;
|
|
68
|
+
constructor(http, runtimeId) {
|
|
69
|
+
this.http = http;
|
|
70
|
+
this.runtimeId = runtimeId;
|
|
71
|
+
}
|
|
72
|
+
async upload(request) {
|
|
73
|
+
const form = new FormData();
|
|
74
|
+
if (request.name) {
|
|
75
|
+
form.set('file', request.file, request.name);
|
|
76
|
+
form.set('name', request.name);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
form.set('file', request.file);
|
|
80
|
+
}
|
|
81
|
+
if (request.storagePath)
|
|
82
|
+
form.set('storagePath', request.storagePath);
|
|
83
|
+
if (request.metadata)
|
|
84
|
+
form.set('metadata', JSON.stringify(request.metadata));
|
|
85
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/upload`, {
|
|
86
|
+
method: 'POST',
|
|
87
|
+
body: form,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
stage(request) {
|
|
91
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/stage`, {
|
|
92
|
+
method: 'POST',
|
|
93
|
+
body: request,
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
collect(request) {
|
|
97
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.runtimeId)}/files/collect`, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
body: request,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
export class V2RuntimeResource {
|
|
104
|
+
http;
|
|
105
|
+
data;
|
|
106
|
+
connections;
|
|
107
|
+
files;
|
|
108
|
+
runs;
|
|
109
|
+
invocations;
|
|
110
|
+
constructor(http, data) {
|
|
111
|
+
this.http = http;
|
|
112
|
+
this.data = data;
|
|
113
|
+
this.connections = new V2RuntimeConnectionsClient(http, data.id);
|
|
114
|
+
this.files = new V2RuntimeFilesClient(http, data.id);
|
|
115
|
+
this.runs = new V2RuntimeRunsClient(http, data.id);
|
|
116
|
+
this.invocations = new V2RuntimeInvocationsClient(http, data.id);
|
|
117
|
+
}
|
|
118
|
+
get id() {
|
|
119
|
+
return this.data.id;
|
|
120
|
+
}
|
|
121
|
+
get activeRunId() {
|
|
122
|
+
return this.data.activeRunId;
|
|
123
|
+
}
|
|
124
|
+
refresh() {
|
|
125
|
+
return new V2RuntimesClient(this.http).get(this.id);
|
|
126
|
+
}
|
|
127
|
+
async connect(request) {
|
|
128
|
+
return this.connections.create(request);
|
|
129
|
+
}
|
|
130
|
+
async start() {
|
|
131
|
+
const response = await this.http.request(`/runtimes/${encodeURIComponent(this.id)}/start`, { method: 'POST' });
|
|
132
|
+
return {
|
|
133
|
+
runtime: new V2RuntimeResource(this.http, response.runtime),
|
|
134
|
+
run: new V2RunResource(this.http, response.run),
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
stop() {
|
|
138
|
+
return this.http.request(`/runtimes/${encodeURIComponent(this.id)}/stop`, {
|
|
139
|
+
method: 'POST',
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
async run() {
|
|
143
|
+
const runtime = await this.refresh();
|
|
144
|
+
if (!runtime.activeRunId) {
|
|
145
|
+
throw new BctrlValidationError('Runtime does not have an active run yet', 'runtime.no_active_run', {
|
|
146
|
+
runtimeId: this.id,
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
const run = await this.http.request(`/runs/${encodeURIComponent(runtime.activeRunId)}`);
|
|
150
|
+
return new V2RunResource(this.http, run);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
function validateRuntimeCreateRequest(request) {
|
|
154
|
+
const profileBacked = request.config?.browser?.profile === true;
|
|
155
|
+
if (!profileBacked)
|
|
156
|
+
return;
|
|
157
|
+
if (!request.name?.trim()) {
|
|
158
|
+
throw new BctrlValidationError('name is required when config.browser.profile is true', 'runtime.profile_name_required');
|
|
159
|
+
}
|
|
160
|
+
const unsupported = ['stealth', 'proxy', 'fingerprint', 'extensions'].filter((key) => request.config?.[key] !== undefined);
|
|
161
|
+
if (unsupported.length > 0) {
|
|
162
|
+
throw new BctrlValidationError('Only config.browser.profile and config.lifecycle are supported for profile-backed browser runtimes', 'runtime.profile_config_unsupported', { unsupported });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
export class V2RuntimesClient {
|
|
166
|
+
http;
|
|
167
|
+
constructor(http) {
|
|
168
|
+
this.http = http;
|
|
169
|
+
}
|
|
170
|
+
list(query = {}) {
|
|
171
|
+
return this.http.request('/runtimes', { query });
|
|
172
|
+
}
|
|
173
|
+
iter(query = {}) {
|
|
174
|
+
return iterateV2Pages(query, (pageQuery) => this.list(pageQuery));
|
|
175
|
+
}
|
|
176
|
+
async create(request) {
|
|
177
|
+
validateRuntimeCreateRequest(request);
|
|
178
|
+
const runtime = await this.http.request('/runtimes', {
|
|
179
|
+
method: 'POST',
|
|
180
|
+
body: request,
|
|
181
|
+
});
|
|
182
|
+
return new V2RuntimeResource(this.http, runtime);
|
|
183
|
+
}
|
|
184
|
+
async createInSpace(spaceId, request) {
|
|
185
|
+
validateRuntimeCreateRequest(request);
|
|
186
|
+
const runtime = await this.http.request('/runtimes', {
|
|
187
|
+
method: 'POST',
|
|
188
|
+
body: { ...request, spaceId },
|
|
189
|
+
});
|
|
190
|
+
return new V2RuntimeResource(this.http, runtime);
|
|
191
|
+
}
|
|
192
|
+
async get(id) {
|
|
193
|
+
const runtime = await this.http.request(`/runtimes/${encodeURIComponent(id)}`);
|
|
194
|
+
return new V2RuntimeResource(this.http, runtime);
|
|
195
|
+
}
|
|
196
|
+
stop(id) {
|
|
197
|
+
return this.http.request(`/runtimes/${encodeURIComponent(id)}/stop`, {
|
|
198
|
+
method: 'POST',
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
async start(id) {
|
|
202
|
+
const runtime = await this.get(id);
|
|
203
|
+
return runtime.start();
|
|
204
|
+
}
|
|
205
|
+
}
|
package/dist/spaces.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { V2SpaceBrowsersClient } from './browsers.js';
|
|
2
|
+
import type { V2HttpClient } from './http.js';
|
|
3
|
+
import { V2RuntimeResource, V2RuntimesClient } from './runtimes.js';
|
|
4
|
+
import type { V2ListEnvelope, V2RuntimeListQuery, V2Space, V2SpaceCreateRequest, V2SpaceEnvironment, V2SpaceEnvironmentUpdateRequest, V2SpaceRuntimeCreateRequest, V2SpaceUpdateRequest } from './types.js';
|
|
5
|
+
export declare class V2SpaceEnvironmentClient {
|
|
6
|
+
private readonly http;
|
|
7
|
+
private readonly spaceId;
|
|
8
|
+
constructor(http: V2HttpClient, spaceId: string);
|
|
9
|
+
get(): Promise<V2SpaceEnvironment>;
|
|
10
|
+
update(request: V2SpaceEnvironmentUpdateRequest): Promise<V2SpaceEnvironment>;
|
|
11
|
+
}
|
|
12
|
+
export declare class V2SpaceRuntimesClient {
|
|
13
|
+
private readonly http;
|
|
14
|
+
private readonly spaceId;
|
|
15
|
+
constructor(http: V2HttpClient, spaceId: string);
|
|
16
|
+
list(query?: Omit<V2RuntimeListQuery, 'spaceId'>): ReturnType<V2RuntimesClient['list']>;
|
|
17
|
+
iter(query?: Omit<V2RuntimeListQuery, 'spaceId'>): ReturnType<V2RuntimesClient['iter']>;
|
|
18
|
+
create(request: V2SpaceRuntimeCreateRequest): Promise<V2RuntimeResource>;
|
|
19
|
+
get(runtimeId: string): Promise<V2RuntimeResource>;
|
|
20
|
+
stop(runtimeId: string): ReturnType<V2RuntimesClient['stop']>;
|
|
21
|
+
}
|
|
22
|
+
export declare class V2SpaceResource {
|
|
23
|
+
private readonly http;
|
|
24
|
+
readonly data: V2Space;
|
|
25
|
+
readonly environment: V2SpaceEnvironmentClient;
|
|
26
|
+
readonly runtimes: V2SpaceRuntimesClient;
|
|
27
|
+
readonly browsers: V2SpaceBrowsersClient;
|
|
28
|
+
constructor(http: V2HttpClient, data: V2Space);
|
|
29
|
+
get id(): string;
|
|
30
|
+
refresh(): Promise<V2SpaceResource>;
|
|
31
|
+
update(request: V2SpaceUpdateRequest): Promise<V2SpaceResource>;
|
|
32
|
+
}
|
|
33
|
+
export declare class V2SpacesClient {
|
|
34
|
+
private readonly http;
|
|
35
|
+
constructor(http: V2HttpClient);
|
|
36
|
+
list(): Promise<V2ListEnvelope<V2Space>>;
|
|
37
|
+
iter(): AsyncGenerator<V2Space, void, undefined>;
|
|
38
|
+
create(request: V2SpaceCreateRequest): Promise<V2SpaceResource>;
|
|
39
|
+
get(id: string): Promise<V2SpaceResource>;
|
|
40
|
+
update(id: string, request: V2SpaceUpdateRequest): Promise<V2SpaceResource>;
|
|
41
|
+
}
|
package/dist/spaces.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { V2SpaceBrowsersClient } from './browsers.js';
|
|
2
|
+
import { iterateV2Pages } from './pagination.js';
|
|
3
|
+
import { V2RuntimesClient } from './runtimes.js';
|
|
4
|
+
export class V2SpaceEnvironmentClient {
|
|
5
|
+
http;
|
|
6
|
+
spaceId;
|
|
7
|
+
constructor(http, spaceId) {
|
|
8
|
+
this.http = http;
|
|
9
|
+
this.spaceId = spaceId;
|
|
10
|
+
}
|
|
11
|
+
get() {
|
|
12
|
+
return this.http.request(`/spaces/${encodeURIComponent(this.spaceId)}/environment`);
|
|
13
|
+
}
|
|
14
|
+
update(request) {
|
|
15
|
+
return this.http.request(`/spaces/${encodeURIComponent(this.spaceId)}/environment`, {
|
|
16
|
+
method: 'PATCH',
|
|
17
|
+
body: request,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export class V2SpaceRuntimesClient {
|
|
22
|
+
http;
|
|
23
|
+
spaceId;
|
|
24
|
+
constructor(http, spaceId) {
|
|
25
|
+
this.http = http;
|
|
26
|
+
this.spaceId = spaceId;
|
|
27
|
+
}
|
|
28
|
+
list(query = {}) {
|
|
29
|
+
return new V2RuntimesClient(this.http).list({ ...query, spaceId: this.spaceId });
|
|
30
|
+
}
|
|
31
|
+
iter(query = {}) {
|
|
32
|
+
return new V2RuntimesClient(this.http).iter({ ...query, spaceId: this.spaceId });
|
|
33
|
+
}
|
|
34
|
+
async create(request) {
|
|
35
|
+
return new V2RuntimesClient(this.http).createInSpace(this.spaceId, request);
|
|
36
|
+
}
|
|
37
|
+
async get(runtimeId) {
|
|
38
|
+
return new V2RuntimesClient(this.http).get(runtimeId);
|
|
39
|
+
}
|
|
40
|
+
stop(runtimeId) {
|
|
41
|
+
return new V2RuntimesClient(this.http).stop(runtimeId);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
export class V2SpaceResource {
|
|
45
|
+
http;
|
|
46
|
+
data;
|
|
47
|
+
environment;
|
|
48
|
+
runtimes;
|
|
49
|
+
browsers;
|
|
50
|
+
constructor(http, data) {
|
|
51
|
+
this.http = http;
|
|
52
|
+
this.data = data;
|
|
53
|
+
this.environment = new V2SpaceEnvironmentClient(http, data.id);
|
|
54
|
+
this.runtimes = new V2SpaceRuntimesClient(http, data.id);
|
|
55
|
+
this.browsers = new V2SpaceBrowsersClient(http, data.id);
|
|
56
|
+
}
|
|
57
|
+
get id() {
|
|
58
|
+
return this.data.id;
|
|
59
|
+
}
|
|
60
|
+
refresh() {
|
|
61
|
+
return new V2SpacesClient(this.http).get(this.id);
|
|
62
|
+
}
|
|
63
|
+
async update(request) {
|
|
64
|
+
return new V2SpacesClient(this.http).update(this.id, request);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
export class V2SpacesClient {
|
|
68
|
+
http;
|
|
69
|
+
constructor(http) {
|
|
70
|
+
this.http = http;
|
|
71
|
+
}
|
|
72
|
+
async list() {
|
|
73
|
+
return this.http.request('/spaces');
|
|
74
|
+
}
|
|
75
|
+
iter() {
|
|
76
|
+
return iterateV2Pages({}, () => this.list());
|
|
77
|
+
}
|
|
78
|
+
async create(request) {
|
|
79
|
+
const space = await this.http.request('/spaces', {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
body: request,
|
|
82
|
+
});
|
|
83
|
+
return new V2SpaceResource(this.http, space);
|
|
84
|
+
}
|
|
85
|
+
async get(id) {
|
|
86
|
+
const space = await this.http.request(`/spaces/${encodeURIComponent(id)}`);
|
|
87
|
+
return new V2SpaceResource(this.http, space);
|
|
88
|
+
}
|
|
89
|
+
async update(id, request) {
|
|
90
|
+
const space = await this.http.request(`/spaces/${encodeURIComponent(id)}`, {
|
|
91
|
+
method: 'PATCH',
|
|
92
|
+
body: request,
|
|
93
|
+
});
|
|
94
|
+
return new V2SpaceResource(this.http, space);
|
|
95
|
+
}
|
|
96
|
+
}
|