@trigger.dev/sdk 0.0.0-background-tasks-20230906212613 → 0.0.0-buffer-import-20231031135043

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _trigger_dev_core from '@trigger.dev/core';
2
- import { RunTaskBodyInput, CompleteTaskBodyInput, FailTaskBodyInput, SendEvent, SendEventOptions, UpdateTriggerSourceBodyV2, TriggerSource, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, BackgroundTaskMetadata, DeserializedJson, IntervalOptions, CronOptions, ScheduledPayload, ServerTask, CachedTask, FetchRequestInit, FetchRetryOptions, RunTaskOptions, IntegrationMetadata, QueueOptions, IntegrationConfig, JobMetadata, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
2
+ import { RunTaskBodyInput, CompleteTaskBodyInput, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, RunTaskOptions, IntegrationMetadata, QueueOptions, IntegrationConfig, JobMetadata, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
3
3
  export { ConnectionAuth, DisplayProperty, EventFilter, Logger, NormalizedRequest, OverridableRunTaskOptions, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
4
4
  import * as zod from 'zod';
5
5
  import { z } from 'zod';
@@ -21,7 +21,326 @@ declare class ApiClient {
21
21
  url: string;
22
22
  name: string;
23
23
  }): Promise<EndpointRecord>;
24
- runTask(runId: string, task: RunTaskBodyInput): Promise<{
24
+ runTask(runId: string, task: RunTaskBodyInput, options?: {
25
+ cachedTasksCursor?: string;
26
+ }): Promise<VersionedResponseBody<{
27
+ "2023-09-29": z.ZodObject<{
28
+ task: z.ZodObject<{
29
+ id: z.ZodString;
30
+ name: z.ZodString;
31
+ icon: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ noop: z.ZodBoolean;
33
+ startedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
34
+ completedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
35
+ delayUntil: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
36
+ status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
37
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
38
+ params: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
39
+ properties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
40
+ label: z.ZodString;
41
+ text: z.ZodString;
42
+ url: z.ZodOptional<z.ZodString>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ label: string;
45
+ text: string;
46
+ url?: string | undefined;
47
+ }, {
48
+ label: string;
49
+ text: string;
50
+ url?: string | undefined;
51
+ }>, "many">>>;
52
+ outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
53
+ label: z.ZodString;
54
+ text: z.ZodString;
55
+ url: z.ZodOptional<z.ZodString>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ label: string;
58
+ text: string;
59
+ url?: string | undefined;
60
+ }, {
61
+ label: string;
62
+ text: string;
63
+ url?: string | undefined;
64
+ }>, "many">>>;
65
+ output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
66
+ error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
67
+ parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
+ style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
69
+ style: z.ZodEnum<["normal", "minimal"]>;
70
+ variant: z.ZodOptional<z.ZodString>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ style: "normal" | "minimal";
73
+ variant?: string | undefined;
74
+ }, {
75
+ style: "normal" | "minimal";
76
+ variant?: string | undefined;
77
+ }>>>;
78
+ operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
79
+ callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
80
+ idempotencyKey: z.ZodString;
81
+ attempts: z.ZodNumber;
82
+ forceYield: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
83
+ }, "strip", z.ZodTypeAny, {
84
+ id: string;
85
+ name: string;
86
+ noop: boolean;
87
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
88
+ idempotencyKey: string;
89
+ attempts: number;
90
+ icon?: string | null | undefined;
91
+ startedAt?: Date | null | undefined;
92
+ completedAt?: Date | null | undefined;
93
+ delayUntil?: Date | null | undefined;
94
+ description?: string | null | undefined;
95
+ params?: _trigger_dev_core.DeserializedJson | undefined;
96
+ properties?: {
97
+ label: string;
98
+ text: string;
99
+ url?: string | undefined;
100
+ }[] | null | undefined;
101
+ outputProperties?: {
102
+ label: string;
103
+ text: string;
104
+ url?: string | undefined;
105
+ }[] | null | undefined;
106
+ output?: _trigger_dev_core.DeserializedJson | undefined;
107
+ error?: string | null | undefined;
108
+ parentId?: string | null | undefined;
109
+ style?: {
110
+ style: "normal" | "minimal";
111
+ variant?: string | undefined;
112
+ } | null | undefined;
113
+ operation?: string | null | undefined;
114
+ callbackUrl?: string | null | undefined;
115
+ forceYield?: boolean | null | undefined;
116
+ }, {
117
+ id: string;
118
+ name: string;
119
+ noop: boolean;
120
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
121
+ idempotencyKey: string;
122
+ attempts: number;
123
+ icon?: string | null | undefined;
124
+ startedAt?: Date | null | undefined;
125
+ completedAt?: Date | null | undefined;
126
+ delayUntil?: Date | null | undefined;
127
+ description?: string | null | undefined;
128
+ params?: _trigger_dev_core.DeserializedJson | undefined;
129
+ properties?: {
130
+ label: string;
131
+ text: string;
132
+ url?: string | undefined;
133
+ }[] | null | undefined;
134
+ outputProperties?: {
135
+ label: string;
136
+ text: string;
137
+ url?: string | undefined;
138
+ }[] | null | undefined;
139
+ output?: _trigger_dev_core.DeserializedJson | undefined;
140
+ error?: string | null | undefined;
141
+ parentId?: string | null | undefined;
142
+ style?: {
143
+ style: "normal" | "minimal";
144
+ variant?: string | undefined;
145
+ } | null | undefined;
146
+ operation?: string | null | undefined;
147
+ callbackUrl?: string | null | undefined;
148
+ forceYield?: boolean | null | undefined;
149
+ }>;
150
+ cachedTasks: z.ZodOptional<z.ZodObject<{
151
+ tasks: z.ZodArray<z.ZodObject<{
152
+ id: z.ZodString;
153
+ idempotencyKey: z.ZodString;
154
+ status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
155
+ noop: z.ZodDefault<z.ZodBoolean>;
156
+ output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
157
+ parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
158
+ }, "strip", z.ZodTypeAny, {
159
+ id: string;
160
+ noop: boolean;
161
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
162
+ idempotencyKey: string;
163
+ output?: _trigger_dev_core.DeserializedJson | undefined;
164
+ parentId?: string | null | undefined;
165
+ }, {
166
+ id: string;
167
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
168
+ idempotencyKey: string;
169
+ noop?: boolean | undefined;
170
+ output?: _trigger_dev_core.DeserializedJson | undefined;
171
+ parentId?: string | null | undefined;
172
+ }>, "many">;
173
+ cursor: z.ZodOptional<z.ZodString>;
174
+ }, "strip", z.ZodTypeAny, {
175
+ tasks: {
176
+ id: string;
177
+ noop: boolean;
178
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
179
+ idempotencyKey: string;
180
+ output?: _trigger_dev_core.DeserializedJson | undefined;
181
+ parentId?: string | null | undefined;
182
+ }[];
183
+ cursor?: string | undefined;
184
+ }, {
185
+ tasks: {
186
+ id: string;
187
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
188
+ idempotencyKey: string;
189
+ noop?: boolean | undefined;
190
+ output?: _trigger_dev_core.DeserializedJson | undefined;
191
+ parentId?: string | null | undefined;
192
+ }[];
193
+ cursor?: string | undefined;
194
+ }>>;
195
+ }, "strip", z.ZodTypeAny, {
196
+ task: {
197
+ id: string;
198
+ name: string;
199
+ noop: boolean;
200
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
201
+ idempotencyKey: string;
202
+ attempts: number;
203
+ icon?: string | null | undefined;
204
+ startedAt?: Date | null | undefined;
205
+ completedAt?: Date | null | undefined;
206
+ delayUntil?: Date | null | undefined;
207
+ description?: string | null | undefined;
208
+ params?: _trigger_dev_core.DeserializedJson | undefined;
209
+ properties?: {
210
+ label: string;
211
+ text: string;
212
+ url?: string | undefined;
213
+ }[] | null | undefined;
214
+ outputProperties?: {
215
+ label: string;
216
+ text: string;
217
+ url?: string | undefined;
218
+ }[] | null | undefined;
219
+ output?: _trigger_dev_core.DeserializedJson | undefined;
220
+ error?: string | null | undefined;
221
+ parentId?: string | null | undefined;
222
+ style?: {
223
+ style: "normal" | "minimal";
224
+ variant?: string | undefined;
225
+ } | null | undefined;
226
+ operation?: string | null | undefined;
227
+ callbackUrl?: string | null | undefined;
228
+ forceYield?: boolean | null | undefined;
229
+ };
230
+ cachedTasks?: {
231
+ tasks: {
232
+ id: string;
233
+ noop: boolean;
234
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
235
+ idempotencyKey: string;
236
+ output?: _trigger_dev_core.DeserializedJson | undefined;
237
+ parentId?: string | null | undefined;
238
+ }[];
239
+ cursor?: string | undefined;
240
+ } | undefined;
241
+ }, {
242
+ task: {
243
+ id: string;
244
+ name: string;
245
+ noop: boolean;
246
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
247
+ idempotencyKey: string;
248
+ attempts: number;
249
+ icon?: string | null | undefined;
250
+ startedAt?: Date | null | undefined;
251
+ completedAt?: Date | null | undefined;
252
+ delayUntil?: Date | null | undefined;
253
+ description?: string | null | undefined;
254
+ params?: _trigger_dev_core.DeserializedJson | undefined;
255
+ properties?: {
256
+ label: string;
257
+ text: string;
258
+ url?: string | undefined;
259
+ }[] | null | undefined;
260
+ outputProperties?: {
261
+ label: string;
262
+ text: string;
263
+ url?: string | undefined;
264
+ }[] | null | undefined;
265
+ output?: _trigger_dev_core.DeserializedJson | undefined;
266
+ error?: string | null | undefined;
267
+ parentId?: string | null | undefined;
268
+ style?: {
269
+ style: "normal" | "minimal";
270
+ variant?: string | undefined;
271
+ } | null | undefined;
272
+ operation?: string | null | undefined;
273
+ callbackUrl?: string | null | undefined;
274
+ forceYield?: boolean | null | undefined;
275
+ };
276
+ cachedTasks?: {
277
+ tasks: {
278
+ id: string;
279
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
280
+ idempotencyKey: string;
281
+ noop?: boolean | undefined;
282
+ output?: _trigger_dev_core.DeserializedJson | undefined;
283
+ parentId?: string | null | undefined;
284
+ }[];
285
+ cursor?: string | undefined;
286
+ } | undefined;
287
+ }>;
288
+ }, z.ZodObject<{
289
+ id: z.ZodString;
290
+ name: z.ZodString;
291
+ icon: z.ZodNullable<z.ZodOptional<z.ZodString>>;
292
+ noop: z.ZodBoolean;
293
+ startedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
294
+ completedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
295
+ delayUntil: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
296
+ status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
297
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
298
+ params: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
299
+ properties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
300
+ label: z.ZodString;
301
+ text: z.ZodString;
302
+ url: z.ZodOptional<z.ZodString>;
303
+ }, "strip", z.ZodTypeAny, {
304
+ label: string;
305
+ text: string;
306
+ url?: string | undefined;
307
+ }, {
308
+ label: string;
309
+ text: string;
310
+ url?: string | undefined;
311
+ }>, "many">>>;
312
+ outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
313
+ label: z.ZodString;
314
+ text: z.ZodString;
315
+ url: z.ZodOptional<z.ZodString>;
316
+ }, "strip", z.ZodTypeAny, {
317
+ label: string;
318
+ text: string;
319
+ url?: string | undefined;
320
+ }, {
321
+ label: string;
322
+ text: string;
323
+ url?: string | undefined;
324
+ }>, "many">>>;
325
+ output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
326
+ error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
327
+ parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
328
+ style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
329
+ style: z.ZodEnum<["normal", "minimal"]>;
330
+ variant: z.ZodOptional<z.ZodString>;
331
+ }, "strip", z.ZodTypeAny, {
332
+ style: "normal" | "minimal";
333
+ variant?: string | undefined;
334
+ }, {
335
+ style: "normal" | "minimal";
336
+ variant?: string | undefined;
337
+ }>>>;
338
+ operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
339
+ callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
340
+ idempotencyKey: z.ZodString;
341
+ attempts: z.ZodNumber;
342
+ forceYield: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
343
+ }, "strip", z.ZodTypeAny, {
25
344
  id: string;
26
345
  name: string;
27
346
  noop: boolean;
@@ -52,7 +371,42 @@ declare class ApiClient {
52
371
  variant?: string | undefined;
53
372
  } | null | undefined;
54
373
  operation?: string | null | undefined;
55
- }>;
374
+ callbackUrl?: string | null | undefined;
375
+ forceYield?: boolean | null | undefined;
376
+ }, {
377
+ id: string;
378
+ name: string;
379
+ noop: boolean;
380
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
381
+ idempotencyKey: string;
382
+ attempts: number;
383
+ icon?: string | null | undefined;
384
+ startedAt?: Date | null | undefined;
385
+ completedAt?: Date | null | undefined;
386
+ delayUntil?: Date | null | undefined;
387
+ description?: string | null | undefined;
388
+ params?: _trigger_dev_core.DeserializedJson | undefined;
389
+ properties?: {
390
+ label: string;
391
+ text: string;
392
+ url?: string | undefined;
393
+ }[] | null | undefined;
394
+ outputProperties?: {
395
+ label: string;
396
+ text: string;
397
+ url?: string | undefined;
398
+ }[] | null | undefined;
399
+ output?: _trigger_dev_core.DeserializedJson | undefined;
400
+ error?: string | null | undefined;
401
+ parentId?: string | null | undefined;
402
+ style?: {
403
+ style: "normal" | "minimal";
404
+ variant?: string | undefined;
405
+ } | null | undefined;
406
+ operation?: string | null | undefined;
407
+ callbackUrl?: string | null | undefined;
408
+ forceYield?: boolean | null | undefined;
409
+ }>>>;
56
410
  completeTask(runId: string, id: string, task: CompleteTaskBodyInput): Promise<{
57
411
  id: string;
58
412
  name: string;
@@ -84,6 +438,8 @@ declare class ApiClient {
84
438
  variant?: string | undefined;
85
439
  } | null | undefined;
86
440
  operation?: string | null | undefined;
441
+ callbackUrl?: string | null | undefined;
442
+ forceYield?: boolean | null | undefined;
87
443
  }>;
