@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
@@ -117,11 +117,7 @@ export declare class TriggerClient {
117
117
  */
118
118
  sendEvent(event: SendEvent, options?: SendEventOptions): Promise<{
119
119
  name: string;
120
- payload: ((string | number | boolean | {
121
- [key: string]: DeserializedJson;
122
- } | DeserializedJson[]) & (string | number | boolean | {
123
- [key: string]: DeserializedJson;
124
- } | DeserializedJson[] | undefined)) | null;
120
+ payload: DeserializedJson;
125
121
  id: string;
126
122
  timestamp: Date;
127
123
  context?: DeserializedJson | undefined;
@@ -136,11 +132,7 @@ export declare class TriggerClient {
136
132
  */
137
133
  sendEvents(events: SendEvent[], options?: SendEventOptions): Promise<{
138
134
  name: string;
139
- payload: ((string | number | boolean | {
140
- [key: string]: DeserializedJson;
141
- } | DeserializedJson[]) & (string | number | boolean | {
142
- [key: string]: DeserializedJson;
143
- } | DeserializedJson[] | undefined)) | null;
135
+ payload: DeserializedJson;
144
136
  id: string;
145
137
  timestamp: Date;
146
138
  context?: DeserializedJson | undefined;
@@ -150,11 +142,7 @@ export declare class TriggerClient {
150
142
  }[]>;
151
143
  cancelEvent(eventId: string): Promise<{
152
144
  name: string;
153
- payload: ((string | number | boolean | {
154
- [key: string]: DeserializedJson;
155
- } | DeserializedJson[]) & (string | number | boolean | {
156
- [key: string]: DeserializedJson;
157
- } | DeserializedJson[] | undefined)) | null;
145
+ payload: DeserializedJson;
158
146
  id: string;
159
147
  timestamp: Date;
160
148
  context?: DeserializedJson | undefined;
@@ -174,8 +162,8 @@ export declare class TriggerClient {
174
162
  state?: "loading" | "success" | "failure" | undefined;
175
163
  data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
176
164
  }[];
177
- data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
178
165
  state?: "loading" | "success" | "failure" | undefined;
166
+ data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
179
167
  }>;
180
168
  registerSchedule(id: string, key: string, schedule: ScheduleMetadata): Promise<{
181
169
  id: string;
@@ -184,15 +172,15 @@ export declare class TriggerClient {
184
172
  cron: string;
185
173
  };
186
174
  type: "cron";
187
- accountId?: string | undefined;
188
175
  metadata?: any;
176
+ accountId?: string | undefined;
189
177
  } | {
190
178
  options: {
191
179
  seconds: number;
192
180
  };
193
181
  type: "interval";
194
- accountId?: string | undefined;
195
182
  metadata?: any;
183
+ accountId?: string | undefined;
196
184
  };
197
185
  active: boolean;
198
186
  metadata?: any;
@@ -227,8 +215,8 @@ export declare class TriggerClient {
227
215
  state?: "loading" | "success" | "failure" | undefined;
228
216
  data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
229
217
  }[];
230
- data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
231
218
  state?: "loading" | "success" | "failure" | undefined;
219
+ data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
232
220
  }[];
233
221
  output?: any;
234
222
  nextCursor?: string | undefined;
@@ -248,8 +236,8 @@ export declare class TriggerClient {
248
236
  state?: "loading" | "success" | "failure" | undefined;
249
237
  data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
250
238
  }[];
251
- data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
252
239
  state?: "loading" | "success" | "failure" | undefined;
240
+ data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
253
241
  }[];
254
242
  output?: any;
255
243
  nextCursor?: string | undefined;
@@ -273,8 +261,8 @@ export declare class TriggerClient {
273
261
  state?: "loading" | "success" | "failure" | undefined;
274
262
  data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
275
263
  }[];
276
- data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
277
264
  state?: "loading" | "success" | "failure" | undefined;
265
+ data?: Record<string, import("@trigger.dev/core").SerializableJson> | undefined;
278
266
  }[];
279
267
  run: {
280
268
  status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
@@ -22,8 +22,8 @@ export declare class InvokeTrigger<TSchema extends ZodType = z.ZodTypeAny> imple
22
22
  examples: {
23
23
  name: string;
24
24
  id: string;
25
- icon?: string | undefined;
26
25
  payload?: any;
26
+ icon?: string | undefined;
27
27
  }[];
28
28
  icon: string;
29
29
  parsePayload: (rawPayload: unknown) => any;
@@ -119,15 +119,15 @@ export declare class DynamicSchedule implements Trigger<ScheduledEventSpecificat
119
119
  cron: string;
120
120
  };
121
121
  type: "cron";
122
- accountId?: string | undefined;
123
122
  metadata?: any;
123
+ accountId?: string | undefined;
124
124
  } | {
125
125
  options: {
126
126
  seconds: number;
127
127
  };
128
128
  type: "interval";
129
- accountId?: string | undefined;
130
129
  metadata?: any;
130
+ accountId?: string | undefined;
131
131
  };
