-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathtasks.ts
More file actions
113 lines (105 loc) · 1.85 KB
/
tasks.ts
File metadata and controls
113 lines (105 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
import {
onStart,
onStartAttempt,
onFailure,
onSuccess,
onComplete,
onWait,
onResume,
onHandleError,
onCatchError,
middleware,
onCancel,
} from "./hooks.js";
import {
batchTrigger,
batchTriggerAndWait,
createTask,
createSchemaTask,
createToolTask,
SubtaskUnwrapError,
trigger,
triggerAndWait,
} from "./shared.js";
export { SubtaskUnwrapError };
import type {
AnyTask,
BatchItem,
BatchResult,
BatchRunHandle,
Queue,
RunHandle,
Task,
TaskIdentifier,
TaskOptions,
TaskOutput,
TaskPayload,
TriggerOptions,
TaskRunResult,
TaskFromIdentifier,
TaskWithSchemaOptions,
TaskSchema,
TaskWithSchema,
TaskOptionsWithSchema,
} from "./shared.js";
export type {
AnyTask,
BatchItem,
BatchResult,
BatchRunHandle,
Queue,
RunHandle,
Task,
TaskIdentifier,
TaskOptions,
TaskOutput,
TaskPayload,
TriggerOptions,
TaskRunResult,
TaskFromIdentifier,
TaskWithSchemaOptions,
TaskSchema,
TaskWithSchema,
TaskOptionsWithSchema,
};
export type * from "./hooks.js";
/** Creates a task that can be triggered
* @param options - Task options
* @example
*
* ```ts
* import { task } from "@trigger.dev/sdk/v3";
*
* export const helloWorld = task({
id: "hello-world",
* run: async (payload: { url: string }) => {
* return { hello: "world" };
* },
* });
*
* ```
*
* @returns A task that can be triggered
*/
export const task = createTask;
export const schemaTask = createSchemaTask;
export const toolTask = createToolTask;
export const tasks = {
trigger,
batchTrigger,
triggerAndWait,
batchTriggerAndWait,
/** @deprecated Use onStartAttempt instead */
onStart,
onStartAttempt,
onFailure,
onSuccess,
onComplete,
onWait,
onResume,
onCancel,
/** @deprecated Use catchError instead */
handleError: onHandleError,
catchError: onCatchError,
middleware,
};