// ── SDK v2 — KaibanClient ────────────────────────────────────────────────────── // // Entry point for all SDK operations. // Instantiate once; reuse everywhere. import { Fetcher } from "./http/fetcher"; import type { ClientConfig } from "./http/types"; import { TeamsClient } from "./resources/teams"; import { ActivitiesClient } from "./resources/activities"; import { BoardsClient } from "./resources/boards"; import { CardsClient } from "./resources/cards"; import { AgentsClient } from "./resources/agents"; import { AgentDraftsClient } from "./resources/agent-drafts"; import { NotificationsClient } from "./resources/notifications"; import { AppsClient } from "./resources/apps"; import { IntegrationsClient } from "./resources/integrations"; import { PositionsClient } from "./resources/positions"; import { ResourcesClient } from "./resources/resources"; export class KaibanClient { /** Access the Boards domain and External Channels sub-resource. */ readonly boards: BoardsClient; /** Access the Cards domain, including bulk ops, sessions, and comments. */ readonly cards: CardsClient; /** Access the Agents domain, including Feedback and Supervisor Feedback. */ readonly agents: AgentsClient; /** Access the Agent Drafts domain, including publish workflow. */ readonly agentDrafts: AgentDraftsClient; /** Access the Teams domain and Invitations sub-resource. */ readonly teams: TeamsClient; /** Access the Activities domain, including real-time SSE streaming. */ readonly activities: ActivitiesClient; /** Access the Notifications domain. */ readonly notifications: NotificationsClient; /** Access the Apps domain and App Settings sub-resource. */ readonly apps: AppsClient; /** Access the Integrations domain. */ readonly integrations: IntegrationsClient; /** Access the Positions domain. */ readonly positions: PositionsClient; /** Access the Resources domain. */ readonly resources: ResourcesClient; private readonly fetcher: Fetcher; /** * Creates a new Kaiban API v2 client. * * @example Browser (Firebase — auto-refreshing token): * ```ts * import { KaibanClient } from "@kaiban/sdk-v2"; * import { getAuth } from "firebase/auth"; * * const client = new KaibanClient({ * tenant: "my-org", * getToken: () => getAuth().currentUser?.getIdToken() ?? Promise.resolve(undefined), * }); * ``` * * @example Server / agent (API key): * ```ts * import { KaibanClient } from "@kaiban/sdk-v2"; * * const client = new KaibanClient({ * tenant: "my-org", * apiKey: process.env.KAIBAN_API_KEY, // kb_t_... or kb_s_... * }); * ``` * * @example Local dev: * ```ts * const client = new KaibanClient({ * tenant: "my-org", * apiKey: "kb_t_...", * baseUrl: "http://localhost:3000/api/v2", * }); * ``` */ constructor(config: ClientConfig) { this.fetcher = new Fetcher(config); this.boards = new BoardsClient(this.fetcher); this.cards = new CardsClient(this.fetcher); this.agents = new AgentsClient(this.fetcher); this.agentDrafts = new AgentDraftsClient(this.fetcher); this.teams = new TeamsClient(this.fetcher); this.activities = new ActivitiesClient(this.fetcher); this.notifications = new NotificationsClient(this.fetcher); this.apps = new AppsClient(this.fetcher); this.integrations = new IntegrationsClient(this.fetcher); this.positions = new PositionsClient(this.fetcher); this.resources = new ResourcesClient(this.fetcher); } }