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

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