From faf5f66b351d98c14175e2b29aa34ad856d3c01f Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 4 Oct 2026 09:44:46 +0000 Subject: [PATCH 1/3] docs(devlog): plan the notes module Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XZQXJtCvJgbG1Z2H312KcS --- DEVLOG.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/DEVLOG.md b/DEVLOG.md index e6e642a46..61a06dd63 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -2,6 +2,35 @@ Plans and progress for work in flight. Newest first. +## 2026-10-04 · Notes: a page for everything + +Goal (Adeel): every resource, entity and topic has its own page (its note), next to free notes written by people or +the assistant. The assistant is the main writer and organiser; people can do everything it can. Notes link to anything +with @ (resources, people, entities) and # (topics). Free notes sit in a tree in the left navigation, like Notion; +pages of resources are opened from those resources. docs/notes.md. + +Model: a `page` has a title, a one-line summary (the context the assistant reads; refined by the AI when switched +on), a date, a place (PARA: project, area, resource, archive), a parent for the tree, the thing it's about (if any), a +body and who wrote it (a person or the assistant). Links found in the body are kept as edges, with backlinks, and show +in the graph. + +Todo: + +- [ ] Pages: create, read, change, move in the tree, archive, delete; a page per resource made on first open +- [ ] @ and # mentions: links and backlinks, a search to pick what to link +- [ ] Web app: tree explorer in the left navigation, page view with title, summary, date, place and backlinks; the + page of a recording or entity reached from its detail view +- [ ] Editor: BlockSuite (AFFiNE's block editor, OctoBase/Yjs documents) behind one component; plain text kept for + search and the assistant. Waits on Adeel's link for the exact editor +- [ ] AI title and summary refinement (notes.refine, on by default, can be switched off); costs to the activity ledger +- [ ] Assistant and MCP tools: find, read, write, link and file notes; changes by the assistant are undoable +- [ ] Self-organising: a routine files notes into PARA and links them to entities and topics, proposing what it isn't + sure of +- [ ] # topics move to the SKOS topics once the graph thread splits them from entities +- [ ] Attachments on a page, encrypted through the keyring +- [ ] Object storage (S3, or an rclone remote served as S3) in the setup wizard, no local storage; a downloadable + 256-bit storage key. Design proposal waiting on Adeel (changes existing installs) + ## 2026-10-04 · The graph, end to end Goal (Adeel): make the graph the one focus and nail it: a human explorer canvas, agent queries with rights, questions From 75186fc2410eff6c2e652762f428d54337d40e45 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 4 Oct 2026 09:51:46 +0000 Subject: [PATCH 2/3] feat(notes): pages for notes and every resource, with @ and # links Free notes in a tree and a page per recording, entity, collection or speaker, with title, one-line summary, date, PARA place and Markdown body. Mentions become links with backlinks; pages follow moved recordings and stay as free notes when their thing is deleted or merged away. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XZQXJtCvJgbG1Z2H312KcS --- DEVLOG.md | 4 +- docs/notes.md | 58 + fastapi_backend/app/api/v1/router.py | 2 + fastapi_backend/app/api/v1/routes/notebook.py | 145 ++ fastapi_backend/app/domain/deletion.py | 3 +- fastapi_backend/app/domain/entities.py | 4 +- fastapi_backend/app/domain/moving.py | 3 +- fastapi_backend/app/domain/notebook.py | 400 +++++ fastapi_backend/app/domain/store.py | 10 + fastapi_backend/app/schemas/notebook.py | 101 ++ fastapi_backend/tests/api/test_notebook.py | 157 ++ mkdocs.yml | 1 + nextjs-frontend/app/openapi-client/index.ts | 52 +- nextjs-frontend/app/openapi-client/sdk.gen.ts | 150 ++ .../app/openapi-client/types.gen.ts | 758 +++++++++- nextjs-frontend/openapi.json | 1288 ++++++++++++++++- 16 files changed, 3030 insertions(+), 106 deletions(-) create mode 100644 docs/notes.md create mode 100644 fastapi_backend/app/api/v1/routes/notebook.py create mode 100644 fastapi_backend/app/domain/notebook.py create mode 100644 fastapi_backend/app/schemas/notebook.py create mode 100644 fastapi_backend/tests/api/test_notebook.py diff --git a/DEVLOG.md b/DEVLOG.md index 61a06dd63..8307ae9b2 100644 --- a/DEVLOG.md +++ b/DEVLOG.md @@ -16,8 +16,8 @@ in the graph. Todo: -- [ ] Pages: create, read, change, move in the tree, archive, delete; a page per resource made on first open -- [ ] @ and # mentions: links and backlinks, a search to pick what to link +- [x] Pages: create, read, change, move in the tree, delete; a page per resource made on first open +- [x] @ and # mentions: links and backlinks, a search to pick what to link - [ ] Web app: tree explorer in the left navigation, page view with title, summary, date, place and backlinks; the page of a recording or entity reached from its detail view - [ ] Editor: BlockSuite (AFFiNE's block editor, OctoBase/Yjs documents) behind one component; plain text kept for diff --git a/docs/notes.md b/docs/notes.md new file mode 100644 index 000000000..6a1451f0c --- /dev/null +++ b/docs/notes.md @@ -0,0 +1,58 @@ +# Notes + +Every resource, entity and topic in Lens has a page of its own, and next to them sit free notes that people and the +assistant write. The assistant is the main writer and organiser; people can do everything it can. + +Status: **built**: pages over the API (free notes in a tree, a page per recording, entity, collection or speaker), +@ and # links with backlinks. **In progress**: the tree in the left navigation, the page view and its editor, AI +refinement of titles and summaries. **Planned**: assistant and MCP tools, a routine that files notes (PARA and the +ontology), attachments on encrypted object storage, pages in the graph, # links to SKOS topics. + +## A page + +| Field | What it is | +| --- | --- | +| title | One line, up to 200 characters | +| summary | One line on what the page holds: the context the assistant reads first. `summary_by` says who wrote it | +| date | The day it's about (default: the day it was written) | +| place | Where it's filed, in PARA: `project`, `area`, `resource` or `archive` | +| parent, position | Its place in the tree (free notes only) | +| about | What it's the page of, like `recording:12` or `entity:5`; empty for a free note | +| body | Markdown with mentions (below) | +| doc | The editor's own document state, if it keeps one (opaque to the server) | +| author | `person` or `assistant` | + +A thing's page is made the first time someone writes on it; until then `GET /api/v1/notes/about/{kind}/{id}` returns a +draft with its name and the pages that already link to it. A page follows its recording to another namespace. When a +thing is deleted, or an entity is merged into another, its page stays as a free note at the top of the tree, so +nothing written on it is lost. + +## Links + +The body links with mention tokens, which the editor and the assistant both write: + +```text +@[Weekly call](recording:12) @[Ada Lovelace](entity:5) @[Plans](page:3) #[Capsids](entity:9) +``` + +`@` links resources, people and other pages; `#` links topics (entities of type Topic, until topics become a SKOS +vocabulary of their own; see [the graph](graph.md)). `GET /api/v1/notes/targets?ns=&sign=&q=` offers what to link. +Links are kept as rows (`note_link`), so every page lists its backlinks; links to things that are gone or that the +reader can't see show without a name. + +## Access + +Pages belong to a namespace: anyone with a role there reads them, editors write, move and delete them. The pages of +recordings also need access to the recording. + +## Editor + +The page view uses AFFiNE's BlockSuite editor, whose documents are Yjs CRDTs, the format OctoBase stores and syncs. +The editor saves its document state in `doc` next to the Markdown; a change to the Markdown alone (the assistant's) +drops `doc`, so the editor rebuilds it from the Markdown. OctoBase is AGPL-3.0, so it would run as a separate service +for live co-editing rather than inside Lens. + +## Refine later + +Pages for people who see only some collections of a namespace; page history and undo; attachments; live co-editing +through OctoBase; pages and their links as nodes and relationships in the graph. diff --git a/fastapi_backend/app/api/v1/router.py b/fastapi_backend/app/api/v1/router.py index 85fb24028..e472f9ee7 100644 --- a/fastapi_backend/app/api/v1/router.py +++ b/fastapi_backend/app/api/v1/router.py @@ -26,6 +26,7 @@ jobs, metadata, namespaces, + notebook, notes, notifications, oauth, @@ -68,6 +69,7 @@ hierarchy, recordings, notes, + notebook, comments, files, fields, diff --git a/fastapi_backend/app/api/v1/routes/notebook.py b/fastapi_backend/app/api/v1/routes/notebook.py new file mode 100644 index 000000000..f6bf2a1dd --- /dev/null +++ b/fastapi_backend/app/api/v1/routes/notebook.py @@ -0,0 +1,145 @@ +"""Notes as pages (docs/notes.md): free notes in a tree, and the page of every resource, entity and topic. + +Pages belong to a namespace: anyone with a role there reads them, editors write them. A thing's own page is made the +first time someone writes on it; until then it reads as a draft. +""" + +from __future__ import annotations + +from typing import Any + +from fastapi import APIRouter, HTTPException, Query + +from app.api.deps import Access, Acl, CurrentUser, Db, Principal, Writer, domain_errors +from app.domain import auth, notebook, store +from app.domain.store import DB +from app.schemas.common import Ok +from app.schemas.notebook import LinkTarget, Page, PageCreate, PageDraft, PageItem, PageMove, PageTree, PageUpdate + +router = APIRouter(prefix="/notes", tags=["notes"]) + + +def _page(acl: Access, db: DB, pid: int, role: str = "viewer") -> dict[str, Any]: + try: + p = notebook.get(db, pid) + except KeyError: + raise HTTPException(404, "not found") from None + acl.need(p["space"], role) + return p + + +def _backlinks(acl: Access, db: DB, sid: int, targets: list[str]) -> list[dict[str, Any]]: + return notebook.backlinks(db, sid, targets) if targets else [] + + +def _out(acl: Access, db: DB, p: dict[str, Any], user: Principal) -> Page: + names = store.space_names(db) + links = notebook.links(db, p["id"]) + found = notebook.labels(db, [x["target"] for x in links]) + readable = set(acl.spaces()) if not user.admin else set(names) + out_links = [] + for x in links: + t = found.get(x["target"]) + seen = t is not None and t.get("space") in readable + out_links.append({**x, "name": t["name"] if seen else None, "namespace": names.get(t["space"]) if seen else None}) + writer = db.one("SELECT email FROM $r", r=store.R("account", p["created_by"])) if p.get("created_by") else None + targets = [f"page:{p['id']}"] + ([p["about"]] if p.get("about") else []) + return Page( + **{k: v for k, v in p.items() if k not in ("space", "created_by", "updated_by")}, + namespace=names.get(p["space"], ""), + created_by=(writer or {}).get("email"), + links=out_links, + backlinks=[b for b in _backlinks(acl, db, p["space"], targets) if b["page"] != p["id"]], + can_edit=user.can_write and auth.allows(acl.roles, p["space"], "editor"), + ) + + +@router.get("") +def list_pages(ns: str, user: CurrentUser, acl: Acl, db: Db, everything: bool = Query(False, alias="all")) -> PageTree: + """The namespace's free notes for the tree (no bodies), in order; `all=true` adds the pages of things.""" + sid = acl.namespace(ns) + return PageTree(namespace=ns, pages=[PageItem(**p) for p in notebook.tree(db, sid, everything)]) + + +@router.post("") +def create_page(body: PageCreate, user: Writer, acl: Acl, db: Db) -> Page: + """Write a free note (optionally inside `parent`), or the page of a thing (`about`, like "recording:12"), which + each thing has one of. Needs editor access to the namespace.""" + sid = acl.namespace(body.ns, "editor") + with domain_errors(): + pid = notebook.create( + db, sid, user.id, body.title, body.body, body.summary, body.date, body.place, body.parent, body.about, doc=body.doc + ) + return _out(acl, db, notebook.get(db, pid), user) + + +@router.get("/targets") +def link_targets( + ns: str, user: CurrentUser, acl: Acl, db: Db, q: str = "", sign: str = "@", limit: int = Query(20, ge=1, le=50) +) -> list[LinkTarget]: + """What a mention can link to, best matches first: `#` for topics; `@` for pages, recordings, people and other + entities, collections and speakers.""" + sid = acl.namespace(ns) + if sign not in ("@", "#"): + raise HTTPException(400, "sign is @ or #") + return [LinkTarget(**t) for t in notebook.search_targets(db, sid, q, sign, limit)] + + +@router.get("/about/{kind}/{key}") +def page_about(kind: str, key: int, user: CurrentUser, acl: Acl, db: Db) -> Page | PageDraft: + """The page of a recording, entity, collection or speaker: its page, or a draft while nobody has written one.""" + thing = f"{kind}:{key}" + with domain_errors(): + notebook._about(thing) + sid = notebook.owner(db, kind, key) + acl.need(sid, "viewer") + if kind == "recording": + rec = db.one("SELECT space, collection FROM $r", r=store.R("recording", key)) + acl.need_in(rec["space"], rec.get("collection")) + p = notebook.about(db, sid, thing) + if p: + return _out(acl, db, p, user) + name = notebook.labels(db, [thing]).get(thing, {}).get("name") or thing + return PageDraft( + namespace=store.space_names(db).get(sid, ""), + about=thing, + title=str(name).rsplit("/", 1)[-1], + backlinks=_backlinks(acl, db, sid, [thing]), + can_edit=user.can_write and auth.allows(acl.roles, sid, "editor"), + ) + + +@router.get("/{pid}") +def get_page(pid: int, user: CurrentUser, acl: Acl, db: Db) -> Page: + """A page with its body, its links (with their targets' current names) and the pages linking to it.""" + return _out(acl, db, _page(acl, db, pid), user) + + +@router.patch("/{pid}") +def update_page(pid: int, body: PageUpdate, user: Writer, acl: Acl, db: Db) -> Page: + """Change what's given. A new body without `doc` drops the editor's state, so it's rebuilt from the Markdown.""" + _page(acl, db, pid, "editor") + given = body.model_fields_set + kw: dict[str, Any] = {k: getattr(body, k) for k in ("summary", "date", "doc") if k in given} + if "place" in given: + kw["place"] = body.place or None + with domain_errors(): + notebook.update(db, pid, user.id, title=body.title, body=body.body, **kw) + return _out(acl, db, notebook.get(db, pid), user) + + +@router.post("/{pid}/move") +def move_page(pid: int, body: PageMove, user: Writer, acl: Acl, db: Db) -> Page: + """Move a free note in the tree: inside `parent` (null: the top), before `before` (null: at the end).""" + _page(acl, db, pid, "editor") + with domain_errors(): + notebook.move(db, pid, body.parent, body.before) + return _out(acl, db, notebook.get(db, pid), user) + + +@router.delete("/{pid}") +def delete_page(pid: int, user: Writer, acl: Acl, db: Db) -> Ok: + """Delete a page; the pages inside it move up a level. Needs editor access.""" + _page(acl, db, pid, "editor") + notebook.delete(db, pid) + return Ok() diff --git a/fastapi_backend/app/domain/deletion.py b/fastapi_backend/app/domain/deletion.py index 5e8f28d96..2657b6db8 100644 --- a/fastapi_backend/app/domain/deletion.py +++ b/fastapi_backend/app/domain/deletion.py @@ -19,7 +19,7 @@ import pathlib import shutil -from . import access as acc, files as filemod, render, store, video +from . import access as acc, files as filemod, notebook, render, store, video R = store.R # rows that belong to the recording @@ -173,6 +173,7 @@ def delete(db, cfg, rid, by=None): target=f"recording:{rid}", rec=R("recording", rid), ) + notebook.release(db, f"recording:{rid}") shutil.rmtree(video.frames_dir(cfg, rid), ignore_errors=True) shutil.rmtree(filemod.folder(cfg, rid), ignore_errors=True) for f in files: diff --git a/fastapi_backend/app/domain/entities.py b/fastapi_backend/app/domain/entities.py index 3991259cd..7695714a7 100644 --- a/fastapi_backend/app/domain/entities.py +++ b/fastapi_backend/app/domain/entities.py @@ -13,7 +13,7 @@ import re from collections import Counter, defaultdict, deque -from . import analyze, entity_setup, render, store +from . import analyze, entity_setup, notebook, render, store R = store.R TYPES = { @@ -795,6 +795,7 @@ def merge(db, keep, others, user=None): ] stmts = ["DELETE mentions WHERE entity = $o"] + (["INSERT RELATION INTO mentions $rows"] if rows else []) + ["DELETE $oref"] db.run(stmts, o=o["id"], oref=R("entity", o["id"]), rows=rows) + notebook.release(db, f"entity:{o['id']}") for key in [o["key"]] + sn["aliases"]: _add_alias(db, k["space"], key, k["id"]) db.q("UPDATE entity_override SET target = $k WHERE target = $o", k=k["id"], o=o["id"]) @@ -937,6 +938,7 @@ def remove(db, eid): if db.rows("SELECT id FROM mentions WHERE entity = $e LIMIT 1", e=e["id"]): raise ValueError(f"{e['name']} is mentioned: merge it into another entity, or hide it.") db.run(["DELETE entity_alias WHERE entity = $e", "DELETE $r"], e=e["id"], r=R("entity", e["id"])) + notebook.release(db, f"entity:{e['id']}") def link(db, a, b, check_spaces=True): diff --git a/fastapi_backend/app/domain/moving.py b/fastapi_backend/app/domain/moving.py index 3202b0043..9a7595255 100644 --- a/fastapi_backend/app/domain/moving.py +++ b/fastapi_backend/app/domain/moving.py @@ -18,7 +18,7 @@ import pathlib import shutil -from . import access as acc, auth, deletion, faces as facemod, jobs, metadata as md, render, speakers as spk, store +from . import access as acc, auth, deletion, faces as facemod, jobs, metadata as md, notebook, render, speakers as spk, store R = store.R # rows that belong to the recording and say which namespace they are in @@ -198,6 +198,7 @@ def move(db, cfg, rid, dst, rediarize=False, revoke_shares=False, by=None, colle home=home, ) deletion.forget(db, dst, fp, rec.get("path")) # it's in the new namespace now: its scans may find it again + notebook.follow(db, f"recording:{rid}", dst) revoked = auth.revoke_shares(db, rid, by) if revoke_shares else 0 _files(db, cfg, rec, rid, names[src], names[dst]) deletion.orphans(db, old_speakers, old_faces) # unnamed ones nothing else has any more diff --git a/fastapi_backend/app/domain/notebook.py b/fastapi_backend/app/domain/notebook.py new file mode 100644 index 000000000..b8a07aa50 --- /dev/null +++ b/fastapi_backend/app/domain/notebook.py @@ -0,0 +1,400 @@ +"""Notes as pages (docs/notes.md): free notes in a tree, and a page for every resource, entity and topic. + +A page belongs to one namespace. It has a title, a one-line summary (the context the assistant reads first), a date, +a place in PARA (project, area, resource, archive), a parent page for the tree, a body in Markdown and who wrote it +(a person or the assistant). A page about something (`about`, like "recording:12" or "entity:5") is that thing's own +page: there is at most one per thing, made the first time someone writes on it; free notes have no `about`. + +The body links to anything with mention tokens, which the editor and the assistant both write: + + @[Weekly call](recording:12) @[Ada Lovelace](entity:5) @[Plans](page:3) #[Capsids](entity:9) + +@ is for resources, people and other pages; # is for topics (entities of type TERM until topics become a SKOS +vocabulary of their own). Links are kept as note_link rows, so a page shows its backlinks and the graph sees them. + +The editor may also keep its own document state (`doc`, opaque: a BlockSuite/Yjs snapshot) next to the Markdown. A +change to the Markdown alone (the assistant's, say) drops that state so the editor rebuilds it from the Markdown. + +Refine later: pages for partial collection members, page history and undo, attachments, real-time co-editing. +""" + +from __future__ import annotations + +import datetime as dt +import re + +from . import store + +R = store.R +PLACES = ("project", "area", "resource", "archive") +AUTHORS = ("person", "assistant") +KINDS = ("recording", "entity", "collection", "speaker", "page") # what a page can link to +ABOUT = ("recording", "entity", "collection", "speaker") # what can have a page of its own +TITLE_MAX = 200 +SUMMARY_MAX = 300 +BODY_MAX = 200_000 +DOC_MAX = 2_000_000 +PAGES_MAX = 20_000 # per namespace +DEPTH_MAX = 12 +MENTION = re.compile(r"([@#])\[([^\]\n]{1,200})\]\(([a-z]+):(\d{1,18})\)") +FIELDS = ( + "record::id(id) AS id, space, title, summary, summary_by, date, place, parent, position, about, author, " + "created_by, updated_by, created_at, updated_at" +) + + +def _title(title): + title = " ".join(str(title or "").split()) + if not title: + raise ValueError("A page needs a title.") + if len(title) > TITLE_MAX: + raise ValueError(f"A title can have up to {TITLE_MAX} characters.") + return title + + +def _summary(summary): + summary = " ".join(str(summary or "").split()) + if len(summary) > SUMMARY_MAX: + raise ValueError(f"A summary is one line of up to {SUMMARY_MAX} characters.") + return summary or None + + +def _date(date): + if date in (None, ""): + return None + try: + return dt.date.fromisoformat(str(date)[:10]).isoformat() + except ValueError: + raise ValueError("A page's date looks like 2026-10-04.") from None + + +def _place(place): + if place in (None, ""): + return None + if place not in PLACES: + raise ValueError(f"A page's place is one of {', '.join(PLACES)}.") + return place + + +def _body(body): + body = str(body or "") + if len(body) > BODY_MAX: + raise ValueError(f"A page can have up to {BODY_MAX} characters.") + return body + + +def _about(about): + """('recording', 12) from 'recording:12', or ValueError.""" + kind, _, key = str(about or "").partition(":") + if kind not in ABOUT or not key.isdigit(): + raise ValueError(f"A page can be about a {', '.join(ABOUT[:-1])} or {ABOUT[-1]}, like recording:12.") + return kind, int(key) + + +def mentions(body): + """The links in a body, in order and once each: [(sign, kind, id, label)].""" + out, seen = [], set() + for sign, label, kind, key in MENTION.findall(body or ""): + if kind not in KINDS or (sign, kind, key) in seen: + continue + seen.add((sign, kind, key)) + out.append((sign, kind, int(key), label.strip())) + return out + + +def plain(body): + """The body as plain text: mentions become their labels, Markdown marks are dropped.""" + text = MENTION.sub(lambda m: m.group(2), body or "") + text = re.sub(r"!\[[^\]]*\]\([^)]*\)", "", text) + text = re.sub(r"\[([^\]]*)\]\([^)]*\)", r"\1", text) + text = re.sub(r"^[ \t]{0,3}(#{1,6}[ \t]+|>[ \t]?|[-*+][ \t]+(\[[ xX]\][ \t]+)?|\d+[.)][ \t]+)", "", text, flags=re.M) + text = re.sub(r"[*_`~]{1,3}", "", text) + return re.sub(r"\n{3,}", "\n\n", text).strip() + + +def owner(db, kind, key): + """The namespace a thing belongs to, or KeyError.""" + if kind == "page": + row = db.one("SELECT space FROM $r", r=R("note_page", int(key))) + else: + row = db.one("SELECT space FROM $r", r=R(kind, int(key))) + if not row or row.get("space") is None: + raise KeyError(f"{kind}:{key}") + return row["space"] + + +def get(db, pid): + """The page with its body, or KeyError.""" + p = db.one(f"SELECT {FIELDS}, body, doc FROM $r", r=R("note_page", int(pid))) + if not p: + raise KeyError(pid) + return p + + +def about(db, sid, thing): + """The page about this thing in namespace sid (its own page), or None while nobody has written one.""" + kind, key = _about(thing) + return db.one(f"SELECT {FIELDS}, body, doc FROM note_page WHERE about_key = $k LIMIT 1", k=f"{sid}:{kind}:{key}") + + +def tree(db, sid, everything=False): + """The namespace's pages without their bodies, for the explorer: free notes only, or every page.""" + where = "space = $s" if everything else "space = $s AND about = NONE" + rows = db.rows(f"SELECT {FIELDS} FROM note_page WHERE {where}", s=sid) + return sorted(rows, key=lambda p: (p.get("position") or 0, p["id"])) + + +def _check_parent(db, sid, pid, parent): + """ValueError unless `parent` is a page of the namespace that isn't `pid` or inside it.""" + if parent is None: + return None + seen, at = set(), int(parent) + while at is not None: + if at == pid: + raise ValueError("A page can't go inside itself.") + row = db.one("SELECT space, parent FROM $r", r=R("note_page", at)) + if not row or row["space"] != sid: + raise ValueError("Its parent has to be a page in the same namespace.") + seen.add(at) + if len(seen) > DEPTH_MAX: + raise ValueError(f"Pages go up to {DEPTH_MAX} levels deep.") + at = row.get("parent") + return int(parent) + + +def _last_position(db, sid, parent): + rows = db.values( + "SELECT VALUE position FROM note_page WHERE space = $s AND parent = $p AND about = NONE", + s=sid, + p=parent if parent is not None else None, + ) + return max([r for r in rows if r is not None], default=0) + 1 + + +def _links(db, pid, sid, body): + """Keep the body's links as note_link rows, in place of the old ones.""" + db.q("DELETE note_link WHERE page = $p", p=pid) + for sign, kind, key, label in mentions(body): + db.q( + "CREATE note_link CONTENT $d", + d={"page": pid, "space": sid, "sign": sign, "target": f"{kind}:{key}", "label": label[:200]}, + ) + + +def create(db, sid, account, title, body="", summary=None, date=None, place=None, parent=None, about_thing=None, author="person", doc=None): + """A new page; its id. ValueError for bad input, a page that already exists about that thing, or too many.""" + if author not in AUTHORS: + raise ValueError("A page is written by a person or the assistant.") + title, body, summary = _title(title), _body(body), _summary(summary) + key = None + if about_thing: + kind, ref = _about(about_thing) + if owner(db, kind, ref) != sid: + raise ValueError("That isn't in this namespace.") + key = f"{sid}:{kind}:{ref}" + if db.one("SELECT VALUE id FROM note_page WHERE about_key = $k LIMIT 1", k=key): + raise ValueError("That already has a page: change it instead.") + about_thing, parent = f"{kind}:{ref}", None + if len(db.values("SELECT VALUE id FROM note_page WHERE space = $s", s=sid)) >= PAGES_MAX: + raise ValueError(f"A namespace can have up to {PAGES_MAX} pages.") + pid = db.next_id("note_page") + parent = _check_parent(db, sid, pid, parent) + t = store.now() + page = { + "space": sid, + "title": title, + "summary": summary, + "summary_by": author if summary else None, + "date": _date(date) or t[:10], + "place": _place(place), + "parent": parent, + "position": None if about_thing else _last_position(db, sid, parent), + "about": about_thing, + "about_key": key, + "body": body, + "text": plain(body), + "doc": _doc(doc), + "author": author, + "created_by": account, + "updated_by": account, + "created_at": t, + "updated_at": t, + } + db.q("CREATE $r CONTENT $d", r=R("note_page", pid), d=store.clean(page)) + _links(db, pid, sid, body) + return pid + + +def _doc(doc): + if doc is None: + return None + if not isinstance(doc, str) or len(doc) > DOC_MAX: + raise ValueError("The editor's document is too large.") + return doc + + +UNSET = object() + + +def update(db, pid, account, title=None, body=None, summary=UNSET, date=UNSET, place=UNSET, author="person", doc=UNSET): + """Change what's given. A new body without `doc` drops the editor's state; the summary records who wrote it.""" + p = get(db, pid) + sets, args = ["updated_at = $t", "updated_by = $a"], {"t": store.now(), "a": account} + if title is not None: + sets.append("title = $title") + args["title"] = _title(title) + if summary is not UNSET: + sets += ["summary = $summary", "summary_by = $by"] + args["summary"] = _summary(summary) + args["by"] = author if args["summary"] else None + if date is not UNSET: + sets.append("date = $date") + args["date"] = _date(date) + if place is not UNSET: + sets.append("place = $place") + args["place"] = _place(place) + if body is not None: + sets += ["body = $body", "text = $text"] + args["body"] = _body(body) + args["text"] = plain(args["body"]) + if doc is UNSET: + doc = None + if doc is not UNSET: + sets.append("doc = $doc") + args["doc"] = _doc(doc) + db.q(f"UPDATE $r SET {', '.join(sets)}", r=R("note_page", int(pid)), **args) + if body is not None: + _links(db, int(pid), p["space"], args["body"]) + + +def move(db, pid, parent=None, before=None): + """Put a free note inside `parent` (None: the top), before the page `before` (None: at the end).""" + p = get(db, pid) + if p.get("about"): + raise ValueError("A page about something stays with it; only free notes move in the tree.") + parent = _check_parent(db, p["space"], int(pid), parent) + if before is None: + position = _last_position(db, p["space"], parent) + else: + sib = db.rows( + "SELECT record::id(id) AS id, position FROM note_page WHERE space = $s AND parent = $p AND about = NONE", + s=p["space"], + p=parent, + ) + sib = sorted((s for s in sib if s["id"] != int(pid)), key=lambda s: (s.get("position") or 0, s["id"])) + at = next((i for i, s in enumerate(sib) if s["id"] == int(before)), None) + if at is None: + raise ValueError("Put it before a page with the same parent.") + low = (sib[at - 1].get("position") or 0) if at else (sib[at].get("position") or 0) - 1 + position = (low + (sib[at].get("position") or 0)) / 2 + db.q("UPDATE $r SET parent = $p, position = $pos, updated_at = $t", r=R("note_page", int(pid)), p=parent, pos=position, t=store.now()) + + +def delete(db, pid): + """Delete a page; the pages inside it move up to its parent. Links to it stay as text.""" + p = get(db, pid) + for child in db.values("SELECT VALUE record::id(id) FROM note_page WHERE parent = $p", p=int(pid)): + db.q("UPDATE $r SET parent = $up", r=R("note_page", child), up=p.get("parent")) + db.q("DELETE note_link WHERE page = $p", p=int(pid)) + db.q("DELETE $r", r=R("note_page", int(pid))) + + +def links(db, pid): + """The page's links, in the order its body has them.""" + p = get(db, pid) + return [{"sign": s, "target": f"{k}:{i}", "label": label} for s, k, i, label in mentions(p.get("body"))] + + +def backlinks(db, sid, targets): + """The pages of namespace `sid` that link to any of these targets ("page:3", "recording:12"): [{page, title}].""" + rows = db.rows( + "SELECT page, sign, target FROM note_link WHERE space = $s AND target IN $t", + s=sid, + t=list(targets), + ) + ids = sorted({r["page"] for r in rows}) + titles = ( + { + p["id"]: p + for p in db.rows( + "SELECT record::id(id) AS id, title, about, updated_at FROM note_page WHERE id IN $ids", + ids=[R("note_page", i) for i in ids], + ) + } + if ids + else {} + ) + return [ + {"page": i, "title": titles[i]["title"], "about": titles[i].get("about"), "updated_at": titles[i].get("updated_at")} + for i in ids + if i in titles + ] + + +def labels(db, targets): + """Current names for link targets: {"recording:12": "Weekly call"}; the ones that are gone are left out.""" + by_kind = {} + for t in targets: + kind, _, key = t.partition(":") + if kind in KINDS and key.isdigit(): + by_kind.setdefault(kind, []).append(int(key)) + out = {} + for kind, keys in by_kind.items(): + table = "note_page" if kind == "page" else kind + name = {"recording": "title ?? path", "page": "title", "speaker": "name ?? label"}.get(kind, "name") + for r in db.rows( + f"SELECT record::id(id) AS id, space, {name} AS name FROM {table} WHERE id IN $ids", ids=[R(table, k) for k in keys] + ): + out[f"{kind}:{r['id']}"] = {"name": r.get("name"), "space": r.get("space")} + return out + + +def search_targets(db, sid, q="", sign="@", limit=20): + """What a mention can link to in namespace sid, best matches first: for #, topics; for @, pages, recordings, + people and other entities, collections and speakers.""" + q = " ".join(str(q or "").split()).casefold() + hit = (lambda s: q in str(s or "").casefold()) if q else (lambda s: True) + out = [] + if sign == "#": + for e in db.rows("SELECT record::id(id) AS id, name FROM entity WHERE space = $s AND type = 'TERM' AND hidden != true", s=sid): + if hit(e["name"]): + out.append({"target": f"entity:{e['id']}", "label": e["name"], "kind": "topic"}) + return sorted(out, key=lambda x: (not x["label"].casefold().startswith(q), x["label"].casefold()))[:limit] + for p in db.rows("SELECT record::id(id) AS id, title FROM note_page WHERE space = $s AND about = NONE", s=sid): + if hit(p["title"]): + out.append({"target": f"page:{p['id']}", "label": p["title"], "kind": "page"}) + for r in db.rows("SELECT record::id(id) AS id, title ?? path AS name FROM recording WHERE space = $s", s=sid): + if hit(r["name"]): + out.append({"target": f"recording:{r['id']}", "label": str(r["name"]).rsplit("/", 1)[-1], "kind": "recording"}) + for e in db.rows( + "SELECT record::id(id) AS id, name, type FROM entity WHERE space = $s AND type NOT IN ['TERM', 'DATE', 'NUMBER'] AND hidden != true", + s=sid, + ): + if hit(e["name"]): + out.append({"target": f"entity:{e['id']}", "label": e["name"], "kind": "entity"}) + for c in db.rows("SELECT record::id(id) AS id, name FROM collection WHERE space = $s", s=sid): + if hit(c["name"]): + out.append({"target": f"collection:{c['id']}", "label": c["name"], "kind": "collection"}) + for s in db.rows("SELECT record::id(id) AS id, name ?? label AS name FROM speaker WHERE space = $s", s=sid): + if s.get("name") and hit(s["name"]): + out.append({"target": f"speaker:{s['id']}", "label": s["name"], "kind": "speaker"}) + return sorted(out, key=lambda x: (not x["label"].casefold().startswith(q), x["label"].casefold()))[:limit] + + +def release(db, thing): + """The thing is gone (deleted, merged away, moved out of the namespace): its page stays, as a free note at the top + of the tree, so nothing written on it is lost.""" + for p in db.rows("SELECT record::id(id) AS id, space FROM note_page WHERE about = $a", a=thing): + db.q( + "UPDATE $r SET about = NONE, about_key = NONE, parent = NONE, position = $pos", + r=R("note_page", p["id"]), + pos=_last_position(db, p["space"], None), + ) + + +def follow(db, thing, dst): + """The thing moved to namespace dst: its page goes with it, with its links.""" + kind, key = _about(thing) + for p in db.rows("SELECT record::id(id) AS id FROM note_page WHERE about = $a", a=thing): + db.q("UPDATE $r SET space = $s, about_key = $k", r=R("note_page", p["id"]), s=dst, k=f"{dst}:{kind}:{key}") + db.q("UPDATE note_link SET space = $s WHERE page = $p", s=dst, p=p["id"]) diff --git a/fastapi_backend/app/domain/store.py b/fastapi_backend/app/domain/store.py index 2916aa33e..78ae2702a 100644 --- a/fastapi_backend/app/domain/store.py +++ b/fastapi_backend/app/domain/store.py @@ -893,6 +893,16 @@ def close(self): "DEFINE TABLE IF NOT EXISTS note SCHEMALESS", "DEFINE INDEX IF NOT EXISTS note_rec ON note FIELDS recording", "DEFINE INDEX IF NOT EXISTS note_account ON note FIELDS account", + # notes as pages: free notes in a tree and a page per resource, entity or topic (app/domain/notebook.py); + # about_key is "::" for a thing's own page + "DEFINE TABLE IF NOT EXISTS note_page SCHEMALESS", + "DEFINE INDEX IF NOT EXISTS note_page_space ON note_page FIELDS space", + "DEFINE INDEX IF NOT EXISTS note_page_parent ON note_page FIELDS parent", + "DEFINE INDEX IF NOT EXISTS note_page_about ON note_page FIELDS about_key UNIQUE", + # the links in a page's body (@ and # mentions), for backlinks and the graph + "DEFINE TABLE IF NOT EXISTS note_link SCHEMALESS", + "DEFINE INDEX IF NOT EXISTS note_link_page ON note_link FIELDS page", + "DEFINE INDEX IF NOT EXISTS note_link_target ON note_link FIELDS target", # comments on resources, threaded, by everyone who can read them (app/domain/comments.py) "DEFINE TABLE IF NOT EXISTS comment SCHEMALESS", "DEFINE INDEX IF NOT EXISTS comment_rec ON comment FIELDS recording", diff --git a/fastapi_backend/app/schemas/notebook.py b/fastapi_backend/app/schemas/notebook.py new file mode 100644 index 000000000..657830de2 --- /dev/null +++ b/fastapi_backend/app/schemas/notebook.py @@ -0,0 +1,101 @@ +"""Notes as pages: free notes in a tree and a page for every resource, entity and topic (docs/notes.md).""" + +from __future__ import annotations + +from typing import Literal + +from pydantic import Field + +from app.schemas.common import RequestModel, ResponseModel + +Place = Literal["project", "area", "resource", "archive"] +Sign = Literal["@", "#"] + + +class PageItem(ResponseModel): + id: int + title: str + summary: str | None = Field(None, description="one line on what the page holds: the context the assistant reads first") + summary_by: Literal["person", "assistant"] | None = Field(None, description="who wrote the summary") + date: str | None = None + place: Place | None = Field(None, description="where it's filed (PARA): project, area, resource or archive") + parent: int | None = Field(None, description="the page it's inside, in the tree") + position: float | None = Field(None, description="its order among its siblings") + about: str | None = Field(None, description='what this is the page of, like "recording:12"; null for a free note') + author: Literal["person", "assistant"] = Field("person", description="who wrote it") + created_at: str | None = None + updated_at: str | None = None + + +class PageLink(ResponseModel): + sign: Sign + target: str = Field(description='what it links to, like "recording:12" or "page:3"') + label: str = Field(description="the text the link shows") + name: str | None = Field(None, description="the target's current name; null when it's gone or you can't see it") + namespace: str | None = None + + +class Backlink(ResponseModel): + page: int + title: str + about: str | None = None + updated_at: str | None = None + + +class Page(PageItem): + namespace: str + body: str = Field("", description="Markdown, with mentions written @[label](kind:id) and #[label](entity:id)") + doc: str | None = Field(None, description="the editor's own document state, if it kept one") + created_by: str | None = Field(None, description="its writer's email") + links: list[PageLink] = [] + backlinks: list[Backlink] = [] + can_edit: bool = False + + +class PageDraft(ResponseModel): + """A thing's page before anyone has written on it.""" + + id: None = None + namespace: str + about: str + title: str + body: str = "" + backlinks: list[Backlink] = [] + can_edit: bool = False + + +class PageTree(ResponseModel): + namespace: str + pages: list[PageItem] + + +class PageCreate(RequestModel): + ns: str = Field(description="the namespace it goes in") + title: str = Field(min_length=1, max_length=200) + body: str = Field("", max_length=200_000) + summary: str | None = Field(None, max_length=300) + date: str | None = Field(None, description="YYYY-MM-DD (default: today)") + place: Place | None = None + parent: int | None = Field(None, description="put it inside this page") + about: str | None = Field(None, description='make the page of this thing, like "recording:12" or "entity:5"') + doc: str | None = None + + +class PageUpdate(RequestModel): + title: str | None = Field(None, min_length=1, max_length=200) + body: str | None = Field(None, max_length=200_000) + summary: str | None = Field(None, max_length=300, description="empty to clear it") + date: str | None = None + place: Place | Literal[""] | None = Field(None, description='"" to unfile it') + doc: str | None = Field(None, description="the editor's document state; a new body without it drops the old one") + + +class PageMove(RequestModel): + parent: int | None = Field(None, description="the page to put it inside; null for the top") + before: int | None = Field(None, description="put it before this sibling; null for the end") + + +class LinkTarget(ResponseModel): + target: str + label: str + kind: Literal["page", "recording", "entity", "topic", "collection", "speaker"] diff --git a/fastapi_backend/tests/api/test_notebook.py b/fastapi_backend/tests/api/test_notebook.py new file mode 100644 index 000000000..68f8774fb --- /dev/null +++ b/fastapi_backend/tests/api/test_notebook.py @@ -0,0 +1,157 @@ +"""Notes as pages: free notes in a tree, a page per thing, @ and # links with backlinks, and pages that outlive or follow +what they were about.""" + +from __future__ import annotations + +import pytest + +from app.domain import deletion, entities, moving, notebook, store +from tests.helpers import login, make_user, seed + +R = store.R + + +@pytest.fixture +def env(client, db, cfg, folder): + a, b, call = seed(db, cfg, folder) + make_user(db, "vi@x.io", "viewer password 1", roles={"pods": "viewer"}) + make_user(db, "ed@x.io", "editor password 1", roles={"pods": "editor"}) + make_user(db, "out@x.io", "outsider password 1", roles={"calls": "editor"}) + return { + "a": a, + "b": b, + "call": call, + "hv": login(client, "vi@x.io", "viewer password 1"), + "he": login(client, "ed@x.io", "editor password 1"), + "hx": login(client, "out@x.io", "outsider password 1"), + } + + +def _entity(db, name, typ, ns="pods"): + sid = store.ns_id(db, ns) + eid = db.next_id("entity") + key = name.casefold() + db.q("CREATE $r CONTENT $d", r=R("entity", eid), d={"space": sid, "key": key, "ekey": f"{sid}:{key}", "name": name, "type": typ}) + return {"id": eid, "name": name} + + +def _new(client, h, **kw): + r = client.post("/api/v1/notes", headers=h, json={"ns": "pods", **kw}) + assert r.status_code == 200, r.text + return r.json() + + +def test_tree(client, env): + he, hv = env["he"], env["hv"] + top = _new(client, he, title=" Plans ", summary="What we do next\n quarter", place="project") + assert (top["title"], top["summary"], top["summary_by"], top["place"], top["author"]) == ( + "Plans", + "What we do next quarter", + "person", + "project", + "person", + ) + assert top["date"] and top["created_by"] == "ed@x.io" and top["can_edit"] + kid = _new(client, he, title="Hiring", parent=top["id"]) + kid2 = _new(client, he, title="Budget", parent=top["id"]) + tree = client.get("/api/v1/notes?ns=pods", headers=hv).json() + assert [(p["title"], p["parent"]) for p in tree["pages"]] == [("Plans", None), ("Hiring", top["id"]), ("Budget", top["id"])] + # viewers read but don't write + assert not client.get(f"/api/v1/notes/{top['id']}", headers=hv).json()["can_edit"] + assert client.post("/api/v1/notes", headers=hv, json={"ns": "pods", "title": "x"}).status_code == 403 + assert client.patch(f"/api/v1/notes/{top['id']}", headers=hv, json={"title": "x"}).status_code == 403 + # people outside the namespace see nothing + assert client.get(f"/api/v1/notes/{top['id']}", headers=env["hx"]).status_code == 404 + assert client.get("/api/v1/notes?ns=pods", headers=env["hx"]).status_code == 404 + # move Budget before Hiring, then a page can't go inside itself or its own child + r = client.post(f"/api/v1/notes/{kid2['id']}/move", headers=he, json={"parent": top["id"], "before": kid["id"]}) + assert r.status_code == 200, r.text + tree = client.get("/api/v1/notes?ns=pods", headers=hv).json()["pages"] + assert [p["title"] for p in tree if p["parent"] == top["id"]] == ["Budget", "Hiring"] + assert client.post(f"/api/v1/notes/{top['id']}/move", headers=he, json={"parent": kid["id"]}).status_code == 400 + assert client.post(f"/api/v1/notes/{top['id']}/move", headers=he, json={"parent": top["id"]}).status_code == 400 + # change and clear fields; place "" unfiles it + r = client.patch(f"/api/v1/notes/{top['id']}", headers=he, json={"summary": "", "place": "", "date": "2026-01-02"}) + assert r.status_code == 200, r.text + assert (r.json()["summary"], r.json()["place"], r.json()["date"]) == (None, None, "2026-01-02") + assert client.patch(f"/api/v1/notes/{top['id']}", headers=he, json={"date": "soon"}).status_code == 400 + # deleting a page moves what's inside it up + assert client.delete(f"/api/v1/notes/{top['id']}", headers=he).status_code == 200 + tree = client.get("/api/v1/notes?ns=pods", headers=hv).json()["pages"] + assert sorted((p["title"], p["parent"]) for p in tree) == [("Budget", None), ("Hiring", None)] + + +def test_links_and_backlinks(client, env, db): + he, a = env["he"], env["a"] + topic, person = _entity(db, "Capsids", "TERM"), _entity(db, "Ada Lovelace", "PERSON") + # what @ and # offer + hits = client.get("/api/v1/notes/targets?ns=pods&sign=%23", headers=he).json() + assert hits and {h["kind"] for h in hits} == {"topic"} + hits = client.get(f"/api/v1/notes/targets?ns=pods&q={person['name'][:3]}", headers=he).json() + assert f"entity:{person['id']}" in [h["target"] for h in hits] + other = _new(client, he, title="Background") + body = ( + f"Met @[{person['name']}](entity:{person['id']}) about #[{topic['name']}](entity:{topic['id']}) in " + f"@[the call](recording:{a}); see @[bg](page:{other['id']}) and @[gone](recording:999999)." + ) + p = _new(client, he, title="Meeting", body=body) + assert [(x["sign"], x["target"], x["name"] is not None) for x in p["links"]] == [ + ("@", f"entity:{person['id']}", True), + ("#", f"entity:{topic['id']}", True), + ("@", f"recording:{a}", True), + ("@", f"page:{other['id']}", True), + ("@", "recording:999999", False), + ] + # the linked page and the recording's page show the backlink + assert [b["title"] for b in client.get(f"/api/v1/notes/{other['id']}", headers=he).json()["backlinks"]] == ["Meeting"] + draft = client.get(f"/api/v1/notes/about/recording/{a}", headers=he).json() + assert draft["id"] is None and draft["about"] == f"recording:{a}" and [b["title"] for b in draft["backlinks"]] == ["Meeting"] + # the body's plain text drops the link syntax + assert db.one("SELECT text FROM $r", r=R("note_page", p["id"]))["text"].startswith(f"Met {person['name']} about") + # a new body replaces the links + client.patch(f"/api/v1/notes/{p['id']}", headers=he, json={"body": "nothing now"}) + assert client.get(f"/api/v1/notes/{other['id']}", headers=he).json()["backlinks"] == [] + + +def test_pages_of_things(client, env, db, cfg): + he, hv, a, b = env["he"], env["hv"], env["a"], env["b"] + # a recording's page is a draft until someone writes it + d = client.get(f"/api/v1/notes/about/recording/{a}", headers=hv).json() + assert d["id"] is None and d["title"] and not d["can_edit"] + p = _new(client, he, title="About ep1", about=f"recording:{a}", body="Good one", doc="opaque-editor-state") + assert p["about"] == f"recording:{a}" and p["doc"] == "opaque-editor-state" + assert client.get(f"/api/v1/notes/about/recording/{a}", headers=hv).json()["id"] == p["id"] + # one page per thing; things of another namespace can't have a page here + assert client.post("/api/v1/notes", headers=he, json={"ns": "pods", "title": "x", "about": f"recording:{a}"}).status_code == 400 + assert ( + client.post("/api/v1/notes", headers=he, json={"ns": "pods", "title": "x", "about": f"recording:{env['call']}"}).status_code == 400 + ) + assert client.get(f"/api/v1/notes/about/recording/{env['call']}", headers=hv).status_code == 404 + # pages of things stay out of the tree unless asked for, and don't move in it + assert client.get("/api/v1/notes?ns=pods", headers=hv).json()["pages"] == [] + assert [x["id"] for x in client.get("/api/v1/notes?ns=pods&all=true", headers=hv).json()["pages"]] == [p["id"]] + assert client.post(f"/api/v1/notes/{p['id']}/move", headers=he, json={}).status_code == 400 + # a new body without the editor's state drops it + r = client.patch(f"/api/v1/notes/{p['id']}", headers=he, json={"body": "Changed by the assistant"}) + assert r.json()["doc"] is None + # an entity's page; the entity merged away leaves its page as a free note + e1, e2 = _entity(db, "Ada Lovelace", "PERSON")["id"], _entity(db, "A. Lovelace", "PERSON")["id"] + ep = _new(client, he, title="Who", about=f"entity:{e2}") + entities.merge(db, e1, [e2]) + assert notebook.get(db, ep["id"]).get("about") is None + assert ep["id"] in [x["id"] for x in client.get("/api/v1/notes?ns=pods", headers=hv).json()["pages"]] + # a recording moved to another namespace takes its page along; a deleted one leaves it as a free note + pb = _new(client, he, title="About ep2", about=f"recording:{b}") + moving.move(db, cfg, b, store.ns_id(db, "calls")) + moved = notebook.get(db, pb["id"]) + assert moved["space"] == store.ns_id(db, "calls") and moved["about"] == f"recording:{b}" + assert client.get(f"/api/v1/notes/about/recording/{b}", headers=env["hx"]).json()["id"] == pb["id"] + deletion.delete(db, cfg, a) + left = notebook.get(db, p["id"]) + assert left["about"] is None and left["body"] == "Changed by the assistant" + + +def test_domain_helpers(): + body = "**Hi** @[Ada](entity:5) and #[Caps](entity:9), @[Ada](entity:5) twice, @[x](nope:1)\n\n- [ ] [site](http://x)" + assert notebook.mentions(body) == [("@", "entity", 5, "Ada"), ("#", "entity", 9, "Caps")] + assert notebook.plain(body) == "Hi Ada and Caps, Ada twice, x\n\nsite" diff --git a/mkdocs.yml b/mkdocs.yml index ebf3509dd..6632044d7 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -77,6 +77,7 @@ nav: - Telemetry: telemetry.md - IIIF: iiif.md - Graph and Cypher: graph.md + - Notes: notes.md - Linked data (RDF): rdf.md - Fedora repository: fedora.md - API: api.md diff --git a/nextjs-frontend/app/openapi-client/index.ts b/nextjs-frontend/app/openapi-client/index.ts index d43175085..687b1db85 100644 --- a/nextjs-frontend/app/openapi-client/index.ts +++ b/nextjs-frontend/app/openapi-client/index.ts @@ -108,11 +108,14 @@ export type { ApproveAccessRequestErrors, ApproveAccessRequestResponse, ApproveAccessRequestResponses, + AppSchemasNotebookPage, + AppSchemasRecordingsPage, AttachedTo, Attachment, AuditEntry, AuthStatus, Backend, + Backlink, Batch, BatchActionResult, BatchCombine, @@ -347,6 +350,11 @@ export type { CreateNotifyTargetErrors, CreateNotifyTargetResponse, CreateNotifyTargetResponses, + CreatePageData, + CreatePageError, + CreatePageErrors, + CreatePageResponse, + CreatePageResponses, CreatePipelineData, CreatePipelineError, CreatePipelineErrors, @@ -536,6 +544,11 @@ export type { DeleteNotifyTargetErrors, DeleteNotifyTargetResponse, DeleteNotifyTargetResponses, + DeletePageData, + DeletePageError, + DeletePageErrors, + DeletePageResponse, + DeletePageResponses, DeleteRecordingData, DeleteRecordingError, DeleteRecordingErrors, @@ -859,6 +872,11 @@ export type { GetNamespaceWordcloudErrors, GetNamespaceWordcloudResponse, GetNamespaceWordcloudResponses, + GetPageData, + GetPageError, + GetPageErrors, + GetPageResponse, + GetPageResponses, GetPdfData, GetPdfError, GetPdfErrors, @@ -1087,6 +1105,12 @@ export type { LinkSpeakerErrors, LinkSpeakerResponse, LinkSpeakerResponses, + LinkTarget, + LinkTargetsData, + LinkTargetsError, + LinkTargetsErrors, + LinkTargetsResponse, + LinkTargetsResponses, ListAccessRequestsData, ListAccessRequestsError, ListAccessRequestsErrors, @@ -1266,6 +1290,11 @@ export type { ListOutputsErrors, ListOutputsResponse, ListOutputsResponses, + ListPagesData, + ListPagesError, + ListPagesErrors, + ListPagesResponse, + ListPagesResponses, ListPasskeysData, ListPasskeysResponse, ListPasskeysResponses, @@ -1451,6 +1480,11 @@ export type { MoveMentionErrors, MoveMentionResponse, MoveMentionResponses, + MovePageData, + MovePageError, + MovePageErrors, + MovePageResponse, + MovePageResponses, MoveRecordingData, MoveRecordingError, MoveRecordingErrors, @@ -1502,8 +1536,19 @@ export type { OpenRecordingToIpGroupResponses, OriginCount, Output, - Page, + PageAboutData, + PageAboutError, + PageAboutErrors, + PageAboutResponse, + PageAboutResponses, PageContext, + PageCreate, + PageDraft, + PageItem, + PageLink, + PageMove, + PageTree, + PageUpdate, Passage, Passkey, PasskeyAnswer, @@ -2246,6 +2291,11 @@ export type { UpdateNotifyTargetErrors, UpdateNotifyTargetResponse, UpdateNotifyTargetResponses, + UpdatePageData, + UpdatePageError, + UpdatePageErrors, + UpdatePageResponse, + UpdatePageResponses, UpdatePatternData, UpdatePatternError, UpdatePatternErrors, diff --git a/nextjs-frontend/app/openapi-client/sdk.gen.ts b/nextjs-frontend/app/openapi-client/sdk.gen.ts index 83b2dc969..1b903e941 100644 --- a/nextjs-frontend/app/openapi-client/sdk.gen.ts +++ b/nextjs-frontend/app/openapi-client/sdk.gen.ts @@ -148,6 +148,9 @@ import type { CreateNotifyTargetData, CreateNotifyTargetErrors, CreateNotifyTargetResponses, + CreatePageData, + CreatePageErrors, + CreatePageResponses, CreatePipelineData, CreatePipelineErrors, CreatePipelineResponses, @@ -259,6 +262,9 @@ import type { DeleteNotifyTargetData, DeleteNotifyTargetErrors, DeleteNotifyTargetResponses, + DeletePageData, + DeletePageErrors, + DeletePageResponses, DeleteRecordingData, DeleteRecordingErrors, DeleteRecordingResponses, @@ -420,6 +426,9 @@ import type { GetNamespaceWordcloudData, GetNamespaceWordcloudErrors, GetNamespaceWordcloudResponses, + GetPageData, + GetPageErrors, + GetPageResponses, GetPdfData, GetPdfErrors, GetPdfResponses, @@ -531,6 +540,9 @@ import type { LinkSpeakerData, LinkSpeakerErrors, LinkSpeakerResponses, + LinkTargetsData, + LinkTargetsErrors, + LinkTargetsResponses, ListAccessRequestsData, ListAccessRequestsErrors, ListAccessRequestsResponses, @@ -641,6 +653,9 @@ import type { ListOutputsData, ListOutputsErrors, ListOutputsResponses, + ListPagesData, + ListPagesErrors, + ListPagesResponses, ListPasskeysData, ListPasskeysResponses, ListPatternsData, @@ -742,6 +757,9 @@ import type { MoveMentionData, MoveMentionErrors, MoveMentionResponses, + MovePageData, + MovePageErrors, + MovePageResponses, MoveRecordingData, MoveRecordingErrors, MoveRecordingResponses, @@ -754,6 +772,9 @@ import type { OpenRecordingToIpGroupData, OpenRecordingToIpGroupErrors, OpenRecordingToIpGroupResponses, + PageAboutData, + PageAboutErrors, + PageAboutResponses, PasskeyLoginData, PasskeyLoginErrors, PasskeyLoginResponses, @@ -1101,6 +1122,9 @@ import type { UpdateNotifyTargetData, UpdateNotifyTargetErrors, UpdateNotifyTargetResponses, + UpdatePageData, + UpdatePageErrors, + UpdatePageResponses, UpdatePatternData, UpdatePatternErrors, UpdatePatternResponses, @@ -3404,6 +3428,132 @@ export class Notes { }, }); } + + /** + * List Pages + * + * The namespace's free notes for the tree (no bodies), in order; `all=true` adds the pages of things. + */ + public static listPages( + options: Options, + ): RequestResult { + return (options.client ?? client).get({ + url: "/api/v1/notes", + ...options, + }); + } + + /** + * Create Page + * + * Write a free note (optionally inside `parent`), or the page of a thing (`about`, like "recording:12"), which + * each thing has one of. Needs editor access to the namespace. + */ + public static createPage( + options: Options, + ): RequestResult { + return (options.client ?? client).post({ + url: "/api/v1/notes", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }); + } + + /** + * Link Targets + * + * What a mention can link to, best matches first: `#` for topics; `@` for pages, recordings, people and other + * entities, collections and speakers. + */ + public static linkTargets( + options: Options, + ): RequestResult { + return (options.client ?? client).get({ + url: "/api/v1/notes/targets", + ...options, + }); + } + + /** + * Page About + * + * The page of a recording, entity, collection or speaker: its page, or a draft while nobody has written one. + */ + public static pageAbout( + options: Options, + ): RequestResult { + return (options.client ?? client).get({ + url: "/api/v1/notes/about/{kind}/{key}", + ...options, + }); + } + + /** + * Delete Page + * + * Delete a page; the pages inside it move up a level. Needs editor access. + */ + public static deletePage( + options: Options, + ): RequestResult { + return (options.client ?? client).delete({ + url: "/api/v1/notes/{pid}", + ...options, + }); + } + + /** + * Get Page + * + * A page with its body, its links (with their targets' current names) and the pages linking to it. + */ + public static getPage( + options: Options, + ): RequestResult { + return (options.client ?? client).get({ + url: "/api/v1/notes/{pid}", + ...options, + }); + } + + /** + * Update Page + * + * Change what's given. A new body without `doc` drops the editor's state, so it's rebuilt from the Markdown. + */ + public static updatePage( + options: Options, + ): RequestResult { + return (options.client ?? client).patch({ + url: "/api/v1/notes/{pid}", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }); + } + + /** + * Move Page + * + * Move a free note in the tree: inside `parent` (null: the top), before `before` (null: at the end). + */ + public static movePage( + options: Options, + ): RequestResult { + return (options.client ?? client).post({ + url: "/api/v1/notes/{pid}/move", + ...options, + headers: { + "Content-Type": "application/json", + ...options.headers, + }, + }); + } } export class Comments { diff --git a/nextjs-frontend/app/openapi-client/types.gen.ts b/nextjs-frontend/app/openapi-client/types.gen.ts index 217fdbd3d..74e9a89f7 100644 --- a/nextjs-frontend/app/openapi-client/types.gen.ts +++ b/nextjs-frontend/app/openapi-client/types.gen.ts @@ -394,6 +394,29 @@ export type Backend = { [key: string]: unknown; }; +/** + * Backlink + */ +export type Backlink = { + /** + * Page + */ + page: number; + /** + * Title + */ + title: string; + /** + * About + */ + about?: string | null; + /** + * Updated At + */ + updated_at?: string | null; + [key: string]: unknown; +}; + /** * Batch */ @@ -5586,6 +5609,25 @@ export type LastSend = { [key: string]: unknown; }; +/** + * LinkTarget + */ +export type LinkTarget = { + /** + * Target + */ + target: string; + /** + * Label + */ + label: string; + /** + * Kind + */ + kind: "page" | "recording" | "entity" | "topic" | "collection" | "speaker"; + [key: string]: unknown; +}; + /** * LlmEstimate */ @@ -7157,88 +7199,291 @@ export type Output = { }; /** - * Page + * PageContext * - * A page of a document, or an image (a TIFF has one per frame). + * The page a question was asked from (chat on any page): where it is, and what of it the person shared. */ -export type Page = { +export type PageContext = { /** - * Idx + * Url * - * from 0 + * the page's path in Lens, e.g. /resources/12?t=30 */ - idx: number; + url: string; /** - * Width + * Title + */ + title?: string | null; + /** + * Text * - * pixels of its image + * the page's visible text, when the person shares the page (only the first 12,000 characters are used) */ - width?: number | null; + text?: string | null; /** - * Height + * Selection + * + * text the person highlighted on it (only the first 4,000 characters are used) */ - height?: number | null; + selection?: string | null; +}; + +/** + * PageCreate + */ +export type PageCreate = { /** - * Image + * Ns * - * a signed link to it, drawn; none when it couldn't be + * the namespace it goes in */ - image?: string | null; + ns: string; /** - * Thumb + * Title + */ + title: string; + /** + * Body + */ + body?: string; + /** + * Summary + */ + summary?: string | null; + /** + * Date * - * a signed link to it, small + * YYYY-MM-DD (default: today) */ - thumb?: string | null; + date?: string | null; /** - * Text + * Place + */ + place?: "project" | "area" | "resource" | "archive" | null; + /** + * Parent * - * how its text was read: from the PDF, or by OCR; none without text + * put it inside this page */ - text?: "pdf" | "ocr" | null; + parent?: number | null; /** - * Chars + * About * - * characters of text on it + * make the page of this thing, like "recording:12" or "entity:5" */ - chars?: number; + about?: string | null; + /** + * Doc + */ + doc?: string | null; +}; + +/** + * PageDraft + * + * A thing's page before anyone has written on it. + */ +export type PageDraft = { + /** + * Id + */ + id?: null; + /** + * Namespace + */ + namespace: string; + /** + * About + */ + about: string; + /** + * Title + */ + title: string; + /** + * Body + */ + body?: string; + /** + * Backlinks + */ + backlinks?: Array; + /** + * Can Edit + */ + can_edit?: boolean; + [key: string]: unknown; +}; + +/** + * PageItem + */ +export type PageItem = { + /** + * Id + */ + id: number; + /** + * Title + */ + title: string; + /** + * Summary + * + * one line on what the page holds: the context the assistant reads first + */ + summary?: string | null; + /** + * Summary By + * + * who wrote the summary + */ + summary_by?: "person" | "assistant" | null; + /** + * Date + */ + date?: string | null; + /** + * Place + * + * where it's filed (PARA): project, area, resource or archive + */ + place?: "project" | "area" | "resource" | "archive" | null; + /** + * Parent + * + * the page it's inside, in the tree + */ + parent?: number | null; + /** + * Position + * + * its order among its siblings + */ + position?: number | null; + /** + * About + * + * what this is the page of, like "recording:12"; null for a free note + */ + about?: string | null; + /** + * Author + * + * who wrote it + */ + author?: "person" | "assistant"; + /** + * Created At + */ + created_at?: string | null; + /** + * Updated At + */ + updated_at?: string | null; + [key: string]: unknown; +}; + +/** + * PageLink + */ +export type PageLink = { + /** + * Sign + */ + sign: "@" | "#"; + /** + * Target + * + * what it links to, like "recording:12" or "page:3" + */ + target: string; /** * Label * - * the PDF's own name for it (iv, A-1, …) when it isn't its number + * the text the link shows */ - label?: string | null; + label: string; + /** + * Name + * + * the target's current name; null when it's gone or you can't see it + */ + name?: string | null; + /** + * Namespace + */ + namespace?: string | null; [key: string]: unknown; }; /** - * PageContext - * - * The page a question was asked from (chat on any page): where it is, and what of it the person shared. + * PageMove */ -export type PageContext = { +export type PageMove = { /** - * Url + * Parent * - * the page's path in Lens, e.g. /resources/12?t=30 + * the page to put it inside; null for the top */ - url: string; + parent?: number | null; + /** + * Before + * + * put it before this sibling; null for the end + */ + before?: number | null; +}; + +/** + * PageTree + */ +export type PageTree = { + /** + * Namespace + */ + namespace: string; + /** + * Pages + */ + pages: Array; + [key: string]: unknown; +}; + +/** + * PageUpdate + */ +export type PageUpdate = { /** * Title */ title?: string | null; /** - * Text + * Body + */ + body?: string | null; + /** + * Summary * - * the page's visible text, when the person shares the page (only the first 12,000 characters are used) + * empty to clear it */ - text?: string | null; + summary?: string | null; /** - * Selection + * Date + */ + date?: string | null; + /** + * Place * - * text the person highlighted on it (only the first 4,000 characters are used) + * "" to unfile it */ - selection?: string | null; + place?: "project" | "area" | "resource" | "archive" | "" | null; + /** + * Doc + * + * the editor's document state; a new body without it drops the old one + */ + doc?: string | null; }; /** @@ -7895,7 +8140,7 @@ export type Player = { * * a document's or an image's pages, in order */ - pages?: Array | null; + pages?: Array | null; /** * Objects * @@ -13980,16 +14225,174 @@ export type WorkflowVersionInfo = { [key: string]: unknown; }; -export type StatusData = { - body?: never; - path?: never; - query?: never; - url: "/api/v1/auth/status"; -}; - -export type StatusResponses = { +/** + * Page + */ +export type AppSchemasNotebookPage = { /** - * Successful Response + * Id + */ + id: number; + /** + * Title + */ + title: string; + /** + * Summary + * + * one line on what the page holds: the context the assistant reads first + */ + summary?: string | null; + /** + * Summary By + * + * who wrote the summary + */ + summary_by?: "person" | "assistant" | null; + /** + * Date + */ + date?: string | null; + /** + * Place + * + * where it's filed (PARA): project, area, resource or archive + */ + place?: "project" | "area" | "resource" | "archive" | null; + /** + * Parent + * + * the page it's inside, in the tree + */ + parent?: number | null; + /** + * Position + * + * its order among its siblings + */ + position?: number | null; + /** + * About + * + * what this is the page of, like "recording:12"; null for a free note + */ + about?: string | null; + /** + * Author + * + * who wrote it + */ + author?: "person" | "assistant"; + /** + * Created At + */ + created_at?: string | null; + /** + * Updated At + */ + updated_at?: string | null; + /** + * Namespace + */ + namespace: string; + /** + * Body + * + * Markdown, with mentions written @[label](kind:id) and #[label](entity:id) + */ + body?: string; + /** + * Doc + * + * the editor's own document state, if it kept one + */ + doc?: string | null; + /** + * Created By + * + * its writer's email + */ + created_by?: string | null; + /** + * Links + */ + links?: Array; + /** + * Backlinks + */ + backlinks?: Array; + /** + * Can Edit + */ + can_edit?: boolean; + [key: string]: unknown; +}; + +/** + * Page + * + * A page of a document, or an image (a TIFF has one per frame). + */ +export type AppSchemasRecordingsPage = { + /** + * Idx + * + * from 0 + */ + idx: number; + /** + * Width + * + * pixels of its image + */ + width?: number | null; + /** + * Height + */ + height?: number | null; + /** + * Image + * + * a signed link to it, drawn; none when it couldn't be + */ + image?: string | null; + /** + * Thumb + * + * a signed link to it, small + */ + thumb?: string | null; + /** + * Text + * + * how its text was read: from the PDF, or by OCR; none without text + */ + text?: "pdf" | "ocr" | null; + /** + * Chars + * + * characters of text on it + */ + chars?: number; + /** + * Label + * + * the PDF's own name for it (iv, A-1, …) when it isn't its number + */ + label?: string | null; + [key: string]: unknown; +}; + +export type StatusData = { + body?: never; + path?: never; + query?: never; + url: "/api/v1/auth/status"; +}; + +export type StatusResponses = { + /** + * Successful Response */ 200: AuthStatus; }; @@ -17873,6 +18276,265 @@ export type UpdateNoteResponses = { export type UpdateNoteResponse = UpdateNoteResponses[keyof UpdateNoteResponses]; +export type ListPagesData = { + body?: never; + path?: never; + query: { + /** + * Ns + */ + ns: string; + /** + * All + */ + all?: boolean; + }; + url: "/api/v1/notes"; +}; + +export type ListPagesErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type ListPagesError = ListPagesErrors[keyof ListPagesErrors]; + +export type ListPagesResponses = { + /** + * Successful Response + */ + 200: PageTree; +}; + +export type ListPagesResponse = ListPagesResponses[keyof ListPagesResponses]; + +export type CreatePageData = { + body: PageCreate; + path?: never; + query?: never; + url: "/api/v1/notes"; +}; + +export type CreatePageErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type CreatePageError = CreatePageErrors[keyof CreatePageErrors]; + +export type CreatePageResponses = { + /** + * Successful Response + */ + 200: AppSchemasNotebookPage; +}; + +export type CreatePageResponse = CreatePageResponses[keyof CreatePageResponses]; + +export type LinkTargetsData = { + body?: never; + path?: never; + query: { + /** + * Ns + */ + ns: string; + /** + * Q + */ + q?: string; + /** + * Sign + */ + sign?: string; + /** + * Limit + */ + limit?: number; + }; + url: "/api/v1/notes/targets"; +}; + +export type LinkTargetsErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type LinkTargetsError = LinkTargetsErrors[keyof LinkTargetsErrors]; + +export type LinkTargetsResponses = { + /** + * Response Notes-Link Targets + * + * Successful Response + */ + 200: Array; +}; + +export type LinkTargetsResponse = LinkTargetsResponses[keyof LinkTargetsResponses]; + +export type PageAboutData = { + body?: never; + path: { + /** + * Kind + */ + kind: string; + /** + * Key + */ + key: number; + }; + query?: never; + url: "/api/v1/notes/about/{kind}/{key}"; +}; + +export type PageAboutErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type PageAboutError = PageAboutErrors[keyof PageAboutErrors]; + +export type PageAboutResponses = { + /** + * Response Notes-Page About + * + * Successful Response + */ + 200: AppSchemasNotebookPage | PageDraft; +}; + +export type PageAboutResponse = PageAboutResponses[keyof PageAboutResponses]; + +export type DeletePageData = { + body?: never; + path: { + /** + * Pid + */ + pid: number; + }; + query?: never; + url: "/api/v1/notes/{pid}"; +}; + +export type DeletePageErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type DeletePageError = DeletePageErrors[keyof DeletePageErrors]; + +export type DeletePageResponses = { + /** + * Successful Response + */ + 200: Ok; +}; + +export type DeletePageResponse = DeletePageResponses[keyof DeletePageResponses]; + +export type GetPageData = { + body?: never; + path: { + /** + * Pid + */ + pid: number; + }; + query?: never; + url: "/api/v1/notes/{pid}"; +}; + +export type GetPageErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type GetPageError = GetPageErrors[keyof GetPageErrors]; + +export type GetPageResponses = { + /** + * Successful Response + */ + 200: AppSchemasNotebookPage; +}; + +export type GetPageResponse = GetPageResponses[keyof GetPageResponses]; + +export type UpdatePageData = { + body: PageUpdate; + path: { + /** + * Pid + */ + pid: number; + }; + query?: never; + url: "/api/v1/notes/{pid}"; +}; + +export type UpdatePageErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type UpdatePageError = UpdatePageErrors[keyof UpdatePageErrors]; + +export type UpdatePageResponses = { + /** + * Successful Response + */ + 200: AppSchemasNotebookPage; +}; + +export type UpdatePageResponse = UpdatePageResponses[keyof UpdatePageResponses]; + +export type MovePageData = { + body: PageMove; + path: { + /** + * Pid + */ + pid: number; + }; + query?: never; + url: "/api/v1/notes/{pid}/move"; +}; + +export type MovePageErrors = { + /** + * Validation Error + */ + 422: HttpValidationError; +}; + +export type MovePageError = MovePageErrors[keyof MovePageErrors]; + +export type MovePageResponses = { + /** + * Successful Response + */ + 200: AppSchemasNotebookPage; +}; + +export type MovePageResponse = MovePageResponses[keyof MovePageResponses]; + export type ListCommentsData = { body?: never; path: { diff --git a/nextjs-frontend/openapi.json b/nextjs-frontend/openapi.json index 5cb83de2b..65e6576f2 100644 --- a/nextjs-frontend/openapi.json +++ b/nextjs-frontend/openapi.json @@ -6338,6 +6338,426 @@ } } }, + "/api/v1/notes": { + "get": { + "tags": [ + "notes" + ], + "summary": "List Pages", + "description": "The namespace's free notes for the tree (no bodies), in order; `all=true` adds the pages of things.", + "operationId": "list_pages", + "parameters": [ + { + "name": "ns", + "in": "query", + "required": true, + "schema": { + "type": "string", + "title": "Ns" + } + }, + { + "name": "all", + "in": "query", + "required": false, + "schema": { + "type": "boolean", + "default": false, + "title": "All" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageTree" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "post": { + "tags": [ + "notes" + ], + "summary": "Create Page", + "description": "Write a free note (optionally inside `parent`), or the page of a thing (`about`, like \"recording:12\"), which\neach thing has one of. Needs editor access to the namespace.", + "operationId": "create_page", + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageCreate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/app__schemas__notebook__Page" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/notes/targets": { + "get": { + "tags": [ + "notes" + ], + "summary": "Link Targets", + "description": "What a mention can link to, best matches first: `#` for topics; `@` for pages, recordings, people and other\nentities, collections and speakers.", + "operationId": "link_targets", + "parameters": [ + { + "name": "ns", + "in": "query", + "required": true, + "schema": { + "type": "string", + "title": "Ns" + } + }, + { + "name": "q", + "in": "query", + "required": false, + "schema": { + "type": "string", + "default": "", + "title": "Q" + } + }, + { + "name": "sign", + "in": "query", + "required": false, + "schema": { + "type": "string", + "default": "@", + "title": "Sign" + } + }, + { + "name": "limit", + "in": "query", + "required": false, + "schema": { + "type": "integer", + "maximum": 50, + "minimum": 1, + "default": 20, + "title": "Limit" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "type": "array", + "items": { + "$ref": "#/components/schemas/LinkTarget" + }, + "title": "Response Notes-Link Targets" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/notes/about/{kind}/{key}": { + "get": { + "tags": [ + "notes" + ], + "summary": "Page About", + "description": "The page of a recording, entity, collection or speaker: its page, or a draft while nobody has written one.", + "operationId": "page_about", + "parameters": [ + { + "name": "kind", + "in": "path", + "required": true, + "schema": { + "type": "string", + "title": "Kind" + } + }, + { + "name": "key", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Key" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "anyOf": [ + { + "$ref": "#/components/schemas/app__schemas__notebook__Page" + }, + { + "$ref": "#/components/schemas/PageDraft" + } + ], + "title": "Response Notes-Page About" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/notes/{pid}": { + "get": { + "tags": [ + "notes" + ], + "summary": "Get Page", + "description": "A page with its body, its links (with their targets' current names) and the pages linking to it.", + "operationId": "get_page", + "parameters": [ + { + "name": "pid", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Pid" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/app__schemas__notebook__Page" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "patch": { + "tags": [ + "notes" + ], + "summary": "Update Page", + "description": "Change what's given. A new body without `doc` drops the editor's state, so it's rebuilt from the Markdown.", + "operationId": "update_page", + "parameters": [ + { + "name": "pid", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Pid" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageUpdate" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/app__schemas__notebook__Page" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + }, + "delete": { + "tags": [ + "notes" + ], + "summary": "Delete Page", + "description": "Delete a page; the pages inside it move up a level. Needs editor access.", + "operationId": "delete_page", + "parameters": [ + { + "name": "pid", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Pid" + } + } + ], + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Ok" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, + "/api/v1/notes/{pid}/move": { + "post": { + "tags": [ + "notes" + ], + "summary": "Move Page", + "description": "Move a free note in the tree: inside `parent` (null: the top), before `before` (null: at the end).", + "operationId": "move_page", + "parameters": [ + { + "name": "pid", + "in": "path", + "required": true, + "schema": { + "type": "integer", + "title": "Pid" + } + } + ], + "requestBody": { + "required": true, + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PageMove" + } + } + } + }, + "responses": { + "200": { + "description": "Successful Response", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/app__schemas__notebook__Page" + } + } + } + }, + "422": { + "description": "Validation Error", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/HTTPValidationError" + } + } + } + } + } + } + }, "/api/v1/resources/{rid}/comments": { "get": { "tags": [ @@ -20192,6 +20612,47 @@ ], "title": "Backend" }, + "Backlink": { + "properties": { + "page": { + "type": "integer", + "title": "Page" + }, + "title": { + "type": "string", + "title": "Title" + }, + "about": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "About" + }, + "updated_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Updated At" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "page", + "title" + ], + "title": "Backlink" + }, "Batch": { "properties": { "id": { @@ -29250,6 +29711,38 @@ ], "title": "LastSend" }, + "LinkTarget": { + "properties": { + "target": { + "type": "string", + "title": "Target" + }, + "label": { + "type": "string", + "title": "Label" + }, + "kind": { + "type": "string", + "enum": [ + "page", + "recording", + "entity", + "topic", + "collection", + "speaker" + ], + "title": "Kind" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "target", + "label", + "kind" + ], + "title": "LinkTarget" + }, "LlmEstimate": { "properties": { "calls": { @@ -31894,26 +32387,123 @@ ], "title": "Output" }, - "Page": { + "PageContext": { "properties": { - "idx": { - "type": "integer", - "title": "Idx", - "description": "from 0" + "url": { + "type": "string", + "maxLength": 2000, + "pattern": "^/([^/]|$)", + "title": "Url", + "description": "the page's path in Lens, e.g. /resources/12?t=30" }, - "width": { + "title": { "anyOf": [ { - "type": "integer" + "type": "string", + "maxLength": 300 }, { "type": "null" } ], - "title": "Width", - "description": "pixels of its image" + "title": "Title" }, - "height": { + "text": { + "anyOf": [ + { + "type": "string", + "maxLength": 200000 + }, + { + "type": "null" + } + ], + "title": "Text", + "description": "the page's visible text, when the person shares the page (only the first 12,000 characters are used)" + }, + "selection": { + "anyOf": [ + { + "type": "string", + "maxLength": 50000 + }, + { + "type": "null" + } + ], + "title": "Selection", + "description": "text the person highlighted on it (only the first 4,000 characters are used)" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "url" + ], + "title": "PageContext", + "description": "The page a question was asked from (chat on any page): where it is, and what of it the person shared." + }, + "PageCreate": { + "properties": { + "ns": { + "type": "string", + "title": "Ns", + "description": "the namespace it goes in" + }, + "title": { + "type": "string", + "maxLength": 200, + "minLength": 1, + "title": "Title" + }, + "body": { + "type": "string", + "maxLength": 200000, + "title": "Body", + "default": "" + }, + "summary": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ], + "title": "Summary" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date", + "description": "YYYY-MM-DD (default: today)" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "null" + } + ], + "title": "Place" + }, + "parent": { "anyOf": [ { "type": "integer" @@ -31922,9 +32512,10 @@ "type": "null" } ], - "title": "Height" + "title": "Parent", + "description": "put it inside this page" }, - "image": { + "about": { "anyOf": [ { "type": "string" @@ -31933,10 +32524,10 @@ "type": "null" } ], - "title": "Image", - "description": "a signed link to it, drawn; none when it couldn't be" + "title": "About", + "description": "make the page of this thing, like \"recording:12\" or \"entity:5\"" }, - "thumb": { + "doc": { "anyOf": [ { "type": "string" @@ -31945,32 +32536,156 @@ "type": "null" } ], - "title": "Thumb", - "description": "a signed link to it, small" + "title": "Doc" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "ns", + "title" + ], + "title": "PageCreate" + }, + "PageDraft": { + "properties": { + "id": { + "type": "null", + "title": "Id" }, - "text": { + "namespace": { + "type": "string", + "title": "Namespace" + }, + "about": { + "type": "string", + "title": "About" + }, + "title": { + "type": "string", + "title": "Title" + }, + "body": { + "type": "string", + "title": "Body", + "default": "" + }, + "backlinks": { + "items": { + "$ref": "#/components/schemas/Backlink" + }, + "type": "array", + "title": "Backlinks", + "default": [] + }, + "can_edit": { + "type": "boolean", + "title": "Can Edit", + "default": false + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "namespace", + "about", + "title" + ], + "title": "PageDraft", + "description": "A thing's page before anyone has written on it." + }, + "PageItem": { + "properties": { + "id": { + "type": "integer", + "title": "Id" + }, + "title": { + "type": "string", + "title": "Title" + }, + "summary": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Summary", + "description": "one line on what the page holds: the context the assistant reads first" + }, + "summary_by": { "anyOf": [ { "type": "string", "enum": [ - "pdf", - "ocr" + "person", + "assistant" ] }, { "type": "null" } ], - "title": "Text", - "description": "how its text was read: from the PDF, or by OCR; none without text" + "title": "Summary By", + "description": "who wrote the summary" }, - "chars": { - "type": "integer", - "title": "Chars", - "description": "characters of text on it", - "default": 0 + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date" }, - "label": { + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "null" + } + ], + "title": "Place", + "description": "where it's filed (PARA): project, area, resource or archive" + }, + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "the page it's inside, in the tree" + }, + "position": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Position", + "description": "its order among its siblings" + }, + "about": { "anyOf": [ { "type": "string" @@ -31979,32 +32694,164 @@ "type": "null" } ], + "title": "About", + "description": "what this is the page of, like \"recording:12\"; null for a free note" + }, + "author": { + "type": "string", + "enum": [ + "person", + "assistant" + ], + "title": "Author", + "description": "who wrote it", + "default": "person" + }, + "created_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Created At" + }, + "updated_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Updated At" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "id", + "title" + ], + "title": "PageItem" + }, + "PageLink": { + "properties": { + "sign": { + "type": "string", + "enum": [ + "@", + "#" + ], + "title": "Sign" + }, + "target": { + "type": "string", + "title": "Target", + "description": "what it links to, like \"recording:12\" or \"page:3\"" + }, + "label": { + "type": "string", "title": "Label", - "description": "the PDF's own name for it (iv, A-1, \u2026) when it isn't its number" + "description": "the text the link shows" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Name", + "description": "the target's current name; null when it's gone or you can't see it" + }, + "namespace": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Namespace" } }, "additionalProperties": true, "type": "object", "required": [ - "idx" + "sign", + "target", + "label" ], - "title": "Page", - "description": "A page of a document, or an image (a TIFF has one per frame)." + "title": "PageLink" }, - "PageContext": { + "PageMove": { "properties": { - "url": { + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "the page to put it inside; null for the top" + }, + "before": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Before", + "description": "put it before this sibling; null for the end" + } + }, + "additionalProperties": false, + "type": "object", + "title": "PageMove" + }, + "PageTree": { + "properties": { + "namespace": { "type": "string", - "maxLength": 2000, - "pattern": "^/([^/]|$)", - "title": "Url", - "description": "the page's path in Lens, e.g. /resources/12?t=30" + "title": "Namespace" }, + "pages": { + "items": { + "$ref": "#/components/schemas/PageItem" + }, + "type": "array", + "title": "Pages" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "namespace", + "pages" + ], + "title": "PageTree" + }, + "PageUpdate": { + "properties": { "title": { "anyOf": [ { "type": "string", - "maxLength": 300 + "maxLength": 200, + "minLength": 1 }, { "type": "null" @@ -32012,7 +32859,7 @@ ], "title": "Title" }, - "text": { + "body": { "anyOf": [ { "type": "string", @@ -32022,30 +32869,70 @@ "type": "null" } ], - "title": "Text", - "description": "the page's visible text, when the person shares the page (only the first 12,000 characters are used)" + "title": "Body" }, - "selection": { + "summary": { "anyOf": [ { "type": "string", - "maxLength": 50000 + "maxLength": 300 }, { "type": "null" } ], - "title": "Selection", - "description": "text the person highlighted on it (only the first 4,000 characters are used)" + "title": "Summary", + "description": "empty to clear it" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "string", + "const": "" + }, + { + "type": "null" + } + ], + "title": "Place", + "description": "\"\" to unfile it" + }, + "doc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Doc", + "description": "the editor's document state; a new body without it drops the old one" } }, "additionalProperties": false, "type": "object", - "required": [ - "url" - ], - "title": "PageContext", - "description": "The page a question was asked from (chat on any page): where it is, and what of it the person shared." + "title": "PageUpdate" }, "Passage": { "properties": { @@ -33161,7 +34048,7 @@ "anyOf": [ { "items": { - "$ref": "#/components/schemas/Page" + "$ref": "#/components/schemas/app__schemas__recordings__Page" }, "type": "array" }, @@ -43822,6 +44709,303 @@ "version" ], "title": "WorkflowVersionInfo" + }, + "app__schemas__notebook__Page": { + "properties": { + "id": { + "type": "integer", + "title": "Id" + }, + "title": { + "type": "string", + "title": "Title" + }, + "summary": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Summary", + "description": "one line on what the page holds: the context the assistant reads first" + }, + "summary_by": { + "anyOf": [ + { + "type": "string", + "enum": [ + "person", + "assistant" + ] + }, + { + "type": "null" + } + ], + "title": "Summary By", + "description": "who wrote the summary" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "null" + } + ], + "title": "Place", + "description": "where it's filed (PARA): project, area, resource or archive" + }, + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "the page it's inside, in the tree" + }, + "position": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Position", + "description": "its order among its siblings" + }, + "about": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "About", + "description": "what this is the page of, like \"recording:12\"; null for a free note" + }, + "author": { + "type": "string", + "enum": [ + "person", + "assistant" + ], + "title": "Author", + "description": "who wrote it", + "default": "person" + }, + "created_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Created At" + }, + "updated_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Updated At" + }, + "namespace": { + "type": "string", + "title": "Namespace" + }, + "body": { + "type": "string", + "title": "Body", + "description": "Markdown, with mentions written @[label](kind:id) and #[label](entity:id)", + "default": "" + }, + "doc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Doc", + "description": "the editor's own document state, if it kept one" + }, + "created_by": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Created By", + "description": "its writer's email" + }, + "links": { + "items": { + "$ref": "#/components/schemas/PageLink" + }, + "type": "array", + "title": "Links", + "default": [] + }, + "backlinks": { + "items": { + "$ref": "#/components/schemas/Backlink" + }, + "type": "array", + "title": "Backlinks", + "default": [] + }, + "can_edit": { + "type": "boolean", + "title": "Can Edit", + "default": false + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "id", + "title", + "namespace" + ], + "title": "Page" + }, + "app__schemas__recordings__Page": { + "properties": { + "idx": { + "type": "integer", + "title": "Idx", + "description": "from 0" + }, + "width": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Width", + "description": "pixels of its image" + }, + "height": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Height" + }, + "image": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Image", + "description": "a signed link to it, drawn; none when it couldn't be" + }, + "thumb": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Thumb", + "description": "a signed link to it, small" + }, + "text": { + "anyOf": [ + { + "type": "string", + "enum": [ + "pdf", + "ocr" + ] + }, + { + "type": "null" + } + ], + "title": "Text", + "description": "how its text was read: from the PDF, or by OCR; none without text" + }, + "chars": { + "type": "integer", + "title": "Chars", + "description": "characters of text on it", + "default": 0 + }, + "label": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Label", + "description": "the PDF's own name for it (iv, A-1, \u2026) when it isn't its number" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "idx" + ], + "title": "Page", + "description": "A page of a document, or an image (a TIFF has one per frame)." } } } From 0e16c0bbfbdeec98c05c9f165460125b27335409 Mon Sep 17 00:00:00 2001 From: Adeel Ahmad Date: Sun, 4 Oct 2026 09:58:06 +0000 Subject: [PATCH 3/3] fix(notes): name the note schemas apart from document pages The notes' Page schema shared its name with a document's Page, so the OpenAPI schema kept only one of them. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XZQXJtCvJgbG1Z2H312KcS --- fastapi_backend/app/api/v1/routes/notebook.py | 35 +- fastapi_backend/app/schemas/notebook.py | 28 +- nextjs-frontend/app/openapi-client/index.ts | 22 +- .../app/openapi-client/types.gen.ts | 1132 +++++------ nextjs-frontend/openapi.json | 1654 ++++++++--------- 5 files changed, 1440 insertions(+), 1431 deletions(-) diff --git a/fastapi_backend/app/api/v1/routes/notebook.py b/fastapi_backend/app/api/v1/routes/notebook.py index f6bf2a1dd..114e50476 100644 --- a/fastapi_backend/app/api/v1/routes/notebook.py +++ b/fastapi_backend/app/api/v1/routes/notebook.py @@ -14,7 +14,16 @@ from app.domain import auth, notebook, store from app.domain.store import DB from app.schemas.common import Ok -from app.schemas.notebook import LinkTarget, Page, PageCreate, PageDraft, PageItem, PageMove, PageTree, PageUpdate +from app.schemas.notebook import ( + NoteLinkTarget, + NotePage, + NotePageCreate, + NotePageDraft, + NotePageItem, + NotePageMove, + NotePageUpdate, + NoteTree, +) router = APIRouter(prefix="/notes", tags=["notes"]) @@ -32,7 +41,7 @@ def _backlinks(acl: Access, db: DB, sid: int, targets: list[str]) -> list[dict[s return notebook.backlinks(db, sid, targets) if targets else [] -def _out(acl: Access, db: DB, p: dict[str, Any], user: Principal) -> Page: +def _out(acl: Access, db: DB, p: dict[str, Any], user: Principal) -> NotePage: names = store.space_names(db) links = notebook.links(db, p["id"]) found = notebook.labels(db, [x["target"] for x in links]) @@ -44,7 +53,7 @@ def _out(acl: Access, db: DB, p: dict[str, Any], user: Principal) -> Page: out_links.append({**x, "name": t["name"] if seen else None, "namespace": names.get(t["space"]) if seen else None}) writer = db.one("SELECT email FROM $r", r=store.R("account", p["created_by"])) if p.get("created_by") else None targets = [f"page:{p['id']}"] + ([p["about"]] if p.get("about") else []) - return Page( + return NotePage( **{k: v for k, v in p.items() if k not in ("space", "created_by", "updated_by")}, namespace=names.get(p["space"], ""), created_by=(writer or {}).get("email"), @@ -55,14 +64,14 @@ def _out(acl: Access, db: DB, p: dict[str, Any], user: Principal) -> Page: @router.get("") -def list_pages(ns: str, user: CurrentUser, acl: Acl, db: Db, everything: bool = Query(False, alias="all")) -> PageTree: +def list_pages(ns: str, user: CurrentUser, acl: Acl, db: Db, everything: bool = Query(False, alias="all")) -> NoteTree: """The namespace's free notes for the tree (no bodies), in order; `all=true` adds the pages of things.""" sid = acl.namespace(ns) - return PageTree(namespace=ns, pages=[PageItem(**p) for p in notebook.tree(db, sid, everything)]) + return NoteTree(namespace=ns, pages=[NotePageItem(**p) for p in notebook.tree(db, sid, everything)]) @router.post("") -def create_page(body: PageCreate, user: Writer, acl: Acl, db: Db) -> Page: +def create_page(body: NotePageCreate, user: Writer, acl: Acl, db: Db) -> NotePage: """Write a free note (optionally inside `parent`), or the page of a thing (`about`, like "recording:12"), which each thing has one of. Needs editor access to the namespace.""" sid = acl.namespace(body.ns, "editor") @@ -76,17 +85,17 @@ def create_page(body: PageCreate, user: Writer, acl: Acl, db: Db) -> Page: @router.get("/targets") def link_targets( ns: str, user: CurrentUser, acl: Acl, db: Db, q: str = "", sign: str = "@", limit: int = Query(20, ge=1, le=50) -) -> list[LinkTarget]: +) -> list[NoteLinkTarget]: """What a mention can link to, best matches first: `#` for topics; `@` for pages, recordings, people and other entities, collections and speakers.""" sid = acl.namespace(ns) if sign not in ("@", "#"): raise HTTPException(400, "sign is @ or #") - return [LinkTarget(**t) for t in notebook.search_targets(db, sid, q, sign, limit)] + return [NoteLinkTarget(**t) for t in notebook.search_targets(db, sid, q, sign, limit)] @router.get("/about/{kind}/{key}") -def page_about(kind: str, key: int, user: CurrentUser, acl: Acl, db: Db) -> Page | PageDraft: +def page_about(kind: str, key: int, user: CurrentUser, acl: Acl, db: Db) -> NotePage | NotePageDraft: """The page of a recording, entity, collection or speaker: its page, or a draft while nobody has written one.""" thing = f"{kind}:{key}" with domain_errors(): @@ -100,7 +109,7 @@ def page_about(kind: str, key: int, user: CurrentUser, acl: Acl, db: Db) -> Page if p: return _out(acl, db, p, user) name = notebook.labels(db, [thing]).get(thing, {}).get("name") or thing - return PageDraft( + return NotePageDraft( namespace=store.space_names(db).get(sid, ""), about=thing, title=str(name).rsplit("/", 1)[-1], @@ -110,13 +119,13 @@ def page_about(kind: str, key: int, user: CurrentUser, acl: Acl, db: Db) -> Page @router.get("/{pid}") -def get_page(pid: int, user: CurrentUser, acl: Acl, db: Db) -> Page: +def get_page(pid: int, user: CurrentUser, acl: Acl, db: Db) -> NotePage: """A page with its body, its links (with their targets' current names) and the pages linking to it.""" return _out(acl, db, _page(acl, db, pid), user) @router.patch("/{pid}") -def update_page(pid: int, body: PageUpdate, user: Writer, acl: Acl, db: Db) -> Page: +def update_page(pid: int, body: NotePageUpdate, user: Writer, acl: Acl, db: Db) -> NotePage: """Change what's given. A new body without `doc` drops the editor's state, so it's rebuilt from the Markdown.""" _page(acl, db, pid, "editor") given = body.model_fields_set @@ -129,7 +138,7 @@ def update_page(pid: int, body: PageUpdate, user: Writer, acl: Acl, db: Db) -> P @router.post("/{pid}/move") -def move_page(pid: int, body: PageMove, user: Writer, acl: Acl, db: Db) -> Page: +def move_page(pid: int, body: NotePageMove, user: Writer, acl: Acl, db: Db) -> NotePage: """Move a free note in the tree: inside `parent` (null: the top), before `before` (null: at the end).""" _page(acl, db, pid, "editor") with domain_errors(): diff --git a/fastapi_backend/app/schemas/notebook.py b/fastapi_backend/app/schemas/notebook.py index 657830de2..48ee5b7d7 100644 --- a/fastapi_backend/app/schemas/notebook.py +++ b/fastapi_backend/app/schemas/notebook.py @@ -12,7 +12,7 @@ Sign = Literal["@", "#"] -class PageItem(ResponseModel): +class NotePageItem(ResponseModel): id: int title: str summary: str | None = Field(None, description="one line on what the page holds: the context the assistant reads first") @@ -27,7 +27,7 @@ class PageItem(ResponseModel): updated_at: str | None = None -class PageLink(ResponseModel): +class NoteLink(ResponseModel): sign: Sign target: str = Field(description='what it links to, like "recording:12" or "page:3"') label: str = Field(description="the text the link shows") @@ -35,24 +35,24 @@ class PageLink(ResponseModel): namespace: str | None = None -class Backlink(ResponseModel): +class NoteBacklink(ResponseModel): page: int title: str about: str | None = None updated_at: str | None = None -class Page(PageItem): +class NotePage(NotePageItem): namespace: str body: str = Field("", description="Markdown, with mentions written @[label](kind:id) and #[label](entity:id)") doc: str | None = Field(None, description="the editor's own document state, if it kept one") created_by: str | None = Field(None, description="its writer's email") - links: list[PageLink] = [] - backlinks: list[Backlink] = [] + links: list[NoteLink] = [] + backlinks: list[NoteBacklink] = [] can_edit: bool = False -class PageDraft(ResponseModel): +class NotePageDraft(ResponseModel): """A thing's page before anyone has written on it.""" id: None = None @@ -60,16 +60,16 @@ class PageDraft(ResponseModel): about: str title: str body: str = "" - backlinks: list[Backlink] = [] + backlinks: list[NoteBacklink] = [] can_edit: bool = False -class PageTree(ResponseModel): +class NoteTree(ResponseModel): namespace: str - pages: list[PageItem] + pages: list[NotePageItem] -class PageCreate(RequestModel): +class NotePageCreate(RequestModel): ns: str = Field(description="the namespace it goes in") title: str = Field(min_length=1, max_length=200) body: str = Field("", max_length=200_000) @@ -81,7 +81,7 @@ class PageCreate(RequestModel): doc: str | None = None -class PageUpdate(RequestModel): +class NotePageUpdate(RequestModel): title: str | None = Field(None, min_length=1, max_length=200) body: str | None = Field(None, max_length=200_000) summary: str | None = Field(None, max_length=300, description="empty to clear it") @@ -90,12 +90,12 @@ class PageUpdate(RequestModel): doc: str | None = Field(None, description="the editor's document state; a new body without it drops the old one") -class PageMove(RequestModel): +class NotePageMove(RequestModel): parent: int | None = Field(None, description="the page to put it inside; null for the top") before: int | None = Field(None, description="put it before this sibling; null for the end") -class LinkTarget(ResponseModel): +class NoteLinkTarget(ResponseModel): target: str label: str kind: Literal["page", "recording", "entity", "topic", "collection", "speaker"] diff --git a/nextjs-frontend/app/openapi-client/index.ts b/nextjs-frontend/app/openapi-client/index.ts index 687b1db85..536e66da6 100644 --- a/nextjs-frontend/app/openapi-client/index.ts +++ b/nextjs-frontend/app/openapi-client/index.ts @@ -108,14 +108,11 @@ export type { ApproveAccessRequestErrors, ApproveAccessRequestResponse, ApproveAccessRequestResponses, - AppSchemasNotebookPage, - AppSchemasRecordingsPage, AttachedTo, Attachment, AuditEntry, AuthStatus, Backend, - Backlink, Batch, BatchActionResult, BatchCombine, @@ -1105,7 +1102,6 @@ export type { LinkSpeakerErrors, LinkSpeakerResponse, LinkSpeakerResponses, - LinkTarget, LinkTargetsData, LinkTargetsError, LinkTargetsErrors, @@ -1507,7 +1503,17 @@ export type { NodeTrace, NodeType, Note, + NoteBacklink, NoteCreate, + NoteLink, + NoteLinkTarget, + NotePage, + NotePageCreate, + NotePageDraft, + NotePageItem, + NotePageMove, + NotePageUpdate, + NoteTree, NoteUpdate, NotifyDelivery, NotifySecret, @@ -1536,19 +1542,13 @@ export type { OpenRecordingToIpGroupResponses, OriginCount, Output, + Page, PageAboutData, PageAboutError, PageAboutErrors, PageAboutResponse, PageAboutResponses, PageContext, - PageCreate, - PageDraft, - PageItem, - PageLink, - PageMove, - PageTree, - PageUpdate, Passage, Passkey, PasskeyAnswer, diff --git a/nextjs-frontend/app/openapi-client/types.gen.ts b/nextjs-frontend/app/openapi-client/types.gen.ts index 74e9a89f7..1edd47ad5 100644 --- a/nextjs-frontend/app/openapi-client/types.gen.ts +++ b/nextjs-frontend/app/openapi-client/types.gen.ts @@ -394,29 +394,6 @@ export type Backend = { [key: string]: unknown; }; -/** - * Backlink - */ -export type Backlink = { - /** - * Page - */ - page: number; - /** - * Title - */ - title: string; - /** - * About - */ - about?: string | null; - /** - * Updated At - */ - updated_at?: string | null; - [key: string]: unknown; -}; - /** * Batch */ @@ -5609,25 +5586,6 @@ export type LastSend = { [key: string]: unknown; }; -/** - * LinkTarget - */ -export type LinkTarget = { - /** - * Target - */ - target: string; - /** - * Label - */ - label: string; - /** - * Kind - */ - kind: "page" | "recording" | "entity" | "topic" | "collection" | "speaker"; - [key: string]: unknown; -}; - /** * LlmEstimate */ @@ -6619,6 +6577,29 @@ export type Note = { [key: string]: unknown; }; +/** + * NoteBacklink + */ +export type NoteBacklink = { + /** + * Page + */ + page: number; + /** + * Title + */ + title: string; + /** + * About + */ + about?: string | null; + /** + * Updated At + */ + updated_at?: string | null; + [key: string]: unknown; +}; + /** * NoteCreate */ @@ -6654,188 +6635,568 @@ export type NoteCreate = { }; /** - * NoteUpdate + * NoteLink */ -export type NoteUpdate = { +export type NoteLink = { /** - * Text + * Sign */ - text?: string | null; + sign: "@" | "#"; /** - * Shared + * Target * - * share or unshare it (sharing needs editor access) - */ - shared?: boolean | null; -}; - -/** - * NotifyDelivery - */ -export type NotifyDelivery = { - /** - * Id - */ - id: string; - /** - * Event - */ - event: string; - /** - * Status - */ - status: "pending" | "sending" | "sent" | "failed" | "dropped"; - /** - * Attempts - */ - attempts?: number; - /** - * Code - */ - code?: number | null; - /** - * Error + * what it links to, like "recording:12" or "page:3" */ - error?: string | null; + target: string; /** - * Text + * Label * - * the message, as chat targets get it - */ - text?: string | null; - /** - * Created At + * the text the link shows */ - created_at: string; + label: string; /** - * Sent At + * Name + * + * the target's current name; null when it's gone or you can't see it */ - sent_at?: string | null; + name?: string | null; /** - * Next At - * - * when it's tried again, while pending + * Namespace */ - next_at?: string | null; + namespace?: string | null; [key: string]: unknown; }; /** - * NotifySecret + * NoteLinkTarget */ -export type NotifySecret = { +export type NoteLinkTarget = { /** - * Secret - * - * the webhook's new signing secret, shown this once + * Target */ - secret: string; + target: string; + /** + * Label + */ + label: string; + /** + * Kind + */ + kind: "page" | "recording" | "entity" | "topic" | "collection" | "speaker"; [key: string]: unknown; }; /** - * NotifyTarget + * NotePage */ -export type NotifyTarget = { +export type NotePage = { /** * Id */ id: number; /** - * Name + * Title */ - name: string; + title: string; /** - * Kind + * Summary + * + * one line on what the page holds: the context the assistant reads first */ - kind: "webhook" | "matterbridge" | "slack" | "discord"; + summary?: string | null; /** - * Url + * Summary By * - * scheme, host and port of its address; the rest stays sealed + * who wrote the summary */ - url?: string | null; + summary_by?: "person" | "assistant" | null; /** - * Events + * Date */ - events: Array<"job.succeeded" | "job.failed" | "job.cancelled" | "batch.finished" | "recording.added">; + date?: string | null; /** - * Enabled + * Place + * + * where it's filed (PARA): project, area, resource or archive */ - enabled: boolean; + place?: "project" | "area" | "resource" | "archive" | null; /** - * Gateway + * Parent * - * Matterbridge: the gateway it sends to + * the page it's inside, in the tree */ - gateway?: string | null; + parent?: number | null; /** - * Username + * Position * - * Matterbridge: the name messages are sent under + * its order among its siblings */ - username?: string | null; + position?: number | null; /** - * Secret Set + * About * - * webhook: deliveries are signed + * what this is the page of, like "recording:12"; null for a free note */ - secret_set?: boolean; + about?: string | null; /** - * Token Set + * Author * - * Matterbridge: an API token is sent + * who wrote it */ - token_set?: boolean; + author?: "person" | "assistant"; /** - * how the latest send went + * Created At */ - last?: LastSend | null; + created_at?: string | null; /** - * By + * Updated At */ - by?: string | null; + updated_at?: string | null; /** - * At + * Namespace */ - at?: string | null; + namespace: string; /** - * Updated By + * Body + * + * Markdown, with mentions written @[label](kind:id) and #[label](entity:id) */ - updated_by?: string | null; + body?: string; /** - * Updated At + * Doc + * + * the editor's own document state, if it kept one */ - updated_at?: string | null; + doc?: string | null; + /** + * Created By + * + * its writer's email + */ + created_by?: string | null; + /** + * Links + */ + links?: Array; + /** + * Backlinks + */ + backlinks?: Array; + /** + * Can Edit + */ + can_edit?: boolean; [key: string]: unknown; }; /** - * NotifyTargetCreate + * NotePageCreate */ -export type NotifyTargetCreate = { +export type NotePageCreate = { /** - * Name + * Ns + * + * the namespace it goes in */ - name: string; + ns: string; /** - * Kind + * Title */ - kind: "webhook" | "matterbridge" | "slack" | "discord"; + title: string; /** - * Url - * - * where to POST: the webhook's URL, or the Matterbridge API's address (/api/message is added) + * Body */ - url: string; + body?: string; /** - * Events - * - * default: job.failed and batch.finished + * Summary */ - events?: Array<"job.succeeded" | "job.failed" | "job.cancelled" | "batch.finished" | "recording.added"> | null; + summary?: string | null; /** - * Enabled + * Date + * + * YYYY-MM-DD (default: today) + */ + date?: string | null; + /** + * Place + */ + place?: "project" | "area" | "resource" | "archive" | null; + /** + * Parent + * + * put it inside this page + */ + parent?: number | null; + /** + * About + * + * make the page of this thing, like "recording:12" or "entity:5" + */ + about?: string | null; + /** + * Doc + */ + doc?: string | null; +}; + +/** + * NotePageDraft + * + * A thing's page before anyone has written on it. + */ +export type NotePageDraft = { + /** + * Id + */ + id?: null; + /** + * Namespace + */ + namespace: string; + /** + * About + */ + about: string; + /** + * Title + */ + title: string; + /** + * Body + */ + body?: string; + /** + * Backlinks + */ + backlinks?: Array; + /** + * Can Edit + */ + can_edit?: boolean; + [key: string]: unknown; +}; + +/** + * NotePageItem + */ +export type NotePageItem = { + /** + * Id + */ + id: number; + /** + * Title + */ + title: string; + /** + * Summary + * + * one line on what the page holds: the context the assistant reads first + */ + summary?: string | null; + /** + * Summary By + * + * who wrote the summary + */ + summary_by?: "person" | "assistant" | null; + /** + * Date + */ + date?: string | null; + /** + * Place + * + * where it's filed (PARA): project, area, resource or archive + */ + place?: "project" | "area" | "resource" | "archive" | null; + /** + * Parent + * + * the page it's inside, in the tree + */ + parent?: number | null; + /** + * Position + * + * its order among its siblings + */ + position?: number | null; + /** + * About + * + * what this is the page of, like "recording:12"; null for a free note + */ + about?: string | null; + /** + * Author + * + * who wrote it + */ + author?: "person" | "assistant"; + /** + * Created At + */ + created_at?: string | null; + /** + * Updated At + */ + updated_at?: string | null; + [key: string]: unknown; +}; + +/** + * NotePageMove + */ +export type NotePageMove = { + /** + * Parent + * + * the page to put it inside; null for the top + */ + parent?: number | null; + /** + * Before + * + * put it before this sibling; null for the end + */ + before?: number | null; +}; + +/** + * NotePageUpdate + */ +export type NotePageUpdate = { + /** + * Title + */ + title?: string | null; + /** + * Body + */ + body?: string | null; + /** + * Summary + * + * empty to clear it + */ + summary?: string | null; + /** + * Date + */ + date?: string | null; + /** + * Place + * + * "" to unfile it + */ + place?: "project" | "area" | "resource" | "archive" | "" | null; + /** + * Doc + * + * the editor's document state; a new body without it drops the old one + */ + doc?: string | null; +}; + +/** + * NoteTree + */ +export type NoteTree = { + /** + * Namespace + */ + namespace: string; + /** + * Pages + */ + pages: Array; + [key: string]: unknown; +}; + +/** + * NoteUpdate + */ +export type NoteUpdate = { + /** + * Text + */ + text?: string | null; + /** + * Shared + * + * share or unshare it (sharing needs editor access) + */ + shared?: boolean | null; +}; + +/** + * NotifyDelivery + */ +export type NotifyDelivery = { + /** + * Id + */ + id: string; + /** + * Event + */ + event: string; + /** + * Status + */ + status: "pending" | "sending" | "sent" | "failed" | "dropped"; + /** + * Attempts + */ + attempts?: number; + /** + * Code + */ + code?: number | null; + /** + * Error + */ + error?: string | null; + /** + * Text + * + * the message, as chat targets get it + */ + text?: string | null; + /** + * Created At + */ + created_at: string; + /** + * Sent At + */ + sent_at?: string | null; + /** + * Next At + * + * when it's tried again, while pending + */ + next_at?: string | null; + [key: string]: unknown; +}; + +/** + * NotifySecret + */ +export type NotifySecret = { + /** + * Secret + * + * the webhook's new signing secret, shown this once + */ + secret: string; + [key: string]: unknown; +}; + +/** + * NotifyTarget + */ +export type NotifyTarget = { + /** + * Id + */ + id: number; + /** + * Name + */ + name: string; + /** + * Kind + */ + kind: "webhook" | "matterbridge" | "slack" | "discord"; + /** + * Url + * + * scheme, host and port of its address; the rest stays sealed + */ + url?: string | null; + /** + * Events + */ + events: Array<"job.succeeded" | "job.failed" | "job.cancelled" | "batch.finished" | "recording.added">; + /** + * Enabled + */ + enabled: boolean; + /** + * Gateway + * + * Matterbridge: the gateway it sends to + */ + gateway?: string | null; + /** + * Username + * + * Matterbridge: the name messages are sent under + */ + username?: string | null; + /** + * Secret Set + * + * webhook: deliveries are signed + */ + secret_set?: boolean; + /** + * Token Set + * + * Matterbridge: an API token is sent + */ + token_set?: boolean; + /** + * how the latest send went + */ + last?: LastSend | null; + /** + * By + */ + by?: string | null; + /** + * At + */ + at?: string | null; + /** + * Updated By + */ + updated_by?: string | null; + /** + * Updated At + */ + updated_at?: string | null; + [key: string]: unknown; +}; + +/** + * NotifyTargetCreate + */ +export type NotifyTargetCreate = { + /** + * Name + */ + name: string; + /** + * Kind + */ + kind: "webhook" | "matterbridge" | "slack" | "discord"; + /** + * Url + * + * where to POST: the webhook's URL, or the Matterbridge API's address (/api/message is added) + */ + url: string; + /** + * Events + * + * default: job.failed and batch.finished + */ + events?: Array<"job.succeeded" | "job.failed" | "job.cancelled" | "batch.finished" | "recording.added"> | null; + /** + * Enabled */ enabled?: boolean; /** @@ -7190,300 +7551,97 @@ export type Output = { /** * Origin */ - origin?: unknown; - /** - * Created At - */ - created_at?: string | null; - [key: string]: unknown; -}; - -/** - * PageContext - * - * The page a question was asked from (chat on any page): where it is, and what of it the person shared. - */ -export type PageContext = { - /** - * Url - * - * the page's path in Lens, e.g. /resources/12?t=30 - */ - url: string; - /** - * Title - */ - title?: string | null; - /** - * Text - * - * the page's visible text, when the person shares the page (only the first 12,000 characters are used) - */ - text?: string | null; - /** - * Selection - * - * text the person highlighted on it (only the first 4,000 characters are used) - */ - selection?: string | null; -}; - -/** - * PageCreate - */ -export type PageCreate = { - /** - * Ns - * - * the namespace it goes in - */ - ns: string; - /** - * Title - */ - title: string; - /** - * Body - */ - body?: string; - /** - * Summary - */ - summary?: string | null; - /** - * Date - * - * YYYY-MM-DD (default: today) - */ - date?: string | null; - /** - * Place - */ - place?: "project" | "area" | "resource" | "archive" | null; - /** - * Parent - * - * put it inside this page - */ - parent?: number | null; - /** - * About - * - * make the page of this thing, like "recording:12" or "entity:5" - */ - about?: string | null; - /** - * Doc - */ - doc?: string | null; -}; - -/** - * PageDraft - * - * A thing's page before anyone has written on it. - */ -export type PageDraft = { - /** - * Id - */ - id?: null; - /** - * Namespace - */ - namespace: string; - /** - * About - */ - about: string; - /** - * Title - */ - title: string; - /** - * Body - */ - body?: string; - /** - * Backlinks - */ - backlinks?: Array; - /** - * Can Edit - */ - can_edit?: boolean; - [key: string]: unknown; -}; - -/** - * PageItem - */ -export type PageItem = { - /** - * Id - */ - id: number; - /** - * Title - */ - title: string; - /** - * Summary - * - * one line on what the page holds: the context the assistant reads first - */ - summary?: string | null; - /** - * Summary By - * - * who wrote the summary - */ - summary_by?: "person" | "assistant" | null; - /** - * Date - */ - date?: string | null; - /** - * Place - * - * where it's filed (PARA): project, area, resource or archive - */ - place?: "project" | "area" | "resource" | "archive" | null; - /** - * Parent - * - * the page it's inside, in the tree - */ - parent?: number | null; - /** - * Position - * - * its order among its siblings - */ - position?: number | null; - /** - * About - * - * what this is the page of, like "recording:12"; null for a free note - */ - about?: string | null; - /** - * Author - * - * who wrote it - */ - author?: "person" | "assistant"; + origin?: unknown; /** * Created At */ created_at?: string | null; - /** - * Updated At - */ - updated_at?: string | null; [key: string]: unknown; }; /** - * PageLink + * Page + * + * A page of a document, or an image (a TIFF has one per frame). */ -export type PageLink = { +export type Page = { /** - * Sign - */ - sign: "@" | "#"; - /** - * Target + * Idx * - * what it links to, like "recording:12" or "page:3" + * from 0 */ - target: string; + idx: number; /** - * Label + * Width * - * the text the link shows + * pixels of its image */ - label: string; + width?: number | null; /** - * Name - * - * the target's current name; null when it's gone or you can't see it + * Height */ - name?: string | null; + height?: number | null; /** - * Namespace + * Image + * + * a signed link to it, drawn; none when it couldn't be */ - namespace?: string | null; - [key: string]: unknown; -}; - -/** - * PageMove - */ -export type PageMove = { + image?: string | null; /** - * Parent + * Thumb * - * the page to put it inside; null for the top + * a signed link to it, small */ - parent?: number | null; + thumb?: string | null; /** - * Before + * Text * - * put it before this sibling; null for the end + * how its text was read: from the PDF, or by OCR; none without text */ - before?: number | null; -}; - -/** - * PageTree - */ -export type PageTree = { + text?: "pdf" | "ocr" | null; /** - * Namespace + * Chars + * + * characters of text on it */ - namespace: string; + chars?: number; /** - * Pages + * Label + * + * the PDF's own name for it (iv, A-1, …) when it isn't its number */ - pages: Array; + label?: string | null; [key: string]: unknown; }; /** - * PageUpdate + * PageContext + * + * The page a question was asked from (chat on any page): where it is, and what of it the person shared. */ -export type PageUpdate = { - /** - * Title - */ - title?: string | null; - /** - * Body - */ - body?: string | null; +export type PageContext = { /** - * Summary + * Url * - * empty to clear it + * the page's path in Lens, e.g. /resources/12?t=30 */ - summary?: string | null; + url: string; /** - * Date + * Title */ - date?: string | null; + title?: string | null; /** - * Place + * Text * - * "" to unfile it + * the page's visible text, when the person shares the page (only the first 12,000 characters are used) */ - place?: "project" | "area" | "resource" | "archive" | "" | null; + text?: string | null; /** - * Doc + * Selection * - * the editor's document state; a new body without it drops the old one + * text the person highlighted on it (only the first 4,000 characters are used) */ - doc?: string | null; + selection?: string | null; }; /** @@ -8140,7 +8298,7 @@ export type Player = { * * a document's or an image's pages, in order */ - pages?: Array | null; + pages?: Array | null; /** * Objects * @@ -14225,164 +14383,6 @@ export type WorkflowVersionInfo = { [key: string]: unknown; }; -/** - * Page - */ -export type AppSchemasNotebookPage = { - /** - * Id - */ - id: number; - /** - * Title - */ - title: string; - /** - * Summary - * - * one line on what the page holds: the context the assistant reads first - */ - summary?: string | null; - /** - * Summary By - * - * who wrote the summary - */ - summary_by?: "person" | "assistant" | null; - /** - * Date - */ - date?: string | null; - /** - * Place - * - * where it's filed (PARA): project, area, resource or archive - */ - place?: "project" | "area" | "resource" | "archive" | null; - /** - * Parent - * - * the page it's inside, in the tree - */ - parent?: number | null; - /** - * Position - * - * its order among its siblings - */ - position?: number | null; - /** - * About - * - * what this is the page of, like "recording:12"; null for a free note - */ - about?: string | null; - /** - * Author - * - * who wrote it - */ - author?: "person" | "assistant"; - /** - * Created At - */ - created_at?: string | null; - /** - * Updated At - */ - updated_at?: string | null; - /** - * Namespace - */ - namespace: string; - /** - * Body - * - * Markdown, with mentions written @[label](kind:id) and #[label](entity:id) - */ - body?: string; - /** - * Doc - * - * the editor's own document state, if it kept one - */ - doc?: string | null; - /** - * Created By - * - * its writer's email - */ - created_by?: string | null; - /** - * Links - */ - links?: Array; - /** - * Backlinks - */ - backlinks?: Array; - /** - * Can Edit - */ - can_edit?: boolean; - [key: string]: unknown; -}; - -/** - * Page - * - * A page of a document, or an image (a TIFF has one per frame). - */ -export type AppSchemasRecordingsPage = { - /** - * Idx - * - * from 0 - */ - idx: number; - /** - * Width - * - * pixels of its image - */ - width?: number | null; - /** - * Height - */ - height?: number | null; - /** - * Image - * - * a signed link to it, drawn; none when it couldn't be - */ - image?: string | null; - /** - * Thumb - * - * a signed link to it, small - */ - thumb?: string | null; - /** - * Text - * - * how its text was read: from the PDF, or by OCR; none without text - */ - text?: "pdf" | "ocr" | null; - /** - * Chars - * - * characters of text on it - */ - chars?: number; - /** - * Label - * - * the PDF's own name for it (iv, A-1, …) when it isn't its number - */ - label?: string | null; - [key: string]: unknown; -}; - export type StatusData = { body?: never; path?: never; @@ -18305,13 +18305,13 @@ export type ListPagesResponses = { /** * Successful Response */ - 200: PageTree; + 200: NoteTree; }; export type ListPagesResponse = ListPagesResponses[keyof ListPagesResponses]; export type CreatePageData = { - body: PageCreate; + body: NotePageCreate; path?: never; query?: never; url: "/api/v1/notes"; @@ -18330,7 +18330,7 @@ export type CreatePageResponses = { /** * Successful Response */ - 200: AppSchemasNotebookPage; + 200: NotePage; }; export type CreatePageResponse = CreatePageResponses[keyof CreatePageResponses]; @@ -18374,7 +18374,7 @@ export type LinkTargetsResponses = { * * Successful Response */ - 200: Array; + 200: Array; }; export type LinkTargetsResponse = LinkTargetsResponses[keyof LinkTargetsResponses]; @@ -18410,7 +18410,7 @@ export type PageAboutResponses = { * * Successful Response */ - 200: AppSchemasNotebookPage | PageDraft; + 200: NotePage | NotePageDraft; }; export type PageAboutResponse = PageAboutResponses[keyof PageAboutResponses]; @@ -18470,13 +18470,13 @@ export type GetPageResponses = { /** * Successful Response */ - 200: AppSchemasNotebookPage; + 200: NotePage; }; export type GetPageResponse = GetPageResponses[keyof GetPageResponses]; export type UpdatePageData = { - body: PageUpdate; + body: NotePageUpdate; path: { /** * Pid @@ -18500,13 +18500,13 @@ export type UpdatePageResponses = { /** * Successful Response */ - 200: AppSchemasNotebookPage; + 200: NotePage; }; export type UpdatePageResponse = UpdatePageResponses[keyof UpdatePageResponses]; export type MovePageData = { - body: PageMove; + body: NotePageMove; path: { /** * Pid @@ -18530,7 +18530,7 @@ export type MovePageResponses = { /** * Successful Response */ - 200: AppSchemasNotebookPage; + 200: NotePage; }; export type MovePageResponse = MovePageResponses[keyof MovePageResponses]; diff --git a/nextjs-frontend/openapi.json b/nextjs-frontend/openapi.json index 65e6576f2..dcb2afc14 100644 --- a/nextjs-frontend/openapi.json +++ b/nextjs-frontend/openapi.json @@ -6373,7 +6373,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PageTree" + "$ref": "#/components/schemas/NoteTree" } } } @@ -6402,7 +6402,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PageCreate" + "$ref": "#/components/schemas/NotePageCreate" } } } @@ -6413,7 +6413,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/app__schemas__notebook__Page" + "$ref": "#/components/schemas/NotePage" } } } @@ -6490,7 +6490,7 @@ "schema": { "type": "array", "items": { - "$ref": "#/components/schemas/LinkTarget" + "$ref": "#/components/schemas/NoteLinkTarget" }, "title": "Response Notes-Link Targets" } @@ -6546,10 +6546,10 @@ "schema": { "anyOf": [ { - "$ref": "#/components/schemas/app__schemas__notebook__Page" + "$ref": "#/components/schemas/NotePage" }, { - "$ref": "#/components/schemas/PageDraft" + "$ref": "#/components/schemas/NotePageDraft" } ], "title": "Response Notes-Page About" @@ -6595,7 +6595,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/app__schemas__notebook__Page" + "$ref": "#/components/schemas/NotePage" } } } @@ -6635,7 +6635,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PageUpdate" + "$ref": "#/components/schemas/NotePageUpdate" } } } @@ -6646,7 +6646,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/app__schemas__notebook__Page" + "$ref": "#/components/schemas/NotePage" } } } @@ -6729,7 +6729,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/PageMove" + "$ref": "#/components/schemas/NotePageMove" } } } @@ -6740,7 +6740,7 @@ "content": { "application/json": { "schema": { - "$ref": "#/components/schemas/app__schemas__notebook__Page" + "$ref": "#/components/schemas/NotePage" } } } @@ -20612,47 +20612,6 @@ ], "title": "Backend" }, - "Backlink": { - "properties": { - "page": { - "type": "integer", - "title": "Page" - }, - "title": { - "type": "string", - "title": "Title" - }, - "about": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "About" - }, - "updated_at": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Updated At" - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "page", - "title" - ], - "title": "Backlink" - }, "Batch": { "properties": { "id": { @@ -29711,38 +29670,6 @@ ], "title": "LastSend" }, - "LinkTarget": { - "properties": { - "target": { - "type": "string", - "title": "Target" - }, - "label": { - "type": "string", - "title": "Label" - }, - "kind": { - "type": "string", - "enum": [ - "page", - "recording", - "entity", - "topic", - "collection", - "speaker" - ], - "title": "Kind" - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "target", - "label", - "kind" - ], - "title": "LinkTarget" - }, "LlmEstimate": { "properties": { "calls": { @@ -31385,6 +31312,47 @@ ], "title": "Note" }, + "NoteBacklink": { + "properties": { + "page": { + "type": "integer", + "title": "Page" + }, + "title": { + "type": "string", + "title": "Title" + }, + "about": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "About" + }, + "updated_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Updated At" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "page", + "title" + ], + "title": "NoteBacklink" + }, "NoteCreate": { "properties": { "text": { @@ -31446,6 +31414,729 @@ ], "title": "NoteCreate" }, + "NoteLink": { + "properties": { + "sign": { + "type": "string", + "enum": [ + "@", + "#" + ], + "title": "Sign" + }, + "target": { + "type": "string", + "title": "Target", + "description": "what it links to, like \"recording:12\" or \"page:3\"" + }, + "label": { + "type": "string", + "title": "Label", + "description": "the text the link shows" + }, + "name": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Name", + "description": "the target's current name; null when it's gone or you can't see it" + }, + "namespace": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Namespace" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "sign", + "target", + "label" + ], + "title": "NoteLink" + }, + "NoteLinkTarget": { + "properties": { + "target": { + "type": "string", + "title": "Target" + }, + "label": { + "type": "string", + "title": "Label" + }, + "kind": { + "type": "string", + "enum": [ + "page", + "recording", + "entity", + "topic", + "collection", + "speaker" + ], + "title": "Kind" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "target", + "label", + "kind" + ], + "title": "NoteLinkTarget" + }, + "NotePage": { + "properties": { + "id": { + "type": "integer", + "title": "Id" + }, + "title": { + "type": "string", + "title": "Title" + }, + "summary": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Summary", + "description": "one line on what the page holds: the context the assistant reads first" + }, + "summary_by": { + "anyOf": [ + { + "type": "string", + "enum": [ + "person", + "assistant" + ] + }, + { + "type": "null" + } + ], + "title": "Summary By", + "description": "who wrote the summary" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "null" + } + ], + "title": "Place", + "description": "where it's filed (PARA): project, area, resource or archive" + }, + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "the page it's inside, in the tree" + }, + "position": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Position", + "description": "its order among its siblings" + }, + "about": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "About", + "description": "what this is the page of, like \"recording:12\"; null for a free note" + }, + "author": { + "type": "string", + "enum": [ + "person", + "assistant" + ], + "title": "Author", + "description": "who wrote it", + "default": "person" + }, + "created_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Created At" + }, + "updated_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Updated At" + }, + "namespace": { + "type": "string", + "title": "Namespace" + }, + "body": { + "type": "string", + "title": "Body", + "description": "Markdown, with mentions written @[label](kind:id) and #[label](entity:id)", + "default": "" + }, + "doc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Doc", + "description": "the editor's own document state, if it kept one" + }, + "created_by": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Created By", + "description": "its writer's email" + }, + "links": { + "items": { + "$ref": "#/components/schemas/NoteLink" + }, + "type": "array", + "title": "Links", + "default": [] + }, + "backlinks": { + "items": { + "$ref": "#/components/schemas/NoteBacklink" + }, + "type": "array", + "title": "Backlinks", + "default": [] + }, + "can_edit": { + "type": "boolean", + "title": "Can Edit", + "default": false + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "id", + "title", + "namespace" + ], + "title": "NotePage" + }, + "NotePageCreate": { + "properties": { + "ns": { + "type": "string", + "title": "Ns", + "description": "the namespace it goes in" + }, + "title": { + "type": "string", + "maxLength": 200, + "minLength": 1, + "title": "Title" + }, + "body": { + "type": "string", + "maxLength": 200000, + "title": "Body", + "default": "" + }, + "summary": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ], + "title": "Summary" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date", + "description": "YYYY-MM-DD (default: today)" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "null" + } + ], + "title": "Place" + }, + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "put it inside this page" + }, + "about": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "About", + "description": "make the page of this thing, like \"recording:12\" or \"entity:5\"" + }, + "doc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Doc" + } + }, + "additionalProperties": false, + "type": "object", + "required": [ + "ns", + "title" + ], + "title": "NotePageCreate" + }, + "NotePageDraft": { + "properties": { + "id": { + "type": "null", + "title": "Id" + }, + "namespace": { + "type": "string", + "title": "Namespace" + }, + "about": { + "type": "string", + "title": "About" + }, + "title": { + "type": "string", + "title": "Title" + }, + "body": { + "type": "string", + "title": "Body", + "default": "" + }, + "backlinks": { + "items": { + "$ref": "#/components/schemas/NoteBacklink" + }, + "type": "array", + "title": "Backlinks", + "default": [] + }, + "can_edit": { + "type": "boolean", + "title": "Can Edit", + "default": false + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "namespace", + "about", + "title" + ], + "title": "NotePageDraft", + "description": "A thing's page before anyone has written on it." + }, + "NotePageItem": { + "properties": { + "id": { + "type": "integer", + "title": "Id" + }, + "title": { + "type": "string", + "title": "Title" + }, + "summary": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Summary", + "description": "one line on what the page holds: the context the assistant reads first" + }, + "summary_by": { + "anyOf": [ + { + "type": "string", + "enum": [ + "person", + "assistant" + ] + }, + { + "type": "null" + } + ], + "title": "Summary By", + "description": "who wrote the summary" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "null" + } + ], + "title": "Place", + "description": "where it's filed (PARA): project, area, resource or archive" + }, + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "the page it's inside, in the tree" + }, + "position": { + "anyOf": [ + { + "type": "number" + }, + { + "type": "null" + } + ], + "title": "Position", + "description": "its order among its siblings" + }, + "about": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "About", + "description": "what this is the page of, like \"recording:12\"; null for a free note" + }, + "author": { + "type": "string", + "enum": [ + "person", + "assistant" + ], + "title": "Author", + "description": "who wrote it", + "default": "person" + }, + "created_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Created At" + }, + "updated_at": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Updated At" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "id", + "title" + ], + "title": "NotePageItem" + }, + "NotePageMove": { + "properties": { + "parent": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Parent", + "description": "the page to put it inside; null for the top" + }, + "before": { + "anyOf": [ + { + "type": "integer" + }, + { + "type": "null" + } + ], + "title": "Before", + "description": "put it before this sibling; null for the end" + } + }, + "additionalProperties": false, + "type": "object", + "title": "NotePageMove" + }, + "NotePageUpdate": { + "properties": { + "title": { + "anyOf": [ + { + "type": "string", + "maxLength": 200, + "minLength": 1 + }, + { + "type": "null" + } + ], + "title": "Title" + }, + "body": { + "anyOf": [ + { + "type": "string", + "maxLength": 200000 + }, + { + "type": "null" + } + ], + "title": "Body" + }, + "summary": { + "anyOf": [ + { + "type": "string", + "maxLength": 300 + }, + { + "type": "null" + } + ], + "title": "Summary", + "description": "empty to clear it" + }, + "date": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Date" + }, + "place": { + "anyOf": [ + { + "type": "string", + "enum": [ + "project", + "area", + "resource", + "archive" + ] + }, + { + "type": "string", + "const": "" + }, + { + "type": "null" + } + ], + "title": "Place", + "description": "\"\" to unfile it" + }, + "doc": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "null" + } + ], + "title": "Doc", + "description": "the editor's document state; a new body without it drops the old one" + } + }, + "additionalProperties": false, + "type": "object", + "title": "NotePageUpdate" + }, + "NoteTree": { + "properties": { + "namespace": { + "type": "string", + "title": "Namespace" + }, + "pages": { + "items": { + "$ref": "#/components/schemas/NotePageItem" + }, + "type": "array", + "title": "Pages" + } + }, + "additionalProperties": true, + "type": "object", + "required": [ + "namespace", + "pages" + ], + "title": "NoteTree" + }, "NoteUpdate": { "properties": { "text": { @@ -32387,123 +33078,14 @@ ], "title": "Output" }, - "PageContext": { - "properties": { - "url": { - "type": "string", - "maxLength": 2000, - "pattern": "^/([^/]|$)", - "title": "Url", - "description": "the page's path in Lens, e.g. /resources/12?t=30" - }, - "title": { - "anyOf": [ - { - "type": "string", - "maxLength": 300 - }, - { - "type": "null" - } - ], - "title": "Title" - }, - "text": { - "anyOf": [ - { - "type": "string", - "maxLength": 200000 - }, - { - "type": "null" - } - ], - "title": "Text", - "description": "the page's visible text, when the person shares the page (only the first 12,000 characters are used)" - }, - "selection": { - "anyOf": [ - { - "type": "string", - "maxLength": 50000 - }, - { - "type": "null" - } - ], - "title": "Selection", - "description": "text the person highlighted on it (only the first 4,000 characters are used)" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "url" - ], - "title": "PageContext", - "description": "The page a question was asked from (chat on any page): where it is, and what of it the person shared." - }, - "PageCreate": { + "Page": { "properties": { - "ns": { - "type": "string", - "title": "Ns", - "description": "the namespace it goes in" - }, - "title": { - "type": "string", - "maxLength": 200, - "minLength": 1, - "title": "Title" - }, - "body": { - "type": "string", - "maxLength": 200000, - "title": "Body", - "default": "" - }, - "summary": { - "anyOf": [ - { - "type": "string", - "maxLength": 300 - }, - { - "type": "null" - } - ], - "title": "Summary" - }, - "date": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Date", - "description": "YYYY-MM-DD (default: today)" - }, - "place": { - "anyOf": [ - { - "type": "string", - "enum": [ - "project", - "area", - "resource", - "archive" - ] - }, - { - "type": "null" - } - ], - "title": "Place" + "idx": { + "type": "integer", + "title": "Idx", + "description": "from 0" }, - "parent": { + "width": { "anyOf": [ { "type": "integer" @@ -32512,99 +33094,21 @@ "type": "null" } ], - "title": "Parent", - "description": "put it inside this page" - }, - "about": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "About", - "description": "make the page of this thing, like \"recording:12\" or \"entity:5\"" + "title": "Width", + "description": "pixels of its image" }, - "doc": { + "height": { "anyOf": [ { - "type": "string" + "type": "integer" }, { "type": "null" } ], - "title": "Doc" - } - }, - "additionalProperties": false, - "type": "object", - "required": [ - "ns", - "title" - ], - "title": "PageCreate" - }, - "PageDraft": { - "properties": { - "id": { - "type": "null", - "title": "Id" - }, - "namespace": { - "type": "string", - "title": "Namespace" - }, - "about": { - "type": "string", - "title": "About" - }, - "title": { - "type": "string", - "title": "Title" - }, - "body": { - "type": "string", - "title": "Body", - "default": "" - }, - "backlinks": { - "items": { - "$ref": "#/components/schemas/Backlink" - }, - "type": "array", - "title": "Backlinks", - "default": [] - }, - "can_edit": { - "type": "boolean", - "title": "Can Edit", - "default": false - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "namespace", - "about", - "title" - ], - "title": "PageDraft", - "description": "A thing's page before anyone has written on it." - }, - "PageItem": { - "properties": { - "id": { - "type": "integer", - "title": "Id" - }, - "title": { - "type": "string", - "title": "Title" + "title": "Height" }, - "summary": { + "image": { "anyOf": [ { "type": "string" @@ -32613,26 +33117,10 @@ "type": "null" } ], - "title": "Summary", - "description": "one line on what the page holds: the context the assistant reads first" - }, - "summary_by": { - "anyOf": [ - { - "type": "string", - "enum": [ - "person", - "assistant" - ] - }, - { - "type": "null" - } - ], - "title": "Summary By", - "description": "who wrote the summary" + "title": "Image", + "description": "a signed link to it, drawn; none when it couldn't be" }, - "date": { + "thumb": { "anyOf": [ { "type": "string" @@ -32641,136 +33129,32 @@ "type": "null" } ], - "title": "Date" + "title": "Thumb", + "description": "a signed link to it, small" }, - "place": { + "text": { "anyOf": [ { "type": "string", "enum": [ - "project", - "area", - "resource", - "archive" + "pdf", + "ocr" ] }, { "type": "null" } ], - "title": "Place", - "description": "where it's filed (PARA): project, area, resource or archive" - }, - "parent": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Parent", - "description": "the page it's inside, in the tree" - }, - "position": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "title": "Position", - "description": "its order among its siblings" - }, - "about": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "About", - "description": "what this is the page of, like \"recording:12\"; null for a free note" - }, - "author": { - "type": "string", - "enum": [ - "person", - "assistant" - ], - "title": "Author", - "description": "who wrote it", - "default": "person" - }, - "created_at": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Created At" - }, - "updated_at": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Updated At" - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "id", - "title" - ], - "title": "PageItem" - }, - "PageLink": { - "properties": { - "sign": { - "type": "string", - "enum": [ - "@", - "#" - ], - "title": "Sign" + "title": "Text", + "description": "how its text was read: from the PDF, or by OCR; none without text" }, - "target": { - "type": "string", - "title": "Target", - "description": "what it links to, like \"recording:12\" or \"page:3\"" + "chars": { + "type": "integer", + "title": "Chars", + "description": "characters of text on it", + "default": 0 }, "label": { - "type": "string", - "title": "Label", - "description": "the text the link shows" - }, - "name": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Name", - "description": "the target's current name; null when it's gone or you can't see it" - }, - "namespace": { "anyOf": [ { "type": "string" @@ -32779,79 +33163,32 @@ "type": "null" } ], - "title": "Namespace" + "title": "Label", + "description": "the PDF's own name for it (iv, A-1, \u2026) when it isn't its number" } }, "additionalProperties": true, "type": "object", "required": [ - "sign", - "target", - "label" + "idx" ], - "title": "PageLink" - }, - "PageMove": { - "properties": { - "parent": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Parent", - "description": "the page to put it inside; null for the top" - }, - "before": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Before", - "description": "put it before this sibling; null for the end" - } - }, - "additionalProperties": false, - "type": "object", - "title": "PageMove" + "title": "Page", + "description": "A page of a document, or an image (a TIFF has one per frame)." }, - "PageTree": { + "PageContext": { "properties": { - "namespace": { + "url": { "type": "string", - "title": "Namespace" + "maxLength": 2000, + "pattern": "^/([^/]|$)", + "title": "Url", + "description": "the page's path in Lens, e.g. /resources/12?t=30" }, - "pages": { - "items": { - "$ref": "#/components/schemas/PageItem" - }, - "type": "array", - "title": "Pages" - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "namespace", - "pages" - ], - "title": "PageTree" - }, - "PageUpdate": { - "properties": { "title": { "anyOf": [ { "type": "string", - "maxLength": 200, - "minLength": 1 + "maxLength": 300 }, { "type": "null" @@ -32859,7 +33196,7 @@ ], "title": "Title" }, - "body": { + "text": { "anyOf": [ { "type": "string", @@ -32869,70 +33206,30 @@ "type": "null" } ], - "title": "Body" - }, - "summary": { - "anyOf": [ - { - "type": "string", - "maxLength": 300 - }, - { - "type": "null" - } - ], - "title": "Summary", - "description": "empty to clear it" - }, - "date": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Date" + "title": "Text", + "description": "the page's visible text, when the person shares the page (only the first 12,000 characters are used)" }, - "place": { + "selection": { "anyOf": [ { "type": "string", - "enum": [ - "project", - "area", - "resource", - "archive" - ] - }, - { - "type": "string", - "const": "" - }, - { - "type": "null" - } - ], - "title": "Place", - "description": "\"\" to unfile it" - }, - "doc": { - "anyOf": [ - { - "type": "string" + "maxLength": 50000 }, { "type": "null" } ], - "title": "Doc", - "description": "the editor's document state; a new body without it drops the old one" + "title": "Selection", + "description": "text the person highlighted on it (only the first 4,000 characters are used)" } }, "additionalProperties": false, "type": "object", - "title": "PageUpdate" + "required": [ + "url" + ], + "title": "PageContext", + "description": "The page a question was asked from (chat on any page): where it is, and what of it the person shared." }, "Passage": { "properties": { @@ -34048,7 +34345,7 @@ "anyOf": [ { "items": { - "$ref": "#/components/schemas/app__schemas__recordings__Page" + "$ref": "#/components/schemas/Page" }, "type": "array" }, @@ -44709,303 +45006,6 @@ "version" ], "title": "WorkflowVersionInfo" - }, - "app__schemas__notebook__Page": { - "properties": { - "id": { - "type": "integer", - "title": "Id" - }, - "title": { - "type": "string", - "title": "Title" - }, - "summary": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Summary", - "description": "one line on what the page holds: the context the assistant reads first" - }, - "summary_by": { - "anyOf": [ - { - "type": "string", - "enum": [ - "person", - "assistant" - ] - }, - { - "type": "null" - } - ], - "title": "Summary By", - "description": "who wrote the summary" - }, - "date": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Date" - }, - "place": { - "anyOf": [ - { - "type": "string", - "enum": [ - "project", - "area", - "resource", - "archive" - ] - }, - { - "type": "null" - } - ], - "title": "Place", - "description": "where it's filed (PARA): project, area, resource or archive" - }, - "parent": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Parent", - "description": "the page it's inside, in the tree" - }, - "position": { - "anyOf": [ - { - "type": "number" - }, - { - "type": "null" - } - ], - "title": "Position", - "description": "its order among its siblings" - }, - "about": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "About", - "description": "what this is the page of, like \"recording:12\"; null for a free note" - }, - "author": { - "type": "string", - "enum": [ - "person", - "assistant" - ], - "title": "Author", - "description": "who wrote it", - "default": "person" - }, - "created_at": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Created At" - }, - "updated_at": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Updated At" - }, - "namespace": { - "type": "string", - "title": "Namespace" - }, - "body": { - "type": "string", - "title": "Body", - "description": "Markdown, with mentions written @[label](kind:id) and #[label](entity:id)", - "default": "" - }, - "doc": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Doc", - "description": "the editor's own document state, if it kept one" - }, - "created_by": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Created By", - "description": "its writer's email" - }, - "links": { - "items": { - "$ref": "#/components/schemas/PageLink" - }, - "type": "array", - "title": "Links", - "default": [] - }, - "backlinks": { - "items": { - "$ref": "#/components/schemas/Backlink" - }, - "type": "array", - "title": "Backlinks", - "default": [] - }, - "can_edit": { - "type": "boolean", - "title": "Can Edit", - "default": false - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "id", - "title", - "namespace" - ], - "title": "Page" - }, - "app__schemas__recordings__Page": { - "properties": { - "idx": { - "type": "integer", - "title": "Idx", - "description": "from 0" - }, - "width": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Width", - "description": "pixels of its image" - }, - "height": { - "anyOf": [ - { - "type": "integer" - }, - { - "type": "null" - } - ], - "title": "Height" - }, - "image": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Image", - "description": "a signed link to it, drawn; none when it couldn't be" - }, - "thumb": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Thumb", - "description": "a signed link to it, small" - }, - "text": { - "anyOf": [ - { - "type": "string", - "enum": [ - "pdf", - "ocr" - ] - }, - { - "type": "null" - } - ], - "title": "Text", - "description": "how its text was read: from the PDF, or by OCR; none without text" - }, - "chars": { - "type": "integer", - "title": "Chars", - "description": "characters of text on it", - "default": 0 - }, - "label": { - "anyOf": [ - { - "type": "string" - }, - { - "type": "null" - } - ], - "title": "Label", - "description": "the PDF's own name for it (iv, A-1, \u2026) when it isn't its number" - } - }, - "additionalProperties": true, - "type": "object", - "required": [ - "idx" - ], - "title": "Page", - "description": "A page of a document, or an image (a TIFF has one per frame)." } } }