@hatchet-dev/typescript-sdk 0.8.0-alpha.2 → 0.8.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.
@@ -25,14 +25,13 @@ 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
- const handler_1 = require("./handler");
28
+ // import sleep from '../../util/sleep.js';
29
29
  const step_1 = require("../../step");
30
30
  class Worker {
31
31
  constructor(client, options) {
32
32
  this.futures = {};
33
33
  this.contexts = {};
34
34
  this.registeredWorkflowPromises = [];
35
- this.registeredWorkflowIds = [];
36
35
  this.client = client;
37
36
  this.name = this.client.config.namespace + options.name;
38
37
  this.action_registry = {};
@@ -43,40 +42,17 @@ class Worker {
43
42
  this.handle_kill = options.handleKill === undefined ? true : options.handleKill;
44
43
  this.logger = new logger_1.Logger(`Worker/${this.name}`, this.client.config.log_level);
45
44
  }
46
- registerActions(workflow) {
47
- var _a;
48
- const newActions = workflow.steps.reduce((acc, step) => {
49
- acc[`${workflow.id}:${step.name}`] = step.run;
50
- return acc;
51
- }, {});
52
- const onFailureAction = workflow.onFailure
53
- ? {
54
- [`${workflow.id}-on-failure:${workflow.onFailure.name}`]: workflow.onFailure.run,
55
- }
56
- : {};
57
- this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
58
- this.action_registry = ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name)
59
- ? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
60
- }
61
- getHandler(workflow) {
62
- const wf = Object.assign(Object.assign({}, workflow), { id: this.client.config.namespace + workflow.id });
63
- this.registerActions(wf);
64
- return new handler_1.WebhookHandler(this);
65
- }
66
- registerWebhook(webhook) {
45
+ /**
46
+ * @deprecated use registerWorkflow instead
47
+ */
48
+ register_workflow(initWorkflow) {
67
49
  return __awaiter(this, void 0, void 0, function* () {
68
- return this.client.admin.webhook_create(Object.assign(Object.assign({}, webhook), { workflows: this.registeredWorkflowIds }));
50
+ return this.registerWorkflow(initWorkflow);
69
51
  });
70
52
  }
71
- // @deprecated
72
53
  registerWorkflow(initWorkflow) {
73
54
  return __awaiter(this, void 0, void 0, function* () {
74
- return this.register_workflow(initWorkflow);
75
- });
76
- }
77
- register_workflow(initWorkflow) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- var _a, _b;
55
+ var _a, _b, _c;
80
56
  const workflow = Object.assign(Object.assign({}, initWorkflow), { id: this.client.config.namespace + initWorkflow.id });
81
57
  try {
82
58
  const concurrency = ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name)
@@ -104,13 +80,14 @@ class Worker {
104
80
  ],
105
81
  }
106
82
  : undefined;
107
- this.registeredWorkflowIds.push(workflow.id);
108
- const registeredWorkflow = this.client.admin.put_workflow({
83
+ const registeredWorkflow = this.client.admin.putWorkflow({
109
84
  name: workflow.id,
110
85
  description: workflow.description,
111
86
  version: workflow.version || '',
112
- eventTriggers: workflow.on.event ? [this.client.config.namespace + workflow.on.event] : [],
113
- cronTriggers: workflow.on.cron ? [workflow.on.cron] : [],
87
+ eventTriggers: workflow.on && workflow.on.event
88
+ ? [this.client.config.namespace + workflow.on.event]
89
+ : [],
90
+ cronTriggers: workflow.on && workflow.on.cron ? [workflow.on.cron] : [],
114
91
  scheduledTriggers: [],
115
92
  concurrency,
116
93
  scheduleTimeout: workflow.scheduleTimeout,
@@ -141,154 +118,145 @@ class Worker {
141
118
  catch (e) {
142
119
  throw new hatchet_error_1.default(`Could not register workflow: ${e.message}`);
143
120
  }
144
- this.registerActions(workflow);
121
+ const newActions = workflow.steps.reduce((acc, step) => {
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);
145
133
  });
146
134
  }
147
135
  registerAction(actionId, action) {
148
136
  this.action_registry[actionId] = action;
149
137
  }
150
138
  handleStartStepRun(action) {
151
- return __awaiter(this, void 0, void 0, function* () {
152
- const { actionId } = action;
153
- try {
154
- const context = new step_1.Context(action, this.client);
155
- this.contexts[action.stepRunId] = context;
156
- const step = this.action_registry[actionId];
157
- if (!step) {
158
- this.logger.error(`Could not find step '${actionId}'`);
159
- return;
160
- }
161
- const run = () => __awaiter(this, void 0, void 0, function* () {
162
- return step(context);
163
- });
164
- const success = (result) => __awaiter(this, void 0, void 0, function* () {
165
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
166
- try {
167
- // Send the action event to the dispatcher
168
- const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result || null);
169
- yield this.client.dispatcher.sendStepActionEvent(event);
170
- // delete the run from the futures
171
- delete this.futures[action.stepRunId];
172
- }
173
- catch (actionEventError) {
174
- this.logger.error(`Could not send completed action event: ${actionEventError.message}`);
139
+ const { actionId } = action;
140
+ try {
141
+ const context = new step_1.Context(action, this.client);
142
+ this.contexts[action.stepRunId] = context;
143
+ const step = this.action_registry[actionId];
144
+ if (!step) {
145
+ this.logger.error(`Could not find step '${actionId}'`);
146
+ return;
147
+ }
148
+ const run = () => __awaiter(this, void 0, void 0, function* () {
149
+ return step(context);
150
+ });
151
+ const success = (result) => {
152
+ this.logger.info(`Step run ${action.stepRunId} succeeded`);
153
+ try {
154
+ // Send the action event to the dispatcher
155
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result || null);
156
+ this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
157
+ this.logger.error(`Could not send completed action event: ${e.message}`);
175
158
  // send a failure event
176
- const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, actionEventError.message);
177
- try {
178
- yield this.client.dispatcher.sendStepActionEvent(failureEvent);
179
- }
180
- catch (failureEventError) {
181
- this.logger.error(`Could not send failed action event: ${failureEventError.message}`);
182
- }
183
- this.logger.error(`Could not send action event: ${actionEventError.message}`);
184
- }
185
- });
186
- const failure = (error) => __awaiter(this, void 0, void 0, function* () {
187
- this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
188
- if (error.stack) {
189
- this.logger.error(error.stack);
190
- }
191
- try {
192
- // Send the action event to the dispatcher
193
- const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, {
194
- message: error === null || error === void 0 ? void 0 : error.message,
195
- stack: error === null || error === void 0 ? void 0 : error.stack,
159
+ const failureEvent = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, e.message);
160
+ this.client.dispatcher.sendStepActionEvent(failureEvent).catch((err2) => {
161
+ this.logger.error(`Could not send failed action event: ${err2.message}`);
196
162
  });
197
- yield this.client.dispatcher.sendStepActionEvent(event);
198
- // delete the run from the futures
199
- delete this.futures[action.stepRunId];
200
- }
201
- catch (e) {
163
+ });
164
+ // delete the run from the futures
165
+ delete this.futures[action.stepRunId];
166
+ }
167
+ catch (e) {
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) => {
202
183
  this.logger.error(`Could not send action event: ${e.message}`);
203
- }
204
- });
205
- const future = new hatchet_promise_1.default((() => __awaiter(this, void 0, void 0, function* () {
206
- let result;
207
- try {
208
- result = yield run();
209
- }
210
- catch (e) {
211
- yield failure(e);
212
- return;
213
- }
214
- yield success(result);
215
- }))());
216
- this.futures[action.stepRunId] = future;
217
- // Send the action event to the dispatcher
218
- const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
219
- this.client.dispatcher.sendStepActionEvent(event).catch((e) => {
184
+ });
185
+ // delete the run from the futures
186
+ delete this.futures[action.stepRunId];
187
+ }
188
+ catch (e) {
220
189
  this.logger.error(`Could not send action event: ${e.message}`);
221
- });
222
- yield future.promise;
223
- }
224
- catch (e) {
190
+ }
191
+ };
192
+ const future = new hatchet_promise_1.default(run().then(success).catch(failure));
193
+ this.futures[action.stepRunId] = future;
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
197
  this.logger.error(`Could not send action event: ${e.message}`);
226
- }
227
- });
198
+ });
199
+ }
200
+ catch (e) {
201
+ this.logger.error(`Could not send action event: ${e.message}`);
202
+ }
228
203
  }
