@trigger.dev/sdk 0.0.0-prerelease-20241119135607 → 0.0.0-prerelease-20241128131418

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.
Files changed (43) hide show
  1. package/dist/commonjs/apiClient.d.ts +53 -63
  2. package/dist/commonjs/io.d.ts +7 -19
  3. package/dist/commonjs/status.d.ts +1 -1
  4. package/dist/commonjs/triggerClient.d.ts +11 -21
  5. package/dist/commonjs/triggers/scheduled.d.ts +2 -2
  6. package/dist/commonjs/v3/batch.d.ts +28 -0
  7. package/dist/commonjs/v3/batch.js +52 -0
  8. package/dist/commonjs/v3/batch.js.map +1 -0
  9. package/dist/commonjs/v3/index.d.ts +2 -1
  10. package/dist/commonjs/v3/index.js +1 -0
  11. package/dist/commonjs/v3/index.js.map +1 -1
  12. package/dist/commonjs/v3/runs.d.ts +148 -58
  13. package/dist/commonjs/v3/runs.js +93 -0
  14. package/dist/commonjs/v3/runs.js.map +1 -1
  15. package/dist/commonjs/v3/shared.d.ts +300 -8
  16. package/dist/commonjs/v3/shared.js +618 -100
  17. package/dist/commonjs/v3/shared.js.map +1 -1
  18. package/dist/commonjs/v3/tasks.d.ts +2 -2
  19. package/dist/commonjs/v3/tasks.js.map +1 -1
  20. package/dist/commonjs/version.js +1 -1
  21. package/dist/esm/apiClient.d.ts +53 -63
  22. package/dist/esm/io.d.ts +7 -19
  23. package/dist/esm/status.d.ts +1 -1
  24. package/dist/esm/triggerClient.d.ts +9 -21
  25. package/dist/esm/triggers/invokeTrigger.d.ts +1 -1
  26. package/dist/esm/triggers/scheduled.d.ts +2 -2
  27. package/dist/esm/types.d.ts +2 -2
  28. package/dist/esm/v3/batch.d.ts +28 -0
  29. package/dist/esm/v3/batch.js +49 -0
  30. package/dist/esm/v3/batch.js.map +1 -0
  31. package/dist/esm/v3/index.d.ts +2 -1
  32. package/dist/esm/v3/index.js +1 -0
  33. package/dist/esm/v3/index.js.map +1 -1
  34. package/dist/esm/v3/runs.d.ts +155 -65
  35. package/dist/esm/v3/runs.js +93 -0
  36. package/dist/esm/v3/runs.js.map +1 -1
  37. package/dist/esm/v3/shared.d.ts +300 -8
  38. package/dist/esm/v3/shared.js +615 -101
  39. package/dist/esm/v3/shared.js.map +1 -1
  40. package/dist/esm/v3/tasks.d.ts +2 -2
  41. package/dist/esm/v3/tasks.js.map +1 -1
  42. package/dist/esm/version.js +1 -1
  43. package/package.json +4 -4
@@ -10,6 +10,7 @@ export const runs = {
10
10
  poll,
11
11
  subscribeToRun,
12
12
  subscribeToRunsWithTag,
13
+ subscribeToBatch: subscribeToRunsInBatch,
13
14
  };
14
15
  function listRuns(paramsOrProjectRef, paramsOrOptions, requestOptions) {
15
16
  const apiClient = apiClientManager.clientOrThrow();
@@ -192,13 +193,105 @@ async function poll(runId, options, requestOptions) {
192
193
  }
193
194
  throw new Error(`Run ${typeof runId === "string" ? runId : runId.id} did not complete after ${MAX_POLL_ATTEMPTS} attempts`);
194
195
  }
