UNPKG

@mastra/core

Version:
70 lines • 2.46 kB
/** * Validate a cron expression. Throws if the pattern is invalid. * * @param cron - Cron expression (5-, 6-, or 7-part). * @param timezone - Optional IANA timezone (e.g. 'America/New_York'). */ export declare function validateCron(cron: string, timezone?: string): void; /** * Compute the next fire time (ms since epoch) for a cron expression. * * @param cron - Cron expression. * @param options - Optional timezone and reference time (`after`, ms since epoch). * The next fire time is the first cron occurrence strictly after `after`. * Defaults to `Date.now()`. * @returns The next fire time in ms since epoch. * @throws If the cron expression is invalid or has no future occurrence. */ export declare function computeNextFireAt(cron: string, options?: { timezone?: string; after?: number; }): number; /** * Resolve what a schedule claim should write after firing at `after`. * * - One-off (`runAt` set): keep `nextFireAt` and mark the row `completed`. * - Cron with no future occurrence: keep `nextFireAt` and mark the row `completed`. * - Bounded cron (`endAt` set): advance to the next cron occurrence, or mark * `completed` when that occurrence is after `endAt`. * - Unbounded cron: advance to the next cron occurrence. */ export declare function computeNextFire(schedule: { cron: string; timezone?: string; runAt?: number; endAt?: number; nextFireAt: number; }, after: number): { nextFireAt: number; completed: boolean; }; /** * Validate the timing fields of a schedule: exactly one of `cron` or a future * `runAt`, `endAt` only alongside `cron` and in the future. Throws on invalid input. * Pass `requireFuture: false` for declarative config, which must survive redeploys * after its times have passed. */ export declare function validateScheduleTiming(input: { cron?: string; timezone?: string; runAt?: number | Date; endAt?: number | Date; }, options?: { requireFuture?: boolean; }): void; /** * Compute the initial row timing for a new schedule. One-offs fire at * `runAt`; a bounded cron whose first occurrence is already past `endAt` * starts `completed`. */ export declare function computeInitialFire(input: { cron?: string; timezone?: string; runAt?: number; endAt?: number; }): { nextFireAt: number; completed: boolean; }; export declare function toEpochMs(value: number | Date): number; //# sourceMappingURL=cron.d.ts.map