@hatchet-dev/typescript-sdk 0.10.1 → 0.12.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.
- package/clients/admin/admin-client.d.ts +1 -0
- package/clients/dispatcher/dispatcher-client.d.ts +3 -0
- package/clients/dispatcher/dispatcher-client.js +20 -1
- package/clients/hatchet-client/hatchet-client.d.ts +2 -2
- package/clients/hatchet-client/hatchet-client.js +11 -4
- package/clients/listener/listener-client.d.ts +10 -4
- package/clients/listener/listener-client.js +45 -13
- package/clients/worker/worker.d.ts +12 -0
- package/clients/worker/worker.js +54 -2
- package/examples/affinity-workers.d.ts +1 -0
- package/examples/affinity-workers.js +93 -0
- package/examples/api.d.ts +1 -0
- package/examples/api.js +61 -0
- package/examples/concurrency/cancel-in-progress/concurrency-event.d.ts +1 -0
- package/examples/concurrency/cancel-in-progress/concurrency-event.js +37 -0
- package/examples/concurrency/cancel-in-progress/concurrency-worker.d.ts +1 -0
- package/examples/concurrency/cancel-in-progress/concurrency-worker.js +66 -0
- package/examples/concurrency/group-round-robin/concurrency-event.d.ts +1 -0
- package/examples/concurrency/group-round-robin/concurrency-event.js +35 -0
- package/examples/concurrency/group-round-robin/concurrency-worker.d.ts +1 -0
- package/examples/concurrency/group-round-robin/concurrency-worker.js +61 -0
- package/examples/dag-worker.d.ts +1 -0
- package/examples/dag-worker.js +76 -0
- package/examples/example-event-with-results.d.ts +1 -0
- package/examples/example-event-with-results.js +50 -0
- package/examples/example-event.d.ts +1 -0
- package/examples/example-event.js +10 -0
- package/examples/fanout-worker.d.ts +1 -0
- package/examples/fanout-worker.js +69 -0
- package/examples/logger.d.ts +1 -0
- package/examples/logger.js +50 -0
- package/examples/manual-trigger.d.ts +1 -0
- package/examples/manual-trigger.js +46 -0
- package/examples/multi-workflow.d.ts +1 -0
- package/examples/multi-workflow.js +55 -0
- package/examples/namespaced-worker.d.ts +1 -0
- package/examples/namespaced-worker.js +56 -0
- package/examples/on-failure.d.ts +1 -0
- package/examples/on-failure.js +53 -0
- package/examples/playground.d.ts +1 -0
- package/examples/playground.js +39 -0
- package/examples/rate-limit/events.d.ts +1 -0
- package/examples/rate-limit/events.js +16 -0
- package/examples/rate-limit/worker.d.ts +1 -0
- package/examples/rate-limit/worker.js +43 -0
- package/examples/retries-worker.d.ts +1 -0
- package/examples/retries-worker.js +60 -0
- package/examples/simple-worker.d.ts +1 -0
- package/examples/simple-worker.js +55 -0
- package/examples/sticky-worker.d.ts +1 -0
- package/examples/sticky-worker.js +73 -0
- package/examples/stream-by-additional-meta.d.ts +1 -0
- package/examples/stream-by-additional-meta.js +55 -0
- package/package.json +24 -21
- package/protoc/dispatcher/dispatcher.d.ts +109 -2
- package/protoc/dispatcher/dispatcher.js +518 -17
- package/protoc/events/events.d.ts +1 -1
- package/protoc/events/events.js +0 -5
- package/protoc/google/protobuf/timestamp.js +0 -8
- package/protoc/workflows/workflows.d.ts +82 -1
- package/protoc/workflows/workflows.js +404 -9
- package/step.d.ts +79 -2
- package/step.js +90 -3
- package/util/workflow-run-ref.d.ts +3 -0
- package/util/workflow-run-ref.js +21 -4
- package/workflow.d.ts +116 -1
- package/workflow.js +6 -1
package/step.d.ts
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
|
+
import { Workflow } from './workflow';
|
|
2
3
|
import { Action } from './clients/dispatcher/action-listener';
|
|
3
4
|
import { LogLevel } from './clients/event/event-client';
|
|
4
5
|
import { Logger } from './util/logger';
|
|
5
6
|
import { HatchetClient } from './clients/hatchet-client';
|
|
6
7
|
import WorkflowRunRef from './util/workflow-run-ref';
|
|
8
|
+
import { Worker } from './clients/worker';
|
|
9
|
+
import { WorkerLabels } from './clients/dispatcher/dispatcher-client';
|
|
10
|
+
import { WorkerLabelComparator } from './protoc/workflows';
|
|
7
11
|
export declare const CreateRateLimitSchema: z.ZodObject<{
|
|
8
12
|
key: z.ZodString;
|
|
9
13
|
units: z.ZodNumber;
|
|
@@ -14,6 +18,22 @@ export declare const CreateRateLimitSchema: z.ZodObject<{
|
|
|
14
18
|
key: string;
|
|
15
19
|
units: number;
|
|
16
20
|
}>;
|
|
21
|
+
export declare const DesiredWorkerLabelSchema: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
22
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
23
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
24
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
comparator: z.ZodOptional<z.ZodNativeEnum<typeof WorkerLabelComparator>>;
|
|
26
|
+
}, "strip", z.ZodTypeAny, {
|
|
27
|
+
value: string | number;
|
|
28
|
+
required?: boolean | undefined;
|
|
29
|
+
comparator?: WorkerLabelComparator | undefined;
|
|
30
|
+
weight?: number | undefined;
|
|
31
|
+
}, {
|
|
32
|
+
value: string | number;
|
|
33
|
+
required?: boolean | undefined;
|
|
34
|
+
comparator?: WorkerLabelComparator | undefined;
|
|
35
|
+
weight?: number | undefined;
|
|
36
|
+
}>]>>;
|
|
17
37
|
export declare const CreateStepSchema: z.ZodObject<{
|
|
18
38
|
name: z.ZodString;
|
|
19
39
|
parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -29,6 +49,22 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
29
49
|
key: string;
|
|
30
50
|
units: number;
|
|
31
51
|
}>, "many">>;
|
|
52
|
+
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
53
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
54
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
55
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
56
|
+
comparator: z.ZodOptional<z.ZodNativeEnum<typeof WorkerLabelComparator>>;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
value: string | number;
|
|
59
|
+
required?: boolean | undefined;
|
|
60
|
+
comparator?: WorkerLabelComparator | undefined;
|
|
61
|
+
weight?: number | undefined;
|
|
62
|
+
}, {
|
|
63
|
+
value: string | number;
|
|
64
|
+
required?: boolean | undefined;
|
|
65
|
+
comparator?: WorkerLabelComparator | undefined;
|
|
66
|
+
weight?: number | undefined;
|
|
67
|
+
}>]>>>>>;
|
|
32
68
|
}, "strip", z.ZodTypeAny, {
|
|
33
69
|
name: string;
|
|
34
70
|
timeout?: string | undefined;
|
|
@@ -38,6 +74,12 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
38
74
|
key: string;
|
|
39
75
|
units: number;
|
|
40
76
|
}[] | undefined;
|
|
77
|
+
worker_labels?: Record<string, string | number | {
|
|
78
|
+
value: string | number;
|
|
79
|
+
required?: boolean | undefined;
|
|
80
|
+
comparator?: WorkerLabelComparator | undefined;
|
|
81
|
+
weight?: number | undefined;
|
|
82
|
+
} | undefined> | undefined;
|
|
41
83
|
}, {
|
|
42
84
|
name: string;
|
|
43
85
|
timeout?: string | undefined;
|
|
@@ -47,6 +89,12 @@ export declare const CreateStepSchema: z.ZodObject<{
|
|
|
47
89
|
key: string;
|
|
48
90
|
units: number;
|
|
49
91
|
}[] | undefined;
|
|
92
|
+
worker_labels?: Record<string, string | number | {
|
|
93
|
+
value: string | number;
|
|
94
|
+
required?: boolean | undefined;
|
|
95
|
+
comparator?: WorkerLabelComparator | undefined;
|
|
96
|
+
weight?: number | undefined;
|
|
97
|
+
} | undefined> | undefined;
|
|
50
98
|
}>;
|
|
51
99
|
export type JsonObject = {
|
|
52
100
|
[Key in string]: JsonValue;
|
|
@@ -65,16 +113,25 @@ interface ContextData<T, K> {
|
|
|
65
113
|
triggered_by: string;
|
|
66
114
|
user_data: K;
|
|
67
115
|
}
|
|
116
|
+
export declare class ContextWorker {
|
|
117
|
+
private worker;
|
|
118
|
+
constructor(worker: Worker);
|
|
119
|
+
id(): string | undefined;
|
|
120
|
+
hasWorkflow(workflowName: string): boolean;
|
|
121
|
+
labels(): WorkerLabels;
|
|
122
|
+
upsertLabels(labels: WorkerLabels): Promise<WorkerLabels>;
|
|
123
|
+
}
|
|
68
124
|
export declare class Context<T, K = {}> {
|
|
69
125
|
data: ContextData<T, K>;
|
|
70
126
|
input: T;
|
|
71
127
|
controller: AbortController;
|
|
72
128
|
action: Action;
|
|
73
129
|
client: HatchetClient;
|
|
130
|
+
worker: ContextWorker;
|
|
74
131
|
overridesData: Record<string, any>;
|
|
75
132
|
logger: Logger;
|
|
76
133
|
spawnIndex: number;
|
|
77
|
-
constructor(action: Action, client: HatchetClient);
|
|
134
|
+
constructor(action: Action, client: HatchetClient, worker: Worker);
|
|
78
135
|
stepOutput(step: string): NextStep;
|
|
79
136
|
triggeredByEvent(): boolean;
|
|
80
137
|
workflowInput(): T;
|
|
@@ -94,7 +151,27 @@ export declare class Context<T, K = {}> {
|
|
|
94
151
|
refreshTimeout(incrementBy: string): Promise<void>;
|
|
95
152
|
releaseSlot(): Promise<void>;
|
|
96
153
|
putStream(data: string | Uint8Array): Promise<void>;
|
|
97
|
-
|
|
154
|
+
/**
|
|
155
|
+
* Spawns a new workflow.
|
|
156
|
+
*
|
|
157
|
+
* @param workflowName the name of the workflow to spawn
|
|
158
|
+
* @param input the input data for the workflow
|
|
159
|
+
* @param options additional options for spawning the workflow. If a string is provided, it is used as the key.
|
|
160
|
+
* If an object is provided, it can include:
|
|
161
|
+
* - key: a unique identifier for the workflow (deprecated, use options.key instead)
|
|
162
|
+
* - sticky: a boolean indicating whether to use sticky execution
|
|
163
|
+
* @param <Q> the type of the input data
|
|
164
|
+
* @param <P> the type of the output data
|
|
165
|
+
* @return a reference to the spawned workflow run
|
|
166
|
+
*/
|
|
167
|
+
spawnWorkflow<Q = JsonValue, P = JsonValue>(workflow: string | Workflow, input: Q, options?: string | {
|
|
168
|
+
key?: string;
|
|
169
|
+
sticky?: boolean;
|
|
170
|
+
}): WorkflowRunRef<P>;
|
|
171
|
+
additionalMetadata(): Record<string, string>;
|
|
172
|
+
childIndex(): number | undefined;
|
|
173
|
+
childKey(): string | undefined;
|
|
174
|
+
parentWorkflowRunId(): string | undefined;
|
|
98
175
|
}
|
|
99
176
|
export type StepRunFunction<T, K> = (ctx: Context<T, K>) => Promise<NextStep | void> | NextStep | void;
|
|
100
177
|
export interface CreateStep<T, K> extends z.infer<typeof CreateStepSchema> {
|
package/step.js
CHANGED
|
@@ -35,26 +35,61 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
35
35
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
36
36
|
};
|
|
37
37
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
38
|
-
exports.Context = exports.CreateStepSchema = exports.CreateRateLimitSchema = void 0;
|
|
38
|
+
exports.Context = exports.ContextWorker = exports.CreateStepSchema = exports.DesiredWorkerLabelSchema = exports.CreateRateLimitSchema = void 0;
|
|
39
39
|
/* eslint-disable max-classes-per-file */
|
|
40
40
|
const hatchet_error_1 = __importDefault(require("./util/errors/hatchet-error"));
|
|
41
41
|
const z = __importStar(require("zod"));
|
|
42
42
|
const workflow_1 = require("./workflow");
|
|
43
43
|
const logger_1 = require("./util/logger");
|
|
44
44
|
const parse_1 = require("./util/parse");
|
|
45
|
+
const workflows_1 = require("./protoc/workflows");
|
|
45
46
|
exports.CreateRateLimitSchema = z.object({
|
|
46
47
|
key: z.string(),
|
|
47
48
|
units: z.number().min(1),
|
|
48
49
|
});
|
|
50
|
+
exports.DesiredWorkerLabelSchema = z
|
|
51
|
+
.union([
|
|
52
|
+
z.string(),
|
|
53
|
+
z.number().int(),
|
|
54
|
+
z.object({
|
|
55
|
+
value: z.union([z.string(), z.number()]),
|
|
56
|
+
required: z.boolean().optional(),
|
|
57
|
+
weight: z.number().int().optional(),
|
|
58
|
+
// (optional) comparator for the label
|
|
59
|
+
// if not provided, the default is EQUAL
|
|
60
|
+
// desired COMPARATOR actual (i.e. desired > actual for GREATER_THAN)
|
|
61
|
+
comparator: z.nativeEnum(workflows_1.WorkerLabelComparator).optional(),
|
|
62
|
+
}),
|
|
63
|
+
])
|
|
64
|
+
.optional();
|
|
49
65
|
exports.CreateStepSchema = z.object({
|
|
50
66
|
name: z.string(),
|
|
51
67
|
parents: z.array(z.string()).optional(),
|
|
52
68
|
timeout: workflow_1.HatchetTimeoutSchema.optional(),
|
|
53
69
|
retries: z.number().optional(),
|
|
54
70
|
rate_limits: z.array(exports.CreateRateLimitSchema).optional(),
|
|
71
|
+
worker_labels: z.record(z.lazy(() => exports.DesiredWorkerLabelSchema)).optional(),
|
|
55
72
|
});
|
|
73
|
+
class ContextWorker {
|
|
74
|
+
constructor(worker) {
|
|
75
|
+
this.worker = worker;
|
|
76
|
+
}
|
|
77
|
+
id() {
|
|
78
|
+
return this.worker.workerId;
|
|
79
|
+
}
|
|
80
|
+
hasWorkflow(workflowName) {
|
|
81
|
+
return !!this.worker.workflow_registry.find((workflow) => workflow.id === workflowName);
|
|
82
|
+
}
|
|
83
|
+
labels() {
|
|
84
|
+
return this.worker.labels;
|
|
85
|
+
}
|
|
86
|
+
upsertLabels(labels) {
|
|
87
|
+
return this.worker.upsertLabels(labels);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
exports.ContextWorker = ContextWorker;
|
|
56
91
|
class Context {
|
|
57
|
-
constructor(action, client) {
|
|
92
|
+
constructor(action, client, worker) {
|
|
58
93
|
this.controller = new AbortController();
|
|
59
94
|
this.overridesData = {};
|
|
60
95
|
this.spawnIndex = 0;
|
|
@@ -63,6 +98,7 @@ class Context {
|
|
|
63
98
|
this.data = data;
|
|
64
99
|
this.action = action;
|
|
65
100
|
this.client = client;
|
|
101
|
+
this.worker = new ContextWorker(worker);
|
|
66
102
|
this.logger = new logger_1.Logger(`Context Logger`, client.config.log_level);
|
|
67
103
|
// if this is a getGroupKeyRunId, the data is the workflow input
|
|
68
104
|
if (action.getGroupKeyRunId !== '') {
|
|
@@ -164,15 +200,49 @@ class Context {
|
|
|
164
200
|
yield this.client.event.putStream(stepRunId, data);
|
|
165
201
|
});
|
|
166
202
|
}
|
|
167
|
-
|
|
203
|
+
/**
|
|
204
|
+
* Spawns a new workflow.
|
|
205
|
+
*
|
|
206
|
+
* @param workflowName the name of the workflow to spawn
|
|
207
|
+
* @param input the input data for the workflow
|
|
208
|
+
* @param options additional options for spawning the workflow. If a string is provided, it is used as the key.
|
|
209
|
+
* If an object is provided, it can include:
|
|
210
|
+
* - key: a unique identifier for the workflow (deprecated, use options.key instead)
|
|
211
|
+
* - sticky: a boolean indicating whether to use sticky execution
|
|
212
|
+
* @param <Q> the type of the input data
|
|
213
|
+
* @param <P> the type of the output data
|
|
214
|
+
* @return a reference to the spawned workflow run
|
|
215
|
+
*/
|
|
216
|
+
spawnWorkflow(workflow, input, options) {
|
|
168
217
|
const { workflowRunId, stepRunId } = this.action;
|
|
218
|
+
let workflowName = '';
|
|
219
|
+
if (typeof workflow === 'string') {
|
|
220
|
+
workflowName = workflow;
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
workflowName = workflow.id;
|
|
224
|
+
}
|
|
169
225
|
const name = this.client.config.namespace + workflowName;
|
|
226
|
+
let key = '';
|
|
227
|
+
let sticky = false;
|
|
228
|
+
if (typeof options === 'string') {
|
|
229
|
+
this.logger.warn('Using key param is deprecated and will be removed in a future release. Use options.key instead.');
|
|
230
|
+
key = options;
|
|
231
|
+
}
|
|
232
|
+
else {
|
|
233
|
+
key = options === null || options === void 0 ? void 0 : options.key;
|
|
234
|
+
sticky = options === null || options === void 0 ? void 0 : options.sticky;
|
|
235
|
+
}
|
|
236
|
+
if (sticky && !this.worker.hasWorkflow(name)) {
|
|
237
|
+
throw new hatchet_error_1.default(`cannot run with sticky: workflow ${name} is not registered on the worker`);
|
|
238
|
+
}
|
|
170
239
|
try {
|
|
171
240
|
const resp = this.client.admin.runWorkflow(name, input, {
|
|
172
241
|
parentId: workflowRunId,
|
|
173
242
|
parentStepRunId: stepRunId,
|
|
174
243
|
childKey: key,
|
|
175
244
|
childIndex: this.spawnIndex,
|
|
245
|
+
desiredWorkerId: sticky ? this.worker.id() : undefined,
|
|
176
246
|
});
|
|
177
247
|
this.spawnIndex += 1;
|
|
178
248
|
return resp;
|
|
@@ -181,5 +251,22 @@ class Context {
|
|
|
181
251
|
throw new hatchet_error_1.default(e.message);
|
|
182
252
|
}
|
|
183
253
|
}
|
|
254
|
+
additionalMetadata() {
|
|
255
|
+
if (!this.action.additionalMetadata) {
|
|
256
|
+
return {};
|
|
257
|
+
}
|
|
258
|
+
// parse the additional metadata
|
|
259
|
+
const res = (0, parse_1.parseJSON)(this.action.additionalMetadata);
|
|
260
|
+
return res;
|
|
261
|
+
}
|
|
262
|
+
childIndex() {
|
|
263
|
+
return this.action.childWorkflowIndex;
|
|
264
|
+
}
|
|
265
|
+
childKey() {
|
|
266
|
+
return this.action.childWorkflowKey;
|
|
267
|
+
}
|
|
268
|
+
parentWorkflowRunId() {
|
|
269
|
+
return this.action.parentWorkflowRunId;
|
|
270
|
+
}
|
|
184
271
|
}
|
|
185
272
|
exports.Context = Context;
|
|
@@ -2,6 +2,9 @@ import { ListenerClient, StepRunEvent } from '../clients/listener/listener-clien
|
|
|
2
2
|
type EventualWorkflowRunId = string | Promise<string> | Promise<{
|
|
3
3
|
workflowRunId: string;
|
|
4
4
|
}>;
|
|
5
|
+
export declare class DedupeViolationErr extends Error {
|
|
6
|
+
constructor(message: string);
|
|
7
|
+
}
|
|
5
8
|
export default class WorkflowRunRef<T> {
|
|
6
9
|
workflowRunId: EventualWorkflowRunId;
|
|
7
10
|
parentWorkflowRunId?: string;
|
package/util/workflow-run-ref.js
CHANGED
|
@@ -16,18 +16,35 @@ 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
|
+
exports.DedupeViolationErr = void 0;
|
|
20
|
+
const nice_grpc_1 = require("nice-grpc");
|
|
19
21
|
const dispatcher_1 = require("../protoc/dispatcher");
|
|
22
|
+
class DedupeViolationErr extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'DedupeViolationErr';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.DedupeViolationErr = DedupeViolationErr;
|
|
20
29
|
function getWorkflowRunId(workflowRunId) {
|
|
21
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
22
31
|
if (typeof workflowRunId === 'string') {
|
|
23
32
|
return workflowRunId;
|
|
24
33
|
}
|
|
25
34
|
if (workflowRunId instanceof Promise) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
try {
|
|
36
|
+
const resolved = yield workflowRunId;
|
|
37
|
+
if (typeof resolved === 'string') {
|
|
38
|
+
return resolved;
|
|
39
|
+
}
|
|
40
|
+
return resolved.workflowRunId;
|
|
41
|
+
}
|
|
42
|
+
catch (e) {
|
|
43
|
+
if (e.code && e.code === nice_grpc_1.Status.ALREADY_EXISTS) {
|
|
44
|
+
throw new DedupeViolationErr(e.details);
|
|
45
|
+
}
|
|
46
|
+
throw new Error('Invalid workflowRunId');
|
|
29
47
|
}
|
|
30
|
-
return resolved.workflowRunId;
|
|
31
48
|
}
|
|
32
49
|
throw new Error('Invalid workflowRunId');
|
|
33
50
|
});
|
package/workflow.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import { CreateStep } from './step';
|
|
3
|
-
import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy } from './protoc/workflows';
|
|
3
|
+
import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy, StickyStrategy as PbStickyStrategy } from './protoc/workflows';
|
|
4
4
|
declare const StepsSchema: z.ZodArray<z.ZodObject<{
|
|
5
5
|
name: z.ZodString;
|
|
6
6
|
parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
@@ -16,6 +16,22 @@ declare const StepsSchema: z.ZodArray<z.ZodObject<{
|
|
|
16
16
|
key: string;
|
|
17
17
|
units: number;
|
|
18
18
|
}>, "many">>;
|
|
19
|
+
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
20
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
21
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
22
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
comparator: z.ZodOptional<z.ZodNativeEnum<typeof import("./protoc/workflows").WorkerLabelComparator>>;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
value: string | number;
|
|
26
|
+
required?: boolean | undefined;
|
|
27
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
28
|
+
weight?: number | undefined;
|
|
29
|
+
}, {
|
|
30
|
+
value: string | number;
|
|
31
|
+
required?: boolean | undefined;
|
|
32
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
33
|
+
weight?: number | undefined;
|
|
34
|
+
}>]>>>>>;
|
|
19
35
|
}, "strip", z.ZodTypeAny, {
|
|
20
36
|
name: string;
|
|
21
37
|
timeout?: string | undefined;
|
|
@@ -25,6 +41,12 @@ declare const StepsSchema: z.ZodArray<z.ZodObject<{
|
|
|
25
41
|
key: string;
|
|
26
42
|
units: number;
|
|
27
43
|
}[] | undefined;
|
|
44
|
+
worker_labels?: Record<string, string | number | {
|
|
45
|
+
value: string | number;
|
|
46
|
+
required?: boolean | undefined;
|
|
47
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
48
|
+
weight?: number | undefined;
|
|
49
|
+
} | undefined> | undefined;
|
|
28
50
|
}, {
|
|
29
51
|
name: string;
|
|
30
52
|
timeout?: string | undefined;
|
|
@@ -34,6 +56,12 @@ declare const StepsSchema: z.ZodArray<z.ZodObject<{
|
|
|
34
56
|
key: string;
|
|
35
57
|
units: number;
|
|
36
58
|
}[] | undefined;
|
|
59
|
+
worker_labels?: Record<string, string | number | {
|
|
60
|
+
value: string | number;
|
|
61
|
+
required?: boolean | undefined;
|
|
62
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
63
|
+
weight?: number | undefined;
|
|
64
|
+
} | undefined> | undefined;
|
|
37
65
|
}>, "many">;
|
|
38
66
|
export type Steps = z.infer<typeof StepsSchema>;
|
|
39
67
|
export declare const ConcurrencyLimitStrategy: typeof PbConcurrencyLimitStrategy;
|
|
@@ -51,10 +79,15 @@ export declare const WorkflowConcurrency: z.ZodObject<{
|
|
|
51
79
|
limitStrategy?: PbConcurrencyLimitStrategy | undefined;
|
|
52
80
|
}>;
|
|
53
81
|
export declare const HatchetTimeoutSchema: z.ZodString;
|
|
82
|
+
export declare const StickyStrategy: typeof PbStickyStrategy;
|
|
54
83
|
export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
55
84
|
id: z.ZodString;
|
|
56
85
|
description: z.ZodString;
|
|
57
86
|
version: z.ZodOptional<z.ZodString>;
|
|
87
|
+
/**
|
|
88
|
+
* sticky will attempt to run all steps for workflow on the same worker
|
|
89
|
+
*/
|
|
90
|
+
sticky: z.ZodOptional<z.ZodNativeEnum<typeof PbStickyStrategy>>;
|
|
58
91
|
scheduleTimeout: z.ZodOptional<z.ZodString>;
|
|
59
92
|
/**
|
|
60
93
|
* @deprecated Workflow timeout is deprecated. Use step timeouts instead.
|
|
@@ -94,6 +127,22 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
94
127
|
key: string;
|
|
95
128
|
units: number;
|
|
96
129
|
}>, "many">>;
|
|
130
|
+
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
131
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
132
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
133
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
134
|
+
comparator: z.ZodOptional<z.ZodNativeEnum<typeof import("./protoc/workflows").WorkerLabelComparator>>;
|
|
135
|
+
}, "strip", z.ZodTypeAny, {
|
|
136
|
+
value: string | number;
|
|
137
|
+
required?: boolean | undefined;
|
|
138
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
139
|
+
weight?: number | undefined;
|
|
140
|
+
}, {
|
|
141
|
+
value: string | number;
|
|
142
|
+
required?: boolean | undefined;
|
|
143
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
144
|
+
weight?: number | undefined;
|
|
145
|
+
}>]>>>>>;
|
|
97
146
|
}, "strip", z.ZodTypeAny, {
|
|
98
147
|
name: string;
|
|
99
148
|
timeout?: string | undefined;
|
|
@@ -103,6 +152,12 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
103
152
|
key: string;
|
|
104
153
|
units: number;
|
|
105
154
|
}[] | undefined;
|
|
155
|
+
worker_labels?: Record<string, string | number | {
|
|
156
|
+
value: string | number;
|
|
157
|
+
required?: boolean | undefined;
|
|
158
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
159
|
+
weight?: number | undefined;
|
|
160
|
+
} | undefined> | undefined;
|
|
106
161
|
}, {
|
|
107
162
|
name: string;
|
|
108
163
|
timeout?: string | undefined;
|
|
@@ -112,6 +167,12 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
112
167
|
key: string;
|
|
113
168
|
units: number;
|
|
114
169
|
}[] | undefined;
|
|
170
|
+
worker_labels?: Record<string, string | number | {
|
|
171
|
+
value: string | number;
|
|
172
|
+
required?: boolean | undefined;
|
|
173
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
174
|
+
weight?: number | undefined;
|
|
175
|
+
} | undefined> | undefined;
|
|
115
176
|
}>, "many">;
|
|
116
177
|
onFailure: z.ZodOptional<z.ZodObject<{
|
|
117
178
|
name: z.ZodString;
|
|
@@ -128,6 +189,22 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
128
189
|
key: string;
|
|
129
190
|
units: number;
|
|
130
191
|
}>, "many">>;
|
|
192
|
+
worker_labels: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodLazy<z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodObject<{
|
|
193
|
+
value: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
|
|
194
|
+
required: z.ZodOptional<z.ZodBoolean>;
|
|
195
|
+
weight: z.ZodOptional<z.ZodNumber>;
|
|
196
|
+
comparator: z.ZodOptional<z.ZodNativeEnum<typeof import("./protoc/workflows").WorkerLabelComparator>>;
|
|
197
|
+
}, "strip", z.ZodTypeAny, {
|
|
198
|
+
value: string | number;
|
|
199
|
+
required?: boolean | undefined;
|
|
200
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
201
|
+
weight?: number | undefined;
|
|
202
|
+
}, {
|
|
203
|
+
value: string | number;
|
|
204
|
+
required?: boolean | undefined;
|
|
205
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
206
|
+
weight?: number | undefined;
|
|
207
|
+
}>]>>>>>;
|
|
131
208
|
}, "strip", z.ZodTypeAny, {
|
|
132
209
|
name: string;
|
|
133
210
|
timeout?: string | undefined;
|
|
@@ -137,6 +214,12 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
137
214
|
key: string;
|
|
138
215
|
units: number;
|
|
139
216
|
}[] | undefined;
|
|
217
|
+
worker_labels?: Record<string, string | number | {
|
|
218
|
+
value: string | number;
|
|
219
|
+
required?: boolean | undefined;
|
|
220
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
221
|
+
weight?: number | undefined;
|
|
222
|
+
} | undefined> | undefined;
|
|
140
223
|
}, {
|
|
141
224
|
name: string;
|
|
142
225
|
timeout?: string | undefined;
|
|
@@ -146,6 +229,12 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
146
229
|
key: string;
|
|
147
230
|
units: number;
|
|
148
231
|
}[] | undefined;
|
|
232
|
+
worker_labels?: Record<string, string | number | {
|
|
233
|
+
value: string | number;
|
|
234
|
+
required?: boolean | undefined;
|
|
235
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
236
|
+
weight?: number | undefined;
|
|
237
|
+
} | undefined> | undefined;
|
|
149
238
|
}>>;
|
|
150
239
|
}, "strip", z.ZodTypeAny, {
|
|
151
240
|
description: string;
|
|
@@ -158,10 +247,17 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
158
247
|
key: string;
|
|
159
248
|
units: number;
|
|
160
249
|
}[] | undefined;
|
|
250
|
+
worker_labels?: Record<string, string | number | {
|
|
251
|
+
value: string | number;
|
|
252
|
+
required?: boolean | undefined;
|
|
253
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
254
|
+
weight?: number | undefined;
|
|
255
|
+
} | undefined> | undefined;
|
|
161
256
|
}[];
|
|
162
257
|
id: string;
|
|
163
258
|
version?: string | undefined;
|
|
164
259
|
scheduleTimeout?: string | undefined;
|
|
260
|
+
sticky?: PbStickyStrategy | undefined;
|
|
165
261
|
timeout?: string | undefined;
|
|
166
262
|
on?: {
|
|
167
263
|
cron: string;
|
|
@@ -179,6 +275,12 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
179
275
|
key: string;
|
|
180
276
|
units: number;
|
|
181
277
|
}[] | undefined;
|
|
278
|
+
worker_labels?: Record<string, string | number | {
|
|
279
|
+
value: string | number;
|
|
280
|
+
required?: boolean | undefined;
|
|
281
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
282
|
+
weight?: number | undefined;
|
|
283
|
+
} | undefined> | undefined;
|
|
182
284
|
} | undefined;
|
|
183
285
|
}, {
|
|
184
286
|
description: string;
|
|
@@ -191,10 +293,17 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
191
293
|
key: string;
|
|
192
294
|
units: number;
|
|
193
295
|
}[] | undefined;
|
|
296
|
+
worker_labels?: Record<string, string | number | {
|
|
297
|
+
value: string | number;
|
|
298
|
+
required?: boolean | undefined;
|
|
299
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
300
|
+
weight?: number | undefined;
|
|
301
|
+
} | undefined> | undefined;
|
|
194
302
|
}[];
|
|
195
303
|
id: string;
|
|
196
304
|
version?: string | undefined;
|
|
197
305
|
scheduleTimeout?: string | undefined;
|
|
306
|
+
sticky?: PbStickyStrategy | undefined;
|
|
198
307
|
timeout?: string | undefined;
|
|
199
308
|
on?: {
|
|
200
309
|
cron: string;
|
|
@@ -212,6 +321,12 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
|
212
321
|
key: string;
|
|
213
322
|
units: number;
|
|
214
323
|
}[] | undefined;
|
|
324
|
+
worker_labels?: Record<string, string | number | {
|
|
325
|
+
value: string | number;
|
|
326
|
+
required?: boolean | undefined;
|
|
327
|
+
comparator?: import("./protoc/workflows").WorkerLabelComparator | undefined;
|
|
328
|
+
weight?: number | undefined;
|
|
329
|
+
} | undefined> | undefined;
|
|
215
330
|
} | undefined;
|
|
216
331
|
}>;
|
|
217
332
|
export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
|
package/workflow.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.CreateWorkflowSchema = exports.HatchetTimeoutSchema = exports.WorkflowConcurrency = exports.ConcurrencyLimitStrategy = void 0;
|
|
26
|
+
exports.CreateWorkflowSchema = exports.StickyStrategy = exports.HatchetTimeoutSchema = exports.WorkflowConcurrency = exports.ConcurrencyLimitStrategy = void 0;
|
|
27
27
|
const z = __importStar(require("zod"));
|
|
28
28
|
const step_1 = require("./step");
|
|
29
29
|
const workflows_1 = require("./protoc/workflows");
|
|
@@ -44,10 +44,15 @@ exports.WorkflowConcurrency = z.object({
|
|
|
44
44
|
limitStrategy: z.nativeEnum(exports.ConcurrencyLimitStrategy).optional(),
|
|
45
45
|
});
|
|
46
46
|
exports.HatchetTimeoutSchema = z.string();
|
|
47
|
+
exports.StickyStrategy = workflows_1.StickyStrategy;
|
|
47
48
|
exports.CreateWorkflowSchema = z.object({
|
|
48
49
|
id: z.string(),
|
|
49
50
|
description: z.string(),
|
|
50
51
|
version: z.string().optional(),
|
|
52
|
+
/**
|
|
53
|
+
* sticky will attempt to run all steps for workflow on the same worker
|
|
54
|
+
*/
|
|
55
|
+
sticky: z.nativeEnum(exports.StickyStrategy).optional(),
|
|
51
56
|
scheduleTimeout: z.string().optional(),
|
|
52
57
|
/**
|
|
53
58
|
* @deprecated Workflow timeout is deprecated. Use step timeouts instead.
|