@hatchet-dev/typescript-sdk 0.17.0 → 0.17.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.
@@ -2,6 +2,7 @@ import { Channel, ClientFactory } from 'nice-grpc';
2
2
  import { EventsServiceClient } from '../../protoc/events/events';
3
3
  import { ClientConfig } from '../hatchet-client/client-config';
4
4
  import { Logger } from '../../util/logger';
5
+ import { retrier } from '../../util/retrier';
5
6
  export declare enum LogLevel {
6
7
  INFO = "INFO",
7
8
  WARN = "WARN",
@@ -18,6 +19,7 @@ export interface EventWithMetadata<T> {
18
19
  export declare class EventClient {
19
20
  config: ClientConfig;
20
21
  client: EventsServiceClient;
22
+ retrier: typeof retrier;
21
23
  logger: Logger;
22
24
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
23
25
  push<T>(type: string, input: T, options?: PushEventOptions): Promise<import("../../protoc/events/events").Event>;
@@ -30,6 +30,7 @@ class EventClient {
30
30
  this.config = config;
31
31
  this.client = factory.create(events_1.EventsServiceDefinition, channel);
32
32
  this.logger = new logger_1.Logger(`Dispatcher`, config.log_level);
33
+ this.retrier = retrier_1.retrier;
33
34
  }
34
35
  push(type, input, options = {}) {
35
36
  var _a;
@@ -43,7 +44,7 @@ class EventClient {
43
44
  : undefined,
44
45
  };
45
46
  try {
46
- const e = this.client.push(req);
47
+ const e = this.retrier(() => __awaiter(this, void 0, void 0, function* () { return this.client.push(req); }), this.logger);
47
48
  this.logger.info(`Event pushed: ${namespacedType}`);
48
49
  return e;
49
50
  }
@@ -74,9 +75,9 @@ class EventClient {
74
75
  events,
75
76
  };
76
77
  try {
77
- const e = this.client.bulkPush(req);
78
+ const res = this.retrier(() => __awaiter(this, void 0, void 0, function* () { return this.client.bulkPush(req); }), this.logger);
78
79
  this.logger.info(`Bulk events pushed for type: ${namespacedType}`);
79
- return e;
80
+ return res;
80
81
  }
81
82
  catch (e) {
82
83
  throw new hatchet_error_1.default(e.message);
@@ -48,7 +48,7 @@ class Worker {
48
48
  registerActions(workflow) {
49
49
  var _a;
50
50
  const newActions = workflow.steps.reduce((acc, step) => {
51
- acc[`${workflow.id}:${step.name}`] = step.run;
51
+ acc[`${workflow.id}:${step.name.toLowerCase()}`] = step.run;
52
52
  return acc;
53
53
  }, {});
54
54
  const onFailureAction = workflow.onFailure
@@ -59,7 +59,7 @@ class Worker {
59
59
  this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
60
60
  this.action_registry =
61
61
  ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.name) && workflow.concurrency.key
62
- ? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
62
+ ? Object.assign(Object.assign({}, this.action_registry), { [`${workflow.id}:${workflow.concurrency.name.toLowerCase()}`]: workflow.concurrency.key }) : Object.assign({}, this.action_registry);
63
63
  }
64
64
  getHandler(workflows) {
65
65
  for (const workflow of workflows) {
@@ -165,7 +165,7 @@ class Worker {
165
165
  });
166
166
  }
167
167
  registerAction(actionId, action) {
168
- this.action_registry[actionId] = action;
168
+ this.action_registry[actionId.toLowerCase()] = action;
169
169
  }
170
170
  handleStartStepRun(action) {
171
171
  return __awaiter(this, void 0, void 0, function* () {
@@ -175,6 +175,7 @@ class Worker {
175
175
  this.contexts[action.stepRunId] = context;
176
176
  const step = this.action_registry[actionId];
177
177
  if (!step) {
178
+ this.logger.error(`Registered actions: '${Object.keys(this.action_registry).join(', ')}'`);
178
179
  this.logger.error(`Could not find step '${actionId}'`);
179
180
  return;
180
181
  }
package/index.d.ts CHANGED
@@ -6,3 +6,4 @@ export * from './clients/rest';
6
6
  export * from './clients/admin';
7
7
  export * from './util/workflow-run-ref';
8
8
  export default Hatchet;
9
+ export { Hatchet };
package/index.js CHANGED
@@ -14,7 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.Hatchet = void 0;
17
18
  const hatchet_client_1 = require("./clients/hatchet-client");
19
+ Object.defineProperty(exports, "Hatchet", { enumerable: true, get: function () { return hatchet_client_1.HatchetClient; } });
18
20
  __exportStar(require("./workflow"), exports);
19
21
  __exportStar(require("./step"), exports);
20
22
  __exportStar(require("./clients/worker"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.17.0",
3
+ "version": "0.17.1",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/util/retrier.js CHANGED
@@ -14,9 +14,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.retrier = retrier;
16
16
  const sleep_1 = __importDefault(require("./sleep"));
17
- const DEFAULT_RETRY_INTERVAL = 1; // seconds
17
+ const DEFAULT_RETRY_INTERVAL = 0.1; // seconds
18
18
  const DEFAULT_RETRY_COUNT = 8;
19
- const MAX_JITTER = 400; // milliseconds
19
+ const MAX_JITTER = 100; // milliseconds
20
20
  function retrier(fn_1, logger_1) {
21
21
  return __awaiter(this, arguments, void 0, function* (fn, logger, retries = DEFAULT_RETRY_COUNT, interval = DEFAULT_RETRY_INTERVAL) {
22
22
  let lastError;
@@ -43,10 +43,10 @@ function getWorkflowRunId(workflowRunId) {
43
43
  if (e.code && e.code === nice_grpc_1.Status.ALREADY_EXISTS) {
44
44
  throw new DedupeViolationErr(e.details);
45
45
  }
46
- throw new Error('Invalid workflowRunId');
46
+ throw e;
47
47
  }
48
48
  }
49
- throw new Error('Invalid workflowRunId');
49
+ throw new Error('Invalid workflowRunId: must be a string or a promise');
50
50
  });
51
51
  }
52
52
  class WorkflowRunRef {
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "0.17.0";
1
+ export declare const HATCHET_VERSION = "0.17.1";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HATCHET_VERSION = void 0;
4
- exports.HATCHET_VERSION = '0.17.0';
4
+ exports.HATCHET_VERSION = '0.17.1';