From b35df41f08f216dd79b092938179376ee858e440 Mon Sep 17 00:00:00 2001 From: Tasnim Kabir Sadik Date: Sat, 16 May 2026 16:23:27 +0600 Subject: [PATCH] test public entry point exports --- src/index.ts | 124 ++++++++++++++++++++++---------------------- tests/index.test.ts | 43 +++++++++++++++ 2 files changed, 105 insertions(+), 62 deletions(-) create mode 100644 tests/index.test.ts diff --git a/src/index.ts b/src/index.ts index f0bca78..ccd10c0 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,90 +1,90 @@ export type { - CapsuleCreateOptions, - CapsuleInfo, - CapsuleMetrics, - CapsuleMetricsOptions, - CapsuleResumeOptions, - WaitForReadyOptions, + CapsuleCreateOptions, + CapsuleInfo, + CapsuleMetrics, + CapsuleMetricsOptions, + CapsuleResumeOptions, + WaitForReadyOptions, } from "./capsule.js"; export { Capsule, Sandbox } from "./capsule.js"; export type { - FileUploadInput, - OperationJsonBody, - OperationJsonResponse, - OperationQueryParams, - OperationRequestOptions, + FileUploadInput, + OperationJsonBody, + OperationJsonResponse, + OperationQueryParams, + OperationRequestOptions, } from "./client.js"; export { - AccountResource, - APIKeysResource, - AuthResource, - CapsulesResource, - ChannelsResource, - FilesResource, - HostsResource, - SnapshotsResource, - TeamsResource, - UsersResource, - WrennClient, + AccountResource, + APIKeysResource, + AuthResource, + CapsulesResource, + ChannelsResource, + FilesResource, + HostsResource, + SnapshotsResource, + TeamsResource, + UsersResource, + WrennClient, } from "./client.js"; export type { - ExecCellOptions, - ExecCellResult, + ExecCellOptions, + ExecCellResult, } from "./code-interpreter/index.js"; export { CodeInterpreter, Notebook } from "./code-interpreter/index.js"; export type { - BackgroundCommandOptions, - BackgroundProcess, - CommandOptions, - CommandResult, - CommandStreamEvent, - CommandStreamOptions, - ProcessList, + BackgroundCommandOptions, + BackgroundProcess, + CommandOptions, + CommandResult, + CommandStreamEvent, + CommandStreamOptions, + ProcessList, } from "./commands.js"; export { CommandManager } from "./commands.js"; export type { ClientConfig, ResolvedClientConfig } from "./config.js"; export { - DEFAULT_BASE_URL, - ENV_API_KEY, - ENV_BASE_URL, - ENV_HOST_TOKEN, - ENV_TOKEN, - resolveConfig, + DEFAULT_BASE_URL, + ENV_API_KEY, + ENV_BASE_URL, + ENV_HOST_TOKEN, + ENV_TOKEN, + resolveConfig, } from "./config.js"; export { - AuthenticationError, - BadRequestError, - ConflictError, - ForbiddenError, - HostHasCapsulesError, - NotFoundError, - PayloadTooLargeError, - ServerError, - TimeoutError, - throwErrorFromResponse, - WrennError, + AuthenticationError, + BadRequestError, + ConflictError, + ForbiddenError, + HostHasCapsulesError, + NotFoundError, + PayloadTooLargeError, + ServerError, + TimeoutError, + throwErrorFromResponse, + WrennError, } from "./exceptions.js"; export type { - FileContent, - FileList, - ListFilesOptions, - MakeDirectoryResult, + FileContent, + FileList, + ListFilesOptions, + MakeDirectoryResult, } from "./files.js"; export { FileManager } from "./files.js"; export type { - GitCheckoutOptions, - GitCloneOptions, - GitLogOptions, - GitOptions, - GitRemoteBranchOptions, + GitCheckoutOptions, + GitCloneOptions, + GitLogOptions, + GitOptions, + GitRemoteBranchOptions, } from "./git/index.js"; export { Git } from "./git/index.js"; export type { - $defs, - components, - operations, - paths, - webhooks, + $defs, + components, + operations, + paths, + webhooks, } from "./models/generated.js"; export type { PtyEvent, PtyStartOptions } from "./pty.js"; export { PtyManager, PtySession } from "./pty.js"; diff --git a/tests/index.test.ts b/tests/index.test.ts new file mode 100644 index 0000000..9f86171 --- /dev/null +++ b/tests/index.test.ts @@ -0,0 +1,43 @@ +import { describe, expect, it } from "vitest"; +import type { components, operations, paths } from "../src/index.js"; +import * as sdk from "../src/index.js"; + +type CapsuleSchema = components["schemas"]["Capsule"]; +type GetCapsuleOperation = operations["getCapsule"]; +type CapsulePath = paths["/v1/capsules/{id}"]; + +function acceptsGeneratedTypes( + _capsule: CapsuleSchema, + _operation: GetCapsuleOperation, + _path: CapsulePath, +): void {} + +describe("public entry point", () => { + it("exports the supported runtime API from the package root", () => { + expect(sdk.Capsule).toBeTypeOf("function"); + expect(sdk.Sandbox).toBe(sdk.Capsule); + expect(sdk.WrennClient).toBeTypeOf("function"); + expect(sdk.CodeInterpreter).toBeTypeOf("function"); + expect(sdk.Notebook).toBeTypeOf("function"); + expect(sdk.CommandManager).toBeTypeOf("function"); + expect(sdk.FileManager).toBeTypeOf("function"); + expect(sdk.Git).toBeTypeOf("function"); + expect(sdk.PtyManager).toBeTypeOf("function"); + expect(sdk.PtySession).toBeTypeOf("function"); + expect(sdk.WrennError).toBeTypeOf("function"); + expect(sdk.NotFoundError).toBeTypeOf("function"); + }); + + it("keeps internal shared helpers out of the public runtime API", () => { + expect("HttpClient" in sdk).toBe(false); + expect("WsConnection" in sdk).toBe(false); + }); + + it("exposes generated OpenAPI types from the package root", () => { + acceptsGeneratedTypes( + {} as CapsuleSchema, + {} as GetCapsuleOperation, + {} as CapsulePath, + ); + }); +});