CMS / foldkit-cms-drizzle
Server setup notes
- Register
cms.sources, notsource(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.makethrows for a type with apublishedrole whose Read rule does not read that field, and, throughGuardServer.validate, for a binding whosevisibleis not the rule your guard set built for it.entityis the type's Entity with its guards attached, the one its table was bound from. - A content type with no
publishedrole 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,Readfor reading unpublished work andUpdatefor any operation on it, so a reviewer can read what they may not change. Who may make a transition is an author any of itstransitionsguards lets; a transition not named is any author's. Archiving an entry on show takes it off, so it asksunpublish's guards too.allowstays for a rule about the entry itself. A refusal isForbidden, with its sentence. - A write says of an entry only what its caller may read. An author your
guards let
Updateand notRead(a drop box, a publishing job) changes unpublished work and reads none of it. Such a caller's write that is made answers itsoutputand 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 abasedOn, theCms.refusal.conflictof 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 readsInternal errorwith 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 readsThis 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. createandupdatego to the CMS, not toRemoteServer.make. Registered there too, they are a way to publish with no draft, no revision and noallow.- Content that exists already is imported, not inserted.
cms.import({ type, values, as, at, entry })makes the entry and a draft ofvalues, then publishes it as a publish does: yourcreatehandler writes the row, asas, and revision 1 recordsvalues, datedat. It is one transaction, and the server's own act, soallowis 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
nowtoCmsServer.makeandatto each import, so every run writes the same dates: the build's pages and every sandbox agree. - Name entries that are pointed at. Pass
entrywhere 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
asonce. Import as an editor and vary the rest; the input isImportItem<P>lessas, 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.