Monorepo for Tangled
tangled.org
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 getProfile = (ctx: BobbinContext, did: string, init?: XrpcRequestInit) =>
34 jsonGet<RecordView<ProfileRecord>>(
35 ctx,
36 "sh.tangled.actor.getProfile",
37 { actor: `at://${did}/sh.tangled.actor.profile/self` },
38 init
39 );
40
41export const getIssue = (ctx: BobbinContext, issue: string, init?: XrpcRequestInit) =>
42 jsonGet<RecordView<IssueRecord>>(ctx, "sh.tangled.repo.getIssue", { issue }, init);
43
44export const getPull = (ctx: BobbinContext, pull: string, init?: XrpcRequestInit) =>
45 jsonGet<RecordView<PullRecord>>(ctx, "sh.tangled.repo.getPull", { pull }, init);
46
47export const getRepos = (ctx: BobbinContext, repos: readonly string[], init?: XrpcRequestInit) =>
48 jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getRepos", { repos }, init);
49
50export const getReposByRepoDids = (
51 ctx: BobbinContext,
52 dids: readonly string[],
53 init?: XrpcRequestInit
54) => jsonGet<RecordList<RepoRecord>>(ctx, "sh.tangled.repo.getReposByRepoDids", { dids }, init);
55
56export const getProfiles = (
57 ctx: BobbinContext,
58 actors: readonly string[],
59 init?: XrpcRequestInit
60) => jsonGet<RecordList<ProfileRecord>>(ctx, "sh.tangled.actor.getProfiles", { actors }, init);
61
62export const getIssues = (ctx: BobbinContext, issues: readonly string[], init?: XrpcRequestInit) =>
63 jsonGet<RecordList<IssueRecord>>(ctx, "sh.tangled.repo.getIssues", { issues }, init);
64
65export const getPulls = (ctx: BobbinContext, pulls: readonly string[], init?: XrpcRequestInit) =>
66 jsonGet<RecordList<PullRecord>>(ctx, "sh.tangled.repo.getPulls", { pulls }, init);