132
132
  active: boolean;
133
133
  metadata?: any;
@@ -118,13 +118,13 @@ export declare const EventSpecificationExampleSchema: z.ZodObject<{
118
118
  }, "strip", z.ZodTypeAny, {
119
119
  name: string;
120
120
  id: string;
121
- icon?: string | undefined;
122
121
  payload?: any;
122
+ icon?: string | undefined;
123
123
  }, {
124
124
  name: string;
125
125
  id: string;
126
- icon?: string | undefined;
127
126
  payload?: any;
127
+ icon?: string | undefined;
128
128
  }>;
129
129
  export type EventSpecificationExample = z.infer<typeof EventSpecificationExampleSchema>;
130
130
  export type TypedEventSpecificationExample<TEvent> = {
@@ -0,0 +1,28 @@
1
+ import { ApiPromise, ApiRequestOptions, RetrieveBatchResponse } from "@trigger.dev/core/v3";
2
+ import { batchTriggerById, batchTriggerByIdAndWait, batchTriggerTasks, batchTriggerAndWaitTasks } from "./shared.js";
3
+ export declare const batch: {
4
+ trigger: typeof batchTriggerById;
5
+ triggerAndWait: typeof batchTriggerByIdAndWait;
6
+ triggerByTask: typeof batchTriggerTasks;
7
+ triggerByTaskAndWait: typeof batchTriggerAndWaitTasks;
8
+ retrieve: typeof retrieveBatch;
9
+ };
10
+ /**
11
+ * Retrieves details about a specific batch by its ID.
12
+ *
13
+ * @param {string} batchId - The unique identifier of the batch to retrieve
14
+ * @param {ApiRequestOptions} [requestOptions] - Optional API request configuration options
15
+ * @returns {ApiPromise<RetrieveBatchResponse>} A promise that resolves with the batch details
16
+ *
17
+ * @example
18
+ * // First trigger a batch
19
+ * const response = await batch.trigger([
20
+ * { id: "simple-task", payload: { message: "Hello, World!" } }
21
+ * ]);
22
+ *
23
+ * // Then retrieve the batch details
24
+ * const batchDetails = await batch.retrieve(response.batchId);
25
+ * console.log("batch", batchDetails);
26
+ */
27
+ declare function retrieveBatch(batchId: string, requestOptions?: ApiRequestOptions): ApiPromise<RetrieveBatchResponse>;
28
+ export {};
@@ -0,0 +1,49 @@
1
+ import { accessoryAttributes, apiClientManager, mergeRequestOptions, } from "@trigger.dev/core/v3";
2
+ import { batchTriggerById, batchTriggerByIdAndWait, batchTriggerTasks, batchTriggerAndWaitTasks, } from "./shared.js";
3
+ import { tracer } from "./tracer.js";
4
+ export const batch = {
5
+ trigger: batchTriggerById,
6
+ triggerAndWait: batchTriggerByIdAndWait,
7
+ triggerByTask: batchTriggerTasks,
8
+ triggerByTaskAndWait: batchTriggerAndWaitTasks,
9
+ retrieve: retrieveBatch,
10
+ };
11
+ /**
12
+ * Retrieves details about a specific batch by its ID.
13
+ *
14
+ * @param {string} batchId - The unique identifier of the batch to retrieve
15
+ * @param {ApiRequestOptions} [requestOptions] - Optional API request configuration options
16
+ * @returns {ApiPromise<RetrieveBatchResponse>} A promise that resolves with the batch details
17
+ *
18
+ * @example
19
+ * // First trigger a batch
20
+ * const response = await batch.trigger([
21
+ * { id: "simple-task", payload: { message: "Hello, World!" } }
22
+ * ]);
23
+ *
24
+ * // Then retrieve the batch details
25
+ * const batchDetails = await batch.retrieve(response.batchId);
26
+ * console.log("batch", batchDetails);
27
+ */
28
+ function retrieveBatch(batchId, requestOptions) {
29
+ const apiClient = apiClientManager.clientOrThrow();
30
+ const $requestOptions = mergeRequestOptions({
31
+ tracer,
32
+ name: "batch.retrieve()",
33
+ icon: "batch",
34
+ attributes: {
35
+ batchId: batchId,
36
+ ...accessoryAttributes({
37
+ items: [
38
+ {
39
+ text: batchId,
40
+ variant: "normal",
41
+ },
42
+ ],
43
+ style: "codepath",
44
+ }),
45
+ },
46
+ }, requestOptions);
47
+ return apiClient.retrieveBatch(batchId, $requestOptions);
48
+ }
49
+ //# sourceMappingURL=batch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"batch.js","sourceRoot":"","sources":["../../../src/v3/batch.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,mBAAmB,EACnB,gBAAgB,EAGhB,mBAAmB,GAEpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,gBAAgB,EAChB,uBAAuB,EACvB,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,OAAO,EAAE,gBAAgB;IACzB,cAAc,EAAE,uBAAuB;IACvC,aAAa,EAAE,iBAAiB;IAChC,oBAAoB,EAAE,wBAAwB;IAC9C,QAAQ,EAAE,aAAa;CACxB,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,aAAa,CACpB,OAAe,EACf,cAAkC;IAElC,MAAM,SAAS,GAAG,gBAAgB,CAAC,aAAa,EAAE,CAAC;IAEnD,MAAM,eAAe,GAAG,mBAAmB,CACzC;QACE,MAAM;QACN,IAAI,EAAE,kBAAkB;QACxB,IAAI,EAAE,OAAO;QACb,UAAU,EAAE;YACV,OAAO,EAAE,OAAO;YAChB,GAAG,mBAAmB,CAAC;gBACrB,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,OAAO;wBACb,OAAO,EAAE,QAAQ;qBAClB;iBACF;gBACD,KAAK,EAAE,UAAU;aAClB,CAAC;SACH;KACF,EACD,cAAc,CACf,CAAC;IAEF,OAAO,SAAS,CAAC,aAAa,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;AAC3D,CAAC"}
@@ -3,6 +3,7 @@ export * from "./config.js";
3
3
  export { retry, type RetryOptions } from "./retry.js";
4
4
  export { queue } from "./shared.js";
5
5
  export * from "./tasks.js";
6
+ export * from "./batch.js";
6
7
  export * from "./wait.js";
7
8
  export * from "./waitUntil.js";
8
9
  export * from "./usage.js";
@@ -16,7 +17,7 @@ import type { Context } from "./shared.js";
16
17
  import type { ApiClientConfiguration } from "@trigger.dev/core/v3";
17
18
  export type { ApiClientConfiguration };
18
19
  export { ApiError, AuthenticationError, BadRequestError, ConflictError, InternalServerError, NotFoundError, PermissionDeniedError, RateLimitError, UnprocessableEntityError, AbortTaskRunError, logger, type LogLevel, } from "@trigger.dev/core/v3";
19
- export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RealtimeRun, type RetrieveRunResult, type AnyRetrieveRunResult, } from "./runs.js";
20
+ export { runs, type RunShape, type AnyRunShape, type TaskRunShape, type RealtimeRun, type AnyRealtimeRun, type RetrieveRunResult, type AnyRetrieveRunResult, } from "./runs.js";
20
21
  export * as schedules from "./schedules/index.js";
