Recipes
Add Draft, Review, and Publishing States
Apply the standard workflow with capability-aware server enforcement.
Use the standard publishing workflow when editors draft, reviewers approve, and publishers control the public snapshot.
Attach Dyrected's standard editorial workflow and its capability-aware transitions to a collection.
Use this when
- add draft and publish states
- require review before publishing
- create an editorial workflow
- let editors submit content for approval
Dyrected concepts
publishingWorkflow, workflow transitions, capabilities
Additional packages: No additional packages.
Complete recipe
This is the canonical source compiled and behavior-tested by @dyrected/knowledge.
import { defineCollection, defineRichTextField, defineTextField, publishingWorkflow } from "@dyrected/core";
export const Posts = defineCollection({
slug: "posts",
workflow: publishingWorkflow(),
fields: [
defineTextField({ name: "title", label: "Title", required: true }),
defineRichTextField({ name: "body", label: "Body", required: true }),
],
});Decisions and cautions
- Map application roles to workflow capabilities on the server.
- Use
expectedRevisionfor transitions initiated from editable screens. - Treat rejection comments and workflow history as potentially sensitive editorial data.
- Put validation in
beforeTransition; useafterTransitionfor idempotent notifications and revalidation.
Do not recreate this lifecycle with an ordinary status select unless the application intentionally does not need capabilities, transition validation, revisions, history, or independent public materialization.