@trigger.dev/sdk 0.0.0-buffer-import-20231031135043 → 0.0.0-buffer-fix-20231206151546

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;
@@ -519,6 +612,7 @@ declare class ApiClient {
519
612
  state?: "loading" | "success" | "failure" | undefined;
520
613
  }>;
521
614
  updateSource(client: string, key: string, source: UpdateTriggerSourceBodyV2): Promise<TriggerSource>;
615
+ updateWebhook(key: string, webhookData: UpdateWebhookBody): Promise<TriggerSource>;
522
616
  registerTrigger(client: string, id: string, key: string, payload: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<RegisterSourceEventV2>;
523
617
  registerSchedule(client: string, id: string, key: string, payload: ScheduleMetadata): Promise<{
524
618
  id: string;
@@ -555,7 +649,7 @@ declare class ApiClient {
555
649
  updatedAt: Date;
556
650
  runs: {
557
651
  id: string;
558
- 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";
559
653
  startedAt?: Date | null | undefined;
560
654
  completedAt?: Date | null | undefined;
561
655
  }[];
@@ -565,7 +659,7 @@ declare class ApiClient {
565
659
  id: string;
566
660
  startedAt: Date | null;
567
661
  completedAt: Date | null;
568
- 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";
569
663
  updatedAt: Date | null;
570
664
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
571
665
  statuses: {
@@ -586,7 +680,7 @@ declare class ApiClient {
586
680
  id: string;
587
681
  startedAt: Date | null;
588
682
  completedAt: Date | null;
589
- 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";
590
684
  updatedAt: Date | null;
591
685
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
592
686
  statuses: {
@@ -617,7 +711,7 @@ declare class ApiClient {
617
711
  }[];
618
712
  run: {
619
713
  id: string;
620
- 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";
621
715
  output?: any;
622
716
  };
623
717
  }>;
@@ -626,11 +720,18 @@ declare class ApiClient {
626
720
  id: string;
627
721
  startedAt: Date | null;
628
722
  completedAt: Date | null;
629
- 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";
630
724
  updatedAt: Date | null;
631
725
  }[];
632
726
  nextCursor?: string | undefined;
633
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;
634
735
  }
635
736
  type VersionedResponseBodyMap = {
636
737
  [key: string]: z.ZodTypeAny;
@@ -645,6 +746,65 @@ type VersionedResponseBody<TVersions extends VersionedResponseBodyMap, TUnversio
645
746
  body: z.infer<TUnversioned>;
646
747
  };
647
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
+
648
808
  interface TriggerContext {
649
809
  /** Job metadata */
650
810
  job: {
@@ -663,6 +823,12 @@ interface TriggerContext {
663
823
  id: string;
664
824
  title: string;
665
825
  };
826
+ /** Project metadata */
827
+ project: {
828
+ slug: string;
829
+ id: string;
830
+ name: string;
831
+ };
666
832
  /** Run metadata */
667
833
  run: {
668
834
  id: string;
@@ -729,20 +895,45 @@ type PreprocessResults = {
729
895
  properties: DisplayProperty[];
730
896
  };
731
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
+ };
732
905
  interface Trigger<TEventSpec extends EventSpecification<any>> {
733
906
  event: TEventSpec;
734
907
  toJSON(): TriggerMetadata;
735
908
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
736
909
  preprocessRuns: boolean;
910
+ verifyPayload: (payload: ReturnType<TEventSpec["parsePayload"]>) => Promise<VerifyResult>;
737
911
  }
738
912
  type TriggerPayload<TTrigger> = TTrigger extends Trigger<EventSpecification<infer TEvent>> ? TEvent : never;
739
- 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> = {
740
931
  id: string;
741
932
  name: string;
742
933
  icon?: string;
743
- payload: any;
934
+ payload: TEvent;
744
935
  };
745
- interface EventSpecification<TEvent extends any> {
936
+ interface EventSpecification<TEvent extends any, TInvoke extends any = TEvent> {
746
937
  name: string | string[];
747
938
  title: string;
748
939
  source: string;
@@ -752,6 +943,7 @@ interface EventSpecification<TEvent extends any> {
752
943
  examples?: Array<EventSpecificationExample>;
753
944
  filter?: EventFilter;
754
945
  parsePayload: (payload: unknown) => TEvent;
946
+ parseInvokePayload?: (payload: unknown) => TInvoke;
755
947
  runProperties?: (payload: TEvent) => DisplayProperty[];
756
948
  }
757
949
  type EventTypeFromSpecification<TEventSpec extends EventSpecification<any>> = TEventSpec extends EventSpecification<infer TEvent> ? TEvent : never;
@@ -771,6 +963,143 @@ type SchemaParserResult<T> = {
771
963
  type SchemaParser<T extends unknown = unknown> = {
772
964
  safeParse: (a: unknown) => SchemaParserResult<T>;
773
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
+ }
774
1103
 
775
1104
  type HttpSourceEvent = {
776
1105
  url: string;
@@ -816,7 +1145,7 @@ type TriggerOptionsRecordWithEvent<TValue, TTriggerOptionDefinitions extends Rec
816
1145
  type TriggerOptionRecord<TValue, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
817
1146
  [K in keyof TTriggerOptionDefinitions]: TValue;
818
1147
  };
819
- 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> = {
820
1149
  options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
821
1150
  source: {
822
1151
  active: boolean;
@@ -831,14 +1160,14 @@ type RegisterSourceEvent<TTriggerOptionDefinitions extends Record<string, string
831
1160
  dynamicTriggerId?: string;
832
1161
  options: TriggerOptionDiffs<TTriggerOptionDefinitions>;
833
1162
  };
834
- type RegisterFunctionOutput<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
1163
+ type RegisterFunctionOutput$1<TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
835
1164
  secret?: string;
836
1165
  data?: SerializableJson;
837
1166
  options: TriggerOptionsRecordWithEvent<string[], TTriggerOptionDefinitions>;
838
1167
  };
839
- 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<{
840
1169
  integration: TIntegration;
841
- }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput<TTriggerOptionDefinitions> | undefined>;
1170
+ }>, ctx: TriggerContext) => Promise<RegisterFunctionOutput$1<TTriggerOptionDefinitions> | undefined>;
842
1171
  type HandlerEvent<TChannel extends ChannelNames, TParams extends any = any> = {
843
1172
  rawEvent: ExternalSourceChannelMap[TChannel]["event"];
844
1173
  source: Prettify<Omit<HandleTriggerSource, "params"> & {
@@ -850,18 +1179,18 @@ type HandlerFunction<TChannel extends ChannelNames, TParams extends any, TTrigge
850
1179
  response?: NormalizedResponse;
851
1180
  metadata?: HttpSourceResponseMetadata;
852
1181
  } | void>;
853
- type KeyFunction<TParams extends any> = (params: TParams) => string;
854
- 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;
855
1184
  type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
856
1185
  id: string;
857
1186
  version: string;
858
1187
  schema: SchemaParser<TParams>;
859
1188
  optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
860
1189
  integration: TIntegration;
861
- register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
862
- filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
1190
+ register: RegisterFunction$1<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
1191
+ filter?: FilterFunction$1<TParams, TTriggerOptionDefinitions>;
863
1192
  handler: HandlerFunction<TChannel, TParams, TIntegration>;
864
- key: KeyFunction<TParams>;
1193
+ key: KeyFunction$1<TParams>;
865
1194
  properties?: (params: TParams) => DisplayProperty[];
866
1195
  };
867
1196
  declare class ExternalSource<TIntegration extends TriggerIntegration, TParams extends any, TChannel extends ChannelNames = ChannelNames, TTriggerOptionDefinitions extends Record<string, string[]> = any> {
@@ -876,6 +1205,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
876
1205
  id?: string | undefined;
877
1206
  timestamp?: Date | undefined;
878
1207
  source?: string | undefined;
1208
+ payloadType?: "JSON" | "REQUEST" | undefined;
879
1209
  }[];
880
1210
  response?: {
881
1211
  status: number;
@@ -886,7 +1216,7 @@ declare class ExternalSource<TIntegration extends TriggerIntegration, TParams ex
886
1216
  }>;
887
1217
  filter(params: TParams, options?: TTriggerOptionDefinitions): EventFilter;
888
1218
  properties(params: TParams): DisplayProperty[];
889
- 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>;
890
1220
  key(params: TParams): string;
891
1221
  get integration(): TIntegration;
892
1222
  get integrationConfig(): {
@@ -914,6 +1244,9 @@ declare class ExternalSourceTrigger<TEventSpecification extends EventSpecificati
914
1244
  toJSON(): TriggerMetadata;
915
1245
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
916
1246
  get preprocessRuns(): boolean;
1247
+ verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<{
1248
+ success: true;
1249
+ }>;
917
1250
  }
918
1251
  declare function omit<T extends Record<string, unknown>, K extends keyof T>(obj: T, key: K): {
919
1252
  result: Omit<T, K>;
@@ -966,6 +1299,9 @@ declare class DynamicTrigger<TEventSpec extends EventSpecification<any>, TExtern
966
1299
  }): Promise<RegisterSourceEventV2>;
967
1300
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpec>, any>): void;
968
1301
  get preprocessRuns(): boolean;
1302
+ verifyPayload(payload: ReturnType<TEventSpec["parsePayload"]>): Promise<{
1303
+ success: true;
1304
+ }>;
969
1305
  }
970
1306
 
971
1307
  type ScheduledEventSpecification = EventSpecification<ScheduledPayload>;
@@ -997,6 +1333,9 @@ declare class IntervalTrigger implements Trigger<ScheduledEventSpecification> {
997
1333
  };
998
1334
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
999
1335
  get preprocessRuns(): boolean;
1336
+ verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1337
+ success: true;
1338
+ }>;
1000
1339
  toJSON(): TriggerMetadata;
1001
1340
  }
1002
1341
  /** `intervalTrigger()` is set as a [Job's trigger](/sdk/job) to trigger a Job at a recurring interval.
@@ -1031,6 +1370,9 @@ declare class CronTrigger implements Trigger<ScheduledEventSpecification> {
1031
1370
  };
1032
1371
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1033
1372
  get preprocessRuns(): boolean;
1373
+ verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1374
+ success: true;
1375
+ }>;
1034
1376
  toJSON(): TriggerMetadata;
1035
1377
  }
1036
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.
@@ -1097,9 +1439,147 @@ declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
1097
1439
  }>;
1098
1440
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<ScheduledEventSpecification>, any>): void;
1099
1441
  get preprocessRuns(): boolean;
1442
+ verifyPayload(payload: ReturnType<ScheduledEventSpecification["parsePayload"]>): Promise<{
1443
+ success: true;
1444
+ }>;
1100
1445
  toJSON(): TriggerMetadata;
1101
1446
  }
1102
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
+
1103
1583
  type TriggerClientOptions = {
1104
1584
  /** The `id` property is used to uniquely identify the client.
1105
1585
  */
@@ -1130,11 +1610,20 @@ declare class TriggerClient {
1130
1610
  #private;
1131
1611
  id: string;
1132
1612
  constructor(options: Prettify<TriggerClientOptions>);
1613
+ on: <E extends keyof NotificationEvents>(event: E, listener: NotificationEvents[E]) => NotificationsEventEmitter;
1133
1614
  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>;
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>;
1135
1616
  defineAuthResolver(integration: TriggerIntegration, resolver: TriggerAuthResolver): TriggerClient;
1136
1617
  defineDynamicSchedule(options: DynamicIntervalOptions): DynamicSchedule;
1137
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;
1138
1627
  attach(job: Job<Trigger<any>, any>): void;
1139
1628
  attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
1140
1629
  attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
@@ -1147,6 +1636,13 @@ declare class TriggerClient {
1147
1636
  }): void;
1148
1637
  attachDynamicSchedule(key: string): void;
1149
1638
  attachDynamicScheduleToJob(key: string, job: Job<Trigger<any>, any>): void;
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;
1150
1646
  registerTrigger(id: string, key: string, options: RegisterTriggerBodyV2, idempotencyKey?: string): Promise<{
1151
1647
  id: string;
1152
1648
  options: {
@@ -1203,6 +1699,25 @@ declare class TriggerClient {
1203
1699
  deliveredAt?: Date | null | undefined;
1204
1700
  cancelledAt?: Date | null | undefined;
1205
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
+ }[]>;
1206
1721
  cancelEvent(eventId: string): Promise<{
1207
1722
  id: string;
1208
1723
  name: string;
@@ -1261,7 +1776,7 @@ declare class TriggerClient {
1261
1776
  updatedAt: Date;
1262
1777
  runs: {
1263
1778
  id: string;
1264
- 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";
1265
1780
  startedAt?: Date | null | undefined;
1266
1781
  completedAt?: Date | null | undefined;
1267
1782
  }[];
@@ -1271,7 +1786,7 @@ declare class TriggerClient {
1271
1786
  id: string;
1272
1787
  startedAt: Date | null;
1273
1788
  completedAt: Date | null;
1274
- 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";
1275
1790
  updatedAt: Date | null;
1276
1791
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1277
1792
  statuses: {
@@ -1292,7 +1807,7 @@ declare class TriggerClient {
1292
1807
  id: string;
1293
1808
  startedAt: Date | null;
1294
1809
  completedAt: Date | null;
1295
- 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";
1296
1811
  updatedAt: Date | null;
1297
1812
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1298
1813
  statuses: {
@@ -1314,7 +1829,7 @@ declare class TriggerClient {
1314
1829
  id: string;
1315
1830
  startedAt: Date | null;
1316
1831
  completedAt: Date | null;
1317
- 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";
1318
1833
  updatedAt: Date | null;
1319
1834
  }[];
1320
1835
  nextCursor?: string | undefined;
@@ -1333,34 +1848,27 @@ declare class TriggerClient {
1333
1848
  }[];
1334
1849
  run: {
1335
1850
  id: string;
1336
- 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";
1337
1852
  output?: any;
1338
1853
  };
1339
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
+ };
1340
1864
  authorized(apiKey?: string | null): "authorized" | "unauthorized" | "missing-client" | "missing-header";
1341
1865
  apiKey(): string | undefined;
1342
1866
  }
1343
1867
 
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;
1355
- }[];
1356
- data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1357
- state?: "loading" | "success" | "failure" | undefined;
1358
- }>;
1359
- }
1360
-
1361
1868
  type IOTask = ServerTask;
1362
1869
  type IOOptions = {
1363
1870
  id: string;
1871
+ jobId: string;
1364
1872
  apiClient: ApiClient;
1365
1873
  client: TriggerClient;
1366
1874
  context: TriggerContext;
@@ -1397,9 +1905,23 @@ type IOStats = {
1397
1905
  noopCachedTaskHits: number;
1398
1906
  noopCachedTaskMisses: number;
1399
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
+ };
1400
1921
  declare class IO {
1401
1922
  #private;
1402
1923
  private _id;
1924
+ private _jobId;
1403
1925
  private _apiClient;
1404
1926
  private _triggerClient;
1405
1927
  private _logger;
@@ -1415,15 +1937,63 @@ declare class IO {
1415
1937
  private _serverVersion;
1416
1938
  private _timeOrigin;
1417
1939
  private _executionTimeout?;
1940
+ private _outputSerializer;
1941
+ private _visitedCacheKeys;
1942
+ private _envStore;
1943
+ private _jobStore;
1944
+ private _runStore;
1418
1945
  get stats(): IOStats;
1419
1946
  constructor(options: IOOptions);
1420
1947
  /** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
1421
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>;
1422
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.
1423
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.
1424
1962
  * @param seconds The number of seconds to wait. This can be very long, serverless timeouts are not an issue.
1425
1963
  */
1426
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>;
1427
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
1428
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.
1429
1999
  * @param initialStatus The initial status you want this status to have. You can update it during the rub using the returned object.
@@ -1468,8 +2038,60 @@ declare class IO {
1468
2038
  * - Ranges: 500-599
1469
2039
  * - Wildcards: 2xx, 3xx, 4xx, 5xx
1470
2040
  */
1471
- backgroundFetch<TResponseData>(cacheKey: string | any[], url: string, requestInit?: FetchRequestInit, retry?: FetchRetryOptions): Promise<TResponseData>;
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).
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).
1473
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.
1474
2096
  * @param event The event to send. The event name must match the name of the event that your Jobs are listening for.
1475
2097
  * @param options Options for sending the event.
@@ -1488,13 +2110,32 @@ declare class IO {
1488
2110
  deliveredAt?: Date | null | undefined;
1489
2111
  cancelledAt?: Date | null | undefined;
1490
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
+ }[]>;
1491
2132
  getEvent(cacheKey: string | any[], id: string): Promise<{
1492
2133
  id: string;
1493
2134
  name: string;
1494
2135
  updatedAt: Date;
1495
2136
  runs: {
1496
2137
  id: string;
1497
- 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";
1498
2139
  startedAt?: Date | null | undefined;
1499
2140
  completedAt?: Date | null | undefined;
1500
2141
  }[];
@@ -1525,6 +2166,12 @@ declare class IO {
1525
2166
  id: string;
1526
2167
  key: string;
1527
2168
  }>;
2169
+ updateWebhook(cacheKey: string | any[], options: {
2170
+ key: string;
2171
+ } & UpdateWebhookBody): Promise<{
2172
+ id: string;
2173
+ key: string;
2174
+ }>;
1528
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.
1529
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.
1530
2177
  * @param dynamicSchedule The [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) to register a new schedule on.
@@ -1610,6 +2257,7 @@ declare class IO {
1610
2257
  key: string;
1611
2258
  } | undefined>;
1612
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>>;
1613
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.
1614
2262
  *
1615
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.
@@ -1618,7 +2266,9 @@ declare class IO {
1618
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.
1619
2267
  * @returns A Promise that resolves with the returned value of the callback.
1620
2268
  */
1621
- 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>;
1622
2272
  /**
1623
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.
1624
2274
  */
@@ -1627,13 +2277,18 @@ declare class IO {
1627
2277
  * `io.brb()` is an alias of `io.yield()`
1628
2278
  */
1629
2279
  brb: (cacheKey: string) => void;
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).
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).
1631
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.
1632
2282
  * @param tryCallback The code you wish to run
1633
2283
  * @param catchCallback Thhis will be called if the Task fails. The callback receives the error
1634
2284
  * @returns A Promise that resolves with the returned value or the error
1635
2285
  */
1636
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
+ };
1637
2292
  }
1638
2293
  type CallbackFunction = (level: "DEBUG" | "INFO" | "WARN" | "ERROR" | "LOG", message: string, properties?: Record<string, any>) => Promise<void>;
1639
2294
  declare class IOLogger implements TaskLogger {
@@ -1660,7 +2315,7 @@ interface TriggerIntegration {
1660
2315
  type IOWithIntegrations<TIntegrations extends Record<string, TriggerIntegration>> = IO & TIntegrations;
1661
2316
  type IntegrationTaskKey = string | any[];
1662
2317
 
1663
- 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> = {
1664
2319
  /** The `id` property is used to uniquely identify the Job. Only change this if you want to create a new Job. */
1665
2320
  id: string;
1666
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. */
@@ -1695,9 +2350,15 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
1695
2350
  });
1696
2351
  ``` */
1697
2352
  integrations?: TIntegrations;
1698
- /** @deprecated This property is deprecated and no longer effects the execution of the Job
1699
- * */
1700
- 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;
1701
2362
  /** The `enabled` property is used to enable or disable the Job. If you disable a Job, it will not run. */
1702
2363
  enabled?: boolean;
1703
2364
  /** This function gets called automatically when a Run is Triggered.
@@ -1706,19 +2367,22 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
1706
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.
1707
2368
  * @param context An object that contains information about the Organization, Job, Run and more.
1708
2369
  */
1709
- 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;
1710
2373
  };
1711
2374
  type JobPayload<TJob> = TJob extends Job<Trigger<EventSpecification<infer TEvent>>, any> ? TEvent : never;
1712
2375
  type JobIO<TJob> = TJob extends Job<any, infer TIntegrations> ? IOWithIntegrations<TIntegrations> : never;
1713
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. */
1714
- 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> {
1715
2378
  #private;
1716
- readonly options: JobOptions<TTrigger, TIntegrations>;
1717
- client: TriggerClient;
1718
- constructor(
1719
- /** An instance of [TriggerClient](/sdk/triggerclient) that is used to send events
1720
- to the Trigger API. */
1721
- 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): void;
1722
2386
  get id(): string;
1723
2387
  get enabled(): boolean;
1724
2388
  get name(): string;
@@ -1727,6 +2391,19 @@ declare class Job<TTrigger extends Trigger<EventSpecification<any>>, TIntegratio
1727
2391
  get logLevel(): LogLevel | undefined;
1728
2392
  get integrations(): Record<string, IntegrationConfig>;
1729
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>>>;
1730
2407
  }
1731
2408
 
1732
2409
  type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> = {
@@ -1734,6 +2411,7 @@ type EventTriggerOptions<TEventSpecification extends EventSpecification<any>> =
1734
2411
  name?: string | string[];
1735
2412
  source?: string;
1736
2413
  filter?: EventFilter;
2414
+ verify?: EventTypeFromSpecification<TEventSpecification> extends Request ? VerifyCallback : never;
1737
2415
  };
1738
2416
  declare class EventTrigger<TEventSpecification extends EventSpecification<any>> implements Trigger<TEventSpecification> {
1739
2417
  #private;
@@ -1742,6 +2420,7 @@ declare class EventTrigger<TEventSpecification extends EventSpecification<any>>
1742
2420
  get event(): TEventSpecification;
1743
2421
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<TEventSpecification>, any>): void;
1744
2422
  get preprocessRuns(): boolean;
2423
+ verifyPayload(payload: ReturnType<TEventSpecification["parsePayload"]>): Promise<VerifyResult>;
1745
2424
  }
1746
2425
  /** Configuration options for an EventTrigger */
1747
2426
  type TriggerOptions<TEvent> = {
@@ -1828,6 +2507,9 @@ declare class MissingConnectionNotification implements Trigger<MissingConnection
1828
2507
  };
1829
2508
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<MissingConnectionNotificationSpecification>, any>): void;
1830
2509
  get preprocessRuns(): boolean;
2510
+ verifyPayload(payload: ReturnType<MissingConnectionNotificationSpecification["parsePayload"]>): Promise<{
2511
+ success: true;
2512
+ }>;
1831
2513
  toJSON(): TriggerMetadata;
1832
2514
  }
1833
2515
  type MissingConnectionResolvedNotificationSpecification = EventSpecification<MissingConnectionResolvedNotificationPayload>;
@@ -1877,13 +2559,74 @@ declare class MissingConnectionResolvedNotification implements Trigger<MissingCo
1877
2559
  };
1878
2560
  attachToJob(triggerClient: TriggerClient, job: Job<Trigger<MissingConnectionResolvedNotificationSpecification>, any>): void;
1879
2561
  get preprocessRuns(): boolean;
2562
+ verifyPayload(payload: ReturnType<MissingConnectionResolvedNotificationSpecification["parsePayload"]>): Promise<{
2563
+ success: true;
2564
+ }>;
1880
2565
  toJSON(): TriggerMetadata;
1881
2566
  }
1882
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
+
1883
2621
  declare class ResumeWithTaskError {
1884
2622
  task: ServerTask;
1885
2623
  constructor(task: ServerTask);
1886
2624
  }
2625
+ declare class ResumeWithParallelTaskError {
2626
+ task: ServerTask;
2627
+ childErrors: Array<TriggerInternalError>;
2628
+ constructor(task: ServerTask, childErrors: Array<TriggerInternalError>);
2629
+ }
1887
2630
  declare class RetryWithTaskError {
1888
2631
  cause: ErrorWithStack;
1889
2632
  task: ServerTask;
@@ -1907,25 +2650,26 @@ declare class AutoYieldExecutionError {
1907
2650
  declare class AutoYieldWithCompletedTaskExecutionError {
1908
2651
  id: string;
1909
2652
  properties: DisplayProperty[] | undefined;
1910
- output: any;
1911
2653
  data: {
1912
2654
  location: string;
1913
2655
  timeRemaining: number;
1914
2656
  timeElapsed: number;
1915
2657
  };
1916
- constructor(id: string, properties: DisplayProperty[] | undefined, output: any, data: {
2658
+ output?: string | undefined;
2659
+ constructor(id: string, properties: DisplayProperty[] | undefined, data: {
1917
2660
  location: string;
1918
2661
  timeRemaining: number;
1919
2662
  timeElapsed: number;
1920
- });
2663
+ }, output?: string | undefined);
1921
2664
  }
2665
+ type TriggerInternalError = ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError | ResumeWithParallelTaskError;
1922
2666
  /** Use this function if you're using a `try/catch` block to catch errors.
1923
2667
  * It checks if a thrown error is a special internal error that you should ignore.
1924
2668
  * If this returns `true` then you must rethrow the error: `throw err;`
1925
2669
  * @param err The error to check
1926
2670
  * @returns `true` if the error is a Trigger Error, `false` otherwise.
1927
2671
  */
1928
- declare function isTriggerError(err: unknown): err is ResumeWithTaskError | RetryWithTaskError | CanceledWithTaskError | YieldExecutionError | AutoYieldExecutionError | AutoYieldWithCompletedTaskExecutionError;
2672
+ declare function isTriggerError(err: unknown): err is TriggerInternalError;
1929
2673
 
1930
2674
  declare const retry: {
1931
2675
  readonly standardBackoff: {
@@ -1935,6 +2679,13 @@ declare const retry: {
1935
2679
  readonly maxTimeoutInMs: 30000;
1936
2680
  readonly randomize: true;
1937
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
+ };
1938
2689
  };
1939
2690
 
1940
2691
  type Task = ServerTask;
@@ -1942,4 +2693,4 @@ type Task = ServerTask;
1942
2693
  type SentEvent = ApiEventLog;
1943
2694
  declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
1944
2695
 
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 };
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 };