UNPKG

@convex-dev/crons

Version:

Convex component for scheduling periodic jobs.

119 lines 3.78 kB
import { FunctionHandle } from "convex/server"; export type Schedule = { /** A schedule using a cron specification string. */ kind: "cron"; /** * A cron specification string. * ``` * * * * * * * * ┬ ┬ ┬ ┬ ┬ ┬ * │ │ │ │ │ | * │ │ │ │ │ └── day of week (0 - 7, 1L - 7L) (0 or 7 is Sun) * │ │ │ │ └───── month (1 - 12) * │ │ │ └──────── day of month (1 - 31, L) * │ │ └─────────── hour (0 - 23) * │ └────────────── minute (0 - 59) * └───────────────── second (0 - 59, optional) * ``` */ cronspec: string; tz?: string; } | { /** A schedule using an interval in milliseconds. */ kind: "interval"; /** The interval in milliseconds. */ ms: number; }; export type CronInfo = { id: string; name?: string; functionHandle: FunctionHandle<"mutation" | "action">; args: Record<string, unknown>; schedule: Schedule; }; /** * Schedule a mutation or action to run on a cron schedule or interval. * * @param name - Optional unique name for the job. Will throw if a name is * provided and a job with the same name already exists. * @param schedule - Either a cron specification string or an interval in * milliseconds. For intervals, ms must be >= 1000. * @param functionHandle - A {@link FunctionHandle} string for the function to * schedule. * @param args - The arguments to the function. * @returns The ID of the scheduled job. */ export declare const register: import("convex/server").RegisteredMutation<"public", { name?: string | undefined; functionHandle: string; args: Record<string, any>; schedule: { kind: "interval"; ms: number; } | { tz?: string | undefined; kind: "cron"; cronspec: string; }; }, Promise<import("convex/values").GenericId<"crons">>>; /** * List all user space cron jobs. * * @returns List of `cron` table rows. */ export declare const list: import("convex/server").RegisteredQuery<"public", {}, Promise<{ functionHandle: string; args: Record<string, any>; schedule: { kind: "interval"; ms: number; } | { tz?: string | undefined; kind: "cron"; cronspec: string; }; name?: string | undefined; id: import("convex/values").GenericId<"crons">; }[]>>; /** * Get an existing cron job by id or name. * * @param identifier - Either the ID or name of the cron job. * @returns Cron job document or null if not found. */ export declare const get: import("convex/server").RegisteredQuery<"public", { identifier: { id: import("convex/values").GenericId<"crons">; } | { name: string; }; }, Promise<{ functionHandle: string; args: Record<string, any>; schedule: { kind: "interval"; ms: number; } | { tz?: string | undefined; kind: "cron"; cronspec: string; }; name?: string | undefined; id: import("convex/values").GenericId<"crons">; } | null>>; /** * Delete and deschedule a cron job by id or name. * * @param identifier - Either the ID or name of the cron job. */ export declare const del: import("convex/server").RegisteredMutation<"public", { identifier: { id: import("convex/values").GenericId<"crons">; } | { name: string; }; }, Promise<void>>; export declare const rescheduler: import("convex/server").RegisteredMutation<"internal", { id: import("convex/values").GenericId<"crons">; }, Promise<void>>; //# sourceMappingURL=public.d.ts.map