Barazo AppView backend barazo.forum
at main 58 lines 1.9 kB view raw
1import type { LEXICON_IDS } from '@singi-labs/barazo-lexicons' 2 3/** Record actions from the firehose. */ 4export type RecordAction = 'create' | 'update' | 'delete' 5 6/** Account status from identity events. */ 7export type RepoStatus = 'active' | 'takendown' | 'suspended' | 'deactivated' | 'deleted' 8 9/** A firehose record event (decoupled from @atproto/tap for testability). */ 10export interface RecordEvent { 11 id: number 12 action: RecordAction 13 did: string 14 rev: string 15 collection: string 16 rkey: string 17 record?: Record<string, unknown> 18 cid?: string 19 live: boolean 20} 21 22/** A firehose identity event (decoupled from @atproto/tap for testability). */ 23export interface IdentityEvent { 24 id: number 25 did: string 26 handle: string 27 isActive: boolean 28 status: RepoStatus 29} 30 31/** Interface for Tap client operations (for testability). */ 32export interface TapClient { 33 addRepos(dids: string[]): Promise<void> 34 removeRepos(dids: string[]): Promise<void> 35} 36 37/** Collections supported by Barazo. */ 38export const SUPPORTED_COLLECTIONS = [ 39 'forum.barazo.topic.post', 40 'forum.barazo.topic.reply', 41 'forum.barazo.interaction.reaction', 42 'forum.barazo.interaction.vote', 43] as const satisfies ReadonlyArray<(typeof LEXICON_IDS)[keyof typeof LEXICON_IDS]> 44 45export type SupportedCollection = (typeof SUPPORTED_COLLECTIONS)[number] 46 47/** Type guard: is the collection string one of the supported Barazo collections? */ 48export function isSupportedCollection(collection: string): collection is SupportedCollection { 49 return (SUPPORTED_COLLECTIONS as readonly string[]).includes(collection) 50} 51 52/** Maps collection NSIDs to short indexer names. */ 53export const COLLECTION_MAP: Record<SupportedCollection, string> = { 54 'forum.barazo.topic.post': 'topic', 55 'forum.barazo.topic.reply': 'reply', 56 'forum.barazo.interaction.reaction': 'reaction', 57 'forum.barazo.interaction.vote': 'vote', 58} as const