@browserbasehq/sdk 1.5.0 → 2.0.0-alpha.1
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/CHANGELOG.md +5 -0
- package/LICENSE +198 -4
- package/README.md +266 -76
- package/_shims/MultipartBody.d.ts +9 -0
- package/_shims/MultipartBody.d.ts.map +1 -0
- package/_shims/MultipartBody.js +16 -0
- package/_shims/MultipartBody.js.map +1 -0
- package/_shims/MultipartBody.mjs +12 -0
- package/_shims/MultipartBody.mjs.map +1 -0
- package/_shims/README.md +46 -0
- package/_shims/auto/runtime-bun.d.ts +5 -0
- package/_shims/auto/runtime-bun.d.ts.map +1 -0
- package/_shims/auto/runtime-bun.js +21 -0
- package/_shims/auto/runtime-bun.js.map +1 -0
- package/_shims/auto/runtime-bun.mjs +2 -0
- package/_shims/auto/runtime-bun.mjs.map +1 -0
- package/_shims/auto/runtime-node.d.ts +5 -0
- package/_shims/auto/runtime-node.d.ts.map +1 -0
- package/_shims/auto/runtime-node.js +21 -0
- package/_shims/auto/runtime-node.js.map +1 -0
- package/_shims/auto/runtime-node.mjs +2 -0
- package/_shims/auto/runtime-node.mjs.map +1 -0
- package/_shims/auto/runtime.d.ts +5 -0
- package/_shims/auto/runtime.d.ts.map +1 -0
- package/_shims/auto/runtime.js +21 -0
- package/_shims/auto/runtime.js.map +1 -0
- package/_shims/auto/runtime.mjs +2 -0
- package/_shims/auto/runtime.mjs.map +1 -0
- package/_shims/auto/types-node.d.ts +5 -0
- package/_shims/auto/types-node.d.ts.map +1 -0
- package/_shims/auto/types-node.js +21 -0
- package/_shims/auto/types-node.js.map +1 -0
- package/_shims/auto/types-node.mjs +2 -0
- package/_shims/auto/types-node.mjs.map +1 -0
- package/_shims/auto/types.d.ts +101 -0
- package/_shims/auto/types.js +3 -0
- package/_shims/auto/types.mjs +3 -0
- package/_shims/bun-runtime.d.ts +6 -0
- package/_shims/bun-runtime.d.ts.map +1 -0
- package/_shims/bun-runtime.js +13 -0
- package/_shims/bun-runtime.js.map +1 -0
- package/_shims/bun-runtime.mjs +10 -0
- package/_shims/bun-runtime.mjs.map +1 -0
- package/_shims/index.d.ts +81 -0
- package/_shims/index.js +13 -0
- package/_shims/index.mjs +7 -0
- package/_shims/manual-types.d.ts +12 -0
- package/_shims/manual-types.js +3 -0
- package/_shims/manual-types.mjs +3 -0
- package/_shims/node-runtime.d.ts +3 -0
- package/_shims/node-runtime.d.ts.map +1 -0
- package/_shims/node-runtime.js +88 -0
- package/_shims/node-runtime.js.map +1 -0
- package/_shims/node-runtime.mjs +56 -0
- package/_shims/node-runtime.mjs.map +1 -0
- package/_shims/node-types.d.ts +42 -0
- package/_shims/node-types.js +3 -0
- package/_shims/node-types.mjs +3 -0
- package/_shims/registry.d.ts +37 -0
- package/_shims/registry.d.ts.map +1 -0
- package/_shims/registry.js +41 -0
- package/_shims/registry.js.map +1 -0
- package/_shims/registry.mjs +37 -0
- package/_shims/registry.mjs.map +1 -0
- package/_shims/web-runtime.d.ts +5 -0
- package/_shims/web-runtime.d.ts.map +1 -0
- package/_shims/web-runtime.js +77 -0
- package/_shims/web-runtime.js.map +1 -0
- package/_shims/web-runtime.mjs +71 -0
- package/_shims/web-runtime.mjs.map +1 -0
- package/_shims/web-types.d.ts +83 -0
- package/_shims/web-types.js +3 -0
- package/_shims/web-types.mjs +3 -0
- package/core.d.ts +240 -0
- package/core.d.ts.map +1 -0
- package/core.js +903 -0
- package/core.js.map +1 -0
- package/core.mjs +871 -0
- package/core.mjs.map +1 -0
- package/error.d.ts +53 -0
- package/error.d.ts.map +1 -0
- package/error.js +143 -0
- package/error.js.map +1 -0
- package/error.mjs +127 -0
- package/error.mjs.map +1 -0
- package/index.d.mts +132 -0
- package/index.d.ts +132 -0
- package/index.d.ts.map +1 -0
- package/index.js +115 -0
- package/index.js.map +1 -0
- package/index.mjs +87 -0
- package/index.mjs.map +1 -0
- package/package.json +93 -31
- package/resource.d.ts +6 -0
- package/resource.d.ts.map +1 -0
- package/resource.js +11 -0
- package/resource.js.map +1 -0
- package/resource.mjs +7 -0
- package/resource.mjs.map +1 -0
- package/resources/contexts.d.ts +82 -0
- package/resources/contexts.d.ts.map +1 -0
- package/resources/contexts.js +29 -0
- package/resources/contexts.js.map +1 -0
- package/resources/contexts.mjs +25 -0
- package/resources/contexts.mjs.map +1 -0
- package/resources/extensions.d.ts +35 -0
- package/resources/extensions.d.ts.map +1 -0
- package/resources/extensions.js +56 -0
- package/resources/extensions.js.map +1 -0
- package/resources/extensions.mjs +29 -0
- package/resources/extensions.mjs.map +1 -0
- package/resources/index.d.ts +5 -0
- package/resources/index.d.ts.map +1 -0
- package/resources/index.js +13 -0
- package/resources/index.js.map +1 -0
- package/resources/index.mjs +6 -0
- package/resources/index.mjs.map +1 -0
- package/resources/projects.d.ts +36 -0
- package/resources/projects.d.ts.map +1 -0
- package/resources/projects.js +29 -0
- package/resources/projects.js.map +1 -0
- package/resources/projects.mjs +25 -0
- package/resources/projects.mjs.map +1 -0
- package/resources/sessions/downloads.d.ts +10 -0
- package/resources/sessions/downloads.d.ts.map +1 -0
- package/resources/sessions/downloads.js +15 -0
- package/resources/sessions/downloads.js.map +1 -0
- package/resources/sessions/downloads.mjs +11 -0
- package/resources/sessions/downloads.mjs.map +1 -0
- package/resources/sessions/index.d.ts +6 -0
- package/resources/sessions/index.d.ts.map +1 -0
- package/resources/sessions/index.js +15 -0
- package/resources/sessions/index.js.map +1 -0
- package/resources/sessions/index.mjs +7 -0
- package/resources/sessions/index.mjs.map +1 -0
- package/resources/sessions/logs.d.ts +47 -0
- package/resources/sessions/logs.d.ts.map +1 -0
- package/resources/sessions/logs.js +17 -0
- package/resources/sessions/logs.js.map +1 -0
- package/resources/sessions/logs.mjs +13 -0
- package/resources/sessions/logs.mjs.map +1 -0
- package/resources/sessions/recording.d.ts +29 -0
- package/resources/sessions/recording.d.ts.map +1 -0
- package/resources/sessions/recording.js +17 -0
- package/resources/sessions/recording.js.map +1 -0
- package/resources/sessions/recording.mjs +13 -0
- package/resources/sessions/recording.mjs.map +1 -0
- package/resources/sessions/sessions.d.ts +338 -0
- package/resources/sessions/sessions.d.ts.map +1 -0
- package/resources/sessions/sessions.js +80 -0
- package/resources/sessions/sessions.js.map +1 -0
- package/resources/sessions/sessions.mjs +53 -0
- package/resources/sessions/sessions.mjs.map +1 -0
- package/resources/sessions/uploads.d.ts +20 -0
- package/resources/sessions/uploads.d.ts.map +1 -0
- package/resources/sessions/uploads.js +41 -0
- package/resources/sessions/uploads.js.map +1 -0
- package/resources/sessions/uploads.mjs +14 -0
- package/resources/sessions/uploads.mjs.map +1 -0
- package/shims/node.d.ts +26 -0
- package/shims/node.d.ts.map +1 -0
- package/shims/node.js +6 -0
- package/shims/node.js.map +1 -0
- package/shims/node.mjs +4 -0
- package/shims/node.mjs.map +1 -0
- package/shims/web.d.ts +26 -0
- package/shims/web.d.ts.map +1 -0
- package/shims/web.js +6 -0
- package/shims/web.js.map +1 -0
- package/shims/web.mjs +4 -0
- package/shims/web.mjs.map +1 -0
- package/src/_shims/MultipartBody.ts +9 -0
- package/src/_shims/README.md +46 -0
- package/src/_shims/auto/runtime-bun.ts +4 -0
- package/src/_shims/auto/runtime-node.ts +4 -0
- package/src/_shims/auto/runtime.ts +4 -0
- package/src/_shims/auto/types-node.ts +4 -0
- package/src/_shims/auto/types.d.ts +101 -0
- package/src/_shims/auto/types.js +3 -0
- package/src/_shims/auto/types.mjs +3 -0
- package/src/_shims/bun-runtime.ts +14 -0
- package/src/_shims/index.d.ts +81 -0
- package/src/_shims/index.js +13 -0
- package/src/_shims/index.mjs +7 -0
- package/src/_shims/manual-types.d.ts +12 -0
- package/src/_shims/manual-types.js +3 -0
- package/src/_shims/manual-types.mjs +3 -0
- package/src/_shims/node-runtime.ts +81 -0
- package/src/_shims/node-types.d.ts +42 -0
- package/src/_shims/node-types.js +3 -0
- package/src/_shims/node-types.mjs +3 -0
- package/src/_shims/registry.ts +67 -0
- package/src/_shims/web-runtime.ts +103 -0
- package/src/_shims/web-types.d.ts +83 -0
- package/src/_shims/web-types.js +3 -0
- package/src/_shims/web-types.mjs +3 -0
- package/src/core.ts +1197 -0
- package/src/error.ts +146 -0
- package/src/index.ts +210 -0
- package/src/lib/.keep +4 -0
- package/src/resource.ts +11 -0
- package/src/resources/contexts.ts +108 -0
- package/src/resources/extensions.ts +55 -0
- package/src/resources/index.ts +21 -0
- package/src/resources/projects.ts +56 -0
- package/src/resources/sessions/downloads.ts +14 -0
- package/src/resources/sessions/index.ts +16 -0
- package/src/resources/sessions/logs.ts +68 -0
- package/src/resources/sessions/recording.ts +40 -0
- package/src/resources/sessions/sessions.ts +451 -0
- package/src/resources/sessions/uploads.ts +34 -0
- package/src/shims/node.ts +50 -0
- package/src/shims/web.ts +50 -0
- package/src/tsconfig.json +11 -0
- package/src/uploads.ts +256 -0
- package/src/version.ts +1 -0
- package/uploads.d.ts +75 -0
- package/uploads.d.ts.map +1 -0
- package/uploads.js +170 -0
- package/uploads.js.map +1 -0
- package/uploads.mjs +157 -0
- package/uploads.mjs.map +1 -0
- package/version.d.ts +2 -0
- package/version.d.ts.map +1 -0
- package/version.js +5 -0
- package/version.js.map +1 -0
- package/version.mjs +2 -0
- package/version.mjs.map +1 -0
- package/dist/index.d.ts +0 -138
- package/dist/index.js +0 -228
- package/dist/integrations/ai-sdk.d.ts +0 -18
- package/dist/integrations/ai-sdk.js +0 -19
- package/dist/recorder/call-metadata.d.ts +0 -66
- package/dist/recorder/call-metadata.js +0 -2
- package/dist/recorder/crypto.d.ts +0 -1
- package/dist/recorder/crypto.js +0 -10
- package/dist/recorder/css-utils.d.ts +0 -2
- package/dist/recorder/css-utils.js +0 -34
- package/dist/recorder/generator.d.ts +0 -31
- package/dist/recorder/generator.js +0 -154
- package/dist/recorder/javascript-generator.d.ts +0 -29
- package/dist/recorder/javascript-generator.js +0 -256
- package/dist/recorder/language.d.ts +0 -127
- package/dist/recorder/language.js +0 -21
- package/dist/recorder/recorder-types.d.ts +0 -108
- package/dist/recorder/recorder-types.js +0 -2
- package/dist/recorder/recorder.d.ts +0 -35
- package/dist/recorder/recorder.js +0 -333
- package/dist/recorder/time.d.ts +0 -1
- package/dist/recorder/time.js +0 -42
- package/dist/recorder/timeout-runner.d.ts +0 -6
- package/dist/recorder/timeout-runner.js +0 -19
- package/dist/recorder/utils/isomorphic/css-parser.d.ts +0 -41
- package/dist/recorder/utils/isomorphic/css-parser.js +0 -291
- package/dist/recorder/utils/isomorphic/css-tokenizer.d.ts +0 -171
- package/dist/recorder/utils/isomorphic/css-tokenizer.js +0 -986
- package/dist/recorder/utils/isomorphic/locator-generators.d.ts +0 -79
- package/dist/recorder/utils/isomorphic/locator-generators.js +0 -666
- package/dist/recorder/utils/isomorphic/locator-parser.d.ts +0 -17
- package/dist/recorder/utils/isomorphic/locator-parser.js +0 -244
- package/dist/recorder/utils/isomorphic/locator-utils.d.ts +0 -43
- package/dist/recorder/utils/isomorphic/locator-utils.js +0 -69
- package/dist/recorder/utils/isomorphic/selector-parser.d.ts +0 -48
- package/dist/recorder/utils/isomorphic/selector-parser.js +0 -483
- package/dist/recorder/utils/isomorphic/string-utils.d.ts +0 -28
- package/dist/recorder/utils/isomorphic/string-utils.js +0 -123
- package/dist/recorder/utils.d.ts +0 -20
- package/dist/recorder/utils.js +0 -32
package/src/error.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { castToError, Headers } from './core';
|
|
4
|
+
|
|
5
|
+
export class BrowserbaseError extends Error {}
|
|
6
|
+
|
|
7
|
+
export class APIError extends BrowserbaseError {
|
|
8
|
+
readonly status: number | undefined;
|
|
9
|
+
readonly headers: Headers | undefined;
|
|
10
|
+
readonly error: Object | undefined;
|
|
11
|
+
|
|
12
|
+
constructor(
|
|
13
|
+
status: number | undefined,
|
|
14
|
+
error: Object | undefined,
|
|
15
|
+
message: string | undefined,
|
|
16
|
+
headers: Headers | undefined,
|
|
17
|
+
) {
|
|
18
|
+
super(`${APIError.makeMessage(status, error, message)}`);
|
|
19
|
+
this.status = status;
|
|
20
|
+
this.headers = headers;
|
|
21
|
+
this.error = error;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
|
|
25
|
+
const msg =
|
|
26
|
+
error?.message ?
|
|
27
|
+
typeof error.message === 'string' ?
|
|
28
|
+
error.message
|
|
29
|
+
: JSON.stringify(error.message)
|
|
30
|
+
: error ? JSON.stringify(error)
|
|
31
|
+
: message;
|
|
32
|
+
|
|
33
|
+
if (status && msg) {
|
|
34
|
+
return `${status} ${msg}`;
|
|
35
|
+
}
|
|
36
|
+
if (status) {
|
|
37
|
+
return `${status} status code (no body)`;
|
|
38
|
+
}
|
|
39
|
+
if (msg) {
|
|
40
|
+
return msg;
|
|
41
|
+
}
|
|
42
|
+
return '(no status code or body)';
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static generate(
|
|
46
|
+
status: number | undefined,
|
|
47
|
+
errorResponse: Object | undefined,
|
|
48
|
+
message: string | undefined,
|
|
49
|
+
headers: Headers | undefined,
|
|
50
|
+
) {
|
|
51
|
+
if (!status) {
|
|
52
|
+
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const error = errorResponse as Record<string, any>;
|
|
56
|
+
|
|
57
|
+
if (status === 400) {
|
|
58
|
+
return new BadRequestError(status, error, message, headers);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (status === 401) {
|
|
62
|
+
return new AuthenticationError(status, error, message, headers);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
if (status === 403) {
|
|
66
|
+
return new PermissionDeniedError(status, error, message, headers);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (status === 404) {
|
|
70
|
+
return new NotFoundError(status, error, message, headers);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (status === 409) {
|
|
74
|
+
return new ConflictError(status, error, message, headers);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (status === 422) {
|
|
78
|
+
return new UnprocessableEntityError(status, error, message, headers);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (status === 429) {
|
|
82
|
+
return new RateLimitError(status, error, message, headers);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (status >= 500) {
|
|
86
|
+
return new InternalServerError(status, error, message, headers);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return new APIError(status, error, message, headers);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export class APIUserAbortError extends APIError {
|
|
94
|
+
override readonly status: undefined = undefined;
|
|
95
|
+
|
|
96
|
+
constructor({ message }: { message?: string } = {}) {
|
|
97
|
+
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export class APIConnectionError extends APIError {
|
|
102
|
+
override readonly status: undefined = undefined;
|
|
103
|
+
|
|
104
|
+
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
105
|
+
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
106
|
+
// in some environments the 'cause' property is already declared
|
|
107
|
+
// @ts-ignore
|
|
108
|
+
if (cause) this.cause = cause;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export class APIConnectionTimeoutError extends APIConnectionError {
|
|
113
|
+
constructor({ message }: { message?: string } = {}) {
|
|
114
|
+
super({ message: message ?? 'Request timed out.' });
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class BadRequestError extends APIError {
|
|
119
|
+
override readonly status: 400 = 400;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export class AuthenticationError extends APIError {
|
|
123
|
+
override readonly status: 401 = 401;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export class PermissionDeniedError extends APIError {
|
|
127
|
+
override readonly status: 403 = 403;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export class NotFoundError extends APIError {
|
|
131
|
+
override readonly status: 404 = 404;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export class ConflictError extends APIError {
|
|
135
|
+
override readonly status: 409 = 409;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export class UnprocessableEntityError extends APIError {
|
|
139
|
+
override readonly status: 422 = 422;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export class RateLimitError extends APIError {
|
|
143
|
+
override readonly status: 429 = 429;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export class InternalServerError extends APIError {}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import * as Errors from './error';
|
|
4
|
+
import * as Uploads from './uploads';
|
|
5
|
+
import { type Agent } from './_shims/index';
|
|
6
|
+
import * as Core from './core';
|
|
7
|
+
import * as API from './resources/index';
|
|
8
|
+
|
|
9
|
+
export interface ClientOptions {
|
|
10
|
+
/**
|
|
11
|
+
* Your [Browserbase API Key](https://www.browserbase.com/settings).
|
|
12
|
+
*/
|
|
13
|
+
apiKey?: string | undefined;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Override the default base URL for the API, e.g., "https://api.example.com/v2/"
|
|
17
|
+
*
|
|
18
|
+
* Defaults to process.env['BROWSERBASE_BASE_URL'].
|
|
19
|
+
*/
|
|
20
|
+
baseURL?: string | null | undefined;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The maximum amount of time (in milliseconds) that the client should wait for a response
|
|
24
|
+
* from the server before timing out a single request.
|
|
25
|
+
*
|
|
26
|
+
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
27
|
+
* much longer than this timeout before the promise succeeds or fails.
|
|
28
|
+
*/
|
|
29
|
+
timeout?: number;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* An HTTP agent used to manage HTTP(S) connections.
|
|
33
|
+
*
|
|
34
|
+
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
35
|
+
* otherwise no agent is used.
|
|
36
|
+
*/
|
|
37
|
+
httpAgent?: Agent;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Specify a custom `fetch` function implementation.
|
|
41
|
+
*
|
|
42
|
+
* If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
|
|
43
|
+
* defined globally.
|
|
44
|
+
*/
|
|
45
|
+
fetch?: Core.Fetch | undefined;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The maximum number of times that the client will retry a request in case of a
|
|
49
|
+
* temporary failure, like a network error or a 5XX error from the server.
|
|
50
|
+
*
|
|
51
|
+
* @default 2
|
|
52
|
+
*/
|
|
53
|
+
maxRetries?: number;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Default headers to include with every request to the API.
|
|
57
|
+
*
|
|
58
|
+
* These can be removed in individual requests by explicitly setting the
|
|
59
|
+
* header to `undefined` or `null` in request options.
|
|
60
|
+
*/
|
|
61
|
+
defaultHeaders?: Core.Headers;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Default query parameters to include with every request to the API.
|
|
65
|
+
*
|
|
66
|
+
* These can be removed in individual requests by explicitly setting the
|
|
67
|
+
* param to `undefined` in request options.
|
|
68
|
+
*/
|
|
69
|
+
defaultQuery?: Core.DefaultQuery;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* API Client for interfacing with the Browserbase API.
|
|
74
|
+
*/
|
|
75
|
+
export class Browserbase extends Core.APIClient {
|
|
76
|
+
apiKey: string;
|
|
77
|
+
|
|
78
|
+
private _options: ClientOptions;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* API Client for interfacing with the Browserbase API.
|
|
82
|
+
*
|
|
83
|
+
* @param {string | undefined} [opts.apiKey=process.env['BROWSERBASE_API_KEY'] ?? undefined]
|
|
84
|
+
* @param {string} [opts.baseURL=process.env['BROWSERBASE_BASE_URL'] ?? https://api.browserbase.com] - Override the default base URL for the API.
|
|
85
|
+
* @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
|
|
86
|
+
* @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
|
|
87
|
+
* @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
|
|
88
|
+
* @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
|
|
89
|
+
* @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
|
|
90
|
+
* @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
|
|
91
|
+
*/
|
|
92
|
+
constructor({
|
|
93
|
+
baseURL = Core.readEnv('BROWSERBASE_BASE_URL'),
|
|
94
|
+
apiKey = Core.readEnv('BROWSERBASE_API_KEY'),
|
|
95
|
+
...opts
|
|
96
|
+
}: ClientOptions = {}) {
|
|
97
|
+
if (apiKey === undefined) {
|
|
98
|
+
throw new Errors.BrowserbaseError(
|
|
99
|
+
"The BROWSERBASE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Browserbase client with an apiKey option, like new Browserbase({ apiKey: 'My API Key' }).",
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
const options: ClientOptions = {
|
|
104
|
+
apiKey,
|
|
105
|
+
...opts,
|
|
106
|
+
baseURL: baseURL || `https://api.browserbase.com`,
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
super({
|
|
110
|
+
baseURL: options.baseURL!,
|
|
111
|
+
timeout: options.timeout ?? 60000 /* 1 minute */,
|
|
112
|
+
httpAgent: options.httpAgent,
|
|
113
|
+
maxRetries: options.maxRetries,
|
|
114
|
+
fetch: options.fetch,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
this._options = options;
|
|
118
|
+
|
|
119
|
+
this.apiKey = apiKey;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
contexts: API.Contexts = new API.Contexts(this);
|
|
123
|
+
extensions: API.Extensions = new API.Extensions(this);
|
|
124
|
+
projects: API.Projects = new API.Projects(this);
|
|
125
|
+
sessions: API.Sessions = new API.Sessions(this);
|
|
126
|
+
|
|
127
|
+
protected override defaultQuery(): Core.DefaultQuery | undefined {
|
|
128
|
+
return this._options.defaultQuery;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
132
|
+
return {
|
|
133
|
+
...super.defaultHeaders(opts),
|
|
134
|
+
...this._options.defaultHeaders,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
|
|
139
|
+
return { 'X-BB-API-Key': this.apiKey };
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
static Browserbase = this;
|
|
143
|
+
static DEFAULT_TIMEOUT = 60000; // 1 minute
|
|
144
|
+
|
|
145
|
+
static BrowserbaseError = Errors.BrowserbaseError;
|
|
146
|
+
static APIError = Errors.APIError;
|
|
147
|
+
static APIConnectionError = Errors.APIConnectionError;
|
|
148
|
+
static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
|
|
149
|
+
static APIUserAbortError = Errors.APIUserAbortError;
|
|
150
|
+
static NotFoundError = Errors.NotFoundError;
|
|
151
|
+
static ConflictError = Errors.ConflictError;
|
|
152
|
+
static RateLimitError = Errors.RateLimitError;
|
|
153
|
+
static BadRequestError = Errors.BadRequestError;
|
|
154
|
+
static AuthenticationError = Errors.AuthenticationError;
|
|
155
|
+
static InternalServerError = Errors.InternalServerError;
|
|
156
|
+
static PermissionDeniedError = Errors.PermissionDeniedError;
|
|
157
|
+
static UnprocessableEntityError = Errors.UnprocessableEntityError;
|
|
158
|
+
|
|
159
|
+
static toFile = Uploads.toFile;
|
|
160
|
+
static fileFromPath = Uploads.fileFromPath;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export const {
|
|
164
|
+
BrowserbaseError,
|
|
165
|
+
APIError,
|
|
166
|
+
APIConnectionError,
|
|
167
|
+
APIConnectionTimeoutError,
|
|
168
|
+
APIUserAbortError,
|
|
169
|
+
NotFoundError,
|
|
170
|
+
ConflictError,
|
|
171
|
+
RateLimitError,
|
|
172
|
+
BadRequestError,
|
|
173
|
+
AuthenticationError,
|
|
174
|
+
InternalServerError,
|
|
175
|
+
PermissionDeniedError,
|
|
176
|
+
UnprocessableEntityError,
|
|
177
|
+
} = Errors;
|
|
178
|
+
|
|
179
|
+
export import toFile = Uploads.toFile;
|
|
180
|
+
export import fileFromPath = Uploads.fileFromPath;
|
|
181
|
+
|
|
182
|
+
export namespace Browserbase {
|
|
183
|
+
export import RequestOptions = Core.RequestOptions;
|
|
184
|
+
|
|
185
|
+
export import Contexts = API.Contexts;
|
|
186
|
+
export import Context = API.Context;
|
|
187
|
+
export import ContextCreateResponse = API.ContextCreateResponse;
|
|
188
|
+
export import ContextUpdateResponse = API.ContextUpdateResponse;
|
|
189
|
+
export import ContextCreateParams = API.ContextCreateParams;
|
|
190
|
+
|
|
191
|
+
export import Extensions = API.Extensions;
|
|
192
|
+
export import Extension = API.Extension;
|
|
193
|
+
export import ExtensionCreateParams = API.ExtensionCreateParams;
|
|
194
|
+
|
|
195
|
+
export import Projects = API.Projects;
|
|
196
|
+
export import Project = API.Project;
|
|
197
|
+
export import ProjectUsage = API.ProjectUsage;
|
|
198
|
+
export import ProjectListResponse = API.ProjectListResponse;
|
|
199
|
+
|
|
200
|
+
export import Sessions = API.Sessions;
|
|
201
|
+
export import Session = API.Session;
|
|
202
|
+
export import SessionLiveURLs = API.SessionLiveURLs;
|
|
203
|
+
export import SessionCreateResponse = API.SessionCreateResponse;
|
|
204
|
+
export import SessionListResponse = API.SessionListResponse;
|
|
205
|
+
export import SessionCreateParams = API.SessionCreateParams;
|
|
206
|
+
export import SessionUpdateParams = API.SessionUpdateParams;
|
|
207
|
+
export import SessionListParams = API.SessionListParams;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
export default Browserbase;
|
package/src/lib/.keep
ADDED
package/src/resource.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import type { Browserbase } from './index';
|
|
4
|
+
|
|
5
|
+
export class APIResource {
|
|
6
|
+
protected _client: Browserbase;
|
|
7
|
+
|
|
8
|
+
constructor(client: Browserbase) {
|
|
9
|
+
this._client = client;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as ContextsAPI from './contexts';
|
|
6
|
+
|
|
7
|
+
export class Contexts extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Create a Context
|
|
10
|
+
*/
|
|
11
|
+
create(body: ContextCreateParams, options?: Core.RequestOptions): Core.APIPromise<ContextCreateResponse> {
|
|
12
|
+
return this._client.post('/v1/contexts', { body, ...options });
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Context
|
|
17
|
+
*/
|
|
18
|
+
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Context> {
|
|
19
|
+
return this._client.get(`/v1/contexts/${id}`, options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Update Context
|
|
24
|
+
*/
|
|
25
|
+
update(id: string, options?: Core.RequestOptions): Core.APIPromise<ContextUpdateResponse> {
|
|
26
|
+
return this._client.put(`/v1/contexts/${id}`, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Context {
|
|
31
|
+
id: string;
|
|
32
|
+
|
|
33
|
+
createdAt: string;
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The Project ID linked to the uploaded Context.
|
|
37
|
+
*/
|
|
38
|
+
projectId: string;
|
|
39
|
+
|
|
40
|
+
updatedAt: string;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface ContextCreateResponse {
|
|
44
|
+
id: string;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The cipher algorithm used to encrypt the user-data-directory. AES-256-CBC is
|
|
48
|
+
* currently the only supported algorithm.
|
|
49
|
+
*/
|
|
50
|
+
cipherAlgorithm: string;
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* The initialization vector size used to encrypt the user-data-directory.
|
|
54
|
+
* [Read more about how to use it](/features/contexts).
|
|
55
|
+
*/
|
|
56
|
+
initializationVectorSize: number;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The public key to encrypt the user-data-directory.
|
|
60
|
+
*/
|
|
61
|
+
publicKey: string;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* An upload URL to upload a custom user-data-directory.
|
|
65
|
+
*/
|
|
66
|
+
uploadUrl: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ContextUpdateResponse {
|
|
70
|
+
id: string;
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* The cipher algorithm used to encrypt the user-data-directory. AES-256-CBC is
|
|
74
|
+
* currently the only supported algorithm.
|
|
75
|
+
*/
|
|
76
|
+
cipherAlgorithm: string;
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* The initialization vector size used to encrypt the user-data-directory.
|
|
80
|
+
* [Read more about how to use it](/features/contexts).
|
|
81
|
+
*/
|
|
82
|
+
initializationVectorSize: number;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* The public key to encrypt the user-data-directory.
|
|
86
|
+
*/
|
|
87
|
+
publicKey: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* An upload URL to upload a custom user-data-directory.
|
|
91
|
+
*/
|
|
92
|
+
uploadUrl: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface ContextCreateParams {
|
|
96
|
+
/**
|
|
97
|
+
* The Project ID. Can be found in
|
|
98
|
+
* [Settings](https://www.browserbase.com/settings).
|
|
99
|
+
*/
|
|
100
|
+
projectId: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export namespace Contexts {
|
|
104
|
+
export import Context = ContextsAPI.Context;
|
|
105
|
+
export import ContextCreateResponse = ContextsAPI.ContextCreateResponse;
|
|
106
|
+
export import ContextUpdateResponse = ContextsAPI.ContextUpdateResponse;
|
|
107
|
+
export import ContextCreateParams = ContextsAPI.ContextCreateParams;
|
|
108
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as ExtensionsAPI from './extensions';
|
|
6
|
+
|
|
7
|
+
export class Extensions extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Upload an Extension
|
|
10
|
+
*/
|
|
11
|
+
create(body: ExtensionCreateParams, options?: Core.RequestOptions): Core.APIPromise<Extension> {
|
|
12
|
+
return this._client.post('/v1/extensions', Core.multipartFormRequestOptions({ body, ...options }));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Extension
|
|
17
|
+
*/
|
|
18
|
+
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Extension> {
|
|
19
|
+
return this._client.get(`/v1/extensions/${id}`, options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Delete Extension
|
|
24
|
+
*/
|
|
25
|
+
delete(id: string, options?: Core.RequestOptions): Core.APIPromise<void> {
|
|
26
|
+
return this._client.delete(`/v1/extensions/${id}`, {
|
|
27
|
+
...options,
|
|
28
|
+
headers: { Accept: '*/*', ...options?.headers },
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface Extension {
|
|
34
|
+
id: string;
|
|
35
|
+
|
|
36
|
+
createdAt: string;
|
|
37
|
+
|
|
38
|
+
fileName: string;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* The Project ID linked to the uploaded Extension.
|
|
42
|
+
*/
|
|
43
|
+
projectId: string;
|
|
44
|
+
|
|
45
|
+
updatedAt: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface ExtensionCreateParams {
|
|
49
|
+
file: Core.Uploadable;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export namespace Extensions {
|
|
53
|
+
export import Extension = ExtensionsAPI.Extension;
|
|
54
|
+
export import ExtensionCreateParams = ExtensionsAPI.ExtensionCreateParams;
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
Context,
|
|
5
|
+
ContextCreateResponse,
|
|
6
|
+
ContextUpdateResponse,
|
|
7
|
+
ContextCreateParams,
|
|
8
|
+
Contexts,
|
|
9
|
+
} from './contexts';
|
|
10
|
+
export { Extension, ExtensionCreateParams, Extensions } from './extensions';
|
|
11
|
+
export { Project, ProjectUsage, ProjectListResponse, Projects } from './projects';
|
|
12
|
+
export {
|
|
13
|
+
Session,
|
|
14
|
+
SessionLiveURLs,
|
|
15
|
+
SessionCreateResponse,
|
|
16
|
+
SessionListResponse,
|
|
17
|
+
SessionCreateParams,
|
|
18
|
+
SessionUpdateParams,
|
|
19
|
+
SessionListParams,
|
|
20
|
+
Sessions,
|
|
21
|
+
} from './sessions/sessions';
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../resource';
|
|
4
|
+
import * as Core from '../core';
|
|
5
|
+
import * as ProjectsAPI from './projects';
|
|
6
|
+
|
|
7
|
+
export class Projects extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Project
|
|
10
|
+
*/
|
|
11
|
+
retrieve(id: string, options?: Core.RequestOptions): Core.APIPromise<Project> {
|
|
12
|
+
return this._client.get(`/v1/projects/${id}`, options);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* List all projects
|
|
17
|
+
*/
|
|
18
|
+
list(options?: Core.RequestOptions): Core.APIPromise<ProjectListResponse> {
|
|
19
|
+
return this._client.get('/v1/projects', options);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Project Usage
|
|
24
|
+
*/
|
|
25
|
+
usage(id: string, options?: Core.RequestOptions): Core.APIPromise<ProjectUsage> {
|
|
26
|
+
return this._client.get(`/v1/projects/${id}/usage`, options);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Project {
|
|
31
|
+
id: string;
|
|
32
|
+
|
|
33
|
+
createdAt: string;
|
|
34
|
+
|
|
35
|
+
defaultTimeout: number;
|
|
36
|
+
|
|
37
|
+
name: string;
|
|
38
|
+
|
|
39
|
+
ownerId: string;
|
|
40
|
+
|
|
41
|
+
updatedAt: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ProjectUsage {
|
|
45
|
+
browserMinutes: number;
|
|
46
|
+
|
|
47
|
+
proxyBytes: number;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ProjectListResponse = Array<Project>;
|
|
51
|
+
|
|
52
|
+
export namespace Projects {
|
|
53
|
+
export import Project = ProjectsAPI.Project;
|
|
54
|
+
export import ProjectUsage = ProjectsAPI.ProjectUsage;
|
|
55
|
+
export import ProjectListResponse = ProjectsAPI.ProjectListResponse;
|
|
56
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
import { APIResource } from '../../resource';
|
|
4
|
+
import * as Core from '../../core';
|
|
5
|
+
import { type Response } from '../../_shims/index';
|
|
6
|
+
|
|
7
|
+
export class Downloads extends APIResource {
|
|
8
|
+
/**
|
|
9
|
+
* Session Downloads
|
|
10
|
+
*/
|
|
11
|
+
list(id: string, options?: Core.RequestOptions): Core.APIPromise<Response> {
|
|
12
|
+
return this._client.get(`/v1/sessions/${id}/downloads`, { ...options, __binaryResponse: true });
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
export { Downloads } from './downloads';
|
|
4
|
+
export {
|
|
5
|
+
Session,
|
|
6
|
+
SessionLiveURLs,
|
|
7
|
+
SessionCreateResponse,
|
|
8
|
+
SessionListResponse,
|
|
9
|
+
SessionCreateParams,
|
|
10
|
+
SessionUpdateParams,
|
|
11
|
+
SessionListParams,
|
|
12
|
+
Sessions,
|
|
13
|
+
} from './sessions';
|
|
14
|
+
export { SessionLog, LogListResponse, Logs } from './logs';
|
|
15
|
+
export { SessionRecording, RecordingRetrieveResponse, Recording } from './recording';
|
|
16
|
+
export { UploadCreateResponse, UploadCreateParams, Uploads } from './uploads';
|