@hatchet-dev/typescript-sdk 1.6.1 → 1.6.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -4,7 +4,7 @@ import { Action } from '../../../clients/dispatcher/action-listener';
4
4
  import { Logger, LogLevel } from '../../../util/logger';
5
5
  import WorkflowRunRef from '../../../util/workflow-run-ref';
6
6
  import { Conditions } from '../../conditions';
7
- import { CreateWorkflowTaskOpts } from '../../task';
7
+ import { CreateWorkflowDurableTaskOpts, CreateWorkflowTaskOpts } from '../../task';
8
8
  import { OutputType } from '../../types';
9
9
  import { Workflow } from '../../../workflow';
10
10
  import { HatchetClient } from '../..';
@@ -48,7 +48,7 @@ export declare class Context<T, K = {}> {
48
48
  * @returns The output of the specified parent task.
49
49
  * @throws An error if the task output is not found.
50
50
  */
51
- parentOutput<L extends OutputType>(parentTask: CreateWorkflowTaskOpts<any, L> | string): Promise<L>;
51
+ parentOutput<L extends OutputType>(parentTask: CreateWorkflowTaskOpts<any, L> | CreateWorkflowDurableTaskOpts<any, L> | string): Promise<L>;
52
52
  /**
53
53
  * Returns errors from any task runs in the workflow.
54
54
  * @returns A record mapping task names to error messages.
@@ -46,7 +46,7 @@ export declare class V1Worker {
46
46
  register_workflow(initWorkflow: Workflow): Promise<void>;
47
47
  registerDurableActionsV1(workflow: WorkflowDefinition): void;
48
48
  private registerActionsV1;
49
- registerWorkflowV1(initWorkflow: BaseWorkflowDeclaration<any, any>): Promise<void>;
49
+ registerWorkflowV1(initWorkflow: BaseWorkflowDeclaration<any, any>, durable?: boolean): Promise<void>;
50
50
  registerWorkflow(initWorkflow: Workflow): Promise<void>;
51
51
  registerAction<T, K>(actionId: string, action: StepRunFunction<T, K>): void;
52
52
  handleStartStepRun(action: Action): Promise<void>;
@@ -113,15 +113,15 @@ class V1Worker {
113
113
  : {};
114
114
  this.action_registry = Object.assign(Object.assign(Object.assign({}, this.action_registry), newActions), onFailureAction);
115
115
  }
116
- registerWorkflowV1(initWorkflow) {
117
- return __awaiter(this, void 0, void 0, function* () {
116
+ registerWorkflowV1(initWorkflow_1) {
117
+ return __awaiter(this, arguments, void 0, function* (initWorkflow, durable = false) {
118
118
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
119
119
  // patch the namespace
120
120
  const workflow = Object.assign(Object.assign({}, initWorkflow.definition), { name: (this.client.config.namespace + initWorkflow.definition.name).toLowerCase() });
121
121
  try {
122
122
  const { concurrency } = workflow;
123
123
  let onFailureTask;
124
- if (workflow.onFailure && typeof workflow.onFailure === 'function') {
124
+ if (!durable && workflow.onFailure && typeof workflow.onFailure === 'function') {
125
125
  onFailureTask = {
126
126
  readableId: 'on-failure-task',
127
127
  action: onFailureTaskName(workflow),
@@ -134,7 +134,7 @@ class V1Worker {
134
134
  concurrency: [],
135
135
  };
136
136
  }
137
- if (workflow.onFailure && typeof workflow.onFailure === 'object') {
137
+ if (!durable && workflow.onFailure && typeof workflow.onFailure === 'object') {
138
138
  const onFailure = workflow.onFailure;
139
139
  onFailureTask = {
140
140
  readableId: 'on-failure-task',
@@ -152,8 +152,8 @@ class V1Worker {
152
152
  };
153
153
  }
154
154
  let onSuccessTask;
155
- if (workflow.onSuccess && typeof workflow.onSuccess === 'function') {
156
- const parents = getLeaves(workflow._tasks);
155
+ if (!durable && workflow.onSuccess && typeof workflow.onSuccess === 'function') {
156
+ const parents = getLeaves([...workflow._tasks, ...workflow._durableTasks]);
157
157
  onSuccessTask = {
158
158
  name: 'on-success-task',
159
159
  fn: workflow.onSuccess,
@@ -165,9 +165,9 @@ class V1Worker {
165
165
  concurrency: [],
166
166
  };
167
167
  }
168
- if (workflow.onSuccess && typeof workflow.onSuccess === 'object') {
168
+ if (!durable && workflow.onSuccess && typeof workflow.onSuccess === 'object') {
169
169
  const onSuccess = workflow.onSuccess;
170
- const parents = getLeaves(workflow._tasks);
170
+ const parents = getLeaves([...workflow._tasks, ...workflow._durableTasks]);
171
171
  onSuccessTask = {
172
172
  name: 'on-success-task',
173
173
  fn: onSuccess.fn,
@@ -58,7 +58,7 @@ class Worker {
58
58
  if (!this.durable) {
59
59
  const opts = Object.assign(Object.assign({ name: `${this.name}-durable` }, this.config), { maxRuns: this.config.durableSlots || DEFAULT_DURABLE_SLOTS });
60
60
  this.durable = new worker_internal_1.V1Worker(this._v1, opts);
61
- yield this.durable.registerWorkflowV1(wf);
61
+ yield this.durable.registerWorkflowV1(wf, true);
62
62
  }
63
63
  this.durable.registerDurableActionsV1(wf.definition);
64
64
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hatchet_client_1 = require("../hatchet-client");
4
+ const workflow_1 = require("./workflow");
5
+ // > Create a filter
6
+ hatchet_client_1.hatchet.filters.create({
7
+ workflowId: workflow_1.lower.id,
8
+ expression: 'input.ShouldSkip == false',
9
+ scope: 'foobarbaz',
10
+ payload: {
11
+ main_character: 'Anna',
12
+ supporting_character: 'Stiva',
13
+ location: 'Moscow',
14
+ },
15
+ });
16
+ // !!
17
+ // > Skip a run
18
+ hatchet_client_1.hatchet.events.push(workflow_1.SIMPLE_EVENT, {
19
+ Message: 'hello',
20
+ ShouldSkip: true,
21
+ }, {
22
+ scope: 'foobarbaz',
23
+ });
24
+ // !!
25
+ // > Trigger a run
26
+ hatchet_client_1.hatchet.events.push(workflow_1.SIMPLE_EVENT, {
27
+ Message: 'hello',
28
+ ShouldSkip: false,
29
+ }, {
30
+ scope: 'foobarbaz',
31
+ });
32
+ // !!
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.6.1";
1
+ export declare const HATCHET_VERSION = "1.6.2";
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 = '1.6.1';
4
+ exports.HATCHET_VERSION = '1.6.2';