Suite of AT Protocol TypeScript libraries built on web standards
21
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 24 lines 598 B view raw
1import { isValidRecordKey } from "@atp/syntax"; 2 3export type LexiconRecordKey = 4 | "any" 5 | "nsid" 6 | "tid" 7 | `literal:${string}`; 8 9export function isLexiconRecordKey<T>(key: T): key is T & LexiconRecordKey { 10 return ( 11 key === "any" || 12 key === "nsid" || 13 key === "tid" || 14 (typeof key === "string" && 15 key.startsWith("literal:") && 16 key.length > 8 && 17 isValidRecordKey(key.slice(8))) 18 ); 19} 20 21export function asLexiconRecordKey(key: unknown): LexiconRecordKey { 22 if (isLexiconRecordKey(key)) return key; 23 throw new Error(`Invalid record key: ${String(key)}`); 24}