takeCodebase
uses tcmts.registry.codebases, which uses tcmts.server.table, which uses tcmts.server.Table, which uses #tcm/host (database)
A listing Jetstream sent, made, changed or deleted: kept (not shown until it checks), and checked against its
author's repository (checkCodebase): an event alone changes nothing the registry shows.
import { CODEBASE_COLLECTION, parseCodebaseRecord } from "#codebase/tcmts/records"; import { checkCodebase, codebases, safeLex } from "#codebase/tcmts/registry"; import { enqueue } from "#codebase/tcmts/server"; import type { RawEvent } from "@bsky/jetstream"; export async function takeCodebase(e: RawEvent & { kind: "commit" }): Promise<void> { const uri = `at://${e.did}/${CODEBASE_COLLECTION}/${e.commit.rkey}`; const had = await codebases.findOne({ uri }); if (e.commit.operation !== "delete" && !had) { const r = parseCodebaseRecord( e.commit.rkey, e.commit.record instanceof Uint8Array ? safeLex(e.commit.record) : e.commit.record, ); if (!r) return; try { await codebases.insert({ uri, did: e.did, name: r.name, url: r.url, description: r.description, createdAt: r.createdAt, state: "pending", }); } catch { // (kept meanwhile) } } else if (!had) return; enqueue(checkCodebase, uri); }
uses
- tcmts.records.CODEBASE_COLLECTION
- tcmts.records.parseCodebaseRecord
- tcmts.registry.checkCodebase
- tcmts.registry.codebases
- tcmts.registry.safeLex
- tcmts.server.enqueue