21
22
  export * as envvars from "./envvars.js";
22
23
  export type { ImportEnvironmentVariablesParams } from "./envvars.js";
@@ -3,6 +3,7 @@ export * from "./config.js";
3
3
  export { retry } from "./retry.js";
4
4
  export { queue } from "./shared.js";
5
5
  export * from "./tasks.js";
6
+ export * from "./batch.js";
6
7
  export * from "./wait.js";
7
8
  export * from "./waitUntil.js";
8
9
  export * from "./usage.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAS/B,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,GAEP,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,IAAI,GAOL,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/v3/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,KAAK,EAAqB,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,YAAY,CAAC;AAC3B,cAAc,sBAAsB,CAAC;AACrC,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,gBAAgB,CAAC;AAS/B,OAAO,EACL,QAAQ,EACR,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,mBAAmB,EACnB,aAAa,EACb,qBAAqB,EACrB,cAAc,EACd,wBAAwB,EACxB,iBAAiB,EACjB,MAAM,GAEP,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,IAAI,GAQL,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC"}
@@ -1,7 +1,7 @@
1
- import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, RunSubscription, TaskRunShape } from "@trigger.dev/core/v3";
1
+ import type { AnyRetrieveRunResult, AnyRunShape, ApiRequestOptions, InferRunTypes, ListProjectRunsQueryParams, ListRunsQueryParams, RescheduleRunRequestBody, RetrieveRunResult, RunShape, RealtimeRun, AnyRealtimeRun, RunSubscription, TaskRunShape, AnyBatchedRunHandle } from "@trigger.dev/core/v3";
2
2
  import { ApiPromise, CanceledRunResponse, CursorPagePromise, ListRunResponseItem, ReplayRunResponse, RetrieveRunResponse } from "@trigger.dev/core/v3";