229
204
  handleStartGroupKeyRun(action) {
230
- return __awaiter(this, void 0, void 0, function* () {
231
- const { actionId } = action;
232
- try {
233
- const context = new step_1.Context(action, this.client);
234
- const key = action.getGroupKeyRunId;
235
- if (!key) {
236
- this.logger.error(`No group key run id provided for action ${actionId}`);
237
- return;
205
+ const { actionId } = action;
206
+ try {
207
+ const context = new step_1.Context(action, this.client);
208
+ const key = action.getGroupKeyRunId;
209
+ this.contexts[key] = context;
210
+ this.logger.debug(`Starting group key run ${key}`);
211
+ const step = this.action_registry[actionId];
212
+ if (!step) {
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];
238
229
  }
239
- this.contexts[key] = context;
240
- this.logger.debug(`Starting group key run ${key}`);
241
- const step = this.action_registry[actionId];
242
- if (!step) {
243
- this.logger.error(`Could not find step '${actionId}'`);
244
- return;
230
+ catch (e) {
231
+ this.logger.error(`Could not send action event: ${e.message}`);
245
232
  }
246
- const run = () => __awaiter(this, void 0, void 0, function* () {
247
- return step(context);
248
- });
249
- const success = (result) => {
250
- this.logger.info(`Step run ${action.stepRunId} succeeded`);
251
- try {
252
- // Send the action event to the dispatcher
253
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
254
- this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
255
- this.logger.error(`Could not send action event: ${e.message}`);
256
- });
257
- // delete the run from the futures
258
- delete this.futures[key];
259
- }
260
- catch (e) {
261
- this.logger.error(`Could not send action event: ${e.message}`);
262
- }
263
- };
264
- const failure = (error) => {
265
- this.logger.error(`Step run ${key} failed: ${error.message}`);
266
- try {
267
- // Send the action event to the dispatcher
268
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
269
- this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
270
- this.logger.error(`Could not send action event: ${e.message}`);
271
- });
272
- // delete the run from the futures
273
- delete this.futures[key];
274
- }
275
- catch (e) {
233
+ };
234
+ const failure = (error) => {
235
+ this.logger.error(`Step run ${key} failed: ${error.message}`);
236
+ try {
237
+ // Send the action event to the dispatcher
238
+ const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
239
+ this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
276
240
  this.logger.error(`Could not send action event: ${e.message}`);
277
- }
278
- };
279
- const future = new hatchet_promise_1.default(run().then(success).catch(failure));
280
- this.futures[key] = future;
281
- // Send the action event to the dispatcher
282
- const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_STARTED);
283
- this.client.dispatcher.sendGroupKeyActionEvent(event).catch((e) => {
241
+ });
242
+ // delete the run from the futures
243
+ delete this.futures[key];
244
+ }
245
+ catch (e) {
284
246
  this.logger.error(`Could not send action event: ${e.message}`);
285
- });
286
- yield future.promise;
287
- }
288
- catch (e) {
247
+ }
248
+ };
249
+ const future = new hatchet_promise_1.default(run().then(success).catch(failure));
250
+ this.futures[action.getGroupKeyRunId] = future;
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
254
  this.logger.error(`Could not send action event: ${e.message}`);
