| title |
Job |
| description |
Job protocol schemas |
{/* ⚠️ AUTO-GENERATED — DO NOT EDIT. Run build-docs.ts to regenerate. Hand-written docs live in the module folders under content/docs/. */}
Cron Schedule Schema
Schedule jobs using cron expressions
**Source:** `packages/spec/src/system/job.zod.ts`
import { CronSchedule, IntervalSchedule, Job, JobExecution, JobExecutionStatus, OnceSchedule, RetryPolicy, Schedule } from '@objectstack/spec/system';
import type { CronSchedule, IntervalSchedule, Job, JobExecution, JobExecutionStatus, OnceSchedule, RetryPolicy, Schedule } from '@objectstack/spec/system';
// Validate data
const result = CronSchedule.parse(data);
| Property |
Type |
Required |
Description |
| type |
'cron' |
✅ |
|
| expression |
string | { dialect: Enum<'cel' | 'js' | 'cron' | 'template'>; source?: string; ast?: any; meta?: object } |
✅ |
Cron expression — cron0 0 * * * for daily at midnight. Build emits {dialect:"cron",source} envelope. |
| timezone |
string |
optional |
Timezone for cron execution (e.g., "America/New_York") |
| Property |
Type |
Required |
Description |
| type |
'interval' |
✅ |
|
| intervalMs |
integer |
✅ |
Interval in milliseconds |
| Property |
Type |
Required |
Description |
| id |
string |
optional |
Unique job identifier (defaults to name when omitted) |
| name |
string |
✅ |
Job name (snake_case) |
| label |
string |
optional |
Human-readable label |
| description |
string |
optional |
Job description / purpose |
| schedule |
{ type: 'cron'; expression: string | { dialect: Enum<'cel' | 'js' | 'cron' | 'template'>; source?: string; ast?: any; meta?: object }; timezone?: string } | { type: 'interval'; intervalMs: integer } | { type: 'once'; at: string } |
✅ |
Job schedule configuration |
| handler |
string |
✅ |
Handler function name (must match a key in defineStack({ functions })) |
| retryPolicy |
{ maxRetries?: integer; backoffMs?: integer; backoffMultiplier?: number } |
optional |
Retry policy configuration. [EXPERIMENTAL — not enforced] The service-job scheduler does not yet read retryPolicy; failed runs are not retried per this config (liveness audit #1878/#1893). |
| timeout |
integer |
optional |
Timeout in milliseconds. [EXPERIMENTAL — not enforced] The service-job scheduler does not yet enforce a per-run timeout (liveness audit #1878/#1893). |
| enabled |
boolean |
optional |
Whether the job is enabled |
| Property |
Type |
Required |
Description |
| jobId |
string |
✅ |
Job identifier |
| startedAt |
string |
✅ |
ISO 8601 datetime when execution started |
| completedAt |
string |
optional |
ISO 8601 datetime when execution completed |
| status |
Enum<'running' | 'success' | 'failed' | 'timeout'> |
✅ |
Execution status |
| error |
string |
optional |
Error message if failed |
| duration |
integer |
optional |
Execution duration in milliseconds |
running
success
failed
timeout
| Property |
Type |
Required |
Description |
| type |
'once' |
✅ |
|
| at |
string |
✅ |
ISO 8601 datetime when to execute |
| Property |
Type |
Required |
Description |
| maxRetries |
integer |
✅ |
Maximum number of retry attempts |
| backoffMs |
integer |
✅ |
Initial backoff delay in milliseconds |
| backoffMultiplier |
number |
✅ |
Multiplier for exponential backoff |
This schema accepts one of the following structures:
Type: cron
| Property |
Type |
Required |
Description |
| type |
'cron' |
✅ |
|
| expression |
string | { dialect: Enum<'cel' | 'js' | 'cron' | 'template'>; source?: string; ast?: any; meta?: object } |
✅ |
Cron expression — cron0 0 * * * for daily at midnight. Build emits {dialect:"cron",source} envelope. |
| timezone |
string |
optional |
Timezone for cron execution (e.g., "America/New_York") |
Type: interval
| Property |
Type |
Required |
Description |
| type |
'interval' |
✅ |
|
| intervalMs |
integer |
✅ |
Interval in milliseconds |
Type: once
| Property |
Type |
Required |
Description |
| type |
'once' |
✅ |
|
| at |
string |
✅ |
ISO 8601 datetime when to execute |