Skip to main content

NotesActivationSchema

Trait NotesActivationSchema 

Source
pub trait NotesActivationSchema:
    Send
    + Sync
    + 'static {
Show 31 methods // Required methods fn create( &self, title: NoteTitle, body: Option<NoteBody>, org: Option<OrgId>, ) -> BoxStream<'static, NotesEvent>; fn get(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn list( &self, query: Option<NoteQuery>, limit: Option<u32>, after: Option<NoteId>, ) -> BoxStream<'static, NotesEvent>; fn save( &self, id: NoteId, body: NoteBody, base: Option<u32>, ) -> BoxStream<'static, NotesEvent>; fn update( &self, id: NoteId, update: NoteUpdate, session: Option<NoteSession>, ) -> BoxStream<'static, NotesEvent>; fn state( &self, id: NoteId, vector: Option<NoteVector>, ) -> BoxStream<'static, NotesEvent>; fn history( &self, id: NoteId, limit: Option<u32>, before: Option<u32>, ) -> BoxStream<'static, NotesEvent>; fn replay( &self, id: NoteId, seq: Option<u32>, at: Option<i64>, ) -> BoxStream<'static, NotesEvent>; fn squash(&self, id: NoteId, until: u32) -> BoxStream<'static, NotesEvent>; fn present(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn here( &self, id: NoteId, session: NoteSession, client: Option<u64>, awareness: Option<NoteAwareness>, ) -> BoxStream<'static, NotesEvent>; fn rename( &self, id: NoteId, title: NoteTitle, ) -> BoxStream<'static, NotesEvent>; fn delete(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn restore(&self, id: NoteId, seq: u32) -> BoxStream<'static, NotesEvent>; fn may(&self, id: NoteId, role: Role) -> BoxStream<'static, NotesEvent>; fn ask( &self, id: NoteId, from: u32, to: u32, text: ThreadText, to_whom: Option<AgentName>, ) -> BoxStream<'static, NotesEvent>; fn reply( &self, id: NoteId, thread: ThreadId, body: ThreadText, ) -> BoxStream<'static, NotesEvent>; fn resolve( &self, id: NoteId, thread: ThreadId, open: Option<bool>, ) -> BoxStream<'static, NotesEvent>; fn threads(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn waiting(&self, to: Option<AgentName>) -> BoxStream<'static, NotesEvent>; fn slot(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn fill( &self, id: NoteId, component: ComponentName, version: VersionRef, props: Option<SlotProps>, say: Option<SlotSay>, ) -> BoxStream<'static, NotesEvent>; fn empty(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn building( &self, id: NoteId, component: ComponentName, step: Option<BuildStep>, say: Option<SlotSay>, failed: Option<bool>, ) -> BoxStream<'static, NotesEvent>; fn props( &self, id: NoteId, patch: SlotProps, ) -> BoxStream<'static, NotesEvent>; fn mark( &self, id: NoteId, from: Option<u32>, to: Option<u32>, mark: Option<MarkId>, link: Option<MarkLink>, label: Option<MarkLabel>, component: Option<ComponentName>, version: Option<VersionRef>, props: Option<SlotProps>, ) -> BoxStream<'static, NotesEvent>; fn mark_props( &self, id: NoteId, mark: MarkId, patch: SlotProps, ) -> BoxStream<'static, NotesEvent>; fn unmark(&self, id: NoteId, mark: MarkId) -> BoxStream<'static, NotesEvent>; fn marks(&self, id: NoteId) -> BoxStream<'static, NotesEvent>; fn watch( &self, id: Option<NoteId>, session: Option<NoteSession>, text: Option<bool>, ) -> BoxStream<'static, NotesEvent>; fn usage( &self, everyone: Option<bool>, daily: Option<bool>, ) -> BoxStream<'static, NotesEvent>;
}
Expand description

Notes: writing on its own, written by many hands at once — make one, read it, write it live (a Yjs CRDT), see who is on it, replay how it was built.

Emitted by #[plexus_macros::activation] from the activation’s wire methods (NEST-17: for every activation, named {Name}ActivationSchema unless trait = "…" names it; a contract is its trait), each under its own return type (RETURNS-36), the values the server injects left out: implemented by the activation (reading those from the call’s context), and by its client when every method answers a Result whose error takes a PeerError, so a local activation and a remote one are interchangeable behind dyn this trait.

Required Methods§

Source

fn create( &self, title: NoteTitle, body: Option<NoteBody>, org: Option<OrgId>, ) -> BoxStream<'static, NotesEvent>

