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
expressionstringCron expression (e.g., "0 0 * * *" for daily at midnight)
timezonestringTimezone for cron execution (e.g., "America/New_York")

IntervalSchedule

Properties

PropertyTypeRequiredDescription
typestring
intervalMsintegerInterval in milliseconds

Job

Properties

PropertyTypeRequiredDescription
idstringUnique job identifier
namestringJob name (snake_case)
scheduleObject | Object | ObjectJob schedule configuration
handlerstringHandler path (e.g. "path/to/file:functionName") or script ID
retryPolicyObjectoptionalRetry policy configuration
timeoutintegeroptionalTimeout in milliseconds
enabledbooleanWhether 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
expressionstringCron expression (e.g., "0 0 * * *" for daily at midnight)
timezonestringTimezone 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