@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
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const sdk_1 = __importDefault(require("../sdk"));
22
+ const sdk_1 = __importDefault(require("../../sdk"));
23
23
  const hatchet = sdk_1.default.init();
24
24
  function main() {
25
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -14,7 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  // eslint-disable-next-line import/no-extraneous-dependencies
16
16
  const pino_1 = __importDefault(require("pino"));
17
- const sdk_1 = __importDefault(require("../sdk"));
17
+ const sdk_1 = __importDefault(require("../../sdk"));
18
18
  // > Create Pino logger
19
19
  const logger = (0, pino_1.default)();
20
20
  class PinoLogger {
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../../sdk"));
15
+ const sdk_1 = __importDefault(require("../../../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  const sleep = (ms) => new Promise((resolve) => {
18
18
  setTimeout(resolve, ms);
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../../sdk"));
15
+ const sdk_1 = __importDefault(require("../../../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  const sleep = (ms) => new Promise((resolve) => {
18
18
  setTimeout(resolve, ms);
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../../sdk"));
15
+ const sdk_1 = __importDefault(require("../../../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  const sleep = (ms) => new Promise((resolve) => {
18
18
  setTimeout(resolve, ms);
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../../sdk"));
16
- const workflow_1 = require("../../../workflow");
15
+ const sdk_1 = __importDefault(require("../../../../sdk"));
16
+ const workflow_1 = require("../../../../workflow");
17
17
  const hatchet = sdk_1.default.init();
18
18
  const sleep = (ms) => new Promise((resolve) => {
19
19
  setTimeout(resolve, ms);
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../../sdk"));
16
- const workflow_1 = require("../../../workflow");
15
+ const sdk_1 = __importDefault(require("../../../../sdk"));
16
+ const workflow_1 = require("../../../../workflow");
17
17
  const hatchet = sdk_1.default.init();
18
18
  const sleep = (ms) => new Promise((resolve) => {
19
19
  setTimeout(resolve, ms);
@@ -1,2 +1,2 @@
1
- import { Workflow } from '../../workflow';
1
+ import { Workflow } from '../../../workflow';
2
2
  export declare const simpleCronWorkflow: Workflow;
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.simpleCronWorkflow = void 0;
16
- const sdk_1 = __importDefault(require("../../sdk"));
16
+ const sdk_1 = __importDefault(require("../../../sdk"));
17
17
  const hatchet = sdk_1.default.init();
18
18
  // > Workflow Definition Cron Trigger
19
19
  // Adding a cron trigger to a workflow is as simple as adding a `cron expression` to the `on` prop of the workflow definition
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../sdk"));
15
+ const sdk_1 = __importDefault(require("../../../sdk"));
16
16
  const cron_worker_1 = require("./cron-worker");
17
17
  const hatchet = sdk_1.default.init();
18
18
  // This example assumes you have a worker already running
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init({
17
17
  log_level: 'OFF',
18
18
  });
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const sdk_1 = __importDefault(require("../sdk"));
22
+ const sdk_1 = __importDefault(require("../../sdk"));
23
23
  function main() {
24
24
  return __awaiter(this, void 0, void 0, function* () {
25
25
  var _a, e_1, _b, _c;
@@ -27,7 +27,7 @@ function main() {
27
27
  const ref = yield hatchet.admin.runWorkflow('simple-workflow', {
28
28
  test: 'test',
29
29
  });
30
- const listener = yield hatchet.v0.listener.stream(yield ref.getWorkflowRunId());
30
+ const listener = yield hatchet.listener.stream(yield ref.getWorkflowRunId());
31
31
  console.log('listening for events');
32
32
  try {
33
33
  for (var _d = true, listener_1 = __asyncValues(listener), listener_1_1; listener_1_1 = yield listener_1.next(), _a = listener_1_1.done, !_a; _d = true) {
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const sdk_1 = __importDefault(require("../sdk"));
6
+ const sdk_1 = __importDefault(require("../../sdk"));
7
7
  const hatchet = sdk_1.default.init();
8
8
  // Push a single event (example)
9
9
  hatchet.events.push('user:create', {
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  const parentWorkflow = {
18
18
  id: 'parent-workflow',
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init({
17
17
  log_level: 'OFF',
18
18
  });
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const sdk_1 = __importDefault(require("../sdk"));
22
+ const sdk_1 = __importDefault(require("../../sdk"));
23
23
  const hatchet = sdk_1.default.init();
24
24
  function main() {
25
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  function main() {
18
18
  return __awaiter(this, void 0, void 0, function* () {
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init({
17
17
  namespace: 'example-namespace',
18
18
  });
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  // > OnFailure Step
18
18
  // This workflow will fail because the step will throw an error
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const sdk_1 = __importDefault(require("../../sdk"));
6
+ const sdk_1 = __importDefault(require("../../../sdk"));
7
7
  const hatchet = sdk_1.default.init();
8
8
  hatchet.events.push('rate-limit:create', {
9
9
  test: '1',
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const workflows_1 = require("../../protoc/workflows");
16
- const sdk_1 = __importDefault(require("../../sdk"));
15
+ const workflows_1 = require("../../../protoc/workflows");
16
+ const sdk_1 = __importDefault(require("../../../sdk"));
17
17
  const hatchet = sdk_1.default.init();
18
18
  const workflow = {
19
19
  id: 'rate-limit-workflow',
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  let numRetries = 0;
18
18
  // > Backoff
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
16
  const hatchet = sdk_1.default.init();
17
17
  const sleep = (ms) => new Promise((resolve) => {
18
18
  setTimeout(resolve, ms);
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../../sdk"));
15
+ const sdk_1 = __importDefault(require("../../../sdk"));
16
16
  const simple_worker_1 = require("../simple-worker");
17
17
  const hatchet = sdk_1.default.init();
18
18
  // This example assumes you have a worker already running
@@ -1,2 +1,2 @@
1
- import { Workflow } from '../workflow';
1
+ import { Workflow } from '../../workflow';
2
2
  export declare const simpleWorkflow: Workflow;
@@ -13,7 +13,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.simpleWorkflow = void 0;
16
- const sdk_1 = __importDefault(require("../sdk"));
16
+ const sdk_1 = __importDefault(require("../../sdk"));
17
17
  const hatchet = sdk_1.default.init();
18
18
  const sleep = (ms) => new Promise((resolve) => {
19
19
  setTimeout(resolve, ms);
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const sdk_1 = __importDefault(require("../sdk"));
22
+ const sdk_1 = __importDefault(require("../../sdk"));
23
23
  const hatchet = sdk_1.default.init();
24
24
  function main() {
25
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
16
- const workflow_1 = require("../workflow");
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
+ const workflow_1 = require("../../workflow");
17
17
  const hatchet = sdk_1.default.init();
18
18
  const workflow = {
19
19
  id: 'sticky-workflow',
@@ -12,8 +12,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const sdk_1 = __importDefault(require("../sdk"));
16
- const workflow_1 = require("../workflow");
15
+ const sdk_1 = __importDefault(require("../../sdk"));
16
+ const workflow_1 = require("../../workflow");
17
17
  const hatchet = sdk_1.default.init();
18
18
  // > StickyWorker
19
19
  const workflow = {
@@ -19,7 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
19
19
  return (mod && mod.__esModule) ? mod : { "default": mod };
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
- const sdk_1 = __importDefault(require("../sdk"));
22
+ const sdk_1 = __importDefault(require("../../sdk"));
23
23
  const hatchet = sdk_1.default.init();
24
24
  function main() {
25
25
  return __awaiter(this, void 0, void 0, function* () {
@@ -34,7 +34,7 @@ function main() {
34
34
  // and can have an arbitrary property name.
35
35
  yield hatchet.admin.runWorkflow('parent-workflow', {}, { additionalMetadata: { [streamKey]: streamVal } });
36
36
  // Stream all events for the additional meta key value
37
- const stream = yield hatchet.v0.listener.streamByAdditionalMeta(streamKey, streamVal);
37
+ const stream = yield hatchet.listener.streamByAdditionalMeta(streamKey, streamVal);
38
38
  try {
39
39
  for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield stream_1.next(), _a = stream_1_1.done, !_a; _d = true) {
40
40
  _c = stream_1_1.value;
@@ -0,0 +1,30 @@
1
+ import { EventClient } from '../clients/event/event-client';
2
+ import { DispatcherClient } from '../clients/dispatcher/dispatcher-client';
3
+ import { AdminClient } from '../clients/admin/admin-client';
4
+ import { ChannelCredentials } from 'nice-grpc';
5
+ import { AxiosRequestConfig } from 'axios';
6
+ import { Logger } from '../util/logger';
7
+ import { RunsClient } from '../v1';
8
+ import { ClientConfig } from '../clients/hatchet-client/client-config';
9
+ import { RunListenerClient } from '../clients/listeners/run-listener/child-listener-client';
10
+ import { Api } from '../clients/rest/generated/Api';
11
+ import { DurableListenerClient } from '../clients/listeners/durable-listener/durable-listener-client';
12
+ export interface HatchetClientOptions {
13
+ config_path?: string;
14
+ credentials?: ChannelCredentials;
15
+ }
16
+ export declare class LegacyHatchetClient {
17
+ config: ClientConfig;
18
+ credentials: ChannelCredentials;
19
+ event: EventClient;
20
+ dispatcher: DispatcherClient;
21
+ admin: AdminClient;
22
+ api: Api;
23
+ runs: RunsClient | undefined;
24
+ listener: RunListenerClient;
25
+ tenantId: string;
26
+ durableListener: DurableListenerClient;
27
+ logger: Logger;
28
+ constructor(config?: Partial<ClientConfig>, options?: HatchetClientOptions, axiosOpts?: AxiosRequestConfig, runs?: RunsClient, listener?: RunListenerClient, event?: EventClient, dispatcher?: DispatcherClient, logger?: Logger, durableListener?: DurableListenerClient);
29
+ static init(config?: Partial<ClientConfig>, options?: HatchetClientOptions, axiosConfig?: AxiosRequestConfig): LegacyHatchetClient;
30
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.LegacyHatchetClient = void 0;
7
+ const zod_1 = require("zod");
8
+ const config_loader_1 = require("../util/config-loader");
9
+ const event_client_1 = require("../clients/event/event-client");
10
+ const dispatcher_client_1 = require("../clients/dispatcher/dispatcher-client");
11
+ const admin_client_1 = require("../clients/admin/admin-client");
12
+ const nice_grpc_1 = require("nice-grpc");
13
+ const hatchet_logger_1 = require("../clients/hatchet-client/hatchet-logger");
14
+ const grpc_helpers_1 = require("../util/grpc-helpers");
15
+ const client_config_1 = require("../clients/hatchet-client/client-config");
16
+ const child_listener_client_1 = require("../clients/listeners/run-listener/child-listener-client");
17
+ const rest_1 = __importDefault(require("../clients/rest"));
18
+ const durable_listener_client_1 = require("../clients/listeners/durable-listener/durable-listener-client");
19
+ class LegacyHatchetClient {
20
+ constructor(config, options, axiosOpts, runs, listener, event, dispatcher, logger, durableListener) {
21
+ // Initializes a new Client instance.
22
+ // Loads config in the following order: config param > yaml file > env vars
23
+ var _a;
24
+ this.runs = runs;
25
+ const loaded = config_loader_1.ConfigLoader.loadClientConfig(config, {
26
+ path: options === null || options === void 0 ? void 0 : options.config_path,
27
+ });
28
+ try {
29
+ const valid = client_config_1.ClientConfigSchema.parse(loaded);
30
+ let logConstructor = config === null || config === void 0 ? void 0 : config.logger;
31
+ if (logConstructor == null) {
32
+ logConstructor = hatchet_logger_1.DEFAULT_LOGGER;
33
+ }
34
+ this.config = Object.assign(Object.assign({}, valid), { logger: logConstructor });
35
+ }
36
+ catch (e) {
37
+ if (e instanceof zod_1.z.ZodError) {
38
+ throw new Error(`Invalid client config: ${e.message}`);
39
+ }
40
+ throw e;
41
+ }
42
+ this.credentials =
43
+ (_a = options === null || options === void 0 ? void 0 : options.credentials) !== null && _a !== void 0 ? _a : config_loader_1.ConfigLoader.createCredentials(this.config.tls_config);
44
+ const clientFactory = (0, nice_grpc_1.createClientFactory)().use((0, grpc_helpers_1.addTokenMiddleware)(this.config.token));
45
+ this.tenantId = this.config.tenant_id;
46
+ this.api = (0, rest_1.default)(this.config.api_url, this.config.token, axiosOpts);
47
+ this.event =
48
+ event ||
49
+ new event_client_1.EventClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
50
+ this.dispatcher =
51
+ dispatcher ||
52
+ new dispatcher_client_1.DispatcherClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory);
53
+ this.listener =
54
+ listener ||
55
+ new child_listener_client_1.RunListenerClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
56
+ this.admin = new admin_client_1.AdminClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api, this.tenantId, this.listener, this.runs);
57
+ this.durableListener =
58
+ durableListener ||
59
+ new durable_listener_client_1.DurableListenerClient(this.config, (0, grpc_helpers_1.channelFactory)(this.config, this.credentials), clientFactory, this.api);
60
+ this.logger = logger || this.config.logger('HatchetClient', this.config.log_level);
61
+ this.logger.debug(`Initialized HatchetClient`);
62
+ }
63
+ static init(config, options, axiosConfig) {
64
+ return new LegacyHatchetClient(config, options, axiosConfig);
65
+ }
66
+ }
67
+ exports.LegacyHatchetClient = LegacyHatchetClient;
@@ -0,0 +1,38 @@
1
+ import type { Workflow } from './workflow';
2
+ import { BaseWorkflowDeclaration, WorkflowDeclaration } from '../v1/declaration';
3
+ export type { Workflow as LegacyWorkflow } from './workflow';
4
+ /**
5
+ * Type guard: returns true if the workflow is a legacy v0 Workflow (not a BaseWorkflowDeclaration).
6
+ */
7
+ export declare function isLegacyWorkflow(workflow: unknown): workflow is Workflow;
8
+ /**
9
+ * Emits a deprecation warning for legacy workflow usage.
10
+ */
11
+ export declare function warnLegacyWorkflow(): void;
12
+ /**
13
+ * Transforms a legacy v0 Workflow into a v1 WorkflowDeclaration.
14
+ *
15
+ * The transformed declaration can be registered with a worker and executed
16
+ * by the v1 runtime. Legacy step `run` functions are wrapped to receive
17
+ * a V0Context for backwards compatibility.
18
+ */
19
+ export declare function transformLegacyWorkflow(workflow: Workflow): WorkflowDeclaration<any, any>;
20
+ /**
21
+ * Normalizes a workflow: if it is a legacy Workflow, emits a deprecation warning
22
+ * and transforms it into a BaseWorkflowDeclaration. If already a v1 declaration,
23
+ * returns it as-is.
24
+ */
25
+ export declare function normalizeWorkflow(workflow: BaseWorkflowDeclaration<any, any> | Workflow): BaseWorkflowDeclaration<any, any>;
26
+ /**
27
+ * Normalizes an array of workflows, transforming any legacy workflows and
28
+ * emitting deprecation warnings.
29
+ */
30
+ export declare function normalizeWorkflows(workflows: Array<BaseWorkflowDeclaration<any, any> | Workflow>): Array<BaseWorkflowDeclaration<any, any>>;
31
+ /**
32
+ * Extracts the workflow name from a workflow-like value.
33
+ * Works for strings, BaseWorkflowDeclaration, WorkflowDefinition, and legacy Workflow.
34
+ * Emits a deprecation warning if a legacy workflow is detected.
35
+ */
36
+ export declare function getWorkflowName(workflow: string | BaseWorkflowDeclaration<any, any> | Workflow | {
37
+ name: string;
38
+ }): string;