A Millwork codec for cron expressions with croner.
pnpm add @millwork-ts/cron @millwork-ts/core croner
| Codec | Value | Raw |
|---|---|---|
cron |
a frozen { expression, dialect, next, nextRuns } |
"0 9 * * 1-5" |
61 minutes, is bad input.value.next(from?) gives the first run after from, or null. The default of from is
now.value.nextRuns(count, from?) gives the next count runs.| Option | Type | Use |
|---|---|---|
dialect |
'unix' | 'seconds' |
'unix' has 5 fields. 'seconds' has 6 fields, seconds first. The default is 'unix'. |
equals compares the expression, with one space between the fields, and the dialect.
"0 9 * * 1-5" equals "0 9 * * 1-5". "0 9 * * MON-FRI" does not equal "0 9 * * 1-5".
Register the codecs before the store calls transformations(), because transformations()
reads the registry when it runs. See the
@millwork-ts/warp-drive README.
import { codecs } from '@millwork-ts/cron'
import { registerCodecs, valueField } from '@millwork-ts/warp-drive'
import { withDefaults } from '@warp-drive/core/reactive'
registerCodecs(codecs)
export const ReportSchema = withDefaults({
type: 'report',
fields: [valueField('schedule', 'cron', { dialect: 'seconds' })],
})