diff --git a/.gitignore b/.gitignore index 0512d60..03f2361 100644 --- a/.gitignore +++ b/.gitignore @@ -4,7 +4,7 @@ yarn-error.log codegen.log Brewfile.lock.json dist -/deno +dist-deno /*.tgz .idea/ diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 895bf0e..b725ab0 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.0.0" + ".": "2.0.1" } diff --git a/.stats.yml b/.stats.yml index 1a6b2b5..d42b050 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-b341dd9d5bb77c4f217b94b186763e730fd798fbb773a5e90bb4e2a8d4a2c822.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/browserbase%2Fbrowserbase-7f88912695bab2b98cb73137e6f36125d02fdfaf8eed4532ee1c82385609a259.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index bc3f2b9..98aa8b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 2.0.1 (2024-11-19) + +Full Changelog: [v2.0.0...v2.0.1](https://github.com/browserbase/sdk-node/compare/v2.0.0...v2.0.1) + +### Features + +* **api:** api update ([#40](https://github.com/browserbase/sdk-node/issues/40)) ([97dddaa](https://github.com/browserbase/sdk-node/commit/97dddaa2729f64c4d1dbf20bebf7c243e3fb723b)) +* **api:** api update ([#42](https://github.com/browserbase/sdk-node/issues/42)) ([2ad71d8](https://github.com/browserbase/sdk-node/commit/2ad71d8e96157370ec64619568d185805dcc97a2)) +* various codegen changes ([7615211](https://github.com/browserbase/sdk-node/commit/7615211d48d953fe0833d35a3986f24673659840)) + + +### Bug Fixes + +* update example ([#38](https://github.com/browserbase/sdk-node/issues/38)) ([242167d](https://github.com/browserbase/sdk-node/commit/242167d2a82a6239fda100ad014436c9ee77a1de)) + + +### Chores + +* rebuild project due to codegen change ([#44](https://github.com/browserbase/sdk-node/issues/44)) ([804a9ec](https://github.com/browserbase/sdk-node/commit/804a9ec93ae35b48c6c7d89948a4146abf5ab8cc)) +* rebuild project due to codegen change ([#45](https://github.com/browserbase/sdk-node/issues/45)) ([889bd8d](https://github.com/browserbase/sdk-node/commit/889bd8d94a245a1f9e26dc6877b045fc5bcbae0a)) +* rebuild project due to codegen change ([#47](https://github.com/browserbase/sdk-node/issues/47)) ([4d08a25](https://github.com/browserbase/sdk-node/commit/4d08a25596cf991be1576d10fa9801cb057b157b)) +* rebuild project due to codegen change ([#48](https://github.com/browserbase/sdk-node/issues/48)) ([189b64f](https://github.com/browserbase/sdk-node/commit/189b64fca8fe9ee76ff0b888108cd276f0387ad3)) + ## 2.0.0 (2024-10-29) 🆕 fully-featured SDK for Browserbase's API diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 915e6f8..0000000 --- a/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright 2024 Browserbase - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/README.md b/README.md index 76f9908..df37743 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ const client = new Browserbase({ }); async function main() { - const session = await client.sessions.create({ projectId: 'your_project_id', proxies: true }); + const session = await client.sessions.create({ projectId: 'your_project_id' }); console.log(session.id); } @@ -48,7 +48,7 @@ const client = new Browserbase({ }); async function main() { - const params: Browserbase.SessionCreateParams = { projectId: 'your_project_id', proxies: true }; + const params: Browserbase.SessionCreateParams = { projectId: 'your_project_id' }; const session: Browserbase.SessionCreateResponse = await client.sessions.create(params); } @@ -66,17 +66,15 @@ a subclass of `APIError` will be thrown: ```ts async function main() { - const session = await client.sessions - .create({ projectId: 'your_project_id', proxies: true }) - .catch(async (err) => { - if (err instanceof Browserbase.APIError) { - console.log(err.status); // 400 - console.log(err.name); // BadRequestError - console.log(err.headers); // {server: 'nginx', ...} - } else { - throw err; - } - }); + const session = await client.sessions.create({ projectId: 'your_project_id' }).catch(async (err) => { + if (err instanceof Browserbase.APIError) { + console.log(err.status); // 400 + console.log(err.name); // BadRequestError + console.log(err.headers); // {server: 'nginx', ...} + } else { + throw err; + } + }); } main(); @@ -111,7 +109,7 @@ const client = new Browserbase({ }); // Or, configure per-request: -await client.sessions.create({ projectId: 'your_project_id', proxies: true }, { +await client.sessions.create({ projectId: 'your_project_id' }, { maxRetries: 5, }); ``` @@ -128,7 +126,7 @@ const client = new Browserbase({ }); // Override per-request: -await client.sessions.create({ projectId: 'your_project_id', proxies: true }, { +await client.sessions.create({ projectId: 'your_project_id' }, { timeout: 5 * 1000, }); ``` @@ -149,12 +147,12 @@ You can also use the `.withResponse()` method to get the raw `Response` along wi ```ts const client = new Browserbase(); -const response = await client.sessions.create({ projectId: 'your_project_id', proxies: true }).asResponse(); +const response = await client.sessions.create({ projectId: 'your_project_id' }).asResponse(); console.log(response.headers.get('X-My-Header')); console.log(response.statusText); // access the underlying Response object const { data: session, response: raw } = await client.sessions - .create({ projectId: 'your_project_id', proxies: true }) + .create({ projectId: 'your_project_id' }) .withResponse(); console.log(raw.headers.get('X-My-Header')); console.log(session.id); @@ -262,7 +260,7 @@ const client = new Browserbase({ // Override per-request: await client.sessions.create( - { projectId: 'your_project_id', proxies: true }, + { projectId: 'your_project_id' }, { httpAgent: new http.Agent({ keepAlive: false }), }, @@ -287,6 +285,15 @@ TypeScript >= 4.5 is supported. The following runtimes are supported: +- Web browsers (Up-to-date Chrome, Firefox, Safari, Edge, and more) +- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions. +- Deno v1.28.0 or higher, using `import Browserbase from "npm:@browserbasehq/sdk"`. +- Bun 1.0 or later. +- Cloudflare Workers. +- Vercel Edge Runtime. +- Jest 28 or greater with the `"node"` environment (`"jsdom"` is not supported at this time). +- Nitro v2.6 or greater. + Note that React Native is not supported at this time. If you are interested in other runtime environments, please open or upvote an issue on GitHub. diff --git a/examples/playwright-basic.ts b/examples/playwright-basic.ts index e7d3afa..9818190 100644 --- a/examples/playwright-basic.ts +++ b/examples/playwright-basic.ts @@ -18,7 +18,7 @@ const bb = new Browserbase({ const browser = await chromium.connectOverCDP(session.connectUrl); // Getting the default context to ensure the sessions are recorded. - const defaultContext = browser.contexts()[0]; + const [defaultContext] = browser.contexts(); const page = defaultContext?.pages()[0]; await page?.goto('https://browserbase.com/'); diff --git a/package-lock.json b/package-lock.json index 8e43ee4..c36eefb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@browserbasehq/sdk", - "version": "2.0.0", + "version": "2.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@browserbasehq/sdk", - "version": "2.0.0", + "version": "2.0.1", "dependencies": { "@types/node": "^18.11.18", "@types/node-fetch": "^2.6.4", diff --git a/package.json b/package.json index 0c28f4b..2f144bd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@browserbasehq/sdk", - "version": "2.0.0", + "version": "2.0.1", "description": "The official Node.js library for the Browserbase API", "author": "Browserbase ", "types": "dist/index.d.ts", @@ -50,7 +50,6 @@ "puppeteer-core": "^19.7.2", "selenium-webdriver": "^4.2.0", "ts-jest": "^29.1.0", - "ts-morph": "^19.0.0", "ts-node": "^10.5.0", "tsc-multi": "^1.1.0", "tsconfig-paths": "^4.0.0", diff --git a/scripts/build b/scripts/build index 4aa2b50..5bc3f52 100755 --- a/scripts/build +++ b/scripts/build @@ -50,7 +50,7 @@ node scripts/utils/postprocess-files.cjs (cd dist && node -e 'require("@browserbasehq/sdk")') (cd dist && node -e 'import("@browserbasehq/sdk")' --input-type=module) -if command -v deno &> /dev/null && [ -e ./scripts/build-deno ] +if [ -e ./scripts/build-deno ] then ./scripts/build-deno fi diff --git a/src/core.ts b/src/core.ts index f89cda2..381c45e 100644 --- a/src/core.ts +++ b/src/core.ts @@ -396,7 +396,7 @@ export abstract class APIClient { error: Object | undefined, message: string | undefined, headers: Headers | undefined, - ) { + ): APIError { return APIError.generate(status, error, message, headers); } @@ -668,9 +668,9 @@ export abstract class AbstractPage implements AsyncIterable { return await this.#client.requestAPIList(this.constructor as any, nextOptions); } - async *iterPages() { + async *iterPages(): AsyncGenerator { // eslint-disable-next-line @typescript-eslint/no-this-alias - let page: AbstractPage = this; + let page: this = this; yield page; while (page.hasNextPage()) { page = await page.getNextPage(); @@ -678,7 +678,7 @@ export abstract class AbstractPage implements AsyncIterable { } } - async *[Symbol.asyncIterator]() { + async *[Symbol.asyncIterator](): AsyncGenerator { for await (const page of this.iterPages()) { for (const item of page.getPaginatedItems()) { yield item; @@ -721,7 +721,7 @@ export class PagePromise< * console.log(item) * } */ - async *[Symbol.asyncIterator]() { + async *[Symbol.asyncIterator](): AsyncGenerator { const page = await this; for await (const item of page) { yield item; diff --git a/src/error.ts b/src/error.ts index 0276e9f..7dbedbd 100644 --- a/src/error.ts +++ b/src/error.ts @@ -47,7 +47,7 @@ export class APIError extends BrowserbaseError { errorResponse: Object | undefined, message: string | undefined, headers: Headers | undefined, - ) { + ): APIError { if (!status) { return new APIConnectionError({ message, cause: castToError(errorResponse) }); } diff --git a/src/index.ts b/src/index.ts index 3d2e3a6..73042a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,29 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -import * as Errors from './error'; -import * as Uploads from './uploads'; import { type Agent } from './_shims/index'; import * as Core from './core'; +import * as Errors from './error'; +import * as Uploads from './uploads'; import * as API from './resources/index'; +import { + Context, + ContextCreateParams, + ContextCreateResponse, + ContextUpdateResponse, + Contexts, +} from './resources/contexts'; +import { Extension, ExtensionCreateParams, Extensions } from './resources/extensions'; +import { Project, ProjectListResponse, ProjectUsage, Projects } from './resources/projects'; +import { + Session, + SessionCreateParams, + SessionCreateResponse, + SessionListParams, + SessionListResponse, + SessionLiveURLs, + SessionUpdateParams, + Sessions, +} from './resources/sessions/sessions'; export interface ClientOptions { /** @@ -160,7 +179,48 @@ export class Browserbase extends Core.APIClient { static fileFromPath = Uploads.fileFromPath; } -export const { +Browserbase.Contexts = Contexts; +Browserbase.Extensions = Extensions; +Browserbase.Projects = Projects; +Browserbase.Sessions = Sessions; +export declare namespace Browserbase { + export type RequestOptions = Core.RequestOptions; + + export { + Contexts as Contexts, + type Context as Context, + type ContextCreateResponse as ContextCreateResponse, + type ContextUpdateResponse as ContextUpdateResponse, + type ContextCreateParams as ContextCreateParams, + }; + + export { + Extensions as Extensions, + type Extension as Extension, + type ExtensionCreateParams as ExtensionCreateParams, + }; + + export { + Projects as Projects, + type Project as Project, + type ProjectUsage as ProjectUsage, + type ProjectListResponse as ProjectListResponse, + }; + + export { + Sessions as Sessions, + type Session as Session, + type SessionLiveURLs as SessionLiveURLs, + type SessionCreateResponse as SessionCreateResponse, + type SessionListResponse as SessionListResponse, + type SessionCreateParams as SessionCreateParams, + type SessionUpdateParams as SessionUpdateParams, + type SessionListParams as SessionListParams, + }; +} + +export { toFile, fileFromPath } from './uploads'; +export { BrowserbaseError, APIError, APIConnectionError, @@ -174,37 +234,6 @@ export const { InternalServerError, PermissionDeniedError, UnprocessableEntityError, -} = Errors; - -export import toFile = Uploads.toFile; -export import fileFromPath = Uploads.fileFromPath; - -export namespace Browserbase { - export import RequestOptions = Core.RequestOptions; - - export import Contexts = API.Contexts; - export import Context = API.Context; - export import ContextCreateResponse = API.ContextCreateResponse; - export import ContextUpdateResponse = API.ContextUpdateResponse; - export import ContextCreateParams = API.ContextCreateParams; - - export import Extensions = API.Extensions; - export import Extension = API.Extension; - export import ExtensionCreateParams = API.ExtensionCreateParams; - - export import Projects = API.Projects; - export import Project = API.Project; - export import ProjectUsage = API.ProjectUsage; - export import ProjectListResponse = API.ProjectListResponse; - - 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; - export import SessionListParams = API.SessionListParams; -} +} from './error'; export default Browserbase; diff --git a/src/resources/contexts.ts b/src/resources/contexts.ts index b747d8d..884cdab 100644 --- a/src/resources/contexts.ts +++ b/src/resources/contexts.ts @@ -2,7 +2,6 @@ import { APIResource } from '../resource'; import * as Core from '../core'; -import * as ContextsAPI from './contexts'; export class Contexts extends APIResource { /** @@ -100,9 +99,11 @@ export interface ContextCreateParams { projectId: string; } -export namespace Contexts { - export import Context = ContextsAPI.Context; - export import ContextCreateResponse = ContextsAPI.ContextCreateResponse; - export import ContextUpdateResponse = ContextsAPI.ContextUpdateResponse; - export import ContextCreateParams = ContextsAPI.ContextCreateParams; +export declare namespace Contexts { + export { + type Context as Context, + type ContextCreateResponse as ContextCreateResponse, + type ContextUpdateResponse as ContextUpdateResponse, + type ContextCreateParams as ContextCreateParams, + }; } diff --git a/src/resources/extensions.ts b/src/resources/extensions.ts index ec30bbf..857349f 100644 --- a/src/resources/extensions.ts +++ b/src/resources/extensions.ts @@ -2,7 +2,6 @@ import { APIResource } from '../resource'; import * as Core from '../core'; -import * as ExtensionsAPI from './extensions'; export class Extensions extends APIResource { /** @@ -49,7 +48,6 @@ export interface ExtensionCreateParams { file: Core.Uploadable; } -export namespace Extensions { - export import Extension = ExtensionsAPI.Extension; - export import ExtensionCreateParams = ExtensionsAPI.ExtensionCreateParams; +export declare namespace Extensions { + export { type Extension as Extension, type ExtensionCreateParams as ExtensionCreateParams }; } diff --git a/src/resources/index.ts b/src/resources/index.ts index 538ff2e..e74c370 100644 --- a/src/resources/index.ts +++ b/src/resources/index.ts @@ -1,21 +1,21 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { - Context, - ContextCreateResponse, - ContextUpdateResponse, - ContextCreateParams, Contexts, + type Context, + type ContextCreateResponse, + type ContextUpdateResponse, + type ContextCreateParams, } from './contexts'; -export { Extension, ExtensionCreateParams, Extensions } from './extensions'; -export { Project, ProjectUsage, ProjectListResponse, Projects } from './projects'; +export { Extensions, type Extension, type ExtensionCreateParams } from './extensions'; +export { Projects, type Project, type ProjectUsage, type ProjectListResponse } from './projects'; export { - Session, - SessionLiveURLs, - SessionCreateResponse, - SessionListResponse, - SessionCreateParams, - SessionUpdateParams, - SessionListParams, Sessions, + type Session, + type SessionLiveURLs, + type SessionCreateResponse, + type SessionListResponse, + type SessionCreateParams, + type SessionUpdateParams, + type SessionListParams, } from './sessions/sessions'; diff --git a/src/resources/projects.ts b/src/resources/projects.ts index 08eac8b..0bc82f6 100644 --- a/src/resources/projects.ts +++ b/src/resources/projects.ts @@ -2,7 +2,6 @@ import { APIResource } from '../resource'; import * as Core from '../core'; -import * as ProjectsAPI from './projects'; export class Projects extends APIResource { /** @@ -13,7 +12,7 @@ export class Projects extends APIResource { } /** - * List all projects + * List projects */ list(options?: Core.RequestOptions): Core.APIPromise { return this._client.get('/v1/projects', options); @@ -49,8 +48,10 @@ export interface ProjectUsage { export type ProjectListResponse = Array; -export namespace Projects { - export import Project = ProjectsAPI.Project; - export import ProjectUsage = ProjectsAPI.ProjectUsage; - export import ProjectListResponse = ProjectsAPI.ProjectListResponse; +export declare namespace Projects { + export { + type Project as Project, + type ProjectUsage as ProjectUsage, + type ProjectListResponse as ProjectListResponse, + }; } diff --git a/src/resources/sessions/index.ts b/src/resources/sessions/index.ts index bca6cc8..727df9c 100644 --- a/src/resources/sessions/index.ts +++ b/src/resources/sessions/index.ts @@ -1,16 +1,16 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { Downloads } from './downloads'; +export { Logs, type SessionLog, type LogListResponse } from './logs'; +export { Recording, type SessionRecording, type RecordingRetrieveResponse } from './recording'; export { - Session, - SessionLiveURLs, - SessionCreateResponse, - SessionListResponse, - SessionCreateParams, - SessionUpdateParams, - SessionListParams, Sessions, + type Session, + type SessionLiveURLs, + type SessionCreateResponse, + type SessionListResponse, + type SessionCreateParams, + type SessionUpdateParams, + type SessionListParams, } from './sessions'; -export { SessionLog, LogListResponse, Logs } from './logs'; -export { SessionRecording, RecordingRetrieveResponse, Recording } from './recording'; -export { UploadCreateResponse, UploadCreateParams, Uploads } from './uploads'; +export { Uploads, type UploadCreateResponse, type UploadCreateParams } from './uploads'; diff --git a/src/resources/sessions/logs.ts b/src/resources/sessions/logs.ts index 27f9379..5f95984 100644 --- a/src/resources/sessions/logs.ts +++ b/src/resources/sessions/logs.ts @@ -2,7 +2,6 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; -import * as LogsAPI from './logs'; export class Logs extends APIResource { /** @@ -62,7 +61,6 @@ export namespace SessionLog { export type LogListResponse = Array; -export namespace Logs { - export import SessionLog = LogsAPI.SessionLog; - export import LogListResponse = LogsAPI.LogListResponse; +export declare namespace Logs { + export { type SessionLog as SessionLog, type LogListResponse as LogListResponse }; } diff --git a/src/resources/sessions/recording.ts b/src/resources/sessions/recording.ts index 344bf77..feb056f 100644 --- a/src/resources/sessions/recording.ts +++ b/src/resources/sessions/recording.ts @@ -2,7 +2,6 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; -import * as RecordingAPI from './recording'; export class Recording extends APIResource { /** @@ -14,8 +13,6 @@ export class Recording extends APIResource { } export interface SessionRecording { - id: string; - /** * See * [rrweb documentation](https://github.com/rrweb-io/rrweb/blob/master/docs/recipes/dive-into-event.md). @@ -34,7 +31,9 @@ export interface SessionRecording { export type RecordingRetrieveResponse = Array; -export namespace Recording { - export import SessionRecording = RecordingAPI.SessionRecording; - export import RecordingRetrieveResponse = RecordingAPI.RecordingRetrieveResponse; +export declare namespace Recording { + export { + type SessionRecording as SessionRecording, + type RecordingRetrieveResponse as RecordingRetrieveResponse, + }; } diff --git a/src/resources/sessions/sessions.ts b/src/resources/sessions/sessions.ts index 013ff3b..5190967 100644 --- a/src/resources/sessions/sessions.ts +++ b/src/resources/sessions/sessions.ts @@ -3,11 +3,14 @@ import { APIResource } from '../../resource'; import { isRequestOptions } from '../../core'; import * as Core from '../../core'; -import * as SessionsAPI from './sessions'; import * as DownloadsAPI from './downloads'; +import { Downloads } from './downloads'; import * as LogsAPI from './logs'; +import { LogListResponse, Logs, SessionLog } from './logs'; import * as RecordingAPI from './recording'; +import { Recording, RecordingRetrieveResponse, SessionRecording } from './recording'; import * as UploadsAPI from './uploads'; +import { UploadCreateParams, UploadCreateResponse, Uploads } from './uploads'; export class Sessions extends APIResource { downloads: DownloadsAPI.Downloads = new DownloadsAPI.Downloads(this._client); @@ -430,22 +433,35 @@ export interface SessionListParams { status?: 'RUNNING' | 'ERROR' | 'TIMED_OUT' | 'COMPLETED'; } -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; - export import SessionListParams = SessionsAPI.SessionListParams; - export import Downloads = DownloadsAPI.Downloads; - export import Logs = LogsAPI.Logs; - export import SessionLog = LogsAPI.SessionLog; - export import LogListResponse = LogsAPI.LogListResponse; - export import Recording = RecordingAPI.Recording; - export import SessionRecording = RecordingAPI.SessionRecording; - export import RecordingRetrieveResponse = RecordingAPI.RecordingRetrieveResponse; - export import Uploads = UploadsAPI.Uploads; - export import UploadCreateResponse = UploadsAPI.UploadCreateResponse; - export import UploadCreateParams = UploadsAPI.UploadCreateParams; +Sessions.Downloads = Downloads; +Sessions.Logs = Logs; +Sessions.Recording = Recording; +Sessions.Uploads = Uploads; + +export declare namespace Sessions { + export { + type Session as Session, + type SessionLiveURLs as SessionLiveURLs, + type SessionCreateResponse as SessionCreateResponse, + type SessionListResponse as SessionListResponse, + type SessionCreateParams as SessionCreateParams, + type SessionUpdateParams as SessionUpdateParams, + type SessionListParams as SessionListParams, + }; + + export { Downloads as Downloads }; + + export { Logs as Logs, type SessionLog as SessionLog, type LogListResponse as LogListResponse }; + + export { + Recording as Recording, + type SessionRecording as SessionRecording, + type RecordingRetrieveResponse as RecordingRetrieveResponse, + }; + + export { + Uploads as Uploads, + type UploadCreateResponse as UploadCreateResponse, + type UploadCreateParams as UploadCreateParams, + }; } diff --git a/src/resources/sessions/uploads.ts b/src/resources/sessions/uploads.ts index 93a17e2..9b33d71 100644 --- a/src/resources/sessions/uploads.ts +++ b/src/resources/sessions/uploads.ts @@ -2,7 +2,6 @@ import { APIResource } from '../../resource'; import * as Core from '../../core'; -import * as UploadsAPI from './uploads'; export class Uploads extends APIResource { /** @@ -28,7 +27,6 @@ export interface UploadCreateParams { file: Core.Uploadable; } -export namespace Uploads { - export import UploadCreateResponse = UploadsAPI.UploadCreateResponse; - export import UploadCreateParams = UploadsAPI.UploadCreateParams; +export declare namespace Uploads { + export { type UploadCreateResponse as UploadCreateResponse, type UploadCreateParams as UploadCreateParams }; } diff --git a/src/version.ts b/src/version.ts index d66dc1b..29da3e4 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '2.0.0'; // x-release-please-version +export const VERSION = '2.0.1'; // x-release-please-version diff --git a/tests/api-resources/sessions/sessions.test.ts b/tests/api-resources/sessions/sessions.test.ts index 6546c42..b750851 100644 --- a/tests/api-resources/sessions/sessions.test.ts +++ b/tests/api-resources/sessions/sessions.test.ts @@ -28,11 +28,11 @@ describe('resource sessions', () => { context: { id: 'id', persist: true }, extensionId: 'extensionId', fingerprint: { - browsers: ['chrome', 'edge', 'firefox'], - devices: ['desktop', 'mobile'], + browsers: ['chrome'], + devices: ['desktop'], httpVersion: 1, - locales: ['string', 'string', 'string'], - operatingSystems: ['android', 'ios', 'linux'], + locales: ['string'], + operatingSystems: ['android'], screen: { maxHeight: 0, maxWidth: 0, minHeight: 0, minWidth: 0 }, }, logSession: true, diff --git a/tsconfig.deno.json b/tsconfig.deno.json index 95b2193..a5e6286 100644 --- a/tsconfig.deno.json +++ b/tsconfig.deno.json @@ -1,9 +1,9 @@ { "extends": "./tsconfig.json", - "include": ["deno"], + "include": ["dist-deno"], "exclude": [], "compilerOptions": { - "rootDir": "./deno", + "rootDir": "./dist-deno", "lib": ["es2020", "DOM"], "paths": { "@browserbasehq/sdk/_shims/auto/*": ["deno/_shims/auto/*-deno"], @@ -13,7 +13,7 @@ "noEmit": true, "declaration": true, "declarationMap": true, - "outDir": "deno", + "outDir": "dist-deno", "pretty": true, "sourceMap": true } diff --git a/tsconfig.json b/tsconfig.json index ebb675d..bb314b5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -32,6 +32,7 @@ "noUncheckedIndexedAccess": true, "noImplicitOverride": true, "noPropertyAccessFromIndexSignature": true, + "isolatedModules": false, "skipLibCheck": true } diff --git a/yarn.lock b/yarn.lock index 7564200..3f0a956 100644 --- a/yarn.lock +++ b/yarn.lock @@ -860,16 +860,6 @@ dependencies: "@swc/counter" "^0.1.3" -"@ts-morph/common@~0.20.0": - version "0.20.0" - resolved "https://registry.yarnpkg.com/@ts-morph/common/-/common-0.20.0.tgz#3f161996b085ba4519731e4d24c35f6cba5b80af" - integrity sha512-7uKjByfbPpwuzkstL3L5MQyuXPSKdoNG93Fmi2JoDcTf3pEP731JdRFAduRVkOs8oqxPsXKA+ScrWkdQ8t/I+Q== - dependencies: - fast-glob "^3.2.12" - minimatch "^7.4.3" - mkdirp "^2.1.6" - path-browserify "^1.0.1" - "@tsconfig/node10@^1.0.7": version "1.0.11" resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.11.tgz#6ee46400685f130e278128c7b38b7e031ff5b2f2" @@ -1471,11 +1461,6 @@ co@^4.6.0: resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184" integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ== -code-block-writer@^12.0.0: - version "12.0.0" - resolved "https://registry.yarnpkg.com/code-block-writer/-/code-block-writer-12.0.0.tgz#4dd58946eb4234105aff7f0035977b2afdc2a770" - integrity sha512-q4dMFMlXtKR3XNBHyMHt/3pwYNA69EDk00lloMOaaUMKPUXBw6lpXtbu3MMVG6/uOihGnRDOlkyqsONEUj60+w== - collect-v8-coverage@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9" @@ -2912,11 +2897,6 @@ mkdirp-classic@^0.5.2: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -mkdirp@^2.1.6: - version "2.1.6" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-2.1.6.tgz#964fbcb12b2d8c5d6fbc62a963ac95a273e2cc19" - integrity sha512-+hEnITedc8LAtIP9u3HJDFIdcLV2vXP33sqLLIzkv1Db1zO/1OxbvYf0Y1OC/S/Qo5dxHXepofhmxL02PsKe+A== - ms@2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" @@ -3068,11 +3048,6 @@ parse-json@^5.2.0: json-parse-even-better-errors "^2.3.0" lines-and-columns "^1.1.6" -path-browserify@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-1.0.1.tgz#d98454a9c3753d5790860f16f68867b9e46be1fd" - integrity sha512-b7uo2UCUOYZcnF/3ID0lulOJi/bafxa1xPe7ZPsammBSpjSWQkjNxlt635YGS2MiR9GjvuXCtz2emr3jbsz98g== - path-exists@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3" @@ -3577,14 +3552,6 @@ ts-jest@^29.1.0: semver "^7.6.3" yargs-parser "^21.1.1" -ts-morph@^19.0.0: - version "19.0.0" - resolved "https://registry.yarnpkg.com/ts-morph/-/ts-morph-19.0.0.tgz#43e95fb0156c3fe3c77c814ac26b7d0be2f93169" - integrity sha512-D6qcpiJdn46tUqV45vr5UGM2dnIEuTGNxVhg0sk5NX11orcouwj6i1bMqZIz2mZTZB1Hcgy7C3oEVhAT+f6mbQ== - dependencies: - "@ts-morph/common" "~0.20.0" - code-block-writer "^12.0.0" - ts-node@^10.5.0: version "10.9.2" resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.2.tgz#70f021c9e185bccdca820e26dc413805c101c71f"