@hatchet-dev/typescript-sdk 0.8.1 → 0.10.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 +14 -7
- package/clients/admin/admin-client.js +28 -18
- package/clients/dispatcher/heartbeat/heartbeat-controller.d.ts +0 -1
- package/clients/hatchet-client/hatchet-client.d.ts +1 -0
- package/clients/hatchet-client/hatchet-client.js +7 -1
- package/clients/listener/child-listener-client.d.ts +0 -1
- package/clients/listener/listener-client.d.ts +6 -14
- package/clients/listener/listener-client.js +16 -85
- package/clients/rest/generated/Api.d.ts +76 -102
- package/clients/rest/generated/Api.js +54 -96
- package/clients/rest/generated/data-contracts.d.ts +102 -51
- package/clients/rest/generated/http-client.js +2 -2
- package/clients/worker/handler.d.ts +58 -0
- package/clients/worker/handler.js +200 -0
- package/clients/worker/worker.d.ts +9 -3
- package/clients/worker/worker.js +203 -153
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -2
- package/protoc/dispatcher/dispatcher.js +13 -13
- package/protoc/workflows/workflows.js +5 -5
- package/step.d.ts +11 -13
- package/step.js +13 -70
- package/util/config-loader/token.js +2 -3
- package/util/parse.js +1 -2
- package/util/retrier.js +1 -2
- package/util/thread-helper.d.ts +0 -1
- package/util/thread-helper.js +1 -2
- package/util/workflow-run-ref.d.ts +17 -0
- package/util/workflow-run-ref.js +94 -0
package/clients/worker/worker.js
CHANGED
|
@@ -25,7 +25,7 @@ const dispatcher_1 = require("../../protoc/dispatcher");
|
|
|
25
25
|
const hatchet_promise_1 = __importDefault(require("../../util/hatchet-promise/hatchet-promise"));
|
|
26
26
|
const workflows_1 = require("../../protoc/workflows");
|
|
27
27
|
const logger_1 = require("../../util/logger");
|
|
28
|
-
|
|
28
|
+
const handler_1 = require("./handler");
|
|
29
29
|
const step_1 = require("../../step");
|
|
30
30
|
class Worker {
|
|
31
31
|
constructor(client, options) {
|
|
@@ -42,6 +42,33 @@ class Worker {
|
|
|
42
42
|
this.handle_kill = options.handleKill === undefined ? true : options.handleKill;
|
|
43
43
|
this.logger = new logger_1.Logger(`Worker/${this.name}`, this.client.config.log_level);
|
|
44
44
|
}
|
|
45
|
+
registerActions(workflow) {
|
|
46
|
+
var _a;
|
|
47
|
+
const newActions = workflow.steps.reduce((acc, step) => {
|
|
48
|
+
acc[`${workflow.id}:${step.name}`] = step.run;
|
|
49
|
+
return acc;
|
|
50
|
+
}, {});
|
|
51
|
+
const onFailureAction = workflow.onFailure
|
|
52
|
+
? {
|
|
53
|
+
[`${workflow.id}-on-failure:${workflow.onFailure.name}`]: workflow.onFailure.run,
|
|
54
|
+
}
|
|
55
|
+
: {};
|
|
56
|
+
this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
|
|
57
|
+
this.action_registry = ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name)
|
|
58
|
+
? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
|
|
59
|
+
}
|
|
60
|
+
getHandler(workflows) {
|
|
61
|
+
for (const workflow of workflows) {
|
|
62
|
+
const wf = Object.assign(Object.assign({}, workflow), { id: this.client.config.namespace + workflow.id });
|
|
63
|
+
this.registerActions(wf);
|
|
64
|
+
}
|
|
65
|
+
return new handler_1.WebhookHandler(this, workflows);
|
|
66
|
+
}
|
|
67
|
+
registerWebhook(webhook) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
return this.client.admin.registerWebhook(Object.assign({}, webhook));
|
|
70
|
+
});
|
|
71
|
+
}
|
|
45
72
|
/**
|
|
46
73
|
* @deprecated use registerWorkflow instead
|
|
47
74
|
*/
|
|
@@ -52,7 +79,7 @@ class Worker {
|
|
|
52
79
|
}
|
|
53
80
|
registerWorkflow(initWorkflow) {
|
|
54
81
|
return __awaiter(this, void 0, void 0, function* () {
|
|
55
|
-
var _a, _b
|
|
82
|
+
var _a, _b;
|
|
56
83
|
const workflow = Object.assign(Object.assign({}, initWorkflow), { id: this.client.config.namespace + initWorkflow.id });
|
|
57
84
|
try {
|
|
58
85
|
const concurrency = ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name)
|
|
@@ -118,145 +145,154 @@ class Worker {
|
|
|
118
145
|
catch (e) {
|
|
119
146
|
throw new hatchet_error_1.default(`Could not register workflow: ${e.message}`);
|
|
120
147
|
}
|
|
121
|
-
|
|
122
|
-
acc[`${workflow.id}:${step.name}`] = step.run;
|
|
123
|
-
return acc;
|
|
124
|
-
}, {});
|
|
125
|
-
const onFailureAction = workflow.onFailure
|
|
126
|
-
? {
|
|
127
|
-
[`${workflow.id}-on-failure:${workflow.onFailure.name}`]: workflow.onFailure.run,
|
|
128
|
-
}
|
|
129
|
-
: {};
|
|
130
|
-
this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
|
|
131
|
-
this.action_registry = ((_c = workflow.concurrency) === null || _c === void 0 ? void 0 : _c.name)
|
|
132
|
-
? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
|
|
148
|
+
this.registerActions(workflow);
|
|
133
149
|
});
|
|
134
150
|
}
|
|
135
151
|
registerAction(actionId, action) {
|
|
136
152
|
this.action_registry[actionId] = action;
|
|
137
153
|
}
|
|
138
154
|
handleStartStepRun(action) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
this.
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
const { actionId } = action;
|
|
157
|
+
try {
|
|
158
|
+
const context = new step_1.Context(action, this.client);
|
|
159
|
+
this.contexts[action.stepRunId] = context;
|
|
160
|
+
const step = this.action_registry[actionId];
|
|
161
|
+
if (!step) {
|
|
162
|
+
this.logger.error(`Could not find step '${actionId}'`);
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
const run = () => __awaiter(this, void 0, void 0, function* () {
|
|
166
|
+
return step(context);
|
|
167
|
+
});
|
|
168
|
+
const success = (result) => __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
this.logger.info(`Step run ${action.stepRunId} succeeded`);
|
|
170
|
+
try {
|
|
171
|
+
// Send the action event to the dispatcher
|
|
172
|
+
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result || null);
|
|
173
|
+
yield this.client.dispatcher.sendStepActionEvent(event);
|
|
174
|
+
// delete the run from the futures
|
|
175
|
+
delete this.futures[action.stepRunId];
|
|
176
|
+
}
|
|
177
|
+
catch (actionEventError) {
|
|
178
|
+
this.logger.error(`Could not send completed action event: ${actionEventError.message}`);
|
|
158
179
|
// send a failure event
|
|
159
|
-
const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED,
|
|
160
|
-
|
|
161
|
-
this.
|
|
180
|
+
const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, actionEventError.message);
|
|
181
|
+
try {
|
|
182
|
+
yield this.client.dispatcher.sendStepActionEvent(failureEvent);
|
|
183
|
+
}
|
|
184
|
+
catch (failureEventError) {
|
|
185
|
+
this.logger.error(`Could not send failed action event: ${failureEventError.message}`);
|
|
186
|
+
}
|
|
187
|
+
this.logger.error(`Could not send action event: ${actionEventError.message}`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
const failure = (error) => __awaiter(this, void 0, void 0, function* () {
|
|
191
|
+
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
192
|
+
if (error.stack) {
|
|
193
|
+
this.logger.error(error.stack);
|
|
194
|
+
}
|
|
195
|
+
try {
|
|
196
|
+
// Send the action event to the dispatcher
|
|
197
|
+
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, {
|
|
198
|
+
message: error === null || error === void 0 ? void 0 : error.message,
|
|
199
|
+
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
162
200
|
});
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
169
|
-
}
|
|
170
|
-
};
|
|
171
|
-
const failure = (error) => {
|
|
172
|
-
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
173
|
-
if (error.stack) {
|
|
174
|
-
this.logger.error(error.stack);
|
|
175
|
-
}
|
|
176
|
-
try {
|
|
177
|
-
// Send the action event to the dispatcher
|
|
178
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, {
|
|
179
|
-
message: error === null || error === void 0 ? void 0 : error.message,
|
|
180
|
-
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
181
|
-
});
|
|
182
|
-
this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
|
|
201
|
+
yield this.client.dispatcher.sendStepActionEvent(event);
|
|
202
|
+
// delete the run from the futures
|
|
203
|
+
delete this.futures[action.stepRunId];
|
|
204
|
+
}
|
|
205
|
+
catch (e) {
|
|
183
206
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
207
|
+
}
|
|
208
|
+
});
|
|
209
|
+
const future = new hatchet_promise_1.default((() => __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
let result;
|
|
211
|
+
try {
|
|
212
|
+
result = yield run();
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
yield failure(e);
|
|
216
|
+
return;
|
|
217
|
+
}
|
|
218
|
+
yield success(result);
|
|
219
|
+
}))());
|
|
220
|
+
this.futures[action.stepRunId] = future;
|
|
221
|
+
// Send the action event to the dispatcher
|
|
222
|
+
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
|
|
223
|
+
this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
|
|
189
224
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
// Send the action event to the dispatcher
|
|
195
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
|
|
196
|
-
this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
|
|
225
|
+
});
|
|
226
|
+
yield future.promise;
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
197
229
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
catch (e) {
|
|
201
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
202
|
-
}
|
|
230
|
+
}
|
|
231
|
+
});
|
|
203
232
|
}
|
|
204
233
|
handleStartGroupKeyRun(action) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
this.logger.error(`Could not find step '${actionId}'`);
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
const run = () => __awaiter(this, void 0, void 0, function* () {
|
|
217
|
-
return step(context);
|
|
218
|
-
});
|
|
219
|
-
const success = (result) => {
|
|
220
|
-
this.logger.info(`Step run ${action.stepRunId} succeeded`);
|
|
221
|
-
try {
|
|
222
|
-
// Send the action event to the dispatcher
|
|
223
|
-
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
|
|
224
|
-
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
225
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
226
|
-
});
|
|
227
|
-
// delete the run from the futures
|
|
228
|
-
delete this.futures[key];
|
|
234
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
235
|
+
const { actionId } = action;
|
|
236
|
+
try {
|
|
237
|
+
const context = new step_1.Context(action, this.client);
|
|
238
|
+
const key = action.getGroupKeyRunId;
|
|
239
|
+
if (!key) {
|
|
240
|
+
this.logger.error(`No group key run id provided for action ${actionId}`);
|
|
241
|
+
return;
|
|
229
242
|
}
|
|
230
|
-
|
|
231
|
-
|
|
243
|
+
this.contexts[key] = context;
|
|
244
|
+
this.logger.debug(`Starting group key run ${key}`);
|
|
245
|
+
const step = this.action_registry[actionId];
|
|
246
|
+
if (!step) {
|
|
247
|
+
this.logger.error(`Could not find step '${actionId}'`);
|
|
248
|
+
return;
|
|
232
249
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
250
|
+
const run = () => __awaiter(this, void 0, void 0, function* () {
|
|
251
|
+
return step(context);
|
|
252
|
+
});
|
|
253
|
+
const success = (result) => {
|
|
254
|
+
this.logger.info(`Step run ${action.stepRunId} succeeded`);
|
|
255
|
+
try {
|
|
256
|
+
// Send the action event to the dispatcher
|
|
257
|
+
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
|
|
258
|
+
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
259
|
+
this.logger.error(`Could not send action event: ${e.message}`);
|
|
260
|
+
});
|
|
261
|
+
// delete the run from the futures
|
|
262
|
+
delete this.futures[key];
|
|
263
|
+
}
|
|
264
|
+
catch (e) {
|
|
240
265
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
266
|
+
}
|
|
267
|
+
};
|
|
268
|
+
const failure = (error) => {
|
|
269
|
+
this.logger.error(`Step run ${key} failed: ${error.message}`);
|
|
270
|
+
try {
|
|
271
|
+
// Send the action event to the dispatcher
|
|
272
|
+
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
|
|
273
|
+
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
274
|
+
this.logger.error(`Could not send action event: ${e.message}`);
|
|
275
|
+
});
|
|
276
|
+
// delete the run from the futures
|
|
277
|
+
delete this.futures[key];
|
|
278
|
+
}
|
|
279
|
+
catch (e) {
|
|
280
|
+
this.logger.error(`Could not send action event: ${e.message}`);
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
const future = new hatchet_promise_1.default(run().then(success).catch(failure));
|
|
284
|
+
this.futures[key] = future;
|
|
285
|
+
// Send the action event to the dispatcher
|
|
286
|
+
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_STARTED);
|
|
287
|
+
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
246
288
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// Send the action event to the dispatcher
|
|
252
|
-
const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_STARTED);
|
|
253
|
-
this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
|
|
289
|
+
});
|
|
290
|
+
yield future.promise;
|
|
291
|
+
}
|
|
292
|
+
catch (e) {
|
|
254
293
|
this.logger.error(`Could not send action event: ${e.message}`);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
catch (e) {
|
|
258
|
-
this.logger.error(`Could not send action event: ${e.message}`);
|
|
259
|
-
}
|
|
294
|
+
}
|
|
295
|
+
});
|
|
260
296
|
}
|
|
261
297
|
getStepActionEvent(action, eventType, payload = '') {
|
|
262
298
|
return {
|
|
@@ -272,6 +308,9 @@ class Worker {
|
|
|
272
308
|
};
|
|
273
309
|
}
|
|
274
310
|
getGroupKeyActionEvent(action, eventType, payload = '') {
|
|
311
|
+
if (!action.getGroupKeyRunId) {
|
|
312
|
+
throw new hatchet_error_1.default('No group key run id provided');
|
|
313
|
+
}
|
|
275
314
|
return {
|
|
276
315
|
workerId: this.name,
|
|
277
316
|
workflowRunId: action.workflowRunId,
|
|
@@ -283,26 +322,29 @@ class Worker {
|
|
|
283
322
|
};
|
|
284
323
|
}
|
|
285
324
|
handleCancelStepRun(action) {
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
context.controller
|
|
293
|
-
|
|
325
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
326
|
+
try {
|
|
327
|
+
this.logger.info(`Cancelling step run ${action.stepRunId}`);
|
|
328
|
+
const { stepRunId } = action;
|
|
329
|
+
const future = this.futures[stepRunId];
|
|
330
|
+
const context = this.contexts[stepRunId];
|
|
331
|
+
if (context && context.controller) {
|
|
332
|
+
context.controller.abort('Cancelled by worker');
|
|
333
|
+
delete this.contexts[stepRunId];
|
|
334
|
+
}
|
|
335
|
+
if (future) {
|
|
336
|
+
future.promise.catch(() => {
|
|
337
|
+
this.logger.info(`Cancelled step run ${action.stepRunId}`);
|
|
338
|
+
});
|
|
339
|
+
future.cancel('Cancelled by worker');
|
|
340
|
+
yield future.promise;
|
|
341
|
+
delete this.futures[stepRunId];
|
|
342
|
+
}
|
|
294
343
|
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
this.logger.info(`Cancelled step run ${action.stepRunId}`);
|
|
298
|
-
});
|
|
299
|
-
future.cancel('Cancelled by worker');
|
|
300
|
-
delete this.futures[stepRunId];
|
|
344
|
+
catch (e) {
|
|
345
|
+
this.logger.error(`Could not cancel step run: ${e.message}`);
|
|
301
346
|
}
|
|
302
|
-
}
|
|
303
|
-
catch (e) {
|
|
304
|
-
this.logger.error(`Could not cancel step run: ${e.message}`);
|
|
305
|
-
}
|
|
347
|
+
});
|
|
306
348
|
}
|
|
307
349
|
stop() {
|
|
308
350
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -350,18 +392,7 @@ class Worker {
|
|
|
350
392
|
_d = false;
|
|
351
393
|
const action = _c;
|
|
352
394
|
this.logger.info(`Worker ${this.name} received action ${action.actionId}:${action.actionType}`);
|
|
353
|
-
|
|
354
|
-
this.handleStartStepRun(action);
|
|
355
|
-
}
|
|
356
|
-
else if (action.actionType === dispatcher_1.ActionType.CANCEL_STEP_RUN) {
|
|
357
|
-
this.handleCancelStepRun(action);
|
|
358
|
-
}
|
|
359
|
-
else if (action.actionType === dispatcher_1.ActionType.START_GET_GROUP_KEY) {
|
|
360
|
-
this.handleStartGroupKeyRun(action);
|
|
361
|
-
}
|
|
362
|
-
else {
|
|
363
|
-
this.logger.error(`Worker ${this.name} received unknown action type ${action.actionType}`);
|
|
364
|
-
}
|
|
395
|
+
void this.handleAction(action);
|
|
365
396
|
}
|
|
366
397
|
}
|
|
367
398
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
@@ -383,5 +414,24 @@ class Worker {
|
|
|
383
414
|
}
|
|
384
415
|
});
|
|
385
416
|
}
|
|
417
|
+
handleAction(action) {
|
|
418
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
419
|
+
const type = action.actionType
|
|
420
|
+
? (0, dispatcher_1.actionTypeFromJSON)(action.actionType)
|
|
421
|
+
: dispatcher_1.ActionType.START_STEP_RUN;
|
|
422
|
+
if (type === dispatcher_1.ActionType.START_STEP_RUN) {
|
|
423
|
+
yield this.handleStartStepRun(action);
|
|
424
|
+
}
|
|
425
|
+
else if (type === dispatcher_1.ActionType.CANCEL_STEP_RUN) {
|
|
426
|
+
yield this.handleCancelStepRun(action);
|
|
427
|
+
}
|
|
428
|
+
else if (type === dispatcher_1.ActionType.START_GET_GROUP_KEY) {
|
|
429
|
+
yield this.handleStartGroupKeyRun(action);
|
|
430
|
+
}
|
|
431
|
+
else {
|
|
432
|
+
this.logger.error(`Worker ${this.name} received unknown action type ${type}`);
|
|
433
|
+
}
|
|
434
|
+
});
|
|
435
|
+
}
|
|
386
436
|
}
|
|
387
437
|
exports.Worker = Worker;
|
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -20,4 +20,5 @@ __exportStar(require("./step"), exports);
|
|
|
20
20
|
__exportStar(require("./clients/worker"), exports);
|
|
21
21
|
__exportStar(require("./clients/rest"), exports);
|
|
22
22
|
__exportStar(require("./clients/admin"), exports);
|
|
23
|
+
__exportStar(require("./util/workflow-run-ref"), exports);
|
|
23
24
|
exports.default = hatchet_client_1.HatchetClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
"ts-jest": "^29.1.1",
|
|
85
85
|
"ts-node": "^10.9.2",
|
|
86
86
|
"ts-proto": "^1.167.0",
|
|
87
|
-
"typedoc": "^0.
|
|
87
|
+
"typedoc": "^0.26.2",
|
|
88
88
|
"typedoc-plugin-markdown": "^4.0.2",
|
|
89
89
|
"typescript": "^5.3.3"
|
|
90
90
|
},
|
|
@@ -28,7 +28,19 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
return result;
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.DispatcherDefinition = exports.ReleaseSlotResponse = exports.ReleaseSlotRequest = exports.RefreshTimeoutResponse = exports.RefreshTimeoutRequest = exports.HeartbeatResponse = exports.HeartbeatRequest = exports.OverridesDataResponse = exports.OverridesData = exports.StepRunResult = exports.WorkflowRunEvent = exports.WorkflowEvent = exports.SubscribeToWorkflowRunsRequest = exports.SubscribeToWorkflowEventsRequest = exports.ActionEventResponse = exports.StepActionEvent = exports.GroupKeyActionEvent = exports.WorkerUnsubscribeResponse = exports.WorkerUnsubscribeRequest = exports.WorkerListenRequest = exports.AssignedAction = exports.WorkerRegisterResponse = exports.WorkerRegisterRequest = exports.
|
|
31
|
+
exports.DispatcherDefinition = exports.ReleaseSlotResponse = exports.ReleaseSlotRequest = exports.RefreshTimeoutResponse = exports.RefreshTimeoutRequest = exports.HeartbeatResponse = exports.HeartbeatRequest = exports.OverridesDataResponse = exports.OverridesData = exports.StepRunResult = exports.WorkflowRunEvent = exports.WorkflowEvent = exports.SubscribeToWorkflowRunsRequest = exports.SubscribeToWorkflowEventsRequest = exports.ActionEventResponse = exports.StepActionEvent = exports.GroupKeyActionEvent = exports.WorkerUnsubscribeResponse = exports.WorkerUnsubscribeRequest = exports.WorkerListenRequest = exports.AssignedAction = exports.WorkerRegisterResponse = exports.WorkerRegisterRequest = exports.WorkflowRunEventType = exports.ResourceEventType = exports.ResourceType = exports.StepActionEventType = exports.GroupKeyActionEventType = exports.ActionType = exports.protobufPackage = void 0;
|
|
32
|
+
exports.actionTypeFromJSON = actionTypeFromJSON;
|
|
33
|
+
exports.actionTypeToJSON = actionTypeToJSON;
|
|
34
|
+
exports.groupKeyActionEventTypeFromJSON = groupKeyActionEventTypeFromJSON;
|
|
35
|
+
exports.groupKeyActionEventTypeToJSON = groupKeyActionEventTypeToJSON;
|
|
36
|
+
exports.stepActionEventTypeFromJSON = stepActionEventTypeFromJSON;
|
|
37
|
+
exports.stepActionEventTypeToJSON = stepActionEventTypeToJSON;
|
|
38
|
+
exports.resourceTypeFromJSON = resourceTypeFromJSON;
|
|
39
|
+
exports.resourceTypeToJSON = resourceTypeToJSON;
|
|
40
|
+
exports.resourceEventTypeFromJSON = resourceEventTypeFromJSON;
|
|
41
|
+
exports.resourceEventTypeToJSON = resourceEventTypeToJSON;
|
|
42
|
+
exports.workflowRunEventTypeFromJSON = workflowRunEventTypeFromJSON;
|
|
43
|
+
exports.workflowRunEventTypeToJSON = workflowRunEventTypeToJSON;
|
|
32
44
|
const _m0 = __importStar(require("protobufjs/minimal"));
|
|
33
45
|
const timestamp_1 = require("../google/protobuf/timestamp");
|
|
34
46
|
exports.protobufPackage = '';
|
|
@@ -56,7 +68,6 @@ function actionTypeFromJSON(object) {
|
|
|
56
68
|
return ActionType.UNRECOGNIZED;
|
|
57
69
|
}
|
|
58
70
|
}
|
|
59
|
-
exports.actionTypeFromJSON = actionTypeFromJSON;
|
|
60
71
|
function actionTypeToJSON(object) {
|
|
61
72
|
switch (object) {
|
|
62
73
|
case ActionType.START_STEP_RUN:
|
|
@@ -70,7 +81,6 @@ function actionTypeToJSON(object) {
|
|
|
70
81
|
return 'UNRECOGNIZED';
|
|
71
82
|
}
|
|
72
83
|
}
|
|
73
|
-
exports.actionTypeToJSON = actionTypeToJSON;
|
|
74
84
|
var GroupKeyActionEventType;
|
|
75
85
|
(function (GroupKeyActionEventType) {
|
|
76
86
|
GroupKeyActionEventType[GroupKeyActionEventType["GROUP_KEY_EVENT_TYPE_UNKNOWN"] = 0] = "GROUP_KEY_EVENT_TYPE_UNKNOWN";
|
|
@@ -99,7 +109,6 @@ function groupKeyActionEventTypeFromJSON(object) {
|
|
|
99
109
|
return GroupKeyActionEventType.UNRECOGNIZED;
|
|
100
110
|
}
|
|
101
111
|
}
|
|
102
|
-
exports.groupKeyActionEventTypeFromJSON = groupKeyActionEventTypeFromJSON;
|
|
103
112
|
function groupKeyActionEventTypeToJSON(object) {
|
|
104
113
|
switch (object) {
|
|
105
114
|
case GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_UNKNOWN:
|
|
@@ -115,7 +124,6 @@ function groupKeyActionEventTypeToJSON(object) {
|
|
|
115
124
|
return 'UNRECOGNIZED';
|
|
116
125
|
}
|
|
117
126
|
}
|
|
118
|
-
exports.groupKeyActionEventTypeToJSON = groupKeyActionEventTypeToJSON;
|
|
119
127
|
var StepActionEventType;
|
|
120
128
|
(function (StepActionEventType) {
|
|
121
129
|
StepActionEventType[StepActionEventType["STEP_EVENT_TYPE_UNKNOWN"] = 0] = "STEP_EVENT_TYPE_UNKNOWN";
|
|
@@ -144,7 +152,6 @@ function stepActionEventTypeFromJSON(object) {
|
|
|
144
152
|
return StepActionEventType.UNRECOGNIZED;
|
|
145
153
|
}
|
|
146
154
|
}
|
|
147
|
-
exports.stepActionEventTypeFromJSON = stepActionEventTypeFromJSON;
|
|
148
155
|
function stepActionEventTypeToJSON(object) {
|
|
149
156
|
switch (object) {
|
|
150
157
|
case StepActionEventType.STEP_EVENT_TYPE_UNKNOWN:
|
|
@@ -160,7 +167,6 @@ function stepActionEventTypeToJSON(object) {
|
|
|
160
167
|
return 'UNRECOGNIZED';
|
|
161
168
|
}
|
|
162
169
|
}
|
|
163
|
-
exports.stepActionEventTypeToJSON = stepActionEventTypeToJSON;
|
|
164
170
|
var ResourceType;
|
|
165
171
|
(function (ResourceType) {
|
|
166
172
|
ResourceType[ResourceType["RESOURCE_TYPE_UNKNOWN"] = 0] = "RESOURCE_TYPE_UNKNOWN";
|
|
@@ -185,7 +191,6 @@ function resourceTypeFromJSON(object) {
|
|
|
185
191
|
return ResourceType.UNRECOGNIZED;
|
|
186
192
|
}
|
|
187
193
|
}
|
|
188
|
-
exports.resourceTypeFromJSON = resourceTypeFromJSON;
|
|
189
194
|
function resourceTypeToJSON(object) {
|
|
190
195
|
switch (object) {
|
|
191
196
|
case ResourceType.RESOURCE_TYPE_UNKNOWN:
|
|
@@ -199,7 +204,6 @@ function resourceTypeToJSON(object) {
|
|
|
199
204
|
return 'UNRECOGNIZED';
|
|
200
205
|
}
|
|
201
206
|
}
|
|
202
|
-
exports.resourceTypeToJSON = resourceTypeToJSON;
|
|
203
207
|
var ResourceEventType;
|
|
204
208
|
(function (ResourceEventType) {
|
|
205
209
|
ResourceEventType[ResourceEventType["RESOURCE_EVENT_TYPE_UNKNOWN"] = 0] = "RESOURCE_EVENT_TYPE_UNKNOWN";
|
|
@@ -240,7 +244,6 @@ function resourceEventTypeFromJSON(object) {
|
|
|
240
244
|
return ResourceEventType.UNRECOGNIZED;
|
|
241
245
|
}
|
|
242
246
|
}
|
|
243
|
-
exports.resourceEventTypeFromJSON = resourceEventTypeFromJSON;
|
|
244
247
|
function resourceEventTypeToJSON(object) {
|
|
245
248
|
switch (object) {
|
|
246
249
|
case ResourceEventType.RESOURCE_EVENT_TYPE_UNKNOWN:
|
|
@@ -262,7 +265,6 @@ function resourceEventTypeToJSON(object) {
|
|
|
262
265
|
return 'UNRECOGNIZED';
|
|
263
266
|
}
|
|
264
267
|
}
|
|
265
|
-
exports.resourceEventTypeToJSON = resourceEventTypeToJSON;
|
|
266
268
|
var WorkflowRunEventType;
|
|
267
269
|
(function (WorkflowRunEventType) {
|
|
268
270
|
WorkflowRunEventType[WorkflowRunEventType["WORKFLOW_RUN_EVENT_TYPE_FINISHED"] = 0] = "WORKFLOW_RUN_EVENT_TYPE_FINISHED";
|
|
@@ -279,7 +281,6 @@ function workflowRunEventTypeFromJSON(object) {
|
|
|
279
281
|
return WorkflowRunEventType.UNRECOGNIZED;
|
|
280
282
|
}
|
|
281
283
|
}
|
|
282
|
-
exports.workflowRunEventTypeFromJSON = workflowRunEventTypeFromJSON;
|
|
283
284
|
function workflowRunEventTypeToJSON(object) {
|
|
284
285
|
switch (object) {
|
|
285
286
|
case WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED:
|
|
@@ -289,7 +290,6 @@ function workflowRunEventTypeToJSON(object) {
|
|
|
289
290
|
return 'UNRECOGNIZED';
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
|
-
exports.workflowRunEventTypeToJSON = workflowRunEventTypeToJSON;
|
|
293
293
|
function createBaseWorkerRegisterRequest() {
|
|
294
294
|
return { workerName: '', actions: [], services: [], maxRuns: undefined };
|
|
295
295
|
}
|
|
@@ -28,7 +28,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
28
28
|
return result;
|
|
29
29
|
};
|
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
31
|
-
exports.WorkflowServiceDefinition = exports.PutRateLimitResponse = exports.PutRateLimitRequest = exports.TriggerWorkflowResponse = exports.TriggerWorkflowRequest = exports.WorkflowTriggerCronRef = exports.WorkflowTriggerEventRef = exports.WorkflowVersion = exports.ScheduleWorkflowRequest = exports.ListWorkflowsRequest = exports.CreateStepRateLimit = exports.CreateWorkflowStepOpts = exports.CreateWorkflowJobOpts = exports.WorkflowConcurrencyOpts = exports.CreateWorkflowVersionOpts = exports.PutWorkflowRequest = exports.
|
|
31
|
+
exports.WorkflowServiceDefinition = exports.PutRateLimitResponse = exports.PutRateLimitRequest = exports.TriggerWorkflowResponse = exports.TriggerWorkflowRequest = exports.WorkflowTriggerCronRef = exports.WorkflowTriggerEventRef = exports.WorkflowVersion = exports.ScheduleWorkflowRequest = exports.ListWorkflowsRequest = exports.CreateStepRateLimit = exports.CreateWorkflowStepOpts = exports.CreateWorkflowJobOpts = exports.WorkflowConcurrencyOpts = exports.CreateWorkflowVersionOpts = exports.PutWorkflowRequest = exports.RateLimitDuration = exports.ConcurrencyLimitStrategy = exports.protobufPackage = void 0;
|
|
32
|
+
exports.concurrencyLimitStrategyFromJSON = concurrencyLimitStrategyFromJSON;
|
|
33
|
+
exports.concurrencyLimitStrategyToJSON = concurrencyLimitStrategyToJSON;
|
|
34
|
+
exports.rateLimitDurationFromJSON = rateLimitDurationFromJSON;
|
|
35
|
+
exports.rateLimitDurationToJSON = rateLimitDurationToJSON;
|
|
32
36
|
const _m0 = __importStar(require("protobufjs/minimal"));
|
|
33
37
|
const timestamp_1 = require("../google/protobuf/timestamp");
|
|
34
38
|
exports.protobufPackage = '';
|
|
@@ -60,7 +64,6 @@ function concurrencyLimitStrategyFromJSON(object) {
|
|
|
60
64
|
return ConcurrencyLimitStrategy.UNRECOGNIZED;
|
|
61
65
|
}
|
|
62
66
|
}
|
|
63
|
-
exports.concurrencyLimitStrategyFromJSON = concurrencyLimitStrategyFromJSON;
|
|
64
67
|
function concurrencyLimitStrategyToJSON(object) {
|
|
65
68
|
switch (object) {
|
|
66
69
|
case ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS:
|
|
@@ -76,7 +79,6 @@ function concurrencyLimitStrategyToJSON(object) {
|
|
|
76
79
|
return 'UNRECOGNIZED';
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
|
-
exports.concurrencyLimitStrategyToJSON = concurrencyLimitStrategyToJSON;
|
|
80
82
|
var RateLimitDuration;
|
|
81
83
|
(function (RateLimitDuration) {
|
|
82
84
|
RateLimitDuration[RateLimitDuration["SECOND"] = 0] = "SECOND";
|
|
@@ -117,7 +119,6 @@ function rateLimitDurationFromJSON(object) {
|
|
|
117
119
|
return RateLimitDuration.UNRECOGNIZED;
|
|
118
120
|
}
|
|
119
121
|
}
|
|
120
|
-
exports.rateLimitDurationFromJSON = rateLimitDurationFromJSON;
|
|
121
122
|
function rateLimitDurationToJSON(object) {
|
|
122
123
|
switch (object) {
|
|
123
124
|
case RateLimitDuration.SECOND:
|
|
@@ -139,7 +140,6 @@ function rateLimitDurationToJSON(object) {
|
|
|
139
140
|
return 'UNRECOGNIZED';
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
exports.rateLimitDurationToJSON = rateLimitDurationToJSON;
|
|
143
143
|
function createBasePutWorkflowRequest() {
|
|
144
144
|
return { opts: undefined };
|
|
145
145
|
}
|