Skip to content
68 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 artifacts service is services/artifacts, the Worker g1t-artifacts, bound as ARTIFACTS by the API, the site and the agents; its live rooms move to it with a Durable Object transfer from g1t-docs-service, and its database, bucket, indexes and queue keep their names. The git store's binding and settings are GITSTORE, its ops scripts gitstore-*, and workflow run artifacts keep their compatible API under run_artifacts modules. The deploy tool puts a Worker that has never deployed before the Workers in its stage that bind to it, and the deploy guide gives the cutover runbook.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),
19 folio_page: (s, a) => s.page(a),
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 attach_file_as_agent: (s, a) => s.attachAsAgent(a),
60 recall_folios_for_agent: (s, a) => s.recallForAgent(a),
61 stale_folios_for_agent: (s, a) => s.staleForAgent(a),
62 mark_folio_current: (s, a) => s.markCurrent(a),
63 reindex_folios: (s, a) => s.reindex(a),
64};
65
66export function folioHandler(method: string): Handler | null {
67 return Object.prototype.hasOwnProperty.call(FOLIO_RPC, method) ? FOLIO_RPC[method as FolioRpcMethod] : null;
68}