import type { CidString } from "@atproto/lex"; import type { DidString, NsidString } from "@atproto/syntax"; export type { CidString } from "@atproto/lex"; export type { DidString, HandleString, NsidString, RecordKeyString } from "@atproto/syntax"; /** The AT URI for a repo. Currently it needs to be a DID. */ export type RepoURI = `at://${DidString}`; /** The AT URI for a collection. Currently it needs to be a DID. */ export type CollectionURI = `at://${DidString}/${N}`; /** The AT URI for a record. Currently it needs to be a DID. */ export type RecordURI = `at://${DidString}/${N}/${string}`; /** * A path to locate fields in AT records. For more read the [spec](https://tangled.org/microcosm.blue/RecordPath). * For a Bluesky "like" record: * * ```json * { * "$type": "app.bsky.feed.like", * "createdAt": "2024-01-15T00:00:00.000Z", * "subject": { * "uri": "at://did:plc:pxa3amkp7jhfclaads3zud7q/app.bsky.feed.post/3mjkx2hpvqc2t", * "cid": "bafyreicuxyp5rmsrqsf3v63ww6gc3j7q6cp7qyk6bv47c3bqkj2gzswiqq" * } * } * ``` * * The RecordPaths are: * ``` * $type -- selects: "app.bsky.feed.like" * createdAt -- "2026-04-15T00:00:00.000Z" * subject -- the entire { uri: .., cid: ..} sub-object * subject.uri -- "at://did:plc:pxa3amkp7jhfclaads3zud7q/app.bsky.feed.post/3mjkx2hpvqc2t" * subject.cid -- "bafyreicuxyp5rmsrqsf3v63ww6gc3j7q6cp7qyk6bv47c3bqkj2gzswiqq" * ``` **/ export type RecordPath = string; export type ATRecord< N extends NsidString = NsidString, T = N extends keyof LexiconMap ? LexiconMap[N] : any, > = { cid: CidString; uri: RecordURI; value: T; }; /** Add the NSID and Main type schema for a lexicon generated by the `lex` CLI. * ```ts * import type * as like from "./schemas/app/bsky/feed/like"; * import type * as post from "./schemas/app/bsky/feed/post"; * * declare module "./utils" { * interface LexiconMap { * [post.$nsid]: post.Main; * [like.$nsid]: like.Main; * } * } * ``` */ export interface LexiconMap {} export type LexiconNsids = keyof LexiconMap & NsidString;