Skip to content
67 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

The docs service answers every artifacts call: docs can be made, listed, shared, moved, trashed, restored, searched, versioned and edited live in their own rooms, agents read, write and recall them only where their person and everyone in the conversation can, and folio events go out on the bus, while Docs' pages keep working as before.1/**
2 * The folio RPC: every method in FOLIO_RPC_METHODS (packages/contracts
3 * folios.ts) and the Folios method that answers it. Typed against the
4 * contract's list, so a method added there and not here fails the
5 * typecheck. src/index.ts asks this table first, then Docs' own switch.
6 */
7import type { FolioRpcMethod } from "@g1t/contracts";
8
9import type { Folios } from "./service.ts";
10
11// Bodies come from other services as JSON; each method checks its own.
12// eslint-disable-next-line @typescript-eslint/no-explicit-any
13type Handler = (service: Folios, args: any) => Promise<unknown>;
14
15export const FOLIO_RPC: Record<FolioRpcMethod, Handler> = {
16 folio_list: (s, a) => s.list(a),
17 folio_sidebar: (s, a) => s.sidebar(a),
18 folio: (s, a) => s.folio(a),
The docs service answers folio_page with a folio and what its page shows around it, a space can let its editors share what is in it, and someone asking for access to an artifact is told to wait when they already asked for it in the last day.19 folio_page: (s, a) => s.page(a),
The docs service answers every artifacts call: docs can be made, listed, shared, moved, trashed, restored, searched, versioned and edited live in their own rooms, agents read, write and recall them only where their person and everyone in the conversation can, and folio events go out on the bus, while Docs' pages keep working as before.20 create_folio: (s, a) => s.create(a),
21 update_folio: (s, a) => s.update(a),
22 move_folio: (s, a) => s.move(a),
23 duplicate_folio: (s, a) => s.duplicate(a),
24 trash_folio: (s, a) => s.trash(a),
25 restore_folio: (s, a) => s.restore(a),
26 delete_folio: (s, a) => s.delete(a),
27 folio_trash: (s, a) => s.trashed(a),
28 favorite_folio: (s, a) => s.favorite(a),
29 folio_content: (s, a) => s.content(a),
30 edit_folio: (s, a) => s.edit(a),
31 folio_access: (s, a) => s.access(a),
32 set_folio_grant: (s, a) => s.setGrant(a),
33 set_folio_general_access: (s, a) => s.setGeneralAccess(a),
34 request_folio_access: (s, a) => s.requestAccess(a),
35 join_space: (s, a) => s.joinSpace(a),
36 leave_space: (s, a) => s.leaveSpace(a),
37 search_folios: (s, a) => s.search(a),
38 folio_versions: (s, a) => s.versions(a),
39 folio_version: (s, a) => s.version(a),
40 restore_folio_version: (s, a) => s.restoreVersion(a),
41 folio_templates: (s, a) => s.templates(a),
42 save_folio_template: (s, a) => s.saveTemplate(a),
43 delete_folio_template: (s, a) => s.deleteTemplate(a),
44 export_folio: (s, a) => s.export(a),
45 folio_suggestions: (s, a) => s.suggestions(a),
46 decide_folio_suggestion: (s, a) => s.decideSuggestion(a),
47 folio_proposals: (s, a) => s.proposals(a),
48 decide_folio_proposal: (s, a) => s.decideProposal(a),
49 folio_thread: (s, a) => s.thread(a),
50 folio_threads: (s, a) => s.threads(a),
51 query_tile: (s, a) => s.queryTile(a),
52 query_dataset: (s, a) => s.queryDataset(a),
53 query_dataset_for_agent: (s, a) => s.queryDatasetForAgent(a),
54 folios_for_agent: (s, a) => s.foliosForAgent(a),
55 read_folio_for_agent: (s, a) => s.readForAgent(a),
56 create_folio_as_agent: (s, a) => s.createAsAgent(a),
57 edit_folio_as_agent: (s, a) => s.editAsAgent(a),
58 share_folio_as_agent: (s, a) => s.shareAsAgent(a),
59 recall_folios_for_agent: (s, a) => s.recallForAgent(a),
60 stale_folios_for_agent: (s, a) => s.staleForAgent(a),
61 mark_folio_current: (s, a) => s.markCurrent(a),
62 reindex_folios: (s, a) => s.reindex(a),
63};
64
65export function folioHandler(method: string): Handler | null {
66 return Object.prototype.hasOwnProperty.call(FOLIO_RPC, method) ? FOLIO_RPC[method as FolioRpcMethod] : null;
67}