This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

core / web / src / lib / api / records.ts
2.5 kB 58 lines
1import type { BobbinContext, XrpcRequestInit } from "./client"; 2import { jsonGet } from "./_request"; 3import type * as ShTangledActorProfile from "./lexicons/types/sh/tangled/actor/profile"; 4import type * as ShTangledRepo from "./lexicons/types/sh/tangled/repo"; 5import type * as ShTangledRepoIssue from "./lexicons/types/sh/tangled/repo/issue"; 6import type * as ShTangledRepoPull from "./lexicons/types/sh/tangled/repo/pull"; 7 8export interface RecordView<V> { 9 uri: string; 10 cid?: string; 11 value: V; 12} 13 14export interface RecordList<V> { 15 items: RecordView<V>[]; 16} 17 18export type RepoRecord = ShTangledRepo.Main; 19export type ProfileRecord = ShTangledActorProfile.Main; 20export type IssueRecord = ShTangledRepoIssue.Main; 21export type PullRecord = ShTangledRepoPull.Main; 22 23export const BULK_LIMIT = 50; 24 25export const getRepo = (ctx: BobbinContext, repo: string, init?: XrpcRequestInit) => 26 jsonGet<RecordView<RepoRecord>>(ctx, "sh.tangled.repo.getRepo", { repo }, init); 27 28export const getRepoByRepoDid = (ctx: BobbinContext, repoDid: string, init?: XrpcRequestInit) => 29 jsonGet<RecordView<RepoRecord>>(ctx, "sh.tangled.repo.getRepoByRepoDid", { repoDid }, init); 30 31export const getProfile = (ctx: BobbinContext, did: string, init?: XrpcRequestInit) => 32 jsonGet<RecordView<ProfileRecord>>( 33 ctx, 34 "sh.tangled.actor.getProfile", 35 { actor: `at://${did}/sh.tangled.actor.profile/self` }, 36 init 37 ); 38 39export const getIssue = (ctx: BobbinContext, issue: string, init?: XrpcRequestInit) => 40 jsonGet<RecordView<IssueRecord>>(ctx, "sh.tangled.repo.getIssue", { issue }, init); 41 42export const getPull = (ctx: BobbinContext, pull: string, init?: XrpcRequestInit) => 43 jsonGet<RecordView<PullRecord>>(ctx, "sh.tangled.repo.getPull", { pull }, init); 44 45export const getRepos = (ctx: BobbinContext, repos: readonly string[], init?: XrpcRequestInit) => 46 jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getRepos", { repos }, init); 47 48export const getProfiles = ( 49 ctx: BobbinContext, 50 actors: readonly string[], 51 init?: XrpcRequestInit 52) => jsonGet<RecordList<ProfileRecord>>(ctx, "sh.tangled.actor.getProfiles", { actors }, init); 53 54export const getIssues = (ctx: BobbinContext, issues: readonly string[], init?: XrpcRequestInit) => 55 jsonGet<RecordList<IssueRecord>>(ctx, "sh.tangled.repo.getIssues", { issues }, init); 56 57export const getPulls = (ctx: BobbinContext, pulls: readonly string[], init?: XrpcRequestInit) => 58 jsonGet<RecordList<PullRecord>>(ctx, "sh.tangled.repo.getPulls", { pulls }, init);