@cossackframework/cms
v0.9.6
Published
Cossack CMS: resources, schema planning, repositories, auth and stores on RomeDB
Readme
@cossackframework/cms
The Cossack CMS on RomeDB: collections defined as data and stored schemaless, blocks, rich
text stored as ProseMirror JSON, taxonomies with nested terms, media, settings, themes,
menus, resources with a schema planner and a migration ledger, authorized repositories,
users and sign-in with authenticator apps and passkeys, the framework stores, an outbox and
plugin hosting. Publishing tools: scheduled entries, preview links, autosaves, revisions you
can compare and restore, automatic and managed redirects, per-entry SEO, resized image
variants with crops and focal points, application passwords for the content and management API (cossack cms, MCP), signed
webhooks, moderated comments, reusable patterns and translations. Several people edit one
entry together through its room (live text, presence, a shared draft; docs/cms/collaboration.md) and leave
review notes for each other on passages, blocks and fields (docs/cms/notes.md). Forms are built from
input blocks with conditional logic, and each keeps its submissions in a table of its own,
with notifications, webhooks and hooks like Gravity Forms'. Add it to an
application with cossack add cms, which renders the shared auth and dashboard pages
over CMS storage and a default theme into src/plugins/default-theme/. It runs on Cloudflare Workers
with RomeDB Cloud and on Node.js with a RomeDB file in the server's process, romedb serve or Cloud. The package is also an application: app/
holds the pages, components and API routes that cossack add cms renders, and pnpm dev here (or
pnpm dev:cms at the repository root) runs them from the workspace; see app/README.md.
import { field, type CollectionDefinition } from '@cossackframework/cms';
export const products: CollectionDefinition = {
name: 'products',
label: 'Products',
singular: 'Product',
path: 'shop',
taxonomies: ['tags'],
features: { content: { blocks: ['core/heading', 'core/paragraph', 'core/image'] }, featuredImage: true },
fields: {
price: field.number({ required: true, min: 0 }),
},
};| Entry | Use |
| --- | --- |
| @cossackframework/cms | Collections, blocks, fields, rich text, menus, the theme contract, permissions, settings, extension points, manifests, media helpers, the co-editing rules (client-safe) |
| @cossackframework/cms/server | createCMS, repositories, planner, users, taxonomies, menus, settings, files, auth, stores, outbox, Markdown (server-only) |
Data contract:
- Each collection is its own document table,
r__cms__<name>. Only host fields are typed in the database; the host validates content fields, and reads tolerate values that no longer fit a changed field. Saving a definition changes only indexes. - A collection's standard fields are its features (
content,excerpt,featuredImage,revisions), fixed names themes rely on; its other fields are the field groups attached to it, in the order the collection manager sets. Field groups are meta boxes built from blocks: field blocks laid out with the core layout blocks, attached to collections, taxonomies, users and menu items. They compile to field declarations, so values are stored flat by name; arowsfield is a repeater (rows with an_id, nested without limit) whose indexed row fields get an array index on their path into the rows (specs.*.name, RomeDB 0.2.11) forarray::containsseeks. A field withmultiple: trueholds several values of its kind as one array, each checked with the kind's rules, bounded byminItemsandmaxItems, and indexed as an array when filterable; a gallery is a multiple media field and a multiple choice a list of its values. Conditions on fields clear what they hide on write. - A collection's entry editor is arranged by its
editorlayout: tabs for the main column and a sidebar every tab shares, built fromeditor/tab,editor/sectionandeditor/boxblocks with the core columns, grids and notes. A box is one ofeditorBoxes(): a field (field:excerpt), a field group (group:pricing), a taxonomy (taxonomy:categories) or the editor's own (seo,attributes,languages,template,discussion,revisions); the title and the Publish box are pinned. Without a stored layout the editor showsdefaultEditorLayout(), the arrangement it always had;resolveEditorLayout()appends boxes a layout does not name, leaves out boxes that are gone and merges what active plugins' manifests add (editor). Plugin manifests also ship field groups (fieldGroups), stored when the plugin is granted. A tab's ID names it in the editor's address (?tab=pricing,EDITOR_TAB_ID). The collection manager's Editor tab edits the layout as one tree, the sidebar its last row, so meta boxes (the dashboard's word for boxes) drag between a tab and the sidebar. - Each mutation is one atomic batch: record, revision, audit and outbox rows, guarded by the operation ID, so a stale edit writes nothing.
- Terms store their ancestors' IDs as a path, so a subtree is a prefix match and a move is one statement. Entries hold term IDs in indexed arrays.
- Code-declared resources use strict collections. Generated schema changes are additive;
renames, backfills, tighter rules and drops are explicit, versioned steps. Each step is one
batch sent with
ifSequence; a conflict re-plans. - A resource is active only when the database records its current declaration.
- Blocks are one tree:
{ id, type, data }, withchildrenunder a container (core/group,core/columnsholdingcore/column,core/grid) and a core-checkedlayout(hideby container width). A type declares what it holds (children) and where it goes (parent); at most 200 blocks and 4 levels per field. Layouts are blocks, so revisions, patterns and the front-end editor cover them; nothing is stored beside the block list. - A block's text fields may bind to the entry's fields:
{{ $.price }}puts the value inside the text, with words and formatting around it (resolveBindings,resolveBlockBindings); the default theme lists no fields on its own. The site resolves them when it renders an entry; the editor keeps the syntax and offers the fields in a picker. - A block's
styleholds slugs of the theme's presets (background,text,padding,margin,fontSize) and analign;layoutadds ananchorandclassName. A type'ssupportsnarrows what its Style tab offers over its category's defaults. Themes declarepresets(colors, font sizes, spacing) in their manifest, Customize adjusts the palette and adds site-level CSS, andblockStyleAttributesrenders a styled block's wrapper with classes and custom properties, so a palette change recolors stored content. - An entry's content is blocks: the
contentfeature, on for posts and pages, and thecore/richtextblock is the word processor among them. Themes get oneentry.contentlist: every blocks field, and each rich text or Markdown field as one rich text block. A collection'stemplateis the blocks every new entry's content starts with (templateLockkeeps them, or their order too); blocks of thedatacategory store values and render nothing. Rich text is validated against an allow-list of nodes, marks and attributes on every write and rendered to escaped HTML; the plain text of searchable rich text and blocks fields feeds the full-text index. - Extension points besides the resource and form hooks:
cms.term.before-save,cms.comment.before-saveandcms.menu.before-saveadjust or refuse writes;cms.dashboard.entry-actions(the built-in quick actions, which handlers add to, remove or reorder),entry-columnsandbulk-actionsadd links, plugin commands and columns to the dashboard's entry lists. - A menu is one JSON tree saved with a revision check. Entries and terms are stored by ID and resolved when the site renders.
- A plugin runs only when its resources are migrated and an administrator grants what its
manifest requests. Builds run the plugin policy lints (
cossack plugins check). Itsui.slotslinks fill the dashboard navigation (dashboard.nav), the dashboard's bottom taskbar (dashboard.taskbar) and the taskbar signed-in users see on the site (site.taskbar). - A theme is a plugin whose manifest has a
themefield and whosetemplates/files (orui.tsthemeexport) are the site templates, picked per page from most specific (entry-posts,term-category) to general (entry,archive). Themes own templates, not routes. Activating one is a settings write; its templates need no grant. A theme'sserver.tsexportsloadersthat read data under the plugin's grants for its templates;templates/head.tsadds stylesheets and fonts fromassets/;theme.extendsmakes a child theme;theme.areasdeclares widget areas; a manifest'scollectionsship site collections with the plugin. Editors can choose an entry's template and edit its blocks on the public page. - A form is a
formsentry whosebodyholds input blocks (input: { kind }in the declaration), laid out with the containers and shown or hidden by a block'swhen; aform/repeaterholds a row of inputs people fill in once per passenger or item, and a text, number or date input withmultipleon takes several values, added one at a time. Aform/fileinput takes uploads (allowed extensions or types, up to 10 MB a file, 10 files, 25 MB a submission; the content is checked against the type): the files are private files undercms/private/forms/<form>/<submission>/, which the library and/media/never serve, and download throughGET /api/cms/forms/<form>/submissions/<id>/files/<file>withcms:submissions; the record keeps{ id, name, size, type }, and deleting the submission or the form removes them. Its submissions are the resourcecms/form_<form id>, stored in its own table and extended when inputs are added. A submission is one batch: the record, a receipt and itsform.submittedoutbox event, which sends the form's notifications and webhooks. Hooks:cms.form.validate,before-submit,prefill,confirmation,notificationandsubmitted. - Scheduled entries are published by maintenance as a system write, so their outbox events and webhooks fire when they go live. A published entry's URL change records a 301 in the same batch.
- Preview links, application passwords and recovery codes are stored as SHA-256 hashes. Webhook deliveries are queued per webhook from the outbox and signed with HMAC-SHA256.
- After a package upgrade, new host tables and changed built-in collections apply on the next request; code-declared resources and plugins still migrate from Tools → Schema.
See the guides with cossack docs --package @cossackframework/cms, and the developer docs
in docs/cms/: overview, plugins,
manifest, hooks,
themes, menus,
settings and languages.
