import type { Branch, BranchCreateRequest, BranchSchemaCompareResponse, BranchUpdateRequest, Endpoint, ListProjectBranchesData } from "../../client/types.gen.js"; import type { CallOptions, RequestContext } from "../context.js"; import { type Paginated } from "../paginate.js"; import { type Outcome } from "../result.js"; type ListQuery = Omit, "cursor">; type BranchFields = NonNullable; type UpdateInput = BranchUpdateRequest["branch"]; export interface ComputeSettings { minCu?: number; maxCu?: number; suspendTimeoutSeconds?: number; } type CreateInputBase = BranchFields & { compute?: ComputeSettings; }; export type CreateInput = (CreateInputBase & { noCompute?: false; }) | (BranchFields & { noCompute: true; compute?: never; }); export interface CreateAndConnectInput { name?: string; /** Parent branch id. Defaults to the project's default branch. */ parentId?: string; compute?: ComputeSettings; } /** A branch with its read-write endpoint and a ready-to-use connection string. */ export interface BranchConnection { branch: Branch; endpoint: Endpoint; connectionString: string; } export interface ResetFromParentInput { /** Required when the branch has children so they can move to the preserved branch. */ preserveUnderName?: string; } export interface CompareSchemaInput { databaseName: string; baseBranchId?: string; lsn?: string; timestamp?: string; baseLsn?: string; baseTimestamp?: string; } export type BranchListParams = ListQuery & { projectId: string; }; export interface BranchGetParams { projectId: string; branchId: string; } export type BranchCreateParams = CreateInput & { projectId: string; }; export type BranchUpdateParams = UpdateInput & { projectId: string; branchId: string; }; export interface BranchDeleteParams { projectId: string; branchId: string; } export type BranchCreateAndConnectParams = CreateAndConnectInput & { projectId: string; /** Return a pooled connection string (default `true`). */ pooled?: boolean; }; export interface BranchGetDefaultParams { projectId: string; } export interface BranchSetDefaultParams { projectId: string; branchId: string; } export type BranchResetFromParentParams = ResetFromParentInput & { projectId: string; branchId: string; }; export type BranchCompareSchemaParams = CompareSchemaInput & { projectId: string; branchId: string; }; export interface BranchFinalizeRestoreParams { projectId: string; branchId: string; name?: string; } export declare class Branches { #private; constructor(ctx: RequestContext); /** @apiCall GET /projects/{project_id}/branches (cursor-paginated) */ list(params: BranchListParams): Paginated; list(params: BranchListParams, opts: CallOptions): Paginated; /** @apiCall GET /projects/{project_id}/branches/{branch_id} */ get(params: BranchGetParams): Promise>; get(params: BranchGetParams, opts: CallOptions): Promise>; /** * This method retains its branch-only result even when it provisions compute; * use {@link Branches.createAndConnect} or `postgres.connectionString` when a * connection string is needed. * * Readiness polling stays on for `noCompute` branches because a * compute-less branch still has provisioning operations. */ create(params: BranchCreateParams): Promise>; create(params: BranchCreateParams, opts: CallOptions): Promise>; /** @apiCall PATCH /projects/{project_id}/branches/{branch_id} */ update(params: BranchUpdateParams): Promise>; update(params: BranchUpdateParams, opts: CallOptions): Promise>; /** @apiCall DELETE /projects/{project_id}/branches/{branch_id} */ delete(params: BranchDeleteParams): Promise>; delete(params: BranchDeleteParams, opts: CallOptions): Promise>; createAndConnect(params: BranchCreateAndConnectParams): Promise>; createAndConnect(params: BranchCreateAndConnectParams, opts: CallOptions): Promise>; /** * Resolve the project's default branch (by the `default` flag — not by name). * Returns a {@link NeonClientError} when no default branch is found. */ getDefault(params: BranchGetDefaultParams): Promise>; getDefault(params: BranchGetDefaultParams, opts: CallOptions): Promise>; /** @apiCall POST /projects/{project_id}/branches/{branch_id}/set_as_default */ setDefault(params: BranchSetDefaultParams): Promise>; setDefault(params: BranchSetDefaultParams, opts: CallOptions): Promise>; /** * Uses the parent's current HEAD; use raw `restoreProjectBranch` for an LSN or timestamp. * * @apiCall GET /projects/{project_id}/branches/{branch_id} * @apiCall POST /projects/{project_id}/branches/{branch_id}/restore */ resetFromParent(params: BranchResetFromParentParams): Promise>; resetFromParent(params: BranchResetFromParentParams, opts: CallOptions): Promise>; /** * Returns a unified SQL diff; omitting `baseBranchId` uses the parent branch. * * @apiCall GET /projects/{project_id}/branches/{branch_id}/compare_schema */ compareSchema(params: BranchCompareSchemaParams): Promise>; compareSchema(params: BranchCompareSchemaParams, opts: CallOptions): Promise>; /** * Complete (commit) a restore previously started with `snapshots.restore({ finalize: false })`: * moves computes onto the restored branch and renames the replaced one. This is **only** * the second step — it does not restore anything itself. * * @apiCall POST /projects/{project_id}/branches/{branch_id}/restore/finalize */ finalizeRestore(params: BranchFinalizeRestoreParams): Promise>; finalizeRestore(params: BranchFinalizeRestoreParams, opts: CallOptions): Promise>; } export {}; //# sourceMappingURL=branches.d.ts.map