ObjectStackObjectStack

Job

Job protocol schemas

Cron Schedule Schema

Schedule jobs using cron expressions

Source: packages/spec/src/system/job.zod.ts

TypeScript Usage

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);

CronSchedule

Properties

PropertyTypeRequiredDescription
typestring
expressionstring | ObjectCron expression — cron0 0 * * * for daily at midnight. Build emits {dialect:"cron",source} envelope.
timezonestringoptionalTimezone for cron execution (e.g., "America/New_York")

IntervalSchedule

Properties

PropertyTypeRequiredDescription
typestring
intervalMsintegerInterval in milliseconds

Job

Properties

PropertyTypeRequiredDescription
idstringoptionalUnique job identifier (defaults to name when omitted)
namestringJob name (snake_case)
labelstringoptionalHuman-readable label
descriptionstringoptionalJob description / purpose
scheduleObject | Object | ObjectJob schedule configuration
handlerstringHandler function name (must match a key in defineStack({ functions }))
retryPolicyObjectoptionalRetry policy configuration
timeoutintegeroptionalTimeout in milliseconds
enabledbooleanoptionalWhether the job is enabled

JobExecution

Properties

PropertyTypeRequiredDescription
jobIdstringJob identifier
startedAtstringISO 8601 datetime when execution started
completedAtstringoptionalISO 8601 datetime when execution completed
statusEnum<'running' | 'success' | 'failed' | 'timeout'>Execution status
errorstringoptionalError message if failed
durationintegeroptionalExecution duration in milliseconds

JobExecutionStatus

Allowed Values

  • running
  • success
  • failed
  • timeout

OnceSchedule

Properties

PropertyTypeRequiredDescription
typestring
atstringISO 8601 datetime when to execute

RetryPolicy

Properties

PropertyTypeRequiredDescription
maxRetriesintegerMaximum number of retry attempts
backoffMsintegerInitial backoff delay in milliseconds
backoffMultipliernumberMultiplier for exponential backoff

Schedule

Union Options

This schema accepts one of the following structures:

Option 1

Type: cron

Properties

PropertyTypeRequiredDescription
typestring
expressionstring | ObjectCron expression — cron0 0 * * * for daily at midnight. Build emits {dialect:"cron",source} envelope.
timezonestringoptionalTimezone for cron execution (e.g., "America/New_York")

Option 2

Type: interval

Properties

PropertyTypeRequiredDescription
typestring
intervalMsintegerInterval in milliseconds

Option 3

Type: once

Properties

PropertyTypeRequiredDescription
typestring
atstringISO 8601 datetime when to execute


On this page