@trigger.dev/sdk 0.0.0-prerelease-20231024083739 → 0.0.0-prerelease-20231208101523

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,8 +1,39 @@
1
1
  import * as _trigger_dev_core 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
- export { ConnectionAuth, DisplayProperty, EventFilter, Logger, NormalizedRequest, OverridableRunTaskOptions, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
2
+ import { AsyncMap, KeyValueStoreResponseBody, RunTaskBodyInput, CompleteTaskBodyV2Input, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, UpdateWebhookBody, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, InvokeOptions, EphemeralEventDispatcherRequestBody, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, SuccessfulRunNotification, FailedRunNotification, HttpEndpointMetadata, RequestFilter, Prettify, HandleTriggerSource, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, RegisterWebhookSource, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, FetchTimeoutOptions, FetchPollOperation, RunTaskOptions, IntegrationMetadata, IntegrationConfig, JobMetadata, RunNotification, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
3
+ export { ConnectionAuth, DisplayProperty, EventFilter, NormalizedRequest, OverridableRunTaskOptions, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
4
+ import { LogLevel, Logger } from '@trigger.dev/core-backend';
5
+ export { Logger } from '@trigger.dev/core-backend';
4
6
  import * as zod from 'zod';
5
- import { z } from 'zod';
7
+ import { z, ZodType, TypeOf } from 'zod';
8
+ import { Buffer } from 'buffer';
9
+ import { BinaryToTextEncoding, BinaryLike, KeyObject } from 'crypto';
10
+
11
+ type ConcurrencyLimitOptions = {
12
+ id: string;
13
+ limit: number;
14
+ };
15
+ declare class ConcurrencyLimit {
16
+ private options;
17
+ constructor(options: ConcurrencyLimitOptions);
18
+ get id(): string;
19
+ get limit(): number;
20
+ }
21
+
22
+ type QueryKeyValueStoreFunction = (action: "DELETE" | "GET" | "HAS" | "SET", data: {
23
+ key: string;
24
+ value?: string;
25
+ }) => Promise<KeyValueStoreResponseBody>;
26
+ declare class KeyValueStoreClient implements AsyncMap {
27
+ #private;
28
+ private queryStore;
29
+ private type;
30
+ private namespace;
31
+ constructor(queryStore: QueryKeyValueStoreFunction, type?: string | null, namespace?: string);
32
+ delete(key: string): Promise<boolean>;
33
+ get<T extends Json<T>>(key: string): Promise<T | undefined>;
34
+ has(key: string): Promise<boolean>;
35
+ set<T extends Json<T>>(key: string, value: T): Promise<T>;
36
+ }
6
37
 
7
38
  type ApiClientOptions = {
8
39
  apiKey?: string;
@@ -40,29 +71,36 @@ declare class ApiClient {
40
71
  label: z.ZodString;
41
72
  text: z.ZodString;
42
73
  url: z.ZodOptional<z.ZodString>;
74
+ imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
75
  }, "strip", z.ZodTypeAny, {
44
76
  label: string;
45
77
  text: string;
46
78
  url?: string | undefined;
79
+ imageUrl?: string[] | undefined;
47
80
  }, {
48
81
  label: string;
49
82
  text: string;
50
83
  url?: string | undefined;
84
+ imageUrl?: string[] | undefined;
51
85
  }>, "many">>>;
52
86
  outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
53
87
  label: z.ZodString;
54
88
  text: z.ZodString;
55
89
  url: z.ZodOptional<z.ZodString>;
90
+ imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
56
91
  }, "strip", z.ZodTypeAny, {
57
92
  label: string;
58
93
  text: string;
59
94
  url?: string | undefined;
95
+ imageUrl?: string[] | undefined;
60
96
  }, {
61
97
  label: string;
62
98
  text: string;
63
99
  url?: string | undefined;
100
+ imageUrl?: string[] | undefined;
64
101
  }>, "many">>>;
65
102
  output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
103
+ context: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
66
104
  error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
67
105
  parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
106
  style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -77,6 +115,7 @@ declare class ApiClient {
77
115
  }>>>;
78
116
  operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
79
117
  callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
118
+ childExecutionMode: z.ZodNullable<z.ZodOptional<z.ZodEnum<["SEQUENTIAL", "PARALLEL"]>>>;
80
119
  idempotencyKey: z.ZodString;
81
120
  attempts: z.ZodNumber;
82
121
  forceYield: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
@@ -97,13 +136,16 @@ declare class ApiClient {
97
136
  label: string;
98
137
  text: string;
99
138
  url?: string | undefined;
139
+ imageUrl?: string[] | undefined;
100
140
  }[] | null | undefined;
101
141
  outputProperties?: {
102
142
  label: string;
103
143
  text: string;
104
144
  url?: string | undefined;
145
+ imageUrl?: string[] | undefined;
105
146
  }[] | null | undefined;
106
147
  output?: _trigger_dev_core.DeserializedJson | undefined;
148
+ context?: _trigger_dev_core.DeserializedJson | undefined;
107
149
  error?: string | null | undefined;
108
150
  parentId?: string | null | undefined;
109
151
  style?: {
@@ -112,6 +154,7 @@ declare class ApiClient {
112
154
  } | null | undefined;
113
155
  operation?: string | null | undefined;
114
156
  callbackUrl?: string | null | undefined;
157
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
115
158
  forceYield?: boolean | null | undefined;
116
159
  }, {
117
160
  id: string;
@@ -130,13 +173,16 @@ declare class ApiClient {
130
173
  label: string;
131
174
  text: string;
132
175
  url?: string | undefined;
176
+ imageUrl?: string[] | undefined;
133
177
  }[] | null | undefined;
134
178
  outputProperties?: {
135
179
  label: string;
136
180
  text: string;
137
181
  url?: string | undefined;
182
+ imageUrl?: string[] | undefined;
138
183
  }[] | null | undefined;
139
184
  output?: _trigger_dev_core.DeserializedJson | undefined;
185
+ context?: _trigger_dev_core.DeserializedJson | undefined;
140
186
  error?: string | null | undefined;
141
187
  parentId?: string | null | undefined;
142
188
  style?: {
@@ -145,6 +191,7 @@ declare class ApiClient {
145
191
  } | null | undefined;
146
192
  operation?: string | null | undefined;
147
193
  callbackUrl?: string | null | undefined;
194
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
148
195
  forceYield?: boolean | null | undefined;
149
196
  }>;
150
197
  cachedTasks: z.ZodOptional<z.ZodObject<{
@@ -210,13 +257,16 @@ declare class ApiClient {
210
257
  label: string;
211
258
  text: string;
212
259
  url?: string | undefined;
260
+ imageUrl?: string[] | undefined;
213
261
  }[] | null | undefined;
214
262
  outputProperties?: {
215
263
  label: string;
216
264
  text: string;
217
265
  url?: string | undefined;
266
+ imageUrl?: string[] | undefined;
218
267
  }[] | null | undefined;
219
268
  output?: _trigger_dev_core.DeserializedJson | undefined;
269
+ context?: _trigger_dev_core.DeserializedJson | undefined;
220
270
  error?: string | null | undefined;
221
271
  parentId?: string | null | undefined;
222
272
  style?: {
@@ -225,6 +275,7 @@ declare class ApiClient {
225
275
  } | null | undefined;
226
276
  operation?: string | null | undefined;
227
277
  callbackUrl?: string | null | undefined;
278
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
228
279
  forceYield?: boolean | null | undefined;
229
280
  };
230
281
  cachedTasks?: {
@@ -256,13 +307,16 @@ declare class ApiClient {
256
307
  label: string;
257
308
  text: string;
258
309
  url?: string | undefined;
310
+ imageUrl?: string[] | undefined;
259
311
  }[] | null | undefined;
260
312
  outputProperties?: {
261
313
  label: string;
262
314
  text: string;
263
315
  url?: string | undefined;
316
+ imageUrl?: string[] | undefined;
264
317
  }[] | null | undefined;
265
318
  output?: _trigger_dev_core.DeserializedJson | undefined;
319
+ context?: _trigger_dev_core.DeserializedJson | undefined;
266
320
  error?: string | null | undefined;
267
321
  parentId?: string | null | undefined;
268
322
  style?: {
@@ -271,6 +325,7 @@ declare class ApiClient {
271
325
  } | null | undefined;
272
326
  operation?: string | null | undefined;
273
327
  callbackUrl?: string | null | undefined;
328
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
274
329
  forceYield?: boolean | null | undefined;
275
330
  };
276
331
  cachedTasks?: {
@@ -300,29 +355,36 @@ declare class ApiClient {
300
355
  label: z.ZodString;
301
356
  text: z.ZodString;
302
357
  url: z.ZodOptional<z.ZodString>;
358
+ imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
303
359
  }, "strip", z.ZodTypeAny, {
304
360
  label: string;
305
361
  text: string;
306
362
  url?: string | undefined;
363
+ imageUrl?: string[] | undefined;
307
364
  }, {
308
365
  label: string;
309
366
  text: string;
310
367
  url?: string | undefined;
368
+ imageUrl?: string[] | undefined;
311
369
  }>, "many">>>;
312
370
  outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
313
371
  label: z.ZodString;
314
372
  text: z.ZodString;
315
373
  url: z.ZodOptional<z.ZodString>;
374
+ imageUrl: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
316
375
  }, "strip", z.ZodTypeAny, {
317
376
  label: string;
318
377
  text: string;
319
378
  url?: string | undefined;
379
+ imageUrl?: string[] | undefined;
320
380
  }, {
321
381
  label: string;
322
382
  text: string;
323
383
  url?: string | undefined;
384
+ imageUrl?: string[] | undefined;
324
385
  }>, "many">>>;
325
386
  output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
387
+ context: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
326
388
  error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
327
389
  parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
328
390
  style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
@@ -337,6 +399,7 @@ declare class ApiClient {
337
399
  }>>>;
338
400
  operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
339
401
  callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
402
+ childExecutionMode: z.ZodNullable<z.ZodOptional<z.ZodEnum<["SEQUENTIAL", "PARALLEL"]>>>;
340
403
  idempotencyKey: z.ZodString;
341
404
  attempts: z.ZodNumber;
342
405
  forceYield: z.ZodNullable<z.ZodOptional<z.ZodBoolean>>;
@@ -357,13 +420,16 @@ declare class ApiClient {
357
420
  label: string;
358
421
  text: string;
359
422
  url?: string | undefined;
423
+ imageUrl?: string[] | undefined;
360
424
  }[] | null | undefined;
361
425
  outputProperties?: {
362
426
  label: string;
363
427
  text: string;
364
428
  url?: string | undefined;
429
+ imageUrl?: string[] | undefined;
365
430
  }[] | null | undefined;
366
431
  output?: _trigger_dev_core.DeserializedJson | undefined;
432
+ context?: _trigger_dev_core.DeserializedJson | undefined;
367
433
  error?: string | null | undefined;
368
434
  parentId?: string | null | undefined;
369
435
  style?: {
@@ -372,6 +438,7 @@ declare class ApiClient {
372
438
  } | null | undefined;
373
439
  operation?: string | null | undefined;
374
440
  callbackUrl?: string | null | undefined;
441
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
375
442
  forceYield?: boolean | null | undefined;
376
443
  }, {
377
444
  id: string;
@@ -390,13 +457,16 @@ declare class ApiClient {
390
457
  label: string;
391
458
  text: string;
392
459
  url?: string | undefined;
460
+ imageUrl?: string[] | undefined;
393
461
  }[] | null | undefined;
394
462
  outputProperties?: {
395
463
  label: string;
396
464
  text: string;
397
465
  url?: string | undefined;
466
+ imageUrl?: string[] | undefined;
398
467
  }[] | null | undefined;
399
468
  output?: _trigger_dev_core.DeserializedJson | undefined;
469
+ context?: _trigger_dev_core.DeserializedJson | undefined;
400
470
  error?: string | null | undefined;
401
471
  parentId?: string | null | undefined;
402
472
  style?: {
@@ -405,9 +475,10 @@ declare class ApiClient {
405
475
  } | null | undefined;
406
476
  operation?: string | null | undefined;
407
477
  callbackUrl?: string | null | undefined;
478
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
408
479
  forceYield?: boolean | null | undefined;
409
480
  }>>>;
410
- completeTask(runId: string, id: string, task: CompleteTaskBodyInput): Promise<{
481
+ completeTask(runId: string, id: string, task: CompleteTaskBodyV2Input): Promise<{
411
482
  id: string;
412
483
  name: string;
413
484
  noop: boolean;
@@ -424,13 +495,16 @@ declare class ApiClient {
424
495
  label: string;
425
496
  text: string;
426
497
  url?: string | undefined;
498
+ imageUrl?: string[] | undefined;
427
499
  }[] | null | undefined;
428
500
  outputProperties?: {
429
501
  label: string;
430
502
  text: string;
431
503
  url?: string | undefined;
504
+ imageUrl?: string[] | undefined;
432
505
  }[] | null | undefined;
433
506
  output?: _trigger_dev_core.DeserializedJson | undefined;
507
+ context?: _trigger_dev_core.DeserializedJson | undefined;
434
508
  error?: string | null | undefined;
435
509
  parentId?: string | null | undefined;
436
510
  style?: {
@@ -439,6 +513,7 @@ declare class ApiClient {
439
513
  } | null | undefined;
440
514
  operation?: string | null | undefined;
441
515
  callbackUrl?: string | null | undefined;
516
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
442
517
  forceYield?: boolean | null | undefined;
443
518
  }>;
444
519
  failTask(runId: string, id: string, body: FailTaskBodyInput): Promise<{
@@ -458,13 +533,16 @@ declare class ApiClient {
458
533
  label: string;
459
534
  text: string;
460
535
  url?: string | undefined;
536
+ imageUrl?: string[] | undefined;
461
537
  }[] | null | undefined;
462
538
  outputProperties?: {
463
539
  label: string;
464
540
  text: string;
465
541
  url?: string | undefined;
542
+ imageUrl?: string[] | undefined;
466
543
  }[] | null | undefined;
467
544
  output?: _trigger_dev_core.DeserializedJson | undefined;
545
+ context?: _trigger_dev_core.DeserializedJson | undefined;
468
546
  error?: string | null | undefined;
469
547
  parentId?: string | null | undefined;
470
548
  style?: {
@@ -473,6 +551,7 @@ declare class ApiClient {
473
551
  } | null | undefined;
474
552
  operation?: string | null | undefined;
475
553
  callbackUrl?: string | null | undefined;
554
+ childExecutionMode?: "SEQUENTIAL" | "PARALLEL" | null | undefined;
476
555
  forceYield?: boolean | null | undefined;
477
556
  }>;
478
557
  sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
@@ -489,6 +568,20 @@ declare class ApiClient {
489
568
  deliveredAt?: Date | null | undefined;
490
569
  cancelledAt?: Date | null | undefined;
491
570
  }>;
571
+ sendEvents(events: SendEvent[], options?: SendEventOptions): Promise<{
572
+ id: string;
573
+ name: string;
574
+ payload: ((string | number | boolean | {
575
+ [key: string]: _trigger_dev_core.DeserializedJson;
576
+ } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
577
+ [key: string]: _trigger_dev_core.DeserializedJson;
578
+ } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
579
+ timestamp: Date;
580
+ context?: _trigger_dev_core.DeserializedJson | undefined;
581
+ deliverAt?: Date | null | undefined;
582
+ deliveredAt?: Date | null | undefined;
583
+ cancelledAt?: Date | null | undefined;
584
+ }[]>;
492
585
  cancelEvent(eventId: string): Promise<{
493
586
  id: string;
494
587
  name: string;
@@ -503,6 +596,10 @@ declare class ApiClient {
503
596
  deliveredAt?: Date | null | undefined;
504
597
  cancelledAt?: Date | null | undefined;
505
598
  }>;
599
+ cancelRunsForEvent(eventId: string): Promise<{
600
+ cancelledRunIds: string[];
601
+ failedToCancelRunIds: string[];
602
+ }>;
506
603
  updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
507
604
  label: string;
508
605
  key: string;
@@ -515,7 +612,8 @@ declare class ApiClient {
515
612
  state?: "loading" | "success" | "failure" | undefined;
516
613
  }>;
517
614
  updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
518
- registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2): Promise<RegisterSourceEventV2>;
615
+ updateWebhook(key: string, webhookData: UpdateWebhookBody): Promise<TriggerSource>;
616
+ registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<RegisterSourceEventV2>;
519
617
  registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
520
618
  id: string;
521
619
  schedule: {
@@ -551,7 +649,7 @@ declare class ApiClient {
551
649
  updatedAt: Date;
552
650
  runs: {
553
651
  id: string;
554
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
652
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
555
653
  startedAt?: Date | null | undefined;
556
654
  completedAt?: Date | null | undefined;
557
655
  }[];
@@ -561,7 +659,7 @@ declare class ApiClient {
561
659
  id: string;
562
660
  startedAt: Date | null;
563
661
  completedAt: Date | null;
564
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
662
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
565
663
  updatedAt: Date | null;
566
664
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
567
665
  statuses: {
@@ -582,7 +680,7 @@ declare class ApiClient {
582
680
  id: string;
583
681
  startedAt: Date | null;
584
682
  completedAt: Date | null;
585
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
683
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
586
684
  updatedAt: Date | null;
587
685
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
588
686
  statuses: {
@@ -613,7 +711,7 @@ declare class ApiClient {
613
711
  }[];
614
712
  run: {
615
713
  id: string;
616
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
714
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
617
715
  output?: any;
618
716
  };
619
717
  }>;
@@ -622,11 +720,18 @@ declare class ApiClient {
622
720
  id: string;
623
721
  startedAt: Date | null;
624
722
  completedAt: Date | null;
625
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
723
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
626
724
  updatedAt: Date | null;
627
725
  }[];
628
726
  nextCursor?: string | undefined;
629
727
  }>;
728
+ invokeJob(jobId: string, payload: any, options?: InvokeOptions): Promise<{
729
+ id: string;
730
+ }>;
731
+ createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
732
+ id: string;
733
+ }>;
734
+ get store(): KeyValueStoreClient;
630
735
  }
631
736
  type VersionedResponseBodyMap = {
632
737
  [key: string]: z.ZodTypeAny;
@@ -641,6 +746,65 @@ type VersionedResponseBody<TVersions extends VersionedResponseBodyMap, TUnversio
641
746
  body: z.infer<TUnversioned>;
642
747
  };
643
748
 
749
+ declare class TriggerStatus {
750
+ private id;
751
+ private io;
752
+ constructor(id: string, io: IO);
753
+ update(key: IntegrationTaskKey, status: StatusUpdate): Promise<{
754
+ label: string;
755
+ key: string;
756
+ history: {
757
+ label?: string | undefined;
758
+ state?: "loading" | "success" | "failure" | undefined;
759
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
760
+ }[];
761
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
762
+ state?: "loading" | "success" | "failure" | undefined;
763
+ }>;
764
+ }
765
+
766
+ type EventMap = {
767
+ [key: string]: (...args: any[]) => void
768
+ }
769
+
770
+ /**
771
+ * Type-safe event emitter.
772
+ *
773
+ * Use it like this:
774
+ *
775
+ * ```typescript
776
+ * type MyEvents = {
777
+ * error: (error: Error) => void;
778
+ * message: (from: string, content: string) => void;
779
+ * }
780
+ *
781
+ * const myEmitter = new EventEmitter() as TypedEmitter<MyEvents>;
782
+ *
783
+ * myEmitter.emit("error", "x") // <- Will catch this type error;
784
+ * ```
785
+ */
786
+ interface TypedEventEmitter<Events extends EventMap> {
787
+ addListener<E extends keyof Events> (event: E, listener: Events[E]): this
788
+ on<E extends keyof Events> (event: E, listener: Events[E]): this
789
+ once<E extends keyof Events> (event: E, listener: Events[E]): this
790
+ prependListener<E extends keyof Events> (event: E, listener: Events[E]): this
791
+ prependOnceListener<E extends keyof Events> (event: E, listener: Events[E]): this
792
+
793
+ off<E extends keyof Events>(event: E, listener: Events[E]): this
794
+ removeAllListeners<E extends keyof Events> (event?: E): this
795
+ removeListener<E extends keyof Events> (event: E, listener: Events[E]): this
796
+
797
+ emit<E extends keyof Events> (event: E, ...args: Parameters<Events[E]>): boolean
798
+ // The sloppy `eventNames()` return type is to mitigate type incompatibilities - see #5
799
+ eventNames (): (keyof Events | string | symbol)[]
800
+ rawListeners<E extends keyof Events> (event: E): Events[E][]
801
+ listeners<E extends keyof Events> (event: E): Events[E][]
802
+ listenerCount<E extends keyof Events> (event: E): number
803
+
804
+ getMaxListeners (): number
805
+ setMaxListeners (maxListeners: number): this
806
+ }
807
+
644
808
  interface TriggerContext {
645
809
  /** Job metadata */
646
810
  job: {
@@ -659,6 +823,12 @@ interface TriggerContext {
659
823
  id: string;
660
824
  title: string;
661
825
  };
826
+ /** Project metadata */
827
+ project: {
828
+ slug: string;
829
+ id: string;
830
+ name: string;
831
+ };
662
832
  /** Run metadata */
663
833
  run: {
664
834
  id: string;
@@ -725,20 +895,45 @@ type PreprocessResults = {
725
895
  properties: DisplayProperty[];
726
896
  };
727
897
  type TriggerEventType<TTrigger extends Trigger<any>> = TTrigger extends Trigger<infer TEventSpec> ? ReturnType<TEventSpec["parsePayload"]> : never;
898
+ type TriggerInvokeType<TTrigger extends Trigger<any>> = TTrigger extends Trigger<infer TEventSpec> ? TEventSpec["parseInvokePayload"] extends (payload: unknown) => infer TInvoke ? TInvoke : any : never;
899
+ type VerifyResult = {
900
+ success: true;
901
+ } | {
902
+ success: false;
903
+ reason?: string;
904
+ };
728
905
  interface Trigger<TEventSpec extends EventSpecification<any>> {
729
906
  event: TEventSpec;
730
907
  toJSON(): TriggerMetadata;
731
908
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
732
909
  preprocessRuns: boolean;
910
+ verifyPayload: (payload: ReturnType<TEventSpec["parsePayload"]>) => Promise<VerifyResult>;
733
911
  }
734
912
  type TriggerPayload<TTrigger> = TTrigger extends Trigger<EventSpecification<infer TEvent>> ? TEvent : never;
735
- type EventSpecificationExample = {
913
+ declare const EventSpecificationExampleSchema: z.ZodObject<{
914
+ id: z.ZodString;
915
+ name: z.ZodString;
916
+ icon: z.ZodOptional<z.ZodString>;
917
+ payload: z.ZodAny;
918
+ }, "strip", z.ZodTypeAny, {
919
+ id: string;
920
+ name: string;
921
+ icon?: string | undefined;
922
+ payload?: any;
923
+ }, {
924
+ id: string;
925
+ name: string;
926
+ icon?: string | undefined;
927
+ payload?: any;
928
+ }>;
929
+ type EventSpecificationExample = z.infer<typeof EventSpecificationExampleSchema>;
930
+ type TypedEventSpecificationExample<TEvent> = {
736
931
  id: string;
737
932
  name: string;
738
933
  icon?: string;
739
- payload: any;
934
+ payload: TEvent;
740
935
  };
741
- interface EventSpecification<TEvent extends any> {
936
+ interface EventSpecification<TEvent extends any, TInvoke extends any = TEvent> {
742
937
  name: string | string[];
743
938
  title: string;
744
939
  source: string;
@@ -748,6 +943,7 @@ interface EventSpecification<TEvent extends any> {
748
943
  examples?: Array<EventSpecificationExample>;
749
944
  filter?: EventFilter;
750
945
  parsePayload: (payload: unknown) => TEvent;
946
+ parseInvokePayload?: (payload: unknown) => TInvoke;
751
947
  runProperties?: (payload: TEvent) => DisplayProperty[];
752
948
  }
753
949
  type EventTypeFromSpecification<TEventSpec extends EventSpecification<any>> = TEventSpec extends EventSpecification<infer TEvent> ? TEvent : never;
@@ -767,6 +963,143 @@ type SchemaParserResult<T> = {
767
963
  type SchemaParser<T extends unknown = unknown> = {
768
964
  safeParse: (a: unknown) => SchemaParserResult<T>;
769
965
  };
966
+ type WaitForEventResult<TEvent> = {
967
+ id: string;
968
+ name: string;
969
+ source: string;
970
+ payload: TEvent;
971
+ timestamp: Date;
972
+ context?: any;
973
+ accountId?: string;
974
+ };
975
+ declare function waitForEventSchema(schema: z.ZodTypeAny): z.ZodObject<{
976
+ id: z.ZodString;
977
+ name: z.ZodString;
978
+ source: z.ZodString;
979
+ payload: z.ZodTypeAny;
980
+ timestamp: z.ZodDate;
981
+ context: z.ZodOptional<z.ZodAny>;
982
+ accountId: z.ZodOptional<z.ZodString>;
983
+ }, "strip", z.ZodTypeAny, {
984
+ id: string;
985
+ name: string;
986
+ timestamp: Date;
987
+ source: string;
988
+ payload?: any;
989
+ context?: any;
990
+ accountId?: string | undefined;
991
+ }, {
992
+ id: string;
993
+ name: string;
994
+ timestamp: Date;
995
+ source: string;
996
+ payload?: any;
997
+ context?: any;
998
+ accountId?: string | undefined;
999
+ }>;
1000
+ type NotificationEvents = {
1001
+ runSucceeeded: (notification: SuccessfulRunNotification<any>) => void;
1002
+ runFailed: (notification: FailedRunNotification) => void;
1003
+ };
1004
+ type NotificationsEventEmitter = TypedEventEmitter<NotificationEvents>;
1005
+
1006
+ type HttpEndpointOptions<TEventSpecification extends EventSpecification<any>> = {
1007
+ id: string;
1008
+ enabled?: boolean;
1009
+ event: TEventSpecification;
1010
+ respondWith?: RespondWith;
1011
+ verify: VerifyCallback;
1012
+ };
1013
+ type RequestOptions = {
1014
+ filter?: RequestFilter;
1015
+ };
1016
+ declare class HttpEndpoint<TEventSpecification extends EventSpecification<any>> {
1017
+ private readonly options;
1018
+ constructor(options: HttpEndpointOptions<TEventSpecification>);
1019
+ get id(): string;
1020
+ onRequest(options?: RequestOptions): HttpTrigger<EventSpecification<Request>>;
1021
+ toJSON(): HttpEndpointMetadata;
1022
+ }
1023
+ type TriggerOptions$1<TEventSpecification extends EventSpecification<any>> = {
1024
+ endpointId: string;
1025
+ event: TEventSpecification;
1026
+ filter?: EventFilter;
1027
+ verify: VerifyCallback;
1028
+ };
1029
+ declare class HttpTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
1030
+ private readonly options;
1031
+ constructor(options: TriggerOptions$1<TEventSpecification>);
1032
+ toJSON(): TriggerMetadata;
1033
+ get event(): TEventSpecification;
1034
+ attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1035
+ get preprocessRuns(): boolean;
1036
+ verifyPayload(payload: Request): Promise<VerifyResult>;
1037
+ }
1038
+ type RespondWith = {
1039
+ /** Only Requests that match this filter will cause the `handler` function to run.
1040
+ * For example, you can use this to only respond to `GET` Requests. */
1041
+ filter?: RequestFilter;
1042
+ /** If you set this to `true`, the Request that comes in won't go on to Trigger any Runs.
1043
+ * This is useful if you want to Respond to the Request, but don't want to Trigger any Runs. */
1044
+ skipTriggeringRuns?: boolean;
1045
+ /** This is a function that's called when a Request comes in.
1046
+ * It's passed the Request object, and expects you to return a Response object. */
1047
+ handler: (request: Request, verify: () => Promise<VerifyResult>) => Promise<Response>;
1048
+ };
1049
+ type VerifyCallback = (request: Request) => Promise<VerifyResult>;
1050
+ type EndpointOptions = {
1051
+ /** Used to uniquely identify the HTTP Endpoint inside your Project. */
1052
+ id: string;
1053
+ enabled?: boolean;
1054
+ /** Usually you would use the domain name of the service, e.g. `cal.com`. */
1055
+ source: string;
1056
+ /** An optional title, displayed in the dashboard. */
1057
+ title?: string;
1058
+ /** An optional icon name that's displayed in the dashboard.
1059
+ * Lots of company names are supported, e.g. `github`, `twilio`.
1060
+ * You can also reference the name of any [Tabler icon](https://tabler-icons.io/), e.g. `brand-google-maps`, `brand-twitch`. */
1061
+ icon?: string;
1062
+ /** Used to provide example payloads that are accepted by the job.
1063
+ * This will be available in the dashboard and can be used to trigger test runs. */
1064
+ examples?: EventSpecificationExample[];
1065
+ /** Properties that are displayed in the dashboard. */
1066
+ properties?: DisplayProperty[];
1067
+ /** This optional object allows you to immediately Respond to a Request. This is useful for some APIs where they do a `GET` Request when the webhook is first setup and expect a specific Response.
1068
+
1069
+ Only use this if you really need to Respond to the Request that comes in. Most of the time you don't. */
1070
+ respondWith?: RespondWith;
1071
+ /** This is compulsory, and is used to verify that the received webhook is authentic.
1072
+ * It's a function that expects you to return a result object like:
1073
+
1074
+ In 90% of cases, you'll want to use the `verifyRequestSignature` helper function we provide.
1075
+
1076
+ @example
1077
+ ```ts
1078
+ //if it's valid
1079
+ return { success: true }
1080
+ //if it's invalid, reason is optional
1081
+ return { success: false, reason: "No header" }
1082
+ ```
1083
+
1084
+ */
1085
+ verify: VerifyCallback;
1086
+ };
1087
+
1088
+ declare class KeyValueStore {
1089
+ #private;
1090
+ private apiClient;
1091
+ private type;
1092
+ private namespace;
1093
+ constructor(apiClient: ApiClient, type?: string | null, namespace?: string);
1094
+ delete(cacheKey: string | any[], key: string): Promise<boolean>;
1095
+ delete(key: string): Promise<boolean>;
1096
+ get<T extends Json<T> = any>(cacheKey: string | any[], key: string): Promise<T | undefined>;
1097
+ get<T extends Json<T> = any>(key: string): Promise<T | undefined>;
1098
+ has(cacheKey: string | any[], key: string): Promise<boolean>;
1099
+ has(key: string): Promise<boolean>;
1100
+ set<T extends Json<T>>(cacheKey: string | any[], key: string, value: T): Promise<T>;
1101
+ set<T extends Json<T>>(key: string, value: T): Promise<T>;
1102
+ }
770
1103
 
771
1104
  type HttpSourceEvent = {
772
1105
  url: string;
@@ -812,7 +1145,7 @@ type TriggerOptionsRecordWithEvent<TValue, TTriggerOptionDefinitions extends Rec
812
1145
  type TriggerOptionRecord<TValue, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
813
1146
  [K in keyof TTriggerOptionDefinitions]: TValue;
814
1147
  };
815
- type RegisterFunctionEvent<TChannel extends ChannelNames, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1148
+ type RegisterFunctionEvent$1<TChannel extends ChannelNames, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
816
1149
  options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
817
1150
  source: {
818
1151
  active: boolean;
@@ -827,14 +1160,14 @@ type RegisterSourceEvent<TTriggerOptionDefinitions extends Record<string, string
827
1160
  dynamicTriggerId?: string;
828
1161
  options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
829
1162
  };
830
- type RegisterFunctionOutput<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1163
+ type RegisterFunctionOutput$1<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
831
1164
  secret?: string;
832
1165
  data?: SerializableJson;
833
1166
  options: TriggerOptionsRecordWithEvent<string[], TTriggerOptionDefinitions>;
834
1167
  };
835
- type RegisterFunction<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (event: RegisterFunctionEvent<TChannel, TParams, TTriggerOptionDefinitions>, io: IOWithIntegrations<{
1168
+ type RegisterFunction$1<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (event: RegisterFunctionEvent$1<TChannel, TParams, TTriggerOptionDefinitions>, io: IOWithIntegrations<{
836
1169
  integration: TIntegration;
837
- }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
1170
+ }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
838
1171
  type HandlerEvent<TChannel extends ChannelNames, TParams extends any = any> = {
839
1172
  rawEvent: ExternalSourceChannelMap[TChannel]["event"];
840
1173
  source: Prettify<Omit<HandleTriggerSource, "params"> & {
@@ -846,18 +1179,18 @@ type HandlerFunction<TChannel extends ChannelNames, TParams extends any, TTrigge
846
1179
  response?: NormalizedResponse;
847
1180
  metadata?: HttpSourceResponseMetadata;
848
1181
  } | void>;
849
- type KeyFunction<TParams extends any> = (params: TParams) => string;
850
- type FilterFunction<TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter;
1182
+ type KeyFunction$1<TParams extends any> = (params: TParams) => string;
1183
+ type FilterFunction$1<TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = (params: TParams, options?: TTriggerOptionDefinitions) => EventFilter;
851
1184
  type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
852
1185
  id: string;
853
1186
  version: string;
854
1187
  schema: SchemaParser<TParams>;
855
1188
  optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
856
1189
  integration: TIntegration;
857
- register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
858
- filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
1190
+ register: RegisterFunction$1<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
1191
+ filter?: FilterFunction$1<TParams, TTriggerOptionDefinitions>;
859
1192
  handler: HandlerFunction<TChannel, TParams, TIntegration>;
860
- key: KeyFunction<TParams>;
1193
+ key: KeyFunction$1<TParams>;
861
1194
  properties?: (params: TParams) => DisplayProperty[];
862
1195
  };
863
1196
  declare class ExternalSource<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames = ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> {
@@ -872,6 +1205,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
872
1205
  id?: string | undefined;
873
1206
  timestamp?: Date | undefined;
874
1207
  source?: string | undefined;
1208
+ payloadType?: "JSON" | "REQUEST" | undefined;
875
1209
  }[];
876
1210
  response?: {
877
1211
  status: number;
@@ -882,7 +1216,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
882
1216
  }>;
883
1217
  filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter;
884
1218
  properties(params: TParams): DisplayProperty[];
885
- register(params: TParams, registerEvent: RegisterSourceEvent<TTriggerOptionDefinitions>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
1219
+ register(params: TParams, registerEvent: RegisterSourceEvent<TTriggerOptionDefinitions>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
886
1220
  key(params: TParams): string;
887
1221
  get integration(): TIntegration;
888
1222
  get integrationConfig(): {
@@ -910,6 +1244,9 @@ declare class ExternalSourceTrigger<TEventSpecification extends EventSpecificati
910
1244
  toJSON(): TriggerMetadata;
911
1245
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
912
1246
  get preprocessRuns(): boolean;
1247
+ verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<{
1248
+ success: true;
1249
+ }>;
913
1250
  }
914
1251
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, key: K): {
915
1252
  result: Omit<T, K>;
@@ -962,6 +1299,9 @@ declare class DynamicTrigger<TEventSpec extends EventSpecification<any>, TExtern
962
1299
  }): Promise<RegisterSourceEventV2>;
963
1300
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
964
1301
  get preprocessRuns(): boolean;
1302
+ verifyPayload(payload: ReturnType<TEventSpec["parsePayload"]>): Promise<{
1303
+ success: true;
1304
+ }>;
965
1305
  }
966
1306
 
967
1307
  type ScheduledEventSpecification = EventSpecification<ScheduledPayload>;
@@ -993,6 +1333,9 @@ declare class IntervalTrigger implements Trigger<ScheduledEventSpecification> {
993
1333
  };
994
1334
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
995
1335
  get preprocessRuns(): boolean;
1336
+ verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1337
+ success: true;
1338
+ }>;
996
1339
  toJSON(): TriggerMetadata;
997
1340
  }
998
1341
  /** `intervalTrigger()` is set as a [Job's trigger](/sdk/job) to trigger a Job at a recurring interval.
@@ -1027,6 +1370,9 @@ declare class CronTrigger implements Trigger<ScheduledEventSpecification> {
1027
1370
  };
1028
1371
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1029
1372
  get preprocessRuns(): boolean;
1373
+ verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1374
+ success: true;
1375
+ }>;
1030
1376
  toJSON(): TriggerMetadata;
1031
1377
  }
1032
1378
  /** `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.
@@ -1093,9 +1439,147 @@ declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
1093
1439
  }>;
1094
1440
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1095
1441
  get preprocessRuns(): boolean;
1442
+ verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1443
+ success: true;
1444
+ }>;
1096
1445
  toJSON(): TriggerMetadata;
1097
1446
  }
1098
1447
 
1448
+ type WebhookCRUDContext<TParams extends any, TConfig extends Record<string, string[]>> = {
1449
+ active: boolean;
1450
+ params: TParams;
1451
+ config: {
1452
+ current: Partial<TConfig>;
1453
+ desired: TConfig;
1454
+ };
1455
+ url: string;
1456
+ secret: string;
1457
+ };
1458
+ type WebhookCRUDFunction<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = (options: {
1459
+ io: IOWithIntegrations<{
1460
+ integration: TIntegration;
1461
+ }>;
1462
+ ctx: WebhookCRUDContext<TParams, TConfig>;
1463
+ }) => Promise<any>;
1464
+ interface WebhookCRUD<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> {
1465
+ create: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1466
+ read?: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1467
+ update?: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1468
+ delete: WebhookCRUDFunction<TIntegration, TParams, TConfig>;
1469
+ }
1470
+ type WebhookConfig<TConfigKeys extends string> = {
1471
+ [K in TConfigKeys]: string[];
1472
+ };
1473
+ type RegisterFunctionEvent<TParams extends any, TConfig extends Record<string, string[]>> = {
1474
+ source: {
1475
+ active: boolean;
1476
+ data?: any;
1477
+ secret: string;
1478
+ url: string;
1479
+ };
1480
+ params: TParams;
1481
+ config: TConfig;
1482
+ };
1483
+ type WebhookRegisterEvent<TConfig extends Record<string, string[]>> = {
1484
+ id: string;
1485
+ source: RegisterWebhookSource;
1486
+ dynamicTriggerId?: string;
1487
+ config: TConfig;
1488
+ };
1489
+ type RegisterFunctionOutput<TConfig extends Record<string, string[]>> = {
1490
+ secret?: string;
1491
+ data?: SerializableJson;
1492
+ config: TConfig;
1493
+ };
1494
+ type RegisterFunction<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = (event: RegisterFunctionEvent<TParams, TConfig>, io: IOWithIntegrations<{
1495
+ integration: TIntegration;
1496
+ }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TConfig> | undefined>;
1497
+ type WebhookHandlerEvent<TParams extends any = any> = {
1498
+ rawEvent: Request;
1499
+ source: Prettify<Omit<HandleTriggerSource, "params"> & {
1500
+ params: TParams;
1501
+ }>;
1502
+ };
1503
+ type WebhookDeliveryContext = {
1504
+ key: string;
1505
+ secret: string;
1506
+ params: any;
1507
+ };
1508
+ type EventGenerator<TParams extends any, TConfig extends Record<string, string[]>, TIntegration extends TriggerIntegration> = (options: {
1509
+ request: Request;
1510
+ client: TriggerClient;
1511
+ ctx: WebhookDeliveryContext;
1512
+ }) => Promise<any>;
1513
+ type KeyFunction<TParams extends any> = (params: TParams) => string;
1514
+ type FilterFunction<TParams extends any, TConfig extends Record<string, string[]>> = (params: TParams, config?: TConfig) => EventFilter;
1515
+ type WebhookOptions<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>> = {
1516
+ id: string;
1517
+ version: string;
1518
+ integration: TIntegration;
1519
+ schemas: {
1520
+ params: SchemaParser<TParams>;
1521
+ config?: SchemaParser<TConfig>;
1522
+ };
1523
+ key: KeyFunction<TParams>;
1524
+ crud: WebhookCRUD<TIntegration, TParams, TConfig>;
1525
+ filter?: FilterFunction<TParams, TConfig>;
1526
+ register?: RegisterFunction<TIntegration, TParams, TConfig>;
1527
+ verify?: (options: {
1528
+ request: Request;
1529
+ client: TriggerClient;
1530
+ ctx: WebhookDeliveryContext;
1531
+ }) => Promise<VerifyResult>;
1532
+ generateEvents: EventGenerator<TParams, TConfig, TIntegration>;
1533
+ properties?: (params: TParams) => DisplayProperty[];
1534
+ };
1535
+ declare class WebhookSource<TIntegration extends TriggerIntegration, TParams extends any = any, TConfig extends Record<string, string[]> = Record<string, string[]>> {
1536
+ #private;
1537
+ private options;
1538
+ constructor(options: WebhookOptions<TIntegration, TParams, TConfig>);
1539
+ generateEvents(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise<any>;
1540
+ filter(params: TParams, config?: TConfig): EventFilter;
1541
+ properties(params: TParams): DisplayProperty[];
1542
+ get crud(): WebhookCRUD<TIntegration, TParams, TConfig>;
1543
+ register(params: TParams, registerEvent: WebhookRegisterEvent<TConfig>, io: IO, ctx: TriggerContext): Promise<RegisterFunctionOutput<TConfig> | undefined>;
1544
+ verify(request: Request, client: TriggerClient, ctx: WebhookDeliveryContext): Promise<VerifyResult>;
1545
+ key(params: TParams): string;
1546
+ get integration(): TIntegration;
1547
+ get integrationConfig(): {
1548
+ id: string;
1549
+ metadata: {
1550
+ id: string;
1551
+ name: string;
1552
+ instructions?: string | undefined;
1553
+ };
1554
+ };
1555
+ get id(): string;
1556
+ get version(): string;
1557
+ }
1558
+ type GetWebhookParams<TWebhook extends WebhookSource<any, any, any>> = TWebhook extends WebhookSource<any, infer TParams, any> ? TParams : never;
1559
+ type GetWebhookConfig<TWebhook extends WebhookSource<any, any, any>> = TWebhook extends WebhookSource<any, any, infer TConfig> ? TConfig : never;
1560
+ type WebhookTriggerOptions<TEventSpecification extends EventSpecification<any>, TEventSource extends WebhookSource<any, any, any>, TConfig extends Record<string, string[]> = Record<string, string[]>> = {
1561
+ event: TEventSpecification;
1562
+ source: TEventSource;
1563
+ params: GetWebhookParams<TEventSource>;
1564
+ config: TConfig;
1565
+ };
1566
+ declare class WebhookTrigger<TEventSpecification extends EventSpecification<any>, TEventSource extends WebhookSource<any, any, any>> implements Trigger<TEventSpecification> {
1567
+ private options;
1568
+ constructor(options: WebhookTriggerOptions<TEventSpecification, TEventSource>);
1569
+ get event(): TEventSpecification;
1570
+ get source(): TEventSource;
1571
+ get key(): string;
1572
+ toJSON(): TriggerMetadata;
1573
+ filter(eventFilter: EventFilter): WebhookTrigger<Omit<TEventSpecification, "filter"> & {
1574
+ filter: EventFilter;
1575
+ }, TEventSource>;
1576
+ attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1577
+ get preprocessRuns(): boolean;
1578
+ verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<{
1579
+ success: true;
1580
+ }>;
1581
+ }
1582
+
1099
1583
  type TriggerClientOptions = {
1100
1584
  /** The `id` property is used to uniquely identify the client.
1101
1585
  */
@@ -1126,11 +1610,20 @@ declare class TriggerClient {
1126
1610
  #private;
1127
1611
  id: string;
1128
1612
  constructor(options: Prettify<TriggerClientOptions>);
1613
+ on: <E extends keyof NotificationEvents>(event: E, listener: NotificationEvents[E]) => NotificationsEventEmitter;
1129
1614
  handleRequest(request: Request, timeOrigin?: number): Promise<NormalizedResponse>;
1130
- defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}>(options: JobOptions<TTrigger, TIntegrations>): Job<TTrigger, TIntegrations>;
1615
+ defineJob<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any>(options: JobOptions<TTrigger, TIntegrations, TOutput>): Job<TTrigger, TIntegrations, TOutput>;
1131
1616
  defineAuthResolver(integration: TriggerIntegration, resolver: TriggerAuthResolver): TriggerClient;
1132
1617
  defineDynamicSchedule(options: DynamicIntervalOptions): DynamicSchedule;
1133
1618
  defineDynamicTrigger<TEventSpec extends EventSpecification<any>, TExternalSource extends ExternalSource<any, any, any>>(options: DynamicTriggerOptions<TEventSpec, TExternalSource>): DynamicTrigger<TEventSpec, TExternalSource>;
1619
+ /**
1620
+ * An [HTTP endpoint](https://trigger.dev/docs/documentation/concepts/http-endpoints) allows you to create a [HTTP Trigger](https://trigger.dev/docs/documentation/concepts/triggers/http), which means you can trigger your Jobs from any webhooks.
1621
+ * @param options The Endpoint options
1622
+ * @returns An HTTP Endpoint, that can be used to create an HTTP Trigger.
1623
+ * @link https://trigger.dev/docs/documentation/concepts/http-endpoints
1624
+ */
1625
+ defineHttpEndpoint(options: EndpointOptions, suppressWarnings?: boolean): HttpEndpoint<EventSpecification<Request, Request>>;
1626
+ defineConcurrencyLimit(options: ConcurrencyLimitOptions): ConcurrencyLimit;
1134
1627
  attach(job: Job<Trigger<any>, any>): void;
1135
1628
  attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
1136
1629
  attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
@@ -1143,7 +1636,14 @@ declare class TriggerClient {
1143
1636
  }): void;
1144
1637
  attachDynamicSchedule(key: string): void;
1145
1638
  attachDynamicScheduleToJob(key: string, job: Job<Trigger<any>, any>): void;
1146
- registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2): Promise<{
1639
+ attachWebhook<TIntegration extends TriggerIntegration, TParams extends any, TConfig extends Record<string, string[]>>(options: {
1640
+ key: string;
1641
+ source: WebhookSource<TIntegration, TParams, TConfig>;
1642
+ event: EventSpecification<any>;
1643
+ params: any;
1644
+ config: TConfig;
1645
+ }): void;
1646
+ registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
1147
1647
  id: string;
1148
1648
  options: {
1149
1649
  event: {
@@ -1199,6 +1699,25 @@ declare class TriggerClient {
1199
1699
  deliveredAt?: Date | null | undefined;
1200
1700
  cancelledAt?: Date | null | undefined;
1201
1701
  }>;
1702
+ /** You can call this function from anywhere in your backend to send multiple events. The other way to send multiple events is by using [`io.sendEvents()`](https://trigger.dev/docs/sdk/io/sendevents) from inside a `run()` function.
1703
+ * @param events The events to send.
1704
+ * @param options Options for sending the events.
1705
+ * @returns A promise that resolves to an array of event details
1706
+ */
1707
+ sendEvents(events: SendEvent[], options?: SendEventOptions): Promise<{
1708
+ id: string;
1709
+ name: string;
1710
+ payload: ((string | number | boolean | {
1711
+ [key: string]: DeserializedJson;
1712
+ } | DeserializedJson[]) & (string | number | boolean | {
1713
+ [key: string]: DeserializedJson;
1714
+ } | DeserializedJson[] | undefined)) | null;
1715
+ timestamp: Date;
1716
+ context?: DeserializedJson | undefined;
1717
+ deliverAt?: Date | null | undefined;
1718
+ deliveredAt?: Date | null | undefined;
1719
+ cancelledAt?: Date | null | undefined;
1720
+ }[]>;
1202
1721
  cancelEvent(eventId: string): Promise<{
1203
1722
  id: string;
1204
1723
  name: string;
@@ -1213,6 +1732,10 @@ declare class TriggerClient {
1213
1732
  deliveredAt?: Date | null | undefined;
1214
1733
  cancelledAt?: Date | null | undefined;
1215
1734
  }>;
1735
+ cancelRunsForEvent(eventId: string): Promise<{
1736
+ cancelledRunIds: string[];
1737
+ failedToCancelRunIds: string[];
1738
+ }>;
1216
1739
  updateStatus(runId: string, id: string, status: StatusUpdate): Promise<{
1217
1740
  label: string;
1218
1741
  key: string;
@@ -1253,7 +1776,7 @@ declare class TriggerClient {
1253
1776
  updatedAt: Date;
1254
1777
  runs: {
1255
1778
  id: string;
1256
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1779
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1257
1780
  startedAt?: Date | null | undefined;
1258
1781
  completedAt?: Date | null | undefined;
1259
1782
  }[];
@@ -1263,7 +1786,7 @@ declare class TriggerClient {
1263
1786
  id: string;
1264
1787
  startedAt: Date | null;
1265
1788
  completedAt: Date | null;
1266
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1789
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1267
1790
  updatedAt: Date | null;
1268
1791
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1269
1792
  statuses: {
@@ -1284,7 +1807,7 @@ declare class TriggerClient {
1284
1807
  id: string;
1285
1808
  startedAt: Date | null;
1286
1809
  completedAt: Date | null;
1287
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1810
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1288
1811
  updatedAt: Date | null;
1289
1812
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1290
1813
  statuses: {
@@ -1306,7 +1829,7 @@ declare class TriggerClient {
1306
1829
  id: string;
1307
1830
  startedAt: Date | null;
1308
1831
  completedAt: Date | null;
1309
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1832
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1310
1833
  updatedAt: Date | null;
1311
1834
  }[];
1312
1835
  nextCursor?: string | undefined;
@@ -1325,34 +1848,27 @@ declare class TriggerClient {
1325
1848
  }[];
1326
1849
  run: {
1327
1850
  id: string;
1328
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1851
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1329
1852
  output?: any;
1330
1853
  };
1331
1854
  }>;
1855
+ invokeJob(jobId: string, payload: any, options?: InvokeOptions): Promise<{
1856
+ id: string;
1857
+ }>;
1858
+ createEphemeralEventDispatcher(payload: EphemeralEventDispatcherRequestBody): Promise<{
1859
+ id: string;
1860
+ }>;
1861
+ get store(): {
1862
+ env: KeyValueStore;
1863
+ };
1332
1864
  authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
1333
1865
  apiKey(): string | undefined;
1334
1866
  }
1335
1867
 
1336
- declare class TriggerStatus {
1337
- private id;
1338
- private io;
1339
- constructor(id: string, io: IO);
1340
- update(key: IntegrationTaskKey, status: StatusUpdate): Promise<{
1341
- label: string;
1342
- key: string;
1343
- history: {
1344
- label?: string | undefined;
1345
- state?: "loading" | "success" | "failure" | undefined;
1346
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1347
- }[];
1348
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1349
- state?: "loading" | "success" | "failure" | undefined;
1350
- }>;
1351
- }
1352
-
1353
1868
  type IOTask = ServerTask;
1354
1869
  type IOOptions = {
1355
1870
  id: string;
1871
+ jobId: string;
1356
1872
  apiClient: ApiClient;
1357
1873
  client: TriggerClient;
1358
1874
  context: TriggerContext;
@@ -1389,9 +1905,23 @@ type IOStats = {
1389
1905
  noopCachedTaskHits: number;
1390
1906
  noopCachedTaskMisses: number;
1391
1907
  };
1908
+ interface OutputSerializer {
1909
+ serialize(value: any): string;
1910
+ deserialize<T>(value: string): T;
1911
+ }
1912
+ declare class JSONOutputSerializer implements OutputSerializer {
1913
+ serialize(value: any): string;
1914
+ deserialize(value?: string): any;
1915
+ }
1916
+ type BackgroundFetchResponse<T> = {
1917
+ status: number;
1918
+ data: T;
1919
+ headers: Record<string, string>;
1920
+ };
1392
1921
  declare class IO {
1393
1922
  #private;
1394
1923
  private _id;
1924
+ private _jobId;
1395
1925
  private _apiClient;
1396
1926
  private _triggerClient;
1397
1927
  private _logger;
@@ -1407,15 +1937,63 @@ declare class IO {
1407
1937
  private _serverVersion;
1408
1938
  private _timeOrigin;
1409
1939
  private _executionTimeout?;
1940
+ private _outputSerializer;
1941
+ private _visitedCacheKeys;
1942
+ private _envStore;
1943
+ private _jobStore;
1944
+ private _runStore;
1410
1945
  get stats(): IOStats;
1411
1946
  constructor(options: IOOptions);
1412
1947
  /** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
1413
1948
  get logger(): IOLogger;
1949
+ /** `io.random()` is identical to `Math.random()` when called without options but ensures your random numbers are not regenerated on resume or retry. It will return a pseudo-random floating-point number between optional `min` (default: 0, inclusive) and `max` (default: 1, exclusive). Can optionally `round` to the nearest integer.
1950
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1951
+ * @param min Sets the lower bound (inclusive). Can't be higher than `max`.
1952
+ * @param max Sets the upper bound (exclusive). Can't be lower than `min`.
1953
+ * @param round Controls rounding to the nearest integer. Any `max` integer will become inclusive when enabled. Rounding with floating-point bounds may cause unexpected skew and boundary inclusivity.
1954
+ */
1955
+ random(cacheKey: string | any[], { min, max, round, }?: {
1956
+ min?: number;
1957
+ max?: number;
1958
+ round?: boolean;
1959
+ }): Promise<number>;
1414
1960
  /** `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.
1415
1961
  * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1416
1962
  * @param seconds The number of seconds to wait. This can be very long, serverless timeouts are not an issue.
1417
1963
  */
1418
1964
  wait(cacheKey: string | any[], seconds: number): Promise<void>;
1965
+ waitForEvent<T extends z.ZodTypeAny = z.ZodTypeAny>(cacheKey: string | any[], event: {
1966
+ name: string;
1967
+ schema?: T;
1968
+ filter?: EventFilter;
1969
+ source?: string;
1970
+ contextFilter?: EventFilter;
1971
+ accountId?: string;
1972
+ }, options?: {
1973
+ timeoutInSeconds?: number;
1974
+ }): Promise<WaitForEventResult<z.output<T>>>;
1975
+ /** `io.waitForRequest()` allows you to pause the execution of a run until the url provided in the callback is POSTed to.
1976
+ * This is useful for integrating with external services that require a callback URL to be provided, or if you want to be able to wait until an action is performed somewhere else in your system.
1977
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1978
+ * @param callback A callback function that will provide the unique URL to POST to.
1979
+ * @param options Options for the callback.
1980
+ * @param options.timeoutInSeconds How long to wait for the request to be POSTed to the callback URL before timing out. Defaults to 1hr.
1981
+ * @returns The POSTed request JSON body.
1982
+ * @example
1983
+ * ```ts
1984
+ const result = await io.waitForRequest<{ message: string }>(
1985
+ "wait-for-request",
1986
+ async (url, task) => {
1987
+ // Save the URL somewhere so you can POST to it later
1988
+ // Or send it to an external service that will POST to it
1989
+ },
1990
+ { timeoutInSeconds: 60 } // wait 60 seconds
1991
+ );
1992
+ * ```
1993
+ */
1994
+ waitForRequest<T extends Json<T> | unknown = unknown>(cacheKey: string | any[], callback: (url: string) => Promise<unknown>, options?: {
1995
+ timeoutInSeconds?: number;
1996
+ }): Promise<T>;
1419
1997
  /** `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
1420
1998
  * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1421
1999
  * @param initialStatus The initial status you want this status to have. You can update it during the rub using the returned object.
@@ -1460,8 +2038,60 @@ declare class IO {
1460
2038
  * - Ranges: 500-599
1461
2039
  * - Wildcards: 2xx, 3xx, 4xx, 5xx
1462
2040
  */
1463
- backgroundFetch<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, retry?: FetchRetryOptions): Promise<TResponseData>;
1464
- /** `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).
2041
+ backgroundFetch<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, options?: {
2042
+ retry?: FetchRetryOptions;
2043
+ timeout?: FetchTimeoutOptions;
2044
+ }): Promise<TResponseData>;
2045
+ /** `io.backgroundPoll()` will fetch data from a URL on an interval. The actual `fetch` requests are performed on the Trigger.dev server, so you don't have to worry about serverless function timeouts.
2046
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2047
+ * @param params The options for the background poll
2048
+ * @param params.url The URL to fetch from.
2049
+ * @param params.requestInit The options for the request, like headers and method
2050
+ * @param params.responseFilter An [EventFilter](https://trigger.dev/docs/documentation/guides/event-filter) that allows you to specify when to stop polling.
2051
+ * @param params.interval The interval in seconds to poll the URL in seconds. Defaults to 10 seconds which is the minimum.
2052
+ * @param params.timeout The timeout in seconds for each request in seconds. Defaults to 10 minutes. Minimum is 60 seconds and max is 1 hour
2053
+ * @param params.requestTimeout An optional object that allows you to timeout individual fetch requests
2054
+ * @param params.requestTimeout An optional object that allows you to timeout individual fetch requests
2055
+ * @param params.requestTimeout.durationInMs The duration in milliseconds to timeout the request
2056
+ *
2057
+ * @example
2058
+ * ```ts
2059
+ * const result = await io.backgroundPoll<{ id: string; status: string; }>("poll", {
2060
+ url: `http://localhost:3030/api/v1/runs/${run.id}`,
2061
+ requestInit: {
2062
+ headers: {
2063
+ Accept: "application/json",
2064
+ Authorization: redactString`Bearer ${process.env["TRIGGER_API_KEY"]!}`,
2065
+ },
2066
+ },
2067
+ interval: 10,
2068
+ timeout: 600,
2069
+ responseFilter: {
2070
+ status: [200],
2071
+ body: {
2072
+ status: ["SUCCESS"],
2073
+ },
2074
+ },
2075
+ });
2076
+ * ```
2077
+ */
2078
+ backgroundPoll<TResponseData>(cacheKey: string | any[], params: FetchPollOperation): Promise<TResponseData>;
2079
+ /** `io.backgroundFetchResponse()` 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.
2080
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2081
+ * @param url The URL to fetch from.
2082
+ * @param requestInit The options for the request
2083
+ * @param retry The options for retrying the request if it fails
2084
+ * An object where the key is a status code pattern and the value is a retrying strategy.
2085
+ * Supported patterns are:
2086
+ * - Specific status codes: 429
2087
+ * - Ranges: 500-599
2088
+ * - Wildcards: 2xx, 3xx, 4xx, 5xx
2089
+ */
2090
+ backgroundFetchResponse<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, options?: {
2091
+ retry?: FetchRetryOptions;
2092
+ timeout?: FetchTimeoutOptions;
2093
+ }): Promise<BackgroundFetchResponse<TResponseData>>;
2094
+ /** `io.sendEvent()` allows you to send an event from inside a Job run. The sent event will trigger any Jobs that are listening for that event (based on the name).
1465
2095
  * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1466
2096
  * @param event The event to send. The event name must match the name of the event that your Jobs are listening for.
1467
2097
  * @param options Options for sending the event.
@@ -1480,13 +2110,32 @@ declare class IO {
1480
2110
  deliveredAt?: Date | null | undefined;
1481
2111
  cancelledAt?: Date | null | undefined;
1482
2112
  }>;
2113
+ /** `io.sendEvents()` allows you to send multiple events from inside a Job run. The sent events will trigger any Jobs that are listening for those events (based on the name).
2114
+ * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
2115
+ * @param event The events to send. The event names must match the names of the events that your Jobs are listening for.
2116
+ * @param options Options for sending the events.
2117
+ */
2118
+ sendEvents(cacheKey: string | any[], events: SendEvent[], options?: SendEventOptions): Promise<{
2119
+ id: string;
2120
+ name: string;
2121
+ payload: ((string | number | boolean | {
2122
+ [key: string]: _trigger_dev_core.DeserializedJson;
2123
+ } | _trigger_dev_core.DeserializedJson[]) & (string | number | boolean | {
2124
+ [key: string]: _trigger_dev_core.DeserializedJson;
2125
+ } | _trigger_dev_core.DeserializedJson[] | undefined)) | null;
2126
+ timestamp: Date;
2127
+ context?: _trigger_dev_core.DeserializedJson | undefined;
2128
+ deliverAt?: Date | null | undefined;
2129
+ deliveredAt?: Date | null | undefined;
2130
+ cancelledAt?: Date | null | undefined;
2131
+ }[]>;
1483
2132
  getEvent(cacheKey: string | any[], id: string): Promise<{
1484
2133
  id: string;
1485
2134
  name: string;
1486
2135
  updatedAt: Date;
1487
2136
  runs: {
1488
2137
  id: string;
1489
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
2138
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1490
2139
  startedAt?: Date | null | undefined;
1491
2140
  completedAt?: Date | null | undefined;
1492
2141
  }[];
@@ -1517,6 +2166,12 @@ declare class IO {
1517
2166
  id: string;
1518
2167
  key: string;
1519
2168
  }>;
2169
+ updateWebhook(cacheKey: string | any[], options: {
2170
+ key: string;
2171
+ } & UpdateWebhookBody): Promise<{
2172
+ id: string;
2173
+ key: string;
2174
+ }>;
1520
2175
  /** `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.
1521
2176
  * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
1522
2177
  * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
@@ -1602,6 +2257,7 @@ declare class IO {
1602
2257
  key: string;
1603
2258
  } | undefined>;
1604
2259
  getAuth(cacheKey: string | any[], clientId?: string): Promise<ConnectionAuth | undefined>;
2260
+ parallel<T extends Json<T> | void, TItem>(cacheKey: string | any[], items: Array<TItem>, callback: (item: TItem, index: number) => Promise<T>, options?: Pick<RunTaskOptions, "name" | "properties">): Promise<Array<T>>;
1605
2261
  /** `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.
1606
2262
  *
1607
2263
  * @param cacheKey Should be a stable and unique key inside the `run()`. See [resumability](https://trigger.dev/docs/documentation/concepts/resumability) for more information.
@@ -1610,7 +2266,9 @@ declare class IO {
1610
2266
  * @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.
1611
2267
  * @returns A Promise that resolves with the returned value of the callback.
1612
2268
  */
1613
- runTask<T extends Json<T> | void>(cacheKey: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions, onError?: RunTaskErrorCallback): Promise<T>;
2269
+ runTask<T extends Json<T> | void>(cacheKey: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions & {
2270
+ parseOutput?: (output: unknown) => T;
2271
+ }, onError?: RunTaskErrorCallback): Promise<T>;
1614
2272
  /**
1615
2273
  * `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.
1616
2274
  */
@@ -1619,13 +2277,18 @@ declare class IO {
1619
2277
  * `io.brb()` is an alias of `io.yield()`
1620
2278
  */
1621
2279
  brb: (cacheKey: string) => void;
1622
- /** `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).
2280
+ /** `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()](https://trigger.dev/docs/sdk/io/runtask).
1623
2281
  * 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.
1624
2282
  * @param tryCallback The code you wish to run
1625
2283
  * @param catchCallback Thhis will be called if the Task fails. The callback receives the error
1626
2284
  * @returns A Promise that resolves with the returned value or the error
1627
2285
  */
1628
2286
  try<TResult, TCatchResult>(tryCallback: () => Promise<TResult>, catchCallback: (error: unknown) => Promise<TCatchResult>): Promise<TResult | TCatchResult>;
2287
+ get store(): {
2288
+ env: KeyValueStore;
2289
+ job: KeyValueStore;
2290
+ run: KeyValueStore;
2291
+ };
1629
2292
  }
1630
2293
  type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
1631
2294
  declare class IOLogger implements TaskLogger {
@@ -1652,7 +2315,7 @@ interface TriggerIntegration {
1652
2315
  type IOWithIntegrations<TIntegrations extends Record<string, TriggerIntegration>> = IO & TIntegrations;
1653
2316
  type IntegrationTaskKey = string | any[];
1654
2317
 
1655
- type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}> = {
2318
+ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any> = {
1656
2319
  /** The `id` property is used to uniquely identify the Job. Only change this if you want to create a new Job. */
1657
2320
  id: string;
1658
2321
  /** The `name` of the Job that you want to appear in the dashboard and logs. You can change this without creating a new Job. */
@@ -1687,9 +2350,15 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
1687
2350
  });
1688
2351
  ``` */
1689
2352
  integrations?: TIntegrations;
1690
- /** @deprecated This property is deprecated and no longer effects the execution of the Job
1691
- * */
1692
- queue?: QueueOptions | string;
2353
+ /**
2354
+ * The `concurrencyLimit` property is used to limit the number of concurrent run executions of a job.
2355
+ * Can be a number which represents the limit or a `ConcurrencyLimit` instance which can be used to
2356
+ * group together multiple jobs to share the same concurrency limit.
2357
+ *
2358
+ * If undefined the job will be limited only by the server's global concurrency limit, or if you are using the
2359
+ * Trigger.dev Cloud service, the concurrency limit of your plan.
2360
+ */
2361
+ concurrencyLimit?: number | ConcurrencyLimit;
1693
2362
  /** The `enabled` property is used to enable or disable the Job. If you disable a Job, it will not run. */
1694
2363
  enabled?: boolean;
1695
2364
  /** This function gets called automatically when a Run is Triggered.
@@ -1698,19 +2367,22 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
1698
2367
  * @param io An object that contains the integrations that you specified in the `integrations` property and other useful functions like delays and running Tasks.
1699
2368
  * @param context An object that contains information about the Organization, Job, Run and more.
1700
2369
  */
1701
- run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<any>;
2370
+ run: (payload: TriggerEventType<TTrigger>, io: IOWithIntegrations<TIntegrations>, context: TriggerContext) => Promise<TOutput>;
2371
+ onSuccess?: (notification: SuccessfulRunNotification<TOutput, TriggerEventType<TTrigger>>) => void;
2372
+ onFailure?: (notification: FailedRunNotification<TriggerEventType<TTrigger>>) => void;
1702
2373
  };
1703
2374
  type JobPayload<TJob> = TJob extends Job<Trigger<EventSpecification<infer TEvent>>, any> ? TEvent : never;
1704
2375
  type JobIO<TJob> = TJob extends Job<any, infer TIntegrations> ? IOWithIntegrations<TIntegrations> : never;
1705
2376
  /** A [Job](https://trigger.dev/docs/documentation/concepts/jobs) is used to define the [Trigger](https://trigger.dev/docs/documentation/concepts/triggers), metadata, and what happens when it runs. */
1706
- declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}> {
2377
+ declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations extends Record<string, TriggerIntegration> = {}, TOutput extends any = any> {
1707
2378
  #private;
1708
- readonly options: JobOptions<TTrigger, TIntegrations>;
1709
- client: TriggerClient;
1710
- constructor(
1711
- /** An instance of [TriggerClient](/sdk/triggerclient) that is used to send events
1712
- to the Trigger API. */
1713
- client: TriggerClient, options: JobOptions<TTrigger, TIntegrations>);
2379
+ readonly options: JobOptions<TTrigger, TIntegrations, TOutput>;
2380
+ client?: TriggerClient;
2381
+ constructor(options: JobOptions<TTrigger, TIntegrations, TOutput>);
2382
+ /**
2383
+ * Attaches the job to a client. This is called automatically when you define a job using `client.defineJob()`.
2384
+ */
2385
+ attachToClient(client: TriggerClient): this;
1714
2386
  get id(): string;
1715
2387
  get enabled(): boolean;
1716
2388
  get name(): string;
@@ -1719,6 +2391,19 @@ declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegratio
1719
2391
  get logLevel(): LogLevel | undefined;
1720
2392
  get integrations(): Record<string, IntegrationConfig>;
1721
2393
  toJSON(): JobMetadata;
2394
+ invoke(cacheKey: string, payload: TriggerInvokeType<TTrigger>, options?: InvokeOptions): Promise<{
2395
+ id: string;
2396
+ }>;
2397
+ invoke(payload: TriggerInvokeType<TTrigger>, options?: InvokeOptions): Promise<{
2398
+ id: string;
2399
+ }>;
2400
+ invokeAndWaitForCompletion(cacheKey: string | string[], payload: TriggerInvokeType<TTrigger>, timeoutInSeconds?: number, // 1 hour
2401
+ options?: Prettify<Pick<InvokeOptions, "accountId" | "context">>): Promise<RunNotification<TOutput>>;
2402
+ batchInvokeAndWaitForCompletion(cacheKey: string | string[], batch: Array<{
2403
+ payload: TriggerInvokeType<TTrigger>;
2404
+ timeoutInSeconds?: number;
2405
+ options?: Prettify<Pick<InvokeOptions, "accountId" | "context">>;
2406
+ }>): Promise<Array<RunNotification<TOutput>>>;
1722
2407
  }
1723
2408
 
1724
2409
  type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> = {
@@ -1726,6 +2411,7 @@ type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> =
1726
2411
  name?: string | string[];
1727
2412
  source?: string;
1728
2413
  filter?: EventFilter;
2414
+ verify?: EventTypeFromSpecification<TEventSpecification> extends Request ? VerifyCallback : never;
1729
2415
  };
1730
2416
  declare class EventTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
1731
2417
  #private;
@@ -1734,6 +2420,7 @@ declare class EventTrigger<TEventSpecification extends EventSpecification<any>>
1734
2420
  get event(): TEventSpecification;
1735
2421
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1736
2422
  get preprocessRuns(): boolean;
2423
+ verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<VerifyResult>;
1737
2424
  }
1738
2425
  /** Configuration options for an EventTrigger */
1739
2426
  type TriggerOptions<TEvent> = {
@@ -1820,6 +2507,9 @@ declare class MissingConnectionNotification implements Trigger<MissingConnection
1820
2507
  };
1821
2508
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<MissingConnectionNotificationSpecification>, any>): void;
1822
2509
  get preprocessRuns(): boolean;
2510
+ verifyPayload(payload: ReturnType<MissingConnectionNotificationSpecification["parsePayload"]>): Promise<{
2511
+ success: true;
2512
+ }>;
1823
2513
  toJSON(): TriggerMetadata;
1824
2514
  }
1825
2515
  type MissingConnectionResolvedNotificationSpecification = EventSpecification<MissingConnectionResolvedNotificationPayload>;
@@ -1869,13 +2559,74 @@ declare class MissingConnectionResolvedNotification implements Trigger<MissingCo
1869
2559
  };
1870
2560
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<MissingConnectionResolvedNotificationSpecification>, any>): void;
1871
2561
  get preprocessRuns(): boolean;
2562
+ verifyPayload(payload: ReturnType<MissingConnectionResolvedNotificationSpecification["parsePayload"]>): Promise<{
2563
+ success: true;
2564
+ }>;
1872
2565
  toJSON(): TriggerMetadata;
1873
2566
  }
1874
2567
 
2568
+ /** Configuration options for an InvokeTrigger */
2569
+ type InvokeTriggerOptions<TSchema extends ZodType = z.ZodTypeAny> = {
2570
+ /** A [Zod](https://trigger.dev/docs/documentation/guides/zod) schema that defines the shape of the event payload.
2571
+ * The default is `z.any()` which is `any`.
2572
+ * */
2573
+ schema?: TSchema;
2574
+ examples?: EventSpecificationExample[];
2575
+ };
2576
+ declare class InvokeTrigger<TSchema extends ZodType = z.ZodTypeAny> implements Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>> {
2577
+ #private;
2578
+ constructor(options: InvokeTriggerOptions<TSchema>);
2579
+ toJSON(): TriggerMetadata;
2580
+ get event(): {
2581
+ name: string;
2582
+ title: string;
2583
+ source: string;
2584
+ examples: {
2585
+ id: string;
2586
+ name: string;
2587
+ icon?: string | undefined;
2588
+ payload?: any;
2589
+ }[];
2590
+ icon: string;
2591
+ parsePayload: (rawPayload: unknown) => any;
2592
+ parseInvokePayload: (rawPayload: unknown) => any;
2593
+ };
2594
+ attachToJob(triggerClient: TriggerClient, job: Job<Trigger<EventSpecification<ZodType<TSchema>>>, any>): void;
2595
+ get preprocessRuns(): boolean;
2596
+ verifyPayload(): Promise<{
2597
+ success: true;
2598
+ }>;
2599
+ }
2600
+ declare function invokeTrigger<TSchema extends ZodType = z.ZodTypeAny>(options?: InvokeTriggerOptions<TSchema>): Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>>;
2601
+
2602
+ declare function slugifyId(input: string): string;
2603
+
2604
+ /** Easily verify webhook payloads when they're using common signing methods. */
2605
+ declare function verifyRequestSignature({ request, headerName, headerEncoding, secret, algorithm, }: {
2606
+ /** The web request that you want to verify. */
2607
+ request: Request;
2608
+ /** The name of the header that contains the signature. E.g. `X-Cal-Signature-256`. */
2609
+ headerName: string;
2610
+ /** The header encoding. Defaults to `hex`. */
2611
+ headerEncoding?: BinaryToTextEncoding;
2612
+ /** The secret that you use to hash the payload. For HttpEndpoints this will usually originally
2613
+ come from the Trigger.dev dashboard and should be stored in an environment variable. */
2614
+ secret: BinaryLike | KeyObject;
2615
+ /** The hashing algorithm that was used to create the signature. Currently only `sha256` is
2616
+ supported. */
2617
+ algorithm: "sha256";
2618
+ }): Promise<VerifyResult>;
2619
+ declare function verifyHmacSha256(headerValue: string, headerEncoding: BinaryToTextEncoding, secret: BinaryLike | KeyObject, body: string): boolean;
2620
+
1875
2621
  declare class ResumeWithTaskError {
1876
2622
  task: ServerTask;
1877
2623
  constructor(task: ServerTask);
1878
2624
  }
2625
+ declare class ResumeWithParallelTaskError {
2626
+ task: ServerTask;
2627
+ childErrors: Array<TriggerInternalError>;
2628
+ constructor(task: ServerTask, childErrors: Array<TriggerInternalError>);
2629
+ }
1879
2630
  declare class RetryWithTaskError {
1880
2631
  cause: ErrorWithStack;
1881
2632
  task: ServerTask;
@@ -1899,25 +2650,26 @@ declare class AutoYieldExecutionError {
1899
2650
  declare class AutoYieldWithCompletedTaskExecutionError {
1900
2651
  id: string;
1901
2652
  properties: DisplayProperty[] | undefined;
1902
- output: any;
1903
2653
  data: {
1904
2654
  location: string;
1905
2655
  timeRemaining: number;
1906
2656
  timeElapsed: number;
1907
2657
  };
1908
- constructor(id: string, properties: DisplayProperty[] | undefined, output: any, data: {
2658
+ output?: string | undefined;
2659
+ constructor(id: string, properties: DisplayProperty[] | undefined, data: {
1909
2660
  location: string;
1910
2661
  timeRemaining: number;
1911
2662
  timeElapsed: number;
1912
- });
2663
+ }, output?: string | undefined);
1913
2664
  }
2665
+ type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | ResumeWithParallelTaskError;
1914
2666
  /** Use this function if you're using a `try/catch` block to catch errors.
1915
2667
  * It checks if a thrown error is a special internal error that you should ignore.
1916
2668
  * If this returns `true` then you must rethrow the error: `throw err;`
1917
2669
  * @param err The error to check
1918
2670
  * @returns `true` if the error is a Trigger Error, `false` otherwise.
1919
2671
  */
1920
- declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError;
2672
+ declare function isTriggerError(err: unknown): err is TriggerInternalError;
1921
2673
 
1922
2674
  declare const retry: {
1923
2675
  readonly standardBackoff: {
@@ -1927,6 +2679,13 @@ declare const retry: {
1927
2679
  readonly maxTimeoutInMs: 30000;
1928
2680
  readonly randomize: true;
1929
2681
  };
2682
+ readonly exponentialBackoff: {
2683
+ readonly limit: 8;
2684
+ readonly factor: 2;
2685
+ readonly minTimeoutInMs: 1000;
2686
+ readonly maxTimeoutInMs: 30000;
2687
+ readonly randomize: true;
2688
+ };
1930
2689
  };
1931
2690
 
1932
2691
  type Task = ServerTask;
@@ -1934,4 +2693,4 @@ type Task = ServerTask;
1934
2693
  type SentEvent = ApiEventLog;
1935
2694
  declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
1936
2695
 
1937
- 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 };
2696
+ export { type AuthResolverResult, type BackgroundFetchResponse, CronTrigger, type DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, type DynamicTriggerOptions, type EventSpecification, type EventSpecificationExample, EventSpecificationExampleSchema, EventTrigger, type EventTypeFromSpecification, ExternalSource, type ExternalSourceParams, ExternalSourceTrigger, type ExternalSourceTriggerOptions, type GetWebhookConfig, type GetWebhookParams, type HandlerEvent, type HttpSourceEvent, IO, IOLogger, type IOOptions, type IOStats, type IOTask, type IOWithIntegrations, type IntegrationTaskKey, IntervalTrigger, InvokeTrigger, JSONOutputSerializer, Job, type JobIO, type JobOptions, type JobPayload, type Json, MissingConnectionNotification, MissingConnectionResolvedNotification, type NotificationEvents, type NotificationsEventEmitter, type OutputSerializer, type PreprocessResults, type RunTaskErrorCallback, type SchemaParser, type SchemaParserIssue, type SchemaParserResult, type SentEvent, type Task, type TaskLogger, type Trigger, type TriggerAuthResolver, TriggerClient, type TriggerClientOptions, type TriggerContext, type TriggerEventType, type TriggerIntegration, type TriggerInvokeType, type TriggerOptionRecord, type TriggerPayload, type TriggerPreprocessContext, type TypedEventSpecificationExample, type VerifyResult, type WaitForEventResult, type WebhookConfig, type WebhookDeliveryContext, type WebhookHandlerEvent, WebhookSource, WebhookTrigger, type WebhookTriggerOptions, cronTrigger, eventTrigger, intervalTrigger, invokeTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry, slugifyId, verifyHmacSha256, verifyRequestSignature, waitForEventSchema };