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

Function createTask

experiments/with-separate-zod-task.ts:227–259  ·  view source on GitHub ↗
(
  params: TaskOptions<TPayloadIn, TPayloadOut, TOutput, TContext, TIndentifier>
)

Source from the content-addressed store, hash-verified

225}
226
227export function createTask<
228 TPayloadIn,
229 TPayloadOut,
230 TOutput,
231 TContext extends object,
232 TIndentifier extends string,
233>(
234 params: TaskOptions<TPayloadIn, TPayloadOut, TOutput, TContext, TIndentifier>
235): Task<TPayloadIn, TPayloadOut, TOutput, TIndentifier> {
236 const task: Task<TPayloadIn, TPayloadOut, TOutput, TIndentifier> = {
237 id: params.id,
238 trigger: async (payload, options) => {
239 return {
240 id: "run_1234",
241 };
242 },
243 triggerAndWait: async (payload, options) => {
244 const output = await params.run({
245 meta: { run: "run_1234" },
246 payload: payload as unknown as inferTaskPayloadOut<TPayloadIn, TPayloadOut>,
247 ctx: {} as TContext,
248 });
249
250 return {
251 ok: true,
252 id: "run_1234",
253 output,
254 };
255 },
256 };
257
258 return task;
259}
260
261export type ZodTaskOptions<
262 TOutput,

Callers 3

taskFunction · 0.70
zodTaskFunction · 0.70
valibotTaskFunction · 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…