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.7 kB 56 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 8/** getRecord-shaped view returned by the hydrated single-record `get*` endpoints. */ 9export interface RecordView<V> { 10 uri: string; 11 cid?: string; 12 value: V; 13} 14 15/** Envelope returned by the bulk `get*s` endpoints (no cursor — inputs are explicit uris). */ 16export interface RecordList<V> { 17 items: RecordView<V>[]; 18} 19 20export type RepoRecord = ShTangledRepo.Main; 21export type ProfileRecord = ShTangledActorProfile.Main; 22export type IssueRecord = ShTangledRepoIssue.Main; 23export type PullRecord = ShTangledRepoPull.Main; 24 25/** Max uris accepted per bulk request (mirrors bobbin's BULK_LIMIT). */ 26export const BULK_LIMIT = 50; 27 28export const getRepo = (ctx: BobbinContext, repo: string, init?: XrpcRequestInit) => 29 jsonGet<RecordView<RepoRecord>>(ctx, 'sh.tangled.repo.getRepo', { repo }, init); 30 31export const getRepoByRepoDid = (ctx: BobbinContext, repoDid: string, init?: XrpcRequestInit) => 32 jsonGet<RecordView<RepoRecord>>(ctx, 'sh.tangled.repo.getRepoByRepoDid', { repoDid }, init); 33 34export const getProfile = (ctx: BobbinContext, actor: string, init?: XrpcRequestInit) => 35 jsonGet<RecordView<ProfileRecord>>(ctx, 'sh.tangled.actor.getProfile', { actor }, init); 36 37export const getIssue = (ctx: BobbinContext, issue: string, init?: XrpcRequestInit) => 38 jsonGet<RecordView<IssueRecord>>(ctx, 'sh.tangled.repo.getIssue', { issue }, init); 39 40export const getPull = (ctx: BobbinContext, pull: string, init?: XrpcRequestInit) => 41 jsonGet<RecordView<PullRecord>>(ctx, 'sh.tangled.repo.getPull', { pull }, init); 42 43export const getRepos = (ctx: BobbinContext, repos: readonly string[], init?: XrpcRequestInit) => 44 jsonGet<RecordList<RepoRecord>>(ctx, 'sh.tangled.repo.getRepos', { repos }, init); 45 46export const getProfiles = ( 47 ctx: BobbinContext, 48 actors: readonly string[], 49 init?: XrpcRequestInit 50) => jsonGet<RecordList<ProfileRecord>>(ctx, 'sh.tangled.actor.getProfiles', { actors }, init); 51 52export const getIssues = (ctx: BobbinContext, issues: readonly string[], init?: XrpcRequestInit) => 53 jsonGet<RecordList<IssueRecord>>(ctx, 'sh.tangled.repo.getIssues', { issues }, init); 54 55export const getPulls = (ctx: BobbinContext, pulls: readonly string[], init?: XrpcRequestInit) => 56 jsonGet<RecordList<PullRecord>>(ctx, 'sh.tangled.repo.getPulls', { pulls }, init);