3
3
  import { AnyRunHandle, AnyTask } from "./shared.js";
4
- export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape, RealtimeRun, };
4
+ export type { AnyRetrieveRunResult, AnyRunShape, RetrieveRunResult, RunShape, TaskRunShape, RealtimeRun, AnyRealtimeRun, };
5
5
  export declare const runs: {
6
6
  replay: typeof replayRun;
7
7
  cancel: typeof cancelRun;
@@ -11,12 +11,13 @@ export declare const runs: {
11
11
  poll: typeof poll;
12
12
  subscribeToRun: typeof subscribeToRun;
13
13
  subscribeToRunsWithTag: typeof subscribeToRunsWithTag;
14
+ subscribeToBatch: typeof subscribeToRunsInBatch;
14
15
  };
15
16
  export type ListRunsItem = ListRunResponseItem;
16
17
  declare function listRuns(projectRef: string, params?: ListProjectRunsQueryParams, requestOptions?: ApiRequestOptions): CursorPagePromise<typeof ListRunResponseItem>;
17
18
  declare function listRuns(params?: ListRunsQueryParams, requestOptions?: ApiRequestOptions): CursorPagePromise<typeof ListRunResponseItem>;
18
- type RunId<TRunId> = TRunId extends AnyRunHandle ? TRunId : TRunId extends AnyTask ? string : TRunId extends string ? TRunId : never;
19
- declare function retrieveRun<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId>, requestOptions?: ApiRequestOptions): ApiPromise<RetrieveRunResult<TRunId>>;
19
+ type RunId<TRunId> = TRunId extends AnyRunHandle | AnyBatchedRunHandle ? TRunId : TRunId extends AnyTask ? string : TRunId extends string ? TRunId : never;
20
+ declare function retrieveRun<TRunId extends AnyRunHandle | AnyBatchedRunHandle | AnyTask | string>(runId: RunId<TRunId>, requestOptions?: ApiRequestOptions): ApiPromise<RetrieveRunResult<TRunId>>;
20
21
  declare function replayRun(runId: string, requestOptions?: ApiRequestOptions): ApiPromise<ReplayRunResponse>;
21
22
  declare function cancelRun(runId: string, requestOptions?: ApiRequestOptions): ApiPromise<CanceledRunResponse>;
22
23
  declare function rescheduleRun(runId: string, body: RescheduleRunRequestBody, requestOptions?: ApiRequestOptions): ApiPromise<RetrieveRunResponse>;
