UI without documents: every page a node, the library root the first; moving, copying, exporting and importing any node
The page has one head for whatever node is the page (crumbs from the library's title, a byline of
sections and nodes, its flags and ⋯); in panes the first pane is the page and every other pane has
a section's head, whatever node it shows. A prompt (a node whose sections cite its sentences) is
folded wherever it shows. The library root's sections open in place like any others; an address
outside the hoisted node un-hoists to the library, and Esc at a hoisted page's top steps out to its
parent's.
What acts on a node and everything under it acts on the node the reader is on (the focused
section, or the one a focused note or selection is in): M moves it under any node (the jump box as
a picker, the root offered too), /duplicate copies it just after itself, /export saves it, /import
reads a file in as its last child (place() prefixes the titles down to the parent), /linkhere scans
it, S lists its links (on the root, the whole library's), history's f filters to it and r reverts
it. Every node's ⋯ offers them.
The documents menu, its mode and keys, /new, /open, /rename and /linkdoc are gone; m is free and
the top bar's left is a plain label with the library's name. Addresses are /n/<node id>, and / the
root; an old /doc/ address shows the library.
Server: /api/docs gives way to /api/nodes/<id>/{tree,export,import}; link jobs take scope "node" or
"library" and pending lists ?node=<id>&subtree=1. Step-1 shims removed: docOf/documents, all of
core/library.ts (IMPORT_MAX and importTree move to seed.ts, address and resolve to address.ts),
docArg, and the old single-document replica check. revertDocTo is revertSubtreeTo.
The page scrolls the focus into view only when the focus, the page or the mode changed, not on a
render for something that arrived in the background; row flags give way on a narrow screen.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014yB6q4BHMwptTX3YFtkRab
This commit is contained in:
1 parent
e6e4ad8d26
commit
bed47c0c7a
31 files changed
+789
-1153
No files matched your search
+39
-80
@@ -6,18 +6,18 @@
|
||||
* In development it also hosts Vite; in production it serves the built files.
|
||||
*
|
||||
* The whole library is one database: /api/tree, /api/ops, /api/sync… act on all of it, and
|
||||
* /api/docs lists the root's children, with a few routes scoped to one. See README.md for the list.
|
||||
* /api/nodes/<id>/… on one node and what is under it. See README.md for the list.
|
||||
*/
|
||||
import { existsSync, mkdirSync, readFileSync } from "node:fs";
|
||||
import { createServer, type IncomingMessage, type ServerResponse } from "node:http";
|
||||
import { userInfo } from "node:os";
|
||||
import { extname, join, resolve } from "node:path";
|
||||
import { VersionVector } from "loro-crdt";
|
||||
import { IMPORT_MAX, createDoc, deleteDoc, duplicateDoc, findTop, importDoc, listDocs, renameDoc, topName } from "../src/core/library";
|
||||
import { Doc, OpError, descendants, topOf, type NodeId, type Op, type Snap } from "../src/core/model";
|
||||
import { Doc, OpError, descendants, type NodeId, type Op } from "../src/core/model";
|
||||
import { encodeVV, history } from "../src/core/repo";
|
||||
import { FormatError, serializeDoc } from "../src/core/format";
|
||||
import { writeSeed } from "../src/core/seed";
|
||||
import { IMPORT_MAX, importTree, writeSeed } from "../src/core/seed";
|
||||
import { slugify } from "../src/core/text";
|
||||
import { mockLLM } from "../src/llm/mock";
|
||||
import { LLMUnavailable, type JsonReq, type LLM, type Req, type TurnReq } from "../src/llm/types";
|
||||
import { seed } from "../src/seed/tree";
|
||||
@@ -159,7 +159,6 @@ function needLLM(): LLM {
|
||||
if (!llm) throw new LLMUnavailable();
|
||||
return llm;
|
||||
}
|
||||
const titleOf = (v: unknown) => (typeof v === "string" ? v.replace(/\s+/g, " ").trim().slice(0, 200) : "");
|
||||
|
||||
/** A server-side write to a branch: saved shortly and announced to every replica. */
|
||||
function wrote(branch: string) {
|
||||
@@ -167,15 +166,6 @@ function wrote(branch: string) {
|
||||
announce({ branch, from: "api" });
|
||||
}
|
||||
|
||||
/** One document's entry in the listing. */
|
||||
const entry = (snap: Snap, id: NodeId) => listDocs(snap).find((d) => d.node === id)!;
|
||||
|
||||
/** A subtree on its own, as the tree route returns the library. */
|
||||
function subtree(snap: Snap, id: NodeId) {
|
||||
const ids = new Set([id, ...descendants(snap, id)]);
|
||||
return { root: id, nodes: Object.fromEntries([...ids].map((x) => [x, snap.nodes[x]])) };
|
||||
}
|
||||
|
||||
async function api(req: IncomingMessage, res: ServerResponse, url: URL) {
|
||||
const parts = url.pathname.split("/").slice(2).map(decodeURIComponent); // after /api/
|
||||
const [a, b] = parts;
|
||||
@@ -188,7 +178,6 @@ async function api(req: IncomingMessage, res: ServerResponse, url: URL) {
|
||||
model: llm?.model ?? null,
|
||||
library: store.id,
|
||||
branches: [...store.branches].map(([name, doc]) => ({ name, vv: vvHeader(doc) })),
|
||||
docs: store.list(),
|
||||
migrated: store.migrated(),
|
||||
wiki: wikiState,
|
||||
embed: embed ? (process.env.IE_EMBED === "fake" ? "fake" : "on") : "off",
|
||||
@@ -238,7 +227,7 @@ async function api(req: IncomingMessage, res: ServerResponse, url: URL) {
|
||||
}
|
||||
}
|
||||
|
||||
if (a === "docs") return docsApi(req, res, url, parts.slice(1));
|
||||
if (a === "nodes") return nodeApi(req, res, url, parts.slice(1));
|
||||
if (["events", "branch", "sync", "tree", "ops"].includes(a)) return libraryApi(req, res, url, a, b);
|
||||
if (await handleWiki(req, res, url)) return;
|
||||
if (url.pathname.startsWith("/api/links/")) nodeIndex.activate();
|
||||
@@ -331,27 +320,38 @@ async function opsApi(req: IncomingMessage, res: ServerResponse, name: string) {
|
||||
}
|
||||
|
||||
/**
|
||||
* /api/docs: the root's children, by node id or name (TEMPORARY: step 3 removes it). Creating,
|
||||
* renaming, copying and deleting one are ordinary commits on main; the browser makes the
|
||||
* same commits in its own replica.
|
||||
* One node and everything under it, by its id: the subtree as JSON with its conflicts, the text
|
||||
* format as a download, or a file in the text format imported under it. An import is an ordinary
|
||||
* commit on main; the browser makes the same commits in its own replica.
|
||||
*/
|
||||
async function docsApi(req: IncomingMessage, res: ServerResponse, url: URL, parts: string[]) {
|
||||
async function nodeApi(req: IncomingMessage, res: ServerResponse, url: URL, parts: string[]) {
|
||||
const method = req.method ?? "GET";
|
||||
const [slug, action, branch] = parts;
|
||||
const main = store.main;
|
||||
if (!slug) {
|
||||
if (method === "GET") return json(res, 200, store.list());
|
||||
if (method === "POST") {
|
||||
const title = titleOf((await readJson<{ title?: string }>(req)).title);
|
||||
if (!title) return json(res, 400, { error: "a new document needs a title" });
|
||||
const id = createDoc(main, title, USER);
|
||||
wrote("main");
|
||||
return json(res, 201, entry(main.snap(), id));
|
||||
}
|
||||
const [id, action, branch] = parts as [NodeId, string | undefined, string | undefined];
|
||||
const name = branch || "main";
|
||||
if (!validBranch(name)) return json(res, 400, { error: "not a branch name" });
|
||||
const doc = store.branches.get(name);
|
||||
if (!doc) return json(res, 404, { error: `no such branch: ${name}` });
|
||||
const snap = doc.snap();
|
||||
if (!id || !snap.nodes[id]) return json(res, 404, { error: `no such node: ${id ?? ""}` });
|
||||
|
||||
// GET /api/nodes/<id>/tree[/<branch>]: the subtree, as /api/tree returns the library.
|
||||
if (action === "tree" && method === "GET") {
|
||||
const ids = new Set([id, ...descendants(snap, id)]);
|
||||
return json(res, 200, { root: id, nodes: Object.fromEntries([...ids].map((x) => [x, snap.nodes[x]])), conflicts: doc.conflicts().filter((c) => [c.node, c.parent].some((x) => x && ids.has(x))) });
|
||||
}
|
||||
// POST /api/docs/import?name=file.md, with the file as the body.
|
||||
if (slug === "import" && !action && method === "POST") {
|
||||
const name = (url.searchParams.get("name") ?? "").replace(/^.*[\\/]/, "").slice(0, 200) || "import.md";
|
||||
// GET /api/nodes/<id>/export[/<branch>]: the text format, as a download.
|
||||
if (action === "export" && method === "GET") {
|
||||
const { text, skipped } = serializeDoc(snap, id);
|
||||
res.writeHead(200, {
|
||||
"content-type": "text/markdown; charset=utf-8",
|
||||
"content-disposition": `attachment; filename="${slugify(snap.nodes[id].title) || "untitled"}${name === "main" ? "" : `-${encodeURIComponent(name)}`}.md"`,
|
||||
"x-skipped": JSON.stringify(skipped),
|
||||
});
|
||||
return res.end(text);
|
||||
}
|
||||
// POST /api/nodes/<id>/import?name=file.md, with the file as the body: a new last child of the node (on main).
|
||||
if (action === "import" && !branch && method === "POST") {
|
||||
const file = (url.searchParams.get("name") ?? "").replace(/^.*[\\/]/, "").slice(0, 200) || "import.md";
|
||||
let text: string;
|
||||
try {
|
||||
text = (await readBody(req, IMPORT_MAX)).toString("utf8");
|
||||
@@ -359,58 +359,17 @@ async function docsApi(req: IncomingMessage, res: ServerResponse, url: URL, part
|
||||
if (err instanceof HttpError && err.status === 413) return json(res, 413, { error: `the file is too large to import (the limit is ${IMPORT_MAX / 1024 / 1024} MB)` });
|
||||
throw err;
|
||||
}
|
||||
const main = store.main;
|
||||
if (!main.snap().nodes[id]) return json(res, 404, { error: `no such node on main: ${id}` });
|
||||
try {
|
||||
const id = importDoc(main, text, name, { creator: USER });
|
||||
const top = importTree(main, text, file, { creator: USER, parent: id });
|
||||
wrote("main");
|
||||
return json(res, 201, entry(main.snap(), id));
|
||||
return json(res, 201, { node: top, title: main.snap().nodes[top].title });
|
||||
} catch (err) {
|
||||
if (err instanceof FormatError) return json(res, 422, { error: err.message, problems: err.problems });
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
const name = branch || "main";
|
||||
if (!validBranch(name)) return json(res, 400, { error: "not a branch name" });
|
||||
const doc = store.branches.get(name);
|
||||
if (!doc) return json(res, 404, { error: `no such branch: ${name}` });
|
||||
const id = findTop(doc.snap(), slug);
|
||||
if (!id) return json(res, 404, { error: `no such document: ${slug}`, missing: "document" });
|
||||
|
||||
if (!action) {
|
||||
if (method === "GET") return json(res, 200, entry(doc.snap(), id));
|
||||
if (method === "PATCH") {
|
||||
const title = titleOf((await readJson<{ title?: string }>(req)).title);
|
||||
if (!title) return json(res, 400, { error: "a title is needed" });
|
||||
renameDoc(main, id, title, USER);
|
||||
wrote("main");
|
||||
return json(res, 200, entry(main.snap(), id));
|
||||
}
|
||||
if (method === "DELETE") {
|
||||
deleteDoc(main, id, USER);
|
||||
wrote("main");
|
||||
return json(res, 200, { deleted: slug });
|
||||
}
|
||||
}
|
||||
if (action === "duplicate" && method === "POST") {
|
||||
const title = titleOf((await readJson<{ title?: string }>(req)).title) || `${main.snap().nodes[id].title} (copy)`;
|
||||
const copy = duplicateDoc(main, id, title, USER);
|
||||
wrote("main");
|
||||
return json(res, 201, entry(main.snap(), copy));
|
||||
}
|
||||
// GET /api/docs/<slug>/export[/<branch>]: the text format, as a download.
|
||||
if (action === "export" && method === "GET") {
|
||||
const { text, skipped } = serializeDoc(doc.snap(), id);
|
||||
res.writeHead(200, {
|
||||
"content-type": "text/markdown; charset=utf-8",
|
||||
"content-disposition": `attachment; filename="${topName(doc.snap().nodes[id].title)}${name === "main" ? "" : `-${encodeURIComponent(name)}`}.md"`,
|
||||
"x-skipped": JSON.stringify(skipped),
|
||||
});
|
||||
return res.end(text);
|
||||
}
|
||||
if (action === "tree" && method === "GET") {
|
||||
const snap = doc.snap();
|
||||
return json(res, 200, { ...subtree(snap, id), conflicts: doc.conflicts().filter((c) => [c.node, c.parent].some((x) => x && snap.nodes[x] && topOf(snap, x) === id)) });
|
||||
}
|
||||
if (action === "ops" && method === "POST") return opsApi(req, res, name);
|
||||
json(res, 404, { error: "not found" });
|
||||
}
|
||||
|
||||
@@ -481,7 +440,7 @@ createServer(async (req, res) => {
|
||||
}).listen(PORT, "127.0.0.1", () => {
|
||||
const nodes = Object.keys(store.main.snap().nodes).length;
|
||||
console.log(`Infinispand http://localhost:${PORT} model: ${llm ? `${llm.kind}${llm.model ? `: ${llm.model}` : ""}` : "off (set ANTHROPIC_API_KEY or CLAUDE_CODE_OAUTH_TOKEN to generate)"} data: ${DATA}`);
|
||||
console.log(`library: ${store.list().length} top-level sections, ${nodes} nodes, opened in ${startMs} ms`);
|
||||
console.log(`library: ${store.titles().length} top-level sections, ${nodes} nodes, opened in ${startMs} ms`);
|
||||
console.log(`web research: ${web.on ? `on (at most ${web.searches} searches and ${web.fetches} pages read per request)` : `off${web.why ? ` (${web.why})` : ""}`}`);
|
||||
console.log(
|
||||
`wikipedia: ${wikiMode === "live" ? `live (${wikiState.lang}.wikipedia.org, ${wikiState.contact ? "with" : "without"} a contact)` : wikiMode === "mock" ? "mock (fixtures, no network)" : "off"}`,
|
||||
|
||||
+6
-5
@@ -6,15 +6,14 @@
|
||||
* <data>/library.json starter files already imported (by file name), so a deleted one stays deleted
|
||||
*
|
||||
* Branch names are percent-encoded into file names, so no request can name a file outside it.
|
||||
* Writes are gathered for a moment before they go to disk: with every document in one file, a
|
||||
* Writes are gathered for a moment before they go to disk: with the whole library in one file, a
|
||||
* save per keystroke would rewrite the whole library each time. Replicas keep what has not been
|
||||
* saved and send it again, so a crash loses nothing that a browser still holds.
|
||||
*/
|
||||
import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
|
||||
import { join } from "node:path";
|
||||
import { FormatError } from "../src/core/format";
|
||||
import { listDocs } from "../src/core/library";
|
||||
import { Doc } from "../src/core/model";
|
||||
import { Doc, tops } from "../src/core/model";
|
||||
import { writeText } from "../src/core/seed";
|
||||
import { slugify } from "../src/core/text";
|
||||
import { SEED_KEY, migrate } from "./migrate";
|
||||
@@ -56,8 +55,10 @@ export class LibraryStore {
|
||||
return this.main.libraryId ?? "";
|
||||
}
|
||||
|
||||
list() {
|
||||
return listDocs(this.main.snap());
|
||||
/** The titles of the root's children on main, in order. */
|
||||
titles(): string[] {
|
||||
const snap = this.main.snap();
|
||||
return tops(snap).map((id) => snap.nodes[id].title);
|
||||
}
|
||||
|
||||
/** What the migration recorded, for browsers that still hold replicas of the old documents. */
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/**
|
||||
* Scanning a document or the whole library in the background: one job at a time, a node at a
|
||||
* Scanning a node and everything under it, or the whole library, in the background: one job at a time, a node at a
|
||||
* time, at bulk priority (a person's own requests to Wikipedia go first), with progress announced
|
||||
* and a cancel. Lookups are gathered across the next few nodes and asked together, 50 phrases a
|
||||
* request, which is most of what keeps a bulk pass affordable. A job started with `review` also has
|
||||
@@ -18,9 +18,9 @@ import type { Linker, Suggestion } from "./scan";
|
||||
|
||||
export interface JobState {
|
||||
id: string;
|
||||
scope: "doc" | "library";
|
||||
/** The document scanned, for a document job. */
|
||||
doc?: NodeId;
|
||||
scope: "node" | "library";
|
||||
/** The node scanned (with everything under it), for a node job. */
|
||||
node?: NodeId;
|
||||
title: string;
|
||||
state: "running" | "done" | "cancelled" | "failed";
|
||||
done: number;
|
||||
@@ -61,14 +61,14 @@ export class Jobs {
|
||||
) {}
|
||||
|
||||
/** Start a job over these nodes (in reading order). A running job is cancelled first. */
|
||||
start(scope: "doc" | "library", nodes: NodeId[], title: string, doc?: NodeId, review = false): JobState {
|
||||
start(scope: "node" | "library", nodes: NodeId[], title: string, node?: NodeId, review = false): JobState {
|
||||
this.cancel();
|
||||
const wiki = this.o.wiki();
|
||||
const spacing = wiki?.spacingMs ?? 0;
|
||||
const state: JobState = {
|
||||
id: Math.random().toString(36).slice(2, 10),
|
||||
scope,
|
||||
...(doc ? { doc } : {}),
|
||||
...(node ? { node } : {}),
|
||||
title,
|
||||
state: "running",
|
||||
done: 0,
|
||||
|
||||
+24
-21
@@ -7,8 +7,9 @@
|
||||
* stored for it, with determinations. review ("all", or "unmarked" to leave out [[marks]],
|
||||
* which a person typed) has the model reviewer judge what is undecided; `apply` is then the
|
||||
* approved links handed to the caller to make, and `review` the reviewer's report
|
||||
* GET /api/links/pending ?doc=<top's id or name>&node=<id>&tier=auto|suggest&limit=&offset=&all=1&claim=1
|
||||
* → { total, suggestions: [{ …, nodeTitle, top, path, sentence }], apply? };
|
||||
* GET /api/links/pending ?node=<id>&subtree=1&tier=auto|suggest&limit=&offset=&all=1&claim=1
|
||||
* → { total, suggestions: [{ …, nodeTitle, top, path, sentence }], apply? }; node alone is
|
||||
* that node, with subtree=1 everything under it too, and without node the whole library;
|
||||
* all=1 lists every entry whatever was decided, with its determinations; claim=1 hands
|
||||
* out the approved links no page has made yet (in `apply`), to be made by the caller
|
||||
* POST /api/links/accept { ids, author? } → applied with applyLinks as one commit by "linker"
|
||||
@@ -17,7 +18,8 @@
|
||||
* GET /api/links/related ?node=<id> → { related, degraded }; or POST { node, text, title, top, topTitle, ancestors }
|
||||
* GET /api/links/nearby ?node=<id>&k=5 → { nearby: [{ handle, title, top }] } (hybrid search on the node);
|
||||
* or POST { node, text, title, ancestors }
|
||||
* POST /api/links/jobs { scope: "doc" | "library", doc?, review? } → the job's state (doc: a top's id or name); it runs in the background
|
||||
* POST /api/links/jobs { scope: "node" | "library", node?, review? } → the job's state (node: a node's id, scanned with
|
||||
* everything under it; on the library root, the whole library); it runs in the background
|
||||
* (with review, the model reviewer judges what it finds, within IE_REVIEW_CALLS calls)
|
||||
* GET /api/links/jobs → { job } (the current or last one)
|
||||
* DELETE /api/links/jobs → cancel the running job
|
||||
@@ -27,8 +29,7 @@
|
||||
*/
|
||||
import type { IncomingMessage, ServerResponse } from "node:http";
|
||||
import { applyLinks, type LinkSpec } from "../../src/core/links";
|
||||
import { findTop } from "../../src/core/library";
|
||||
import { descendants, isLibraryRoot, tops, type Doc, type NodeId, type Op, type Snap } from "../../src/core/model";
|
||||
import { descendants, isLibraryRoot, label, tops, type Doc, type NodeId, type Op, type Snap } from "../../src/core/model";
|
||||
import type { Embedder } from "../embed";
|
||||
import { HttpError, abortOnClose, readJson as readBody, sendJson as send } from "../util";
|
||||
import type { Jobs } from "./jobs";
|
||||
@@ -57,12 +58,12 @@ class Bad extends HttpError {
|
||||
|
||||
const readJson = <T>(req: IncomingMessage) => readBody<T>(req, 4 * 1024 * 1024);
|
||||
|
||||
/** A child of the root by its node id or name (TEMPORARY: step 2 scopes by any node). */
|
||||
const docArg = (snap: Snap, v: string | null): NodeId | null => (v ? (findTop(snap, v) ?? null) : null);
|
||||
|
||||
/** The nodes of a top's tree (or of the library), in reading order: sections and notes with text. */
|
||||
export function scopeNodes(snap: Snap, doc: NodeId | null): NodeId[] {
|
||||
const roots = doc ? [doc] : tops(snap);
|
||||
/**
|
||||
* A node and everything under it (or, for none or the library root, the whole library but the
|
||||
* Wikipedia container), in reading order: the sections and notes with text.
|
||||
*/
|
||||
export function scopeNodes(snap: Snap, node: NodeId | null): NodeId[] {
|
||||
const roots = node && !isLibraryRoot(snap, node) ? [node] : tops(snap);
|
||||
const out: NodeId[] = [];
|
||||
for (const r of roots) for (const id of [r, ...descendants(snap, r)]) if (snap.nodes[id].body.trim() && !isLibraryRoot(snap, id)) out.push(id);
|
||||
return out;
|
||||
@@ -99,10 +100,10 @@ export function linkRoutes(deps: LinkDeps) {
|
||||
return send(res, 200, { ...r, entries: deps.pending.of(input.node), apply, review: report }), true;
|
||||
}
|
||||
if (route === "pending" && method === "GET") {
|
||||
const docId = docArg(snap, url.searchParams.get("doc"));
|
||||
if (url.searchParams.get("doc") && !docId) throw new Bad(`no document ${url.searchParams.get("doc")}`);
|
||||
const node = url.searchParams.get("node") as NodeId | null;
|
||||
const scope = node ? new Set([node]) : docId ? new Set(scopeNodes(snap, docId)) : undefined;
|
||||
const subtree = url.searchParams.get("subtree") === "1";
|
||||
if (node && subtree && !snap.nodes[node]) throw new Bad(`no node ${node}`);
|
||||
const scope = node ? new Set(subtree ? scopeNodes(snap, node) : [node]) : undefined;
|
||||
const tier = url.searchParams.get("tier");
|
||||
const all = url.searchParams.get("all") === "1";
|
||||
const apply = url.searchParams.get("claim") === "1" ? deps.pending.claim(snap, scope ?? scopeNodes(snap, null)) : undefined;
|
||||
@@ -160,13 +161,15 @@ export function linkRoutes(deps: LinkDeps) {
|
||||
if (method === "GET") return send(res, 200, { job: deps.jobs.current }), true;
|
||||
if (method === "DELETE") return send(res, 200, { cancelled: deps.jobs.cancel(), job: deps.jobs.current }), true;
|
||||
if (method === "POST") {
|
||||
const input = await readJson<{ scope?: string; doc?: string; review?: boolean }>(req);
|
||||
if (input.scope !== "doc" && input.scope !== "library") throw new Bad('scope is "doc" or "library"');
|
||||
const docId = input.scope === "doc" ? docArg(snap, input.doc ?? null) : null;
|
||||
if (input.scope === "doc" && !docId) throw new Bad(`no document ${input.doc ?? ""}`);
|
||||
const nodes = scopeNodes(snap, docId);
|
||||
const title = docId ? snap.nodes[docId].title : "the library";
|
||||
return send(res, 202, { job: deps.jobs.start(input.scope, nodes, title, docId ?? undefined, input.review === true) }), true;
|
||||
const input = await readJson<{ scope?: string; node?: string; review?: boolean }>(req);
|
||||
if (input.scope !== "node" && input.scope !== "library") throw new Bad('scope is "node" or "library"');
|
||||
const id = input.scope === "node" ? ((input.node ?? "") as NodeId) : null;
|
||||
if (id !== null && !snap.nodes[id]) throw new Bad(`no node ${input.node ?? ""}`);
|
||||
// The library root is the whole library, as a library job.
|
||||
const at = id && !isLibraryRoot(snap, id) ? id : null;
|
||||
const nodes = scopeNodes(snap, at);
|
||||
const title = at ? label(snap, at) : "the library";
|
||||
return send(res, 202, { job: deps.jobs.start(at ? "node" : "library", nodes, title, at ?? undefined, input.review === true) }), true;
|
||||
}
|
||||
}
|
||||
if (route === "status" && method === "GET") {
|
||||
|
||||
Reference in new issue
Block a user