/** * Tinybird Branch (Environment) API client * Uses the /v1/environments endpoints (Forward API) */ /** * Branch information from Tinybird API */ export interface TinybirdBranch { /** Branch ID */ id: string; /** Branch name */ name: string; /** Branch token (only present when requested with with_token=true) */ token?: string; /** When the branch was created */ created_at: string; } /** * Result of getOrCreateBranch operation */ export interface GetOrCreateBranchResult extends TinybirdBranch { /** Whether the branch was newly created (vs already existed) */ wasCreated: boolean; } /** * API configuration for branch operations */ export interface BranchApiConfig { /** Tinybird API base URL */ baseUrl: string; /** Parent workspace token (used to create/manage branches) */ token: string; /** Custom fetch implementation (optional) */ fetch?: typeof fetch; } /** * Error thrown by branch API operations */ export declare class BranchApiError extends Error { readonly status: number; readonly body?: unknown | undefined; constructor(message: string, status: number, body?: unknown | undefined); } /** * Create a new branch * POST /v1/environments?name={name} * * This is an async operation that returns a job. We poll the job until * it completes, then fetch the branch with its token. * * @param config - API configuration * @param name - Branch name to create * @returns The created branch with token */ export interface CreateBranchOptions { /** Copy the last partition of production data into the branch */ lastPartition?: boolean; } export declare function createBranch(config: BranchApiConfig, name: string, options?: CreateBranchOptions): Promise; /** * List all branches in the workspace * GET /v1/environments * * @param config - API configuration * @returns Array of branches */ export declare function listBranches(config: BranchApiConfig): Promise; /** * Get a branch by name with its token * GET /v0/environments/{name}?with_token=true * * @param config - API configuration * @param name - Branch name * @returns Branch with token */ export declare function getBranch(config: BranchApiConfig, name: string): Promise; /** * Delete a branch * DELETE /v0/environments/{id} * * Note: The API requires the branch ID, not name. This function first * fetches the branch to get its ID, then deletes it. * * @param config - API configuration * @param name - Branch name to delete */ export declare function deleteBranch(config: BranchApiConfig, name: string): Promise; /** * Check if a branch exists * * @param config - API configuration * @param name - Branch name to check * @returns true if branch exists, false if not * @throws BranchApiError on API/network/auth failures */ export declare function branchExists(config: BranchApiConfig, name: string): Promise; /** * Get or create a branch * If the branch exists, returns it with token. * If it doesn't exist, creates it. * * @param config - API configuration * @param name - Branch name * @returns Branch with token */ export declare function getOrCreateBranch(config: BranchApiConfig, name: string, options?: CreateBranchOptions): Promise; /** * Clear a branch by deleting and recreating it * * @param config - API configuration * @param name - Branch name to clear * @returns The recreated branch with token */ export declare function clearBranch(config: BranchApiConfig, name: string): Promise; //# sourceMappingURL=branches.d.ts.map