MCPcopy Index your code
hub / github.com/triggerdotdev/trigger.dev / createTask

Function createTask

experiments/with-generic-parser.ts:209–240  ·  view source on GitHub ↗
(
  params: TaskOptions<TOutput, TContext, TIndentifier, TParser>
)

Source from the content-addressed store, hash-verified

207}
208
209export function createTask<
210 TOutput,
211 TContext extends object,
212 TIndentifier extends string,
213 TParser extends Parser | undefined = undefined,
214>(
215 params: TaskOptions<TOutput, TContext, TIndentifier, TParser>
216): Task<TOutput, TIndentifier, TParser> {
217 const task: Task<TOutput, TIndentifier, TParser> = {
218 id: params.id,
219 trigger: async (payload, options) => {
220 return {
221 id: "run_1234",
222 };
223 },
224 triggerAndWait: async (payload, options) => {
225 const output = await params.run({
226 meta: { run: "run_1234" },
227 payload: payload as unknown as inferParserOut<TParser>, // Actually do the parsing
228 ctx: {} as TContext,
229 });
230
231 return {
232 ok: true,
233 id: "run_1234",
234 output,
235 };
236 },
237 };
238
239 return task;
240}
241
242export interface TaskLibraryRecord {
243 [key: string]: AnyTask | TaskLibraryRecord;

Callers 1

taskFunction · 0.70

Calls 1

runMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…