~james/core

core/web/src/lib/api/issue.ts -rw-r--r-- 980 bytes
452f17b7 — james chore(import): snapshot james.dad.town/core at f70c71c7696a 15 hours ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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);