import { BranchInfo } from "../validation/dolt-schemas.js"; import { AgentScopeConfig, ProjectScopeConfig } from "../db/manage/scope-definitions.js"; import "../types/utility.js"; import { AgentsManageDatabaseClient } from "../db/manage/manage-client.js"; //#region src/dolt/branches-api.d.ts declare const MAIN_BRANCH_SUFFIX = "main"; declare class invalidBranchParamsError extends Error { constructor(message: string); } /** * Get the tenant-scoped main branch name */ declare const getTenantMainBranch: (tenantId: string) => string; /** * Check if a branch name (without tenant/project prefix) is a protected branch */ declare const isProtectedBranchName: (branchName: string) => boolean; declare const getTempBranchSuffix: (prefix: string) => string; declare const isTempBranchName: (fullName: string) => boolean; type CreateBranchParams = { tenantId: string; projectId: string; name: string; /** Branch name to create from. Defaults to tenant main branch. */ fromBranch?: string; /** Commit hash to create from. Mutually exclusive with fromBranch. */ fromCommit?: string; /** * Whether to sync schema on the source branch before creating. * This ensures the new branch starts with the latest schema from main. * Default: true. Ignored when fromCommit is set. */ syncSchemaOnSource?: boolean; }; type GetBranchParams = { tenantId: string; projectId: string; name: string; }; /** * Parameters for checking out a branch with optional schema sync */ type CheckoutBranchParams = { /** The full branch name (e.g., "tenant1_project1_main") */ branchName: string; /** Whether to sync schema from main after checkout. Default: true */ syncSchema?: boolean; /** Whether to auto-commit pending changes before schema sync. Default: false */ autoCommitPending?: boolean; }; /** * Result of a branch checkout operation */ type CheckoutBranchResult = { /** The full branch name that was checked out */ branchName: string; /** The commit hash of the branch after checkout (and potential schema sync) */ hash: string; /** Result of the schema sync operation */ schemaSync: { /** Whether schema sync was performed */ performed: boolean; /** Whether there were schema differences */ hadDifferences: boolean; /** Error message if schema sync failed */ error?: string; /** The merge commit hash if schema was synced */ mergeCommitHash?: string; }; }; /** * Checkout a branch with optional schema synchronization from main. * * This function: * 1. Checks out the specified branch * 2. If syncSchema is true (default), checks for schema differences from main * 3. If differences exist, merges schema from main into the branch * * @param db - Database client * @returns Function that takes checkout params and returns checkout result */ declare const checkoutBranch: (db: AgentsManageDatabaseClient) => (params: CheckoutBranchParams) => Promise; declare const syncSchemaOnBranch: (db: AgentsManageDatabaseClient) => (branchName: string) => Promise; /** * Create a new branch with optional schema synchronization. * * This function: * 1. Optionally syncs schema on the source branch from main (default: true) * 2. Creates a new branch from the source branch * * By syncing schema on the source branch first, we ensure the new branch * starts with the latest schema, avoiding schema conflicts later. * If you want to create a branch from a commit hash, use the fromCommit parameter. */ declare const createBranch: (db: AgentsManageDatabaseClient) => (params: CreateBranchParams) => Promise; type DeleteBranchParams = { tenantId: string; projectId: string; branchName: string; force?: boolean; }; /** * Delete a branch */ declare const deleteBranch: (db: AgentsManageDatabaseClient) => (params: DeleteBranchParams) => Promise; /** * Get a single branch */ declare const getBranch: (db: AgentsManageDatabaseClient) => (params: GetBranchParams) => Promise; /** * List all branches for a project * Returns only project-specific branches (e.g., {tenantId}_{projectId}_main, {tenantId}_{projectId}_feature-x) * Does NOT include the tenant_main branch as that's an organizational branch, not a project development branch */ declare const listBranches: (db: AgentsManageDatabaseClient) => (params: ProjectScopeConfig) => Promise; declare const listBranchesForAgent: (db: AgentsManageDatabaseClient) => (params: AgentScopeConfig) => Promise; //#endregion export { CheckoutBranchParams, CheckoutBranchResult, CreateBranchParams, DeleteBranchParams, GetBranchParams, MAIN_BRANCH_SUFFIX, checkoutBranch, createBranch, deleteBranch, getBranch, getTempBranchSuffix, getTenantMainBranch, invalidBranchParamsError, isProtectedBranchName, isTempBranchName, listBranches, listBranchesForAgent, syncSchemaOnBranch };