@hatchet-dev/typescript-sdk 0.0.3 → 0.0.8

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.
Files changed (59) hide show
  1. package/{dist/clients → clients}/admin/admin-client.d.ts +1 -3
  2. package/{dist/clients → clients}/admin/admin-client.js +1 -4
  3. package/{dist/clients → clients}/dispatcher/action-listener.d.ts +2 -0
  4. package/clients/dispatcher/dispatcher-client.d.ts +20 -0
  5. package/{dist/clients → clients}/dispatcher/dispatcher-client.js +15 -3
  6. package/{dist/clients → clients}/event/event-client.d.ts +2 -0
  7. package/{dist/clients → clients}/event/event-client.js +5 -1
  8. package/{dist/clients → clients}/hatchet-client/hatchet-client.js +1 -1
  9. package/{dist/clients → clients}/worker/worker.d.ts +11 -8
  10. package/{dist/clients → clients}/worker/worker.js +114 -25
  11. package/package.json +25 -19
  12. package/{dist/protoc → protoc}/dispatcher/dispatcher.d.ts +82 -22
  13. package/{dist/protoc → protoc}/dispatcher/dispatcher.js +292 -58
  14. package/{dist/protoc → protoc}/workflows/workflows.d.ts +26 -0
  15. package/{dist/protoc → protoc}/workflows/workflows.js +138 -1
  16. package/{dist/step.d.ts → step.d.ts} +3 -0
  17. package/{dist/step.js → step.js} +2 -0
  18. package/{dist/workflow.d.ts → workflow.d.ts} +33 -0
  19. package/{dist/workflow.js → workflow.js} +11 -1
  20. package/README.md +0 -3
  21. package/dist/clients/dispatcher/dispatcher-client.d.ts +0 -17
  22. /package/{dist/clients → clients}/dispatcher/action-listener.js +0 -0
  23. /package/{dist/clients → clients}/hatchet-client/client-config.d.ts +0 -0
  24. /package/{dist/clients → clients}/hatchet-client/client-config.js +0 -0
  25. /package/{dist/clients → clients}/hatchet-client/hatchet-client.d.ts +0 -0
  26. /package/{dist/clients → clients}/hatchet-client/index.d.ts +0 -0
  27. /package/{dist/clients → clients}/hatchet-client/index.js +0 -0
  28. /package/{dist/clients → clients}/worker/index.d.ts +0 -0
  29. /package/{dist/clients → clients}/worker/index.js +0 -0
  30. /package/{dist/index.d.ts → index.d.ts} +0 -0
  31. /package/{dist/index.js → index.js} +0 -0
  32. /package/{dist/protoc → protoc}/dispatcher/index.d.ts +0 -0
  33. /package/{dist/protoc → protoc}/dispatcher/index.js +0 -0
  34. /package/{dist/protoc → protoc}/events/events.d.ts +0 -0
  35. /package/{dist/protoc → protoc}/events/events.js +0 -0
  36. /package/{dist/protoc → protoc}/events/index.d.ts +0 -0
  37. /package/{dist/protoc → protoc}/events/index.js +0 -0
  38. /package/{dist/protoc → protoc}/google/protobuf/timestamp.d.ts +0 -0
  39. /package/{dist/protoc → protoc}/google/protobuf/timestamp.js +0 -0
  40. /package/{dist/protoc → protoc}/google/protobuf/wrappers.d.ts +0 -0
  41. /package/{dist/protoc → protoc}/google/protobuf/wrappers.js +0 -0
  42. /package/{dist/protoc → protoc}/workflows/index.d.ts +0 -0
  43. /package/{dist/protoc → protoc}/workflows/index.js +0 -0
  44. /package/{dist/sdk.d.ts → sdk.d.ts} +0 -0
  45. /package/{dist/sdk.js → sdk.js} +0 -0
  46. /package/{dist/util → util}/config-loader/config-loader.d.ts +0 -0
  47. /package/{dist/util → util}/config-loader/config-loader.js +0 -0
  48. /package/{dist/util → util}/config-loader/index.d.ts +0 -0
  49. /package/{dist/util → util}/config-loader/index.js +0 -0
  50. /package/{dist/util → util}/errors/hatchet-error.d.ts +0 -0
  51. /package/{dist/util → util}/errors/hatchet-error.js +0 -0
  52. /package/{dist/util → util}/hatchet-promise/hatchet-promise.d.ts +0 -0
  53. /package/{dist/util → util}/hatchet-promise/hatchet-promise.js +0 -0
  54. /package/{dist/util → util}/logger/index.d.ts +0 -0
  55. /package/{dist/util → util}/logger/index.js +0 -0
  56. /package/{dist/util → util}/logger/logger.d.ts +0 -0
  57. /package/{dist/util → util}/logger/logger.js +0 -0
  58. /package/{dist/util → util}/sleep.d.ts +0 -0
  59. /package/{dist/util → util}/sleep.js +0 -0
