@sewdn/workflow-plugins
v0.1.1
Published
Generic workflow plugins, one folder per plugin and one part per layer: meetings (a phase plans a meeting), documents (a task makes a document placeholder) and catalog (the data schemas and standard seats routes share), each with an engine part, a state a
Readme
@sewdn/workflow-plugins
Generic workflow plugins, one folder per plugin and one part per layer. Each part imports only its own layer and
earlier ones (bun run boundaries checks src/<plugin>/engine, runtime, react and ui as the engine, the
runtime, workflow-react and workflow-ui).
| Plugin | What it adds |
| ----------- | ---------------------------------------------------------------------------------------------- |
| meetings | meetings.plan-meeting: a phase plans a meeting when a run of it starts. |
| documents | documents.create-document, documents.revise-document: a task makes a document placeholder. |
| catalog | The data schemas and standard seats routes share, saved with the drafts that use them. |
Each plugin has state: the register of what its triggers asked for, projected from trigger.fired in the commit that
fired them (so it is in snapshots, seeds and rollbacks) and read by a query, not by a read-model row.
| Query | Params | Result |
| --------------------- | -------------------- | ---------------------------- |
| meetings.planned | { runId?: string } | the meetings a phase planned |
| documents.requested | { runId?: string } | the placeholders a task made |
| catalog.schemas | {} | the catalog's data schemas |
| catalog.seats | {} | the catalog's standard seats |
Subpaths: ./<plugin>/engine (the pure part: triggers, state, queries and the record types), ./<plugin>/runtime
(the outward binding), ./<plugin>/react (the hooks that read the queries and give the commands, and the lists a
screen shows), ./meetings/ui (the meetings plugin's UI part meetingsUi: its trigger's inspector, and its part of a
run's screens drawn with the kit's primitives: the meetings of a phase visit with "Mark held", and the view of its
planning task that puts a place on the series on a series meeting or moves it).
The catalog plugin has no trigger and no outward work: its state is the application's lists of data schemas and
standard seats, and its commands (catalog.save-schema, .remove-schema, .save-seat, .remove-seat; authors only,
workflow.author) change them. A save is one commit with the edits it causes: it chains the engine's editDraft, as
item-addressed changes that are on nobody's undo stack (undoable: false), on the draft of every route that uses the
schema, or has the seat. skipDefinitionId leaves one route's draft to the editor that has it open, materialize:
false changes the catalog alone, and a route that stops using a schema while a field of its draft is typed by it
refuses the save (schema-in-use). A route without a draft is not touched. Its UI part catalogUi (./catalog/ui)
contributes catalog: { useSchemas, useSeats, useSaveSchema }, which the editor reads through useCatalog() of
workflow-react without importing the plugin.
A plugin's events can read as lines of a run's history: the meetings plugin's records (put on a series meeting, moved, a series meeting held, a planned meeting held) do, worded by its copy.
An application composes each plugin from its parts and registers the one list with the engine, the runtime and the React provider; the plugin works with no runtime part at all:
import { meetingsUi } from "@sewdn/workflow-plugins/meetings/ui";
const plugins = [
{ ...meetingsPlugin, ui: meetingsUi },
{ ...documentsPlugin, ui: documentsUi },
];
const meetings = usePlannedMeetings(runId); // a QueryState of the `meetings.planned` queryBindings
The engine makes the meeting and the placeholder inside the run, and the plugin's state shows them in the same commit.
The runtime part is only what a host does outward with them, as one function: meetingsBinding(planner) and
documentsBinding(planner) take a planner (MeetingPlanner, DocumentPlanner) and bind it as the trigger's handler.
A server binding passes a planner that calls its calendar or its document store. A planner is idempotent by its
record's id (the same id the state's record has): the reactions deliver at least once.
