Millwork
    Preparing search index...

    Module @millwork-ts/cron

    @millwork-ts/cron

    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"
    • croner checks the expression. A bad field, such as 61 minutes, is bad input.
    • The codec writes the expression with one space between the fields.
    • 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.
    • The run times use the local time zone of the device.
    • The codec does not start a job. To run a job, use croner directly.
    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' })],
    })
    CronOptions
    CronValue
    CronDialect
    codecs
    cron