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
3.0 kB 73 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"; 7import type * as ShTangledString from "./lexicons/types/sh/tangled/string"; 8 9export interface RecordView<V> { 10 uri: string; 11 cid?: string; 12 value: V; 13} 14 15export interface RecordList<V> { 16 items: RecordView<V>[]; 17} 18 19export type RepoRecord = ShTangledRepo.Main; 20export type ProfileRecord = ShTangledActorProfile.Main; 21export type IssueRecord = ShTangledRepoIssue.Main; 22export type PullRecord = ShTangledRepoPull.Main; 23export type StringRecord = ShTangledString.Main; 24 25export const BULK_LIMIT = 50; 26 27export const getRepo = (ctx: BobbinContext, repo: string, init?: XrpcRequestInit) => 28 jsonGet<RecordView<RepoRecord>>(ctx, "sh.tangled.repo.getRepo", { repo }, init); 29 30export const getRepoByRepoDid = (ctx: BobbinContext, repoDid: string, init?: XrpcRequestInit) => 31 jsonGet<RecordView<RepoRecord>>(ctx, "sh.tangled.repo.getRepoByRepoDid", { repoDid }, init); 32 33export const getRepoByName = ( 34 ctx: BobbinContext, 35 owner: string, 36 name: string, 37 init?: XrpcRequestInit 38) => jsonGet<RecordView<RepoRecord>>(ctx, "sh.tangled.repo.getRepoByName", { owner, name }, init); 39 40export const getProfile = (ctx: BobbinContext, did: string, init?: XrpcRequestInit) => 41 jsonGet<RecordView<ProfileRecord>>( 42 ctx, 43 "sh.tangled.actor.getProfile", 44 { actor: `at://${did}/sh.tangled.actor.profile/self` }, 45 init 46 ); 47 48export const getIssue = (ctx: BobbinContext, issue: string, init?: XrpcRequestInit) => 49 jsonGet<RecordView<IssueRecord>>(ctx, "sh.tangled.repo.getIssue", { issue }, init); 50 51export const getPull = (ctx: BobbinContext, pull: string, init?: XrpcRequestInit) => 52 jsonGet<RecordView<PullRecord>>(ctx, "sh.tangled.repo.getPull", { pull }, init); 53 54export const getRepos = (ctx: BobbinContext, repos: readonly string[], init?: XrpcRequestInit) => 55 jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getRepos", { repos }, init); 56 57export const getReposByRepoDids = ( 58 ctx: BobbinContext, 59 dids: readonly string[], 60 init?: XrpcRequestInit 61) => jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getReposByRepoDids", { dids }, init); 62 63export const getProfiles = ( 64 ctx: BobbinContext, 65 actors: readonly string[], 66 init?: XrpcRequestInit 67) => jsonGet<RecordList<ProfileRecord>>(ctx, "sh.tangled.actor.getProfiles", { actors }, init); 68 69export const getIssues = (ctx: BobbinContext, issues: readonly string[], init?: XrpcRequestInit) => 70 jsonGet<RecordList<IssueRecord>>(ctx, "sh.tangled.repo.getIssues", { issues }, init); 71 72export const getPulls = (ctx: BobbinContext, pulls: readonly string[], init?: XrpcRequestInit) => 73 jsonGet<RecordList<PullRecord>>(ctx, "sh.tangled.repo.getPulls", { pulls }, init);