io.registerInterval and io.unregisterInterval jsdocs

This commit is contained in:
Matt Aitken
2023-07-04 11:22:24 +01:00
parent 9fbc5ab8de
commit 99c6cd0371
4 changed files with 25 additions and 0 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/sdk": patch
---
io.registerInterval and io.unregisterInterval jsdocs
+3
View File
@@ -554,8 +554,11 @@ export const InitializeTriggerBodySchema = z.object({
export type InitializeTriggerBody = z.infer<typeof InitializeTriggerBodySchema>;
const RegisterCommonScheduleBodySchema = z.object({
/** A unique id for the schedule. This is used to identify and unregister the schedule later. */
id: z.string(),
/** Any additional metadata about the schedule. */
metadata: z.any(),
/** This will be used by the Trigger.dev Connect feature, which is coming soon. */
accountId: z.string().optional(),
});
@@ -10,9 +10,11 @@ export const ScheduledPayloadSchema = z.object({
export type ScheduledPayload = z.infer<typeof ScheduledPayloadSchema>;
export const IntervalOptionsSchema = z.object({
/** The number of seconds for the interval. Min = 60, Max = 86400 (1 day) */
seconds: z.number().int().positive().min(60).max(86400),
});
/** Interval options */
export type IntervalOptions = z.infer<typeof IntervalOptionsSchema>;
export const CronOptionsSchema = z.object({
@@ -30,8 +32,11 @@ export const CronMetadataSchema = z.object({
export type CronMetadata = z.infer<typeof CronMetadataSchema>;
export const IntervalMetadataSchema = z.object({
/** An interval reoccurs at the specified number of seconds */
type: z.literal("interval"),
/** An object containing options about the interval. */
options: IntervalOptionsSchema,
/** Any additional metadata about the schedule. */
metadata: z.any(),
});
+12
View File
@@ -256,6 +256,13 @@ export class IO {
);
}
/** `io.registerInterval()` allows you to register a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that will trigger any jobs it's attached to on a regular interval.
* @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
* @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
* @param id A unique id for the interval. This is used to identify and unregister the interval later.
* @param options The options for the interval.
* @returns A promise that has information about the interval.
*/
async registerInterval(
key: string | any[],
dynamicSchedule: DynamicSchedule,
@@ -282,6 +289,11 @@ export class IO {
);
}
/** `io.unregisterInterval()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerInterval()`.
* @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
* @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
* @param id A unique id for the interval. This is used to identify and unregister the interval later.
*/
async unregisterInterval(
key: string | any[],
dynamicSchedule: DynamicSchedule,