diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 2a248c7..76d5538 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.8.3" + ".": "0.9.0" } diff --git a/.stats.yml b/.stats.yml index fbe1e82..062204b 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,4 +1,4 @@ -configured_endpoints: 19 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-9f2d347a4bcb03aed092ba4495aac090c3d988e9a99af091ee35c09994adad8b.yml -openapi_spec_hash: 73b92bd5503ab6c64dc26da31cca36e2 -config_hash: 65328ff206b8c0168c915914506d9dba +configured_endpoints: 31 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/kernel%2Fkernel-e907afeabfeea49dedd783112ac3fd29267bc86f3d594f89ba9a2abf2bcbc9d8.yml +openapi_spec_hash: 060ca6288c1a09b6d1bdf207a0011165 +config_hash: f67e4b33b2fb30c1405ee2fff8096320 diff --git a/CHANGELOG.md b/CHANGELOG.md index 96c0acb..88a1d4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 0.9.0 (2025-08-08) + +Full Changelog: [v0.8.3...v0.9.0](https://github.com/onkernel/kernel-node-sdk/compare/v0.8.3...v0.9.0) + +### Features + +* **api:** browser instance file i/o ([cc7f07f](https://github.com/onkernel/kernel-node-sdk/commit/cc7f07fedf78492e092dd1e982634a6e142f0dfa)) + + +### Bug Fixes + +* **methods:** define methods with parameters and binary body correctly ([6c70c14](https://github.com/onkernel/kernel-node-sdk/commit/6c70c147bfca8429aec6c114e42741d405c552b2)) + + +### Chores + +* **internal:** move publish config ([7662fc0](https://github.com/onkernel/kernel-node-sdk/commit/7662fc06f49f4816b9ff6328bae5aa70964a4143)) + ## 0.8.3 (2025-08-01) Full Changelog: [v0.8.2...v0.8.3](https://github.com/onkernel/kernel-node-sdk/compare/v0.8.2...v0.8.3) diff --git a/api.md b/api.md index 5f2b98c..19d1eca 100644 --- a/api.md +++ b/api.md @@ -84,3 +84,35 @@ Methods: - client.browsers.replays.download(replayID, { ...params }) -> Response - client.browsers.replays.start(id, { ...params }) -> ReplayStartResponse - client.browsers.replays.stop(replayID, { ...params }) -> void + +## Fs + +Types: + +- FFileInfoResponse +- FListFilesResponse + +Methods: + +- client.browsers.fs.createDirectory(id, { ...params }) -> void +- client.browsers.fs.deleteDirectory(id, { ...params }) -> void +- client.browsers.fs.deleteFile(id, { ...params }) -> void +- client.browsers.fs.fileInfo(id, { ...params }) -> FFileInfoResponse +- client.browsers.fs.listFiles(id, { ...params }) -> FListFilesResponse +- client.browsers.fs.move(id, { ...params }) -> void +- client.browsers.fs.readFile(id, { ...params }) -> Response +- client.browsers.fs.setFilePermissions(id, { ...params }) -> void +- client.browsers.fs.writeFile(id, contents, { ...params }) -> void + +### Watch + +Types: + +- WatchEventsResponse +- WatchStartResponse + +Methods: + +- client.browsers.fs.watch.events(watchID, { ...params }) -> WatchEventsResponse +- client.browsers.fs.watch.start(id, { ...params }) -> WatchStartResponse +- client.browsers.fs.watch.stop(watchID, { ...params }) -> void diff --git a/bin/publish-npm b/bin/publish-npm index fa2243d..45e8aa8 100644 --- a/bin/publish-npm +++ b/bin/publish-npm @@ -58,4 +58,4 @@ else fi # Publish with the appropriate tag -yarn publish --access public --tag "$TAG" +yarn publish --tag "$TAG" diff --git a/package.json b/package.json index 9c6fda5..e01977a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@onkernel/sdk", - "version": "0.8.3", + "version": "0.9.0", "description": "The official TypeScript library for the Kernel API", "author": "Kernel <>", "types": "dist/index.d.ts", @@ -13,6 +13,9 @@ "**/*" ], "private": false, + "publishConfig": { + "access": "public" + }, "scripts": { "test": "./scripts/test", "build": "./scripts/build", diff --git a/src/resources/browsers/browsers.ts b/src/resources/browsers/browsers.ts index 1f8f204..438a892 100644 --- a/src/resources/browsers/browsers.ts +++ b/src/resources/browsers/browsers.ts @@ -11,6 +11,21 @@ import { ReplayStopParams, Replays, } from './replays'; +import * as FsAPI from './fs/fs'; +import { + FCreateDirectoryParams, + FDeleteDirectoryParams, + FDeleteFileParams, + FFileInfoParams, + FFileInfoResponse, + FListFilesParams, + FListFilesResponse, + FMoveParams, + FReadFileParams, + FSetFilePermissionsParams, + FWriteFileParams, + Fs, +} from './fs/fs'; import { APIPromise } from '../../core/api-promise'; import { buildHeaders } from '../../internal/headers'; import { RequestOptions } from '../../internal/request-options'; @@ -18,6 +33,7 @@ import { path } from '../../internal/utils/path'; export class Browsers extends APIResource { replays: ReplaysAPI.Replays = new ReplaysAPI.Replays(this._client); + fs: FsAPI.Fs = new FsAPI.Fs(this._client); /** * Create a new browser session from within an action. @@ -212,6 +228,7 @@ export interface BrowserDeleteParams { } Browsers.Replays = Replays; +Browsers.Fs = Fs; export declare namespace Browsers { export { @@ -231,4 +248,19 @@ export declare namespace Browsers { type ReplayStartParams as ReplayStartParams, type ReplayStopParams as ReplayStopParams, }; + + export { + Fs as Fs, + type FFileInfoResponse as FFileInfoResponse, + type FListFilesResponse as FListFilesResponse, + type FCreateDirectoryParams as FCreateDirectoryParams, + type FDeleteDirectoryParams as FDeleteDirectoryParams, + type FDeleteFileParams as FDeleteFileParams, + type FFileInfoParams as FFileInfoParams, + type FListFilesParams as FListFilesParams, + type FMoveParams as FMoveParams, + type FReadFileParams as FReadFileParams, + type FSetFilePermissionsParams as FSetFilePermissionsParams, + type FWriteFileParams as FWriteFileParams, + }; } diff --git a/src/resources/browsers/fs.ts b/src/resources/browsers/fs.ts new file mode 100644 index 0000000..d210ff1 --- /dev/null +++ b/src/resources/browsers/fs.ts @@ -0,0 +1,3 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export * from './fs/index'; diff --git a/src/resources/browsers/fs/fs.ts b/src/resources/browsers/fs/fs.ts new file mode 100644 index 0000000..caaa148 --- /dev/null +++ b/src/resources/browsers/fs/fs.ts @@ -0,0 +1,385 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import * as WatchAPI from './watch'; +import { + Watch, + WatchEventsParams, + WatchEventsResponse, + WatchStartParams, + WatchStartResponse, + WatchStopParams, +} from './watch'; +import { APIPromise } from '../../../core/api-promise'; +import { buildHeaders } from '../../../internal/headers'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class Fs extends APIResource { + watch: WatchAPI.Watch = new WatchAPI.Watch(this._client); + + /** + * Create a new directory + * + * @example + * ```ts + * await client.browsers.fs.createDirectory('id', { + * path: '/J!', + * }); + * ``` + */ + createDirectory(id: string, body: FCreateDirectoryParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/browsers/${id}/fs/create_directory`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Delete a directory + * + * @example + * ```ts + * await client.browsers.fs.deleteDirectory('id', { + * path: '/J!', + * }); + * ``` + */ + deleteDirectory(id: string, body: FDeleteDirectoryParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/browsers/${id}/fs/delete_directory`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Delete a file + * + * @example + * ```ts + * await client.browsers.fs.deleteFile('id', { path: '/J!' }); + * ``` + */ + deleteFile(id: string, body: FDeleteFileParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/browsers/${id}/fs/delete_file`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Get information about a file or directory + * + * @example + * ```ts + * const response = await client.browsers.fs.fileInfo('id', { + * path: '/J!', + * }); + * ``` + */ + fileInfo(id: string, query: FFileInfoParams, options?: RequestOptions): APIPromise { + return this._client.get(path`/browsers/${id}/fs/file_info`, { query, ...options }); + } + + /** + * List files in a directory + * + * @example + * ```ts + * const response = await client.browsers.fs.listFiles('id', { + * path: '/J!', + * }); + * ``` + */ + listFiles(id: string, query: FListFilesParams, options?: RequestOptions): APIPromise { + return this._client.get(path`/browsers/${id}/fs/list_files`, { query, ...options }); + } + + /** + * Move or rename a file or directory + * + * @example + * ```ts + * await client.browsers.fs.move('id', { + * dest_path: '/J!', + * src_path: '/J!', + * }); + * ``` + */ + move(id: string, body: FMoveParams, options?: RequestOptions): APIPromise { + return this._client.put(path`/browsers/${id}/fs/move`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Read file contents + * + * @example + * ```ts + * const response = await client.browsers.fs.readFile('id', { + * path: '/J!', + * }); + * + * const content = await response.blob(); + * console.log(content); + * ``` + */ + readFile(id: string, query: FReadFileParams, options?: RequestOptions): APIPromise { + return this._client.get(path`/browsers/${id}/fs/read_file`, { + query, + ...options, + headers: buildHeaders([{ Accept: 'application/octet-stream' }, options?.headers]), + __binaryResponse: true, + }); + } + + /** + * Set file or directory permissions/ownership + * + * @example + * ```ts + * await client.browsers.fs.setFilePermissions('id', { + * mode: '0611', + * path: '/J!', + * }); + * ``` + */ + setFilePermissions( + id: string, + body: FSetFilePermissionsParams, + options?: RequestOptions, + ): APIPromise { + return this._client.put(path`/browsers/${id}/fs/set_file_permissions`, { + body, + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } + + /** + * Write or create a file + * + * @example + * ```ts + * await client.browsers.fs.writeFile( + * 'id', + * fs.createReadStream('path/to/file'), + * { path: '/J!' }, + * ); + * ``` + */ + writeFile( + id: string, + contents: string | ArrayBuffer | ArrayBufferView | Blob | DataView, + params: FWriteFileParams, + options?: RequestOptions, + ): APIPromise { + const { path: path_, mode } = params; + return this._client.put(path`/browsers/${id}/fs/write_file`, { + body: contents, + query: { path: path_, mode }, + ...options, + headers: buildHeaders([ + { 'Content-Type': 'application/octet-stream', Accept: '*/*' }, + options?.headers, + ]), + }); + } +} + +export interface FFileInfoResponse { + /** + * Whether the path is a directory. + */ + is_dir: boolean; + + /** + * Last modification time. + */ + mod_time: string; + + /** + * File mode bits (e.g., "drwxr-xr-x" or "-rw-r--r--"). + */ + mode: string; + + /** + * Base name of the file or directory. + */ + name: string; + + /** + * Absolute path. + */ + path: string; + + /** + * Size in bytes. 0 for directories. + */ + size_bytes: number; +} + +/** + * Array of file or directory information entries. + */ +export type FListFilesResponse = Array; + +export namespace FListFilesResponse { + export interface FListFilesResponseItem { + /** + * Whether the path is a directory. + */ + is_dir: boolean; + + /** + * Last modification time. + */ + mod_time: string; + + /** + * File mode bits (e.g., "drwxr-xr-x" or "-rw-r--r--"). + */ + mode: string; + + /** + * Base name of the file or directory. + */ + name: string; + + /** + * Absolute path. + */ + path: string; + + /** + * Size in bytes. 0 for directories. + */ + size_bytes: number; + } +} + +export interface FCreateDirectoryParams { + /** + * Absolute directory path to create. + */ + path: string; + + /** + * Optional directory mode (octal string, e.g. 755). Defaults to 755. + */ + mode?: string; +} + +export interface FDeleteDirectoryParams { + /** + * Absolute path to delete. + */ + path: string; +} + +export interface FDeleteFileParams { + /** + * Absolute path to delete. + */ + path: string; +} + +export interface FFileInfoParams { + /** + * Absolute path of the file or directory. + */ + path: string; +} + +export interface FListFilesParams { + /** + * Absolute directory path. + */ + path: string; +} + +export interface FMoveParams { + /** + * Absolute destination path. + */ + dest_path: string; + + /** + * Absolute source path. + */ + src_path: string; +} + +export interface FReadFileParams { + /** + * Absolute file path to read. + */ + path: string; +} + +export interface FSetFilePermissionsParams { + /** + * File mode bits (octal string, e.g. 644). + */ + mode: string; + + /** + * Absolute path whose permissions are to be changed. + */ + path: string; + + /** + * New group name or GID. + */ + group?: string; + + /** + * New owner username or UID. + */ + owner?: string; +} + +export interface FWriteFileParams { + /** + * Query param: Destination absolute file path. + */ + path: string; + + /** + * Query param: Optional file mode (octal string, e.g. 644). Defaults to 644. + */ + mode?: string; +} + +Fs.Watch = Watch; + +export declare namespace Fs { + export { + type FFileInfoResponse as FFileInfoResponse, + type FListFilesResponse as FListFilesResponse, + type FCreateDirectoryParams as FCreateDirectoryParams, + type FDeleteDirectoryParams as FDeleteDirectoryParams, + type FDeleteFileParams as FDeleteFileParams, + type FFileInfoParams as FFileInfoParams, + type FListFilesParams as FListFilesParams, + type FMoveParams as FMoveParams, + type FReadFileParams as FReadFileParams, + type FSetFilePermissionsParams as FSetFilePermissionsParams, + type FWriteFileParams as FWriteFileParams, + }; + + export { + Watch as Watch, + type WatchEventsResponse as WatchEventsResponse, + type WatchStartResponse as WatchStartResponse, + type WatchEventsParams as WatchEventsParams, + type WatchStartParams as WatchStartParams, + type WatchStopParams as WatchStopParams, + }; +} diff --git a/src/resources/browsers/fs/index.ts b/src/resources/browsers/fs/index.ts new file mode 100644 index 0000000..14c3cb8 --- /dev/null +++ b/src/resources/browsers/fs/index.ts @@ -0,0 +1,24 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +export { + Fs, + type FFileInfoResponse, + type FListFilesResponse, + type FCreateDirectoryParams, + type FDeleteDirectoryParams, + type FDeleteFileParams, + type FFileInfoParams, + type FListFilesParams, + type FMoveParams, + type FReadFileParams, + type FSetFilePermissionsParams, + type FWriteFileParams, +} from './fs'; +export { + Watch, + type WatchEventsResponse, + type WatchStartResponse, + type WatchEventsParams, + type WatchStartParams, + type WatchStopParams, +} from './watch'; diff --git a/src/resources/browsers/fs/watch.ts b/src/resources/browsers/fs/watch.ts new file mode 100644 index 0000000..b0cc18c --- /dev/null +++ b/src/resources/browsers/fs/watch.ts @@ -0,0 +1,135 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import { APIResource } from '../../../core/resource'; +import { APIPromise } from '../../../core/api-promise'; +import { Stream } from '../../../core/streaming'; +import { buildHeaders } from '../../../internal/headers'; +import { RequestOptions } from '../../../internal/request-options'; +import { path } from '../../../internal/utils/path'; + +export class Watch extends APIResource { + /** + * Stream filesystem events for a watch + * + * @example + * ```ts + * const response = await client.browsers.fs.watch.events( + * 'watch_id', + * { id: 'id' }, + * ); + * ``` + */ + events( + watchID: string, + params: WatchEventsParams, + options?: RequestOptions, + ): APIPromise> { + const { id } = params; + return this._client.get(path`/browsers/${id}/fs/watch/${watchID}/events`, { + ...options, + headers: buildHeaders([{ Accept: 'text/event-stream' }, options?.headers]), + stream: true, + }) as APIPromise>; + } + + /** + * Watch a directory for changes + * + * @example + * ```ts + * const response = await client.browsers.fs.watch.start( + * 'id', + * { path: 'path' }, + * ); + * ``` + */ + start(id: string, body: WatchStartParams, options?: RequestOptions): APIPromise { + return this._client.post(path`/browsers/${id}/fs/watch`, { body, ...options }); + } + + /** + * Stop watching a directory + * + * @example + * ```ts + * await client.browsers.fs.watch.stop('watch_id', { + * id: 'id', + * }); + * ``` + */ + stop(watchID: string, params: WatchStopParams, options?: RequestOptions): APIPromise { + const { id } = params; + return this._client.delete(path`/browsers/${id}/fs/watch/${watchID}`, { + ...options, + headers: buildHeaders([{ Accept: '*/*' }, options?.headers]), + }); + } +} + +/** + * Filesystem change event. + */ +export interface WatchEventsResponse { + /** + * Absolute path of the file or directory. + */ + path: string; + + /** + * Event type. + */ + type: 'CREATE' | 'WRITE' | 'DELETE' | 'RENAME'; + + /** + * Whether the affected path is a directory. + */ + is_dir?: boolean; + + /** + * Base name of the file or directory affected. + */ + name?: string; +} + +export interface WatchStartResponse { + /** + * Unique identifier for the directory watch + */ + watch_id?: string; +} + +export interface WatchEventsParams { + /** + * Browser session ID + */ + id: string; +} + +export interface WatchStartParams { + /** + * Directory to watch. + */ + path: string; + + /** + * Whether to watch recursively. + */ + recursive?: boolean; +} + +export interface WatchStopParams { + /** + * Browser session ID + */ + id: string; +} + +export declare namespace Watch { + export { + type WatchEventsResponse as WatchEventsResponse, + type WatchStartResponse as WatchStartResponse, + type WatchEventsParams as WatchEventsParams, + type WatchStartParams as WatchStartParams, + type WatchStopParams as WatchStopParams, + }; +} diff --git a/src/resources/browsers/index.ts b/src/resources/browsers/index.ts index deb5900..cc79adb 100644 --- a/src/resources/browsers/index.ts +++ b/src/resources/browsers/index.ts @@ -9,6 +9,20 @@ export { type BrowserCreateParams, type BrowserDeleteParams, } from './browsers'; +export { + Fs, + type FFileInfoResponse, + type FListFilesResponse, + type FCreateDirectoryParams, + type FDeleteDirectoryParams, + type FDeleteFileParams, + type FFileInfoParams, + type FListFilesParams, + type FMoveParams, + type FReadFileParams, + type FSetFilePermissionsParams, + type FWriteFileParams, +} from './fs/index'; export { Replays, type ReplayListResponse, diff --git a/src/version.ts b/src/version.ts index c8e7320..5c16194 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1 +1 @@ -export const VERSION = '0.8.3'; // x-release-please-version +export const VERSION = '0.9.0'; // x-release-please-version diff --git a/tests/api-resources/browsers/fs/fs.test.ts b/tests/api-resources/browsers/fs/fs.test.ts new file mode 100644 index 0000000..44a5ad8 --- /dev/null +++ b/tests/api-resources/browsers/fs/fs.test.ts @@ -0,0 +1,164 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Kernel, { toFile } from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource fs', () => { + // skipped: tests are disabled for the time being + test.skip('createDirectory: only required params', async () => { + const responsePromise = client.browsers.fs.createDirectory('id', { path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('createDirectory: required and optional params', async () => { + const response = await client.browsers.fs.createDirectory('id', { path: '/J!', mode: '0611' }); + }); + + // skipped: tests are disabled for the time being + test.skip('deleteDirectory: only required params', async () => { + const responsePromise = client.browsers.fs.deleteDirectory('id', { path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('deleteDirectory: required and optional params', async () => { + const response = await client.browsers.fs.deleteDirectory('id', { path: '/J!' }); + }); + + // skipped: tests are disabled for the time being + test.skip('deleteFile: only required params', async () => { + const responsePromise = client.browsers.fs.deleteFile('id', { path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('deleteFile: required and optional params', async () => { + const response = await client.browsers.fs.deleteFile('id', { path: '/J!' }); + }); + + // skipped: tests are disabled for the time being + test.skip('fileInfo: only required params', async () => { + const responsePromise = client.browsers.fs.fileInfo('id', { path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('fileInfo: required and optional params', async () => { + const response = await client.browsers.fs.fileInfo('id', { path: '/J!' }); + }); + + // skipped: tests are disabled for the time being + test.skip('listFiles: only required params', async () => { + const responsePromise = client.browsers.fs.listFiles('id', { path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('listFiles: required and optional params', async () => { + const response = await client.browsers.fs.listFiles('id', { path: '/J!' }); + }); + + // skipped: tests are disabled for the time being + test.skip('move: only required params', async () => { + const responsePromise = client.browsers.fs.move('id', { dest_path: '/J!', src_path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('move: required and optional params', async () => { + const response = await client.browsers.fs.move('id', { dest_path: '/J!', src_path: '/J!' }); + }); + + // skipped: tests are disabled for the time being + test.skip('readFile: required and optional params', async () => { + const response = await client.browsers.fs.readFile('id', { path: '/J!' }); + }); + + // skipped: tests are disabled for the time being + test.skip('setFilePermissions: only required params', async () => { + const responsePromise = client.browsers.fs.setFilePermissions('id', { mode: '0611', path: '/J!' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('setFilePermissions: required and optional params', async () => { + const response = await client.browsers.fs.setFilePermissions('id', { + mode: '0611', + path: '/J!', + group: 'group', + owner: 'owner', + }); + }); + + // skipped: tests are disabled for the time being + test.skip('writeFile: only required params', async () => { + const responsePromise = client.browsers.fs.writeFile( + 'id', + await toFile(Buffer.from('# my file contents'), 'README.md'), + { path: '/J!' }, + ); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('writeFile: required and optional params', async () => { + const response = await client.browsers.fs.writeFile( + 'id', + await toFile(Buffer.from('# my file contents'), 'README.md'), + { path: '/J!', mode: '0611' }, + ); + }); +}); diff --git a/tests/api-resources/browsers/fs/watch.test.ts b/tests/api-resources/browsers/fs/watch.test.ts new file mode 100644 index 0000000..c85702d --- /dev/null +++ b/tests/api-resources/browsers/fs/watch.test.ts @@ -0,0 +1,61 @@ +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. + +import Kernel from '@onkernel/sdk'; + +const client = new Kernel({ + apiKey: 'My API Key', + baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', +}); + +describe('resource watch', () => { + // skipped: currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail + test.skip('events: only required params', async () => { + const responsePromise = client.browsers.fs.watch.events('watch_id', { id: 'id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: currently no good way to test endpoints with content type text/event-stream, Prism mock server will fail + test.skip('events: required and optional params', async () => { + const response = await client.browsers.fs.watch.events('watch_id', { id: 'id' }); + }); + + // skipped: tests are disabled for the time being + test.skip('start: only required params', async () => { + const responsePromise = client.browsers.fs.watch.start('id', { path: 'path' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('start: required and optional params', async () => { + const response = await client.browsers.fs.watch.start('id', { path: 'path', recursive: true }); + }); + + // skipped: tests are disabled for the time being + test.skip('stop: only required params', async () => { + const responsePromise = client.browsers.fs.watch.stop('watch_id', { id: 'id' }); + const rawResponse = await responsePromise.asResponse(); + expect(rawResponse).toBeInstanceOf(Response); + const response = await responsePromise; + expect(response).not.toBeInstanceOf(Response); + const dataAndResponse = await responsePromise.withResponse(); + expect(dataAndResponse.data).toBe(response); + expect(dataAndResponse.response).toBe(rawResponse); + }); + + // skipped: tests are disabled for the time being + test.skip('stop: required and optional params', async () => { + const response = await client.browsers.fs.watch.stop('watch_id', { id: 'id' }); + }); +});