MCPcopy
hub / github.com/triggerdotdev/trigger.dev / CronTrigger

Class CronTrigger

packages/trigger-sdk/src/triggers/scheduled.ts:83–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83export class CronTrigger implements Trigger<ScheduledEventSpecification> {
84 constructor(private options: CronOptions) {}
85
86 get event() {
87 /**
88 * We need to concat `(UTC)` string at the end of the human readable string to avoid confusion
89 * with execution time/last run of a job in the UI dashboard which is displayed in local time.
90 */
91 const humanReadable = cronstrue.toString(this.options.cron, {
92 throwExceptionOnParseError: false,
93 }).concat(" (UTC)");
94
95 return {
96 name: "trigger.scheduled",
97 title: "Cron Schedule",
98 source: "trigger.dev",
99 icon: "schedule-cron",
100 examples,
101 parsePayload: ScheduledPayloadSchema.parse,
102 properties: [
103 {
104 label: "cron",
105 text: this.options.cron,
106 },
107 {
108 label: "Schedule",
109 text: humanReadable,
110 },
111 ],
112 };
113 }
114
115 attachToJob(
116 triggerClient: TriggerClient,
117 job: Job<Trigger<ScheduledEventSpecification>, any>
118 ): void {}
119
120 get preprocessRuns() {
121 return false;
122 }
123
124 async verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>) {
125 return { success: true as const };
126 }
127
128 toJSON(): TriggerMetadata {
129 return {
130 type: "scheduled",
131 schedule: {
132 type: "cron",
133 options: {
134 cron: this.options.cron,
135 },
136 },
137 };
138 }
139}
140

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…