CMS / foldkit-cms-drizzle
Scheduling
CmsSchedule promises a draft for later: it sets the draft's scheduledFor,
after checking the publish mutation would take the draft now. What could not be
published now is not promised for later. CmsUnschedule takes the promise back.
Nothing else happens until you call due:
// A Cloudflare cron trigger, a setInterval, a queue consumer: the host's choice.
export default {
scheduled: () =>
run(cms.due(new Date(), { as: name => authors.byName(name) })),
}- The package owns no timer. Hosts keep time differently, and a library that starts its own runs twice behind a load balancer.
due(now, { as })publishes every draft whose time has come, each in its own transaction, as whoever scheduled it: a draft keeps the name yournameOfgave, andassays who that is now. Someone who has since lost the right publishes nothing.- A publish that fails stays scheduled, with the reason. The entry reads overdue with that error, because that is true. It is not tried again until the draft changes: a fault the author must fix is not hammered every minute.
- What was promised is changed only by someone who could have promised it.
Since a scheduled draft is published as whoever scheduled it, saving over it,
restoring over it or discarding it is refused to an author your
transitionsorallowwould not letschedule. Otherwise someone who may not publish would publish through someone who may. - One failure does not stop the rest.
dueanswers with each entry and its error, ornull. - An archived entry keeps its promise, and keeps it waiting.
Restoring
CmsRestore makes a revision's value the working copy. It publishes nothing:
what comes back is a draft like any other, to look at, change, and publish, which
makes the next revision. It replaces what the draft held, and takes back a
promise made of that. The saved Model goes with it, so an editor fills its form
from the values, key by key, and a revision older than the form still opens.
Only what has been published has a past to restore.
Archiving
CmsArchive puts an entry away: off the worklist, and, for a type with a
published role, off show. CmsUnarchive brings it back as unpublished work;
publishing shows it again. Put away, an entry offers nothing else.
The worklist, and an entry's state
cms.queries is Cms.Entries: the entries of one content type, searched by
label (as typed: % and _ are characters, not wildcards), the archived ones or the rest. It lists entries, not content rows, so
something never published is in it.
An entry's state is not a column. This server derives it, with Cms.state,
from whether the entry has a draft and whether a visitor can see its row, using
your now. An overdue scheduled publish reads overdue, with its reason.