196
+ /**
197
+ * Subscribes to real-time updates for a specific run.
198
+ *
199
+ * This function allows you to receive real-time updates whenever a run changes, including:
200
+ * - Status changes in the run lifecycle
201
+ * - Tag additions or removals
202
+ * - Metadata updates
203
+ *
204
+ * @template TRunId - The type parameter extending AnyRunHandle, AnyTask, or string
205
+ * @param {RunId<TRunId>} runId - The ID of the run to subscribe to. Can be a string ID, RunHandle, or Task
206
+ * @returns {RunSubscription<InferRunTypes<TRunId>>} An async iterator that yields updated run objects
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * // Subscribe using a run handle
211
+ * const handle = await tasks.trigger("my-task", { some: "data" });
212
+ * for await (const run of runs.subscribeToRun(handle.id)) {
213
+ * console.log("Run updated:", run);
214
+ * }
215
+ *
216
+ * // Subscribe with type safety
217
+ * for await (const run of runs.subscribeToRun<typeof myTask>(runId)) {
218
+ * console.log("Payload:", run.payload.some);
219
+ * if (run.output) {
220
+ * console.log("Output:", run.output);
221
+ * }
222
+ * }
223
+ * ```
224
+ */
195
225
  function subscribeToRun(runId) {
196
226
  const $runId = typeof runId === "string" ? runId : runId.id;
197
227
  const apiClient = apiClientManager.clientOrThrow();
198
228
  return apiClient.subscribeToRun($runId);
199
229
  }
230
+ /**
231
+ * Subscribes to real-time updates for all runs that have specific tags.
232
+ *
233
+ * This function allows you to monitor multiple runs simultaneously by filtering on tags.
234
+ * You'll receive updates whenever any run with the specified tag(s) changes.
235
+ *
236
+ * @template TTasks - The type parameter extending AnyTask for type-safe payload and output
237
+ * @param {string | string[]} tag - A single tag or array of tags to filter runs
238
+ * @returns {RunSubscription<InferRunTypes<TTasks>>} An async iterator that yields updated run objects
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * // Subscribe to runs with a single tag
243
+ * for await (const run of runs.subscribeToRunsWithTag("user:1234")) {
244
+ * console.log("Run updated:", run);
245
+ * }
246
+ *
247
+ * // Subscribe with multiple tags and type safety
248
+ * for await (const run of runs.subscribeToRunsWithTag<typeof myTask | typeof otherTask>(["tag1", "tag2"])) {
249
+ * switch (run.taskIdentifier) {
250
+ * case "my-task":
251
+ * console.log("MyTask output:", run.output.foo);
252
+ * break;
253
+ * case "other-task":
254
+ * console.log("OtherTask output:", run.output.bar);
255
+ * break;
256
+ * }
257
+ * }
258
+ * ```
259
+ */
200
260
  function subscribeToRunsWithTag(tag) {
201
261
  const apiClient = apiClientManager.clientOrThrow();
202
262
  return apiClient.subscribeToRunsWithTag(tag);
203
263
  }
264
+ /**
265
+ * Subscribes to real-time updates for all runs within a specific batch.
266
+ *
267
+ * Use this function when you've triggered multiple runs using `batchTrigger` and want
268
+ * to monitor all runs in that batch. You'll receive updates whenever any run in the batch changes.
269
+ *
270
+ * @template TTasks - The type parameter extending AnyTask for type-safe payload and output
271
+ * @param {string} batchId - The ID of the batch to subscribe to
272
+ * @returns {RunSubscription<InferRunTypes<TTasks>>} An async iterator that yields updated run objects
273
+ *
274
+ * @example
275
+ * ```ts
276
+ * // Subscribe to all runs in a batch
277
+ * for await (const run of runs.subscribeToRunsInBatch("batch-123")) {
278
+ * console.log("Batch run updated:", run);
279
+ * }
280
+ *
281
+ * // Subscribe with type safety
282
+ * for await (const run of runs.subscribeToRunsInBatch<typeof myTask>("batch-123")) {
283
+ * console.log("Run payload:", run.payload);
284
+ * if (run.output) {
285
+ * console.log("Run output:", run.output);
286
+ * }
287
+ * }
288
+ * ```
289
+ *
290
+ * @note The run objects received will include standard fields like id, status, payload, output,
291
+ * createdAt, updatedAt, tags, and more. See the Run object documentation for full details.
292
+ */
293
+ function subscribeToRunsInBatch(batchId) {
294
+ const apiClient = apiClientManager.clientOrThrow();
295
+ return apiClient.subscribeToBatch(batchId);
296
+ }
204
297
  //# sourceMappingURL=runs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runs.js","sourceRoot":"","sources":["../../../src/v3/runs.ts"],"names":[],"mappings":"AAcA,OAAO,EAOL,mBAAmB,EACnB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAEvF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAWrC,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB,MAAM,EAAE,SAAS;IACjB,MAAM,EAAE,SAAS;IACjB,QAAQ,EAAE,WAAW;IACrB,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE,aAAa;IACzB,IAAI;IACJ,cAAc;IACd,sBAAsB;CACvB,CAAC;AAaF,SAAS,QAAQ,CACf,kBAAiD,EACjD,eAAsF,EACtF,cAAkC;IAElC,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,sBAAsB,CAC5C,kBAAkB,EAClB,eAAe,EACf,cAAc,CACf,CAAC;IAEF,IAAI,OAAO,kBAAkB,KAAK,QAAQ,EAAE,CAAC;QAC3C,IAAI,gBAAgB,CAAC,eAAe,CA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AM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,sBAAsB,CAAwB,GAAG,CAAC,CAAC;AACtE,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AACH,SAAS,sBAAsB,CAC7B,OAAe;IAEf,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,OAAO,SAAS,CAAC,gBAAgB,CAAwB,OAAO,CAAC,CAAC;AACpE,CAAC"}
@@ -1,8 +1,8 @@
1
1
  import { SerializableJson } from "@trigger.dev/core";
2
- import { ApiRequestOptions, InitOutput, Queue, QueueOptions, SubtaskUnwrapError, TaskRunContext, TaskRunPromise } from "@trigger.dev/core/v3";
2
+ import { ApiRequestOptions, InitOutput, Queue, QueueOptions, SubtaskUnwrapError, TaskRunContext, TaskRunPromise, TaskFromIdentifier } from "@trigger.dev/core/v3";
3
3
  import { PollOptions } from "./runs.js";
4
- import type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, BatchRunHandleFromTypes, InferRunTypes, RetrieveRunResult, RunHandle, RunHandleFromTypes, RunHandleOutput, RunHandlePayload, Task, TaskBatchOutputHandle, TaskIdentifier, TaskOptions, TaskOutput, TaskOutputHandle, TaskPayload, TaskRunOptions, TaskRunResult, TaskSchema, TaskWithSchema, TaskWithSchemaOptions, TaskWithToolOptions, ToolTask, ToolTaskParameters, TriggerApiRequestOptions } from "@trigger.dev/core/v3";
5
- export type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, Queue, RunHandle, RunHandleOutput, RunHandlePayload, SerializableJson, Task, TaskBatchOutputHandle, TaskIdentifier, TaskOptions, TaskOutput, TaskOutputHandle, TaskPayload, TaskRunOptions, TaskRunResult, };
4
+ import type { AnyRunHandle, AnyTask, BatchByIdAndWaitItem, BatchByTaskAndWaitItem, BatchByIdItem, BatchByTaskItem, BatchByTaskResult, BatchByIdResult, BatchItem, BatchResult, BatchRunHandle, BatchRunHandleFromTypes, BatchTasksRunHandleFromTypes, BatchTriggerOptions, InferRunTypes, RetrieveRunResult, RunHandle, RunHandleFromTypes, RunHandleOutput, RunHandlePayload, Task, TaskBatchOutputHandle, TaskIdentifier, TaskOptions, TaskOutput, TaskOutputHandle, TaskPayload, TaskRunResult, TaskSchema, TaskWithSchema, TaskWithSchemaOptions, TaskWithToolOptions, ToolTask, ToolTaskParameters, TriggerAndWaitOptions, TriggerApiRequestOptions, TriggerOptions } from "@trigger.dev/core/v3";
5
+ export type { AnyRunHandle, AnyTask, BatchItem, BatchResult, BatchRunHandle, BatchTriggerOptions, Queue, RunHandle, RunHandleOutput, RunHandlePayload, SerializableJson, Task, TaskBatchOutputHandle, TaskIdentifier, TaskOptions, TaskOutput, TaskOutputHandle, TaskPayload, TaskRunResult, TriggerOptions, TaskFromIdentifier, };
6
6
  export { SubtaskUnwrapError, TaskRunPromise };
7
7
  export type Context = TaskRunContext;
