@hatchet-dev/typescript-sdk 1.30.1 → 1.31.1
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.
- package/package.json +15 -15
- package/v1/client/worker/worker-internal.d.ts +15 -0
- package/v1/client/worker/worker-internal.js +39 -14
- package/v1/declaration.d.ts +3 -1
- package/v1/examples/concurrency_dynamic/workflow.d.ts +10 -0
- package/v1/examples/concurrency_dynamic/workflow.js +32 -0
- package/v1/examples/concurrency_shared/workflow.d.ts +17 -0
- package/v1/examples/concurrency_shared/workflow.js +70 -0
- package/v1/examples/e2e-worker.js +97 -93
- package/v1/task.d.ts +24 -3
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.31.1",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -33,12 +33,20 @@
|
|
|
33
33
|
],
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"devDependencies": {
|
|
36
|
+
"@anthropic-ai/claude-agent-sdk": "^0.3.148",
|
|
36
37
|
"@aws-sdk/client-s3": "^3.1042.0",
|
|
37
38
|
"@eslint/js": "^10.0.1",
|
|
39
|
+
"@grpc/grpc-js": "^1.14.3",
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
41
|
+
"@openai/agents": "0.14.2",
|
|
42
|
+
"@opentelemetry/api": "^1.9.0",
|
|
43
|
+
"@opentelemetry/core": "^2.0.0",
|
|
44
|
+
"@opentelemetry/exporter-trace-otlp-grpc": "^0.221.0",
|
|
45
|
+
"@opentelemetry/instrumentation": "^0.221.0",
|
|
46
|
+
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
38
47
|
"@types/jest": "^29.5.14",
|
|
39
48
|
"@types/node": "^22.13.14",
|
|
40
49
|
"autoprefixer": "^10.4.27",
|
|
41
|
-
"postcss": "^8.5.10",
|
|
42
50
|
"dotenv-cli": "^7.4.4",
|
|
43
51
|
"eslint": "^10.0.3",
|
|
44
52
|
"eslint-config-prettier": "^10.1.8",
|
|
@@ -49,23 +57,15 @@
|
|
|
49
57
|
"jest": "^29.7.0",
|
|
50
58
|
"jest-tsd": "^0.2.2",
|
|
51
59
|
"pino": "^9.12.0",
|
|
60
|
+
"postcss": "^8.5.10",
|
|
52
61
|
"prettier": "^3.8.1",
|
|
62
|
+
"prom-client": "^15.1.3",
|
|
53
63
|
"resolve-tspaths": "^0.8.23",
|
|
54
64
|
"ts-jest": "^29.4.6",
|
|
55
65
|
"ts-node": "^10.9.2",
|
|
56
66
|
"ts-proto": "^2.11.4",
|
|
57
67
|
"tsconfig-paths": "^4.2.0",
|
|
58
68
|
"tsx": "^4.21.0",
|
|
59
|
-
"@anthropic-ai/claude-agent-sdk": "^0.3.148",
|
|
60
|
-
"@grpc/grpc-js": "^1.14.3",
|
|
61
|
-
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
62
|
-
"@openai/agents": "0.14.2",
|
|
63
|
-
"@opentelemetry/api": "^1.9.0",
|
|
64
|
-
"@opentelemetry/core": "^2.0.0",
|
|
65
|
-
"@opentelemetry/exporter-trace-otlp-grpc": "^0.221.0",
|
|
66
|
-
"@opentelemetry/instrumentation": "^0.221.0",
|
|
67
|
-
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
68
|
-
"prom-client": "^15.1.3",
|
|
69
69
|
"typedoc": "^0.28.17",
|
|
70
70
|
"typedoc-plugin-markdown": "^4.10.0",
|
|
71
71
|
"typedoc-plugin-no-inherit": "^1.6.1",
|
|
@@ -81,13 +81,12 @@
|
|
|
81
81
|
"nice-grpc": "^2.1.14",
|
|
82
82
|
"nice-grpc-common": "^2.0.2",
|
|
83
83
|
"protobufjs": "^7.5.5",
|
|
84
|
-
"qs": "^6.
|
|
84
|
+
"qs": "^6.16.0",
|
|
85
85
|
"semver": "^7.7.4",
|
|
86
86
|
"yaml": "^2.8.3",
|
|
87
87
|
"zod-to-json-schema": "^3.24.2"
|
|
88
88
|
},
|
|
89
89
|
"peerDependencies": {
|
|
90
|
-
"zod": "^3.25.0 || ^4.0.0",
|
|
91
90
|
"@anthropic-ai/claude-agent-sdk": "^0.3.148",
|
|
92
91
|
"@grpc/grpc-js": "^1.14.3",
|
|
93
92
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
@@ -97,7 +96,8 @@
|
|
|
97
96
|
"@opentelemetry/exporter-trace-otlp-grpc": "^0.221.0",
|
|
98
97
|
"@opentelemetry/instrumentation": "^0.221.0",
|
|
99
98
|
"@opentelemetry/sdk-trace-base": "^2.0.0",
|
|
100
|
-
"prom-client": "^15.1.3"
|
|
99
|
+
"prom-client": "^15.1.3",
|
|
100
|
+
"zod": "^3.25.0 || ^4.0.0"
|
|
101
101
|
},
|
|
102
102
|
"peerDependenciesMeta": {
|
|
103
103
|
"zod": {
|
|
@@ -113,6 +113,21 @@ 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 mapConcurrencyPb(entries: Concurrency[]): {
|
|
117
|
+
expression: string;
|
|
118
|
+
maxRuns: number | undefined;
|
|
119
|
+
limitStrategy: import("../..").ConcurrencyLimitStrategy | undefined;
|
|
120
|
+
name: string | undefined;
|
|
121
|
+
isTenantScoped: boolean | undefined;
|
|
122
|
+
maxRunsExpression: string | undefined;
|
|
123
|
+
}[];
|
|
124
|
+
export declare function taskConcurrencyArr(task: {
|
|
125
|
+
concurrency?: Concurrency | Concurrency[];
|
|
126
|
+
}, workflow: {
|
|
127
|
+
taskDefaults?: {
|
|
128
|
+
concurrency?: Concurrency | Concurrency[];
|
|
129
|
+
};
|
|
130
|
+
}): Concurrency[];
|
|
116
131
|
export declare function assertValidConcurrencyArr(concurrency: Concurrency[] | undefined): void;
|
|
117
132
|
export declare function mapBatchConfigPb(batch: CreateWorkflowTaskOpts<any, any>['batch']): TaskBatchConfig | undefined;
|
|
118
133
|
export declare function resolveExecutionTimeout(task: {
|
|
@@ -55,6 +55,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
55
55
|
exports.InternalWorker = void 0;
|
|
56
56
|
exports.mapSlotRequestsPb = mapSlotRequestsPb;
|
|
57
57
|
exports.mapRateLimitPb = mapRateLimitPb;
|
|
58
|
+
exports.mapConcurrencyPb = mapConcurrencyPb;
|
|
59
|
+
exports.taskConcurrencyArr = taskConcurrencyArr;
|
|
58
60
|
exports.assertValidConcurrencyArr = assertValidConcurrencyArr;
|
|
59
61
|
exports.mapBatchConfigPb = mapBatchConfigPb;
|
|
60
62
|
exports.resolveExecutionTimeout = resolveExecutionTimeout;
|
|
@@ -307,7 +309,7 @@ class InternalWorker {
|
|
|
307
309
|
eventTriggers,
|
|
308
310
|
cronTriggers,
|
|
309
311
|
sticky: stickyStrategy,
|
|
310
|
-
concurrencyArr,
|
|
312
|
+
concurrencyArr: mapConcurrencyPb(concurrencyArr),
|
|
311
313
|
onFailureTask,
|
|
312
314
|
defaultPriority: workflow.defaultPriority,
|
|
313
315
|
inputJsonSchema,
|
|
@@ -333,22 +335,13 @@ class InternalWorker {
|
|
|
333
335
|
slotRequests: mapSlotRequestsPb(task, durableTaskSet.has(task)),
|
|
334
336
|
batch: mapBatchConfigPb(batchOf(task)),
|
|
335
337
|
concurrency: (() => {
|
|
336
|
-
|
|
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
|
-
: [];
|
|
338
|
+
const taskConcurrency = taskConcurrencyArr(task, workflow);
|
|
346
339
|
assertValidConcurrencyArr(taskConcurrency);
|
|
347
|
-
return taskConcurrency;
|
|
340
|
+
return mapConcurrencyPb(taskConcurrency);
|
|
348
341
|
})(),
|
|
349
342
|
});
|
|
350
343
|
}),
|
|
351
|
-
concurrency: concurrencySolo,
|
|
344
|
+
concurrency: concurrencySolo ? mapConcurrencyPb([concurrencySolo])[0] : undefined,
|
|
352
345
|
defaultFilters: (_w = (_v = workflow.defaultFilters) === null || _v === void 0 ? void 0 : _v.map((f) => ({
|
|
353
346
|
scope: f.scope,
|
|
354
347
|
expression: f.expression,
|
|
@@ -1116,10 +1109,42 @@ function parseBatchPayload(actionPayload) {
|
|
|
1116
1109
|
function batchOf(task) {
|
|
1117
1110
|
return 'batch' in task ? task.batch : undefined;
|
|
1118
1111
|
}
|
|
1112
|
+
// mapConcurrencyPb maps SDK concurrency entries onto the proto shape; entries keep their
|
|
1113
|
+
// declared order, which is the chain order.
|
|
1114
|
+
function mapConcurrencyPb(entries) {
|
|
1115
|
+
return entries.map((c) => ({
|
|
1116
|
+
expression: c.expression,
|
|
1117
|
+
// a string maxRuns is a CEL expression; the static field then carries the default
|
|
1118
|
+
// of 1, which only governs slots created before the expression existed
|
|
1119
|
+
maxRuns: typeof c.maxRuns === 'string' ? 1 : c.maxRuns,
|
|
1120
|
+
limitStrategy: c.limitStrategy,
|
|
1121
|
+
name: c.name,
|
|
1122
|
+
isTenantScoped: c.isTenantScoped,
|
|
1123
|
+
maxRunsExpression: typeof c.maxRuns === 'string' ? c.maxRuns : undefined,
|
|
1124
|
+
}));
|
|
1125
|
+
}
|
|
1126
|
+
function taskConcurrencyArr(task, workflow) {
|
|
1127
|
+
var _a;
|
|
1128
|
+
if (task.concurrency) {
|
|
1129
|
+
return Array.isArray(task.concurrency) ? task.concurrency : [task.concurrency];
|
|
1130
|
+
}
|
|
1131
|
+
if ((_a = workflow.taskDefaults) === null || _a === void 0 ? void 0 : _a.concurrency) {
|
|
1132
|
+
return Array.isArray(workflow.taskDefaults.concurrency)
|
|
1133
|
+
? workflow.taskDefaults.concurrency
|
|
1134
|
+
: [workflow.taskDefaults.concurrency];
|
|
1135
|
+
}
|
|
1136
|
+
return [];
|
|
1137
|
+
}
|
|
1119
1138
|
function assertValidConcurrencyArr(concurrency) {
|
|
1120
1139
|
concurrency === null || concurrency === void 0 ? void 0 : concurrency.forEach((c) => {
|
|
1140
|
+
if (typeof c.maxRuns === 'string') {
|
|
1141
|
+
if (!c.maxRuns.trim()) {
|
|
1142
|
+
throw new Error('concurrency.maxRuns expression must be non-empty');
|
|
1143
|
+
}
|
|
1144
|
+
return;
|
|
1145
|
+
}
|
|
1121
1146
|
if (c.maxRuns !== undefined && (!Number.isInteger(c.maxRuns) || c.maxRuns <= 0)) {
|
|
1122
|
-
throw new Error(`concurrency.maxRuns must be a positive integer
|
|
1147
|
+
throw new Error(`concurrency.maxRuns must be a positive integer or a CEL expression, got: ${c.maxRuns}`);
|
|
1123
1148
|
}
|
|
1124
1149
|
});
|
|
1125
1150
|
}
|
package/v1/declaration.d.ts
CHANGED
|
@@ -228,7 +228,9 @@ export type TaskDefaults = {
|
|
|
228
228
|
*/
|
|
229
229
|
workerLabels?: CreateWorkflowTaskOpts<any, any>['desiredWorkerLabels'];
|
|
230
230
|
/**
|
|
231
|
-
* (optional) the concurrency options for the task.
|
|
231
|
+
* (optional) the concurrency options for the task, processed in array order. Entries
|
|
232
|
+
* may be workflow-scoped strategies or tenant-scoped entries (`isTenantScoped`)
|
|
233
|
+
* strategies, whose definitions are upserted as part of workflow registration.
|
|
232
234
|
*/
|
|
233
235
|
concurrency?: Concurrency | Concurrency[];
|
|
234
236
|
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type WorkflowInput = {
|
|
2
|
+
account: string;
|
|
3
|
+
tier: string;
|
|
4
|
+
};
|
|
5
|
+
export type WorkflowOutput = {
|
|
6
|
+
'dynamic-task': {
|
|
7
|
+
account: string;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare const concurrencyDynamicWorkflow: import("../..").WorkflowDeclaration<WorkflowInput, WorkflowOutput, {}>;
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
+
exports.concurrencyDynamicWorkflow = void 0;
|
|
13
|
+
const v1_1 = require("../..");
|
|
14
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
15
|
+
// > Dynamic Max Runs
|
|
16
|
+
// maxRuns accepts a number or a CEL expression string. With an expression, each
|
|
17
|
+
// concurrency group's limit is computed from the task's input.
|
|
18
|
+
exports.concurrencyDynamicWorkflow = hatchet_client_1.hatchet.workflow({
|
|
19
|
+
name: 'concurrency-dynamic',
|
|
20
|
+
});
|
|
21
|
+
exports.concurrencyDynamicWorkflow.task({
|
|
22
|
+
name: 'dynamic-task',
|
|
23
|
+
concurrency: [
|
|
24
|
+
{
|
|
25
|
+
expression: 'input.account',
|
|
26
|
+
maxRuns: "input.tier == 'premium' ? 10 : 1",
|
|
27
|
+
limitStrategy: v1_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
fn: (input) => __awaiter(void 0, void 0, void 0, function* () { return ({ account: input.account }); }),
|
|
31
|
+
});
|
|
32
|
+
// !!
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Concurrency } from '../..';
|
|
2
|
+
export declare const SLEEP_TIME_MS = 1500;
|
|
3
|
+
export type WorkflowInput = {
|
|
4
|
+
group: string;
|
|
5
|
+
inline?: string;
|
|
6
|
+
};
|
|
7
|
+
export type RunWindow = {
|
|
8
|
+
startMs: number;
|
|
9
|
+
endMs: number;
|
|
10
|
+
};
|
|
11
|
+
export type WorkflowOutput = {
|
|
12
|
+
'shared-task': RunWindow;
|
|
13
|
+
};
|
|
14
|
+
export declare const sharedLimit: Concurrency;
|
|
15
|
+
export declare const concurrencySharedWorkflowA: import("../..").WorkflowDeclaration<WorkflowInput, WorkflowOutput, {}>;
|
|
16
|
+
export declare const concurrencySharedWorkflowB: import("../..").WorkflowDeclaration<WorkflowInput, WorkflowOutput, {}>;
|
|
17
|
+
export declare const concurrencySharedMixedWorkflow: import("../..").WorkflowDeclaration<WorkflowInput, WorkflowOutput, {}>;
|
|
@@ -0,0 +1,70 @@
|
|
|
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
|
+
exports.concurrencySharedMixedWorkflow = exports.concurrencySharedWorkflowB = exports.concurrencySharedWorkflowA = exports.sharedLimit = exports.SLEEP_TIME_MS = void 0;
|
|
13
|
+
const v1_1 = require("../..");
|
|
14
|
+
const hatchet_client_1 = require("../hatchet-client");
|
|
15
|
+
const sleep = (ms) => new Promise((resolve) => {
|
|
16
|
+
setTimeout(resolve, ms);
|
|
17
|
+
});
|
|
18
|
+
exports.SLEEP_TIME_MS = 1500;
|
|
19
|
+
// > Shared Concurrency Strategy
|
|
20
|
+
// A tenant-scoped strategy is shared across workflows: every task declaring the same name
|
|
21
|
+
// consumes the same concurrency limit. The definition rides on workflow registration and
|
|
22
|
+
// re-registering the name updates it in place.
|
|
23
|
+
exports.sharedLimit = {
|
|
24
|
+
name: 'ts-example-shared-limit',
|
|
25
|
+
isTenantScoped: true,
|
|
26
|
+
expression: 'input.group',
|
|
27
|
+
maxRuns: 1,
|
|
28
|
+
limitStrategy: v1_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
29
|
+
};
|
|
30
|
+
const runWindowTask = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
+
const startMs = Date.now();
|
|
32
|
+
yield sleep(exports.SLEEP_TIME_MS);
|
|
33
|
+
return { startMs, endMs: Date.now() };
|
|
34
|
+
});
|
|
35
|
+
exports.concurrencySharedWorkflowA = hatchet_client_1.hatchet.workflow({
|
|
36
|
+
name: 'concurrency-shared-a',
|
|
37
|
+
});
|
|
38
|
+
exports.concurrencySharedWorkflowA.task({
|
|
39
|
+
name: 'shared-task',
|
|
40
|
+
concurrency: [exports.sharedLimit],
|
|
41
|
+
fn: runWindowTask,
|
|
42
|
+
});
|
|
43
|
+
exports.concurrencySharedWorkflowB = hatchet_client_1.hatchet.workflow({
|
|
44
|
+
name: 'concurrency-shared-b',
|
|
45
|
+
});
|
|
46
|
+
exports.concurrencySharedWorkflowB.task({
|
|
47
|
+
name: 'shared-task',
|
|
48
|
+
concurrency: [exports.sharedLimit],
|
|
49
|
+
fn: runWindowTask,
|
|
50
|
+
});
|
|
51
|
+
// !!
|
|
52
|
+
// > Mixed Inline And Shared Concurrency
|
|
53
|
+
// A single task can combine a workflow-scoped inline strategy with a shared strategy;
|
|
54
|
+
// both limits apply at once.
|
|
55
|
+
exports.concurrencySharedMixedWorkflow = hatchet_client_1.hatchet.workflow({
|
|
56
|
+
name: 'concurrency-shared-mixed',
|
|
57
|
+
});
|
|
58
|
+
exports.concurrencySharedMixedWorkflow.task({
|
|
59
|
+
name: 'shared-task',
|
|
60
|
+
concurrency: [
|
|
61
|
+
{
|
|
62
|
+
expression: 'input.inline',
|
|
63
|
+
maxRuns: 1,
|
|
64
|
+
limitStrategy: v1_1.ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN,
|
|
65
|
+
},
|
|
66
|
+
exports.sharedLimit,
|
|
67
|
+
],
|
|
68
|
+
fn: runWindowTask,
|
|
69
|
+
});
|
|
70
|
+
// !!
|
|
@@ -25,30 +25,31 @@ const workflow_4 = require("./concurrency_cancel_newest/workflow");
|
|
|
25
25
|
const workflow_5 = require("./concurrency_cancel_queued_except_newest/workflow");
|
|
26
26
|
const workflow_6 = require("./concurrency_cancel_queued_except_oldest/workflow");
|
|
27
27
|
const workflow_7 = require("./concurrency_multiple_keys/workflow");
|
|
28
|
-
const workflow_8 = require("./
|
|
29
|
-
const workflow_9 = require("./
|
|
30
|
-
const workflow_10 = require("./
|
|
31
|
-
const workflow_11 = require("./
|
|
32
|
-
const workflow_12 = require("./
|
|
33
|
-
const workflow_13 = require("./
|
|
34
|
-
const workflow_14 = require("./
|
|
35
|
-
const workflow_15 = require("./
|
|
36
|
-
const workflow_16 = require("./
|
|
37
|
-
const workflow_17 = require("./
|
|
38
|
-
const workflow_18 = require("./
|
|
39
|
-
const workflow_19 = require("./
|
|
40
|
-
const workflow_20 = require("./
|
|
41
|
-
const workflow_21 = require("./
|
|
28
|
+
const workflow_8 = require("./concurrency_shared/workflow");
|
|
29
|
+
const workflow_9 = require("./concurrency_workflow_level/workflow");
|
|
30
|
+
const workflow_10 = require("./dag/workflow");
|
|
31
|
+
const workflow_11 = require("./durable/workflow");
|
|
32
|
+
const workflow_12 = require("./durable_event/workflow");
|
|
33
|
+
const workflow_13 = require("./durable_eviction/workflow");
|
|
34
|
+
const workflow_14 = require("./durable_callback_ordering/workflow");
|
|
35
|
+
const workflow_15 = require("./durable_sleep/workflow");
|
|
36
|
+
const workflow_16 = require("./logger/workflow");
|
|
37
|
+
const workflow_17 = require("./non_retryable/workflow");
|
|
38
|
+
const workflow_18 = require("./on_failure/workflow");
|
|
39
|
+
const workflow_19 = require("./idempotency/workflow");
|
|
40
|
+
const workflow_20 = require("./on_event/workflow");
|
|
41
|
+
const workflow_21 = require("./return_exceptions/workflow");
|
|
42
|
+
const workflow_22 = require("./run_details/workflow");
|
|
42
43
|
const e2e_workflows_1 = require("./simple/e2e-workflows");
|
|
43
|
-
const
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
const
|
|
44
|
+
const workflow_23 = require("./batch_assign/workflow");
|
|
45
|
+
const workflow_24 = require("./streaming/workflow");
|
|
46
|
+
const workflow_25 = require("./subscribe_to_stream/workflow");
|
|
47
|
+
const workflow_26 = require("./timeout/workflow");
|
|
48
|
+
const workflow_27 = require("./webhooks/workflow");
|
|
49
|
+
const workflow_28 = require("./child_index/workflow");
|
|
50
|
+
const workflow_29 = require("./support_agent/workflow");
|
|
51
|
+
const workflow_30 = require("./welcome_email/workflow");
|
|
52
|
+
const workflow_31 = require("./pdf_pipeline/workflow");
|
|
52
53
|
const workflows = [
|
|
53
54
|
workflow_1.bulkChild,
|
|
54
55
|
workflow_1.bulkParentWorkflow,
|
|
@@ -62,78 +63,81 @@ const workflows = [
|
|
|
62
63
|
workflow_5.concurrencyCancelQueuedExceptNewestWorkflow,
|
|
63
64
|
workflow_6.concurrencyCancelQueuedExceptOldestWorkflow,
|
|
64
65
|
workflow_7.concurrencyMultipleKeysWorkflow,
|
|
65
|
-
workflow_8.
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
workflow_10.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
workflow_11.
|
|
84
|
-
workflow_11.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
workflow_14.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
66
|
+
workflow_8.concurrencySharedWorkflowA,
|
|
67
|
+
workflow_8.concurrencySharedWorkflowB,
|
|
68
|
+
workflow_8.concurrencySharedMixedWorkflow,
|
|
69
|
+
workflow_9.concurrencyWorkflowLevelWorkflow,
|
|
70
|
+
workflow_10.dag,
|
|
71
|
+
workflow_11.durableWorkflow,
|
|
72
|
+
workflow_11.waitForSleepTwice,
|
|
73
|
+
workflow_11.spawnChildTask,
|
|
74
|
+
workflow_11.durableWithSpawn,
|
|
75
|
+
workflow_11.durableWithBulkSpawn,
|
|
76
|
+
workflow_11.durableSleepEventSpawn,
|
|
77
|
+
workflow_11.durableWithExplicitSpawn,
|
|
78
|
+
workflow_11.durableNonDeterminism,
|
|
79
|
+
workflow_11.durableReplayReset,
|
|
80
|
+
workflow_11.dagChildWorkflow,
|
|
81
|
+
workflow_11.durableSpawnDag,
|
|
82
|
+
workflow_11.waitForEventLookback,
|
|
83
|
+
workflow_11.waitForOrEventLookback,
|
|
84
|
+
workflow_11.waitForTwoEventsSecondPushedFirst,
|
|
85
|
+
workflow_11.errorRaisingTask,
|
|
86
|
+
workflow_11.errorRaisingDurableParent,
|
|
87
|
+
workflow_12.durableEvent,
|
|
88
|
+
workflow_12.durableEventWithFilter,
|
|
89
|
+
workflow_14.callbackOrderingLeaf,
|
|
90
|
+
workflow_14.callbackOrderingMid,
|
|
91
|
+
workflow_14.callbackOrderingRoot,
|
|
92
|
+
workflow_15.durableSleep,
|
|
93
|
+
workflow_13.evictableSleep,
|
|
94
|
+
workflow_13.evictableWaitForEvent,
|
|
95
|
+
workflow_13.evictableMemoThenWaitForEvent,
|
|
96
|
+
workflow_13.evictableChildSpawn,
|
|
97
|
+
workflow_13.multipleEviction,
|
|
98
|
+
workflow_13.nonEvictableSleep,
|
|
99
|
+
workflow_13.childTask,
|
|
100
|
+
workflow_13.bulkChildTask,
|
|
101
|
+
workflow_13.evictableChildBulkSpawn,
|
|
102
|
+
(0, workflow_16.createLoggingWorkflow)(hatchet_client_1.hatchet),
|
|
103
|
+
workflow_17.nonRetryableWorkflow,
|
|
104
|
+
workflow_18.failureWorkflow,
|
|
105
|
+
workflow_19.idempotentTask,
|
|
106
|
+
workflow_19.idempotentTaskShortWindow,
|
|
107
|
+
workflow_20.lower,
|
|
108
|
+
workflow_21.returnExceptionsTask,
|
|
109
|
+
workflow_22.runDetailTestWorkflow,
|
|
106
110
|
e2e_workflows_1.helloWorld,
|
|
107
111
|
e2e_workflows_1.helloWorldDurable,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
112
|
+
workflow_24.streamingTask,
|
|
113
|
+
workflow_25.dagStream,
|
|
114
|
+
workflow_25.longStream,
|
|
115
|
+
workflow_26.timeoutTask,
|
|
116
|
+
workflow_26.refreshTimeoutTask,
|
|
117
|
+
workflow_27.webhookWorkflow,
|
|
118
|
+
workflow_28.childIndexChild,
|
|
119
|
+
workflow_28.childIndexParent,
|
|
120
|
+
workflow_28.scenarioTask,
|
|
121
|
+
workflow_28.orchestratorTask,
|
|
122
|
+
workflow_29.supportAgent,
|
|
123
|
+
workflow_29.triageTicket,
|
|
124
|
+
workflow_29.generateReply,
|
|
125
|
+
workflow_29.escalateTicket,
|
|
126
|
+
workflow_30.welcomeEmail,
|
|
127
|
+
workflow_31.pdfPipeline,
|
|
128
|
+
workflow_23.batchSimple,
|
|
129
|
+
workflow_23.batchKeyed,
|
|
130
|
+
workflow_23.batchKeyedFailable,
|
|
131
|
+
workflow_23.batchKeyedInterval,
|
|
132
|
+
workflow_23.batchLarge,
|
|
133
|
+
workflow_23.batchSingle,
|
|
134
|
+
workflow_23.batchOrdered,
|
|
135
|
+
workflow_23.batchBroadcast,
|
|
136
|
+
workflow_23.batchCancel,
|
|
137
|
+
workflow_23.child,
|
|
138
|
+
workflow_23.childBatch,
|
|
139
|
+
workflow_23.batchChildSpawn,
|
|
140
|
+
workflow_23.batchChildBatchSpawn,
|
|
137
141
|
];
|
|
138
142
|
function main() {
|
|
139
143
|
return __awaiter(this, void 0, void 0, function* () {
|
package/v1/task.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { ConcurrencyLimitStrategy, WorkerLabelComparator };
|
|
|
11
11
|
*/
|
|
12
12
|
export type Concurrency = {
|
|
13
13
|
/**
|
|
14
|
-
* required the CEL expression to use for concurrency
|
|
14
|
+
* required: the CEL expression to use for concurrency
|
|
15
15
|
*
|
|
16
16
|
* @example
|
|
17
17
|
* ```
|
|
@@ -20,17 +20,38 @@ export type Concurrency = {
|
|
|
20
20
|
*/
|
|
21
21
|
expression: string;
|
|
22
22
|
/**
|
|
23
|
-
* (optional) the maximum number of concurrent
|
|
23
|
+
* (optional) the maximum number of concurrent runs: a fixed number, or a CEL
|
|
24
|
+
* expression over task input computing the max runs for that task's concurrency
|
|
25
|
+
* group. With an expression, a group's effective limit is the value from its most
|
|
26
|
+
* recently created task.
|
|
24
27
|
*
|
|
25
28
|
* default: 1
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```
|
|
32
|
+
* maxRuns: 5
|
|
33
|
+
* maxRuns: "input.tier == 'premium' ? 10 : 1"
|
|
34
|
+
* ```
|
|
26
35
|
*/
|
|
27
|
-
maxRuns?: number;
|
|
36
|
+
maxRuns?: number | string;
|
|
28
37
|
/**
|
|
29
38
|
* (optional) the strategy to use when the concurrency limit is reached
|
|
30
39
|
*
|
|
31
40
|
* default: CANCEL_IN_PROGRESS
|
|
32
41
|
*/
|
|
33
42
|
limitStrategy?: ConcurrencyLimitStrategy;
|
|
43
|
+
/**
|
|
44
|
+
* (required when isTenantScoped) the strategy name; unique per tenant for tenant-scoped
|
|
45
|
+
* strategies
|
|
46
|
+
*/
|
|
47
|
+
name?: string;
|
|
48
|
+
/**
|
|
49
|
+
* (optional) when true, the entry defines (or updates in place) a tenant-scoped strategy
|
|
50
|
+
* shared across workflows, keyed by name: every task declaring the same name consumes
|
|
51
|
+
* the same concurrency limit. The position in the concurrency list is the chain order,
|
|
52
|
+
* and chains sharing tenant-scoped strategies must order them consistently.
|
|
53
|
+
*/
|
|
54
|
+
isTenantScoped?: boolean;
|
|
34
55
|
};
|
|
35
56
|
/**
|
|
36
57
|
* @deprecated use Concurrency instead
|
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.31.1";
|
package/version.js
CHANGED