@hatchet-dev/typescript-sdk 1.13.0 → 1.14.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 (245) hide show
  1. package/clients/dispatcher/dispatcher-client.d.ts +1 -1
  2. package/clients/dispatcher/heartbeat/heartbeat-controller.js +13 -1
  3. package/clients/dispatcher/heartbeat/heartbeat-worker.js +4 -3
  4. package/clients/event/event-client.d.ts +1 -2
  5. package/clients/event/event-client.js +2 -2
  6. package/clients/hatchet-client/client-config.d.ts +15 -5
  7. package/clients/hatchet-client/client-config.js +3 -0
  8. package/clients/hatchet-client/hatchet-logger.js +1 -0
  9. package/clients/hatchet-client/index.d.ts +1 -1
  10. package/clients/hatchet-client/index.js +1 -1
  11. package/clients/listeners/durable-listener/durable-listener-client.d.ts +6 -0
  12. package/clients/listeners/durable-listener/durable-listener-client.js +8 -0
  13. package/clients/listeners/durable-listener/pooled-durable-listener-client.d.ts +9 -2
  14. package/clients/listeners/durable-listener/pooled-durable-listener-client.js +67 -15
  15. package/clients/listeners/run-listener/child-listener-client.js +1 -0
  16. package/clients/listeners/run-listener/pooled-child-listener-client.d.ts +10 -2
  17. package/clients/listeners/run-listener/pooled-child-listener-client.js +63 -7
  18. package/clients/rest/api.js +10 -2
  19. package/clients/rest/generated/Api.d.ts +2 -2
  20. package/clients/rest/generated/data-contracts.d.ts +6 -0
  21. package/index.d.ts +2 -3
  22. package/index.js +2 -3
  23. package/{examples → legacy/examples}/affinity-workers.js +2 -2
  24. package/{examples → legacy/examples}/bulk-fanout-trigger.js +1 -1
  25. package/{examples → legacy/examples}/bulk-fanout-worker.js +1 -1
  26. package/{examples → legacy/examples}/bulk-trigger.js +1 -1
  27. package/{examples → legacy/examples}/byo-logger.js +1 -1
  28. package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-event.js +1 -1
  29. package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-worker.js +1 -1
  30. package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-event.js +1 -1
  31. package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.js +2 -2
  32. package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.js +2 -2
  33. package/{examples → legacy/examples}/crons/cron-worker.d.ts +1 -1
  34. package/{examples → legacy/examples}/crons/cron-worker.js +1 -1
  35. package/{examples → legacy/examples}/crons/programatic-crons.js +1 -1
  36. package/{examples → legacy/examples}/dag-worker.js +1 -1
  37. package/{examples → legacy/examples}/example-event-with-results.js +2 -2
  38. package/{examples → legacy/examples}/example-event.js +1 -1
  39. package/{examples → legacy/examples}/fanout-worker.js +1 -1
  40. package/{examples → legacy/examples}/logger.js +1 -1
  41. package/{examples → legacy/examples}/manual-trigger.js +1 -1
  42. package/{examples → legacy/examples}/multi-workflow.js +1 -1
  43. package/{examples → legacy/examples}/namespaced-worker.js +1 -1
  44. package/{examples → legacy/examples}/on-failure.js +1 -1
  45. package/{examples → legacy/examples}/rate-limit/events.js +1 -1
  46. package/{examples → legacy/examples}/rate-limit/worker.js +2 -2
  47. package/{examples → legacy/examples}/retries-with-backoff.js +1 -1
  48. package/{examples → legacy/examples}/retries-worker.js +1 -1
  49. package/{examples → legacy/examples}/scheduled-runs/programatic-schedules.js +1 -1
  50. package/{examples → legacy/examples}/simple-worker.d.ts +1 -1
  51. package/{examples → legacy/examples}/simple-worker.js +1 -1
  52. package/{examples → legacy/examples}/sticky-trigger.js +1 -1
  53. package/{examples → legacy/examples}/sticky-worker-with-check.js +2 -2
  54. package/{examples → legacy/examples}/sticky-worker.js +2 -2
  55. package/{examples → legacy/examples}/stream-by-additional-meta.js +2 -2
  56. package/legacy/legacy-client.d.ts +30 -0
  57. package/legacy/legacy-client.js +67 -0
  58. package/legacy/legacy-transformer.d.ts +38 -0
  59. package/legacy/legacy-transformer.js +181 -0
  60. package/legacy/step.d.ts +429 -0
  61. package/legacy/step.js +662 -0
  62. package/legacy/workflow.d.ts +488 -0
  63. package/legacy/workflow.js +72 -0
  64. package/package.json +7 -7
  65. package/step.d.ts +1 -430
  66. package/step.js +6 -647
  67. package/util/abort-error.d.ts +38 -0
  68. package/util/abort-error.js +58 -0
  69. package/util/hatchet-promise/hatchet-promise.d.ts +8 -1
  70. package/util/hatchet-promise/hatchet-promise.js +3 -2
  71. package/util/logger/index.d.ts +1 -0
  72. package/util/logger/index.js +1 -0
  73. package/util/logger/task-run-log.d.ts +3 -0
  74. package/util/logger/task-run-log.js +20 -0
  75. package/util/sleep.d.ts +5 -2
  76. package/util/sleep.js +27 -4
  77. package/util/workflow-run-ref.d.ts +7 -1
  78. package/util/workflow-run-ref.js +5 -3
  79. package/v1/client/admin.d.ts +8 -1
  80. package/v1/client/admin.js +22 -6
  81. package/v1/client/client.d.ts +36 -18
  82. package/v1/client/client.interface.d.ts +9 -2
  83. package/v1/client/client.js +47 -27
  84. package/v1/client/features/crons.d.ts +3 -3
  85. package/v1/client/features/crons.js +2 -2
  86. package/v1/client/features/schedules.js +2 -2
  87. package/v1/client/features/workflows.d.ts +5 -5
  88. package/v1/client/features/workflows.js +7 -8
  89. package/v1/client/worker/context.d.ts +49 -10
  90. package/v1/client/worker/context.js +92 -20
  91. package/v1/client/worker/deprecated/legacy-v1-worker.d.ts +3 -3
  92. package/v1/client/worker/deprecated/legacy-v1-worker.js +2 -2
  93. package/v1/client/worker/deprecated/legacy-worker.js +9 -7
  94. package/v1/client/worker/slot-utils.d.ts +3 -3
  95. package/v1/client/worker/worker-internal.d.ts +7 -16
  96. package/v1/client/worker/worker-internal.js +225 -209
  97. package/v1/client/worker/worker.d.ts +18 -18
  98. package/v1/client/worker/worker.js +45 -30
  99. package/v1/declaration.d.ts +28 -7
  100. package/v1/declaration.js +56 -6
  101. package/v1/examples/__e2e__/harness.d.ts +19 -0
  102. package/v1/examples/__e2e__/harness.js +70 -0
  103. package/v1/examples/affinity/affinity-workers.js +4 -4
  104. package/v1/examples/bulk_fanout/workflow.d.ts +9 -0
  105. package/v1/examples/bulk_fanout/workflow.js +34 -0
  106. package/v1/examples/bulk_operations/workflow.d.ts +3 -0
  107. package/v1/examples/bulk_operations/workflow.js +44 -0
  108. package/v1/examples/cancellation/cancellation-workflow.d.ts +2 -0
  109. package/v1/examples/cancellation/cancellation-workflow.js +69 -0
  110. package/v1/examples/cancellation/run.js +53 -0
  111. package/v1/examples/cancellation/worker.d.ts +1 -0
  112. package/v1/examples/cancellation/worker.js +29 -0
  113. package/v1/examples/concurrency-types.d.ts +5 -0
  114. package/v1/examples/concurrency-types.js +2 -0
  115. package/v1/examples/concurrency_cancel_in_progress/workflow.d.ts +9 -0
  116. package/v1/examples/concurrency_cancel_in_progress/workflow.js +45 -0
  117. package/v1/examples/concurrency_cancel_newest/workflow.d.ts +9 -0
  118. package/v1/examples/concurrency_cancel_newest/workflow.js +45 -0
  119. package/v1/examples/concurrency_limit_rr/load.d.ts +1 -0
  120. package/v1/examples/concurrency_limit_rr/load.js +54 -0
  121. package/v1/examples/concurrency_limit_rr/run.d.ts +1 -0
  122. package/v1/examples/concurrency_limit_rr/run.js +39 -0
  123. package/v1/examples/concurrency_limit_rr/worker.d.ts +1 -0
  124. package/v1/examples/concurrency_limit_rr/worker.js +24 -0
  125. package/v1/examples/concurrency_limit_rr/workflow.d.ts +12 -0
  126. package/v1/examples/concurrency_limit_rr/workflow.js +62 -0
  127. package/v1/examples/concurrency_multiple_keys/workflow.d.ts +12 -0
  128. package/v1/examples/concurrency_multiple_keys/workflow.js +42 -0
  129. package/v1/examples/concurrency_workflow_level/workflow.d.ts +13 -0
  130. package/v1/examples/concurrency_workflow_level/workflow.js +49 -0
  131. package/v1/examples/conditions/complex-workflow.d.ts +1 -0
  132. package/v1/examples/conditions/complex-workflow.js +107 -0
  133. package/v1/examples/conditions/event.d.ts +1 -0
  134. package/v1/examples/conditions/event.js +28 -0
  135. package/v1/examples/conditions/run.d.ts +1 -0
  136. package/v1/examples/conditions/run.js +25 -0
  137. package/v1/examples/conditions/worker.d.ts +1 -0
  138. package/v1/examples/conditions/worker.js +24 -0
  139. package/v1/examples/conditions/workflow.d.ts +11 -0
  140. package/v1/examples/conditions/workflow.js +41 -0
  141. package/v1/examples/durable/workflow.d.ts +7 -0
  142. package/v1/examples/durable/workflow.js +116 -0
  143. package/v1/examples/durable_event/event.d.ts +1 -0
  144. package/v1/examples/durable_event/event.js +28 -0
  145. package/v1/examples/durable_event/run.d.ts +1 -0
  146. package/v1/examples/durable_event/run.js +30 -0
  147. package/v1/examples/durable_event/worker.d.ts +1 -0
  148. package/v1/examples/durable_event/worker.js +24 -0
  149. package/v1/examples/durable_event/workflow.d.ts +6 -0
  150. package/v1/examples/durable_event/workflow.js +46 -0
  151. package/v1/examples/durable_sleep/event.d.ts +1 -0
  152. package/v1/examples/durable_sleep/event.js +28 -0
  153. package/v1/examples/durable_sleep/run.d.ts +1 -0
  154. package/v1/examples/durable_sleep/run.js +30 -0
  155. package/v1/examples/durable_sleep/worker.d.ts +1 -0
  156. package/v1/examples/durable_sleep/worker.js +24 -0
  157. package/v1/examples/durable_sleep/workflow.d.ts +1 -0
  158. package/v1/examples/durable_sleep/workflow.js +31 -0
  159. package/v1/examples/e2e-worker.d.ts +1 -0
  160. package/v1/examples/e2e-worker.js +82 -0
  161. package/v1/examples/events/event.d.ts +1 -0
  162. package/v1/examples/events/event.js +53 -0
  163. package/v1/examples/events/filter.d.ts +1 -0
  164. package/v1/examples/events/filter.js +32 -0
  165. package/v1/examples/events/worker.d.ts +1 -0
  166. package/v1/examples/events/worker.js +24 -0
  167. package/v1/examples/events/workflow.d.ts +19 -0
  168. package/v1/examples/events/workflow.js +60 -0
  169. package/v1/examples/high-memory/workflow-with-child.js +1 -1
  170. package/v1/examples/logger/byo-logger.d.ts +1 -0
  171. package/v1/examples/logger/byo-logger.js +73 -0
  172. package/v1/examples/logger/logger.d.ts +1 -0
  173. package/v1/examples/logger/logger.js +46 -0
  174. package/v1/examples/logger/workflow.d.ts +2 -0
  175. package/v1/examples/logger/workflow.js +38 -0
  176. package/v1/examples/multiple_wf_concurrency/workflow.js +3 -3
  177. package/v1/examples/on_failure/workflow.d.ts +1 -0
  178. package/v1/examples/on_failure/workflow.js +12 -7
  179. package/v1/examples/priority/workflow.js +1 -1
  180. package/v1/examples/retries/workflow.js +2 -2
  181. package/v1/examples/return_exceptions/workflow.d.ts +6 -0
  182. package/v1/examples/return_exceptions/workflow.js +22 -0
  183. package/v1/examples/run_details/workflow.d.ts +4 -0
  184. package/v1/examples/run_details/workflow.js +65 -0
  185. package/v1/examples/simple/e2e-workflows.d.ts +14 -0
  186. package/v1/examples/simple/e2e-workflows.js +27 -0
  187. package/v1/examples/simple/enqueue.js +2 -2
  188. package/v1/examples/sticky/workflow.js +2 -2
  189. package/v1/examples/timeout/run.d.ts +1 -0
  190. package/v1/examples/timeout/run.js +30 -0
  191. package/v1/examples/timeout/worker.d.ts +1 -0
  192. package/v1/examples/timeout/worker.js +25 -0
  193. package/v1/examples/timeout/workflow.d.ts +10 -0
  194. package/v1/examples/timeout/workflow.js +56 -0
  195. package/v1/examples/webhooks/workflow.d.ts +5 -0
  196. package/v1/examples/webhooks/workflow.js +23 -0
  197. package/v1/index.d.ts +1 -0
  198. package/v1/index.js +1 -0
  199. package/v1/parent-run-context-vars.d.ts +6 -0
  200. package/v1/parent-run-context-vars.js +3 -0
  201. package/v1/task.d.ts +22 -7
  202. package/v1/task.js +4 -1
  203. package/version.d.ts +1 -1
  204. package/version.js +1 -1
  205. package/workflow.d.ts +3 -491
  206. package/workflow.js +12 -62
  207. package/clients/hatchet-client/hatchet-client.d.ts +0 -35
  208. package/clients/hatchet-client/hatchet-client.js +0 -108
  209. package/clients/worker/handler.d.ts +0 -50
  210. package/clients/worker/handler.js +0 -214
  211. package/clients/worker/index.d.ts +0 -1
  212. package/clients/worker/index.js +0 -17
  213. package/clients/worker/worker.d.ts +0 -59
  214. package/clients/worker/worker.js +0 -568
  215. package/examples/webhooks.js +0 -45
  216. /package/{examples → legacy/examples}/affinity-workers.d.ts +0 -0
  217. /package/{examples → legacy/examples}/bulk-fanout-trigger.d.ts +0 -0
  218. /package/{examples → legacy/examples}/bulk-fanout-worker.d.ts +0 -0
  219. /package/{examples → legacy/examples}/bulk-trigger.d.ts +0 -0
  220. /package/{examples → legacy/examples}/byo-logger.d.ts +0 -0
  221. /package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-event.d.ts +0 -0
  222. /package/{examples → legacy/examples}/concurrency/cancel-in-progress/concurrency-worker.d.ts +0 -0
  223. /package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-event.d.ts +0 -0
  224. /package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-expression.d.ts +0 -0
  225. /package/{examples → legacy/examples}/concurrency/group-round-robin/concurrency-worker-key-fn.d.ts +0 -0
  226. /package/{examples → legacy/examples}/crons/programatic-crons.d.ts +0 -0
  227. /package/{examples → legacy/examples}/dag-worker.d.ts +0 -0
  228. /package/{examples → legacy/examples}/example-event-with-results.d.ts +0 -0
  229. /package/{examples → legacy/examples}/example-event.d.ts +0 -0
  230. /package/{examples → legacy/examples}/fanout-worker.d.ts +0 -0
  231. /package/{examples → legacy/examples}/logger.d.ts +0 -0
  232. /package/{examples → legacy/examples}/manual-trigger.d.ts +0 -0
  233. /package/{examples → legacy/examples}/multi-workflow.d.ts +0 -0
  234. /package/{examples → legacy/examples}/namespaced-worker.d.ts +0 -0
  235. /package/{examples → legacy/examples}/on-failure.d.ts +0 -0
  236. /package/{examples → legacy/examples}/rate-limit/events.d.ts +0 -0
  237. /package/{examples → legacy/examples}/rate-limit/worker.d.ts +0 -0
  238. /package/{examples → legacy/examples}/retries-with-backoff.d.ts +0 -0
  239. /package/{examples → legacy/examples}/retries-worker.d.ts +0 -0
  240. /package/{examples → legacy/examples}/scheduled-runs/programatic-schedules.d.ts +0 -0
  241. /package/{examples → legacy/examples}/sticky-trigger.d.ts +0 -0
  242. /package/{examples → legacy/examples}/sticky-worker-with-check.d.ts +0 -0
  243. /package/{examples → legacy/examples}/sticky-worker.d.ts +0 -0
  244. /package/{examples → legacy/examples}/stream-by-additional-meta.d.ts +0 -0
  245. /package/{examples/webhooks.d.ts → v1/examples/cancellation/run.d.ts} +0 -0
package/step.d.ts CHANGED
@@ -1,430 +1 @@
1
- import * as z from 'zod';
2
- import { JsonObject } from '@bufbuild/protobuf';
3
- import { Workflow } from './workflow';
4
- import { Action } from './clients/dispatcher/action-listener';
5
- import { LogLevel } from './clients/event/event-client';
6
- import { Logger } from './util/logger';
7
- import WorkflowRunRef from './util/workflow-run-ref';
8
- import { WorkerLabels } from './clients/dispatcher/dispatcher-client';
9
- import { CreateStepRateLimit, RateLimitDuration, WorkerLabelComparator } from './protoc/workflows';
10
- import { CreateWorkflowTaskOpts, Priority } from './v1';
11
- import { RunOpts, TaskWorkflowDeclaration, BaseWorkflowDeclaration as WorkflowV1 } from './v1/declaration';
12
- import { Conditions } from './v1/conditions';
13
- import { Duration } from './v1/client/duration';
14
- import { JsonValue, OutputType } from './v1/types';
15
- import { V1Worker } from './v1/client/worker/worker-internal';
16
- import { V0Worker } from './clients/worker';
17
- import { LegacyHatchetClient } from './clients/hatchet-client';
18
- export declare const CreateRateLimitSchema: z.ZodObject<{
19
- key: z.ZodOptional<z.ZodString>;
20
- staticKey: z.ZodOptional<z.ZodString>;
21
- dynamicKey: z.ZodOptional<z.ZodString>;
22
- units: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
23
- limit: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
24
- duration: z.ZodOptional<z.ZodNativeEnum<typeof RateLimitDuration>>;
25
- }, "strip", z.ZodTypeAny, {
26
- units: string | number;
27
- key?: string | undefined;
28
- staticKey?: string | undefined;
29
- dynamicKey?: string | undefined;
30
- limit?: string | number | undefined;
31
- duration?: RateLimitDuration | undefined;
32
- }, {
33
- units: string | number;
34
- key?: string | undefined;
35
- staticKey?: string | undefined;
36
- dynamicKey?: string | undefined;
37
- limit?: string | number | undefined;
38
- duration?: RateLimitDuration | undefined;
39
- }>;
40
- export declare const DesiredWorkerLabelSchema: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
41
- value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
42
- required: z.ZodOptional<z.ZodBoolean>;
43
- weight: z.ZodOptional<z.ZodNumber>;
44
- comparator: z.ZodOptional<z.ZodNativeEnum<typeof WorkerLabelComparator>>;
45
- }, "strip", z.ZodTypeAny, {
46
- value: string | number;
47
- required?: boolean | undefined;
48
- weight?: number | undefined;
49
- comparator?: WorkerLabelComparator | undefined;
50
- }, {
51
- value: string | number;
52
- required?: boolean | undefined;
53
- weight?: number | undefined;
54
- comparator?: WorkerLabelComparator | undefined;
55
- }>]>>;
56
- export declare const CreateStepSchema: z.ZodObject<{
57
- name: z.ZodString;
58
- parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
59
- timeout: z.ZodOptional<z.ZodString>;
60
- retries: z.ZodOptional<z.ZodNumber>;
61
- rate_limits: z.ZodOptional<z.ZodArray<z.ZodObject<{
62
- key: z.ZodOptional<z.ZodString>;
63
- staticKey: z.ZodOptional<z.ZodString>;
64
- dynamicKey: z.ZodOptional<z.ZodString>;
65
- units: z.ZodUnion<[z.ZodNumber, z.ZodString]>;
66
- limit: z.ZodOptional<z.ZodUnion<[z.ZodNumber, z.ZodString]>>;
67
- duration: z.ZodOptional<z.ZodNativeEnum<typeof RateLimitDuration>>;
68
- }, "strip", z.ZodTypeAny, {
69
- units: string | number;
70
- key?: string | undefined;
71
- staticKey?: string | undefined;
72
- dynamicKey?: string | undefined;
73
- limit?: string | number | undefined;
74
- duration?: RateLimitDuration | undefined;
75
- }, {
76
- units: string | number;
77
- key?: string | undefined;
78
- staticKey?: string | undefined;
79
- dynamicKey?: string | undefined;
80
- limit?: string | number | undefined;
81
- duration?: RateLimitDuration | undefined;
82
- }>, "many">>;
83
- worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
84
- value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
85
- required: z.ZodOptional<z.ZodBoolean>;
86
- weight: z.ZodOptional<z.ZodNumber>;
87
- comparator: z.ZodOptional<z.ZodNativeEnum<typeof WorkerLabelComparator>>;
88
- }, "strip", z.ZodTypeAny, {
89
- value: string | number;
90
- required?: boolean | undefined;
91
- weight?: number | undefined;
92
- comparator?: WorkerLabelComparator | undefined;
93
- }, {
94
- value: string | number;
95
- required?: boolean | undefined;
96
- weight?: number | undefined;
97
- comparator?: WorkerLabelComparator | undefined;
98
- }>]>>>>>;
99
- backoff: z.ZodOptional<z.ZodObject<{
100
- factor: z.ZodOptional<z.ZodNumber>;
101
- maxSeconds: z.ZodOptional<z.ZodNumber>;
102
- }, "strip", z.ZodTypeAny, {
103
- factor?: number | undefined;
104
- maxSeconds?: number | undefined;
105
- }, {
106
- factor?: number | undefined;
107
- maxSeconds?: number | undefined;
108
- }>>;
109
- }, "strip", z.ZodTypeAny, {
110
- name: string;
111
- timeout?: string | undefined;
112
- parents?: string[] | undefined;
113
- retries?: number | undefined;
114
- rate_limits?: {
115
- units: string | number;
116
- key?: string | undefined;
117
- staticKey?: string | undefined;
118
- dynamicKey?: string | undefined;
119
- limit?: string | number | undefined;
120
- duration?: RateLimitDuration | undefined;
121
- }[] | undefined;
122
- worker_labels?: Record<string, string | number | {
123
- value: string | number;
124
- required?: boolean | undefined;
125
- weight?: number | undefined;
126
- comparator?: WorkerLabelComparator | undefined;
127
- } | undefined> | undefined;
128
- backoff?: {
129
- factor?: number | undefined;
130
- maxSeconds?: number | undefined;
131
- } | undefined;
132
- }, {
133
- name: string;
134
- timeout?: string | undefined;
135
- parents?: string[] | undefined;
136
- retries?: number | undefined;
137
- rate_limits?: {
138
- units: string | number;
139
- key?: string | undefined;
140
- staticKey?: string | undefined;
141
- dynamicKey?: string | undefined;
142
- limit?: string | number | undefined;
143
- duration?: RateLimitDuration | undefined;
144
- }[] | undefined;
145
- worker_labels?: Record<string, string | number | {
146
- value: string | number;
147
- required?: boolean | undefined;
148
- weight?: number | undefined;
149
- comparator?: WorkerLabelComparator | undefined;
150
- } | undefined> | undefined;
151
- backoff?: {
152
- factor?: number | undefined;
153
- maxSeconds?: number | undefined;
154
- } | undefined;
155
- }>;
156
- export type NextStep = {
157
- [key: string]: JsonValue;
158
- };
159
- type TriggerData = Record<string, Record<string, any>>;
160
- type ChildRunOpts = RunOpts & {
161
- key?: string;
162
- sticky?: boolean;
163
- };
164
- interface ContextData<T, K> {
165
- input: T;
166
- triggers: TriggerData;
167
- parents: Record<string, any>;
168
- triggered_by: string;
169
- user_data: K;
170
- step_run_errors: Record<string, string>;
171
- }
172
- export declare class ContextWorker {
173
- private worker;
174
- constructor(worker: V0Worker | V1Worker);
175
- /**
176
- * Gets the ID of the worker.
177
- * @returns The ID of the worker.
178
- */
179
- id(): string | undefined;
180
- /**
181
- * Checks if the worker has a registered workflow.
182
- * @param workflowName - The name of the workflow to check.
183
- * @returns True if the workflow is registered, otherwise false.
184
- */
185
- hasWorkflow(workflowName: string): boolean;
186
- /**
187
- * Gets the current state of the worker labels.
188
- * @returns The labels of the worker.
189
- */
190
- labels(): WorkerLabels;
191
- /**
192
- * Upserts the a set of labels on the worker.
193
- * @param labels - The labels to upsert.
194
- * @returns A promise that resolves when the labels have been upserted.
195
- */
196
- upsertLabels(labels: WorkerLabels): Promise<WorkerLabels>;
197
- }
198
- export declare class V0Context<T, K = {}> {
199
- data: ContextData<T, K>;
200
- input: T;
201
- controller: AbortController;
202
- action: Action;
203
- v0: LegacyHatchetClient;
204
- worker: ContextWorker;
205
- overridesData: Record<string, any>;
206
- logger: Logger;
207
- spawnIndex: number;
208
- constructor(action: Action, client: LegacyHatchetClient, worker: V0Worker | V1Worker);
209
- get abortController(): AbortController;
210
- get cancelled(): boolean;
211
- /**
212
- * Retrieves the output of a parent task.
213
- * @param parentTask - The a CreateTaskOpts or string of the parent task name.
214
- * @returns The output of the specified parent task.
215
- * @throws An error if the task output is not found.
216
- */
217
- parentOutput<L extends OutputType>(parentTask: 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
- */
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
- */
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
- */
248
- triggeredByEvent(): boolean;
249
- /**
250
- * Gets the input data for the current workflow.
251
- * @returns The input data for the workflow.
252
- * @deprecated use task input parameter instead
253
- */
254
- workflowInput(): T;
255
- /**
256
- * Gets the name of the current workflow.
257
- * @returns The name of the workflow.
258
- */
259
- workflowName(): string;
260
- /**
261
- * Gets the user data associated with the workflow.
262
- * @returns The user data.
263
- */
264
- userData(): K;
265
- /**
266
- * Gets the name of the current task.
267
- * @returns The name of the task.
268
- * @deprecated use ctx.taskName instead
269
- */
270
- stepName(): string;
271
- /**
272
- * Gets the name of the current running task.
273
- * @returns The name of the task.
274
- */
275
- taskName(): string;
276
- /**
277
- * Gets the ID of the current workflow run.
278
- * @returns The workflow run ID.
279
- */
280
- workflowRunId(): string;
281
- /**
282
- * Gets the ID of the current task run.
283
- * @returns The task run ID.
284
- */
285
- taskRunExternalId(): string;
286
- /**
287
- * Gets the ID of the current task run.
288
- * @returns The task run ID.
289
- * @deprecated use taskRunExternalId() instead
290
- */
291
- taskRunId(): string;
292
- /**
293
- * Gets the number of times the current task has been retried.
294
- * @returns The retry count.
295
- */
296
- retryCount(): number;
297
- /**
298
- * Logs a message from the current task.
299
- * @param message - The message to log.
300
- * @param level - The log level (optional).
301
- */
302
- log(message: string, level?: LogLevel): void;
303
- /**
304
- * Refreshes the timeout for the current task.
305
- * @param incrementBy - The interval by which to increment the timeout.
306
- * The interval should be specified in the format of '10s' for 10 seconds, '1m' for 1 minute, or '1d' for 1 day.
307
- */
308
- refreshTimeout(incrementBy: Duration): Promise<void>;
309
- /**
310
- * Releases a worker slot for a task run such that the worker can pick up another task.
311
- * Note: this is an advanced feature that may lead to unexpected behavior if used incorrectly.
312
- * @returns A promise that resolves when the slot has been released.
313
- */
314
- releaseSlot(): Promise<void>;
315
- /**
316
- * Streams data from the current task run.
317
- * @param data - The data to stream (string or binary).
318
- * @returns A promise that resolves when the data has been streamed.
319
- */
320
- putStream(data: string | Uint8Array): Promise<void>;
321
- /**
322
- * Runs multiple children workflows in parallel without waiting for their results.
323
- * @param children - An array of objects containing the workflow name, input data, and options for each workflow.
324
- * @returns A list of workflow run references to the enqueued runs.
325
- */
326
- bulkRunNoWaitChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
327
- workflow: string | Workflow | WorkflowV1<Q, P>;
328
- input: Q;
329
- options?: ChildRunOpts;
330
- }>): Promise<WorkflowRunRef<P>[]>;
331
- /**
332
- * Runs multiple children workflows in parallel and waits for all results.
333
- * @param children - An array of objects containing the workflow name, input data, and options for each workflow.
334
- * @returns A list of results from the children workflows.
335
- */
336
- bulkRunChildren<Q extends JsonObject = any, P extends JsonObject = any>(children: Array<{
337
- workflow: string | Workflow | WorkflowV1<Q, P>;
338
- input: Q;
339
- options?: ChildRunOpts;
340
- }>): Promise<P[]>;
341
- /**
342
- * Spawns multiple workflows.
343
- *
344
- * @param workflows - An array of objects containing the workflow name, input data, and options for each workflow.
345
- * @returns A list of references to the spawned workflow runs.
346
- * @deprecated Use bulkRunNoWaitChildren or bulkRunChildren instead.
347
- */
348
- spawnWorkflows<Q extends JsonObject = any, P extends JsonObject = any>(workflows: Array<{
349
- workflow: string | Workflow | WorkflowV1<Q, P>;
350
- input: Q;
351
- options?: ChildRunOpts;
352
- }>): Promise<WorkflowRunRef<P>[]>;
353
- /**
354
- * Runs a new workflow and waits for its result.
355
- *
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 - An options object containing key, sticky, priority, and additionalMetadata.
359
- * @returns The result of the workflow.
360
- */
361
- runChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, options?: ChildRunOpts): Promise<P>;
362
- /**
363
- * Enqueues a new workflow without waiting for its result.
364
- *
365
- * @param workflow - The workflow to enqueue (name, Workflow instance, or WorkflowV1 instance).
366
- * @param input - The input data for the workflow.
367
- * @param options - An options object containing key, sticky, priority, and additionalMetadata.
368
- * @returns A reference to the spawned workflow run.
369
- */
370
- runNoWaitChild<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P>, input: Q, options?: ChildRunOpts): Promise<WorkflowRunRef<P>>;
371
- /**
372
- * Spawns a new workflow.
373
- *
374
- * @param workflow - The workflow to spawn (name, Workflow instance, or WorkflowV1 instance).
375
- * @param input - The input data for the workflow.
376
- * @param options - Additional options for spawning the workflow.
377
- * @returns A reference to the spawned workflow run.
378
- * @deprecated Use runChild or runNoWaitChild instead.
379
- */
380
- spawnWorkflow<Q extends JsonObject, P extends JsonObject>(workflow: string | Workflow | WorkflowV1<Q, P> | TaskWorkflowDeclaration<Q, P>, input: Q, options?: ChildRunOpts): Promise<WorkflowRunRef<P>>;
381
- /**
382
- * Retrieves additional metadata associated with the current workflow run.
383
- * @returns A record of metadata key-value pairs.
384
- */
385
- additionalMetadata(): Record<string, string>;
386
- /**
387
- * Gets the index of this workflow if it was spawned as part of a bulk operation.
388
- * @returns The child index number, or undefined if not set.
389
- */
390
- childIndex(): number | undefined;
391
- /**
392
- * Gets the key associated with this workflow if it was spawned as a child workflow.
393
- * @returns The child key, or undefined if not set.
394
- */
395
- childKey(): string | undefined;
396
- /**
397
- * Gets the ID of the parent workflow run if this workflow was spawned as a child.
398
- * @returns The parent workflow run ID, or undefined if not a child workflow.
399
- */
400
- parentWorkflowRunId(): string | undefined;
401
- priority(): Priority | undefined;
402
- }
403
- export declare class V0DurableContext<T, K = {}> extends V0Context<T, K> {
404
- waitKey: number;
405
- /**
406
- * Pauses execution for the specified duration.
407
- * Duration is "global" meaning it will wait in real time regardless of transient failures like worker restarts.
408
- * @param duration - The duration to sleep for.
409
- * @returns A promise that resolves when the sleep duration has elapsed.
410
- */
411
- sleepFor(duration: Duration, readableDataKey?: string): Promise<Record<string, any>>;
412
- /**
413
- * Pauses execution until the specified conditions are met.
414
- * Conditions are "global" meaning they will wait in real time regardless of transient failures like worker restarts.
415
- * @param conditions - The conditions to wait for.
416
- * @returns A promise that resolves with the event that satisfied the conditions.
417
- */
418
- waitFor(conditions: Conditions | Conditions[]): Promise<Record<string, any>>;
419
- }
420
- export type StepRunFunction<T, K> = (ctx: V0Context<T, K>) => Promise<NextStep | void> | NextStep | void;
421
- /**
422
- * A step is a unit of work that can be run by a worker.
423
- * It is defined by a name, a function that returns the next step, and optional configuration.
424
- * @deprecated use hatchet.workflows.task factory instead
425
- */
426
- export interface CreateStep<T, K> extends z.infer<typeof CreateStepSchema> {
427
- run: StepRunFunction<T, K>;
428
- }
429
- export declare function mapRateLimit(limits: CreateStep<any, any>['rate_limits']): CreateStepRateLimit[];
430
- export {};
1
+ export * from './legacy/step';