88
444
  failTask(runId: string, id: string, body: FailTaskBodyInput): Promise<{
89
445
  id: string;
@@ -116,6 +472,8 @@ declare class ApiClient {
116
472
  variant?: string | undefined;
117
473
  } | null | undefined;
118
474
  operation?: string | null | undefined;
475
+ callbackUrl?: string | null | undefined;
476
+ forceYield?: boolean | null | undefined;
119
477
  }>;
120
478
  sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
121
479
  id: string;
@@ -145,8 +503,23 @@ declare class ApiClient {
145
503
  deliveredAt?: Date | null | undefined;
146
504
  cancelledAt?: Date | null | undefined;
147
505
  }>;
506
+ cancelRunsForEvent(eventId: string): Promise<{
507
+ cancelledRunIds: string[];
508
+ failedToCancelRunIds: string[];
509
+ }>;
510
+ updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
511
+ label: string;
512
+ key: string;
513
+ history: {
514
+ label?: string | undefined;
515
+ state?: "loading" | "success" | "failure" | undefined;
516
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
517
+ }[];
518
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
519
+ state?: "loading" | "success" | "failure" | undefined;
520
+ }>;
148
521
  updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
149
- registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2): Promise<RegisterSourceEventV2>;
522
+ registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<RegisterSourceEventV2>;
150
523
  registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
