ATProto forum built with ESAV
at main 1.2 kB view raw
1// A document as stored in our global cache 2export interface EsavDocument { 3 cid: string; 4 doc: QueryDoc; 5} 6 7export interface QueryDoc { 8 "$metadata.uri": string; 9 "$metadata.cid": string; 10 "$metadata.did": string; 11 "$metadata.collection": string; 12 "$metadata.rkey": string; 13 "$metadata.indexedAt": string; 14 $raw?: Record<string, unknown>; 15 [key: string]: unknown; 16} 17 18// The state for a single query subscription 19export interface QueryState { 20 ecid: string; 21 result: string[]; // An ordered array of document URIs 22} 23 24// The server->client message we expect 25export interface QueryDeltaMessage { 26 type: 'query-delta'; 27 documents?: Record<string, EsavDocument>; 28 queries?: Record<string, QueryState>; 29} 30 31// The client->server message for subscribing 32export interface SubscribeMessage { 33 type: 'subscribe'; 34 queryId: string; 35 esquery: Record<string, any>; 36 ecid?: string; // Optional last known ECID 37} 38 39// The client->server message for unsubscribing 40export interface UnsubscribeMessage { 41 type: 'unsubscribe'; 42 queryId: string; 43} 44 45export type LogEntryType = 'incoming' | 'outgoing' | 'status' | 'error'; 46 47export interface LogEntry { 48 id: number; 49 timestamp: Date; 50 type: LogEntryType; 51 payload: any; 52}