@hatchet-dev/typescript-sdk 1.0.0-alpha1 → 1.0.0

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 (194) hide show
  1. package/clients/admin/admin-client.d.ts +15 -20
  2. package/clients/admin/admin-client.js +21 -17
  3. package/clients/hatchet-client/hatchet-client.d.ts +5 -4
  4. package/clients/hatchet-client/hatchet-client.js +6 -4
  5. package/clients/listeners/durable-listener/durable-listener-client.d.ts +25 -0
  6. package/clients/listeners/durable-listener/durable-listener-client.js +30 -0
  7. package/clients/listeners/durable-listener/pooled-durable-listener-client.d.ts +43 -0
  8. package/clients/listeners/durable-listener/pooled-durable-listener-client.js +241 -0
  9. package/clients/{listener/listener-client.d.ts → listeners/run-listener/child-listener-client.d.ts} +8 -8
  10. package/clients/{listener/listener-client.js → listeners/run-listener/child-listener-client.js} +8 -19
  11. package/clients/{listener/child-listener-client.d.ts → listeners/run-listener/pooled-child-listener-client.d.ts} +5 -5
  12. package/clients/{listener/child-listener-client.js → listeners/run-listener/pooled-child-listener-client.js} +5 -5
  13. package/clients/rest/generated/Api.d.ts +49 -2
  14. package/clients/rest/generated/Api.js +30 -0
  15. package/clients/rest/generated/data-contracts.d.ts +88 -82
  16. package/clients/rest/generated/data-contracts.js +8 -1
  17. package/clients/worker/worker.d.ts +5 -1
  18. package/clients/worker/worker.js +173 -2
  19. package/examples/affinity-workers.js +5 -1
  20. package/examples/api.js +1 -1
  21. package/examples/bulk-fanout-worker.js +1 -1
  22. package/examples/byo-logger.js +4 -0
  23. package/examples/concurrency/cancel-in-progress/concurrency-event.js +2 -2
  24. package/examples/concurrency/group-round-robin/concurrency-event.js +1 -1
  25. package/examples/crons/programatic-crons.js +4 -4
  26. package/examples/dag-worker.js +0 -1
  27. package/examples/example-event.js +2 -2
  28. package/examples/logger.js +2 -0
  29. package/examples/on-failure.js +1 -1
  30. package/examples/rate-limit/events.js +3 -3
  31. package/examples/scheduled-runs/programatic-schedules.js +4 -4
  32. package/examples/sticky-worker-with-check.js +2 -2
  33. package/examples/sticky-worker.js +5 -0
  34. package/index.d.ts +1 -3
  35. package/index.js +1 -3
  36. package/package.json +2 -2
  37. package/protoc/dispatcher/dispatcher.d.ts +2 -0
  38. package/protoc/dispatcher/dispatcher.js +1 -1
  39. package/protoc/events/events.js +1 -1
  40. package/protoc/google/protobuf/timestamp.js +1 -1
  41. package/protoc/v1/dispatcher.d.ts +77 -0
  42. package/protoc/v1/dispatcher.js +341 -0
  43. package/protoc/v1/shared/condition.d.ts +59 -0
  44. package/protoc/v1/shared/condition.js +549 -0
  45. package/protoc/v1/workflows.d.ts +263 -0
  46. package/protoc/v1/workflows.js +1823 -0
  47. package/protoc/workflows/workflows.js +1 -1
  48. package/step.d.ts +173 -47
  49. package/step.js +208 -64
  50. package/util/sleep.d.ts +7 -0
  51. package/util/sleep.js +7 -0
  52. package/util/workflow-run-ref.d.ts +8 -2
  53. package/util/workflow-run-ref.js +13 -0
  54. package/v1/client/client.d.ts +125 -7
  55. package/v1/client/client.interface.d.ts +9 -1
  56. package/v1/client/client.js +148 -17
  57. package/v1/client/duration.d.ts +7 -0
  58. package/v1/client/duration.js +2 -0
  59. package/v1/client/features/index.d.ts +5 -0
  60. package/v1/client/features/index.js +21 -0
  61. package/v1/client/features/metrics.d.ts +14 -0
  62. package/v1/client/features/metrics.js +45 -0
  63. package/v1/client/features/ratelimits.d.ts +20 -0
  64. package/v1/client/features/ratelimits.js +40 -0
  65. package/v1/client/features/runs.d.ts +15 -0
  66. package/v1/client/features/runs.js +60 -0
  67. package/v1/client/features/workers.d.ts +14 -0
  68. package/v1/client/features/workers.js +56 -0
  69. package/v1/client/features/workflows.d.ts +17 -0
  70. package/v1/client/features/workflows.js +93 -0
  71. package/v1/client/worker.d.ts +25 -15
  72. package/v1/client/worker.js +76 -47
  73. package/v1/conditions/base.d.ts +18 -0
  74. package/v1/conditions/base.js +18 -0
  75. package/v1/conditions/index.d.ts +31 -0
  76. package/v1/conditions/index.js +91 -0
  77. package/v1/conditions/parent-condition.d.ts +40 -0
  78. package/v1/conditions/parent-condition.js +36 -0
  79. package/v1/conditions/sleep-condition.d.ts +47 -0
  80. package/v1/conditions/sleep-condition.js +38 -0
  81. package/v1/conditions/transformer.d.ts +5 -0
  82. package/v1/conditions/transformer.js +52 -0
  83. package/v1/conditions/user-event-condition.d.ts +50 -0
  84. package/v1/conditions/user-event-condition.js +39 -0
  85. package/v1/declaration.d.ts +309 -0
  86. package/v1/declaration.js +296 -0
  87. package/v1/examples/child_workflows/worker.js +2 -2
  88. package/v1/examples/child_workflows/workflow.d.ts +2 -2
  89. package/v1/examples/child_workflows/workflow.js +5 -3
  90. package/v1/examples/concurrency-rr/load.js +2 -2
  91. package/v1/examples/concurrency-rr/worker.js +2 -2
  92. package/v1/examples/concurrency-rr/workflow.d.ts +1 -1
  93. package/v1/examples/concurrency-rr/workflow.js +2 -3
  94. package/v1/examples/dag/worker.js +2 -2
  95. package/v1/examples/dag/workflow.d.ts +1 -1
  96. package/v1/examples/dag/workflow.js +3 -3
  97. package/v1/examples/dag_match_condition/event.js +28 -0
  98. package/v1/examples/dag_match_condition/run.d.ts +1 -0
  99. package/v1/examples/dag_match_condition/run.js +25 -0
  100. package/v1/examples/dag_match_condition/worker.d.ts +1 -0
  101. package/{examples/playground.js → v1/examples/dag_match_condition/worker.js} +7 -22
  102. package/v1/examples/dag_match_condition/workflow.d.ts +11 -0
  103. package/v1/examples/dag_match_condition/workflow.js +41 -0
  104. package/v1/examples/deep/worker.js +2 -2
  105. package/v1/examples/deep/workflow.d.ts +6 -6
  106. package/v1/examples/deep/workflow.js +7 -7
  107. package/v1/examples/durable-sleep/event.d.ts +1 -0
  108. package/v1/examples/durable-sleep/event.js +28 -0
  109. package/v1/examples/durable-sleep/run.d.ts +1 -0
  110. package/v1/examples/durable-sleep/run.js +30 -0
  111. package/v1/examples/durable-sleep/worker.d.ts +1 -0
  112. package/v1/examples/durable-sleep/worker.js +24 -0
  113. package/v1/examples/durable-sleep/workflow.d.ts +1 -0
  114. package/v1/examples/durable-sleep/workflow.js +37 -0
  115. package/v1/examples/inferred-typing/run.d.ts +1 -0
  116. package/v1/examples/inferred-typing/run.js +41 -0
  117. package/v1/examples/inferred-typing/worker.d.ts +1 -0
  118. package/v1/examples/inferred-typing/worker.js +24 -0
  119. package/v1/examples/inferred-typing/workflow.d.ts +15 -0
  120. package/v1/examples/inferred-typing/workflow.js +44 -0
  121. package/v1/examples/landing_page/durable-excution.d.ts +3 -0
  122. package/v1/examples/landing_page/durable-excution.js +40 -0
  123. package/v1/examples/landing_page/event-signaling.d.ts +6 -0
  124. package/v1/examples/landing_page/event-signaling.js +16 -0
  125. package/v1/examples/landing_page/flow-control.d.ts +6 -0
  126. package/v1/examples/landing_page/flow-control.js +26 -0
  127. package/v1/examples/landing_page/queues.d.ts +3 -0
  128. package/v1/examples/landing_page/queues.js +33 -0
  129. package/v1/examples/landing_page/scheduling.d.ts +1 -0
  130. package/v1/examples/landing_page/scheduling.js +12 -0
  131. package/v1/examples/landing_page/task-routing.d.ts +6 -0
  132. package/v1/examples/landing_page/task-routing.js +25 -0
  133. package/v1/examples/legacy/run.js +2 -2
  134. package/v1/examples/legacy/worker.js +2 -2
  135. package/v1/examples/on_cron/worker.d.ts +1 -0
  136. package/v1/examples/on_cron/worker.js +24 -0
  137. package/v1/examples/on_cron/workflow.d.ts +10 -0
  138. package/v1/examples/on_cron/workflow.js +21 -0
  139. package/v1/examples/on_event/event.js +3 -2
  140. package/v1/examples/on_event/worker.js +2 -2
  141. package/v1/examples/on_event/workflow.d.ts +4 -4
  142. package/v1/examples/on_event/workflow.js +6 -3
  143. package/v1/examples/on_event copy/event.d.ts +1 -0
  144. package/v1/examples/on_event copy/event.js +26 -0
  145. package/v1/examples/on_event copy/worker.d.ts +1 -0
  146. package/v1/examples/on_event copy/worker.js +24 -0
  147. package/v1/examples/on_event copy/workflow.d.ts +16 -0
  148. package/v1/examples/on_event copy/workflow.js +35 -0
  149. package/v1/examples/on_failure/worker.js +2 -2
  150. package/v1/examples/on_failure/workflow.d.ts +1 -1
  151. package/v1/examples/on_failure/workflow.js +18 -8
  152. package/v1/examples/on_success/run.d.ts +1 -0
  153. package/v1/examples/on_success/run.js +31 -0
  154. package/v1/examples/on_success/worker.d.ts +1 -0
  155. package/v1/examples/on_success/worker.js +24 -0
  156. package/v1/examples/on_success/workflow.d.ts +4 -0
  157. package/v1/examples/on_success/workflow.js +59 -0
  158. package/v1/examples/retries/run.d.ts +1 -0
  159. package/v1/examples/retries/run.js +29 -0
  160. package/v1/examples/retries/worker.d.ts +1 -0
  161. package/v1/examples/retries/worker.js +24 -0
  162. package/v1/examples/retries/workflow.d.ts +5 -0
  163. package/v1/examples/retries/workflow.js +53 -0
  164. package/v1/examples/simple/client-run.d.ts +1 -0
  165. package/v1/examples/simple/client-run.js +16 -0
  166. package/v1/examples/simple/cron.js +6 -2
  167. package/v1/examples/simple/delay.js +2 -2
  168. package/v1/examples/simple/enqueue.d.ts +1 -0
  169. package/v1/examples/simple/enqueue.js +43 -0
  170. package/v1/examples/simple/run.js +8 -3
  171. package/v1/examples/simple/schedule.js +11 -5
  172. package/v1/examples/simple/stub-workflow.d.ts +9 -0
  173. package/v1/examples/simple/stub-workflow.js +17 -0
  174. package/v1/examples/simple/worker.js +7 -2
  175. package/v1/examples/simple/workflow.d.ts +4 -3
  176. package/v1/examples/simple/workflow.js +5 -5
  177. package/v1/examples/sticky/run.d.ts +1 -0
  178. package/v1/examples/sticky/run.js +29 -0
  179. package/v1/examples/sticky/worker.d.ts +1 -0
  180. package/v1/examples/sticky/worker.js +24 -0
  181. package/v1/examples/sticky/workflow.d.ts +7 -0
  182. package/v1/examples/sticky/workflow.js +32 -0
  183. package/v1/examples/with_timeouts/workflow.d.ts +9 -0
  184. package/v1/examples/with_timeouts/workflow.js +62 -0
  185. package/v1/index.d.ts +5 -0
  186. package/v1/index.js +20 -0
  187. package/v1/task.d.ts +144 -14
  188. package/version.d.ts +1 -1
  189. package/version.js +1 -1
  190. package/v1/workflow.d.ts +0 -158
  191. package/v1/workflow.js +0 -145
  192. /package/{examples/playground.d.ts → v1/examples/dag_match_condition/event.d.ts} +0 -0
  193. /package/v1/examples/{client.d.ts → hatchet-client.d.ts} +0 -0
  194. /package/v1/examples/{client.js → hatchet-client.js} +0 -0
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
- // protoc-gen-ts_proto v2.6.0
4
+ // protoc-gen-ts_proto v2.6.1
5
5
  // protoc v3.19.1
6
6
  // source: workflows/workflows.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
package/step.d.ts CHANGED
@@ -8,8 +8,10 @@ import WorkflowRunRef from './util/workflow-run-ref';
8
8
  import { V0Worker } from './clients/worker';
9
9
  import { WorkerLabels } from './clients/dispatcher/dispatcher-client';
10
10
  import { CreateStepRateLimit, RateLimitDuration, WorkerLabelComparator } from './protoc/workflows';
11
- import { CreateTaskOpts } from './v1/task';
12
- import { WorkflowDeclaration as WorkflowV1 } from './v1/workflow';
11
+ import { CreateWorkflowTaskOpts } from './v1/task';
12
+ import { BaseWorkflowDeclaration as WorkflowV1 } from './v1/declaration';
13
+ import { Conditions } from './v1/conditions';
14
+ import { Duration } from './v1/client/duration';
13
15
  export declare const CreateRateLimitSchema: z.ZodObject<{
14
16
  key: z.ZodOptional<z.ZodString>;
15
17
  staticKey: z.ZodOptional<z.ZodString>;
@@ -159,8 +161,10 @@ export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
159
161
  export type NextStep = {
160
162
  [key: string]: JsonValue;
161
163
  };
164
+ type TriggerData = Record<string, Record<string, any>>;
162
165
  interface ContextData<T, K> {
163
166
  input: T;
167
+ triggers: TriggerData;
164
168
  parents: Record<string, any>;
165
169
  triggered_by: string;
166
170
  user_data: K;
@@ -169,9 +173,27 @@ interface ContextData<T, K> {
169
173
  export declare class ContextWorker {
170
174
  private worker;
171
175
  constructor(worker: V0Worker);
176
+ /**
177
+ * Gets the ID of the worker.
178
+ * @returns The ID of the worker.
179
+ */
172
180
  id(): string | undefined;
181
+ /**
182
+ * Checks if the worker has a registered workflow.
183
+ * @param workflowName - The name of the workflow to check.
184
+ * @returns True if the workflow is registered, otherwise false.
185
+ */
173
186
  hasWorkflow(workflowName: string): boolean;
187
+ /**
188
+ * Gets the current state of the worker labels.
189
+ * @returns The labels of the worker.
190
+ */
174
191
  labels(): WorkerLabels;
192
+ /**
193
+ * Upserts the a set of labels on the worker.
194
+ * @param labels - The labels to upsert.
195
+ * @returns A promise that resolves when the labels have been upserted.
196
+ */
175
197
  upsertLabels(labels: WorkerLabels): Promise<WorkerLabels>;
176
198
  }
177
199
  export declare class Context<T, K = {}> {
@@ -185,33 +207,111 @@ export declare class Context<T, K = {}> {
185
207
  logger: Logger;
186
208
  spawnIndex: number;
187
209
  constructor(action: Action, client: InternalHatchetClient, worker: V0Worker);
188
- parentData<L = NextStep>(task: CreateTaskOpts<any, L> | string): Promise<L>;
210
+ /**
211
+ * Retrieves the output of a parent task.
212
+ * @param task - The name of the task or a CreateTaskOpts object.
213
+ * @returns The output of the specified parent task.
214
+ * @throws An error if the task output is not found.
215
+ *
216
+ */
217
+ parentOutput<L = NextStep>(task: CreateWorkflowTaskOpts<any, L> | string): Promise<L>;
218
+ /**
219
+ * Get the output of a task.
220
+ * @param task - The name of the task to get the output for.
221
+ * @returns The output of the task.
222
+ * @throws An error if the task output is not found.
223
+ * @deprecated use ctx.parentOutput instead
224
+ */
189
225
  stepOutput<L = NextStep>(step: string): L;
226
+ /**
227
+ * Returns errors from any task runs in the workflow.
228
+ * @returns A record mapping task names to error messages.
229
+ * @throws A warning if no errors are found (this method should be used in on-failure tasks).
230
+ * @deprecated use ctx.errors instead
231
+ */
190
232
  stepRunErrors(): Record<string, string>;
233
+ /**
234
+ * Returns errors from any task runs in the workflow.
235
+ * @returns A record mapping task names to error messages.
236
+ * @throws A warning if no errors are found (this method should be used in on-failure tasks).
237
+ */
238
+ errors(): Record<string, string>;
239
+ /**
240
+ * Gets the dag conditional triggers for the current workflow run.
241
+ * @returns The triggers for the current workflow.
242
+ */
243
+ triggers(): TriggerData;
244
+ /**
245
+ * Determines if the workflow was triggered by an event.
246
+ * @returns True if the workflow was triggered by an event, otherwise false.
247
+ */
191
248
  triggeredByEvent(): boolean;
249
+ /**
250
+ * Gets the input data for the current workflow.
251
+ * @returns The input data for the workflow.
252
+ */
192
253
  workflowInput(): T;
254
+ /**
255
+ * Gets the name of the current workflow.
256
+ * @returns The name of the workflow.
257
+ */
193
258
  workflowName(): string;
259
+ /**
260
+ * Gets the user data associated with the workflow.
261
+ * @returns The user data.
262
+ */
194
263
  userData(): K;
264
+ /**
265
+ * Gets the name of the current task.
266
+ * @returns The name of the task.
267
+ * @deprecated use ctx.taskName instead
268
+ */
195
269
  stepName(): string;
270
+ /**
271
+ * Gets the name of the current running task.
272
+ * @returns The name of the task.
273
+ */
274
+ taskName(): string;
275
+ /**
276
+ * Gets the ID of the current workflow run.
277
+ * @returns The workflow run ID.
278
+ */
196
279
  workflowRunId(): string;
280
+ /**
281
+ * Gets the number of times the current task has been retried.
282
+ * @returns The retry count.
283
+ */
197
284
  retryCount(): number;
198
- playground(name: string, defaultValue?: string): string;
285
+ /**
286
+ * Logs a message from the current task.
287
+ * @param message - The message to log.
288
+ * @param level - The log level (optional).
289
+ */
199
290
  log(message: string, level?: LogLevel): void;
200
291
  /**
201
- * Refreshes the timeout for the current step.
292
+ * Refreshes the timeout for the current task.
202
293
  * @param incrementBy - The interval by which to increment the timeout.
203
- * The interval should be specified in the format of '10s' for 10 seconds,
204
- * '1m' for 1 minute, or '1d' for 1 day.
294
+ * The interval should be specified in the format of '10s' for 10 seconds, '1m' for 1 minute, or '1d' for 1 day.
295
+ */
296
+ refreshTimeout(incrementBy: Duration): Promise<void>;
297
+ /**
298
+ * Releases a worker slot for a task run such that the worker can pick up another task.
299
+ * Note: this is an advanced feature that may lead to unexpected behavior if used incorrectly.
300
+ * @returns A promise that resolves when the slot has been released.
205
301
  */
206
- refreshTimeout(incrementBy: string): Promise<void>;
207
302
  releaseSlot(): Promise<void>;
303
+ /**
304
+ * Streams data from the current task run.
305
+ * @param data - The data to stream (string or binary).
306
+ * @returns A promise that resolves when the data has been streamed.
307
+ */
208
308
  putStream(data: string | Uint8Array): Promise<void>;
209
309
  /**
210
- * Enqueues multiple children workflows in parallel.
211
- * @param children an array of objects containing the workflow name, input data, and options for each workflow
212
- * @returns a list of workflow run references to the enqueued runs
310
+ * Runs multiple children workflows in parallel without waiting for their results.
311
+ * @param children - An array of objects containing the workflow name, input data, and options for each workflow.
312
+ * @returns A list of workflow run references to the enqueued runs.
213
313
  */
214
- bulkEnqueueChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
314
+ bulkRunNoWaitChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
215
315
  workflow: string | Workflow | WorkflowV1<Q, P>;
216
316
  input: Q;
217
317
  options?: {
@@ -221,9 +321,9 @@ export declare class Context<T, K = {}> {
221
321
  };
222
322
  }>): Promise<WorkflowRunRef<P>[]>;
223
323
  /**
224
- * Runs multiple children workflows in parallel.
225
- * @param children an array of objects containing the workflow name, input data, and options for each workflow
226
- * @returns a list of results from the children workflows
324
+ * Runs multiple children workflows in parallel and waits for all results.
325
+ * @param children - An array of objects containing the workflow name, input data, and options for each workflow.
326
+ * @returns A list of results from the children workflows.
227
327
  */
228
328
  bulkRunChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
229
329
  workflow: string | Workflow | WorkflowV1<Q, P>;
@@ -237,9 +337,9 @@ export declare class Context<T, K = {}> {
237
337
  /**
238
338
  * Spawns multiple workflows.
239
339
  *
240
- * @param workflows an array of objects containing the workflow name, input data, and options for each workflow
241
- * @returns a list of references to the spawned workflow runs
242
- * @deprecated use bulkEnqueueChildren or bulkRunChildren instead
340
+ * @param workflows - An array of objects containing the workflow name, input data, and options for each workflow.
341
+ * @returns A list of references to the spawned workflow runs.
342
+ * @deprecated Use bulkRunNoWaitChildren or bulkRunChildren instead.
243
343
  */
244
344
  spawnWorkflows<Q extends JsonObject = any, P extends JsonObject = any>(workflows: Array<{
245
345
  workflow: string | Workflow | WorkflowV1<Q, P>;
@@ -251,14 +351,12 @@ export declare class Context<T, K = {}> {
251
351
  };
252
352
  }>): Promise<WorkflowRunRef<P>[]>;
253
353
  /**
254
- * Runs a new workflow.
354
+ * Runs a new workflow and waits for its result.
255
355
  *
256
- * @param workflow the workflow to run
257
- * @param input the input data for the workflow
258
- * @param options additional options for spawning the workflow. If a string is provided, it is used as the key.
259
- * @param <Q> the type of the input data
260
- * @param <P> the type of the output data
261
- * @return the result of the workflow
356
+ * @param workflow - The workflow to run (name, Workflow instance, or WorkflowV1 instance).
357
+ * @param input - The input data for the workflow.
358
+ * @param options - Additional options for spawning the workflow. If a string is provided, it is used as the key.
359
+ * @returns The result of the workflow.
262
360
  */
263
361
  runChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: string | {
264
362
  key?: string;
@@ -266,19 +364,14 @@ export declare class Context<T, K = {}> {
266
364
  additionalMetadata?: Record<string, string>;
267
365
  }): Promise<P>;
268
366
  /**
269
- * Enqueues a new workflow.
367
+ * Enqueues a new workflow without waiting for its result.
270
368
  *
271
- * @param workflowName the name of the workflow to spawn
272
- * @param input the input data for the workflow
273
- * @param options additional options for spawning the workflow. If a string is provided, it is used as the key.
274
- * If an object is provided, it can include:
275
- * - key: a unique identifier for the workflow (deprecated, use options.key instead)
276
- * - sticky: a boolean indicating whether to use sticky execution
277
- * @param <Q> the type of the input data
278
- * @param <P> the type of the output data
279
- * @return a reference to the spawned workflow run
280
- */
281
- enqueueChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: string | {
369
+ * @param workflow - The workflow to enqueue (name, Workflow instance, or WorkflowV1 instance).
370
+ * @param input - The input data for the workflow.
371
+ * @param options - Additional options for spawning the workflow.
372
+ * @returns A reference to the spawned workflow run.
373
+ */
374
+ runNoWaitChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: string | {
282
375
  key?: string;
283
376
  sticky?: boolean;
284
377
  additionalMetadata?: Record<string, string>;
@@ -286,28 +379,61 @@ export declare class Context<T, K = {}> {
286
379
  /**
287
380
  * Spawns a new workflow.
288
381
  *
289
- * @param workflowName the name of the workflow to spawn
290
- * @param input the input data for the workflow
291
- * @param options additional options for spawning the workflow. If a string is provided, it is used as the key.
292
- * If an object is provided, it can include:
293
- * - key: a unique identifier for the workflow (deprecated, use options.key instead)
294
- * - sticky: a boolean indicating whether to use sticky execution
295
- * @param <Q> the type of the input data
296
- * @param <P> the type of the output data
297
- * @return a reference to the spawned workflow run
298
- * @deprecated use runChild or enqueueChild instead
382
+ * @param workflow - The workflow to spawn (name, Workflow instance, or WorkflowV1 instance).
383
+ * @param input - The input data for the workflow.
384
+ * @param options - Additional options for spawning the workflow.
385
+ * @returns A reference to the spawned workflow run.
386
+ * @deprecated Use runChild or runNoWaitChild instead.
299
387
  */
300
388
  spawnWorkflow<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: string | {
301
389
  key?: string;
302
390
  sticky?: boolean;
303
391
  additionalMetadata?: Record<string, string>;
304
392
  }): WorkflowRunRef<P>;
393
+ /**
394
+ * Retrieves additional metadata associated with the current workflow run.
395
+ * @returns A record of metadata key-value pairs.
396
+ */
305
397
  additionalMetadata(): Record<string, string>;
398
+ /**
399
+ * Gets the index of this workflow if it was spawned as part of a bulk operation.
400
+ * @returns The child index number, or undefined if not set.
401
+ */
306
402
  childIndex(): number | undefined;
403
+ /**
404
+ * Gets the key associated with this workflow if it was spawned as a child workflow.
405
+ * @returns The child key, or undefined if not set.
406
+ */
307
407
  childKey(): string | undefined;
408
+ /**
409
+ * Gets the ID of the parent workflow run if this workflow was spawned as a child.
410
+ * @returns The parent workflow run ID, or undefined if not a child workflow.
411
+ */
308
412
  parentWorkflowRunId(): string | undefined;
309
413
  }
414
+ export declare class DurableContext<T, K = {}> extends Context<T, K> {
415
+ waitKey: number;
416
+ /**
417
+ * Pauses execution for the specified duration.
418
+ * Duration is "global" meaning it will wait in real time regardless of transient failures like worker restarts.
419
+ * @param duration - The duration to sleep for.
420
+ * @returns A promise that resolves when the sleep duration has elapsed.
421
+ */
422
+ sleepFor(duration: Duration, readableDataKey?: string): Promise<Record<string, any>>;
423
+ /**
424
+ * Pauses execution until the specified conditions are met.
425
+ * Conditions are "global" meaning they will wait in real time regardless of transient failures like worker restarts.
426
+ * @param conditions - The conditions to wait for.
427
+ * @returns A promise that resolves with the event that satisfied the conditions.
428
+ */
429
+ waitFor(conditions: Conditions | Conditions[]): Promise<Record<string, any>>;
430
+ }
310
431
  export type StepRunFunction<T, K> = (ctx: Context<T, K>) => Promise<NextStep | void> | NextStep | void;
432
+ /**
433
+ * A step is a unit of work that can be run by a worker.
434
+ * It is defined by a name, a function that returns the next step, and optional configuration.
435
+ * @deprecated use hatchet.workflows.task factory instead
436
+ */
311
437
  export interface CreateStep<T, K> extends z.infer<typeof CreateStepSchema> {
312
438
  run: StepRunFunction<T, K>;
313
439
  }