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

Function createTask

experiments/context.ts:356–387  ·  view source on GitHub ↗
(
  params: TaskOptions<TOutput, TContext, TIndentifier, TParser>
)

Source from the content-addressed store, hash-verified

354}
355
356export function createTask<
357 TOutput,
358 TContext extends AnyContextBuilder,
359 TIndentifier extends string,
360 TParser extends Parser | undefined = undefined,
361>(
362 params: TaskOptions<TOutput, TContext, TIndentifier, TParser>
363): Task<TOutput, TIndentifier, TParser> {
364 const task: Task<TOutput, TIndentifier, TParser> = {
365 id: params.id,
366 trigger: async (payload, options) => {
367 return {
368 id: "run_1234",
369 };
370 },
371 triggerAndWait: async (payload, options) => {
372 const output = await params.run({
373 meta: { run: "run_1234" },
374 payload: payload as unknown as inferParserOut<TParser>, // Actually do the parsing
375 ctx: {} as inferContext<TContext>,
376 });
377
378 return {
379 ok: true,
380 id: "run_1234",
381 output,
382 };
383 },
384 };
385
386 return task;
387}
388
389export interface TaskLibraryRecord {
390 [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…