diff options
author | Raashid Anwar <raashid12anwar@gmail.com> | 2023-12-01 03:21:56 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-30 13:51:56 -0800 |
commit | ab755a07d8997a1d41b84e91ca772815c9ef9699 (patch) | |
tree | 62361900a2f6de3d1a459c28be785d5c3f8990e2 /cli/tsc | |
parent | 8050cbf39e69c1056eaa95e9e7b0887e50776b40 (diff) |
feat(cron): added the support for json type schedule to cron api (#21340)
Added the support for JSON type schedule to cron API; previously it was string only.
fixes #21122
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 5cba27a5e..895b7c0c5 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1319,9 +1319,39 @@ declare namespace Deno { /** **UNSTABLE**: New API, yet to be vetted. * + * CronScheduleExpression is used as the type of `minute`, `hour`, + * `dayOfMonth`, `month`, and `dayOfWeek` in {@linkcode CronSchedule}. + * @category Cron + */ + type CronScheduleExpression = number | { exact: number | number[] } | { + start?: number; + end?: number; + every?: number; + }; + + /** **UNSTABLE**: New API, yet to be vetted. + * + * CronSchedule is the interface used for JSON format + * cron `schedule`. + * @category Cron + */ + export interface CronSchedule { + minute?: CronScheduleExpression; + hour?: CronScheduleExpression; + dayOfMonth?: CronScheduleExpression; + month?: CronScheduleExpression; + dayOfWeek?: CronScheduleExpression; + } + + /** **UNSTABLE**: New API, yet to be vetted. + * * Create a cron job that will periodically execute the provided handler * callback based on the specified schedule. * + * `schedule` can be a string in the Unix cron format or in JSON format + * as specified by interface {@linkcode CronSchedule}, where time is specified + * using UTC time zone. + * * ```ts * Deno.cron("sample cron", "20 * * * *", () => { * console.log("cron job executed"); @@ -1339,7 +1369,7 @@ declare namespace Deno { */ export function cron( name: string, - schedule: string, + schedule: string | CronSchedule, handler: () => Promise<void> | void, options: { backoffSchedule?: number[]; signal?: AbortSignal }, ): Promise<void>; @@ -1355,14 +1385,15 @@ declare namespace Deno { * }); * ``` * - * `schedule` is a Unix cron format expression, where time is specified + * `schedule` can be a string in the Unix cron format or in JSON format + * as specified by interface {@linkcode CronSchedule}, where time is specified * using UTC time zone. * * @category Cron */ export function cron( name: string, - schedule: string, + schedule: string | CronSchedule, handler: () => Promise<void> | void, ): Promise<void>; @@ -1379,7 +1410,8 @@ declare namespace Deno { * }); * ``` * - * `schedule` is a Unix cron format expression, where time is specified + * `schedule` can be a string in the Unix cron format or in JSON format + * as specified by interface {@linkcode CronSchedule}, where time is specified * using UTC time zone. * * `backoffSchedule` option can be used to specify the retry policy for failed @@ -1392,7 +1424,7 @@ declare namespace Deno { */ export function cron( name: string, - schedule: string, + schedule: string | CronSchedule, options: { backoffSchedule?: number[]; signal?: AbortSignal }, handler: () => Promise<void> | void, ): Promise<void>; |