151
524
  id: string;
152
525
  schedule: {
@@ -154,12 +527,14 @@ declare class ApiClient {
154
527
  cron: string;
155
528
  };
156
529
  type: "cron";
530
+ accountId?: string | undefined;
157
531
  metadata?: any;
158
532
  } | {
159
533
  options: {
160
534
  seconds: number;
161
535
  };
162
536
  type: "interval";
537
+ accountId?: string | undefined;
163
538
  metadata?: any;
164
539
  };
165
540
  active: boolean;
@@ -169,7 +544,7 @@ declare class ApiClient {
169
544
  ok: boolean;
170
545
  }>;
171
546
  getAuth(client: string, id: string): Promise<{
172
- type: "oauth2";
547
+ type: "oauth2" | "apiKey";
173
548
  accessToken: string;
174
549
  scopes?: string[] | undefined;
175
550
  additionalFields?: Record<string, string> | undefined;
@@ -177,36 +552,98 @@ declare class ApiClient {
177
552
  getEvent(eventId: string): Promise<{
178
553
  id: string;
179
554
  name: string;
180
- createdAt: Date;
181
555
  updatedAt: Date;
182
556
  runs: {
183
557
  id: string;
184
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
558
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
185
559
  startedAt?: Date | null | undefined;
186
560
  completedAt?: Date | null | undefined;
187
561
  }[];
562
+ createdAt: Date;
188
563
  }>;
189
564
  getRun(runId: string, options?: GetRunOptionsWithTaskDetails): Promise<{
190
565
  id: string;
191
566
  startedAt: Date | null;
192
567
  completedAt: Date | null;
193
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
568
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
569
+ updatedAt: Date | null;
194
570
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
571
+ statuses: {
572
+ label: string;
573
+ key: string;
574
+ history: {
575
+ label?: string | undefined;
576
+ state?: "loading" | "success" | "failure" | undefined;
577
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
578
+ }[];
579
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
580
+ state?: "loading" | "success" | "failure" | undefined;
581
+ }[];
582
+ output?: any;
583
+ nextCursor?: string | undefined;
584
+ }>;
585
+ cancelRun(runId: string): Promise<{
586
+ id: string;
587
+ startedAt: Date | null;
588
+ completedAt: Date | null;
589
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
195
590
  updatedAt: Date | null;
591
+ tasks: _trigger_dev_core.RunTaskWithSubtasks[];
592
+ statuses: {
593
+ label: string;
594
+ key: string;
595
+ history: {
596
+ label?: string | undefined;
597
+ state?: "loading" | "success" | "failure" | undefined;
598
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
599
+ }[];
600
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
601
+ state?: "loading" | "success" | "failure" | undefined;
602
+ }[];
196
603
  output?: any;
197
604
  nextCursor?: string | undefined;
198
605
  }>;
606
+ getRunStatuses(runId: string): Promise<{
607
+ statuses: {
608
+ label: string;
609
+ key: string;
610
+ history: {
611
+ label?: string | undefined;
612
+ state?: "loading" | "success" | "failure" | undefined;
613
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
614
+ }[];
615
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
616
+ state?: "loading" | "success" | "failure" | undefined;
617
+ }[];
618
+ run: {
619
+ id: string;
620
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
621
+ output?: any;
622
+ };
623
+ }>;
199
624
  getRuns(jobSlug: string, options?: GetRunsOptions): Promise<{
200
625
  runs: {
201
626
  id: string;
202
627
  startedAt: Date | null;
203
628
  completedAt: Date | null;
204
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
629
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
205
630
  updatedAt: Date | null;
206
631
  }[];
207
632
  nextCursor?: string | undefined;
208
633
  }>;
209
634
  }
635
+ type VersionedResponseBodyMap = {
636
+ [key: string]: z.ZodTypeAny;
637
+ };
638
+ type VersionedResponseBody<TVersions extends VersionedResponseBodyMap, TUnversioned extends z.ZodTypeAny> = {
639
+ [TVersion in keyof TVersions]: {
640
+ version: TVersion;
641
+ body: z.infer<TVersions[TVersion]>;
642
+ };
643
+ }[keyof TVersions] | {
644
+ version: "unversioned";
645
+ body: z.infer<TUnversioned>;
646
+ };
210
647
 
211
648
  interface TriggerContext {
212
649
  /** Job metadata */
@@ -318,6 +755,22 @@ interface EventSpecification<TEvent extends any> {
318
755
  runProperties?: (payload: TEvent) => DisplayProperty[];
319
756
  }
320
757
  type EventTypeFromSpecification<TEventSpec extends EventSpecification<any>> = TEventSpec extends EventSpecification<infer TEvent> ? TEvent : never;
758
+ type SchemaParserIssue = {
759
+ path: PropertyKey[];
760
+ message: string;
761
+ };
762
+ type SchemaParserResult<T> = {
763
+ success: true;
764
+ data: T;
765
+ } | {
766
+ success: false;
767
+ error: {
768
+ issues: SchemaParserIssue[];
769
+ };
770
+ };
771
+ type SchemaParser<T extends unknown = unknown> = {
772
+ safeParse: (a: unknown) => SchemaParserResult<T>;
773
+ };
321
774
 
322
775
  type HttpSourceEvent = {
323
776
  url: string;
@@ -402,8 +855,8 @@ type FilterFunction<TParams extends any, TTriggerOptionDefinitions extends Recor
402
855
  type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
403
856
  id: string;
404
857
  version: string;
405
- schema: z.Schema<TParams>;
406
- optionSchema?: z.Schema<TTriggerOptionDefinitions>;
858
+ schema: SchemaParser<TParams>;
859
+ optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
407
860
  integration: TIntegration;
408
861
  register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
409
862
  filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
@@ -447,9 +900,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
447
900
  get id(): string;
448
901
  get version(): string;
449
902
  }
450
- type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams & {
451
- filter?: EventFilter;
452
- } : never;
903
+ type ExternalSourceParams<TExternalSource extends ExternalSource<any, any, any>> = TExternalSource extends ExternalSource<any, infer TParams, any> ? TParams : never;
453
904
  type ExternalSourceTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends ExternalSource<any, any, any>, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
454
905
  event: TEventSpecification;
455
906
  source: TEventSource;
@@ -480,7 +931,7 @@ type DynamicTriggerOptions<TEventSpec extends EventSpecification<any>, TExternal
480
931
  * ```ts
481
932
  * import { events } from "@trigger.dev/github";
482
933
  *
483
- * const dynamicOnIssueOpened = new DynamicTrigger(client, {
934
+ * const dynamicOnIssueOpened = client.defineDynamicTrigger({
484
935
  id: "github-issue-opened",
485
936
  event: events.onIssueOpened,
486
937
  source: github.sources.repo,
@@ -501,44 +952,152 @@ declare class DynamicTrigger<TEventSpec extends EventSpecification<any>, TExtern
501
952
  toJSON(): TriggerMetadata;
502
953
  get id(): string;
503
954
  get event(): TEventSpec;
504
- registeredTriggerForParams(params: ExternalSourceParams<TExternalSource>): RegisterTriggerBodyV2;
505
955
  /** Use this method to register a new configuration with the DynamicTrigger.
506
956
  * @param key The key for the configuration. This will be used to identify the configuration when it is triggered.
507
957
  * @param params The params for the configuration.
958
+ * @param options Options for the configuration.
959
+ * @param options.accountId The accountId to associate with the configuration.
960
+ * @param options.filter The filter to use for the configuration.
961
+ *
508
962
  */
509
- register(key: string, params: ExternalSourceParams<TExternalSource>): Promise<RegisterSourceEventV2>;
963
+ register(key: string, params: ExternalSourceParams<TExternalSource>, options?: {
964
+ accountId?: string;
965
+ filter?: EventFilter;
966
+ }): Promise<RegisterSourceEventV2>;
510
967
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
511
968
  get preprocessRuns(): boolean;
512
969
  }
513
970
 
514
- type BackgroundTaskOptions<TPayload = any> = {
515
- id: string;
516
- name: string;
517
- version: string;
518
- schema?: z.Schema<TPayload>;
519
- logLevel?: LogLevel;
520
- cpu?: 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128;
521
- memory?: 256 | 512 | 1024 | 2048 | 4096 | 8192 | 16384 | 32768;
522
- concurrency?: number;
523
- secrets?: {
524
- [key: string]: string;
971
+ type ScheduledEventSpecification = EventSpecification<ScheduledPayload>;
972
+ declare class IntervalTrigger implements Trigger<ScheduledEventSpecification> {
973
+ private options;
974
+ constructor(options: IntervalOptions);
975
+ get event(): {
976
+ name: string;
977
+ title: string;
978
+ source: string;
979
+ icon: string;
980
+ examples: {
981
+ id: string;
982
+ name: string;
983
+ icon: string;
984
+ payload: {
985
+ ts: string;
986
+ lastTimestamp: string;
987
+ };
988
+ }[];
989
+ parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
990
+ ts: Date;
991
+ lastTimestamp?: Date | undefined;
992
+ };
993
+ properties: {
994
+ label: string;
995
+ text: string;
996
+ }[];
525
997
  };
526
- enabled?: boolean;
527
- run: (payload: TPayload) => Promise<any>;
998
+ attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
999
+ get preprocessRuns(): boolean;
1000
+ toJSON(): TriggerMetadata;
1001
+ }
1002
+ /** `intervalTrigger()` is set as a [Job's trigger](/sdk/job) to trigger a Job at a recurring interval.
1003
+ * @param options An object containing options about the interval.
1004
+ */
1005
+ declare function intervalTrigger(options: IntervalOptions): IntervalTrigger;
1006
+ declare class CronTrigger implements Trigger<ScheduledEventSpecification> {
1007
+ private options;
1008
+ constructor(options: CronOptions);
1009
+ get event(): {
1010
+ name: string;
1011
+ title: string;
1012
+ source: string;
1013
+ icon: string;
1014
+ examples: {
1015
+ id: string;
1016
+ name: string;
1017
+ icon: string;
1018
+ payload: {
1019
+ ts: string;
1020
+ lastTimestamp: string;
1021
+ };
1022
+ }[];
1023
+ parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
1024
+ ts: Date;
1025
+ lastTimestamp?: Date | undefined;
1026
+ };
1027
+ properties: {
1028
+ label: string;
1029
+ text: string;
1030
+ }[];
1031
+ };
1032
+ attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1033
+ get preprocessRuns(): boolean;
1034
+ toJSON(): TriggerMetadata;
1035
+ }
1036
+ /** `cronTrigger()` is set as a [Job's trigger](https://trigger.dev/docs/sdk/job) to trigger a Job on a recurring schedule using a CRON expression.
1037
+ * @param options An object containing options about the CRON schedule.
1038
+ */
1039
+ declare function cronTrigger(options: CronOptions): CronTrigger;
1040
+ /** DynamicSchedule options
1041
+ * @param id Used to uniquely identify a DynamicSchedule
1042
+ */
1043
+ type DynamicIntervalOptions = {
1044
+ id: string;
528
1045
  };
529
- declare class BackgroundTask<TPayload = any> {
530
- #private;
531
- readonly options: BackgroundTaskOptions<TPayload>;
532
- client: TriggerClient;
533
- constructor(client: TriggerClient, options: BackgroundTaskOptions<TPayload>);
1046
+ /** DynamicSchedule` allows you to define a scheduled trigger that can be configured dynamically at runtime. */
1047
+ declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
1048
+ private client;
1049
+ private options;
1050
+ /**
1051
+ * @param client The `TriggerClient` instance to use for registering the trigger.
1052
+ * @param options The options for the schedule.
1053
+ */
1054
+ constructor(client: TriggerClient, options: DynamicIntervalOptions);
534
1055
  get id(): string;
535
- get enabled(): boolean;
536
- get name(): string;
537
- get schema(): z.ZodType<TPayload, z.ZodTypeDef, TPayload> | undefined;
538
- get version(): string;
539
- get logLevel(): LogLevel | undefined;
540
- invoke(key: string, payload: TPayload): Promise<any>;
541
- toJSON(): BackgroundTaskMetadata;
1056
+ get event(): {
1057
+ name: string;
1058
+ title: string;
1059
+ source: string;
1060
+ icon: string;
1061
+ examples: {
1062
+ id: string;
1063
+ name: string;
1064
+ icon: string;
1065
+ payload: {
1066
+ ts: string;
1067
+ lastTimestamp: string;
1068
+ };
1069
+ }[];
1070
+ parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
1071
+ ts: Date;
1072
+ lastTimestamp?: Date | undefined;
1073
+ };
1074
+ };
1075
+ register(key: string, metadata: ScheduleMetadata): Promise<{
1076
+ id: string;
1077
+ schedule: {
1078
+ options: {
1079
+ cron: string;
1080
+ };
1081
+ type: "cron";
1082
+ accountId?: string | undefined;
1083
+ metadata?: any;
1084
+ } | {
1085
+ options: {
1086
+ seconds: number;
1087
+ };
1088
+ type: "interval";
1089
+ accountId?: string | undefined;
1090
+ metadata?: any;
1091
+ };
1092
+ active: boolean;
1093
+ metadata?: any;
1094
+ }>;
1095
+ unregister(key: string): Promise<{
1096
+ ok: boolean;
1097
+ }>;
1098
+ attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1099
+ get preprocessRuns(): boolean;
1100
+ toJSON(): TriggerMetadata;
542
1101
  }
