@hatchet-dev/typescript-sdk 0.1.16 → 0.1.18

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.
@@ -7,7 +7,6 @@ import { Logger } from '../../util/logger';
7
7
  import { Context, StepRunFunction } from '../../step';
8
8
  export type ActionRegistry = Record<Action['actionId'], Function>;
9
9
  export declare class Worker {
10
- serviceName: string;
11
10
  client: HatchetClient;
12
11
  name: string;
13
12
  killing: boolean;
@@ -29,7 +29,6 @@ const logger_1 = require("../../util/logger");
29
29
  const step_1 = require("../../step");
30
30
  class Worker {
31
31
  constructor(client, options) {
32
- this.serviceName = 'default';
33
32
  this.futures = {};
34
33
  this.contexts = {};
35
34
  this.client = client;
@@ -48,7 +47,7 @@ class Worker {
48
47
  try {
49
48
  const concurrency = ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name)
50
49
  ? {
51
- action: `${this.serviceName}:${workflow.concurrency.name}`,
50
+ action: `${workflow.id}:${workflow.concurrency.name}`,
52
51
  maxRuns: workflow.concurrency.maxRuns || 1,
53
52
  limitStrategy: workflow.concurrency.limitStrategy || workflows_1.ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS,
54
53
  }
@@ -61,6 +60,7 @@ class Worker {
61
60
  cronTriggers: workflow.on.cron ? [workflow.on.cron] : [],
62
61
  scheduledTriggers: [],
63
62
  concurrency,
63
+ scheduleTimeout: workflow.scheduleTimeout,
64
64
  jobs: [
65
65
  {
66
66
  name: workflow.id,
@@ -70,7 +70,7 @@ class Worker {
70
70
  var _a;
71
71
  return ({
72
72
  readableId: step.name,
73
- action: `${this.serviceName}:${step.name}`,
73
+ action: `${workflow.id}:${step.name}`,
74
74
  timeout: step.timeout || '60s',
75
75
  inputs: '{}',
76
76
  parents: (_a = step.parents) !== null && _a !== void 0 ? _a : [],
@@ -85,12 +85,13 @@ class Worker {
85
85
  catch (e) {
86
86
  throw new hatchet_error_1.default(`Could not register workflow: ${e.message}`);
87
87
  }
88
- this.action_registry = workflow.steps.reduce((acc, step) => {
89
- acc[`${this.serviceName}:${step.name}`] = step.run;
88
+ const newActions = workflow.steps.reduce((acc, step) => {
89
+ acc[`${workflow.id}:${step.name}`] = step.run;
90
90
  return acc;
91
91
  }, {});
92
+ this.action_registry = Object.assign(Object.assign({}, this.action_registry), newActions);
92
93
  this.action_registry = ((_b = workflow.concurrency) === null || _b === void 0 ? void 0 : _b.name)
93
- ? Object.assign(Object.assign({}, this.action_registry), { [`${this.serviceName}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
94
+ ? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
94
95
  });
95
96
  }
96
97
  registerAction(actionId, action) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.1.16",
3
+ "version": "0.1.18",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,6 +36,7 @@
36
36
  "worker:concurrency:rr": "npm run exec -- ./examples/concurrency/group-round-robin/concurrency-worker.ts",
37
37
  "event:concurrency:rr": "npm run exec -- ./examples/concurrency/group-round-robin/concurrency-event.ts",
38
38
  "worker:retries": "npm run exec -- ./examples/retries-worker.ts",
39
+ "worker:multi-workflow": "npm run exec -- ./examples/multi-workflow.ts",
39
40
  "api": "npm run exec -- ./examples/api.ts",
40
41
  "prepublish": "cp package.json dist/package.json;",
41
42
  "publish:ci": "rm -rf ./dist && npm run tsc:build && npm run prepublish && cd dist && npm publish --access public --no-git-checks",
@@ -31,6 +31,8 @@ export interface CreateWorkflowVersionOpts {
31
31
  jobs: CreateWorkflowJobOpts[];
32
32
  /** (optional) the workflow concurrency options */
33
33
  concurrency: WorkflowConcurrencyOpts | undefined;
34
+ /** (optional) the timeout for the schedule */
35
+ scheduleTimeout?: string | undefined;
34
36
  }
35
37
  export interface WorkflowConcurrencyOpts {
36
38
  /** (required) the action id for getting the concurrency group */
@@ -135,6 +135,7 @@ function createBaseCreateWorkflowVersionOpts() {
135
135
  scheduledTriggers: [],
136
136
  jobs: [],
137
137
  concurrency: undefined,
138
+ scheduleTimeout: undefined,
138
139
  };
139
140
  }
140
141
  exports.CreateWorkflowVersionOpts = {
@@ -163,6 +164,9 @@ exports.CreateWorkflowVersionOpts = {
163
164
  if (message.concurrency !== undefined) {
164
165
  exports.WorkflowConcurrencyOpts.encode(message.concurrency, writer.uint32(66).fork()).ldelim();
165
166
  }
167
+ if (message.scheduleTimeout !== undefined) {
168
+ writer.uint32(74).string(message.scheduleTimeout);
169
+ }
166
170
  return writer;
167
171
  },
168
172
  decode(input, length) {
@@ -220,6 +224,12 @@ exports.CreateWorkflowVersionOpts = {
220
224
  }
221
225
  message.concurrency = exports.WorkflowConcurrencyOpts.decode(reader, reader.uint32());
222
226
  continue;
227
+ case 9:
228
+ if (tag !== 74) {
229
+ break;
230
+ }
231
+ message.scheduleTimeout = reader.string();
232
+ continue;
223
233
  }
224
234
  if ((tag & 7) === 4 || tag === 0) {
225
235
  break;
@@ -246,6 +256,7 @@ exports.CreateWorkflowVersionOpts = {
246
256
  ? object.jobs.map((e) => exports.CreateWorkflowJobOpts.fromJSON(e))
247
257
  : [],
248
258
  concurrency: isSet(object.concurrency) ? exports.WorkflowConcurrencyOpts.fromJSON(object.concurrency) : undefined,
259
+ scheduleTimeout: isSet(object.scheduleTimeout) ? globalThis.String(object.scheduleTimeout) : undefined,
249
260
  };
250
261
  },
251
262
  toJSON(message) {
@@ -275,13 +286,16 @@ exports.CreateWorkflowVersionOpts = {
275
286
  if (message.concurrency !== undefined) {
276
287
  obj.concurrency = exports.WorkflowConcurrencyOpts.toJSON(message.concurrency);
277
288
  }
289
+ if (message.scheduleTimeout !== undefined) {
290
+ obj.scheduleTimeout = message.scheduleTimeout;
291
+ }
278
292
  return obj;
279
293
  },
280
294
  create(base) {
281
295
  return exports.CreateWorkflowVersionOpts.fromPartial(base !== null && base !== void 0 ? base : {});
282
296
  },
283
297
  fromPartial(object) {
284
- var _a, _b, _c, _d, _e, _f, _g;
298
+ var _a, _b, _c, _d, _e, _f, _g, _h;
285
299
  const message = createBaseCreateWorkflowVersionOpts();
286
300
  message.name = (_a = object.name) !== null && _a !== void 0 ? _a : "";
287
301
  message.description = (_b = object.description) !== null && _b !== void 0 ? _b : "";
@@ -293,6 +307,7 @@ exports.CreateWorkflowVersionOpts = {
293
307
  message.concurrency = (object.concurrency !== undefined && object.concurrency !== null)
294
308
  ? exports.WorkflowConcurrencyOpts.fromPartial(object.concurrency)
295
309
  : undefined;
310
+ message.scheduleTimeout = (_h = object.scheduleTimeout) !== null && _h !== void 0 ? _h : undefined;
296
311
  return message;
297
312
  },
298
313
  };
package/workflow.d.ts CHANGED
@@ -37,6 +37,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
37
37
  id: z.ZodString;
38
38
  description: z.ZodString;
39
39
  version: z.ZodOptional<z.ZodString>;
40
+ scheduleTimeout: z.ZodOptional<z.ZodString>;
40
41
  timeout: z.ZodOptional<z.ZodString>;
41
42
  on: z.ZodUnion<[z.ZodObject<{
42
43
  cron: z.ZodString;
@@ -90,6 +91,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
90
91
  cron?: undefined;
91
92
  };
92
93
  version?: string | undefined;
94
+ scheduleTimeout?: string | undefined;
93
95
  timeout?: string | undefined;
94
96
  }, {
95
97
  description: string;
@@ -108,6 +110,7 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
108
110
  cron?: undefined;
109
111
  };
110
112
  version?: string | undefined;
113
+ scheduleTimeout?: string | undefined;
111
114
  timeout?: string | undefined;
112
115
  }>;
113
116
  export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
package/workflow.js CHANGED
@@ -48,6 +48,7 @@ exports.CreateWorkflowSchema = z.object({
48
48
  id: z.string(),
49
49
  description: z.string(),
50
50
  version: z.string().optional(),
51
+ scheduleTimeout: z.string().optional(),
51
52
  timeout: exports.HatchetTimeoutSchema.optional(),
52
53
  on: OnConfigSchema,
53
54
  steps: StepsSchema,