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