@hatchet-dev/typescript-sdk 1.29.2 → 1.30.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.
@@ -1,6 +1,6 @@
1
1
  import * as z from 'zod/v4';
2
2
  import { CreateStep } from '../step';
3
- import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy, StickyStrategy as PbStickyStrategy } from '../protoc/workflows';
3
+ import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy, StickyStrategy as PbStickyStrategy } from '../protoc/v1/workflows';
4
4
  declare const StepsSchema: z.ZodArray<z.ZodObject<{
5
5
  name: z.ZodString;
6
6
  parents: z.ZodOptional<z.ZodArray<z.ZodString>>;
@@ -12,7 +12,7 @@ declare const StepsSchema: z.ZodArray<z.ZodObject<{
12
12
  dynamicKey: z.ZodOptional<z.ZodString>;
13
13
  units: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
14
14
  limit: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
15
- duration: z.ZodOptional<z.ZodEnum<typeof import("../protoc/workflows").RateLimitDuration>>;
15
+ duration: z.ZodOptional<z.ZodEnum<typeof import("..").RateLimitDuration>>;
16
16
  }, z.core.$strip>>>;
17
17
  worker_labels: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodLazy<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodObject<{
18
18
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
@@ -63,7 +63,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
63
63
  dynamicKey: z.ZodOptional<z.ZodString>;
64
64
  units: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
65
65
  limit: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
66
- duration: z.ZodOptional<z.ZodEnum<typeof import("../protoc/workflows").RateLimitDuration>>;
66
+ duration: z.ZodOptional<z.ZodEnum<typeof import("..").RateLimitDuration>>;
67
67
  }, z.core.$strip>>>;
68
68
  worker_labels: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodLazy<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodObject<{
69
69
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
@@ -87,7 +87,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
87
87
  dynamicKey: z.ZodOptional<z.ZodString>;
88
88
  units: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
89
89
  limit: z.ZodOptional<z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>>;
90
- duration: z.ZodOptional<z.ZodEnum<typeof import("../protoc/workflows").RateLimitDuration>>;
90
+ duration: z.ZodOptional<z.ZodEnum<typeof import("..").RateLimitDuration>>;
91
91
  }, z.core.$strip>>>;
92
92
  worker_labels: z.ZodOptional<z.ZodRecord<z.ZodAny, z.ZodLazy<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodObject<{
93
93
  value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.CreateWorkflowSchema = exports.StickyStrategy = exports.HatchetTimeoutSchema = exports.WorkflowConcurrency = exports.ConcurrencyLimitStrategy = void 0;
37
37
  const z = __importStar(require("zod/v4"));
38
38
  const step_1 = require("../step");
39
- const workflows_1 = require("../protoc/workflows");
39
+ const workflows_1 = require("../protoc/v1/workflows");
40
40
  const CronConfigSchema = z.object({
41
41
  cron: z.string(),
42
42
  event: z.undefined().optional(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.29.2",
3
+ "version": "1.30.0",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -48,6 +48,8 @@ export declare enum ConcurrencyLimitStrategy {
48
48
  QUEUE_NEWEST = 2,
49
49
  GROUP_ROUND_ROBIN = 3,
50
50
  CANCEL_NEWEST = 4,
51
+ CANCEL_QUEUED_EXCEPT_NEWEST = 5,
52
+ CANCEL_QUEUED_EXCEPT_OLDEST = 6,
51
53
  UNRECOGNIZED = -1
52
54
  }
53
55
  export declare function concurrencyLimitStrategyFromJSON(object: any): ConcurrencyLimitStrategy;
@@ -209,6 +209,8 @@ var ConcurrencyLimitStrategy;
209
209
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["QUEUE_NEWEST"] = 2] = "QUEUE_NEWEST";
210
210
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["GROUP_ROUND_ROBIN"] = 3] = "GROUP_ROUND_ROBIN";
211
211
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_NEWEST"] = 4] = "CANCEL_NEWEST";
212
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_QUEUED_EXCEPT_NEWEST"] = 5] = "CANCEL_QUEUED_EXCEPT_NEWEST";
213
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_QUEUED_EXCEPT_OLDEST"] = 6] = "CANCEL_QUEUED_EXCEPT_OLDEST";
212
214
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
213
215
  })(ConcurrencyLimitStrategy || (exports.ConcurrencyLimitStrategy = ConcurrencyLimitStrategy = {}));
214
216
  function concurrencyLimitStrategyFromJSON(object) {
@@ -228,6 +230,12 @@ function concurrencyLimitStrategyFromJSON(object) {
228
230
  case 4:
229
231
  case 'CANCEL_NEWEST':
230
232
  return ConcurrencyLimitStrategy.CANCEL_NEWEST;
233
+ case 5:
234
+ case 'CANCEL_QUEUED_EXCEPT_NEWEST':
235
+ return ConcurrencyLimitStrategy.CANCEL_QUEUED_EXCEPT_NEWEST;
236
+ case 6:
237
+ case 'CANCEL_QUEUED_EXCEPT_OLDEST':
238
+ return ConcurrencyLimitStrategy.CANCEL_QUEUED_EXCEPT_OLDEST;
231
239
  case -1:
232
240
  case 'UNRECOGNIZED':
233
241
  default:
@@ -246,6 +254,10 @@ function concurrencyLimitStrategyToJSON(object) {
246
254
  return 'GROUP_ROUND_ROBIN';
247
255
  case ConcurrencyLimitStrategy.CANCEL_NEWEST:
248
256
  return 'CANCEL_NEWEST';
257
+ case ConcurrencyLimitStrategy.CANCEL_QUEUED_EXCEPT_NEWEST:
258
+ return 'CANCEL_QUEUED_EXCEPT_NEWEST';
259
+ case ConcurrencyLimitStrategy.CANCEL_QUEUED_EXCEPT_OLDEST:
260
+ return 'CANCEL_QUEUED_EXCEPT_OLDEST';
249
261
  case ConcurrencyLimitStrategy.UNRECOGNIZED:
250
262
  default:
251
263
  return 'UNRECOGNIZED';
@@ -59,7 +59,7 @@ class ConfigLoader {
59
59
  port: parseInt(this.env('HATCHET_CLIENT_WORKER_HEALTHCHECK_PORT') || '8001', 10),
60
60
  };
61
61
  if (!token) {
62
- throw new Error('No token provided. Provide it by setting the HATCHET_CLIENT_TOKEN environment variable.');
62
+ throw new Error('API token is required. Set it via the HATCHET_CLIENT_TOKEN environment variable. For local development, you can run Hatchet embedded via HatchetEmbeddedClient.init() (imported from @hatchet-dev/typescript-sdk/v1/embedded). More docs here: https://docs.hatchet.run/v1/embedded');
63
63
  }
64
64
  let grpcBroadcastAddress;
65
65
  let apiUrl;
@@ -5,7 +5,7 @@ import { CreateStepRateLimit } from '../../../protoc/workflows';
5
5
  import { Logger } from '../../../util/logger';
6
6
  import { BaseWorkflowDeclaration, WorkflowDefinition, HatchetClient } from '../..';
7
7
  import { TaskBatchConfig } from '../../../protoc/v1/workflows';
8
- import { CreateWorkflowTaskOpts } from '../../task';
8
+ import { Concurrency, CreateWorkflowTaskOpts } from '../../task';
9
9
  import { WorkerLabels } from '../../../clients/dispatcher/dispatcher-client';
10
10
  import { Duration } from '../duration';
11
11
  import { Context } from './context';
@@ -113,6 +113,7 @@ export declare function mapSlotRequestsPb(task: {
113
113
  slotCost?: number;
114
114
  }, isDurable: boolean): Record<string, number>;
115
115
  export declare function mapRateLimitPb(limits: CreateWorkflowTaskOpts<any, any>['rateLimits']): CreateStepRateLimit[];
116
+ export declare function assertValidConcurrencyArr(concurrency: Concurrency[] | undefined): void;
116
117
  export declare function mapBatchConfigPb(batch: CreateWorkflowTaskOpts<any, any>['batch']): TaskBatchConfig | undefined;
117
118
  export declare function resolveExecutionTimeout(task: {
118
119
  executionTimeout?: Duration;
@@ -55,6 +55,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
55
55
  exports.InternalWorker = void 0;
56
56
  exports.mapSlotRequestsPb = mapSlotRequestsPb;
57
57
  exports.mapRateLimitPb = mapRateLimitPb;
58
+ exports.assertValidConcurrencyArr = assertValidConcurrencyArr;
58
59
  exports.mapBatchConfigPb = mapBatchConfigPb;
59
60
  exports.resolveExecutionTimeout = resolveExecutionTimeout;
60
61
  exports.resolveScheduleTimeout = resolveScheduleTimeout;
@@ -269,6 +270,8 @@ class InternalWorker {
269
270
  ];
270
271
  const concurrencyArr = Array.isArray(concurrency) ? concurrency : [];
271
272
  const concurrencySolo = !Array.isArray(concurrency) ? concurrency : undefined;
273
+ assertValidConcurrencyArr(concurrencyArr);
274
+ assertValidConcurrencyArr(concurrencySolo ? [concurrencySolo] : undefined);
272
275
  // Convert Zod schema to JSON Schema if provided
273
276
  let inputJsonSchema;
274
277
  if (workflow.inputValidator) {
@@ -309,7 +312,7 @@ class InternalWorker {
309
312
  defaultPriority: workflow.defaultPriority,
310
313
  inputJsonSchema,
311
314
  tasks: [...workflow._tasks, ...workflow._durableTasks].map((task) => {
312
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
315
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
313
316
  return ({
314
317
  readableId: task.name,
315
318
  action: `${workflow.name}:${task.name}`,
@@ -329,15 +332,20 @@ class InternalWorker {
329
332
  isDurable: durableTaskSet.has(task),
330
333
  slotRequests: mapSlotRequestsPb(task, durableTaskSet.has(task)),
331
334
  batch: mapBatchConfigPb(batchOf(task)),
332
- concurrency: task.concurrency
333
- ? Array.isArray(task.concurrency)
334
- ? task.concurrency
335
- : [task.concurrency]
336
- : ((_m = workflow.taskDefaults) === null || _m === void 0 ? void 0 : _m.concurrency)
337
- ? Array.isArray(workflow.taskDefaults.concurrency)
338
- ? workflow.taskDefaults.concurrency
339
- : [workflow.taskDefaults.concurrency]
340
- : [],
335
+ concurrency: (() => {
336
+ var _a;
337
+ const taskConcurrency = task.concurrency
338
+ ? Array.isArray(task.concurrency)
339
+ ? task.concurrency
340
+ : [task.concurrency]
341
+ : ((_a = workflow.taskDefaults) === null || _a === void 0 ? void 0 : _a.concurrency)
342
+ ? Array.isArray(workflow.taskDefaults.concurrency)
343
+ ? workflow.taskDefaults.concurrency
344
+ : [workflow.taskDefaults.concurrency]
345
+ : [];
346
+ assertValidConcurrencyArr(taskConcurrency);
347
+ return taskConcurrency;
348
+ })(),
341
349
  });
342
350
  }),
343
351
  concurrency: concurrencySolo,
@@ -1096,6 +1104,13 @@ function parseBatchPayload(actionPayload) {
1096
1104
  function batchOf(task) {
1097
1105
  return 'batch' in task ? task.batch : undefined;
1098
1106
  }
1107
+ function assertValidConcurrencyArr(concurrency) {
1108
+ concurrency === null || concurrency === void 0 ? void 0 : concurrency.forEach((c) => {
1109
+ if (c.maxRuns !== undefined && (!Number.isInteger(c.maxRuns) || c.maxRuns <= 0)) {
1110
+ throw new Error(`concurrency.maxRuns must be a positive integer when provided, got: ${c.maxRuns}`);
1111
+ }
1112
+ });
1113
+ }
1099
1114
  function mapBatchConfigPb(batch) {
1100
1115
  if (!batch) {
1101
1116
  return undefined;
@@ -0,0 +1,9 @@
1
+ import type { EmptyTaskOutput } from '../concurrency-types';
2
+ export type WorkflowInput = {
3
+ group: string;
4
+ };
5
+ export type WorkflowOutput = {
6
+ step1: EmptyTaskOutput;
7
+ step2: EmptyTaskOutput;
8
+ };
9
+ export declare const concurrencyCancelQueuedExceptNewestWorkflow: import("../..").WorkflowDeclaration<WorkflowInput, WorkflowOutput, {}>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.concurrencyCancelQueuedExceptNewestWorkflow = void 0;
16
+ const sleep_1 = __importDefault(require("../../../util/sleep"));
17
+ const v1_1 = require("../..");
18
+ const hatchet_client_1 = require("../hatchet-client");
19
+ // > Cancel Queued Except Newest
20
+ exports.concurrencyCancelQueuedExceptNewestWorkflow = hatchet_client_1.hatchet.workflow({
21
+ name: 'concurrencycancelqueuedexceptnewest',
22
+ concurrency: {
23
+ expression: 'input.group',
24
+ maxRuns: 1,
25
+ limitStrategy: v1_1.ConcurrencyLimitStrategy.CANCEL_QUEUED_EXCEPT_NEWEST,
26
+ },
27
+ });
28
+ // !!
29
+ const step1 = exports.concurrencyCancelQueuedExceptNewestWorkflow.task({
30
+ name: 'step1',
31
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
32
+ for (let i = 0; i < 50; i += 1) {
33
+ yield (0, sleep_1.default)(20, ctx.abortController.signal);
34
+ }
35
+ return {};
36
+ }),
37
+ });
38
+ exports.concurrencyCancelQueuedExceptNewestWorkflow.task({
39
+ name: 'step2',
40
+ parents: [step1],
41
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
42
+ for (let i = 0; i < 50; i += 1) {
43
+ yield (0, sleep_1.default)(20, ctx.abortController.signal);
44
+ }
45
+ return {};
46
+ }),
47
+ });
@@ -0,0 +1,9 @@
1
+ import type { EmptyTaskOutput } from '../concurrency-types';
2
+ export type WorkflowInput = {
3
+ group: string;
4
+ };
5
+ export type WorkflowOutput = {
6
+ step1: EmptyTaskOutput;
7
+ step2: EmptyTaskOutput;
8
+ };
9
+ export declare const concurrencyCancelQueuedExceptOldestWorkflow: import("../..").WorkflowDeclaration<WorkflowInput, WorkflowOutput, {}>;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.concurrencyCancelQueuedExceptOldestWorkflow = void 0;
16
+ const sleep_1 = __importDefault(require("../../../util/sleep"));
17
+ const v1_1 = require("../..");
18
+ const hatchet_client_1 = require("../hatchet-client");
19
+ // > Cancel Queued Except Oldest
20
+ exports.concurrencyCancelQueuedExceptOldestWorkflow = hatchet_client_1.hatchet.workflow({
21
+ name: 'concurrencycancelqueuedexceptoldest',
22
+ concurrency: {
23
+ expression: 'input.group',
24
+ maxRuns: 1,
25
+ limitStrategy: v1_1.ConcurrencyLimitStrategy.CANCEL_QUEUED_EXCEPT_OLDEST,
26
+ },
27
+ });
28
+ // !!
29
+ const step1 = exports.concurrencyCancelQueuedExceptOldestWorkflow.task({
30
+ name: 'step1',
31
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
32
+ for (let i = 0; i < 50; i += 1) {
33
+ yield (0, sleep_1.default)(20, ctx.abortController.signal);
34
+ }
35
+ return {};
36
+ }),
37
+ });
38
+ exports.concurrencyCancelQueuedExceptOldestWorkflow.task({
39
+ name: 'step2',
40
+ parents: [step1],
41
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
42
+ for (let i = 0; i < 50; i += 1) {
43
+ yield (0, sleep_1.default)(20, ctx.abortController.signal);
44
+ }
45
+ return {};
46
+ }),
47
+ });
@@ -22,29 +22,32 @@ const cancellation_workflow_1 = require("./cancellation/cancellation-workflow");
22
22
  const complex_workflow_1 = require("./conditions/complex-workflow");
23
23
  const workflow_3 = require("./concurrency_cancel_in_progress/workflow");
24
24
  const workflow_4 = require("./concurrency_cancel_newest/workflow");
25
- const workflow_5 = require("./concurrency_multiple_keys/workflow");
26
- const workflow_6 = require("./concurrency_workflow_level/workflow");
27
- const workflow_7 = require("./dag/workflow");
28
- const workflow_8 = require("./durable/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("./idempotency/workflow");
36
- const workflow_16 = require("./on_event/workflow");
37
- const workflow_17 = require("./return_exceptions/workflow");
38
- const workflow_18 = require("./run_details/workflow");
25
+ const workflow_5 = require("./concurrency_cancel_queued_except_newest/workflow");
26
+ const workflow_6 = require("./concurrency_cancel_queued_except_oldest/workflow");
27
+ const workflow_7 = require("./concurrency_multiple_keys/workflow");
28
+ const workflow_8 = require("./concurrency_workflow_level/workflow");
29
+ const workflow_9 = require("./dag/workflow");
30
+ const workflow_10 = require("./durable/workflow");
31
+ const workflow_11 = require("./durable_event/workflow");
32
+ const workflow_12 = require("./durable_eviction/workflow");
33
+ const workflow_13 = require("./durable_sleep/workflow");
34
+ const workflow_14 = require("./logger/workflow");
35
+ const workflow_15 = require("./non_retryable/workflow");
36
+ const workflow_16 = require("./on_failure/workflow");
37
+ const workflow_17 = require("./idempotency/workflow");
38
+ const workflow_18 = require("./on_event/workflow");
39
+ const workflow_19 = require("./return_exceptions/workflow");
40
+ const workflow_20 = require("./run_details/workflow");
39
41
  const e2e_workflows_1 = require("./simple/e2e-workflows");
40
- const workflow_19 = require("./batch_assign/workflow");
41
- const workflow_20 = require("./streaming/workflow");
42
- const workflow_21 = require("./timeout/workflow");
43
- const workflow_22 = require("./webhooks/workflow");
44
- const workflow_23 = require("./child_index/workflow");
45
- const workflow_24 = require("./support_agent/workflow");
46
- const workflow_25 = require("./welcome_email/workflow");
47
- const workflow_26 = require("./pdf_pipeline/workflow");
42
+ const workflow_21 = require("./batch_assign/workflow");
43
+ const workflow_22 = require("./streaming/workflow");
44
+ const workflow_23 = require("./subscribe_to_stream/workflow");
45
+ const workflow_24 = require("./timeout/workflow");
46
+ const workflow_25 = require("./webhooks/workflow");
47
+ const workflow_26 = require("./child_index/workflow");
48
+ const workflow_27 = require("./support_agent/workflow");
49
+ const workflow_28 = require("./welcome_email/workflow");
50
+ const workflow_29 = require("./pdf_pipeline/workflow");
48
51
  const workflows = [
49
52
  workflow_1.bulkChild,
50
53
  workflow_1.bulkParentWorkflow,
@@ -55,73 +58,77 @@ const workflows = [
55
58
  complex_workflow_1.taskConditionWorkflow,
56
59
  workflow_3.concurrencyCancelInProgressWorkflow,
57
60
  workflow_4.concurrencyCancelNewestWorkflow,
58
- workflow_5.concurrencyMultipleKeysWorkflow,
59
- workflow_6.concurrencyWorkflowLevelWorkflow,
60
- workflow_7.dag,
61
- workflow_8.durableWorkflow,
62
- workflow_8.waitForSleepTwice,
63
- workflow_8.spawnChildTask,
64
- workflow_8.durableWithSpawn,
65
- workflow_8.durableWithBulkSpawn,
66
- workflow_8.durableSleepEventSpawn,
67
- workflow_8.durableWithExplicitSpawn,
68
- workflow_8.durableNonDeterminism,
69
- workflow_8.durableReplayReset,
70
- workflow_8.dagChildWorkflow,
71
- workflow_8.durableSpawnDag,
72
- workflow_8.waitForEventLookback,
73
- workflow_8.waitForOrEventLookback,
74
- workflow_8.waitForTwoEventsSecondPushedFirst,
75
- workflow_8.errorRaisingTask,
76
- workflow_8.errorRaisingDurableParent,
77
- workflow_9.durableEvent,
78
- workflow_9.durableEventWithFilter,
79
- workflow_11.durableSleep,
80
- workflow_10.evictableSleep,
81
- workflow_10.evictableWaitForEvent,
82
- workflow_10.evictableChildSpawn,
83
- workflow_10.multipleEviction,
84
- workflow_10.nonEvictableSleep,
85
- workflow_10.childTask,
86
- workflow_10.bulkChildTask,
87
- workflow_10.evictableChildBulkSpawn,
88
- (0, workflow_12.createLoggingWorkflow)(hatchet_client_1.hatchet),
89
- workflow_13.nonRetryableWorkflow,
90
- workflow_14.failureWorkflow,
91
- workflow_15.idempotentTask,
92
- workflow_15.idempotentTaskShortWindow,
93
- workflow_16.lower,
94
- workflow_17.returnExceptionsTask,
95
- workflow_18.runDetailTestWorkflow,
61
+ workflow_5.concurrencyCancelQueuedExceptNewestWorkflow,
62
+ workflow_6.concurrencyCancelQueuedExceptOldestWorkflow,
63
+ workflow_7.concurrencyMultipleKeysWorkflow,
64
+ workflow_8.concurrencyWorkflowLevelWorkflow,
65
+ workflow_9.dag,
66
+ workflow_10.durableWorkflow,
67
+ workflow_10.waitForSleepTwice,
68
+ workflow_10.spawnChildTask,
69
+ workflow_10.durableWithSpawn,
70
+ workflow_10.durableWithBulkSpawn,
71
+ workflow_10.durableSleepEventSpawn,
72
+ workflow_10.durableWithExplicitSpawn,
73
+ workflow_10.durableNonDeterminism,
74
+ workflow_10.durableReplayReset,
75
+ workflow_10.dagChildWorkflow,
76
+ workflow_10.durableSpawnDag,
77
+ workflow_10.waitForEventLookback,
78
+ workflow_10.waitForOrEventLookback,
79
+ workflow_10.waitForTwoEventsSecondPushedFirst,
80
+ workflow_10.errorRaisingTask,
81
+ workflow_10.errorRaisingDurableParent,
82
+ workflow_11.durableEvent,
83
+ workflow_11.durableEventWithFilter,
84
+ workflow_13.durableSleep,
85
+ workflow_12.evictableSleep,
86
+ workflow_12.evictableWaitForEvent,
87
+ workflow_12.evictableChildSpawn,
88
+ workflow_12.multipleEviction,
89
+ workflow_12.nonEvictableSleep,
90
+ workflow_12.childTask,
91
+ workflow_12.bulkChildTask,
92
+ workflow_12.evictableChildBulkSpawn,
93
+ (0, workflow_14.createLoggingWorkflow)(hatchet_client_1.hatchet),
94
+ workflow_15.nonRetryableWorkflow,
95
+ workflow_16.failureWorkflow,
96
+ workflow_17.idempotentTask,
97
+ workflow_17.idempotentTaskShortWindow,
98
+ workflow_18.lower,
99
+ workflow_19.returnExceptionsTask,
100
+ workflow_20.runDetailTestWorkflow,
96
101
  e2e_workflows_1.helloWorld,
97
102
  e2e_workflows_1.helloWorldDurable,
98
- workflow_20.streamingTask,
99
- workflow_21.timeoutTask,
100
- workflow_21.refreshTimeoutTask,
101
- workflow_22.webhookWorkflow,
102
- workflow_23.childIndexChild,
103
- workflow_23.childIndexParent,
104
- workflow_23.scenarioTask,
105
- workflow_23.orchestratorTask,
106
- workflow_24.supportAgent,
107
- workflow_24.triageTicket,
108
- workflow_24.generateReply,
109
- workflow_24.escalateTicket,
110
- workflow_25.welcomeEmail,
111
- workflow_26.pdfPipeline,
112
- workflow_19.batchSimple,
113
- workflow_19.batchKeyed,
114
- workflow_19.batchKeyedFailable,
115
- workflow_19.batchKeyedInterval,
116
- workflow_19.batchLarge,
117
- workflow_19.batchSingle,
118
- workflow_19.batchOrdered,
119
- workflow_19.batchBroadcast,
120
- workflow_19.batchCancel,
121
- workflow_19.child,
122
- workflow_19.childBatch,
123
- workflow_19.batchChildSpawn,
124
- workflow_19.batchChildBatchSpawn,
103
+ workflow_22.streamingTask,
104
+ workflow_23.dagStream,
105
+ workflow_23.longStream,
106
+ workflow_24.timeoutTask,
107
+ workflow_24.refreshTimeoutTask,
108
+ workflow_25.webhookWorkflow,
109
+ workflow_26.childIndexChild,
110
+ workflow_26.childIndexParent,
111
+ workflow_26.scenarioTask,
112
+ workflow_26.orchestratorTask,
113
+ workflow_27.supportAgent,
114
+ workflow_27.triageTicket,
115
+ workflow_27.generateReply,
116
+ workflow_27.escalateTicket,
117
+ workflow_28.welcomeEmail,
118
+ workflow_29.pdfPipeline,
119
+ workflow_21.batchSimple,
120
+ workflow_21.batchKeyed,
121
+ workflow_21.batchKeyedFailable,
122
+ workflow_21.batchKeyedInterval,
123
+ workflow_21.batchLarge,
124
+ workflow_21.batchSingle,
125
+ workflow_21.batchOrdered,
126
+ workflow_21.batchBroadcast,
127
+ workflow_21.batchCancel,
128
+ workflow_21.child,
129
+ workflow_21.childBatch,
130
+ workflow_21.batchChildSpawn,
131
+ workflow_21.batchChildBatchSpawn,
125
132
  ];
126
133
  function main() {
127
134
  return __awaiter(this, void 0, void 0, function* () {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ const hatchet_client_1 = require("../hatchet-client");
13
+ const workflow_1 = require("./workflow");
14
+ function main() {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const worker = yield hatchet_client_1.hatchet.worker('subscribe-stream-worker', {
17
+ workflows: [workflow_1.longStream, workflow_1.dagStream],
18
+ slots: 8,
19
+ });
20
+ yield worker.start();
21
+ });
22
+ }
23
+ if (require.main === module) {
24
+ main();
25
+ }
@@ -0,0 +1,5 @@
1
+ export declare const STREAM_CHUNKS: string[];
2
+ export declare const PRE_STREAM_SLEEP_MS = 2000;
3
+ export declare const INTER_CHUNK_MS = 50;
4
+ export declare const longStream: import("../..").TaskWorkflowDeclaration<import("../..").UnknownInputType, void, {}, {}, {}, {}>;
5
+ export declare const dagStream: import("../..").WorkflowDeclaration<import("../..").UnknownInputType, {}, {}>;
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.dagStream = exports.longStream = exports.INTER_CHUNK_MS = exports.PRE_STREAM_SLEEP_MS = exports.STREAM_CHUNKS = void 0;
16
+ const sleep_1 = __importDefault(require("../../../util/sleep"));
17
+ const hatchet_client_1 = require("../hatchet-client");
18
+ exports.STREAM_CHUNKS = Array.from({ length: 20 }, (_, i) => `c${String(i).padStart(2, '0')}|`);
19
+ exports.PRE_STREAM_SLEEP_MS = 2000;
20
+ exports.INTER_CHUNK_MS = 50;
21
+ exports.longStream = hatchet_client_1.hatchet.task({
22
+ name: 'subscribe-stream-long',
23
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
24
+ yield (0, sleep_1.default)(exports.PRE_STREAM_SLEEP_MS);
25
+ for (const chunk of exports.STREAM_CHUNKS) {
26
+ yield ctx.putStream(chunk);
27
+ yield (0, sleep_1.default)(exports.INTER_CHUNK_MS);
28
+ }
29
+ }),
30
+ });
31
+ // An onFailure handler makes the run a DAG. DAG QUEUED->RUNNING used to be
32
+ // published as workflow-run-finished, which hung up stream subscribers as
33
+ // soon as the run started.
34
+ exports.dagStream = hatchet_client_1.hatchet.workflow({
35
+ name: 'subscribe-stream-dag',
36
+ });
37
+ exports.dagStream.task({
38
+ name: 'subscribe-stream-dag',
39
+ fn: (_, ctx) => __awaiter(void 0, void 0, void 0, function* () {
40
+ yield (0, sleep_1.default)(exports.PRE_STREAM_SLEEP_MS);
41
+ for (const chunk of exports.STREAM_CHUNKS) {
42
+ yield ctx.putStream(chunk);
43
+ }
44
+ }),
45
+ });
46
+ exports.dagStream.onFailure({
47
+ name: 'subscribe-stream-dag-on-failure',
48
+ fn: () => __awaiter(void 0, void 0, void 0, function* () { }),
49
+ });
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.29.2";
1
+ export declare const HATCHET_VERSION = "1.30.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.29.2';
4
+ exports.HATCHET_VERSION = '1.30.0';