@@ -23,11 +23,50 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.WorkflowServiceDefinition = exports.GetWorkflowByNameRequest = exports.DeleteWorkflowRequest = exports.Step = exports.Job = exports.WorkflowTriggerCronRef = exports.WorkflowTriggerEventRef = exports.WorkflowTriggers = exports.WorkflowVersion = exports.Workflow = exports.ListWorkflowsForEventRequest = exports.ListWorkflowsResponse = exports.ScheduleWorkflowRequest = exports.ListWorkflowsRequest = exports.CreateWorkflowStepOpts = exports.CreateWorkflowJobOpts = exports.CreateWorkflowVersionOpts = exports.PutWorkflowRequest = exports.protobufPackage = void 0;
26
+ exports.WorkflowServiceDefinition = exports.GetWorkflowByNameRequest = exports.DeleteWorkflowRequest = exports.Step = exports.Job = exports.WorkflowTriggerCronRef = exports.WorkflowTriggerEventRef = exports.WorkflowTriggers = exports.WorkflowVersion = exports.Workflow = exports.ListWorkflowsForEventRequest = exports.ListWorkflowsResponse = exports.ScheduleWorkflowRequest = exports.ListWorkflowsRequest = exports.CreateWorkflowStepOpts = exports.CreateWorkflowJobOpts = exports.WorkflowConcurrencyOpts = exports.CreateWorkflowVersionOpts = exports.PutWorkflowRequest = exports.concurrencyLimitStrategyToJSON = exports.concurrencyLimitStrategyFromJSON = exports.ConcurrencyLimitStrategy = exports.protobufPackage = void 0;
27
27
  const _m0 = __importStar(require("protobufjs/minimal"));
28
28
  const timestamp_1 = require("../google/protobuf/timestamp");
29
29
  const wrappers_1 = require("../google/protobuf/wrappers");
30
30
  exports.protobufPackage = "";