290
- }
291
- });
255
+ });
256
+ }
257
+ catch (e) {
258
+ this.logger.error(`Could not send action event: ${e.message}`);
259
+ }
292
260
  }
293
261
  getStepActionEvent(action, eventType, payload = '') {
294
262
  return {
@@ -304,9 +272,6 @@ class Worker {
304
272
  };
305
273
  }
306
274
  getGroupKeyActionEvent(action, eventType, payload = '') {
307
- if (!action.getGroupKeyRunId) {
308
- throw new hatchet_error_1.default('No group key run id provided');
309
- }
310
275
  return {
311
276
  workerId: this.name,
312
277
  workflowRunId: action.workflowRunId,
@@ -318,29 +283,26 @@ class Worker {
318
283
  };
319
284
  }
320
285
  handleCancelStepRun(action) {
321
- return __awaiter(this, void 0, void 0, function* () {
322
- try {
323
- this.logger.info(`Cancelling step run ${action.stepRunId}`);
324
- const { stepRunId } = action;
325
- const future = this.futures[stepRunId];
326
- const context = this.contexts[stepRunId];
327
- if (context && context.controller) {
328
- context.controller.abort('Cancelled by worker');
329
- delete this.contexts[stepRunId];
330
- }
331
- if (future) {
332
- future.promise.catch(() => {
333
- this.logger.info(`Cancelled step run ${action.stepRunId}`);
334
- });
335
- future.cancel('Cancelled by worker');
336
- yield future.promise;
337
- delete this.futures[stepRunId];
338
- }
286
+ try {
287
+ this.logger.info(`Cancelling step run ${action.stepRunId}`);
288
+ const { stepRunId } = action;
289
+ const future = this.futures[stepRunId];
290
+ const context = this.contexts[stepRunId];
291
+ if (context && context.controller) {
292
+ context.controller.abort('Cancelled by worker');
293
+ delete this.contexts[stepRunId];
339
294
  }
340
- catch (e) {
341
- this.logger.error(`Could not cancel step run: ${e.message}`);
295
+ if (future) {
296
+ future.promise.catch(() => {
297
+ this.logger.info(`Cancelled step run ${action.stepRunId}`);
298
+ });
299
+ future.cancel('Cancelled by worker');
300
+ delete this.futures[stepRunId];
342
301
  }
343
- });
302
+ }
303
+ catch (e) {
304
+ this.logger.error(`Could not cancel step run: ${e.message}`);
305
+ }
344
306
  }
345
307
  stop() {
346
308
  return __awaiter(this, void 0, void 0, function* () {
@@ -388,7 +350,18 @@ class Worker {
388
350
  _d = false;
389
351
  const action = _c;
390
352
  this.logger.info(`Worker ${this.name} received action ${action.actionId}:${action.actionType}`);
391
- void this.handleAction(action);
353
+ if (action.actionType === dispatcher_1.ActionType.START_STEP_RUN) {
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
+ }
392
365
  }
393
366
  }
394
367
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -410,24 +383,5 @@ class Worker {
410
383
  }
411
384
  });
412
385
  }
413
- handleAction(action) {
414
- return __awaiter(this, void 0, void 0, function* () {
415
- const type = action.actionType
416
- ? (0, dispatcher_1.actionTypeFromJSON)(action.actionType)
417
- : dispatcher_1.ActionType.START_STEP_RUN;
418
- if (type === dispatcher_1.ActionType.START_STEP_RUN) {
419
- yield this.handleStartStepRun(action);
420
- }
421
- else if (type === dispatcher_1.ActionType.CANCEL_STEP_RUN) {
422
- yield this.handleCancelStepRun(action);
423
- }
424
- else if (type === dispatcher_1.ActionType.START_GET_GROUP_KEY) {
425
- yield this.handleStartGroupKeyRun(action);
426
- }
427
- else {
428
- this.logger.error(`Worker ${this.name} received unknown action type ${type}`);
429
- }
430
- });
431
- }
432
386
  }
433
387
  exports.Worker = Worker;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.8.0-alpha.2",
3
+ "version": "0.8.1",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -19,7 +19,7 @@
19
19
  "prepare": "npm run build",
20
20
  "tsc:build": "tsc && resolve-tspaths",
21
21
  "test:unit": "jest --testMatch='**/*.test.ts'",
22
- "test:e2e": "jest --testMatch='**/*.e2e.ts' --runInBand --detectOpenHandles",
22
+ "test:e2e": "jest --testMatch='**/*.e2e.ts'",
23
23
  "test:unit:watch": "jest --testMatch='**/*.test.ts' --watch",
24
24
  "generate": "pnpm run '/generate-.*/'",
25
25
  "generate-api": "npx --yes swagger-cli bundle ./hatchet/api-contracts/openapi/openapi.yaml --outfile openapi.yaml --type yaml && npx swagger-typescript-api -p openapi.yaml -o src/clients/rest/generated -n hatchet.ts --modular --axios",
@@ -51,7 +51,7 @@
51
51
  "worker:logger": "npm run exec -- ./examples/logger.ts",
52
52
  "api": "npm run exec -- ./examples/api.ts",
53
53
  "prepublish": "cp package.json dist/package.json;",
54
- "publish:ci": "rm -rf ./dist && npm run tsc:build && npm run prepublish && cd dist && npm publish --access public --no-git-checks --tag=alpha",
54
+ "publish:ci": "rm -rf ./dist && npm run tsc:build && npm run prepublish && cd dist && npm publish --access public --no-git-checks",
55
55
  "generate-docs": "typedoc"
56
56
  },
57
57
  "keywords": [],
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
- // protoc-gen-ts_proto v1.178.0
4
+ // protoc-gen-ts_proto v1.180.0
5
5
  // protoc v3.19.1
6
6
  // source: dispatcher/dispatcher.proto
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
- // protoc-gen-ts_proto v1.178.0
4
+ // protoc-gen-ts_proto v1.180.0
5
5
  // protoc v3.19.1
6
6
  // source: events/events.proto
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
- // protoc-gen-ts_proto v1.178.0
4
+ // protoc-gen-ts_proto v1.180.0
5
5
  // protoc v3.19.1
6
6
  // source: google/protobuf/timestamp.proto
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  // Code generated by protoc-gen-ts_proto. DO NOT EDIT.
3
3
  // versions:
4
- // protoc-gen-ts_proto v1.178.0
4
+ // protoc-gen-ts_proto v1.180.0
5
5
  // protoc v3.19.1
6
6
  // source: workflows/workflows.proto
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
package/step.d.ts CHANGED
@@ -67,7 +67,7 @@ declare class ChildWorkflowRef<T> {
67
67
  result(): Promise<T>;
68
68
  toJSON(): Promise<string>;
69
69
  }
70
- export declare class Context<T, K> {
70
+ export declare class Context<T, K = {}> {
71
71
  data: ContextData<T, K>;
72
72
  input: T;
73
73
  controller: AbortController;
package/step.js CHANGED
@@ -229,7 +229,7 @@ class Context {
229
229
  spawnWorkflow(workflowName, input, key) {
230
230
  const { workflowRunId, stepRunId } = this.action;
231
231
  const name = this.client.config.namespace + workflowName;
232
- const childWorkflowRunIdPromise = this.client.admin.run_workflow(name, input, {
232
+ const childWorkflowRunIdPromise = this.client.admin.runWorkflow(name, input, {
233
233
  parentId: workflowRunId,
234
234
  parentStepRunId: stepRunId,
235
235
  childKey: key,
package/util/parse.js CHANGED
@@ -2,11 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseJSON = void 0;
4
4
  function parseJSON(json) {
5
- // TODO why is this needed?
6
- if (json.startsWith('ey')) {
7
- const decoded = Buffer.from(json, 'base64').toString('utf8');
8
- return JSON.parse(decoded);
9
- }
10
5
  try {
11
6
  const firstParse = JSON.parse(json);
12
7
  // Hatchet engine versions <=0.14.0 return JSON as a quoted string which needs to be parsed again.
package/workflow.d.ts CHANGED
@@ -60,7 +60,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
60
60
  * @deprecated Workflow timeout is deprecated. Use step timeouts instead.
61
61
  */
62
62
  timeout: z.ZodOptional<z.ZodString>;
63
- on: z.ZodUnion<[z.ZodObject<{
63
+ on: z.ZodOptional<z.ZodUnion<[z.ZodObject<{
64
64
  cron: z.ZodString;
65
65
  event: z.ZodUndefined;
66
66
  }, "strip", z.ZodTypeAny, {
@@ -78,7 +78,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
78
78
  }, {
79
79
  event: string;
80
80
  cron?: undefined;
81
- }>]>;
81
+ }>]>>;
82
82
  steps: z.ZodArray<z.ZodObject<{
83
83
  name: z.ZodString;
84
84
  parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
@@ -160,16 +160,16 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
160
160
  }[] | undefined;
161
161
  }[];
162
162
  id: string;
163
- on: {
163
+ version?: string | undefined;
164
+ scheduleTimeout?: string | undefined;
165
+ timeout?: string | undefined;
166
+ on?: {
164
167
  cron: string;
165
168
  event?: undefined;
166
169
  } | {
167
170
  event: string;
168
171
  cron?: undefined;
169
- };
170
- version?: string | undefined;
171
- scheduleTimeout?: string | undefined;
172
- timeout?: string | undefined;
172
+ } | undefined;
173
173
  onFailure?: {
174
174
  name: string;
175
175
  timeout?: string | undefined;
@@ -193,16 +193,16 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
193
193
  }[] | undefined;
194
194
  }[];
195
195
  id: string;
196
- on: {
196
+ version?: string | undefined;
197
+ scheduleTimeout?: string | undefined;
198
+ timeout?: string | undefined;
199
+ on?: {
197
200
  cron: string;
198
201
  event?: undefined;
199
202
  } | {
200
203
  event: string;
201
204
  cron?: undefined;
202
- };
203
- version?: string | undefined;
204
- scheduleTimeout?: string | undefined;
205
- timeout?: string | undefined;
205
+ } | undefined;
206
206
  onFailure?: {
207
207
  name: string;
208
208
  timeout?: string | undefined;
package/workflow.js CHANGED
@@ -35,7 +35,7 @@ const EventConfigSchema = z.object({
35
35
  cron: z.undefined(),
36
36
  event: z.string(),
37
37
  });
38
- const OnConfigSchema = z.union([CronConfigSchema, EventConfigSchema]);
38
+ const OnConfigSchema = z.union([CronConfigSchema, EventConfigSchema]).optional();
39
39
  const StepsSchema = z.array(step_1.CreateStepSchema);
40
40
  exports.ConcurrencyLimitStrategy = workflows_1.ConcurrencyLimitStrategy;
41
41
  exports.WorkflowConcurrency = z.object({