@trigger.dev/sdk 0.0.0-prerelease-20230922203841 → 0.0.0-prerelease-20231005170730

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
@@ -21,7 +21,320 @@ declare class ApiClient {
21
21
  url: string;
22
22
  name: string;
23
23
  }): Promise<EndpointRecord>;
24
- runTask(runId: string, task: RunTaskBodyInput): Promise<{
24
+ runTask(runId: string, task: RunTaskBodyInput, options?: {
25
+ cachedTasksCursor?: string;
26
+ }): Promise<VersionedResponseBody<{
27
+ "2023-09-29": z.ZodObject<{
28
+ task: z.ZodObject<{
29
+ id: z.ZodString;
30
+ name: z.ZodString;
31
+ icon: z.ZodNullable<z.ZodOptional<z.ZodString>>;
32
+ noop: z.ZodBoolean;
33
+ startedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
34
+ completedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
35
+ delayUntil: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
36
+ status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
37
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
38
+ params: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
39
+ properties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
40
+ label: z.ZodString;
41
+ text: z.ZodString;
42
+ url: z.ZodOptional<z.ZodString>;
43
+ }, "strip", z.ZodTypeAny, {
44
+ label: string;
45
+ text: string;
46
+ url?: string | undefined;
47
+ }, {
48
+ label: string;
49
+ text: string;
50
+ url?: string | undefined;
51
+ }>, "many">>>;
52
+ outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
53
+ label: z.ZodString;
54
+ text: z.ZodString;
55
+ url: z.ZodOptional<z.ZodString>;
56
+ }, "strip", z.ZodTypeAny, {
57
+ label: string;
58
+ text: string;
59
+ url?: string | undefined;
60
+ }, {
61
+ label: string;
62
+ text: string;
63
+ url?: string | undefined;
64
+ }>, "many">>>;
65
+ output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
66
+ error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
67
+ parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
68
+ style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
69
+ style: z.ZodEnum<["normal", "minimal"]>;
70
+ variant: z.ZodOptional<z.ZodString>;
71
+ }, "strip", z.ZodTypeAny, {
72
+ style: "normal" | "minimal";
73
+ variant?: string | undefined;
74
+ }, {
75
+ style: "normal" | "minimal";
76
+ variant?: string | undefined;
77
+ }>>>;
78
+ operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
79
+ callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
80
+ idempotencyKey: z.ZodString;
81
+ attempts: z.ZodNumber;
82
+ }, "strip", z.ZodTypeAny, {
83
+ id: string;
84
+ name: string;
85
+ noop: boolean;
86
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
87
+ idempotencyKey: string;
88
+ attempts: number;
89
+ icon?: string | null | undefined;
90
+ startedAt?: Date | null | undefined;
91
+ completedAt?: Date | null | undefined;
92
+ delayUntil?: Date | null | undefined;
93
+ description?: string | null | undefined;
94
+ params?: _trigger_dev_core.DeserializedJson | undefined;
95
+ properties?: {
96
+ label: string;
97
+ text: string;
98
+ url?: string | undefined;
99
+ }[] | null | undefined;
100
+ outputProperties?: {
101
+ label: string;
102
+ text: string;
103
+ url?: string | undefined;
104
+ }[] | null | undefined;
105
+ output?: _trigger_dev_core.DeserializedJson | undefined;
106
+ error?: string | null | undefined;
107
+ parentId?: string | null | undefined;
108
+ style?: {
109
+ style: "normal" | "minimal";
110
+ variant?: string | undefined;
111
+ } | null | undefined;
112
+ operation?: string | null | undefined;
113
+ callbackUrl?: string | null | undefined;
114
+ }, {
115
+ id: string;
116
+ name: string;
117
+ noop: boolean;
118
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
119
+ idempotencyKey: string;
120
+ attempts: number;
121
+ icon?: string | null | undefined;
122
+ startedAt?: Date | null | undefined;
123
+ completedAt?: Date | null | undefined;
124
+ delayUntil?: Date | null | undefined;
125
+ description?: string | null | undefined;
126
+ params?: _trigger_dev_core.DeserializedJson | undefined;
127
+ properties?: {
128
+ label: string;
129
+ text: string;
130
+ url?: string | undefined;
131
+ }[] | null | undefined;
132
+ outputProperties?: {
133
+ label: string;
134
+ text: string;
135
+ url?: string | undefined;
136
+ }[] | null | undefined;
137
+ output?: _trigger_dev_core.DeserializedJson | undefined;
138
+ error?: string | null | undefined;
139
+ parentId?: string | null | undefined;
140
+ style?: {
141
+ style: "normal" | "minimal";
142
+ variant?: string | undefined;
143
+ } | null | undefined;
144
+ operation?: string | null | undefined;
145
+ callbackUrl?: string | null | undefined;
146
+ }>;
147
+ cachedTasks: z.ZodOptional<z.ZodObject<{
148
+ tasks: z.ZodArray<z.ZodObject<{
149
+ id: z.ZodString;
150
+ idempotencyKey: z.ZodString;
151
+ status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
152
+ noop: z.ZodDefault<z.ZodBoolean>;
153
+ output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
154
+ parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
155
+ }, "strip", z.ZodTypeAny, {
156
+ id: string;
157
+ noop: boolean;
158
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
159
+ idempotencyKey: string;
160
+ output?: _trigger_dev_core.DeserializedJson | undefined;
161
+ parentId?: string | null | undefined;
162
+ }, {
163
+ id: string;
164
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
165
+ idempotencyKey: string;
166
+ noop?: boolean | undefined;
167
+ output?: _trigger_dev_core.DeserializedJson | undefined;
168
+ parentId?: string | null | undefined;
169
+ }>, "many">;
170
+ cursor: z.ZodOptional<z.ZodString>;
171
+ }, "strip", z.ZodTypeAny, {
172
+ tasks: {
173
+ id: string;
174
+ noop: boolean;
175
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
176
+ idempotencyKey: string;
177
+ output?: _trigger_dev_core.DeserializedJson | undefined;
178
+ parentId?: string | null | undefined;
179
+ }[];
180
+ cursor?: string | undefined;
181
+ }, {
182
+ tasks: {
183
+ id: string;
184
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
185
+ idempotencyKey: string;
186
+ noop?: boolean | undefined;
187
+ output?: _trigger_dev_core.DeserializedJson | undefined;
188
+ parentId?: string | null | undefined;
189
+ }[];
190
+ cursor?: string | undefined;
191
+ }>>;
192
+ }, "strip", z.ZodTypeAny, {
193
+ task: {
194
+ id: string;
195
+ name: string;
196
+ noop: boolean;
197
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
198
+ idempotencyKey: string;
199
+ attempts: number;
200
+ icon?: string | null | undefined;
201
+ startedAt?: Date | null | undefined;
202
+ completedAt?: Date | null | undefined;
203
+ delayUntil?: Date | null | undefined;
204
+ description?: string | null | undefined;
205
+ params?: _trigger_dev_core.DeserializedJson | undefined;
206
+ properties?: {
207
+ label: string;
208
+ text: string;
209
+ url?: string | undefined;
210
+ }[] | null | undefined;
211
+ outputProperties?: {
212
+ label: string;
213
+ text: string;
214
+ url?: string | undefined;
215
+ }[] | null | undefined;
216
+ output?: _trigger_dev_core.DeserializedJson | undefined;
217
+ error?: string | null | undefined;
218
+ parentId?: string | null | undefined;
219
+ style?: {
220
+ style: "normal" | "minimal";
221
+ variant?: string | undefined;
222
+ } | null | undefined;
223
+ operation?: string | null | undefined;
224
+ callbackUrl?: string | null | undefined;
225
+ };
226
+ cachedTasks?: {
227
+ tasks: {
228
+ id: string;
229
+ noop: boolean;
230
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
231
+ idempotencyKey: string;
232
+ output?: _trigger_dev_core.DeserializedJson | undefined;
233
+ parentId?: string | null | undefined;
234
+ }[];
235
+ cursor?: string | undefined;
236
+ } | undefined;
237
+ }, {
238
+ task: {
239
+ id: string;
240
+ name: string;
241
+ noop: boolean;
242
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
243
+ idempotencyKey: string;
244
+ attempts: number;
245
+ icon?: string | null | undefined;
246
+ startedAt?: Date | null | undefined;
247
+ completedAt?: Date | null | undefined;
248
+ delayUntil?: Date | null | undefined;
249
+ description?: string | null | undefined;
250
+ params?: _trigger_dev_core.DeserializedJson | undefined;
251
+ properties?: {
252
+ label: string;
253
+ text: string;
254
+ url?: string | undefined;
255
+ }[] | null | undefined;
256
+ outputProperties?: {
257
+ label: string;
258
+ text: string;
259
+ url?: string | undefined;
260
+ }[] | null | undefined;
261
+ output?: _trigger_dev_core.DeserializedJson | undefined;
262
+ error?: string | null | undefined;
263
+ parentId?: string | null | undefined;
264
+ style?: {
265
+ style: "normal" | "minimal";
266
+ variant?: string | undefined;
267
+ } | null | undefined;
268
+ operation?: string | null | undefined;
269
+ callbackUrl?: string | null | undefined;
270
+ };
271
+ cachedTasks?: {
272
+ tasks: {
273
+ id: string;
274
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
275
+ idempotencyKey: string;
276
+ noop?: boolean | undefined;
277
+ output?: _trigger_dev_core.DeserializedJson | undefined;
278
+ parentId?: string | null | undefined;
279
+ }[];
280
+ cursor?: string | undefined;
281
+ } | undefined;
282
+ }>;
283
+ }, z.ZodObject<{
284
+ id: z.ZodString;
285
+ name: z.ZodString;
286
+ icon: z.ZodNullable<z.ZodOptional<z.ZodString>>;
287
+ noop: z.ZodBoolean;
288
+ startedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
289
+ completedAt: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
290
+ delayUntil: z.ZodNullable<z.ZodOptional<z.ZodDate>>;
291
+ status: z.ZodEnum<["PENDING", "WAITING", "RUNNING", "COMPLETED", "ERRORED", "CANCELED"]>;
292
+ description: z.ZodNullable<z.ZodOptional<z.ZodString>>;
293
+ params: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
294
+ properties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
295
+ label: z.ZodString;
296
+ text: z.ZodString;
297
+ url: z.ZodOptional<z.ZodString>;
298
+ }, "strip", z.ZodTypeAny, {
299
+ label: string;
300
+ text: string;
301
+ url?: string | undefined;
302
+ }, {
303
+ label: string;
304
+ text: string;
305
+ url?: string | undefined;
306
+ }>, "many">>>;
307
+ outputProperties: z.ZodNullable<z.ZodOptional<z.ZodArray<z.ZodObject<{
308
+ label: z.ZodString;
309
+ text: z.ZodString;
310
+ url: z.ZodOptional<z.ZodString>;
311
+ }, "strip", z.ZodTypeAny, {
312
+ label: string;
313
+ text: string;
314
+ url?: string | undefined;
315
+ }, {
316
+ label: string;
317
+ text: string;
318
+ url?: string | undefined;
319
+ }>, "many">>>;
320
+ output: z.ZodNullable<z.ZodOptional<z.ZodType<_trigger_dev_core.DeserializedJson, z.ZodTypeDef, _trigger_dev_core.DeserializedJson>>>;
321
+ error: z.ZodNullable<z.ZodOptional<z.ZodString>>;
322
+ parentId: z.ZodNullable<z.ZodOptional<z.ZodString>>;
323
+ style: z.ZodNullable<z.ZodOptional<z.ZodObject<{
324
+ style: z.ZodEnum<["normal", "minimal"]>;
325
+ variant: z.ZodOptional<z.ZodString>;
326
+ }, "strip", z.ZodTypeAny, {
327
+ style: "normal" | "minimal";
328
+ variant?: string | undefined;
329
+ }, {
330
+ style: "normal" | "minimal";
331
+ variant?: string | undefined;
332
+ }>>>;
333
+ operation: z.ZodNullable<z.ZodOptional<z.ZodString>>;
334
+ callbackUrl: z.ZodNullable<z.ZodOptional<z.ZodString>>;
335
+ idempotencyKey: z.ZodString;
336
+ attempts: z.ZodNumber;
337
+ }, "strip", z.ZodTypeAny, {
25
338
  id: string;
26
339
  name: string;
27
340
  noop: boolean;
@@ -52,7 +365,40 @@ declare class ApiClient {
52
365
  variant?: string | undefined;
53
366
  } | null | undefined;
54
367
  operation?: string | null | undefined;
55
- }>;
368
+ callbackUrl?: string | null | undefined;
369
+ }, {
370
+ id: string;
371
+ name: string;
372
+ noop: boolean;
373
+ status: "PENDING" | "WAITING" | "RUNNING" | "COMPLETED" | "ERRORED" | "CANCELED";
374
+ idempotencyKey: string;
375
+ attempts: number;
376
+ icon?: string | null | undefined;
377
+ startedAt?: Date | null | undefined;
378
+ completedAt?: Date | null | undefined;
379
+ delayUntil?: Date | null | undefined;
380
+ description?: string | null | undefined;
381
+ params?: _trigger_dev_core.DeserializedJson | undefined;
382
+ properties?: {
383
+ label: string;
384
+ text: string;
385
+ url?: string | undefined;
386
+ }[] | null | undefined;
387
+ outputProperties?: {
388
+ label: string;
389
+ text: string;
390
+ url?: string | undefined;
391
+ }[] | null | undefined;
392
+ output?: _trigger_dev_core.DeserializedJson | undefined;
393
+ error?: string | null | undefined;
394
+ parentId?: string | null | undefined;
395
+ style?: {
396
+ style: "normal" | "minimal";
397
+ variant?: string | undefined;
398
+ } | null | undefined;
399
+ operation?: string | null | undefined;
400
+ callbackUrl?: string | null | undefined;
401
+ }>>>;
56
402
  completeTask(runId: string, id: string, task: CompleteTaskBodyInput): Promise<{
57
403
  id: string;
58
404
  name: string;
@@ -84,6 +430,7 @@ declare class ApiClient {
84
430
  variant?: string | undefined;
85
431
  } | null | undefined;
86
432
  operation?: string | null | undefined;
433
+ callbackUrl?: string | null | undefined;
87
434
  }>;
88
435
  failTask(runId: string, id: string, body: FailTaskBodyInput): Promise<{
89
436
  id: string;
@@ -116,6 +463,7 @@ declare class ApiClient {
116
463
  variant?: string | undefined;
117
464
  } | null | undefined;
118
465
  operation?: string | null | undefined;
466
+ callbackUrl?: string | null | undefined;
119
467
  }>;
120
468
  sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
121
469
  id: string;
@@ -193,7 +541,7 @@ declare class ApiClient {
193
541
  updatedAt: Date;
194
542
  runs: {
195
543
  id: string;
196
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
544
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
197
545
  startedAt?: Date | null | undefined;
198
546
  completedAt?: Date | null | undefined;
199
547
  }[];
@@ -203,11 +551,31 @@ declare class ApiClient {
203
551
  id: string;
204
552
  startedAt: Date | null;
205
553
  completedAt: Date | null;
206
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
554
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
207
555
  updatedAt: Date | null;
208
556
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
557
+ statuses: {
558
+ label: string;
559
+ key: string;
560
+ history: {
561
+ label?: string | undefined;
562
+ state?: "loading" | "success" | "failure" | undefined;
563
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
564
+ }[];
565
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
566
+ state?: "loading" | "success" | "failure" | undefined;
567
+ }[];
209
568
  output?: any;
210
- statuses?: {
569
+ nextCursor?: string | undefined;
570
+ }>;
571
+ cancelRun(runId: string): Promise<{
572
+ id: string;
573
+ startedAt: Date | null;
574
+ completedAt: Date | null;
575
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
576
+ updatedAt: Date | null;
577
+ tasks: _trigger_dev_core.RunTaskWithSubtasks[];
578
+ statuses: {
211
579
  label: string;
212
580
  key: string;
213
581
  history: {
@@ -217,7 +585,8 @@ declare class ApiClient {
217
585
  }[];
218
586
  data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
219
587
  state?: "loading" | "success" | "failure" | undefined;
220
- }[] | undefined;
588
+ }[];
589
+ output?: any;
221
590
  nextCursor?: string | undefined;
222
591
  }>;
223
592
  getRunStatuses(runId: string): Promise<{
@@ -234,7 +603,7 @@ declare class ApiClient {
234
603
  }[];
235
604
  run: {
236
605
  id: string;
237
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
606
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
238
607
  output?: any;
239
608
  };
240
609
  }>;
@@ -243,12 +612,24 @@ declare class ApiClient {
243
612
  id: string;
244
613
  startedAt: Date | null;
245
614
  completedAt: Date | null;
246
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
615
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
247
616
  updatedAt: Date | null;
248
617
  }[];
249
618
  nextCursor?: string | undefined;
250
619
  }>;
251
620
  }