31
+ var ConcurrencyLimitStrategy;
32
+ (function (ConcurrencyLimitStrategy) {
33
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_IN_PROGRESS"] = 0] = "CANCEL_IN_PROGRESS";
34
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["DROP_NEWEST"] = 1] = "DROP_NEWEST";
35
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["QUEUE_NEWEST"] = 2] = "QUEUE_NEWEST";
36
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
37
+ })(ConcurrencyLimitStrategy || (exports.ConcurrencyLimitStrategy = ConcurrencyLimitStrategy = {}));
38
+ function concurrencyLimitStrategyFromJSON(object) {
39
+ switch (object) {
40
+ case 0:
41
+ case "CANCEL_IN_PROGRESS":
42
+ return ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS;
43
+ case 1:
44
+ case "DROP_NEWEST":
45
+ return ConcurrencyLimitStrategy.DROP_NEWEST;
46
+ case 2:
47
+ case "QUEUE_NEWEST":
48
+ return ConcurrencyLimitStrategy.QUEUE_NEWEST;
49
+ case -1:
50
+ case "UNRECOGNIZED":
51
+ default:
52
+ return ConcurrencyLimitStrategy.UNRECOGNIZED;
53
+ }
54
+ }
55
+ exports.concurrencyLimitStrategyFromJSON = concurrencyLimitStrategyFromJSON;
56
+ function concurrencyLimitStrategyToJSON(object) {
57
+ switch (object) {
58
+ case ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS:
59
+ return "CANCEL_IN_PROGRESS";
60
+ case ConcurrencyLimitStrategy.DROP_NEWEST:
61
+ return "DROP_NEWEST";
62
+ case ConcurrencyLimitStrategy.QUEUE_NEWEST:
63
+ return "QUEUE_NEWEST";
64
+ case ConcurrencyLimitStrategy.UNRECOGNIZED:
65
+ default:
66
+ return "UNRECOGNIZED";
67
+ }
68
+ }
69
+ exports.concurrencyLimitStrategyToJSON = concurrencyLimitStrategyToJSON;
31
70
  function createBasePutWorkflowRequest() {
32
71
  return { opts: undefined };
33
72
  }
@@ -89,6 +128,7 @@ function createBaseCreateWorkflowVersionOpts() {
89
128
  cronTriggers: [],
90
129
  scheduledTriggers: [],
91
130
  jobs: [],
131
+ concurrency: undefined,
92
132
  };
93
133
  }
94
134
  exports.CreateWorkflowVersionOpts = {
@@ -114,6 +154,9 @@ exports.CreateWorkflowVersionOpts = {
114
154
  for (const v of message.jobs) {
115
155
  exports.CreateWorkflowJobOpts.encode(v, writer.uint32(58).fork()).ldelim();
116
156
  }
157
+ if (message.concurrency !== undefined) {
158
+ exports.WorkflowConcurrencyOpts.encode(message.concurrency, writer.uint32(66).fork()).ldelim();
159
+ }
117
160
  return writer;
118
161
  },
119
162
  decode(input, length) {
@@ -165,6 +208,12 @@ exports.CreateWorkflowVersionOpts = {
165
208
  }
166
209
  message.jobs.push(exports.CreateWorkflowJobOpts.decode(reader, reader.uint32()));
167
210
  continue;
211
+ case 8:
212
+ if (tag !== 66) {
213
+ break;
214
+ }
215
+ message.concurrency = exports.WorkflowConcurrencyOpts.decode(reader, reader.uint32());
216
+ continue;
168
217
  }
169
218
  if ((tag & 7) === 4 || tag === 0) {
170
219
  break;
@@ -190,6 +239,7 @@ exports.CreateWorkflowVersionOpts = {
190
239
  jobs: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.jobs)
191
240
  ? object.jobs.map((e) => exports.CreateWorkflowJobOpts.fromJSON(e))
192
241
  : [],
242
+ concurrency: isSet(object.concurrency) ? exports.WorkflowConcurrencyOpts.fromJSON(object.concurrency) : undefined,
193
243
  };
194
244
  },