8
8
  export declare function queue(options: {
@@ -27,7 +27,7 @@ export declare function createSchemaTask<TIdentifier extends string, TSchema ext
27
27
  *
28
28
  * @returns {RunHandle} An object with the `id` of the run. Can be used to retrieve the completed run output in a typesafe manner.
29
29
  */
30
- export declare function trigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>, payload: TaskPayload<TTask>, options?: TaskRunOptions, requestOptions?: TriggerApiRequestOptions): Promise<RunHandleFromTypes<InferRunTypes<TTask>>>;
30
+ export declare function trigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>, payload: TaskPayload<TTask>, options?: TriggerOptions, requestOptions?: TriggerApiRequestOptions): Promise<RunHandleFromTypes<InferRunTypes<TTask>>>;
31
31
  /**
32
32
  * Trigger a task with the given payload, and wait for the result. Returns the result of the task run
33
33
  * @param id - The id of the task to trigger
@@ -46,7 +46,7 @@ export declare function trigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>
46
46
  * }
47
47
  * ```
48
48
  */
49
- export declare function triggerAndWait<TTask extends AnyTask>(id: TaskIdentifier<TTask>, payload: TaskPayload<TTask>, options?: TaskRunOptions, requestOptions?: ApiRequestOptions): TaskRunPromise<TaskOutput<TTask>>;
49
+ export declare function triggerAndWait<TTask extends AnyTask>(id: TaskIdentifier<TTask>, payload: TaskPayload<TTask>, options?: TriggerAndWaitOptions, requestOptions?: ApiRequestOptions): TaskRunPromise<TaskIdentifier<TTask>, TaskOutput<TTask>>;
50
50
  /**
51
51
  * Batch trigger multiple task runs with the given payloads, and wait for the results. Returns the results of the task runs.
52
52
  * @param id - The id of the task to trigger
@@ -71,7 +71,7 @@ export declare function triggerAndWait<TTask extends AnyTask>(id: TaskIdentifier
71
71
  * }
72
72
  * ```
73
73
  */
74
- export declare function batchTriggerAndWait<TTask extends AnyTask>(id: TaskIdentifier<TTask>, items: Array<BatchItem<TaskPayload<TTask>>>, requestOptions?: ApiRequestOptions): Promise<BatchResult<TaskOutput<TTask>>>;
74
+ export declare function batchTriggerAndWait<TTask extends AnyTask>(id: TaskIdentifier<TTask>, items: Array<BatchItem<TaskPayload<TTask>>>, requestOptions?: ApiRequestOptions): Promise<BatchResult<TaskIdentifier<TTask>, TaskOutput<TTask>>>;
75
75
  /**
76
76
  * Trigger a task by its identifier with the given payload and poll until the run is completed.
77
77
  *
@@ -87,5 +87,297 @@ export declare function batchTriggerAndWait<TTask extends AnyTask>(id: TaskIdent
87
87
  *
88
88
  * @returns {Run} The completed run, either successful or failed.
89
89
  */
