listedCodebase
The record at the signed-in account's codes.tcm.codebase/<name>, if there's one.
import type { OAuthSession } from "#codebase/tcmts/atproto"; import { CODEBASE_COLLECTION } from "#codebase/tcmts/records"; import type { CodebaseRecord } from "#codebase/tcmts/records"; export async function listedCodebase( s: OAuthSession, name: string, ): Promise<{ cid: string; value: CodebaseRecord } | undefined> { const q = new URLSearchParams({ repo: s.did, collection: CODEBASE_COLLECTION, rkey: name }); const got = await fetch(`${s.pds}/xrpc/com.atproto.repo.getRecord?${q}`, { headers: { accept: "application/json" }, }); if (got.ok) return (await got.json()) as { cid: string; value: CodebaseRecord }; if (got.status !== 400 && got.status !== 404) throw new Error( `reading at://${s.did}/${CODEBASE_COLLECTION}/${name}: ${got.status} ${await got.text().catch(() => "")}`, ); return undefined; }