import type { RestRepositoryWithProject } from './repository.js'; /** * Types for Bitbucket's code search REST plugin * (`POST /rest/search/latest/search`). The endpoint is multi-entity (code, * repositories, …); we model the `code` entity only, which is the primary * entity for a code search. * * The response nests the paged result under `code` with its own cursor fields * (`count` / `start` / `nextStart` / `isLastPage`) — a different shape from the * core REST `PaginatedResponse`, so it gets its own types here. */ /** A single matched line inside a file hit. `text` carries Bitbucket's `` highlight markup and HTML entities verbatim. */ export interface RestSearchHitLine { line: number; text: string; } /** * One file that matched the query. `hitContexts` is an array of context blocks * (each a run of adjacent lines around a match), so a file with matches in two * distant regions yields two blocks. */ export interface RestCodeSearchResult { repository: RestRepositoryWithProject; file: string; hitContexts: RestSearchHitLine[][]; pathMatches: unknown[]; hitCount: number; } /** The `code` entity block of a search response — a self-paginating result set. */ export interface RestCodeSearchEntity { category: string; isLastPage: boolean; /** Total number of matches across all pages. */ count: number; /** 0-based offset of this page. */ start: number; /** Offset to pass as the next page's `start`. Present even when `isLastPage`. */ nextStart: number; values: RestCodeSearchResult[]; } /** Full response envelope from `POST /rest/search/latest/search` for a code query. */ export interface CodeSearchResponse { scope: { type: string; }; code: RestCodeSearchEntity; /** * Bitbucket may rewrite a query (e.g. spelling); `substitutedText` carries the * rewrite when it did. **`null` when a `project:`/`repo:` scope in the query * failed to resolve** — Bitbucket then falls back to a GLOBAL scope, returns * zero hits, and nulls this field (a legitimate empty result keeps * `{ substituted: false }`). Consumers should treat `null` as an unresolved * scope (bad project key / repo slug), not as "no matches". */ query: { substituted: boolean; substitutedText?: string; } | null; } /** Parameters for {@link SearchApi.searchCode}. */ export interface CodeSearchParams { /** Raw query string. Supports Bitbucket modifiers (`project:`, `repo:`, `lang:`, `ext:`). */ query: string; /** 0-based offset into the result set. */ start?: number; /** Page size (maps to the API's `limits.primary`). */ limit?: number; } //# sourceMappingURL=search.d.ts.map