import type { Did } from "#lib/api/syntax.ts";
import type { BobbinContext, XrpcRequestInit } from "#lib/api/client.ts";
import { jsonGet } from "#lib/api/_request.ts";
import type { TicketRecord, TicketState } from "#lib/api/records.ts";
export type IssueState = "open" | "closed";
// a listIssues row: the embedded issue record plus bobbin-derived state/counts.
export interface IssueListItem {
cid?: string;
commentCount: number;
state: TicketState;
stateUpdatedAt?: string;
uri: string;
value: TicketRecord;
}
export interface IssueListPage {
cursor?: string | null;
total?: number;
items: IssueListItem[];
}
export interface ListIssuesFilter {
state?: TicketState;
author?: string;
limit?: number;
cursor?: string;
order?: "asc" | "desc";
}
export const listIssues = (
ctx: BobbinContext,
subject: Did,
filter: ListIssuesFilter = {},
init?: XrpcRequestInit
) => jsonGet<IssueListPage>(ctx, "org.tangled.repo.listIssues", { subject, ...filter }, init);