diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..d8e2386 --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,32 @@ +# This workflow is triggered when a GitHub release is created. +# It can also be run manually to re-publish to NPM in case it failed for some reason. +# You can run this workflow by navigating to https://www.github.com/browserbase/sdk-node/actions/workflows/publish-npm.yml +name: Publish NPM +on: + workflow_dispatch: + + release: + types: [published] + +jobs: + publish: + name: publish + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up Node + uses: actions/setup-node@v3 + with: + node-version: '18' + + - name: Install dependencies + run: | + yarn install + + - name: Publish to NPM + run: | + bash ./bin/publish-npm + env: + NPM_TOKEN: ${{ secrets.BROWSERBASE_NPM_TOKEN || secrets.NPM_TOKEN }} diff --git a/.github/workflows/release-doctor.yml b/.github/workflows/release-doctor.yml new file mode 100644 index 0000000..ee48392 --- /dev/null +++ b/.github/workflows/release-doctor.yml @@ -0,0 +1,22 @@ +name: Release Doctor +on: + pull_request: + branches: + - main + workflow_dispatch: + +jobs: + release_doctor: + name: release doctor + runs-on: ubuntu-latest + if: github.repository == 'browserbase/sdk-node' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next') + + steps: + - uses: actions/checkout@v4 + + - name: Check release environment + run: | + bash ./bin/check-release-environment + env: + NPM_TOKEN: ${{ secrets.BROWSERBASE_NPM_TOKEN || secrets.NPM_TOKEN }} + diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..d7a8735 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "0.1.0-alpha.1" +} diff --git a/.stats.yml b/.stats.yml index e74d0ee..70bddde 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 18 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-099e8b99a50c73a107fe278d9d286dca1cc4b26769aa223ea1bcf9924ba38467.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-60444f8b1aa1aa8dbec1e9f11e929c2b7ac27470764ef5f1796134fc27f3381c.yml diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..eb71cba --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,24 @@ +# Changelog + +## 0.1.0-alpha.1 (2024-10-28) + +Full Changelog: [v0.0.1-alpha.0...v0.1.0-alpha.1](https://github.com/browserbase/sdk-node/compare/v0.0.1-alpha.0...v0.1.0-alpha.1) + +### Features + +* **api:** update via SDK Studio ([#10](https://github.com/browserbase/sdk-node/issues/10)) ([2c6c15d](https://github.com/browserbase/sdk-node/commit/2c6c15d148d1a5e74a48f92087580d8c590288af)) +* **api:** update via SDK Studio ([#11](https://github.com/browserbase/sdk-node/issues/11)) ([9191ed6](https://github.com/browserbase/sdk-node/commit/9191ed631256b52a39de1aafcf1d7deb2788efdb)) +* **api:** update via SDK Studio ([#12](https://github.com/browserbase/sdk-node/issues/12)) ([ebeaf82](https://github.com/browserbase/sdk-node/commit/ebeaf82736747398450d739e27d6874603c4f942)) +* **api:** update via SDK Studio ([#13](https://github.com/browserbase/sdk-node/issues/13)) ([c0ffdce](https://github.com/browserbase/sdk-node/commit/c0ffdce615059b9523817d22ef18e01e778f3454)) +* **api:** update via SDK Studio ([#3](https://github.com/browserbase/sdk-node/issues/3)) ([8a06f81](https://github.com/browserbase/sdk-node/commit/8a06f81c1cd5dc8a64b9fd10ed26f8547469fdeb)) +* **api:** update via SDK Studio ([#4](https://github.com/browserbase/sdk-node/issues/4)) ([cf6309b](https://github.com/browserbase/sdk-node/commit/cf6309bb5de1376139fb0ba6b8e45b5d0801bee5)) +* **api:** update via SDK Studio ([#5](https://github.com/browserbase/sdk-node/issues/5)) ([4275810](https://github.com/browserbase/sdk-node/commit/427581035437844d44333c0e3471db675dff89c7)) +* **api:** update via SDK Studio ([#6](https://github.com/browserbase/sdk-node/issues/6)) ([299d77e](https://github.com/browserbase/sdk-node/commit/299d77ebc0994b0ab39a9c908157d42d605e9765)) +* **api:** update via SDK Studio ([#7](https://github.com/browserbase/sdk-node/issues/7)) ([e1e4738](https://github.com/browserbase/sdk-node/commit/e1e47381dc142f94bd61e7f5819eafbf5b4797a7)) +* **api:** update via SDK Studio ([#8](https://github.com/browserbase/sdk-node/issues/8)) ([2d845ff](https://github.com/browserbase/sdk-node/commit/2d845ffc683ea988980e42ea2c03699034af6980)) +* **api:** update via SDK Studio ([#9](https://github.com/browserbase/sdk-node/issues/9)) ([a17fadc](https://github.com/browserbase/sdk-node/commit/a17fadcac323079f3e36e0c965f6d6c1be26f1d8)) + + +### Chores + +* go live ([#1](https://github.com/browserbase/sdk-node/issues/1)) ([bc9e36e](https://github.com/browserbase/sdk-node/commit/bc9e36ec17be8df65bc4bd43bad6ad6617e4973c)) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 9ab3ba6..0536551 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -42,15 +42,15 @@ If you’d like to use the repository from source, you can either install from g To install via git: ```sh -$ npm install git+ssh://git@github.com:stainless-sdks/browserbase-node.git +$ npm install git+ssh://git@github.com:browserbase/sdk-node.git ``` Alternatively, to link a local copy of the repo: ```sh # Clone -$ git clone https://www.github.com/stainless-sdks/browserbase-node -$ cd browserbase-node +$ git clone https://www.github.com/browserbase/sdk-node +$ cd sdk-node # With yarn $ yarn link @@ -99,7 +99,7 @@ the changes aren't made through the automated pipeline, you may want to make rel ### Publish with a GitHub workflow -You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/stainless-sdks/browserbase-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. +You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/browserbase/sdk-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up. ### Publish manually diff --git a/README.md b/README.md index 599e1ae..0380e8f 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ It is generated with [Stainless](https://www.stainlessapi.com/). ## Installation ```sh -npm install git+ssh://git@github.com:stainless-sdks/browserbase-node.git +npm install git+ssh://git@github.com:browserbase/sdk-node.git ``` > [!NOTE] @@ -221,7 +221,7 @@ import Browserbase from 'browserbase'; ``` To do the inverse, add `import "browserbase/shims/node"` (which does import polyfills). -This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/browserbase-node/tree/main/src/_shims#readme)). +This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/browserbase/sdk-node/tree/main/src/_shims#readme)). ### Logging and middleware @@ -280,7 +280,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. -We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/browserbase-node/issues) with questions, bugs, or suggestions. +We are keen for your feedback; please open an [issue](https://www.github.com/browserbase/sdk-node/issues) with questions, bugs, or suggestions. ## Requirements diff --git a/api.md b/api.md index 3c44ad6..efcf2db 100644 --- a/api.md +++ b/api.md @@ -44,11 +44,12 @@ Types: - Session - SessionLiveURLs +- SessionCreateResponse - SessionListResponse Methods: -- client.sessions.create({ ...params }) -> Session +- client.sessions.create({ ...params }) -> SessionCreateResponse - client.sessions.retrieve(id) -> Session - client.sessions.update(id, { ...params }) -> Session - client.sessions.list({ ...params }) -> SessionListResponse diff --git a/bin/check-release-environment b/bin/check-release-environment new file mode 100644 index 0000000..3098216 --- /dev/null +++ b/bin/check-release-environment @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +errors=() + +if [ -z "${NPM_TOKEN}" ]; then + errors+=("The BROWSERBASE_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets") +fi + +lenErrors=${#errors[@]} + +if [[ lenErrors -gt 0 ]]; then + echo -e "Found the following errors in the release environment:\n" + + for error in "${errors[@]}"; do + echo -e "- $error\n" + done + + exit 1 +fi + +echo "The environment is ready to push releases!" + diff --git a/package.json b/package.json index 959dd65..8f223e2 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,12 @@ { "name": "browserbase", - "version": "0.0.1-alpha.0", + "version": "0.1.0-alpha.1", "description": "The official TypeScript library for the Browserbase API", "author": "Browserbase ", "types": "dist/index.d.ts", "main": "dist/index.js", "type": "commonjs", - "repository": "github:stainless-sdks/browserbase-node", + "repository": "github:browserbase/sdk-node", "license": "Apache-2.0", "packageManager": "yarn@1.22.22", "files": [ diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..624ed99 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,67 @@ +{ + "packages": { + ".": {} + }, + "$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json", + "include-v-in-tag": true, + "include-component-in-tag": false, + "versioning": "prerelease", + "prerelease": true, + "bump-minor-pre-major": true, + "bump-patch-for-minor-pre-major": false, + "pull-request-header": "Automated Release PR", + "pull-request-title-pattern": "release: ${version}", + "changelog-sections": [ + { + "type": "feat", + "section": "Features" + }, + { + "type": "fix", + "section": "Bug Fixes" + }, + { + "type": "perf", + "section": "Performance Improvements" + }, + { + "type": "revert", + "section": "Reverts" + }, + { + "type": "chore", + "section": "Chores" + }, + { + "type": "docs", + "section": "Documentation" + }, + { + "type": "style", + "section": "Styles" + }, + { + "type": "refactor", + "section": "Refactors" + }, + { + "type": "test", + "section": "Tests", + "hidden": true + }, + { + "type": "build", + "section": "Build System" + }, + { + "type": "ci", + "section": "Continuous Integration", + "hidden": true + } + ], + "release-type": "node", + "extra-files": [ + "src/version.ts", + "README.md" + ] +} diff --git a/src/_shims/index-deno.ts b/src/_shims/index-deno.ts index b76c7b7..a13f39e 100644 --- a/src/_shims/index-deno.ts +++ b/src/_shims/index-deno.ts @@ -79,7 +79,7 @@ export function getDefaultAgent(url: string) { } export function fileFromPath() { throw new Error( - 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/browserbase-node#file-uploads', + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/browserbase/sdk-node#file-uploads', ); } diff --git a/src/_shims/web-runtime.ts b/src/_shims/web-runtime.ts index 93c32d4..ced67c2 100644 --- a/src/_shims/web-runtime.ts +++ b/src/_shims/web-runtime.ts @@ -95,7 +95,7 @@ export function getRuntime({ manuallyImported }: { manuallyImported?: boolean } getDefaultAgent: (url: string) => undefined, fileFromPath: () => { throw new Error( - 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/stainless-sdks/browserbase-node#file-uploads', + 'The `fileFromPath` function is only supported in Node. See the README for more details: https://www.github.com/browserbase/sdk-node#file-uploads', ); }, isFsReadStream: (value: any) => false, diff --git a/src/index.ts b/src/index.ts index 12640c8..03c44c2 100644 --- a/src/index.ts +++ b/src/index.ts @@ -81,7 +81,7 @@ export class Browserbase extends Core.APIClient { * API Client for interfacing with the Browserbase API. * * @param {string | undefined} [opts.apiKey=process.env['BROWSERBASE_API_KEY'] ?? undefined] - * @param {string} [opts.baseURL=process.env['BROWSERBASE_BASE_URL'] ?? https://www.browserbase.com] - Override the default base URL for the API. + * @param {string} [opts.baseURL=process.env['BROWSERBASE_BASE_URL'] ?? https://api.dev.browserbase.com] - Override the default base URL for the API. * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out. * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections. * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation. @@ -103,7 +103,7 @@ export class Browserbase extends Core.APIClient { const options: ClientOptions = { apiKey, ...opts, - baseURL: baseURL || `https://www.browserbase.com`, + baseURL: baseURL || `https://api.dev.browserbase.com`, }; super({ @@ -200,6 +200,7 @@ export namespace Browserbase { export import Sessions = API.Sessions; export import Session = API.Session; export import SessionLiveURLs = API.SessionLiveURLs; + export import SessionCreateResponse = API.SessionCreateResponse; export import SessionListResponse = API.SessionListResponse; export import SessionCreateParams = API.SessionCreateParams; export import SessionUpdateParams = API.SessionUpdateParams; diff --git a/src/resources/contexts.ts b/src/resources/contexts.ts index cf56a99..b747d8d 100644 --- a/src/resources/contexts.ts +++ b/src/resources/contexts.ts @@ -32,6 +32,11 @@ export interface Context { createdAt: string; + /** + * The Project ID linked to the uploaded Context. + */ + projectId: string; + updatedAt: string; } diff --git a/src/resources/extensions.ts b/src/resources/extensions.ts index 19230ff..ec30bbf 100644 --- a/src/resources/extensions.ts +++ b/src/resources/extensions.ts @@ -35,6 +35,13 @@ export interface Extension { createdAt: string; + fileName: string; + + /** + * The Project ID linked to the uploaded Extension. + */ + projectId: string; + updatedAt: string; } diff --git a/src/resources/index.ts b/src/resources/index.ts index 7354ce4..538ff2e 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -12,6 +12,7 @@ export { Project, ProjectUsage, ProjectListResponse, Projects } from './projects export { Session, SessionLiveURLs, + SessionCreateResponse, SessionListResponse, SessionCreateParams, SessionUpdateParams, diff --git a/src/resources/projects.ts b/src/resources/projects.ts index c699879..08eac8b 100644 --- a/src/resources/projects.ts +++ b/src/resources/projects.ts @@ -32,6 +32,12 @@ export interface Project { createdAt: string; + defaultTimeout: number; + + name: string; + + ownerId: string; + updatedAt: string; } diff --git a/src/resources/sessions/index.ts b/src/resources/sessions/index.ts index 8b57297..bca6cc8 100644 --- a/src/resources/sessions/index.ts +++ b/src/resources/sessions/index.ts @@ -4,6 +4,7 @@ export { Downloads } from './downloads'; export { Session, SessionLiveURLs, + SessionCreateResponse, SessionListResponse, SessionCreateParams, SessionUpdateParams, diff --git a/src/resources/sessions/sessions.ts b/src/resources/sessions/sessions.ts index 7665f34..517092b 100644 --- a/src/resources/sessions/sessions.ts +++ b/src/resources/sessions/sessions.ts @@ -18,7 +18,7 @@ export class Sessions extends APIResource { /** * Create a Session */ - create(body: SessionCreateParams, options?: Core.RequestOptions): Core.APIPromise { + create(body: SessionCreateParams, options?: Core.RequestOptions): Core.APIPromise { return this._client.post('/v1/sessions', { body, ...options }); } @@ -64,7 +64,50 @@ export interface Session { createdAt: string; + expiresAt: string; + + /** + * Indicates if the Session was created to be kept alive upon disconnections + */ + keepAlive: boolean; + + /** + * The Project ID linked to the Session. + */ + projectId: string; + + /** + * Bytes used via the [Proxy](/features/stealth-mode#proxies-and-residential-ips) + */ + proxyBytes: number; + + /** + * The region where the Session is running. + */ + region: 'us-west-2' | 'us-east-1' | 'eu-central-1' | 'ap-southeast-1'; + + startedAt: string; + + status: 'RUNNING' | 'ERROR' | 'TIMED_OUT' | 'COMPLETED'; + updatedAt: string; + + /** + * CPU used by the Session + */ + avgCpuUsage?: number; + + /** + * Optional. The Context linked to the Session. + */ + contextId?: string; + + endedAt?: string; + + /** + * Memory used by the Session + */ + memoryUsage?: number; } export interface SessionLiveURLs { @@ -93,6 +136,72 @@ export namespace SessionLiveURLs { } } +export interface SessionCreateResponse { + id: string; + + /** + * WebSocket URL to connect to the Session. + */ + connectUrl: string; + + createdAt: string; + + expiresAt: string; + + /** + * Indicates if the Session was created to be kept alive upon disconnections + */ + keepAlive: boolean; + + /** + * The Project ID linked to the Session. + */ + projectId: string; + + /** + * Bytes used via the [Proxy](/features/stealth-mode#proxies-and-residential-ips) + */ + proxyBytes: number; + + /** + * The region where the Session is running. + */ + region: 'us-west-2' | 'us-east-1' | 'eu-central-1' | 'ap-southeast-1'; + + /** + * HTTP URL to connect to the Session. + */ + seleniumRemoteUrl: string; + + /** + * Signing key to use when connecting to the Session via HTTP. + */ + signingKey: string; + + startedAt: string; + + status: 'RUNNING' | 'ERROR' | 'TIMED_OUT' | 'COMPLETED'; + + updatedAt: string; + + /** + * CPU used by the Session + */ + avgCpuUsage?: number; + + /** + * Optional. The Context linked to the Session. + */ + contextId?: string; + + endedAt?: string; + + /** + * Memory used by the Session + */ + memoryUsage?: number; +} + export type SessionListResponse = Array; export interface SessionCreateParams { @@ -120,9 +229,12 @@ export interface SessionCreateParams { * Proxy configuration. Can be true for default proxy, or an array of proxy * configurations. */ - proxies?: - | boolean - | Array; + proxies?: unknown; + + /** + * The region where the Session should run. + */ + region?: 'us-west-2' | 'us-east-1' | 'eu-central-1' | 'ap-southeast-1'; /** * Duration in seconds after which the session will automatically end. Defaults to @@ -180,7 +292,7 @@ export namespace SessionCreateParams { /** * Whether or not to persist the context after browsing. Defaults to `false`. */ - persist: boolean; + persist?: boolean; } /** @@ -227,75 +339,6 @@ export namespace SessionCreateParams { width?: number; } } - - export interface BrowserbaseProxyConfig { - /** - * Type of proxy. Always use 'browserbase' for the Browserbase managed proxy - * network. - */ - type: 'browserbase'; - - /** - * Domain pattern for which this proxy should be used. If omitted, defaults to all - * domains. Optional. - */ - domainPattern?: string; - - /** - * Configuration for geolocation - */ - geolocation?: BrowserbaseProxyConfig.Geolocation; - } - - export namespace BrowserbaseProxyConfig { - /** - * Configuration for geolocation - */ - export interface Geolocation { - /** - * Country code in ISO 3166-1 alpha-2 format - */ - country: string; - - /** - * Name of the city. Use spaces for multi-word city names. Optional. - */ - city?: string; - - /** - * US state code (2 characters). Must also specify US as the country. Optional. - */ - state?: string; - } - } - - export interface ExternalProxyConfig { - /** - * Server URL for external proxy. Required. - */ - server: string; - - /** - * Type of proxy. Always 'external' for this config. - */ - type: 'external'; - - /** - * Domain pattern for which this proxy should be used. If omitted, defaults to all - * domains. Optional. - */ - domainPattern?: string; - - /** - * Password for external proxy authentication. Optional. - */ - password?: string; - - /** - * Username for external proxy authentication. Optional. - */ - username?: string; - } } export interface SessionUpdateParams { @@ -319,6 +362,7 @@ export interface SessionListParams { export namespace Sessions { export import Session = SessionsAPI.Session; export import SessionLiveURLs = SessionsAPI.SessionLiveURLs; + export import SessionCreateResponse = SessionsAPI.SessionCreateResponse; export import SessionListResponse = SessionsAPI.SessionListResponse; export import SessionCreateParams = SessionsAPI.SessionCreateParams; export import SessionUpdateParams = SessionsAPI.SessionUpdateParams; diff --git a/src/version.ts b/src/version.ts index 55a1a52..b0bfd9e 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.0.1-alpha.0'; +export const VERSION = '0.1.0-alpha.1'; // x-release-please-version diff --git a/tests/api-resources/sessions/sessions.test.ts b/tests/api-resources/sessions/sessions.test.ts index 1dea419..ca73798 100644 --- a/tests/api-resources/sessions/sessions.test.ts +++ b/tests/api-resources/sessions/sessions.test.ts @@ -42,7 +42,8 @@ describe('resource sessions', () => { }, extensionId: 'extensionId', keepAlive: true, - proxies: true, + proxies: {}, + region: 'us-west-2', timeout: 60, }); }); diff --git a/tests/index.test.ts b/tests/index.test.ts index 5c0cfb8..5507454 100644 --- a/tests/index.test.ts +++ b/tests/index.test.ts @@ -151,13 +151,13 @@ describe('instantiate client', () => { test('empty env variable', () => { process.env['BROWSERBASE_BASE_URL'] = ''; // empty const client = new Browserbase({ apiKey: 'My API Key' }); - expect(client.baseURL).toEqual('https://www.browserbase.com'); + expect(client.baseURL).toEqual('https://api.dev.browserbase.com'); }); test('blank env variable', () => { process.env['BROWSERBASE_BASE_URL'] = ' '; // blank const client = new Browserbase({ apiKey: 'My API Key' }); - expect(client.baseURL).toEqual('https://www.browserbase.com'); + expect(client.baseURL).toEqual('https://api.dev.browserbase.com'); }); });