Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677import type { Nsid } from "@atcute/lexicons/syntax";import type { OAuthUserAgent } from "@atcute/oauth-browser-client";import { deleteRecord, putRecord } from "./write";import type { BobbinContext, XrpcRequestInit } from "./client";import { jsonGet } from "./_request";import type { RecordList, RecordView } from "./records";import type * as ShTangledRepoIssue from "./lexicons/types/sh/tangled/repo/issue";import type * as ShTangledRepoIssueState from "./lexicons/types/sh/tangled/repo/issue/state";
export type IssueRecord = ShTangledRepoIssue.Main;export type IssueStateRecord = ShTangledRepoIssueState.Main;
const ISSUE_COLLECTION = "sh.tangled.repo.issue" as Nsid;
export const putIssue = async ( agent: OAuthUserAgent, rkey: string, record: IssueRecord): Promise<RecordView<IssueRecord>> => { const { uri, cid } = await putRecord(agent, ISSUE_COLLECTION, rkey, record); return { uri, cid, value: record };};
export const deleteIssue = async (agent: OAuthUserAgent, rkey: string): Promise<void> => { await deleteRecord(agent, ISSUE_COLLECTION, rkey);};
export const getIssue = (ctx: BobbinContext, issue: string, init?: XrpcRequestInit) => jsonGet<RecordView<IssueRecord>>(ctx, "sh.tangled.repo.getIssue", { issue }, init);
export const getIssues = (ctx: BobbinContext, issues: readonly string[], init?: XrpcRequestInit) => jsonGet<RecordList<IssueRecord>>(ctx, "sh.tangled.repo.getIssues", { issues }, init);
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: string; stateUpdatedAt?: string; uri: string; value: IssueRecord;}
export interface IssueListPage { cursor?: string | null; items: IssueListItem[];}
export interface ListIssuesFilter { state?: IssueState; author?: string; limit?: number; cursor?: string; order?: "asc" | "desc";}
export const listIssues = ( ctx: BobbinContext, subject: string, filter: ListIssuesFilter = {}, init?: XrpcRequestInit) => jsonGet<IssueListPage>(ctx, "sh.tangled.repo.listIssues", { subject, ...filter }, init);
export interface IssueStateList { cursor?: string | null; items: RecordView<IssueStateRecord>[];}
export const listIssueStates = ( ctx: BobbinContext, subject: string, filter: { limit?: number; cursor?: string; order?: "asc" | "desc" } = {}, init?: XrpcRequestInit) => jsonGet<IssueStateList>(ctx, "sh.tangled.repo.issue.listStates", { subject, ...filter }, init);