import type { PaginatedResponse, RestLinks, RestPath } from './common.js'; import type { RestProject } from './project.js'; import type { DiffResponseFormat, RepoArchiveState, RepoVisibility, WhitespaceHandling } from './pull-request.js'; /** * Repository state values from Bitbucket Server. */ export type RepositoryState = 'AVAILABLE' | 'INITIALISATION_FAILED' | 'INITIALISING' | 'OFFLINE'; /** * Bitbucket Server repository information (RestRepository schema from Swagger). * Simplified to include only commonly used readonly fields. */ export interface RestRepository { /** Repository ID */ id: number; /** Repository name (e.g., "My repo") */ name: string; /** Repository slug (e.g., "my-repo") */ slug: string; /** Repository description */ description?: string; /** Hierarchy ID (e.g., "e3c939f9ef4a7fae272e") */ hierarchyId?: string; /** SCM ID (e.g., "git") */ scmId?: string; /** Repository state */ state?: RepositoryState; /** Status message (e.g., "Available") */ statusMessage?: string; /** Whether the repository is forkable */ forkable?: boolean; /** Whether the repository is archived */ archived?: boolean; /** Whether the repository is public */ public?: boolean; /** Repository partition */ partition?: number; /** Repository scope (e.g., "REPOSITORY") */ scope?: string; /** Project this repository belongs to */ project?: RestProject; /** Origin repository (for forks) */ origin?: RestRepository; /** Links */ links?: RestLinks; } /** * Response type for list repositories endpoint. */ export type RepositoriesResponse = PaginatedResponse; /** * Repository with required project (for inbox PRs). */ export interface RestRepositoryWithProject extends Omit { /** Project (required for inbox PRs) */ project: RestProject; } /** * Entry in browse response (file or directory). */ export interface RestBrowseEntry { /** Path information */ path: RestPath; /** Entry type: DIRECTORY, FILE, or SUBMODULE */ type: 'DIRECTORY' | 'FILE' | 'SUBMODULE'; /** Content ID (present for files) */ contentId?: string; /** Node hash (present for directories) */ node?: string; /** File size in bytes (present for files) */ size?: number; } /** * Response when browsing a directory. * Contains children array with file/folder entries. */ export interface BrowseDirectoryResponse { /** Current path info */ path: RestPath; /** Current revision/branch */ revision: string; /** Children entries (files and directories) */ children: PaginatedResponse; } /** * Response when browsing a file via /browse endpoint. * Contains file content as lines. */ export interface BrowseFileResponse { /** File content as lines */ lines: { text: string; }[]; /** Pagination start */ start: number; /** Number of lines in this response */ size: number; /** Whether this is the last page */ isLastPage: boolean; /** Pagination limit */ limit: number; } /** * Union type for browse response. * Check 'children' in response to determine if it's a directory or file. */ export type BrowseResponse = BrowseDirectoryResponse | BrowseFileResponse; /** * Result of repository permission check */ export interface RepositoryPermissions { /** Whether the token has read access to the repository */ read: boolean; /** Whether the token has write access to the repository */ write: boolean; } /** * Attachment metadata from Bitbucket Server. */ export interface RestAttachmentMetadata { [key: string]: unknown; /** Attachment ID */ id: string; /** Original file name */ metadata?: Record; } /** * Response from the attachment upload endpoint. */ export interface UploadAttachmentResponse { attachments: { id: string; url: string; links?: { attachment?: { href: string; }; }; }[]; } /** * Result of a single attachment upload. */ export interface UploadAttachmentResult { /** Attachment ID */ id: string; /** Attachment reference URL (attachment:repoId/attachmentId) */ url: string; } /** * Parameters for list method (GET /repos — cross-project listing). */ export interface ListRepositoriesParams { /** Filter by repository name (case-insensitive partial match) */ name?: string; /** Filter by project name (case-insensitive partial match) */ projectname?: string; /** Filter by project key (case-insensitive exact match) */ projectkey?: string; /** Filter by visibility */ visibility?: RepoVisibility; /** Filter by permission level */ permission?: 'REPO_READ' | 'REPO_WRITE' | 'REPO_ADMIN'; /** Filter by archived status (default: ACTIVE) */ archived?: RepoArchiveState; /** Filter by repository state */ state?: 'AVAILABLE' | 'INITIALISING' | 'INITIALISATION_FAILED'; /** Pagination start offset */ start?: number; /** Maximum number of results (default: 25) */ limit?: number; } /** * Parameters for get method */ export interface GetRepositoryParams { /** The Bitbucket Server project key */ projectKey: string; /** The repository slug */ repositorySlug: string; } /** * Parameters for create method (POST /projects/{projectKey}/repos). */ export interface CreateRepositoryParams { /** The Bitbucket Server project key the repo will live under */ projectKey: string; /** Repository name (slug is derived by Bitbucket) */ name: string; /** SCM type. Defaults to 'git' if omitted. */ scmId?: 'git'; /** Description shown on the repo page */ description?: string; /** Default branch ref (e.g. 'refs/heads/main' or just 'main') */ defaultBranch?: string; /** Whether the repository is forkable (server default: true) */ forkable?: boolean; /** Whether the repository is public (server default: false) */ public?: boolean; } /** * Parameters for update method (PUT /projects/{projectKey}/repos/{slug}). * Only provided fields are sent; Bitbucket leaves omitted fields unchanged. * * Note: the `archived` field on repos is "Available since 8.0" and is * silently ignored on 7.x servers. Not exposed here until the server upgrades. */ export interface UpdateRepositoryParams { /** Current project key the repo lives under */ projectKey: string; /** Current repository slug */ repositorySlug: string; /** New display name (slug is regenerated server-side) */ name?: string; /** New description */ description?: string; /** New default branch ref (e.g. 'refs/heads/main' or just 'main') */ defaultBranch?: string; /** Toggle forkable */ forkable?: boolean; /** Toggle public visibility */ public?: boolean; } /** * Parameters for delete method (DELETE /projects/{projectKey}/repos/{slug}). * Bitbucket returns 202 and asynchronously deletes the repository. */ export interface DeleteRepositoryParams { /** The Bitbucket Server project key */ projectKey: string; /** The repository slug */ repositorySlug: string; } /** * Parameters for browse method. * Browse repository contents at a given path (structured JSON response). */ export interface BrowseParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** Path to browse (empty or omit for root directory) */ path?: string; /** Branch, tag, or commit ref (e.g., "refs/heads/main") */ at?: string; /** Pagination limit (default: 500) */ limit?: number; /** Pagination start offset */ start?: number; } /** * Parameters for getRawContent method. * Get raw content from repository (plain text for files, git tree listing for directories). */ export interface GetRawContentParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** File path (required) */ path: string; /** Branch, tag, or commit ref (e.g., "refs/heads/main") */ at?: string; } /** * Parameters for editFile method (PUT /projects/{key}/repos/{slug}/browse/{path}). * Creates or updates a single file on a branch and produces a new commit. */ export interface EditFileParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** File path within the repository (no leading slash) */ path: string; /** Full file content (string or Buffer). Replaces the file entirely. */ content: string | Buffer; /** Branch on which the new commit lands */ branch: string; /** Commit message. If omitted, Bitbucket uses a default. */ message?: string; /** * Commit ID of the file before this edit. REQUIRED when updating an * existing file (Bitbucket uses it for conflict detection). Omit when * creating a new file. */ sourceCommitId?: string; /** * When set, `branch` is created from this existing branch. Use this to * land the change on a new branch instead of an existing one. */ sourceBranch?: string; } /** * Parameters for checkPermissions method */ export interface CheckRepositoryPermissionsParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; } /** * Parameters for downloadAttachment method. * Downloads an attachment binary to disk. */ export interface DownloadAttachmentParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** The attachment ID */ attachmentId: string; /** Local file path to write the attachment to */ destinationPath: string; } /** * Parameters for getAttachmentMetadata method. * Gets metadata for a repository attachment. */ export interface GetAttachmentMetadataParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** The attachment ID */ attachmentId: string; } /** * Parameters for uploadAttachment method. * Uploads a file as an attachment to a repository. */ export interface UploadAttachmentParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** Local file path to upload */ filePath: string; } /** * Parameters for getCommitChanges method. * List files changed in a specific commit. */ export interface GetCommitChangesParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** The commit hash */ commitId: string; /** The commit to compare against (defaults to parent) */ since?: string; /** Pagination limit (default: 25) */ limit?: number; /** Pagination start offset */ start?: number; } /** * Parameters for getCommitDiff method. * Get the diff for a specific commit. */ export interface GetCommitDiffParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** The commit hash */ commitId: string; /** Scope diff to a single file path */ path?: string; /** Number of context lines around changes */ contextLines?: number; /** Whitespace handling */ whitespace?: WhitespaceHandling; /** Response format: 'text' for raw unified diff, 'json' for structured response */ format?: DiffResponseFormat; } /** * Parameters for getCompareChanges method. * List files that differ between two refs. */ export interface GetCompareChangesParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** Source ref (branch, tag, or commit hash) */ from: string; /** Target ref (branch, tag, or commit hash) */ to: string; /** Pagination limit (default: 25) */ limit?: number; /** Pagination start offset */ start?: number; } /** * Parameters for getCompareDiff method. * Get the diff between two refs. */ export interface GetCompareDiffParams { /** The Bitbucket project key */ projectKey: string; /** The repository slug */ repositorySlug: string; /** Source ref (branch, tag, or commit hash) */ from: string; /** Target ref (branch, tag, or commit hash) */ to: string; /** Scope diff to a single file path */ path?: string; /** Number of context lines around changes */ contextLines?: number; /** Whitespace handling */ whitespace?: WhitespaceHandling; } //# sourceMappingURL=repository.d.ts.map