Make a note in an organization you write in; yields created { note } (revision 1, its id 8 characters, opened at #/note/).

org names the organization (acme); without it, the first one you write notes in. Who may read and write the note is the roles held on its organization (acme:) or on *. Refused in band: not_found { org } for an organization you are not in, refused { forbidden } for one you only read. Editor.

Source

fn get(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

A note whole; yields note { note } — its title, its body (the markdown its CRDT holds now), its revision, who made it and who wrote it last — or not_found.

A note in an organization you do not read is not_found, as one there is not. replay reads it as it stood at a moment. Viewer.

Source

fn list( &self, query: Option<NoteQuery>, limit: Option<u32>, after: Option<NoteId>, ) -> BoxStream<'static, NotesEvent>

The notes you read, newest made first, without their bodies; yields rows { items: [note { note }] } then page { next, remaining }.

query keeps those whose title holds every word of it, case-blind. A page is 50 rows unless limit says (at most 1,000); after is the last row’s id of the page before (page.next). Viewer.

Source

fn save( &self, id: NoteId, body: NoteBody, base: Option<u32>, ) -> BoxStream<'static, NotesEvent>

Write a note’s body whole — merged with whatever else is being written; yields saved { id, revision, at, by } (stale: true when base was not the revision it found).

For an agent or a script over synapse: the body given is diffed against the text now and made into the CRDT’s own inserts and deletes, so it merges with live typing instead of overwriting it (a hand typing in a paragraph the body did not change keeps its words). base is the revision you read (note.revision). A body equal to the text writes nothing. The editor sends updates instead. Editor.

Source

fn update( &self, id: NoteId, update: NoteUpdate, session: Option<NoteSession>, ) -> BoxStream<'static, NotesEvent>

Apply a Yjs update to a note’s body — the editor’s live typing; yields applied { id, revision }.

update is a Yjs v1 update of the note’s body text (base64), as the page’s ydoc made it; it is merged into the note’s CRDT, kept as a change with you and the moment, and said to everyone on the note (watch’s updated) — not back to session, when you name the presence it came from. Editor.

Source

fn state( &self, id: NoteId, vector: Option<NoteVector>, ) -> BoxStream<'static, NotesEvent>

What your copy of a note’s CRDT lacks; yields state { id, update, vector, revision } — the Yjs update to apply, and the note’s own state vector.

vector is your state vector (Y.encodeStateVector, base64); with none, the whole note. Send back what the note lacks of yours (Y.encodeStateAsUpdate(ydoc, vector)) as an update. Viewer.

Source

fn history( &self, id: NoteId, limit: Option<u32>, before: Option<u32>, ) -> BoxStream<'static, NotesEvent>

Every change of a note, newest first; yields change { change: { seq, kind, at, by, principal, bytes, title?, authors? } } each.

Every change is kept with who and when until squashed: create, update (live typing), save (a whole body, merged), rename, delete, and snapshot (a squash: its authors say who wrote what in it). at is unix milliseconds. before pages back by seq. Viewer.

Source

fn replay( &self, id: NoteId, seq: Option<u32>, at: Option<i64>, ) -> BoxStream<'static, NotesEvent>

A note as it stood at a moment; yields note { note } — its title and body then, revision the change it stood at — or not_found { revision }.

seq stands it after that change (history’s); at (unix milliseconds) after the last change made by then. A moment before the first change kept — squashed away — is not_found. With neither, now. Viewer.

Source

fn squash(&self, id: NoteId, until: u32) -> BoxStream<'static, NotesEvent>

Collapse a note’s changes up to a moment into one snapshot, keeping who wrote what; yields squashed { id, until, removed, at, by }, said on watch.

The changes up to until (a seq) become one snapshot change whose authors say each writer’s changes and bytes; later changes stay as they are. A replay before until is not_found after. Needs its own grant, notes.squash, on the note’s organization — admin’s by default, grantable to a role by the role table; refused typed without it. Admin.

Source

fn present(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

Who is on a note now; yields present { present: { session, principal, name, agent, colour, client?, awareness?, at } } each.

A connection is on it while its watch { id, session } is open; a writer without one (an agent’s save) while it writes, idling out after 30 s. Viewer.

Source

fn here( &self, id: NoteId, session: NoteSession, client: Option<u64>, awareness: Option<NoteAwareness>, ) -> BoxStream<'static, NotesEvent>

Say where your caret is on a note; yields present { present }, said to everyone on it.

awareness is your page’s Yjs awareness update (base64) — your caret, your selection — and client your Yjs client id; session your page’s, as your watch named it (one someone else holds is refused). Viewer.

Source

fn rename(&self, id: NoteId, title: NoteTitle) -> BoxStream<'static, NotesEvent>

Retitle a note; yields renamed { id, title, revision, at, by }. Editor.

Source

fn delete(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

Delete a note; yields deleted { id, at, by }. Its changes stay in the service’s file. Admin.

Source

fn restore(&self, id: NoteId, seq: u32) -> BoxStream<'static, NotesEvent>

Put a note’s body back as it stood after a change; yields saved { id, revision, at, by } — the restore is a change more, merged like a save. Editor.

Source

fn may(&self, id: NoteId, role: Role) -> BoxStream<'static, NotesEvent>

Whether you hold a role on a note — viewer | editor | admin — as the gate says on its organization now; yields may { id, role, held }, or not_found for one you do not read.

The question another service asks through the seam before it keeps something of a note’s, as the caller (the service that keeps images asks editor before it keeps one for a note, viewer before it answers one). Nothing is written. Viewer.

Source

fn ask( &self, id: NoteId, from: u32, to: u32, text: ThreadText, to_whom: Option<AgentName>, ) -> BoxStream<'static, NotesEvent>

Ask a question on a range of a note — it stays beside that text as the text changes; yields asked { thread }, said on watch.

from and to are the range in characters of the text now (as get’s body counts them). The range is anchored in the note’s CRDT, so it follows the text through every edit (thread.from, thread.to where it stands now; deleted whole, the thread is detached). text is the question (markdown: links, images). to_whom asks it of an agent (builder, or agent for any); such a question is listed by waiting and said to every watch of the organization’s notes, so an agent picks it up, and may answer with reply or edit the note itself. Editor.

Source

fn reply( &self, id: NoteId, thread: ThreadId, body: ThreadText, ) -> BoxStream<'static, NotesEvent>

Answer in a thread — words, links, images; yields replied { thread }, said on watch. Editor.

Source

fn resolve( &self, id: NoteId, thread: ThreadId, open: Option<bool>, ) -> BoxStream<'static, NotesEvent>

Resolve a thread (it folds in the margin), or open it again; yields resolved { thread }, said on watch. Editor.

Source

fn threads(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

A note’s threads, in the order their ranges stand in the text, the detached ones last; yields thread { thread } each.

Each thread is whole: its anchor (two Yjs relative positions, for a page to resolve in its own copy), its range now in characters, the text it quoted, the question, whom it was asked of, its answers, and whether it is resolved. Viewer.

Source

fn waiting(&self, to: Option<AgentName>) -> BoxStream<'static, NotesEvent>

The open questions asked of someone, in the notes you read, oldest first; yields thread { thread } each — an agent’s queue.

to keeps those asked of that name (builder, or agent for the ones asked of any agent). Viewer.

Source

fn slot(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

NOTES-4: a note’s slot whole; yields slot { slot: { id, fill?, props, fills, building? } } — what fills it now, its props, every fill newest first, the build under way.

A fill is { n, component, version, say?, by, principal, at }; a build { component, step?, say?, failed, by, principal, started, at }. The page draws fill by a mark pinned to its version. Viewer.

Source

fn fill( &self, id: NoteId, component: ComponentName, version: VersionRef, props: Option<SlotProps>, say: Option<SlotSay>, ) -> BoxStream<'static, NotesEvent>

NOTES-4: fill a note’s slot with a component of a kept version; yields filled { slot }, said on watch as slot_changed; the build under way ends.

The ui service is asked whether version (a hash, or its first 6 hex digits or more) holds component: refused unknown_version or unknown_component naming both, the slot unchanged. props replaces the slot’s props (none: they stay); say is one line of what this fill does. Every open page draws it in place. Editor.

Source

fn empty(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

NOTES-4: empty a note’s slot — nothing drawn, its props cleared, its fills kept; yields emptied { slot }, said on watch as slot_changed. Editor.

Source

fn building( &self, id: NoteId, component: ComponentName, step: Option<BuildStep>, say: Option<SlotSay>, failed: Option<bool>, ) -> BoxStream<'static, NotesEvent>

NOTES-4: say a slot is being built — a step, a line, a failure; yields building { slot }, said on watch as building_changed.

step is the last reached: heard, written or compiled; say one line; failed: true with say holding the refusal (the compiler’s line) marks a build that failed. The component that is in the slot stays drawn. A fill or an empty ends it; so do ten minutes without a word, and a restart: it is kept in memory only. Editor.

Source

fn props(&self, id: NoteId, patch: SlotProps) -> BoxStream<'static, NotesEvent>

NOTES-4: merge a patch into a slot’s props — what its component keeps its state in; yields props { slot }, said on watch as props_changed { id, props, by, slot }.

A key set to null is taken away. The props are held to 64 KiB written as JSON: past it, refused { too_large } and nothing written. Every page open on the note hands the new props to the component it has mounted. Editor.

Source

fn mark( &self, id: NoteId, from: Option<u32>, to: Option<u32>, mark: Option<MarkId>, link: Option<MarkLink>, label: Option<MarkLabel>, component: Option<ComponentName>, version: Option<VersionRef>, props: Option<SlotProps>, ) -> BoxStream<'static, NotesEvent>

Mark a range of a note — an underline that follows its words, with a link, a line of state, a component under its passage, or any of them; or change a mark; yields marked { mark }, said on watch. The note’s text is not changed.

A new mark names from and to, the range in characters of the text now (as get’s body counts them); it is anchored in the note’s CRDT as a question’s range is, so it follows its words through every edit (mark.from, mark.to where they stand now; every character deleted, it is detached, kept and drawn nowhere). With mark instead, that mark is changed: its link and label set as given, an empty one taken off. link is a ticket (KILN-12), an address of the app (#/…) or an https address; a click on the underline opens it. label is one line of state, drawn under the passage with who left it. component and version place a component of a version the ui service keeps under the passage that holds the range — never in the text — with props its props (a JSON object, at most 64 KiB): the ui service is asked whether the version holds it, refused unknown_version or unknown_component naming both, nothing written; mark_props patches the props after. Nothing here writes the note: its body and its revision stay as they are. Editor.

Source

fn mark_props( &self, id: NoteId, mark: MarkId, patch: SlotProps, ) -> BoxStream<'static, NotesEvent>

Merge a patch into the props of the component a mark places — what the component keeps its state in; yields marked { mark }, said on watch as mark_changed. The note’s text is not changed.

A key set to null is taken away. The props are held to 64 KiB written as JSON: past it, refused { too_large } and nothing written; a mark that places no component is refused { no_component }. Every page open on the note hands the new props to the component it has mounted under the passage, in place. Editor.

Source

fn unmark(&self, id: NoteId, mark: MarkId) -> BoxStream<'static, NotesEvent>

Take a mark off a note; yields unmarked { id, mark }, said on watch as mark_removed. The note’s text is not changed. Editor.

Source

fn marks(&self, id: NoteId) -> BoxStream<'static, NotesEvent>

A note’s marks, in the order their ranges stand in the text, the detached ones last; yields mark { mark } each — where each stands now and the words it holds.

Each mark is whole: its anchor (two Yjs relative positions, for a page to resolve in its own copy), its range now in characters (from, to), the words it holds now and the quote it held when made, its link and label, who left it and when. Viewer.

Source

fn watch( &self, id: Option<NoteId>, session: Option<NoteSession>, text: Option<bool>, ) -> BoxStream<'static, NotesEvent>

Follow notes: watching { id? } first, then created, updated { id, seq, update, by }, renamed, deleted, squashed, asked, replied, resolved, slot_changed, building_changed, props_changed, mark_changed, mark_removed — and, on one note, present and left, and with text the body as words — as they happen; open-ended, ends with watch_closed { reason, message }.

With id, one note’s: each updated carries the Yjs update to apply (the stream ends after its deleted), and who comes and goes (present { present }, left { session, client? }); with session as well, this watch is your presence on it while it is open, and your own updates (sent with that session) are not said back. Without id, every note’s you read, note without its body. Held to you by the gate: asked again when the grants move, a sign-out or the expiry comes, and closed with a typed reason (signed_out, expired, revoked, refused); each write is asked of the gate on its organization as it stands then. lagged { missed } when it fell behind: read again (state with your vector). NOTES-5: mark_changed { id, mark } (a mark made or changed, whole) and mark_removed { id, mark }; with text: true (and id) the note’s markdown as words — text { id, revision, body, by, at } once as the watch opens, then a second after the first change not yet said, holding every change since: at most one a second, the last change always said. Viewer.

Source

fn usage( &self, everyone: Option<bool>, daily: Option<bool>, ) -> BoxStream<'static, NotesEvent>

Every principal’s notes made and bytes written (admin of *): yields usage { principal, count, bytes } each — what quota.recount reads.

V2-31: from the changes kept — count the notes a principal made, bytes every change they wrote (a squash’s snapshot is nobody’s). Admin of *: KEEL-48, everywhere — the gate refuses a holder on a narrower scope before it runs.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§