543
1102
 
544
1103
  type TriggerClientOptions = {
@@ -560,14 +1119,23 @@ type TriggerClientOptions = {
560
1119
  /** Default is unset and off. If set to true it will log to the server's console as well as the Trigger.dev platform */
561
1120
  ioLogLocalEnabled?: boolean;
562
1121
  };
1122
+ type AuthResolverResult = {
1123
+ type: "apiKey" | "oauth";
1124
+ token: string;
1125
+ additionalFields?: Record<string, string>;
1126
+ };
1127
+ type TriggerAuthResolver = (ctx: TriggerContext, integration: TriggerIntegration) => Promise<AuthResolverResult | void | undefined>;
563
1128
  /** A [TriggerClient](https://trigger.dev/docs/documentation/concepts/client-adaptors) is used to connect to a specific [Project](https://trigger.dev/docs/documentation/concepts/projects) by using an [API Key](https://trigger.dev/docs/documentation/concepts/environments-apikeys). */
564
1129
  declare class TriggerClient {
565
1130
  #private;
566
1131
  id: string;
567
1132
  constructor(options: Prettify<TriggerClientOptions>);
568
- handleRequest(request: Request): Promise<NormalizedResponse>;
1133
+ handleRequest(request: Request, timeOrigin?: number): Promise<NormalizedResponse>;
1134
+ defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}>(options: JobOptions<TTrigger, TIntegrations>): Job<TTrigger, TIntegrations>;
1135
+ defineAuthResolver(integration: TriggerIntegration, resolver: TriggerAuthResolver): TriggerClient;
1136
+ defineDynamicSchedule(options: DynamicIntervalOptions): DynamicSchedule;
1137
+ defineDynamicTrigger<TEventSpec extends EventSpecification<any>, TExternalSource extends ExternalSource<any, any, any>>(options: DynamicTriggerOptions<TEventSpec, TExternalSource>): DynamicTrigger<TEventSpec, TExternalSource>;
569
1138
  attach(job: Job<Trigger<any>, any>): void;
570
- attachBackgroundTask(task: BackgroundTask<any>): void;
571
1139
  attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
572
1140
  attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
573
1141
  attachSource(options: {
@@ -577,8 +1145,9 @@ declare class TriggerClient {
577
1145
  params: any;
578
1146
  options?: Record<string, string[]>;
579
1147
  }): void;
580
- attachDynamicSchedule(key: string, job: Job<Trigger<any>, any>): void;
581
- registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2): Promise<{
1148
+ attachDynamicSchedule(key: string): void;
1149
+ attachDynamicScheduleToJob(key: string, job: Job<Trigger<any>, any>): void;
1150
+ registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
582
1151
  id: string;
583
1152
  options: {
584
1153
  event: {
@@ -610,12 +1179,12 @@ declare class TriggerClient {
610
1179
  dynamicTriggerId?: string | undefined;
611
1180
  }>;
612
1181
  getAuth(id: string): Promise<{
613
- type: "oauth2";
1182
+ type: "oauth2" | "apiKey";
614
1183
  accessToken: string;
615
1184
  scopes?: string[] | undefined;
616
1185
  additionalFields?: Record<string, string> | undefined;
617
1186
  } | undefined>;
618
- /** You can call this function from anywhere in your code to send an event. The other way to send an event is by using [`io.sendEvent()`](https://trigger.dev/docs/sdk/io/sendevent) from inside a `run()` function.
1187
+ /** You can call this function from anywhere in your backend to send an event. The other way to send an event is by using [`io.sendEvent()`](https://trigger.dev/docs/sdk/io/sendevent) from inside a `run()` function.
619
1188
  * @param event The event to send.
620
1189
  * @param options Options for sending the event.
621
1190
  * @returns A promise that resolves to the event details
@@ -648,6 +1217,21 @@ declare class TriggerClient {
648
1217
  deliveredAt?: Date | null | undefined;
649
1218
  cancelledAt?: Date | null | undefined;
650
1219
  }>;
1220
+ cancelRunsForEvent(eventId: string): Promise<{
1221
+ cancelledRunIds: string[];
1222
+ failedToCancelRunIds: string[];
1223
+ }>;
1224
+ updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
1225
+ label: string;
1226
+ key: string;
1227
+ history: {
1228
+ label?: string | undefined;
1229
+ state?: "loading" | "success" | "failure" | undefined;
1230
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1231
+ }[];
1232
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1233
+ state?: "loading" | "success" | "failure" | undefined;
1234
+ }>;
651
1235
  registerSchedule(id: string, key: string, schedule: ScheduleMetadata): Promise<{
652
1236
  id: string;
653
1237
  schedule: {
@@ -655,12 +1239,14 @@ declare class TriggerClient {
655
1239
  cron: string;
656
1240
  };
657
1241
  type: "cron";
1242
+ accountId?: string | undefined;
658
1243
  metadata?: any;
659
1244
  } | {
660
1245
  options: {
661
1246
  seconds: number;
662
1247
  };
663
1248
  type: "interval";
1249
+ accountId?: string | undefined;
664
1250
  metadata?: any;
665
1251
  };
666
1252
  active: boolean;
@@ -672,22 +1258,54 @@ declare class TriggerClient {
672
1258
  getEvent(eventId: string): Promise<{
673
1259
  id: string;
674
1260
  name: string;
675
- createdAt: Date;
676
1261
  updatedAt: Date;
677
1262
  runs: {
678
1263
  id: string;
679
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
1264
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
680
1265
  startedAt?: Date | null | undefined;
681
1266
  completedAt?: Date | null | undefined;
682
1267
  }[];
1268
+ createdAt: Date;
683
1269
  }>;
684
1270
  getRun(runId: string, options?: GetRunOptionsWithTaskDetails): Promise<{
685
1271
  id: string;
686
1272
  startedAt: Date | null;
687
1273
  completedAt: Date | null;
688
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
1274
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1275
+ updatedAt: Date | null;
689
1276
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1277
+ statuses: {
1278
+ label: string;
1279
+ key: string;
1280
+ history: {
1281
+ label?: string | undefined;
1282
+ state?: "loading" | "success" | "failure" | undefined;
1283
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1284
+ }[];
1285
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1286
+ state?: "loading" | "success" | "failure" | undefined;
1287
+ }[];
1288
+ output?: any;
1289
+ nextCursor?: string | undefined;
1290
+ }>;
1291
+ cancelRun(runId: string): Promise<{
1292
+ id: string;
1293
+ startedAt: Date | null;
1294
+ completedAt: Date | null;
1295
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
690
1296
  updatedAt: Date | null;
1297
+ tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1298
+ statuses: {
1299
+ label: string;
1300
+ key: string;
1301
+ history: {
1302
+ label?: string | undefined;
1303
+ state?: "loading" | "success" | "failure" | undefined;
1304
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1305
+ }[];
1306
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1307
+ state?: "loading" | "success" | "failure" | undefined;
1308
+ }[];
691
1309
  output?: any;
692
1310
  nextCursor?: string | undefined;
693
1311
  }>;
@@ -696,145 +1314,48 @@ declare class TriggerClient {
696
1314
  id: string;
697
1315
  startedAt: Date | null;
698
1316
  completedAt: Date | null;
699
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
1317
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
700
1318
  updatedAt: Date | null;
701
1319
  }[];
702
1320
  nextCursor?: string | undefined;
703
1321
  }>;
704
- authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
705
- apiKey(): string | undefined;
706
- defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}>(options: JobOptions<TTrigger, TIntegrations>): Job<TTrigger, TIntegrations>;
707
- defineBackgroundTask<TPayload = any>(options: BackgroundTaskOptions<TPayload>): BackgroundTask<TPayload>;
708
- }
709
-
710
- type ScheduledEventSpecification = EventSpecification<ScheduledPayload>;
711
- declare class IntervalTrigger implements Trigger<ScheduledEventSpecification> {
712
- private options;
713
- constructor(options: IntervalOptions);
714
- get event(): {
715
- name: string;
716
- title: string;
717
- source: string;
718
- icon: string;
719
- examples: {
720
- id: string;
721
- name: string;
722
- icon: string;
723
- payload: {
724
- ts: string;
725
- lastTimestamp: string;
726
- };
727
- }[];
728
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
729
- ts: Date;
730
- lastTimestamp?: Date | undefined;
731
- };
732
- properties: {
1322
+ getRunStatuses(runId: string): Promise<{
1323
+ statuses: {
733
1324
  label: string;
734
- text: string;
1325
+ key: string;
1326
+ history: {
1327
+ label?: string | undefined;
1328
+ state?: "loading" | "success" | "failure" | undefined;
1329
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1330
+ }[];
1331
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1332
+ state?: "loading" | "success" | "failure" | undefined;
735
1333
  }[];
736
- };
737
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
738
- get preprocessRuns(): boolean;
739
- toJSON(): TriggerMetadata;
740
- }
741
- /** `intervalTrigger()` is set as a [Job's trigger](/sdk/job) to trigger a Job at a recurring interval.
742
- * @param options An object containing options about the interval.
743
- */
744
- declare function intervalTrigger(options: IntervalOptions): IntervalTrigger;
745
- declare class CronTrigger implements Trigger<ScheduledEventSpecification> {
746
- private options;
747
- constructor(options: CronOptions);
748
- get event(): {
749
- name: string;
750
- title: string;
751
- source: string;
752
- icon: string;
753
- examples: {
1334
+ run: {
754
1335
  id: string;
755
- name: string;
756
- icon: string;
757
- payload: {
758
- ts: string;
759
- lastTimestamp: string;
760
- };
761
- }[];
762
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
763
- ts: Date;
764
- lastTimestamp?: Date | undefined;
1336
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1337
+ output?: any;
765
1338
  };
766
- properties: {
767
- label: string;
768
- text: string;
769
- }[];
770
- };
771
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
772
- get preprocessRuns(): boolean;
773
- toJSON(): TriggerMetadata;
1339
+ }>;
1340
+ authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
1341
+ apiKey(): string | undefined;
774
1342
  }
775
- /** `cronTrigger()` is set as a [Job's trigger](https://trigger.dev/docs/sdk/job) to trigger a Job on a recurring schedule using a CRON expression.
776
- * @param options An object containing options about the CRON schedule.
777
- */
778
- declare function cronTrigger(options: CronOptions): CronTrigger;
779
- /** DynamicSchedule options
780
- * @param id Used to uniquely identify a DynamicSchedule
781
- */
782
- type DynamicIntervalOptions = {
783
- id: string;
784
- };
785
- /** DynamicSchedule` allows you to define a scheduled trigger that can be configured dynamically at runtime. */
786
- declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
787
- private client;
788
- private options;
789
- /**
790
- * @param client The `TriggerClient` instance to use for registering the trigger.
791
- * @param options The options for the schedule.
792
- */
793
- constructor(client: TriggerClient, options: DynamicIntervalOptions);
794
- get id(): string;
795
- get event(): {
796
- name: string;
797
- title: string;
798
- source: string;
799
- icon: string;
800
- examples: {
801
- id: string;
802
- name: string;
803
- icon: string;
804
- payload: {
805
- ts: string;
806
- lastTimestamp: string;
807
- };
1343
+
1344
+ declare class TriggerStatus {
1345
+ private id;
1346
+ private io;
1347
+ constructor(id: string, io: IO);
1348
+ update(key: IntegrationTaskKey, status: StatusUpdate): Promise<{
1349
+ label: string;
1350
+ key: string;
1351
+ history: {
1352
+ label?: string | undefined;
1353
+ state?: "loading" | "success" | "failure" | undefined;
1354
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
808
1355
  }[];
809
- parsePayload: (data: unknown, params?: Partial<zod.ParseParams> | undefined) => {
810
- ts: Date;
811
- lastTimestamp?: Date | undefined;
812
- };
813
- };
814
- register(key: string, metadata: ScheduleMetadata): Promise<{
815
- id: string;
816
- schedule: {
817
- options: {
818
- cron: string;
819
- };
820
- type: "cron";
821
- metadata?: any;
822
- } | {
823
- options: {
824
- seconds: number;
825
- };
826
- type: "interval";
827
- metadata?: any;
828
- };
829
- active: boolean;
830
- metadata?: any;
1356
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1357
+ state?: "loading" | "success" | "failure" | undefined;
831
1358
  }>;
832
- unregister(key: string): Promise<{
833
- ok: boolean;
834
- }>;
835
- attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
836
- get preprocessRuns(): boolean;
837
- toJSON(): TriggerMetadata;
838
1359
  }
839
1360
 
840
1361
  type IOTask = ServerTask;
@@ -843,11 +1364,17 @@ type IOOptions = {
843
1364
  apiClient: ApiClient;
844
1365
  client: TriggerClient;
845
1366
  context: TriggerContext;
1367
+ timeOrigin: number;
846
1368
  logger?: Logger;
847
1369
  logLevel?: LogLevel;
848
1370
  jobLogger?: Logger;
849
1371
  jobLogLevel: LogLevel;
850
1372
  cachedTasks?: Array<CachedTask>;
1373
+ cachedTasksCursor?: string;
1374
+ yieldedExecutions?: Array<string>;
1375
+ noopTasksSet?: string;
1376
+ serverVersion?: string | null;
1377
+ executionTimeout?: number;
851
1378
  };
852
1379
  type JsonPrimitive = string | number | boolean | null | undefined | Date | symbol;
853
1380
  type JsonArray = Json[];
@@ -856,10 +1383,20 @@ type JsonRecord<T> = {
856
1383
  };
857
1384
  type Json<T = any> = JsonPrimitive | JsonArray | JsonRecord<T>;
858
1385
  type RunTaskErrorCallback = (error: unknown, task: IOTask, io: IO) => {
859
- retryAt: Date;
1386
+ retryAt?: Date;
860
1387
  error?: Error;
861
1388
  jitter?: number;
1389
+ skipRetrying?: boolean;
862
1390
  } | Error | undefined | void;
1391
+ type IOStats = {
1392
+ initialCachedTasks: number;
1393
+ lazyLoadedCachedTasks: number;
1394
+ executedTasks: number;
1395
+ cachedTaskHits: number;
1396
+ cachedTaskMisses: number;
1397
+ noopCachedTaskHits: number;
1398
+ noopCachedTaskMisses: number;
1399
+ };
863
1400
  declare class IO {
864
1401
  #private;
865
1402
  private _id;
@@ -870,17 +1407,58 @@ declare class IO {
870
1407
  private _jobLogLevel;
871
1408
  private _cachedTasks;
872
1409
  private _taskStorage;
1410
+ private _cachedTasksCursor?;
873
1411
  private _context;
1412
+ private _yieldedExecutions;
1413
+ private _noopTasksBloomFilter;
1414
+ private _stats;
1415
+ private _serverVersion;
1416
+ private _timeOrigin;
1417
+ private _executionTimeout?;
1418
+ get stats(): IOStats;
874
1419
  constructor(options: IOOptions);
875
1420
  /** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
876
1421
  get logger(): IOLogger;
877
1422
  /** `io.wait()` waits for the specified amount of time before continuing the Job. Delays work even if you're on a serverless platform with timeouts, or if your server goes down. They utilize [resumability](https://trigger.dev/docs/documentation/concepts/resumability) to ensure that the Run can be resumed after the delay.
878
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1423
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
879
1424
  * @param seconds The number of seconds to wait. This can be very long, serverless timeouts are not an issue.
880
1425
  */
881
- wait(key: string | any[], seconds: number): Promise<void>;
1426
+ wait(cacheKey: string | any[], seconds: number): Promise<void>;
1427
+ /** `io.createStatus()` allows you to set a status with associated data during the Run. Statuses can be used by your UI using the react package
1428
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1429
+ * @param initialStatus The initial status you want this status to have. You can update it during the rub using the returned object.
1430
+ * @returns a TriggerStatus object that you can call `update()` on, to update the status.
1431
+ * @example
1432
+ * ```ts
1433
+ * client.defineJob(
1434
+ //...
1435
+ run: async (payload, io, ctx) => {
1436
+ const generatingImages = await io.createStatus("generating-images", {
1437
+ label: "Generating Images",
1438
+ state: "loading",
1439
+ data: {
1440
+ progress: 0.1,
1441
+ },
1442
+ });
1443
+
1444
+ //...do stuff
1445
+
1446
+ await generatingImages.update("completed-generation", {
1447
+ label: "Generated images",
1448
+ state: "success",
1449
+ data: {
1450
+ progress: 1.0,
1451
+ urls: ["http://..."]
1452
+ },
1453
+ });
1454
+
1455
+ //...
1456
+ });
1457
+ * ```
1458
+ */
1459
+ createStatus(cacheKey: IntegrationTaskKey, initialStatus: InitialStatusUpdate): Promise<TriggerStatus>;
882
1460
  /** `io.backgroundFetch()` fetches data from a URL that can take longer that the serverless timeout. The actual `fetch` request is performed on the Trigger.dev platform, and the response is sent back to you.
883
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1461
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
884
1462
  * @param url The URL to fetch from.
885
1463
  * @param requestInit The options for the request
886
1464
  * @param retry The options for retrying the request if it fails
@@ -890,13 +1468,13 @@ declare class IO {
890
1468
  * - Ranges: 500-599
891
1469
  * - Wildcards: 2xx, 3xx, 4xx, 5xx
892
1470
  */
893
- backgroundFetch<TResponseData>(key: string | any[], url: string, requestInit?: FetchRequestInit, retry?: FetchRetryOptions): Promise<TResponseData>;
1471
+ backgroundFetch<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, retry?: FetchRetryOptions): Promise<TResponseData>;
894
1472
  /** `io.sendEvent()` allows you to send an event from inside a Job run. The sent even will trigger any Jobs that are listening for that event (based on the name).
895
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1473
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
896
1474
  * @param event The event to send. The event name must match the name of the event that your Jobs are listening for.
897
1475
  * @param options Options for sending the event.
898
1476
  */
899
- sendEvent(key: string | any[], event: SendEvent, options?: SendEventOptions): Promise<{
1477
+ sendEvent(cacheKey: string | any[], event: SendEvent, options?: SendEventOptions): Promise<{
900
1478
  id: string;
901
1479
  name: string;
902
1480
  payload: ((string | number | boolean | {
@@ -910,24 +1488,24 @@ declare class IO {
910
1488
  deliveredAt?: Date | null | undefined;
911
1489
  cancelledAt?: Date | null | undefined;
912
1490
  }>;
913
- getEvent(key: string | any[], id: string): Promise<{
1491
+ getEvent(cacheKey: string | any[], id: string): Promise<{
914
1492
  id: string;
915
1493
  name: string;
916
- createdAt: Date;
917
1494
  updatedAt: Date;
918
1495
  runs: {
919
1496
  id: string;
920
- status: "PENDING" | "CANCELED" | "SUCCESS" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "FAILURE" | "TIMED_OUT" | "ABORTED";
1497
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
921
1498
  startedAt?: Date | null | undefined;
922
1499
  completedAt?: Date | null | undefined;
923
1500
  }[];
1501
+ createdAt: Date;
924
1502
  }>;
925
1503
  /** `io.cancelEvent()` allows you to cancel an event that was previously sent with `io.sendEvent()`. This will prevent any Jobs from running that are listening for that event if the event was sent with a delay
926
- * @param key
1504
+ * @param cacheKey
927
1505
  * @param eventId
928
1506
  * @returns
929
1507
  */
930
- cancelEvent(key: string | any[], eventId: string): Promise<{
1508
+ cancelEvent(cacheKey: string | any[], eventId: string): Promise<{
931
1509
  id: string;
932
1510
  name: string;
933
1511
  payload: ((string | number | boolean | {
@@ -941,97 +1519,114 @@ declare class IO {
941
1519
  deliveredAt?: Date | null | undefined;
942
1520
  cancelledAt?: Date | null | undefined;
943
1521
  }>;
944
- updateSource(key: string | any[], options: {
1522
+ updateSource(cacheKey: string | any[], options: {
945
1523
  key: string;
946
1524
  } & UpdateTriggerSourceBodyV2): Promise<{
947
1525
  id: string;
948
1526
  key: string;
949
1527
  }>;
950
1528
  /** `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.
951
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1529
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
952
1530
  * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
953
1531
  * @param id A unique id for the interval. This is used to identify and unregister the interval later.
954
1532
  * @param options The options for the interval.
955
1533
  * @returns A promise that has information about the interval.
1534
+ * @deprecated Use `DynamicSchedule.register` instead.
956
1535
  */
957
- registerInterval(key: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: IntervalOptions): Promise<{
1536
+ registerInterval(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: IntervalOptions): Promise<{
958
1537
  id: string;
959
1538
  schedule: {
960
1539
  options: {
961
1540
  cron: string;
962
1541
  };
963
1542
  type: "cron";
1543
+ accountId?: string | undefined;
964
1544
  metadata?: any;
965
1545
  } | {
966
1546
  options: {
967
1547
  seconds: number;
968
1548
  };
969
1549
  type: "interval";
1550
+ accountId?: string | undefined;
970
1551
  metadata?: any;
971
1552
  };
972
1553
  active: boolean;
973
1554
  metadata?: any;
974
1555
  }>;
975
1556
  /** `io.unregisterInterval()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerInterval()`.
976
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1557
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
977
1558
  * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
978
1559
  * @param id A unique id for the interval. This is used to identify and unregister the interval later.
1560
+ * @deprecated Use `DynamicSchedule.unregister` instead.
979
1561
  */
980
- unregisterInterval(key: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
1562
+ unregisterInterval(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
981
1563
  ok: boolean;
982
1564
  }>;
983
1565
  /** `io.registerCron()` allows you to register a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that will trigger any jobs it's attached to on a regular CRON schedule.
984
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1566
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
985
1567
  * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
986
1568
  * @param id A unique id for the schedule. This is used to identify and unregister the schedule later.
987
1569
  * @param options The options for the CRON schedule.
1570
+ * @deprecated Use `DynamicSchedule.register` instead.
988
1571
  */
989
- registerCron(key: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: CronOptions): Promise<{
1572
+ registerCron(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string, options: CronOptions): Promise<{
990
1573
  id: string;
991
1574
  schedule: {
992
1575
  options: {
993
1576
  cron: string;
994
1577
  };
995
1578
  type: "cron";
1579
+ accountId?: string | undefined;
996
1580
  metadata?: any;
997
1581
  } | {
998
1582
  options: {
999
1583
  seconds: number;
1000
1584
  };
1001
1585
  type: "interval";
1586
+ accountId?: string | undefined;
1002
1587
  metadata?: any;
1003
1588
  };
1004
1589
  active: boolean;
1005
1590
  metadata?: any;
1006
1591
  }>;
1007
1592
  /** `io.unregisterCron()` allows you to unregister a [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) that was previously registered with `io.registerCron()`.
1008
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1593
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1009
1594
  * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to unregister a schedule on.
1010
1595
  * @param id A unique id for the interval. This is used to identify and unregister the interval later.
1596
+ * @deprecated Use `DynamicSchedule.unregister` instead.
1011
1597
  */
1012
- unregisterCron(key: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
1598
+ unregisterCron(cacheKey: string | any[], dynamicSchedule: DynamicSchedule, id: string): Promise<{
1013
1599
  ok: boolean;
1014
1600
  }>;
1015
1601
  /** `io.registerTrigger()` allows you to register a [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) with the specified trigger params.
1016
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1602
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1017
1603
  * @param trigger The [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) to register.
1018
1604
  * @param id A unique id for the trigger. This is used to identify and unregister the trigger later.
1019
1605
  * @param params The params for the trigger.
1606
+ * @deprecated Use `DynamicTrigger.register` instead.
1020
1607
  */
1021
- registerTrigger<TTrigger extends DynamicTrigger<EventSpecification<any>, ExternalSource<any, any, any>>>(key: string | any[], trigger: TTrigger, id: string, params: ExternalSourceParams<TTrigger["source"]>): Promise<{
1608
+ registerTrigger<TTrigger extends DynamicTrigger<EventSpecification<any>, ExternalSource<any, any, any>>>(cacheKey: string | any[], trigger: TTrigger, id: string, params: ExternalSourceParams<TTrigger["source"]>): Promise<{
1022
1609
  id: string;
1023
1610
  key: string;
1024
1611
  } | undefined>;
1025
- getAuth(key: string | any[], clientId?: string): Promise<ConnectionAuth | undefined>;
1612
+ getAuth(cacheKey: string | any[], clientId?: string): Promise<ConnectionAuth | undefined>;
1026
1613
  /** `io.runTask()` allows you to run a [Task](https://trigger.dev/docs/documentation/concepts/tasks) from inside a Job run. A Task is a resumable unit of a Run that can be retried, resumed and is logged. [Integrations](https://trigger.dev/docs/integrations) use Tasks internally to perform their actions.
1027
1614
  *
1028
- * @param key Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1615
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1029
1616
  * @param callback The callback that will be called when the Task is run. The callback receives the Task and the IO as parameters.
1030
1617
  * @param options The options of how you'd like to run and log the Task.
1031
1618
  * @param onError The callback that will be called when the Task fails. The callback receives the error, the Task and the IO as parameters. If you wish to retry then return an object with a `retryAt` property.
1032
1619
  * @returns A Promise that resolves with the returned value of the callback.
1033
1620
  */
1034
- runTask<T extends Json<T> | void>(key: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions, onError?: RunTaskErrorCallback): Promise<T>;
1621
+ runTask<T extends Json<T> | void>(cacheKey: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions, onError?: RunTaskErrorCallback): Promise<T>;
1622
+ /**
1623
+ * `io.yield()` allows you to yield execution of the current run and resume it in a new function execution. Similar to `io.wait()` but does not create a task and resumes execution immediately.
1624
+ */
1625
+ yield(cacheKey: string): void;
1626
+ /**
1627
+ * `io.brb()` is an alias of `io.yield()`
1628
+ */
1629
+ brb: (cacheKey: string) => void;
1035
1630
  /** `io.try()` allows you to run Tasks and catch any errors that are thrown, it's similar to a normal `try/catch` block but works with [io.runTask()](/sdk/io/runtask).
1036
1631
  * A regular `try/catch` block on its own won't work as expected with Tasks. Internally `runTask()` throws some special errors to control flow execution. This is necessary to deal with resumability, serverless timeouts, and retrying Tasks.
1037
1632
  * @param tryCallback The code you wish to run
@@ -1129,8 +1724,8 @@ declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegratio
1129
1724
  get name(): string;
1130
1725
  get trigger(): TTrigger;
1131
1726
  get version(): string;
1132
- get integrations(): Record<string, IntegrationConfig>;
1133
1727
  get logLevel(): LogLevel | undefined;
1728
+ get integrations(): Record<string, IntegrationConfig>;
1134
1729
  toJSON(): JobMetadata;
1135
1730
  }
1136
1731
 
@@ -1155,7 +1750,7 @@ type TriggerOptions<TEvent> = {
1155
1750
  /** A [Zod](https://trigger.dev/docs/documentation/guides/zod) schema that defines the shape of the event payload.
1156
1751
  * The default is `z.any()` which is `any`.
1157
1752
  * */
1158
- schema?: z.Schema<TEvent>;
1753
+ schema?: SchemaParser<TEvent>;
1159
1754
  /** You can use this to filter events based on the source. */
1160
1755
  source?: string;
1161
1756
  /** Used to filter which events trigger the Job
@@ -1206,8 +1801,8 @@ declare class MissingConnectionNotification implements Trigger<MissingConnection
1206
1801
  id: string;
1207
1802
  scopes: string[];
1208
1803
  title: string;
1209
- createdAt: Date;
1210
1804
  updatedAt: Date;
1805
+ createdAt: Date;
1211
1806
  };
1212
1807
  authorizationUrl: string;
1213
1808
  } | {
@@ -1221,8 +1816,8 @@ declare class MissingConnectionNotification implements Trigger<MissingConnection
1221
1816
  id: string;
1222
1817
  scopes: string[];
1223
1818
  title: string;
1224
- createdAt: Date;
1225
1819
  updatedAt: Date;
1820
+ createdAt: Date;
1226
1821
  };
1227
1822
  authorizationUrl: string;
1228
1823
  };
@@ -1251,8 +1846,8 @@ declare class MissingConnectionResolvedNotification implements Trigger<MissingCo
1251
1846
  id: string;
1252
1847
  scopes: string[];
1253
1848
  title: string;
1254
- createdAt: Date;
1255
1849
  updatedAt: Date;
1850
+ createdAt: Date;
1256
1851
  integrationIdentifier: string;
1257
1852
  integrationAuthMethod: string;
1258
1853
  };
@@ -1268,8 +1863,8 @@ declare class MissingConnectionResolvedNotification implements Trigger<MissingCo
1268
1863
  id: string;
1269
1864
  scopes: string[];
1270
1865
  title: string;
1271
- createdAt: Date;
1272
1866
  updatedAt: Date;
1867
+ createdAt: Date;
1273
1868
  integrationIdentifier: string;
1274
1869
  integrationAuthMethod: string;
1275
1870
  };
@@ -1299,13 +1894,38 @@ declare class CanceledWithTaskError {
1299
1894
  task: ServerTask;
1300
1895
  constructor(task: ServerTask);
1301
1896
  }
1897
+ declare class YieldExecutionError {
1898
+ key: string;
1899
+ constructor(key: string);
1900
+ }
1901
+ declare class AutoYieldExecutionError {
1902
+ location: string;
1903
+ timeRemaining: number;
1904
+ timeElapsed: number;
1905
+ constructor(location: string, timeRemaining: number, timeElapsed: number);
1906
+ }
1907
+ declare class AutoYieldWithCompletedTaskExecutionError {
1908
+ id: string;
1909
+ properties: DisplayProperty[] | undefined;
1910
+ output: any;
1911
+ data: {
1912
+ location: string;
1913
+ timeRemaining: number;
1914
+ timeElapsed: number;
1915
+ };
1916
+ constructor(id: string, properties: DisplayProperty[] | undefined, output: any, data: {
1917
+ location: string;
1918
+ timeRemaining: number;
1919
+ timeElapsed: number;
1920
+ });
1921
+ }
1302
1922
  /** Use this function if you're using a `try/catch` block to catch errors.
1303
1923
  * It checks if a thrown error is a special internal error that you should ignore.
1304
1924
  * If this returns `true` then you must rethrow the error: `throw err;`
1305
1925
  * @param err The error to check
1306
1926
  * @returns `true` if the error is a Trigger Error, `false` otherwise.
1307
1927
  */
1308
- declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError;
1928
+ declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError;
1309
1929
 
1310
1930
  declare const retry: {
1311
1931
  readonly standardBackoff: {
@@ -1322,4 +1942,4 @@ type Task = ServerTask;
1322
1942
  type SentEvent = ApiEventLog;
1323
1943
  declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
1324
1944
 
1325
- export { CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventSpecification, EventSpecificationExample, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOTask, IOWithIntegrations, IntegrationTaskKey, IntervalTrigger, Job, JobIO, JobOptions, JobPayload, Json, MissingConnectionNotification, MissingConnectionResolvedNotification, PreprocessResults, RunTaskErrorCallback, SentEvent, Task, TaskLogger, Trigger, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerOptionRecord, TriggerPayload, TriggerPreprocessContext, cronTrigger, eventTrigger, intervalTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry };
1945
+ export { AuthResolverResult, CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventSpecification, EventSpecificationExample, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOStats, IOTask, IOWithIntegrations, IntegrationTaskKey, IntervalTrigger, Job, JobIO, JobOptions, JobPayload, Json, MissingConnectionNotification, MissingConnectionResolvedNotification, PreprocessResults, RunTaskErrorCallback, SchemaParser, SchemaParserIssue, SchemaParserResult, SentEvent, Task, TaskLogger, Trigger, TriggerAuthResolver, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerOptionRecord, TriggerPayload, TriggerPreprocessContext, cronTrigger, eventTrigger, intervalTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry };