@hatchet-dev/typescript-sdk 1.15.2 → 1.17.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 (202) hide show
  1. package/README.md +14 -2
  2. package/clients/admin/admin-client.d.ts +2 -2
  3. package/clients/admin/admin-client.js +8 -9
  4. package/clients/dispatcher/action-listener.d.ts +3 -6
  5. package/clients/dispatcher/action-listener.js +54 -23
  6. package/clients/dispatcher/dispatcher-client.js +5 -8
  7. package/clients/dispatcher/heartbeat/heartbeat-worker.js +7 -4
  8. package/clients/event/event-client.d.ts +2 -2
  9. package/clients/event/event-client.js +5 -11
  10. package/clients/hatchet-client/hatchet-logger.js +8 -17
  11. package/clients/listeners/durable-listener/durable-listener-client.d.ts +115 -15
  12. package/clients/listeners/durable-listener/durable-listener-client.js +769 -19
  13. package/clients/listeners/durable-listener/pooled-durable-listener-client.js +11 -22
  14. package/clients/listeners/run-listener/child-listener-client.d.ts +1 -1
  15. package/clients/listeners/run-listener/child-listener-client.js +34 -30
  16. package/clients/listeners/run-listener/pooled-child-listener-client.js +9 -19
  17. package/clients/rest/generated/Api.d.ts +25 -1
  18. package/clients/rest/generated/Api.js +20 -0
  19. package/clients/rest/generated/data-contracts.d.ts +60 -1
  20. package/clients/rest/generated/data-contracts.js +9 -1
  21. package/legacy/examples/affinity-workers.js +2 -3
  22. package/legacy/examples/byo-logger.js +0 -2
  23. package/legacy/examples/concurrency/cancel-in-progress/concurrency-worker.js +4 -2
  24. package/legacy/examples/concurrency/group-round-robin/concurrency-event.js +0 -1
  25. package/legacy/examples/concurrency/group-round-robin/concurrency-worker-expression.js +4 -2
  26. package/legacy/examples/concurrency/group-round-robin/concurrency-worker-key-fn.js +4 -2
  27. package/legacy/examples/example-event.js +0 -3
  28. package/legacy/examples/logger.js +0 -1
  29. package/legacy/examples/sticky-worker-with-check.js +0 -1
  30. package/legacy/examples/sticky-worker.js +0 -1
  31. package/legacy/legacy-client.js +2 -2
  32. package/legacy/legacy-transformer.js +2 -4
  33. package/legacy/step.d.ts +16 -16
  34. package/legacy/step.js +8 -17
  35. package/legacy/workflow.d.ts +81 -81
  36. package/package.json +20 -29
  37. package/protoc/dispatcher/dispatcher.d.ts +20 -0
  38. package/protoc/dispatcher/dispatcher.js +136 -2
  39. package/protoc/v1/dispatcher.d.ts +168 -0
  40. package/protoc/v1/dispatcher.js +1920 -1
  41. package/protoc/v1/shared/trigger.d.ts +89 -0
  42. package/protoc/v1/shared/trigger.js +493 -0
  43. package/protoc/v1/workflows.d.ts +34 -34
  44. package/protoc/v1/workflows.js +252 -200
  45. package/protoc/workflows/workflows.d.ts +2 -75
  46. package/protoc/workflows/workflows.js +16 -491
  47. package/util/abort-error.d.ts +15 -1
  48. package/util/abort-error.js +30 -5
  49. package/util/config-loader/config-loader.js +4 -3
  50. package/util/config-loader/token.js +9 -2
  51. package/util/errors/eviction-not-supported-error.d.ts +5 -0
  52. package/util/errors/eviction-not-supported-error.js +18 -0
  53. package/util/errors/hatchet-error.d.ts +9 -1
  54. package/util/errors/hatchet-error.js +23 -2
  55. package/util/errors/non-determinism-error.d.ts +7 -0
  56. package/util/errors/non-determinism-error.js +21 -0
  57. package/util/errors/task-run-terminated-error.d.ts +6 -0
  58. package/util/errors/task-run-terminated-error.js +15 -0
  59. package/util/grpc-error.d.ts +9 -0
  60. package/util/grpc-error.js +25 -0
  61. package/util/hatchet-promise/hatchet-promise.d.ts +6 -1
  62. package/util/hatchet-promise/hatchet-promise.js +16 -2
  63. package/util/logger/logger.js +0 -1
  64. package/util/parse.d.ts +1 -1
  65. package/util/parse.js +4 -2
  66. package/util/retrier.js +2 -3
  67. package/util/sleep.d.ts +3 -2
  68. package/util/sleep.js +6 -4
  69. package/util/workflow-run-ref.js +5 -3
  70. package/v1/client/admin.d.ts +2 -2
  71. package/v1/client/admin.js +2 -6
  72. package/v1/client/client.d.ts +7 -11
  73. package/v1/client/client.interface.d.ts +5 -8
  74. package/v1/client/client.js +34 -40
  75. package/v1/client/duration.d.ts +11 -1
  76. package/v1/client/duration.js +44 -0
  77. package/v1/client/features/cel.js +1 -1
  78. package/v1/client/features/crons.js +2 -2
  79. package/v1/client/features/index.d.ts +5 -0
  80. package/v1/client/features/index.js +5 -0
  81. package/v1/client/features/logs.d.ts +37 -0
  82. package/v1/client/features/logs.js +46 -0
  83. package/v1/client/features/runs.d.ts +16 -3
  84. package/v1/client/features/runs.js +38 -4
  85. package/v1/client/features/schedules.js +4 -4
  86. package/v1/client/features/webhooks.js +4 -2
  87. package/v1/client/features/workflows.js +1 -1
  88. package/v1/client/worker/context.d.ts +101 -6
  89. package/v1/client/worker/context.js +257 -44
  90. package/v1/client/worker/deprecated/deprecation.js +8 -4
  91. package/v1/client/worker/deprecated/index.d.ts +1 -1
  92. package/v1/client/worker/deprecated/index.js +2 -1
  93. package/v1/client/worker/deprecated/legacy-worker.d.ts +5 -0
  94. package/v1/client/worker/deprecated/legacy-worker.js +33 -24
  95. package/v1/client/worker/deprecated/pre-eviction.d.ts +12 -0
  96. package/v1/client/worker/deprecated/pre-eviction.js +37 -0
  97. package/v1/client/worker/engine-version.d.ts +5 -0
  98. package/v1/client/worker/engine-version.js +14 -0
  99. package/v1/client/worker/eviction/eviction-cache.d.ts +33 -0
  100. package/v1/client/worker/eviction/eviction-cache.js +139 -0
  101. package/v1/client/worker/eviction/eviction-manager.d.ts +42 -0
  102. package/v1/client/worker/eviction/eviction-manager.js +132 -0
  103. package/v1/client/worker/eviction/eviction-policy.d.ts +19 -0
  104. package/v1/client/worker/eviction/eviction-policy.js +8 -0
  105. package/v1/client/worker/eviction/index.d.ts +3 -0
  106. package/v1/client/worker/eviction/index.js +11 -0
  107. package/v1/client/worker/health-server.js +3 -3
  108. package/v1/client/worker/slot-utils.js +0 -3
  109. package/v1/client/worker/worker-internal.d.ts +23 -4
  110. package/v1/client/worker/worker-internal.js +216 -148
  111. package/v1/client/worker/worker.d.ts +1 -0
  112. package/v1/client/worker/worker.js +34 -0
  113. package/v1/conditions/base.js +0 -1
  114. package/v1/conditions/index.js +2 -4
  115. package/v1/conditions/sleep-condition.js +2 -1
  116. package/v1/conditions/transformer.js +2 -1
  117. package/v1/declaration.d.ts +6 -4
  118. package/v1/declaration.js +20 -7
  119. package/v1/examples/__e2e__/harness.d.ts +5 -0
  120. package/v1/examples/__e2e__/harness.js +17 -3
  121. package/v1/examples/affinity/affinity-workers.js +0 -1
  122. package/v1/examples/bulk_operations/workflow.js +0 -1
  123. package/v1/examples/cancellation/run.js +0 -1
  124. package/v1/examples/cancellations/run.js +0 -1
  125. package/v1/examples/child_workflows/run.js +0 -2
  126. package/v1/examples/child_workflows/workflow.js +0 -1
  127. package/v1/examples/concurrency-rr/load.js +0 -1
  128. package/v1/examples/concurrency-rr/run.js +0 -3
  129. package/v1/examples/concurrency_limit_rr/load.js +0 -1
  130. package/v1/examples/concurrency_limit_rr/run.js +0 -3
  131. package/v1/examples/concurrency_workflow_level/workflow.d.ts +1 -1
  132. package/v1/examples/concurrency_workflow_level/workflow.js +1 -1
  133. package/v1/examples/conditions/event.js +0 -1
  134. package/v1/examples/conditions/run.js +0 -1
  135. package/v1/examples/dag/run.js +0 -1
  136. package/v1/examples/dag_match_condition/event.js +0 -1
  137. package/v1/examples/dag_match_condition/run.js +0 -1
  138. package/v1/examples/deep/run.js +0 -2
  139. package/v1/examples/durable/workflow.d.ts +57 -0
  140. package/v1/examples/durable/workflow.js +164 -10
  141. package/v1/examples/durable-event/event.js +0 -1
  142. package/v1/examples/durable-event/run.js +0 -2
  143. package/v1/examples/durable-event/workflow.js +2 -7
  144. package/v1/examples/durable-sleep/event.js +0 -1
  145. package/v1/examples/durable-sleep/run.js +0 -2
  146. package/v1/examples/durable_event/event.js +0 -1
  147. package/v1/examples/durable_event/run.js +0 -2
  148. package/v1/examples/durable_event/workflow.d.ts +1 -0
  149. package/v1/examples/durable_event/workflow.js +4 -9
  150. package/v1/examples/durable_eviction/capacity-worker.d.ts +1 -0
  151. package/v1/examples/durable_eviction/capacity-worker.js +31 -0
  152. package/v1/examples/durable_eviction/worker.d.ts +1 -0
  153. package/v1/examples/durable_eviction/worker.js +34 -0
  154. package/v1/examples/durable_eviction/workflow.d.ts +44 -0
  155. package/v1/examples/durable_eviction/workflow.js +129 -0
  156. package/v1/examples/durable_sleep/event.js +0 -1
  157. package/v1/examples/durable_sleep/run.js +0 -2
  158. package/v1/examples/e2e-worker.js +42 -19
  159. package/v1/examples/events/event.js +0 -1
  160. package/v1/examples/high-memory/run.js +0 -1
  161. package/v1/examples/inferred-typing/run.js +0 -1
  162. package/v1/examples/landing_page/durable-excution.js +0 -1
  163. package/v1/examples/landing_page/queues.js +0 -1
  164. package/v1/examples/legacy/run.js +0 -1
  165. package/v1/examples/logger/byo-logger.js +0 -2
  166. package/v1/examples/logger/logger.js +0 -1
  167. package/v1/examples/logging/byo-logger.js +0 -2
  168. package/v1/examples/logging/logger.js +0 -1
  169. package/v1/examples/middleware/recipes.js +3 -1
  170. package/v1/examples/migration-guides/mergent.js +2 -1
  171. package/v1/examples/multiple_wf_concurrency/run.js +0 -3
  172. package/v1/examples/non_retryable/run.js +0 -1
  173. package/v1/examples/on_event/event.js +0 -1
  174. package/v1/examples/on_failure/run.js +0 -1
  175. package/v1/examples/on_failure/workflow.js +0 -1
  176. package/v1/examples/on_success/run.js +0 -1
  177. package/v1/examples/on_success/workflow.js +0 -1
  178. package/v1/examples/priority/run.js +0 -1
  179. package/v1/examples/priority/workflow.js +0 -1
  180. package/v1/examples/retries/run.js +0 -1
  181. package/v1/examples/retries/workflow.js +0 -1
  182. package/v1/examples/simple/bulk.js +0 -1
  183. package/v1/examples/simple/cron.js +0 -2
  184. package/v1/examples/simple/delay.js +0 -1
  185. package/v1/examples/simple/enqueue.js +0 -2
  186. package/v1/examples/simple/run.js +0 -1
  187. package/v1/examples/simple/schedule.js +0 -1
  188. package/v1/examples/simple/workflow-with-child.js +10 -4
  189. package/v1/examples/sticky/run.js +0 -1
  190. package/v1/examples/sticky/workflow.js +0 -1
  191. package/v1/examples/streaming/nextjs-proxy.js +0 -1
  192. package/v1/examples/streaming/run.js +0 -1
  193. package/v1/examples/timeout/run.js +0 -1
  194. package/v1/examples/timeouts/run.js +0 -1
  195. package/v1/index.d.ts +5 -0
  196. package/v1/index.js +10 -0
  197. package/v1/parent-run-context-vars.d.ts +6 -0
  198. package/v1/slot-types.js +0 -1
  199. package/v1/task.d.ts +10 -2
  200. package/v1/task.js +2 -1
  201. package/version.d.ts +1 -1
  202. package/version.js +1 -1
@@ -26,16 +26,19 @@ const workflow_5 = require("./concurrency_multiple_keys/workflow");
26
26
  const workflow_6 = require("./concurrency_workflow_level/workflow");
27
27
  const workflow_7 = require("./dag/workflow");
28
28
  const workflow_8 = require("./durable/workflow");
29
- const workflow_9 = require("./logger/workflow");
30
- const workflow_10 = require("./non_retryable/workflow");
31
- const workflow_11 = require("./on_failure/workflow");
32
- const workflow_12 = require("./on_event/workflow");
33
- const workflow_13 = require("./return_exceptions/workflow");
34
- const workflow_14 = require("./run_details/workflow");
29
+ const workflow_9 = require("./durable_event/workflow");
30
+ const workflow_10 = require("./durable_eviction/workflow");
31
+ const workflow_11 = require("./durable_sleep/workflow");
32
+ const workflow_12 = require("./logger/workflow");
33
+ const workflow_13 = require("./non_retryable/workflow");
34
+ const workflow_14 = require("./on_failure/workflow");
35
+ const workflow_15 = require("./on_event/workflow");
36
+ const workflow_16 = require("./return_exceptions/workflow");
37
+ const workflow_17 = require("./run_details/workflow");
35
38
  const e2e_workflows_1 = require("./simple/e2e-workflows");
36
- const workflow_15 = require("./streaming/workflow");
37
- const workflow_16 = require("./timeout/workflow");
38
- const workflow_17 = require("./webhooks/workflow");
39
+ const workflow_18 = require("./streaming/workflow");
40
+ const workflow_19 = require("./timeout/workflow");
41
+ const workflow_20 = require("./webhooks/workflow");
39
42
  const workflows = [
40
43
  workflow_1.bulkChild,
41
44
  workflow_1.bulkParentWorkflow,
@@ -51,18 +54,38 @@ const workflows = [
51
54
  workflow_7.dag,
52
55
  workflow_8.durableWorkflow,
53
56
  workflow_8.waitForSleepTwice,
54
- (0, workflow_9.createLoggingWorkflow)(hatchet_client_1.hatchet),
55
- workflow_10.nonRetryableWorkflow,
56
- workflow_11.failureWorkflow,
57
- workflow_12.lower,
58
- workflow_13.returnExceptionsTask,
59
- workflow_14.runDetailTestWorkflow,
57
+ workflow_8.spawnChildTask,
58
+ workflow_8.durableWithSpawn,
59
+ workflow_8.durableWithBulkSpawn,
60
+ workflow_8.durableSleepEventSpawn,
61
+ workflow_8.durableWithExplicitSpawn,
62
+ workflow_8.durableNonDeterminism,
63
+ workflow_8.durableReplayReset,
64
+ workflow_8.dagChildWorkflow,
65
+ workflow_8.durableSpawnDag,
66
+ workflow_9.durableEvent,
67
+ workflow_9.durableEventWithFilter,
68
+ workflow_11.durableSleep,
69
+ workflow_10.evictableSleep,
70
+ workflow_10.evictableWaitForEvent,
71
+ workflow_10.evictableChildSpawn,
72
+ workflow_10.multipleEviction,
73
+ workflow_10.nonEvictableSleep,
74
+ workflow_10.childTask,
75
+ workflow_10.bulkChildTask,
76
+ workflow_10.evictableChildBulkSpawn,
77
+ (0, workflow_12.createLoggingWorkflow)(hatchet_client_1.hatchet),
78
+ workflow_13.nonRetryableWorkflow,
79
+ workflow_14.failureWorkflow,
80
+ workflow_15.lower,
81
+ workflow_16.returnExceptionsTask,
82
+ workflow_17.runDetailTestWorkflow,
60
83
  e2e_workflows_1.helloWorld,
61
84
  e2e_workflows_1.helloWorldDurable,
62
- workflow_15.streamingTask,
63
- workflow_16.timeoutTask,
64
- workflow_16.refreshTimeoutTask,
65
- workflow_17.webhookWorkflow,
85
+ workflow_18.streamingTask,
86
+ workflow_19.timeoutTask,
87
+ workflow_19.refreshTimeoutTask,
88
+ workflow_20.webhookWorkflow,
66
89
  ];
67
90
  function main() {
68
91
  return __awaiter(this, void 0, void 0, function* () {
@@ -44,7 +44,6 @@ function main() {
44
44
  ];
45
45
  yield hatchet_client_1.hatchet.events.bulkPush('user:create', events);
46
46
  // !!
47
- // eslint-disable-next-line no-console
48
47
  console.log(res.eventId);
49
48
  });
50
49
  }
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_with_child_1 = require("./workflow-with-child");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_1 = require("./workflow");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable @typescript-eslint/no-unused-vars */
13
12
  const conditions_1 = require("../../conditions");
14
13
  const hatchet_client_1 = require("../hatchet-client");
15
14
  function main() {
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable @typescript-eslint/no-unused-vars */
13
12
  const hatchet_client_1 = require("../hatchet-client");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -16,7 +16,6 @@ function main() {
16
16
  const res = yield hatchet_client_1.hatchet.run(workflow_1.simple, {
17
17
  Message: 'hello',
18
18
  });
19
- // eslint-disable-next-line no-console
20
19
  console.log(res.step2);
21
20
  });
22
21
  }
@@ -12,7 +12,6 @@ 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
- // eslint-disable-next-line import/no-extraneous-dependencies
16
15
  const pino_1 = __importDefault(require("pino"));
17
16
  const sdk_1 = __importDefault(require("../../../sdk"));
18
17
  // > Create Pino logger
@@ -54,7 +53,6 @@ const hatchet = sdk_1.default.init({
54
53
  const workflow = hatchet.task({
55
54
  name: 'byo-logger-example',
56
55
  fn: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
57
- // eslint-disable-next-line no-plusplus
58
56
  for (let i = 0; i < 5; i++) {
59
57
  logger.info(`log message ${i}`);
60
58
  }
@@ -25,7 +25,6 @@ workflow.task({
25
25
  name: 'logger-step1',
26
26
  fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
27
27
  // log in a for loop
28
- // eslint-disable-next-line no-plusplus
29
28
  for (let i = 0; i < 10; i++) {
30
29
  ctx.logger.info(`log message ${i}`);
31
30
  yield sleep(200);
@@ -12,7 +12,6 @@ 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
- // eslint-disable-next-line import/no-extraneous-dependencies
16
15
  const pino_1 = __importDefault(require("pino"));
17
16
  const sdk_1 = __importDefault(require("../../../sdk"));
18
17
  // > Create Pino logger
@@ -54,7 +53,6 @@ const hatchet = sdk_1.default.init({
54
53
  const workflow = hatchet.task({
55
54
  name: 'byo-logger-example',
56
55
  fn: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
57
- // eslint-disable-next-line no-plusplus
58
56
  for (let i = 0; i < 5; i++) {
59
57
  logger.info(`log message ${i}`);
60
58
  }
@@ -25,7 +25,6 @@ workflow.task({
25
25
  name: 'logger-step1',
26
26
  fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
27
27
  // log in a for loop
28
- // eslint-disable-next-line no-plusplus
29
28
  for (let i = 0; i < 10; i++) {
30
29
  ctx.logger.info(`log message ${i}`);
31
30
  yield sleep(200);
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment -- Demo file with external deps not in SDK
2
3
  // @ts-nocheck
3
4
  // These snippets demonstrate common middleware patterns.
4
5
  // They reference external packages (@aws-sdk/*) that are NOT
@@ -39,8 +40,9 @@ function decrypt(ciphertext, iv, tag) {
39
40
  }
40
41
  const e2eEncryption = {
41
42
  before: (input) => {
42
- if (!input.encrypted)
43
+ if (!input.encrypted) {
43
44
  return input;
45
+ }
44
46
  const { ciphertext, iv, tag } = input.encrypted;
45
47
  const decrypted = JSON.parse(decrypt(ciphertext, iv, tag));
46
48
  return Object.assign(Object.assign(Object.assign({}, input), decrypted), { encrypted: undefined });
@@ -37,8 +37,9 @@ exports.imageProcessor = hatchet_client_1.hatchet.task({
37
37
  fn: (_a) => __awaiter(void 0, [_a], void 0, function* ({ imageUrl, filters }) {
38
38
  // Do some image processing
39
39
  const result = yield processImage(imageUrl, filters);
40
- if (!result.url)
40
+ if (!result.url) {
41
41
  throw new Error('Processing failed to generate URL');
42
+ }
42
43
  return {
43
44
  processedUrl: result.url,
44
45
  metadata: {
@@ -26,11 +26,8 @@ function main() {
26
26
  GroupKey: 'B',
27
27
  },
28
28
  ]);
29
- // eslint-disable-next-line no-console
30
29
  console.log(res[0]['to-lower'].TransformedMessage);
31
- // eslint-disable-next-line no-console
32
30
  console.log(res[1]['to-lower'].TransformedMessage);
33
- // eslint-disable-next-line no-console
34
31
  console.log(res[2]['to-lower'].TransformedMessage);
35
32
  });
36
33
  }
@@ -13,7 +13,6 @@ const workflow_1 = require("./workflow");
13
13
  function main() {
14
14
  return __awaiter(this, void 0, void 0, function* () {
15
15
  const res = yield workflow_1.nonRetryableWorkflow.runNoWait({});
16
- // eslint-disable-next-line no-console
17
16
  console.log(res);
18
17
  });
19
18
  }
@@ -44,7 +44,6 @@ function main() {
44
44
  ];
45
45
  yield hatchet_client_1.hatchet.events.bulkPush('user:create', events);
46
46
  // !!
47
- // eslint-disable-next-line no-console
48
47
  console.log(res.eventId);
49
48
  });
50
49
  }
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_1 = require("./workflow");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.failureWorkflow = exports.ERROR_TEXT = void 0;
13
- /* eslint-disable no-console */
14
13
  const hatchet_client_1 = require("../hatchet-client");
15
14
  exports.ERROR_TEXT = 'step1 failed';
16
15
  // > On Failure Task
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_1 = require("./workflow");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.onSuccessDag = void 0;
13
- /* eslint-disable no-console */
14
13
  const hatchet_client_1 = require("../hatchet-client");
15
14
  // > On Success DAG
16
15
  exports.onSuccessDag = hatchet_client_1.hatchet.workflow({
@@ -11,7 +11,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  const v1_1 = require("../..");
13
13
  const workflow_1 = require("./workflow");
14
- /* eslint-disable no-console */
15
14
  function main() {
16
15
  return __awaiter(this, void 0, void 0, function* () {
17
16
  try {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.priorityTasks = exports.priorityWf = exports.priority = void 0;
13
- /* eslint-disable no-console */
14
13
  const v1_1 = require("../..");
15
14
  const hatchet_client_1 = require("../hatchet-client");
16
15
  // > Simple Task Priority
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_1 = require("./workflow");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.withBackoff = exports.retriesWithCount = exports.retries = void 0;
13
- /* eslint-disable no-console */
14
13
  const hatchet_client_1 = require("../hatchet-client");
15
14
  // > Simple Step Retries
16
15
  exports.retries = hatchet_client_1.hatchet.task({
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const hatchet_client_1 = require("../hatchet-client");
14
13
  const workflow_1 = require("./workflow");
15
14
  function main() {
@@ -20,7 +20,6 @@ function main() {
20
20
  // it may be useful to save the cron id for later
21
21
  const cronId = cron.metadata.id;
22
22
  // !!
23
- // eslint-disable-next-line no-console
24
23
  console.log(cron.metadata.id);
25
24
  // > Delete
26
25
  yield hatchet_client_1.hatchet.crons.delete(cronId);
@@ -30,7 +29,6 @@ function main() {
30
29
  workflow: workflow_1.simple,
31
30
  });
32
31
  // !!
33
- // eslint-disable-next-line no-console
34
32
  console.log(crons);
35
33
  });
36
34
  }
@@ -17,7 +17,6 @@ function main() {
17
17
  const scheduled = yield workflow_1.simple.delay(tomorrow, {
18
18
  Message: 'hello',
19
19
  });
20
- // eslint-disable-next-line no-console
21
20
  console.log(scheduled.metadata.id);
22
21
  yield hatchet_client_1.hatchet.schedules.delete(scheduled);
23
22
  });
@@ -9,8 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable import/no-duplicates */
13
- /* eslint-disable no-console */
14
12
  const hatchet_client_1 = require("../hatchet-client");
15
13
  // > Enqueuing a Workflow (Fire and Forget)
16
14
  const workflow_1 = require("./workflow");
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.extra = extra;
13
- /* eslint-disable no-console */
14
13
  const hatchet_client_1 = require("../hatchet-client");
15
14
  const workflow_1 = require("./workflow");
16
15
  const workflow_with_child_1 = require("./workflow-with-child");
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const hatchet_client_1 = require("../hatchet-client");
14
13
  const workflow_1 = require("./workflow");
15
14
  function main() {
@@ -8,21 +8,26 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
11
14
  Object.defineProperty(exports, "__esModule", { value: true });
12
15
  exports.parent = exports.child3 = exports.child2 = exports.child1 = exports.child = void 0;
13
16
  // > Declaring a Task
17
+ const sleep_1 = __importDefault(require("../../../util/sleep"));
14
18
  const hatchet_client_1 = require("../hatchet-client");
15
19
  exports.child = hatchet_client_1.hatchet.workflow({
16
20
  name: 'child',
17
21
  });
18
22
  exports.child1 = exports.child.task({
19
23
  name: 'child1',
20
- fn: (input, ctx) => {
24
+ fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
25
+ yield (0, sleep_1.default)(30 * 1000);
21
26
  ctx.logger.info('hello from the child1', { hello: 'moon' });
22
27
  return {
23
28
  TransformedMessage: input.Message.toLowerCase(),
24
29
  };
25
- },
30
+ }),
26
31
  });
27
32
  exports.child2 = exports.child.task({
28
33
  name: 'child2',
@@ -36,15 +41,16 @@ exports.child2 = exports.child.task({
36
41
  exports.child3 = exports.child.task({
37
42
  name: 'child3',
38
43
  parents: [exports.child1, exports.child2],
39
- fn: (input, ctx) => {
44
+ fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
40
45
  ctx.logger.info('hello from the child3');
41
46
  return {
42
47
  TransformedMessage: input.Message.toLowerCase(),
43
48
  };
44
- },
49
+ }),
45
50
  });
46
51
  exports.parent = hatchet_client_1.hatchet.task({
47
52
  name: 'parent',
53
+ executionTimeout: '5m',
48
54
  fn: (input, ctx) => __awaiter(void 0, void 0, void 0, function* () {
49
55
  const c = yield ctx.runChild(exports.child, {
50
56
  Message: input.Message,
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_1 = require("../retries/workflow");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.sticky = void 0;
13
- /* eslint-disable no-console */
14
13
  const v1_1 = require("../..");
15
14
  const hatchet_client_1 = require("../hatchet-client");
16
15
  const workflow_1 = require("../child_workflows/workflow");
@@ -20,7 +20,6 @@ function GET() {
20
20
  const ref = yield workflow_1.streamingTask.runNoWait({});
21
21
  const workflowRunId = yield ref.getWorkflowRunId();
22
22
  const stream = stream_1.Readable.from(hatchet_client_1.hatchet.runs.subscribeToStream(workflowRunId));
23
- // @ts-ignore
24
23
  return new Response(stream_1.Readable.toWeb(stream), {
25
24
  headers: {
26
25
  'Content-Type': 'text/plain',
@@ -16,7 +16,6 @@ var __asyncValues = (this && this.__asyncValues) || function (o) {
16
16
  function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
17
  };
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- /* eslint-disable no-console */
20
19
  const workflow_1 = require("./workflow");
21
20
  const hatchet_client_1 = require("../hatchet-client");
22
21
  function main() {
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  const workflow_1 = require("./workflow");
14
13
  function main() {
15
14
  return __awaiter(this, void 0, void 0, function* () {
@@ -9,7 +9,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- /* eslint-disable no-console */
13
12
  // > Running a Task with Results
14
13
  const workflow_1 = require("./workflow");
15
14
  // ...
package/v1/index.d.ts CHANGED
@@ -9,3 +9,8 @@ export * from './task';
9
9
  export * from './client/worker/context';
10
10
  export * from './slot-types';
11
11
  export * from '../legacy/legacy-transformer';
12
+ export { NonDeterminismError } from '../util/errors/non-determinism-error';
13
+ export { EvictionNotSupportedError } from '../util/errors/eviction-not-supported-error';
14
+ export { EvictionPolicy, DEFAULT_DURABLE_TASK_EVICTION_POLICY, } from './client/worker/eviction/eviction-policy';
15
+ export { DurableEvictionConfig } from './client/worker/eviction/eviction-manager';
16
+ export { MinEngineVersion, supportsEviction } from './client/worker/engine-version';
package/v1/index.js CHANGED
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.supportsEviction = exports.MinEngineVersion = exports.DEFAULT_DURABLE_TASK_EVICTION_POLICY = exports.EvictionNotSupportedError = exports.NonDeterminismError = void 0;
17
18
  __exportStar(require("./client/client"), exports);
18
19
  __exportStar(require("./client/features"), exports);
19
20
  __exportStar(require("./client/worker/worker"), exports);
@@ -25,3 +26,12 @@ __exportStar(require("./task"), exports);
25
26
  __exportStar(require("./client/worker/context"), exports);
26
27
  __exportStar(require("./slot-types"), exports);
27
28
  __exportStar(require("../legacy/legacy-transformer"), exports);
29
+ var non_determinism_error_1 = require("../util/errors/non-determinism-error");
30
+ Object.defineProperty(exports, "NonDeterminismError", { enumerable: true, get: function () { return non_determinism_error_1.NonDeterminismError; } });
31
+ var eviction_not_supported_error_1 = require("../util/errors/eviction-not-supported-error");
32
+ Object.defineProperty(exports, "EvictionNotSupportedError", { enumerable: true, get: function () { return eviction_not_supported_error_1.EvictionNotSupportedError; } });
33
+ var eviction_policy_1 = require("./client/worker/eviction/eviction-policy");
34
+ Object.defineProperty(exports, "DEFAULT_DURABLE_TASK_EVICTION_POLICY", { enumerable: true, get: function () { return eviction_policy_1.DEFAULT_DURABLE_TASK_EVICTION_POLICY; } });
35
+ var engine_version_1 = require("./client/worker/engine-version");
36
+ Object.defineProperty(exports, "MinEngineVersion", { enumerable: true, get: function () { return engine_version_1.MinEngineVersion; } });
37
+ Object.defineProperty(exports, "supportsEviction", { enumerable: true, get: function () { return engine_version_1.supportsEviction; } });
@@ -1,3 +1,4 @@
1
+ import { DurableContext } from './client/worker/context';
1
2
  export interface ParentRunContext {
2
3
  parentId: string;
3
4
  /**
@@ -11,6 +12,11 @@ export interface ParentRunContext {
11
12
  * Used to cancel local "wait for result" subscriptions when the parent task is cancelled.
12
13
  */
13
14
  signal?: AbortSignal;
15
+ /**
16
+ * Present when the current task is running in durable mode.
17
+ * Used by child `run()` calls to route through `spawnChild` instead of a fresh trigger.
18
+ */
19
+ durableContext?: DurableContext<unknown, unknown>;
14
20
  }
15
21
  export declare class ParentRunContextManager {
16
22
  private storage;
package/v1/slot-types.js CHANGED
@@ -1,7 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SlotType = void 0;
4
- // eslint-disable-next-line no-shadow
5
4
  var SlotType;
6
5
  (function (SlotType) {
7
6
  SlotType["Default"] = "default";
package/v1/task.d.ts CHANGED
@@ -1,8 +1,10 @@
1
- import { ConcurrencyLimitStrategy, RateLimitDuration, WorkerLabelComparator } from '../protoc/v1/workflows';
1
+ import { ConcurrencyLimitStrategy, RateLimitDuration } from '../protoc/v1/workflows';
2
2
  import { Conditions } from './conditions';
3
3
  import { Duration } from './client/duration';
4
4
  import { InputType, OutputType, UnknownInputType } from './types';
5
5
  import { Context, DurableContext } from './client/worker/context';
6
+ import { EvictionPolicy } from './client/worker/eviction/eviction-policy';
7
+ import { WorkerLabelComparator } from '../protoc/v1/shared/trigger';
6
8
  export { ConcurrencyLimitStrategy, WorkerLabelComparator };
7
9
  /**
8
10
  * Options for configuring the concurrency for a task.
@@ -185,7 +187,13 @@ export type CreateWorkflowTaskOpts<I extends InputType = UnknownInputType, O ext
185
187
  * @template I The input type for the task function.
186
188
  * @template O The return type of the task function (can be inferred from the return value of fn).
187
189
  */
188
- export type CreateWorkflowDurableTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends DurableTaskFn<I, O> = DurableTaskFn<I, O>> = CreateWorkflowTaskOpts<I, O, C>;
190
+ export type CreateWorkflowDurableTaskOpts<I extends InputType = UnknownInputType, O extends OutputType = void, C extends DurableTaskFn<I, O> = DurableTaskFn<I, O>> = CreateWorkflowTaskOpts<I, O, C> & {
191
+ /**
192
+ * Eviction policy for the durable task. Controls TTL-based eviction and capacity-based eviction.
193
+ * Defaults to the built-in eviction policy when omitted or `undefined`.
194
+ */
195
+ evictionPolicy?: EvictionPolicy;
196
+ };
189
197
  /**
190
198
  * Options for configuring the onSuccess task that is invoked when a task succeeds.
191
199
  * @template I The input type for the task function.
package/v1/task.js CHANGED
@@ -3,7 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NonRetryableError = exports.WorkerLabelComparator = exports.ConcurrencyLimitStrategy = void 0;
4
4
  const workflows_1 = require("../protoc/v1/workflows");
5
5
  Object.defineProperty(exports, "ConcurrencyLimitStrategy", { enumerable: true, get: function () { return workflows_1.ConcurrencyLimitStrategy; } });
6
- Object.defineProperty(exports, "WorkerLabelComparator", { enumerable: true, get: function () { return workflows_1.WorkerLabelComparator; } });
6
+ const trigger_1 = require("../protoc/v1/shared/trigger");
7
+ Object.defineProperty(exports, "WorkerLabelComparator", { enumerable: true, get: function () { return trigger_1.WorkerLabelComparator; } });
7
8
  class NonRetryableError extends Error {
8
9
  constructor(message) {
9
10
  super(message);
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.15.2";
1
+ export declare const HATCHET_VERSION = "1.17.0";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HATCHET_VERSION = void 0;
4
- exports.HATCHET_VERSION = '1.15.2';
4
+ exports.HATCHET_VERSION = '1.17.0';