Skip to content

Latest commit

 

History

History
173 lines (109 loc) · 4.97 KB

File metadata and controls

173 lines (109 loc) · 4.97 KB
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`

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

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

IntervalSchedule

Properties

Property Type Required Description
type 'interval'
intervalMs integer Interval in milliseconds

Job

Properties

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

JobExecution

Properties

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

JobExecutionStatus

Allowed Values

  • running
  • success
  • failed
  • timeout

OnceSchedule

Properties

Property Type Required Description
type 'once'
at string ISO 8601 datetime when to execute

RetryPolicy

Properties

Property Type Required Description
maxRetries integer Maximum number of retry attempts
backoffMs integer Initial backoff delay in milliseconds
backoffMultiplier number Multiplier for exponential backoff

Schedule

Union Options

This schema accepts one of the following structures:

Option 1

Type: cron

Properties

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

Option 2

Type: interval

Properties

Property Type Required Description
type 'interval'
intervalMs integer Interval in milliseconds

Option 3

Type: once

Properties

Property Type Required Description
type 'once'
at string ISO 8601 datetime when to execute