Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/app-showcase/src/objects/account.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export const Account = ObjectSchema.create({
label: 'Account Lifecycle',
description: 'Accounts move prospect → active → churned, and can be reactivated.',
field: 'status',
// Transitions are validated on update; insert sets the initial state.
events: ['update'] as const,
message: 'Invalid account lifecycle transition.',
transitions: {
prospect: ['active', 'churned'],
Expand Down
22 changes: 22 additions & 0 deletions examples/app-showcase/src/objects/project.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export const Project = ObjectSchema.create({
label: 'Project Status Flow',
description: 'Projects progress through valid status transitions.',
field: 'status',
// State machines validate *transitions*, so they run on update only —
// an insert sets the initial state (constrained by the select options).
events: ['update'] as const,
message: 'Invalid project status transition.',
transitions: {
planned: ['active', 'cancelled'],
Expand All @@ -83,5 +86,24 @@ export const Project = ObjectSchema.create({
cancelled: ['planned'],
},
},
{
// Advisory (severity: 'warning') state machine — demonstrates a soft
// transition guard: health should escalate/de-escalate one step at a
// time (green↔yellow↔red). A jump (e.g. green→red) is *flagged* (logged
// server-side) but NOT blocked, unlike the error-severity status flow.
type: 'state_machine' as const,
name: 'project_health_progression',
label: 'Project Health Progression (advisory)',
description: 'Health should change one step at a time; skips are warned, not blocked.',
field: 'health',
events: ['update'] as const,
severity: 'warning' as const,
message: 'Health changed by more than one step — confirm this is intentional.',
transitions: {
green: ['yellow'],
yellow: ['green', 'red'],
red: ['yellow'],
},
},
],
});
2 changes: 2 additions & 0 deletions examples/app-showcase/src/objects/task.object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ export const Task = ObjectSchema.create({
label: 'Task Status Flow',
description: 'Tasks move forward through the board (reopen allowed from Done).',
field: 'status',
// Transitions are validated on update; insert sets the initial state.
events: ['update'] as const,
message: 'Invalid task status transition.',
transitions: {
backlog: ['todo'],
Expand Down