/** * A topic's list of files — SPEC §6.14 "A file's list of other files"; record * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-topic-keeps-its-own-list-of-files.md * * A topic lists files from any Folder, one entry per file, by the file's id. * An entry is a `kind:1851` change on the topic: `a` and `O` name the topic, * `field` is `lists:`, `value` is `true` or `false`, `h` is the topic's * Folder, then `ts`, then `["o", ]` naming the listed file. The newest * entry per topic and file counts (§6.3). * * `O` is the file the change is about and `o` another file it points at * (why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-change-is-about-its-file-as-a-comment-is.md), * so `#o` asks which topics list a file and `#O` asks what changed on a topic, * and a file's own changes never include a topic's entry about it. * * Here rather than in each app because Peek, Ship and Leaf all add, remove * and read entries, and a reader rule kept in one of them only is a list that * reads differently in the next. * * ## What a listing is not * * It grants nothing: who reads the listed file is its own Folder's rule. It is * not a mention, not a parent and not a Folder's listing, so Mentioned in, the * archive chain and a Folder move all ignore it. It carries no `p`, so it adds * nobody to the file (§11.8). */ import { type SignedEvent, type UnsignedEvent } from '@estiva-app/protocol'; import { type Following, type MembershipRead } from '@estiva-app/conversation'; import { type ForeignObject, type ProjectionCache, type QueryFn } from './projection.js'; /** * The file kinds a listed id is looked for under by default: topic, document, * project, issue. Never a bare `#d`, since a Folder's `kind:39000` shares its * uuid (§11.1). An app that knows more kinds from manifests passes them. */ export declare const LISTED_FILE_KINDS: readonly number[]; /** The field an entry for `file` sets: `lists:`. */ export declare function listsField(file: string): string; /** The file a list carries entries on, as a write needs it. */ export interface ListHolder { /** Its address, `::`. */ address: string; /** Its Folder, read from its root (`folderOf`), never the Folder it was opened from (§6.2). */ folder: string; } /** * Put a file on a topic's list: `[kind:1851 lists: = true]`, signed by * whoever adds it. `file` is the listed file's id (its `d`), from any Folder. */ export declare function planListInTopic(pubkey: string, createdAtMs: number, args: { topic: ListHolder; file: string; note?: string; }): UnsignedEvent[]; /** Take a file off a topic's list: `[kind:1851 lists: = false]`. {@link planListInTopic} in reverse. */ export declare function planRemoveFromTopic(pubkey: string, createdAtMs: number, args: { topic: ListHolder; file: string; note?: string; }): UnsignedEvent[]; /** Which topics list a file: every entry naming its id in `o`. Fold with {@link listEntries}. */ export declare function topicsOfFileFilter(file: string): Record; /** A topic's changes, its list entries among them: `#O` on its id. Fold with {@link listEntries}. */ export declare function topicListFilter(topic: string): Record; /** The newest entry for one list and one file. */ export interface ListEntry { /** The address of the file keeping the list (a topic). */ list: string; /** The listed file's id. */ file: string; /** The entry's Folder: its first `h` with a value. */ folder: string; /** `true` when the newest entry lists the file. */ listed: boolean; event: SignedEvent; } /** * The newest entry per list and file, from any mix of changes: the reader * rules of §6.14. A change counts as an entry only when its field is * `lists:`, one of its `o` tags is that same `` (an `o` the field does * not name is some other relation, a move's new parent for one), its `a` * names a file whose `d` is its `O`, `` is not that file itself, and it * names a Folder. Anything else is skipped, not folded, so a malformed entry * never hides a good one. A `value` other than exactly `true` does not list * the file. * * `folderOfList` is §6.2's Folder check against each list's root, applied * before the fold: an entry filed in any other Folder must not become the * newest and hide the good one before it. A list it answers no Folder for (an * unread root, or one naming none) keeps no entry. Without it the check is the * caller's; {@link topicsOfFile} and {@link topicList} pass it. */ export declare function listEntries(events: readonly SignedEvent[], folderOfList?: (list: string) => string | null | undefined): ListEntry[]; /** A topic that lists a file. */ export interface FileTopic { /** The topic's address. */ address: string; /** The topic's root, as the reader read it. */ root: SignedEvent; entry: ListEntry; } /** * Which topics list a file — `{kinds:[1851], "#o":[]}`, folded per topic. * * Keeps an entry only when its newest value lists the file, it is on a topic * (only topics' lists are read, Miky 2026-10-30), the topic's root is one the * reader can read (a deleted or unreadable topic drops out), and the entry is * filed in the topic's own Folder (§6.2). Two reads: the entries, then the * topics' roots. */ export declare function topicsOfFile(query: QueryFn, file: string): Promise; /** A file on a topic's list. */ export interface ListedFile { /** The listed file's id. */ file: string; /** Its address when exactly one file the reader can read holds the id, else `null`: not drawn, not counted. */ address: string | null; /** The resolved file's Folder, from its root (§6.2), when it names one; `null` when unresolved or it names none. */ folder: string | null; entry: ListEntry; } /** * A topic's list, by the topic's address: its entries whose newest value * lists the file, filed in the Folder the topic's root names (§6.2; read here, * never taken from the caller), in no promised order (sort as the design * says; `entry.event` carries the time), each id resolved over `fileKinds` by * `#d`. A topic the reader cannot read, or whose root names no Folder, lists * nothing. An id held by none the reader can read, or by two, resolves to * `null`: a consumer draws and counts only the resolved ones (§3.2, the count * is the disclosure). */ export declare function topicList(query: QueryFn, topic: string, options?: { fileKinds?: readonly number[]; }): Promise; /** * Many topics' lists at once, by address (TOP-4, Peek's Topics screen): the * rules of {@link topicList} for each, in three requests whatever the number * of topics (one more per 100 listed files): the roots, every topic's changes * (one `#O` filter per topic) and the batched `#d` resolve, where one * `topicList` per topic would be three requests each and trips a relay's rate * limit at a few dozen topics. Every address asked for is a key; one that * lists nothing, or that the reader cannot read, maps to `[]`. */ export declare function topicLists(query: QueryFn, topics: readonly string[], options?: { fileKinds?: readonly number[]; }): Promise>; /** A topic as {@link readTopics} reads it. */ export interface ReadTopic { address: string; /** As its roots and changes draw it: its title and summary slots, and `archived`, its own or its parent's (§6.5). */ object: ForeignObject; /** Its Folder, from its root (§6.2): where an entry on its list is filed. */ folder: string; /** Its first record's time, Unix seconds: its time in the order of topics when nothing has happened in it since. */ createdAt: number; /** Its list, as {@link topicLists} reads it. */ listed: ListedFile[]; /** * How the viewer is in it (§11.8 *Places and following*), by the shared * fold every app uses: a level they chose, an Add or a join, or having made * it, over all history. Writing in it is not one. A space's team default is * not read here (no roster, no private teams list): Ship's Topics draws no * space. * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/writing-in-a-place-never-follows-it.md */ following: Following; /** The viewer is in it: `following.in`. */ yours: boolean; /** * A team marks it one of its spaces (§3.3): its entry on a team's * relay-signed list carries the role `space`. Ship's Topics never draws one. * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-space-is-the-teams-own-mark-on-a-topic-it-lists.md */ space: boolean; } /** Every topic the viewer can read, and the membership read that judges their dots. */ export interface TopicsRead { me: string; topics: ReadTopic[]; /** Folded from the viewer's part inside the horizon: `mentioned` says which messages name them. */ membership: MembershipRead; /** The topics where a message inside the horizon names the viewer: a mention lights at any level, and when they are not in (§11.8). */ mentionedIn: ReadonlySet; /** * The conversations the viewer is in, by {@link conversationKey} (topic and * root id): the second they first wrote in one or were named in it, over all * history — so a reply of theirs from before the reply floor still makes a * later reply light at Important. */ inConversations: ReadonlyMap; } /** A conversation's key in {@link TopicsRead.inConversations}: the topic it is anchored to and its root's id. */ export declare function conversationKey(topic: string, root: string): string; /** Whether an event answers a filter, as NIP-01 reads it: kinds, authors, `#x` tags, `since` and `until`. */ export declare function answers(event: SignedEvent, filter: Record): boolean; /** * Everything the filters match, however many: each asked with a page's * `limit`, and a filter whose answer filled it asked again from its oldest * second down (`until`), until a page comes back short. One request when * nothing fills a page, as at Miky's scale; never a silent cut at the relay's * cap. A second holding a page's worth on its own ends the walk there. */ export declare function readAll(query: QueryFn, filters: readonly Record[]): Promise; /** * Every topic the viewer can read, once (SHIPS-2): each with its list, its * archive (its own, or with its project), its Folder, whether it is the * viewer's and whether a team marks it a space (SHIPS-3) — the one read Ship's * Topics, a topic's page and Add to topic draw from, and Leaf's Add to topic too. * * Three rounds whatever the number of topics: every `kind:30840` root; then * the topics as drawn, their lists, the viewer's part in them and the team * lists naming them; then the * listed ids and archived parents. No conversation is read here: * {@link topicConversations} is for a page that draws them. * * The viewer's part is one read over all history, narrowed to the topics — * the changes naming them, what they wrote, what names them — and the * horizon's membership is folded from the part of it inside the horizon, as * {@link membershipQueries} would have read it for these files. On * production, QA-2's horizon read over every file was 500 KB; over the topics * it is a few. * * How the viewer is in each topic is {@link followingOf} over its root and * the changes naming them (TEA-6), the fold Peek's switch reads too. * `parentsListRead`, where the relay offers the list read (NIP-11 * `file_list`): the parents walked to see whether a topic is archived with one * are read as their current values (§6.13), not every change ever made to them * (ALO-15). The topics themselves are read as before, their text included. * * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/a-topic-keeps-its-own-list-of-files.md */ export declare function readTopics(query: QueryFn, me: string, options?: { cache?: ProjectionCache; fileKinds?: readonly number[]; nowSeconds?: number; parentsListRead?: boolean; }): Promise; /** * What Add to topic offers: the open topics in a Folder the viewer is in — * `folders`, the Folders the relay lists for them, where it accepts their * entry — theirs first, then the rest, each A–Z. An archived topic, its own * or with its project, is read-only and is not offered. */ export declare function addableTopics(read: TopicsRead, folders: ReadonlySet): { yours: ReadTopic[]; others: ReadTopic[]; }; /** A topic's conversations in Peek: how many, and whether one has something new for the viewer. */ export interface TopicConversation { /** Thread roots addressed to the topic, as Peek's Topics badge counts them. */ conversations: number; /** Peek's dot: only on an open topic of the viewer's. */ unread: boolean; /** How many of its conversations have something new for the viewer, judged as the dot is: `unread` is `fresh > 0`. */ fresh: number; } /** * Each topic's conversations and dot, as Peek's Topics shows them (SHIPS-2): * the count is the thread roots addressed to the topic (`conversationsOf`), * the dot is §11.8's *What is unread on a place* ({@link isUnreadOnPlace}) at * the viewer's level on it ({@link ReadTopic.following}): at Important a new * conversation, or a reply in one they wrote in or were named in; at All every * message since they chose it; a mention at any level, and when they are not * in. An archived topic lights nothing. `fresh` is the same judge over each * thread alone (a root and its replies), so Ship's Topics can say how many of * them are new where Peek shows the dot (SHIPS-3). * * The read state and the muted list are encrypted, so the app hands in what * it holds: `merged` (the merged markers, once the first merge has landed) * and `muted`. Replies are read only for the topics a dot is judged on — the * open ones the viewer is in or is named in — and only from the latest second * before which none can be unread: the thread rule's cut-over and the reply * floor (§11.3: a reply is read by its thread's marker or the floor, never the * topic's). Not from when the viewer came in: a reply of theirs from before * then still puts them in its conversation. * why: https://github.com/estiva-app/estiva-docs/blob/main/decisions/writing-in-a-place-never-follows-it.md */ export declare function topicConversations(read: TopicsRead, query: QueryFn, state: { merged: Readonly>; muted: ReadonlySet; nowSeconds?: number; }, options?: { cache?: ProjectionCache; }): Promise>; //# sourceMappingURL=topics.d.ts.map