Something went wrong. Try again.
Monorepo for Tangled tangled.org
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170import type { BobbinContext, XrpcRequestInit } from "$lib/api/client";import { jsonGet } from "$lib/api/_request";import type * as ShTangledActorGetProfileActivity from "$lib/api/lexicons/types/sh/tangled/actor/getProfileActivity";import type * as OrgTangledActorProfile from "$lib/api/lexicons/types/org/tangled/actor/profile";import type * as OrgTangledFeedStar from "$lib/api/lexicons/types/org/tangled/feed/star";import type * as OrgTangledGraphVouch from "$lib/api/lexicons/types/org/tangled/graph/vouch";import type * as OrgTangledRepoManifest from "$lib/api/lexicons/types/org/tangled/repo/manifest";import type * as OrgTangledReviewPatch from "$lib/api/lexicons/types/org/tangled/review/patch";import type * as OrgTangledSnippetString from "$lib/api/lexicons/types/org/tangled/snippet/string";import type * as OrgTangledTrackGetTicketView from "$lib/api/lexicons/types/org/tangled/track/getTicketView";import type * as OrgTangledTrackTicket from "$lib/api/lexicons/types/org/tangled/track/ticket";import type * as ShTangledRepo from "$lib/api/lexicons/types/sh/tangled/repo";import type * as ShTangledRepoPull from "$lib/api/lexicons/types/sh/tangled/repo/pull";import type * as ShTangledRepoPullStatus from "$lib/api/lexicons/types/sh/tangled/repo/pull/status";export interface RecordView<V> { uri: string; cid?: string; value: V;}
export interface RecordList<V> { items: RecordView<V>[];}
export type RepoRecord = OrgTangledRepoManifest.Main;export type LegacyRepoRecord = ShTangledRepo.Main;export type ProfileRecord = OrgTangledActorProfile.Main;export type PullRecord = ShTangledRepoPull.Main;export type TicketRecord = OrgTangledTrackTicket.Main;export type TicketState = OrgTangledTrackTicket.Main["state"];
export type PullStatusRecord = ShTangledRepoPullStatus.Main;export type StringRecord = OrgTangledSnippetString.Main;export type StarRecord = OrgTangledFeedStar.Main;export type VouchRecord = OrgTangledGraphVouch.Main;export type ProfileActivityOutput = ShTangledActorGetProfileActivity.$output;export type ProfileActivityRepoRef = ShTangledActorGetProfileActivity.RepoRef;
export const BULK_LIMIT = 50;
export type RepoView = RecordView<RepoRecord> & { knot?: string };
export const getRepo = (ctx: BobbinContext, repo: string, init?: XrpcRequestInit) => jsonGet<RepoView>(ctx, "sh.tangled.repo.getRepo", { repo }, init);
export const getRepoByRepoDid = (ctx: BobbinContext, repoDid: string, init?: XrpcRequestInit) => jsonGet<RepoView>(ctx, "sh.tangled.repo.getRepoByRepoDid", { repoDid }, init);
export const getRepoByName = ( ctx: BobbinContext, owner: string, name: string, init?: XrpcRequestInit) => jsonGet<RepoView>(ctx, "sh.tangled.repo.getRepoByName", { owner, name }, init);
export interface RepoListPage { cursor?: string | null; items: RecordView<RepoRecord>[];}
export const listRepos = ( ctx: BobbinContext, subject: string, filter: { limit?: number; cursor?: string; order?: "asc" | "desc" } = {}, init?: XrpcRequestInit) => jsonGet<RepoListPage>(ctx, "sh.tangled.repo.listRepos", { subject, ...filter }, init);
export const getProfile = (ctx: BobbinContext, did: string, init?: XrpcRequestInit) => jsonGet<RecordView<ProfileRecord>>( ctx, "sh.tangled.actor.getProfile", { actor: `at://${did}/org.tangled.actor.profile/self` }, init );
export const getPull = (ctx: BobbinContext, pull: string, init?: XrpcRequestInit) => jsonGet<RecordView<PullRecord>>(ctx, "sh.tangled.repo.getPull", { pull }, init);
export type TicketViewDetailed = OrgTangledTrackGetTicketView.$output;
export const getTicketView = (ctx: BobbinContext, uri: string, init?: XrpcRequestInit) => jsonGet<TicketViewDetailed>(ctx, "org.tangled.track.getTicketView", { uri }, init);
export type PatchRecord = OrgTangledReviewPatch.Main;
export const listPatches = (ctx: BobbinContext, ticket: string, init?: XrpcRequestInit) => jsonGet<RecordList<PatchRecord>>( ctx, "org.tangled.temp.review.listPatches", { ticket, order: "asc", limit: 500 }, init );
export interface PullListItem { cid?: string; commentCount: number; state: TicketState; stateUpdatedAt?: string; uri: string; value: TicketRecord;}
export interface PullListPage { cursor?: string | null; total?: number; items: PullListItem[];}
export interface ListPullsFilter { status?: TicketState; author?: string; limit?: number; cursor?: string; order?: "asc" | "desc";}
export const listPulls = ( ctx: BobbinContext, subject: string, filter: ListPullsFilter = {}, init?: XrpcRequestInit) => jsonGet<PullListPage>(ctx, "sh.tangled.repo.listPulls", { subject, ...filter }, init);
export const getRepos = (ctx: BobbinContext, repos: readonly string[], init?: XrpcRequestInit) => jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getRepos", { repos }, init);
export const getReposByRepoDids = ( ctx: BobbinContext, dids: readonly string[], init?: XrpcRequestInit) => jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getReposByRepoDids", { dids }, init);
export const getProfileActivity = ( ctx: BobbinContext, actor: string, months = 7, init?: XrpcRequestInit) => jsonGet<ProfileActivityOutput>( ctx, "sh.tangled.actor.getProfileActivity", { actor, months }, init );
export const getProfiles = ( ctx: BobbinContext, actors: readonly string[], init?: XrpcRequestInit) => jsonGet<RecordList<ProfileRecord>>(ctx, "sh.tangled.actor.getProfiles", { actors }, init);
export const getPulls = (ctx: BobbinContext, pulls: readonly string[], init?: XrpcRequestInit) => jsonGet<RecordList<PullRecord>>(ctx, "sh.tangled.repo.getPulls", { pulls }, init);
export interface StarListPage { cursor?: string | null; total?: number; items: RecordView<StarRecord>[];}
export const listStars = ( ctx: BobbinContext, subject: string, filter: { limit?: number; cursor?: string; offset?: number; order?: "asc" | "desc" } = {}, init?: XrpcRequestInit) => jsonGet<StarListPage>(ctx, "sh.tangled.feed.listStars", { subject, ...filter }, init);
export const getString = (ctx: BobbinContext, uri: string, init?: XrpcRequestInit) => jsonGet<RecordView<StringRecord>>(ctx, "sh.tangled.string.getString", { uri }, init);