CMS / foldkit-cms-drizzle

Server setup notes

  • Register cms.sources, not source(Db.Post). They are the content types' sources and the CMS's own, each behind the boundary.
  • A content type that can be unpublished must be guarded by whether it is. CmsServer.make throws for a type with a published role whose Read rule does not read that field, and, through GuardServer.validate, for a binding whose visible is not the rule your guard set built for it. entity is the type's Entity with its guards attached, the one its table was bound from.
  • A content type with no published role has nothing to hide, and needs none.
  • Who is an author is any of authors, principal guards; anyone else is a visitor. Their bodies are asked with the interaction it is for, Read for reading unpublished work and Update for any operation on it, so a reviewer can read what they may not change. Who may make a transition is an author any of its transitions guards lets; a transition not named is any author's. Archiving an entry on show takes it off, so it asks unpublish's guards too. allow stays for a rule about the entry itself. A refusal is Forbidden, with its sentence.
  • A write says of an entry only what its caller may read. An author your guards let Update and not Read (a drop box, a publishing job) changes unpublished work and reads none of it. Such a caller's write that is made answers its output and no patch of the entry, its draft or its revisions, which the server cuts to what the caller may read (a row on show, such as the article a publish put there, is still answered). One that is refused answers what an entry that is not there answers (There is no such entry; for a save that names a basedOn, the Cms.refusal.conflict of a discarded draft), whatever refused it: the entry's type, its state, its revisions, a taken address, transitions, allow, or your handler's own refusal. What was sent is still refused in its own words (an unknown type, a draft too large, a time that is not one), before any entry is looked up, and a failure on the server's side still reads Internal error with an incident. Such a caller can still tell two things. A write that was made was made. And a first save (basedOn: null) of an id an entry already has reads This draft cannot be saved as this entry, whatever the entry is, since an id cannot be given twice; ids are random (Cms.newEntryId()), so that lists nothing. A live hub is told of no row by such a caller's write.
  • create and update go to the CMS, not to RemoteServer.make. Registered there too, they are a way to publish with no draft, no revision and no allow.
  • Content that exists already is imported, not inserted. cms.import({ type, values, as, at, entry }) makes the entry and a draft of values, then publishes it as a publish does: your create handler writes the row, as as, and revision 1 records values, dated at. It is one transaction, and the server's own act, so allow is not asked. Writing the CMS's tables by hand has to match what a publish writes, and drifts.

Seeding

A seed is a runner over cms.import — one item per entry, in dependency order:

  • Fix the clock. Pass now to CmsServer.make and at to each import, so every run writes the same dates: the build's pages and every sandbox agree.
  • Name entries that are pointed at. Pass entry where another import names it (a page naming its featured post), and import what is pointed at first so the id is known. Anything else takes the default new id.
  • Fix as once. Import as an editor and vary the rest; the input is ImportItem<P> less as, so the runner and the tool cannot drift.

The CMS example's seed.ts is the worked shape: dated posts, then the pages that point at them.

Verify the audience boundary

Before connecting the editor, exercise the same content read as an author and as a visitor. An author may see working content; a visitor must see only rows allowed by the binding's visible rule. Repeat through a relation and a query, not just a direct id read. CMS state and allowed actions are separate from the identity established by your HTTP or RPC authentication.

For the first write, save a draft and read the public row again: it must be unchanged. Publishing should then update the row, append a revision, and remove the draft within the supplied transaction. A scheduled time alone executes nothing; your host must call cms.due as described below.