@@ -26,27 +27,20 @@ export type PollOptions = {
26
27
  declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId>, options?: {
27
28
  pollIntervalMs?: number;
28
29
  }, requestOptions?: ApiRequestOptions): Promise<{
29
- taskIdentifier: string;
30
- status: "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "COMPLETED" | "CANCELED" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED" | "TIMED_OUT";
30
+ status: "CANCELED" | "COMPLETED" | "FAILED" | "TIMED_OUT" | "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
31
31
  id: string;
32
- idempotencyKey?: string | undefined;
33
- createdAt: Date;
34
- updatedAt: Date;
35
32
  startedAt?: Date | undefined;
36
- expiredAt?: Date | undefined;
33
+ tags: string[];
37
34
  isTest: boolean;
35
+ createdAt: Date;
36
+ idempotencyKey?: string | undefined;
37
+ durationMs: number;
38
38
  costInCents: number;
39
39
  baseCostInCents: number;
40
- ttl?: string | undefined;
41
- metadata?: Record<string, any> | undefined;
42
- error?: {
43
- message: string;
44
- name?: string | undefined;
45
- stackTrace?: string | undefined;
46
- } | undefined;
47
- tags: string[];
48
- durationMs: number;
49
40
  version?: string | undefined;
41
+ metadata?: Record<string, any> | undefined;
42
+ ttl?: string | undefined;
43
+ taskIdentifier: string;
50
44
  schedule?: {
51
45
  id: string;
52
46
  generator: {
@@ -57,124 +51,220 @@ declare function poll<TRunId extends AnyRunHandle | AnyTask | string>(runId: Run
57
51
  externalId?: string | undefined;
58
52
  deduplicationKey?: string | undefined;
59
53
  } | undefined;
54
+ batchId?: string | undefined;
55
+ error?: {
56
+ message: string;
57
+ name?: string | undefined;
58
+ stackTrace?: string | undefined;
59
+ } | undefined;
60
+ depth: number;
61
+ triggerFunction: "trigger" | "batchTrigger" | "triggerAndWait" | "batchTriggerAndWait";
62
+ isQueued: boolean;
63
+ isExecuting: boolean;
64
+ isCompleted: boolean;
65
+ isSuccess: boolean;
66
+ isFailed: boolean;
67
+ isCancelled: boolean;
68
+ updatedAt: Date;
69
+ finishedAt?: Date | undefined;
70
+ delayedUntil?: Date | undefined;
71
+ expiredAt?: Date | undefined;
60
72
  payloadPresignedUrl?: string | undefined;
61
73
  outputPresignedUrl?: string | undefined;
62
74
  relatedRuns: {
63
75
  root?: {
64
- taskIdentifier: string;
65
- status: "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "COMPLETED" | "CANCELED" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED" | "TIMED_OUT";
76
+ status: "CANCELED" | "COMPLETED" | "FAILED" | "TIMED_OUT" | "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
66
77
  id: string;
67
- createdAt: Date;
68
- updatedAt: Date;
78
+ tags: string[];
69
79
  isTest: boolean;
80
+ createdAt: Date;
81
+ durationMs: number;
70
82
  costInCents: number;
71
83
  baseCostInCents: number;
72
- tags: string[];
73
- durationMs: number;
84
+ taskIdentifier: string;
74
85
  depth: number;
75
- triggerFunction: "triggerAndWait" | "trigger" | "batchTriggerAndWait" | "batchTrigger";
86
+ triggerFunction: "trigger" | "batchTrigger" | "triggerAndWait" | "batchTriggerAndWait";
76
87
  isQueued: boolean;
77
88
  isExecuting: boolean;
78
89
  isCompleted: boolean;
79
90
  isSuccess: boolean;
80
91
  isFailed: boolean;
81
92
  isCancelled: boolean;
82
- batchId?: string | undefined;
93
+ updatedAt: Date;
94
+ startedAt?: Date | undefined;
83
95
  idempotencyKey?: string | undefined;
84
96
  version?: string | undefined;
85
- startedAt?: Date | undefined;
97
+ metadata?: Record<string, any> | undefined;
98
+ ttl?: string | undefined;
99
+ batchId?: string | undefined;
86
100
  finishedAt?: Date | undefined;
87
101
  delayedUntil?: Date | undefined;
88
- ttl?: string | undefined;
89
102
  expiredAt?: Date | undefined;
90
- metadata?: Record<string, any> | undefined;
91
103
  } | undefined;
92
104
  parent?: {
93
- taskIdentifier: string;
94
- status: "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "COMPLETED" | "CANCELED" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED" | "TIMED_OUT";
105
+ status: "CANCELED" | "COMPLETED" | "FAILED" | "TIMED_OUT" | "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
95
106
  id: string;
96
- createdAt: Date;
97
- updatedAt: Date;
107
+ tags: string[];
98
108
  isTest: boolean;
109
+ createdAt: Date;
110
+ durationMs: number;
99
111
  costInCents: number;
100
112
  baseCostInCents: number;
101
- tags: string[];
102
- durationMs: number;
113
+ taskIdentifier: string;
103
114
  depth: number;
104
- triggerFunction: "triggerAndWait" | "trigger" | "batchTriggerAndWait" | "batchTrigger";
115
+ triggerFunction: "trigger" | "batchTrigger" | "triggerAndWait" | "batchTriggerAndWait";
105
116
  isQueued: boolean;
106
117
  isExecuting: boolean;
107
118
  isCompleted: boolean;
108
119
  isSuccess: boolean;
109
120
  isFailed: boolean;
110
121
  isCancelled: boolean;
111
- batchId?: string | undefined;
122
+ updatedAt: Date;
123
+ startedAt?: Date | undefined;
112
124
  idempotencyKey?: string | undefined;
113
125
  version?: string | undefined;
114
- startedAt?: Date | undefined;
126
+ metadata?: Record<string, any> | undefined;
127
+ ttl?: string | undefined;
128
+ batchId?: string | undefined;
115
129
  finishedAt?: Date | undefined;
116
130
  delayedUntil?: Date | undefined;
117
- ttl?: string | undefined;
118
131
  expiredAt?: Date | undefined;
119
- metadata?: Record<string, any> | undefined;
120
132
  } | undefined;
121
133
  children?: {
122
- taskIdentifier: string;
123
- status: "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "COMPLETED" | "CANCELED" | "FAILED" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED" | "TIMED_OUT";
134
+ status: "CANCELED" | "COMPLETED" | "FAILED" | "TIMED_OUT" | "WAITING_FOR_DEPLOY" | "QUEUED" | "EXECUTING" | "REATTEMPTING" | "FROZEN" | "CRASHED" | "INTERRUPTED" | "SYSTEM_FAILURE" | "DELAYED" | "EXPIRED";
124
135
  id: string;
125
- createdAt: Date;
126
- updatedAt: Date;
136
+ tags: string[];
127
137
  isTest: boolean;
138
+ createdAt: Date;
139
+ durationMs: number;
128
140
  costInCents: number;
129
141
  baseCostInCents: number;
130
- tags: string[];
131
- durationMs: number;
142
+ taskIdentifier: string;
132
143
  depth: number;
133
- triggerFunction: "triggerAndWait" | "trigger" | "batchTriggerAndWait" | "batchTrigger";
144
+ triggerFunction: "trigger" | "batchTrigger" | "triggerAndWait" | "batchTriggerAndWait";
134
145
  isQueued: boolean;
135
146
  isExecuting: boolean;
136
147
  isCompleted: boolean;
137
148
  isSuccess: boolean;
138
149
  isFailed: boolean;
139
150
  isCancelled: boolean;
140
- batchId?: string | undefined;
151
+ updatedAt: Date;
152
+ startedAt?: Date | undefined;
141
153
  idempotencyKey?: string | undefined;
142
154
  version?: string | undefined;
143
- startedAt?: Date | undefined;
155
+ metadata?: Record<string, any> | undefined;
156
+ ttl?: string | undefined;
157
+ batchId?: string | undefined;
144
158
  finishedAt?: Date | undefined;
145
159
  delayedUntil?: Date | undefined;
146
- ttl?: string | undefined;
147
160
  expiredAt?: Date | undefined;
148
- metadata?: Record<string, any> | undefined;
149
161
  }[] | undefined;
150
162
  };
151
- depth: number;
152
- triggerFunction: "triggerAndWait" | "trigger" | "batchTriggerAndWait" | "batchTrigger";
153
- batchId?: string | undefined;
154
- isQueued: boolean;
155
- isExecuting: boolean;
156
- isCompleted: boolean;
157
- isSuccess: boolean;
158
- isFailed: boolean;
159
- isCancelled: boolean;
160
- finishedAt?: Date | undefined;
161
- delayedUntil?: Date | undefined;
162
163
  attempts: ({
163
- status: "EXECUTING" | "COMPLETED" | "CANCELED" | "FAILED" | "PENDING" | "PAUSED";
164
+ status: "PENDING" | "CANCELED" | "COMPLETED" | "FAILED" | "EXECUTING" | "PAUSED";
164
165
  id: string;
165
166
  createdAt: Date;
166
167
  updatedAt: Date;
167
168
  startedAt?: Date | undefined;
168
- completedAt?: Date | undefined;
169
169
  error?: {
170
170
  message: string;
171
171
  name?: string | undefined;
172
172
  stackTrace?: string | undefined;
173
173
  } | undefined;
174
+ completedAt?: Date | undefined;
174
175
  } | undefined)[];
175
176
  attemptCount: number;
176
177
  output?: InferRunTypes<TRunId>["output"] | undefined;
177
178
  payload?: InferRunTypes<TRunId>["payload"] | undefined;
178
179
  }>;
180
+ /**
181
+ * Subscribes to real-time updates for a specific run.
182
+ *
183
+ * This function allows you to receive real-time updates whenever a run changes, including:
184
+ * - Status changes in the run lifecycle
185
+ * - Tag additions or removals
186
+ * - Metadata updates
187
+ *
188
+ * @template TRunId - The type parameter extending AnyRunHandle, AnyTask, or string
189
+ * @param {RunId<TRunId>} runId - The ID of the run to subscribe to. Can be a string ID, RunHandle, or Task
190
+ * @returns {RunSubscription<InferRunTypes<TRunId>>} An async iterator that yields updated run objects
191
+ *
192
+ * @example
193
+ * ```ts
194
+ * // Subscribe using a run handle
195
+ * const handle = await tasks.trigger("my-task", { some: "data" });
196
+ * for await (const run of runs.subscribeToRun(handle.id)) {
197
+ * console.log("Run updated:", run);
198
+ * }
199
+ *
200
+ * // Subscribe with type safety
201
+ * for await (const run of runs.subscribeToRun<typeof myTask>(runId)) {
202
+ * console.log("Payload:", run.payload.some);
203
+ * if (run.output) {
204
+ * console.log("Output:", run.output);
205
+ * }
206
+ * }
207
+ * ```
208
+ */
179
209
  declare function subscribeToRun<TRunId extends AnyRunHandle | AnyTask | string>(runId: RunId<TRunId>): RunSubscription<InferRunTypes<TRunId>>;
210
+ /**
211
+ * Subscribes to real-time updates for all runs that have specific tags.
212
+ *
213
+ * This function allows you to monitor multiple runs simultaneously by filtering on tags.
214
+ * You'll receive updates whenever any run with the specified tag(s) changes.
215
+ *
216
+ * @template TTasks - The type parameter extending AnyTask for type-safe payload and output
217
+ * @param {string | string[]} tag - A single tag or array of tags to filter runs
218
+ * @returns {RunSubscription<InferRunTypes<TTasks>>} An async iterator that yields updated run objects
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * // Subscribe to runs with a single tag
223
+ * for await (const run of runs.subscribeToRunsWithTag("user:1234")) {
224
+ * console.log("Run updated:", run);
225
+ * }
226
+ *
227
+ * // Subscribe with multiple tags and type safety
228
+ * for await (const run of runs.subscribeToRunsWithTag<typeof myTask | typeof otherTask>(["tag1", "tag2"])) {
229
+ * switch (run.taskIdentifier) {
230
+ * case "my-task":
231
+ * console.log("MyTask output:", run.output.foo);
232
+ * break;
233
+ * case "other-task":
234
+ * console.log("OtherTask output:", run.output.bar);
235
+ * break;
236
+ * }
237
+ * }
238
+ * ```
239
+ */
180
240
  declare function subscribeToRunsWithTag<TTasks extends AnyTask>(tag: string | string[]): RunSubscription<InferRunTypes<TTasks>>;
241
+ /**
242
+ * Subscribes to real-time updates for all runs within a specific batch.
243
+ *
244
+ * Use this function when you've triggered multiple runs using `batchTrigger` and want
245
+ * to monitor all runs in that batch. You'll receive updates whenever any run in the batch changes.
246
+ *
247
+ * @template TTasks - The type parameter extending AnyTask for type-safe payload and output
248
+ * @param {string} batchId - The ID of the batch to subscribe to
249
+ * @returns {RunSubscription<InferRunTypes<TTasks>>} An async iterator that yields updated run objects
250
+ *
251
+ * @example
252
+ * ```ts
253
+ * // Subscribe to all runs in a batch
254
+ * for await (const run of runs.subscribeToRunsInBatch("batch-123")) {
255
+ * console.log("Batch run updated:", run);
256
+ * }
257
+ *
258
+ * // Subscribe with type safety
259
+ * for await (const run of runs.subscribeToRunsInBatch<typeof myTask>("batch-123")) {
260
+ * console.log("Run payload:", run.payload);
261
+ * if (run.output) {
262
+ * console.log("Run output:", run.output);
263
+ * }
264
+ * }
265
+ * ```
266
+ *
267
+ * @note The run objects received will include standard fields like id, status, payload, output,
268
+ * createdAt, updatedAt, tags, and more. See the Run object documentation for full details.
269
+ */
270
+ declare function subscribeToRunsInBatch<TTasks extends AnyTask>(batchId: string): RunSubscription<InferRunTypes<TTasks>>;