@graview/core
v0.1.21
Published
The graph, the log, the schema and the checker. Everything a Graview app declares, and the CLI that verifies it.
Maintainers
Readme
@graview/core
Everything a Graview app declares, and the checker that verifies it.
- Schema —
defineNodeandcreateSchema. Zod is the single source of runtime validation, TypeScript types and JSON Schema. - Graph — nodes and edges, with a tracked reader so a mutation records what it read as well as what it wrote.
- Mutations —
defineMutation. Every change is a typed, named, describable act; nothing writes the graph directly. Each kind gets a derivededit-<kind>offering the fields no other act writes. Every act refuses an argument it does not take, naming those it does, and an act refused as asked throws anActRefusalwhosereasonandsentencea host can show (refusalOfreads one):refusedwhen the act's own rule says no,invalidfor the call as sent. - Invariants — rules that judge the graph and name the mutations that would repair them. That naming is the seam derived affordances ride on.
- Operation log — the graph is a fold over it. Author, intent, reads and writes on every op, which is what makes selective undo a dependency question rather than a stack.
- Permissions — a
Principalis anAuthorwith roles, so what the log blames is what the policy judged. - Theme — the token contract, the two shipped palettes, and a contrast
checker that measures a brand's palette before it ships. The rest of the
look is data beside them —
SHAPE,TYPOGRAPHYandisoShade(scheme), resolved for a brand byshapeOfandtypographyOf— so a page outside the app can dress as one without importing a stylesheet. A document's brand holds the rest of it too (FR-124): a logo and a page icon, judged bysvgProblemandmarkProblemunder the same rules as Graview Cloud's images; faces named fromSYSTEM_STACKS, the system's own andDOCUMENT_FONTS, judged byfontProblem; and an accent that does not read as given is refused byaccentProblemwith the pair, its ratio and a shade that would pass (FR-126). Graview's own identity (the design kit, revision 03) is data too, and reaches an app only through these defaults:GRAVIEW_COLORS(En Dash navy and turquoise, paper, reading ink, muted text),GRAVIEW_FACEandWEIGHTS(Montserrat at 550, 450 and 600, named first inTYPOGRAPHYand never fetched),LOGO_RULES, and the shared-plane symbol as an inline currentColor SVG (graviewSymbol, the micro cut under 28 px bysymbolCut). The shipped palettes are built on it; turquoise is in neither, since it is a point and a fill, never text. graview check— reads a declaration and reports what is wrong with it, in terms an agent can act on. In code it is@graview/core/check:checkApp,describeApp, the agent docs (generateLlmsTxt), andcompileDocument, a document compiled and checked.- Documents —
@graview/core/document: a whole app as one JSON object, compiled bycompileDocumentWithoutCheckinto the same appdefineAppdeclares and never run as code (compileDocumentfrom@graview/core/checkalso asks the checker);toDocumentwrites an app back out. Rules say what must hold in a small, budgeted language (expressionRule). Every command that takes an entry takes--document <file>. A view's blocks resolve with@graview/core/blocks. A number field may say its range (min,max,step), which every form, tool and apply honors; an act'sconnectslinks from whichever end of the relation its subject is,replacessevers the links it supersedes and set the record at the other end (its "setsOther" key).editDocument,diffDocumentsandplanMigrationchange a document and say what the change does to stored data. A host that compiles a document on its server hands the pageserializeCompiled(compiled), and the page builds the same app withappFromorappFromOrCompilefrom@graview/core/compiled, which carries no compiler (the format isgraview-compiled@1). - A part that tries again —
@graview/core/retry, for a page only:retryingImport(() => import("./part.js"))is a loader that asks again after the import failed, with a URL of its own (?retry=<n>) where the engine keeps a failed module for the page's life, as Chromium and Firefox do. Never from a server's code: workerd refuses a script with a computedimport()in it. - The city —
@graview/core/scene:sceneThumbnaildraws a document (or an app) as the Scene draws it from altitude — the same districts on the same map, in their hues — as one SVG string, with no DOM, for a host listing apps;sceneDistrictsis the same answer as data. At a card's size,fit: "content"fits it to what stands: each district on its whole block from the same corner, cropped to the plots, with a few blocks no narrower thanminBuildingpixels (16 by default) rather than a speck per record. Without counts — a live app with no snapshot — each district stands three blocks placed and raised by its kind's name, so every app still looks like itself.size: "icon"draws it as a tab's icon: 32 by 32, each district on its block in its hue with one block on it, readable at 16 pixels and about a kilobyte — a standalone SVG to serve as a favicon. A kind's figures are@graview/core/figures. - What a page loads first —
@graview/coreand@graview/core/documenthold only what a page draws with. The checker, the city, the figures and the block resolver are on the subpaths above because a bundler places a whole module in every chunk that can reach it: a hosted page imports both barrels up front, and would otherwise carry them before a face is fetched. - A place's address —
addressOf(place, { basePath })spells a place fromplacesOfas the routed face links to it under a host's base path,pathWithinreads an address back, andbasePathOfnormalizes a base. Asearchhit says its own: a record, a kind's list or a place carriesaddress, spelled the same way under thebasePathit is given, and a seat finds only the records its sight lets it open. - Conformance —
@graview/core/conformance: fixtures a host runs against a version (conformance()) to prove it reads, compiles and derives the same. - A status board's moves —
@graview/core/describe:columnReachsays which acts move a card to which column — the named steps that set the field to that column's value, or else an act told the value — andcolumnMovesthe ones one seat may run on one record, its conditions judged.
npx graview create my-app # a product on Graview, started (also: npm create graview)
npx graview check ./dist/domain/app.js
npx graview docs ./dist/domain/app.jscreate writes the declaration split into domain and UI, a shell, a headless
test and a CI workflow, initializes a repository, installs, and says what to
do next. --link <path> consumes the framework from a sibling checkout by
path instead of a registry — the only way that works until the packages are
published — and refuses a framework that is not built.
The generator behind it is @graview/core/scaffold, a pure function from a
name and a first kind to a list of files, for a host that provisions apps.