90
- export declare function triggerAndPoll<TTask extends AnyTask>(id: TaskIdentifier<TTask>, payload: TaskPayload<TTask>, options?: TaskRunOptions & PollOptions, requestOptions?: TriggerApiRequestOptions): Promise<RetrieveRunResult<TTask>>;
91
- export declare function batchTrigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>, items: Array<BatchItem<TaskPayload<TTask>>>, requestOptions?: TriggerApiRequestOptions): Promise<BatchRunHandleFromTypes<InferRunTypes<TTask>>>;
90
+ export declare function triggerAndPoll<TTask extends AnyTask>(id: TaskIdentifier<TTask>, payload: TaskPayload<TTask>, options?: TriggerOptions & PollOptions, requestOptions?: TriggerApiRequestOptions): Promise<RetrieveRunResult<TTask>>;
91
+ export declare function batchTrigger<TTask extends AnyTask>(id: TaskIdentifier<TTask>, items: Array<BatchItem<TaskPayload<TTask>>>, options?: BatchTriggerOptions, requestOptions?: TriggerApiRequestOptions): Promise<BatchRunHandleFromTypes<InferRunTypes<TTask>>>;
92
+ /**
93
+ * Triggers multiple runs of different tasks with specified payloads and options.
94
+ *
95
+ * @template TTask - The type of task(s) to be triggered, extends AnyTask
96
+ *
97
+ * @param {Array<BatchByIdItem<InferRunTypes<TTask>>>} items - Array of task items to trigger
98
+ * @param {BatchTriggerOptions} [options] - Optional batch-level trigger options
99
+ * @param {TriggerApiRequestOptions} [requestOptions] - Optional API request configuration
100
+ *
101
+ * @returns {Promise<BatchRunHandleFromTypes<InferRunTypes<TTask>>>} A promise that resolves with the batch run handle
102
+ * containing batch ID, cached status, idempotency info, runs, and public access token
103
+ *
104
+ * @example
105
+ * ```ts
106
+ * import { batch } from "@trigger.dev/sdk/v3";
107
+ * import type { myTask1, myTask2 } from "~/trigger/myTasks";
108
+ *
109
+ * // Trigger multiple tasks with different payloads
110
+ * const result = await batch.trigger<typeof myTask1 | typeof myTask2>([
111
+ * {
112
+ * id: "my-task-1",
113
+ * payload: { some: "data" },
114
+ * options: {
115
+ * queue: "default",
116
+ * concurrencyKey: "key",
117
+ * idempotencyKey: "unique-key",
118
+ * delay: "5m",
119
+ * tags: ["tag1", "tag2"]
120
+ * }
121
+ * },
122
+ * {
123
+ * id: "my-task-2",
124
+ * payload: { other: "data" }
125
+ * }
126
+ * ]);
127
+ * ```
128
+ *
129
+ * @description
130
+ * Each task item in the array can include:
131
+ * - `id`: The unique identifier of the task
132
+ * - `payload`: The data to pass to the task
133
+ * - `options`: Optional task-specific settings including:
134
+ * - `queue`: Specify a queue for the task
135
+ * - `concurrencyKey`: Control concurrent execution
136
+ * - `idempotencyKey`: Prevent duplicate runs
137
+ * - `idempotencyKeyTTL`: Time-to-live for idempotency key
138
+ * - `delay`: Delay before task execution
139
+ * - `ttl`: Time-to-live for the task
140
+ * - `tags`: Array of tags for the task
141
+ * - `maxAttempts`: Maximum retry attempts
142
+ * - `metadata`: Additional metadata
143
+ * - `maxDuration`: Maximum execution duration
144
+ */
145
+ export declare function batchTriggerById<TTask extends AnyTask>(items: Array<BatchByIdItem<InferRunTypes<TTask>>>, options?: BatchTriggerOptions, requestOptions?: TriggerApiRequestOptions): Promise<BatchRunHandleFromTypes<InferRunTypes<TTask>>>;
146
+ /**
147
+ * Triggers multiple tasks and waits for all of them to complete before returning their results.
148
+ * This function must be called from within a task.run() context.
149
+ *
150
+ * @template TTask - Union type of tasks to be triggered, extends AnyTask
151
+ *
152
+ * @param {Array<BatchByIdAndWaitItem<InferRunTypes<TTask>>>} items - Array of task items to trigger
153
+ * @param {TriggerApiRequestOptions} [requestOptions] - Optional API request configuration
154
+ *
155
+ * @returns {Promise<BatchByIdResult<TTask>>} A promise that resolves with the batch results, including
156
+ * success/failure status and strongly-typed outputs for each task
157
+ *
158
+ * @throws {Error} If called outside of a task.run() context
159
+ * @throws {Error} If no API client is configured
160
+ *
161
+ * @example
162
+ * ```ts
163
+ * import { batch, task } from "@trigger.dev/sdk/v3";
164
+ *
165
+ * export const parentTask = task({
166
+ * id: "parent-task",
167
+ * run: async (payload: string) => {
168
+ * const results = await batch.triggerAndWait<typeof childTask1 | typeof childTask2>([
169
+ * {
170
+ * id: "child-task-1",
171
+ * payload: { foo: "World" },
172
+ * options: {
173
+ * queue: "default",
174
+ * delay: "5m",
175
+ * tags: ["batch", "child1"]
176
+ * }
177
+ * },
178
+ * {
179
+ * id: "child-task-2",
180
+ * payload: { bar: 42 }
181
+ * }
182
+ * ]);
183
+ *
184
+ * // Type-safe result handling
185
+ * for (const result of results) {
186
+ * if (result.ok) {
187
+ * switch (result.taskIdentifier) {
188
+ * case "child-task-1":
189
+ * console.log("Child task 1 output:", result.output); // string type
190
+ * break;
191
+ * case "child-task-2":
192
+ * console.log("Child task 2 output:", result.output); // number type
193
+ * break;
194
+ * }
195
+ * } else {
196
+ * console.error("Task failed:", result.error);
197
+ * }
198
+ * }
199
+ * }
200
+ * });
201
+ * ```
202
+ *
203
+ * @description
204
+ * Each task item in the array can include:
205
+ * - `id`: The task identifier (must match one of the tasks in the union type)
206
+ * - `payload`: Strongly-typed payload matching the task's input type
207
+ * - `options`: Optional task-specific settings including:
208
+ * - `queue`: Specify a queue for the task
209
+ * - `concurrencyKey`: Control concurrent execution
210
+ * - `delay`: Delay before task execution
211
+ * - `ttl`: Time-to-live for the task
212
+ * - `tags`: Array of tags for the task
213
+ * - `maxAttempts`: Maximum retry attempts
214
+ * - `metadata`: Additional metadata
215
+ * - `maxDuration`: Maximum execution duration
216
+ *
217
+ * The function provides full type safety for:
218
+ * - Task IDs
219
+ * - Payload types
220
+ * - Return value types
221
+ * - Error handling
222
+ */
223
+ export declare function batchTriggerByIdAndWait<TTask extends AnyTask>(items: Array<BatchByIdAndWaitItem<InferRunTypes<TTask>>>, requestOptions?: TriggerApiRequestOptions): Promise<BatchByIdResult<TTask>>;
224
+ /**
225
+ * Triggers multiple tasks and waits for all of them to complete before returning their results.
226
+ * This function must be called from within a task.run() context.
227
+ *
228
+ * @template TTask - Union type of tasks to be triggered, extends AnyTask
229
+ *
230
+ * @param {Array<BatchByIdAndWaitItem<InferRunTypes<TTask>>>} items - Array of task items to trigger
231
+ * @param {TriggerApiRequestOptions} [requestOptions] - Optional API request configuration
232
+ *
233
+ * @returns {Promise<BatchByIdResult<TTask>>} A promise that resolves with the batch results, including
234
+ * success/failure status and strongly-typed outputs for each task
235
+ *
236
+ * @throws {Error} If called outside of a task.run() context
237
+ * @throws {Error} If no API client is configured
238
+ *
239
+ * @example
240
+ * ```ts
241
+ * import { batch, task } from "@trigger.dev/sdk/v3";
242
+ *
243
+ * export const parentTask = task({
244
+ * id: "parent-task",
245
+ * run: async (payload: string) => {
246
+ * const results = await batch.triggerAndWait<typeof childTask1 | typeof childTask2>([
247
+ * {
248
+ * id: "child-task-1",
249
+ * payload: { foo: "World" },
250
+ * options: {
251
+ * queue: "default",
252
+ * delay: "5m",
253
+ * tags: ["batch", "child1"]
254
+ * }
255
+ * },
256
+ * {
257
+ * id: "child-task-2",
258
+ * payload: { bar: 42 }
259
+ * }
260
+ * ]);
261
+ *
262
+ * // Type-safe result handling
263
+ * for (const result of results) {
264
+ * if (result.ok) {
265
+ * switch (result.taskIdentifier) {
266
+ * case "child-task-1":
267
+ * console.log("Child task 1 output:", result.output); // string type
268
+ * break;
269
+ * case "child-task-2":
270
+ * console.log("Child task 2 output:", result.output); // number type
271
+ * break;
272
+ * }
273
+ * } else {
274
+ * console.error("Task failed:", result.error);
275
+ * }
276
+ * }
277
+ * }
278
+ * });
279
+ * ```
280
+ *
281
+ * @description
282
+ * Each task item in the array can include:
283
+ * - `id`: The task identifier (must match one of the tasks in the union type)
284
+ * - `payload`: Strongly-typed payload matching the task's input type
285
+ * - `options`: Optional task-specific settings including:
286
+ * - `queue`: Specify a queue for the task
287
+ * - `concurrencyKey`: Control concurrent execution
288
+ * - `delay`: Delay before task execution
289
+ * - `ttl`: Time-to-live for the task
290
+ * - `tags`: Array of tags for the task
291
+ * - `maxAttempts`: Maximum retry attempts
292
+ * - `metadata`: Additional metadata
293
+ * - `maxDuration`: Maximum execution duration
294
+ *
295
+ * The function provides full type safety for:
296
+ * - Task IDs
297
+ * - Payload types
298
+ * - Return value types
299
+ * - Error handling
300
+ */
301
+ export declare function batchTriggerTasks<TTasks extends readonly AnyTask[]>(items: {
302
+ [K in keyof TTasks]: BatchByTaskItem<TTasks[K]>;
303
+ }, options?: BatchTriggerOptions, requestOptions?: TriggerApiRequestOptions): Promise<BatchTasksRunHandleFromTypes<TTasks>>;
304
+ /**
305
+ * Triggers multiple tasks and waits for all of them to complete before returning their results.
306
+ * This function must be called from within a task.run() context.
307
+ *
308
+ * @template TTask - Union type of tasks to be triggered, extends AnyTask
309
+ *
310
+ * @param {Array<BatchByIdAndWaitItem<InferRunTypes<TTask>>>} items - Array of task items to trigger
311
+ * @param {TriggerApiRequestOptions} [requestOptions] - Optional API request configuration
312
+ *
313
+ * @returns {Promise<BatchByIdResult<TTask>>} A promise that resolves with the batch results, including
314
+ * success/failure status and strongly-typed outputs for each task
315
+ *
316
+ * @throws {Error} If called outside of a task.run() context
317
+ * @throws {Error} If no API client is configured
318
+ *
319
+ * @example
320
+ * ```ts
321
+ * import { batch, task } from "@trigger.dev/sdk/v3";
322
+ *
323
+ * export const parentTask = task({
324
+ * id: "parent-task",
325
+ * run: async (payload: string) => {
326
+ * const results = await batch.triggerAndWait<typeof childTask1 | typeof childTask2>([
327
+ * {
328
+ * id: "child-task-1",
329
+ * payload: { foo: "World" },
330
+ * options: {
331
+ * queue: "default",
332
+ * delay: "5m",
333
+ * tags: ["batch", "child1"]
334
+ * }
335
+ * },
336
+ * {
337
+ * id: "child-task-2",
338
+ * payload: { bar: 42 }
339
+ * }
340
+ * ]);
341
+ *
342
+ * // Type-safe result handling
343
+ * for (const result of results) {
344
+ * if (result.ok) {
345
+ * switch (result.taskIdentifier) {
346
+ * case "child-task-1":
347
+ * console.log("Child task 1 output:", result.output); // string type
348
+ * break;
349
+ * case "child-task-2":
350
+ * console.log("Child task 2 output:", result.output); // number type
351
+ * break;
352
+ * }
353
+ * } else {
354
+ * console.error("Task failed:", result.error);
355
+ * }
356
+ * }
357
+ * }
358
+ * });
359
+ * ```
360
+ *
361
+ * @description
362
+ * Each task item in the array can include:
363
+ * - `id`: The task identifier (must match one of the tasks in the union type)
364
+ * - `payload`: Strongly-typed payload matching the task's input type
365
+ * - `options`: Optional task-specific settings including:
366
+ * - `queue`: Specify a queue for the task
367
+ * - `concurrencyKey`: Control concurrent execution
368
+ * - `delay`: Delay before task execution
369
+ * - `ttl`: Time-to-live for the task
370
+ * - `tags`: Array of tags for the task
371
+ * - `maxAttempts`: Maximum retry attempts
372
+ * - `metadata`: Additional metadata
373
+ * - `maxDuration`: Maximum execution duration
374
+ *
375
+ * The function provides full type safety for:
376
+ * - Task IDs
377
+ * - Payload types
378
+ * - Return value types
379
+ * - Error handling
380
+ */
381
+ export declare function batchTriggerAndWaitTasks<TTasks extends readonly AnyTask[]>(items: {
382
+ [K in keyof TTasks]: BatchByTaskAndWaitItem<TTasks[K]>;
383
+ }, requestOptions?: TriggerApiRequestOptions): Promise<BatchByTaskResult<TTasks>>;