621
+ type VersionedResponseBodyMap = {
622
+ [key: string]: z.ZodTypeAny;
623
+ };
624
+ type VersionedResponseBody<TVersions extends VersionedResponseBodyMap, TUnversioned extends z.ZodTypeAny> = {
625
+ [TVersion in keyof TVersions]: {
626
+ version: TVersion;
627
+ body: z.infer<TVersions[TVersion]>;
628
+ };
629
+ }[keyof TVersions] | {
630
+ version: "unversioned";
631
+ body: z.infer<TUnversioned>;
632
+ };
252
633
 
253
634
  interface TriggerContext {
254
635
  /** Job metadata */
@@ -360,6 +741,22 @@ interface EventSpecification<TEvent extends any> {
360
741
  runProperties?: (payload: TEvent) => DisplayProperty[];
361
742
  }
362
743
  type EventTypeFromSpecification<TEventSpec extends EventSpecification<any>> = TEventSpec extends EventSpecification<infer TEvent> ? TEvent : never;
744
+ type SchemaParserIssue = {
745
+ path: PropertyKey[];
746
+ message: string;
747
+ };
748
+ type SchemaParserResult<T> = {
749
+ success: true;
750
+ data: T;
751
+ } | {
752
+ success: false;
753
+ error: {
754
+ issues: SchemaParserIssue[];
755
+ };
756
+ };
757
+ type SchemaParser<T extends unknown = unknown> = {
758
+ safeParse: (a: unknown) => SchemaParserResult<T>;
759
+ };
363
760
 
364
761
  type HttpSourceEvent = {
365
762
  url: string;
@@ -444,8 +841,8 @@ type FilterFunction<TParams extends any, TTriggerOptionDefinitions extends Recor
444
841
  type ExternalSourceOptions<TChannel extends ChannelNames, TIntegration extends TriggerIntegration, TParams extends any, TTriggerOptionDefinitions extends Record<string, string[]> = any> = {
445
842
  id: string;
446
843
  version: string;
447
- schema: z.Schema<TParams>;
448
- optionSchema?: z.Schema<TTriggerOptionDefinitions>;
844
+ schema: SchemaParser<TParams>;
845
+ optionSchema?: SchemaParser<TTriggerOptionDefinitions>;
449
846
  integration: TIntegration;
450
847
  register: RegisterFunction<TIntegration, TParams, TChannel, TTriggerOptionDefinitions>;
451
848
  filter?: FilterFunction<TParams, TTriggerOptionDefinitions>;
@@ -773,7 +1170,7 @@ declare class TriggerClient {
773
1170
  scopes?: string[] | undefined;
774
1171
  additionalFields?: Record<string, string> | undefined;
775
1172
  } | undefined>;
776
- /** You can call this function from anywhere in your code to send an event. The other way to send an event is by using [`io.sendEvent()`](https://trigger.dev/docs/sdk/io/sendevent) from inside a `run()` function.
1173
+ /** You can call this function from anywhere in your backend to send an event. The other way to send an event is by using [`io.sendEvent()`](https://trigger.dev/docs/sdk/io/sendevent) from inside a `run()` function.
777
1174
  * @param event The event to send.
778
1175
  * @param options Options for sending the event.
779
1176
  * @returns A promise that resolves to the event details
@@ -846,7 +1243,7 @@ declare class TriggerClient {
846
1243
  updatedAt: Date;
847
1244
  runs: {
848
1245
  id: string;
849
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
1246
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
850
1247
  startedAt?: Date | null | undefined;
851
1248
  completedAt?: Date | null | undefined;
852
1249
  }[];
@@ -856,11 +1253,31 @@ declare class TriggerClient {
856
1253
  id: string;
857
1254
  startedAt: Date | null;
858
1255
  completedAt: Date | null;
859
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
1256
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
860
1257
  updatedAt: Date | null;
861
1258
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1259
+ statuses: {
1260
+ label: string;
1261
+ key: string;
1262
+ history: {
1263
+ label?: string | undefined;
1264
+ state?: "loading" | "success" | "failure" | undefined;
1265
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1266
+ }[];
1267
+ data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
1268
+ state?: "loading" | "success" | "failure" | undefined;
1269
+ }[];
862
1270
  output?: any;
863
- statuses?: {
1271
+ nextCursor?: string | undefined;
1272
+ }>;
1273
+ cancelRun(runId: string): Promise<{
1274
+ id: string;
1275
+ startedAt: Date | null;
1276
+ completedAt: Date | null;
1277
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1278
+ updatedAt: Date | null;
1279
+ tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1280
+ statuses: {
864
1281
  label: string;
865
1282
  key: string;
866
1283
  history: {
@@ -870,7 +1287,8 @@ declare class TriggerClient {
870
1287
  }[];
871
1288
  data?: Record<string, _trigger_dev_core.SerializableJson> | undefined;
872
1289
  state?: "loading" | "success" | "failure" | undefined;
873
- }[] | undefined;
1290
+ }[];
1291
+ output?: any;
874
1292
  nextCursor?: string | undefined;
875
1293
  }>;
876
1294
  getRuns(jobSlug: string, options?: GetRunsOptions): Promise<{
@@ -878,7 +1296,7 @@ declare class TriggerClient {
878
1296
  id: string;
879
1297
  startedAt: Date | null;
880
1298
  completedAt: Date | null;
881
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
1299
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
882
1300
  updatedAt: Date | null;
883
1301
  }[];
884
1302
  nextCursor?: string | undefined;
@@ -897,7 +1315,7 @@ declare class TriggerClient {
897
1315
  }[];
898
1316
  run: {
899
1317
  id: string;
900
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
1318
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
901
1319
  output?: any;
902
1320
  };
903
1321
  }>;
@@ -933,6 +1351,10 @@ type IOOptions = {
933
1351
  jobLogger?: Logger;
934
1352
  jobLogLevel: LogLevel;
935
1353
  cachedTasks?: Array<CachedTask>;
1354
+ cachedTasksCursor?: string;
1355
+ yieldedExecutions?: Array<string>;
1356
+ noopTasksSet?: string;
1357
+ serverVersion?: string | null;
936
1358
  };
937
1359
  type JsonPrimitive = string | number | boolean | null | undefined | Date | symbol;
938
1360
  type JsonArray = Json[];
@@ -946,6 +1368,15 @@ type RunTaskErrorCallback = (error: unknown, task: IOTask, io: IO) => {
946
1368
  jitter?: number;
947
1369
  skipRetrying?: boolean;
948
1370
  } | Error | undefined | void;
1371
+ type IOStats = {
1372
+ initialCachedTasks: number;
1373
+ lazyLoadedCachedTasks: number;
1374
+ executedTasks: number;
1375
+ cachedTaskHits: number;
1376
+ cachedTaskMisses: number;
1377
+ noopCachedTaskHits: number;
1378
+ noopCachedTaskMisses: number;
1379
+ };
949
1380
  declare class IO {
950
1381
  #private;
951
1382
  private _id;
@@ -956,7 +1387,13 @@ declare class IO {
956
1387
  private _jobLogLevel;
957
1388
  private _cachedTasks;
958
1389
  private _taskStorage;
1390
+ private _cachedTasksCursor?;
959
1391
  private _context;
1392
+ private _yieldedExecutions;
1393
+ private _noopTasksBloomFilter;
1394
+ private _stats;
1395
+ private _serverVersion;
1396
+ get stats(): IOStats;
960
1397
  constructor(options: IOOptions);
961
1398
  /** Used to send log messages to the [Run log](https://trigger.dev/docs/documentation/guides/viewing-runs). */
962
1399
  get logger(): IOLogger;
@@ -1035,7 +1472,7 @@ declare class IO {
1035
1472
  updatedAt: Date;
1036
1473
  runs: {
1037
1474
  id: string;
1038
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH";
1475
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1039
1476
  startedAt?: Date | null | undefined;
1040
1477
  completedAt?: Date | null | undefined;
1041
1478
  }[];
@@ -1160,6 +1597,14 @@ declare class IO {
1160
1597
  * @returns A Promise that resolves with the returned value of the callback.
1161
1598
  */
1162
1599
  runTask<T extends Json<T> | void>(key: string | any[], callback: (task: ServerTask, io: IO) => Promise<T>, options?: RunTaskOptions, onError?: RunTaskErrorCallback): Promise<T>;
1600
+ /**
1601
+ * `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.
1602
+ */
1603
+ yield(key: string): void;
1604
+ /**
1605
+ * `io.brb()` is an alias of `io.yield()`
1606
+ */
1607
+ brb: (key: string) => void;
1163
1608
  /** `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).
1164
1609
  * 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.
1165
1610
  * @param tryCallback The code you wish to run
@@ -1283,7 +1728,7 @@ type TriggerOptions<TEvent> = {
1283
1728
  /** A [Zod](https://trigger.dev/docs/documentation/guides/zod) schema that defines the shape of the event payload.
1284
1729
  * The default is `z.any()` which is `any`.
1285
1730
  * */
1286
- schema?: z.Schema<TEvent>;
1731
+ schema?: SchemaParser<TEvent>;
1287
1732
  /** You can use this to filter events based on the source. */
1288
1733
  source?: string;
1289
1734
  /** Used to filter which events trigger the Job
@@ -1450,4 +1895,4 @@ type Task = ServerTask;
1450
1895
  type SentEvent = ApiEventLog;
1451
1896
  declare function redactString(strings: TemplateStringsArray, ...interpolations: string[]): RedactString;
1452
1897
 
1453
- export { AuthResolverResult, CronTrigger, DynamicIntervalOptions, DynamicSchedule, DynamicTrigger, DynamicTriggerOptions, EventSpecification, EventSpecificationExample, EventTrigger, EventTypeFromSpecification, ExternalSource, ExternalSourceParams, ExternalSourceTrigger, ExternalSourceTriggerOptions, HandlerEvent, HttpSourceEvent, IO, IOLogger, IOOptions, IOTask, IOWithIntegrations, IntegrationTaskKey, IntervalTrigger, Job, JobIO, JobOptions, JobPayload, Json, MissingConnectionNotification, MissingConnectionResolvedNotification, PreprocessResults, RunTaskErrorCallback, SentEvent, Task, TaskLogger, Trigger, TriggerAuthResolver, TriggerClient, TriggerClientOptions, TriggerContext, TriggerEventType, TriggerIntegration, TriggerOptionRecord, TriggerPayload, TriggerPreprocessContext, cronTrigger, eventTrigger, intervalTrigger, isTriggerError, missingConnectionNotification, missingConnectionResolvedNotification, omit, redactString, retry };
1898
+ 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 };