195
245
  toJSON(message) {
@@ -216,6 +266,9 @@ exports.CreateWorkflowVersionOpts = {
216
266
  if ((_d = message.jobs) === null || _d === void 0 ? void 0 : _d.length) {
217
267
  obj.jobs = message.jobs.map((e) => exports.CreateWorkflowJobOpts.toJSON(e));
218
268
  }
269
+ if (message.concurrency !== undefined) {
270
+ obj.concurrency = exports.WorkflowConcurrencyOpts.toJSON(message.concurrency);
271
+ }
219
272
  return obj;
220
273
  },
221
274
  create(base) {
@@ -231,6 +284,90 @@ exports.CreateWorkflowVersionOpts = {
231
284
  message.cronTriggers = ((_e = object.cronTriggers) === null || _e === void 0 ? void 0 : _e.map((e) => e)) || [];
232
285
  message.scheduledTriggers = ((_f = object.scheduledTriggers) === null || _f === void 0 ? void 0 : _f.map((e) => e)) || [];
233
286
  message.jobs = ((_g = object.jobs) === null || _g === void 0 ? void 0 : _g.map((e) => exports.CreateWorkflowJobOpts.fromPartial(e))) || [];
287
+ message.concurrency = (object.concurrency !== undefined && object.concurrency !== null)
288
+ ? exports.WorkflowConcurrencyOpts.fromPartial(object.concurrency)
289
+ : undefined;
290
+ return message;
291
+ },
292
+ };
293
+ function createBaseWorkflowConcurrencyOpts() {
294
+ return { action: "", maxRuns: 0, limitStrategy: 0 };
295
+ }
296
+ exports.WorkflowConcurrencyOpts = {
297
+ encode(message, writer = _m0.Writer.create()) {
298
+ if (message.action !== "") {
299
+ writer.uint32(10).string(message.action);
300
+ }
301
+ if (message.maxRuns !== 0) {
302
+ writer.uint32(16).int32(message.maxRuns);
303
+ }
304
+ if (message.limitStrategy !== 0) {
305
+ writer.uint32(24).int32(message.limitStrategy);
306
+ }
307
+ return writer;
308
+ },
309
+ decode(input, length) {
310
+ const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
311
+ let end = length === undefined ? reader.len : reader.pos + length;
312
+ const message = createBaseWorkflowConcurrencyOpts();
313
+ while (reader.pos < end) {
314
+ const tag = reader.uint32();
315
+ switch (tag >>> 3) {
316
+ case 1:
317
+ if (tag !== 10) {
318
+ break;
319
+ }
320
+ message.action = reader.string();
321
+ continue;
322
+ case 2:
323
+ if (tag !== 16) {
324
+ break;
325
+ }
326
+ message.maxRuns = reader.int32();
327
+ continue;
328
+ case 3:
329
+ if (tag !== 24) {
330
+ break;
331
+ }
332
+ message.limitStrategy = reader.int32();
333
+ continue;
334
+ }
335
+ if ((tag & 7) === 4 || tag === 0) {
336
+ break;
337
+ }
338
+ reader.skipType(tag & 7);
339
+ }
340
+ return message;
341
+ },
342
+ fromJSON(object) {
343
+ return {
344
+ action: isSet(object.action) ? globalThis.String(object.action) : "",
345
+ maxRuns: isSet(object.maxRuns) ? globalThis.Number(object.maxRuns) : 0,
346
+ limitStrategy: isSet(object.limitStrategy) ? concurrencyLimitStrategyFromJSON(object.limitStrategy) : 0,
347
+ };
348
+ },
349
+ toJSON(message) {
350
+ const obj = {};
351
+ if (message.action !== "") {
352
+ obj.action = message.action;
353
+ }
354
+ if (message.maxRuns !== 0) {
355
+ obj.maxRuns = Math.round(message.maxRuns);
356
+ }
357
+ if (message.limitStrategy !== 0) {
358
+ obj.limitStrategy = concurrencyLimitStrategyToJSON(message.limitStrategy);
359
+ }
360
+ return obj;
361
+ },
362
+ create(base) {
363
+ return exports.WorkflowConcurrencyOpts.fromPartial(base !== null && base !== void 0 ? base : {});
364
+ },
365
+ fromPartial(object) {
366
+ var _a, _b, _c;
367
+ const message = createBaseWorkflowConcurrencyOpts();
368
+ message.action = (_a = object.action) !== null && _a !== void 0 ? _a : "";
369
+ message.maxRuns = (_b = object.maxRuns) !== null && _b !== void 0 ? _b : 0;
370
+ message.limitStrategy = (_c = object.limitStrategy) !== null && _c !== void 0 ? _c : 0;
234
371
  return message;
235
372
  },
236
373
  };
@@ -2,12 +2,15 @@ import * as z from 'zod';
2
2
  export declare const CreateStepSchema: z.ZodObject<{
3
3
  name: z.ZodString;
4
4
  parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
5
+ timeout: z.ZodOptional<z.ZodString>;
5
6
  }, "strip", z.ZodTypeAny, {
6
7
  name: string;
7
8
  parents?: string[] | undefined;
9
+ timeout?: string | undefined;
8
10
  }, {
9
11
  name: string;
10
12
  parents?: string[] | undefined;
13
+ timeout?: string | undefined;
11
14
  }>;
12
15
  export type NextStep = {
13
16
  [key: string]: string;
@@ -29,9 +29,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Context = exports.CreateStepSchema = void 0;
30
30
  const hatchet_error_1 = __importDefault(require("./util/errors/hatchet-error"));
31
31
  const z = __importStar(require("zod"));
32
+ const workflow_1 = require("./workflow");
32
33
  exports.CreateStepSchema = z.object({
33
34
  name: z.string(),
34
35
  parents: z.array(z.string()).optional(),
36
+ timeout: workflow_1.HatchetTimeoutSchema.optional(),
35
37
  });
36
38
  class Context {
37
39
  constructor(payload) {
@@ -1,19 +1,40 @@
1
1
  import * as z from 'zod';
2
2
  import { CreateStep } from './step';
3
+ import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy } from './protoc/workflows';
3
4
  declare const StepsSchema: z.ZodArray<z.ZodObject<{
4
5
  name: z.ZodString;
5
6
  parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
7
+ timeout: z.ZodOptional<z.ZodString>;
6
8
  }, "strip", z.ZodTypeAny, {
7
9
  name: string;
8
10
  parents?: string[] | undefined;
11
+ timeout?: string | undefined;
9
12
  }, {
10
13
  name: string;
11
14
  parents?: string[] | undefined;
15
+ timeout?: string | undefined;
12
16
  }>, "many">;
13
17
  export type Steps = z.infer<typeof StepsSchema>;
18
+ export declare const ConcurrencyLimitStrategy: typeof PbConcurrencyLimitStrategy;
19
+ export declare const WorkflowConcurrency: z.ZodObject<{
20
+ action: z.ZodOptional<z.ZodString>;
21
+ maxRuns: z.ZodOptional<z.ZodNumber>;
22
+ limitStrategy: z.ZodOptional<z.ZodNativeEnum<typeof PbConcurrencyLimitStrategy>>;
23
+ }, "strip", z.ZodTypeAny, {
24
+ action?: string | undefined;
25
+ maxRuns?: number | undefined;
26
+ limitStrategy?: PbConcurrencyLimitStrategy | undefined;
27
+ }, {
28
+ action?: string | undefined;
29
+ maxRuns?: number | undefined;
30
+ limitStrategy?: PbConcurrencyLimitStrategy | undefined;
31
+ }>;
32
+ export declare const HatchetTimeoutSchema: z.ZodString;
14
33
  export declare const CreateWorkflowSchema: z.ZodObject<{
15
34
  id: z.ZodString;
16
35
  description: z.ZodString;
36
+ version: z.ZodOptional<z.ZodString>;
37
+ timeout: z.ZodOptional<z.ZodString>;
17
38
  on: z.ZodUnion<[z.ZodObject<{
18
39
  cron: z.ZodString;
19
40
  event: z.ZodUndefined;
@@ -36,18 +57,22 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
36
57
  steps: z.ZodArray<z.ZodObject<{
37
58
  name: z.ZodString;
38
59
  parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
60
+ timeout: z.ZodOptional<z.ZodString>;
39
61
  }, "strip", z.ZodTypeAny, {
40
62
  name: string;
41
63
  parents?: string[] | undefined;
64
+ timeout?: string | undefined;
42
65
  }, {
43
66
  name: string;
44
67
  parents?: string[] | undefined;
68
+ timeout?: string | undefined;
45
69
  }>, "many">;
46
70
  }, "strip", z.ZodTypeAny, {
47
71
  description: string;
48
72
  steps: {
49
73
  name: string;
50
74
  parents?: string[] | undefined;
75
+ timeout?: string | undefined;
51
76
  }[];
52
77
  id: string;
53
78
  on: {
@@ -57,11 +82,14 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
57
82
  event: string;
58
83
  cron?: undefined;
59
84
  };
85
+ version?: string | undefined;
86
+ timeout?: string | undefined;
60
87
  }, {
61
88
  description: string;
62
89
  steps: {
63
90
  name: string;
64
91
  parents?: string[] | undefined;
92
+ timeout?: string | undefined;
65
93
  }[];
66
94
  id: string;
67
95
  on: {
@@ -71,8 +99,13 @@ export declare const CreateWorkflowSchema: z.ZodObject<{
71
99
  event: string;
72
100
  cron?: undefined;
73
101
  };
102
+ version?: string | undefined;
103
+ timeout?: string | undefined;
74
104
  }>;
75
105
  export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
106
+ concurrency?: z.infer<typeof WorkflowConcurrency> & {
107
+ key: (ctx: any) => string;
108
+ };
76
109
  steps: CreateStep<any>[];
77
110
  }
78
111
  export {};
@@ -23,9 +23,10 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.CreateWorkflowSchema = void 0;
26
+ exports.CreateWorkflowSchema = exports.HatchetTimeoutSchema = exports.WorkflowConcurrency = exports.ConcurrencyLimitStrategy = void 0;
27
27
  const z = __importStar(require("zod"));
28
28
  const step_1 = require("./step");
29
+ const workflows_1 = require("./protoc/workflows");
29
30
  const CronConfigSchema = z.object({
30
31
  cron: z.string(),
31
32
  event: z.undefined(),
@@ -36,9 +37,18 @@ const EventConfigSchema = z.object({
36
37
  });
37
38
  const OnConfigSchema = z.union([CronConfigSchema, EventConfigSchema]);
38
39
  const StepsSchema = z.array(step_1.CreateStepSchema);
40
+ exports.ConcurrencyLimitStrategy = workflows_1.ConcurrencyLimitStrategy;
41
+ exports.WorkflowConcurrency = z.object({
42
+ action: z.string().optional(),
43
+ maxRuns: z.number().optional(),
44
+ limitStrategy: z.nativeEnum(exports.ConcurrencyLimitStrategy).optional(),
45
+ });
46
+ exports.HatchetTimeoutSchema = z.string();
39
47
  exports.CreateWorkflowSchema = z.object({
40
48
  id: z.string(),
41
49
  description: z.string(),
50
+ version: z.string().optional(),
51
+ timeout: exports.HatchetTimeoutSchema.optional(),
42
52
  on: OnConfigSchema,
43
53
  steps: StepsSchema,
44
54
  });
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Hatchet - Typescript SDK
2
-
3
- Please refer to the [Hatchet Typescript SDK documentation](https://docs.hatchet.run/typescript-sdk/setup) for setup instructions and usage details.
@@ -1,17 +0,0 @@
1
- import { Channel, ClientFactory } from 'nice-grpc';
2
- import { DispatcherClient as PbDispatcherClient, ActionEvent } from '../../protoc/dispatcher';
3
- import { ClientConfig } from '../hatchet-client/client-config';
4
- import { ActionListener } from './action-listener';
5
- interface GetActionListenerOptions {
6
- workerName: string;
7
- services: string[];
8
- actions: string[];
9
- }
10
- export declare class DispatcherClient {
11
- config: ClientConfig;
12
- client: PbDispatcherClient;
13
- constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
14
- get_action_listener(options: GetActionListenerOptions): Promise<ActionListener>;
15
- send_action_event(in_: ActionEvent): Promise<import("../../protoc/dispatcher").ActionEventResponse>;
16
- }
17
- export {};
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes