@hatchet-dev/typescript-sdk 0.17.1 → 0.18.0

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.
@@ -594,7 +594,22 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
594
594
  * @request GET:/api/v1/tenants/{tenant}/workflows
595
595
  * @secure
596
596
  */
597
- workflowList: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowList, any>>;
597
+ workflowList: (tenant: string, query?: {
598
+ /**
599
+ * The number to skip
600
+ * @format int
601
+ * @default 0
602
+ */
603
+ offset?: number;
604
+ /**
605
+ * The number to limit by
606
+ * @format int
607
+ * @default 50
608
+ */
609
+ limit?: number;
610
+ /** Search by name */
611
+ name?: string;
612
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowList, any>>;
598
613
  /**
599
614
  * @description Schedule a new workflow run for a tenant
600
615
  *
@@ -1223,4 +1238,13 @@ export declare class Api<SecurityDataType = unknown> extends HttpClient<Security
1223
1238
  * @secure
1224
1239
  */
1225
1240
  workflowRunGetInput: (tenant: string, workflowRun: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<Record<string, any>, any>>;
1241
+ /**
1242
+ * @description Triggers a workflow to check the status of the instance
1243
+ *
1244
+ * @name MonitoringPostRunProbe
1245
+ * @summary Detailed Health Probe For the Instance
1246
+ * @request POST:/api/v1/monitoring/{tenant}/probe
1247
+ * @secure
1248
+ */
1249
+ monitoringPostRunProbe: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
1226
1250
  }
@@ -551,7 +551,7 @@ class Api extends http_client_1.HttpClient {
551
551
  * @request GET:/api/v1/tenants/{tenant}/workflows
552
552
  * @secure
553
553
  */
554
- this.workflowList = (tenant, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows`, method: 'GET', secure: true, format: 'json' }, params));
554
+ this.workflowList = (tenant, query, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflows`, method: 'GET', query: query, secure: true, format: 'json' }, params));
555
555
  /**
556
556
  * @description Schedule a new workflow run for a tenant
557
557
  *
@@ -918,6 +918,15 @@ class Api extends http_client_1.HttpClient {
918
918
  * @secure
919
919
  */
920
920
  this.workflowRunGetInput = (tenant, workflowRun, params = {}) => this.request(Object.assign({ path: `/api/v1/tenants/${tenant}/workflow-runs/${workflowRun}/input`, method: 'GET', secure: true, format: 'json' }, params));
921
+ /**
922
+ * @description Triggers a workflow to check the status of the instance
923
+ *
924
+ * @name MonitoringPostRunProbe
925
+ * @summary Detailed Health Probe For the Instance
926
+ * @request POST:/api/v1/monitoring/{tenant}/probe
927
+ * @secure
928
+ */
929
+ this.monitoringPostRunProbe = (tenant, params = {}) => this.request(Object.assign({ path: `/api/v1/monitoring/${tenant}/probe`, method: 'POST', secure: true }, params));
921
930
  }
922
931
  }
923
932
  exports.Api = Api;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ const sdk_1 = __importDefault(require("../sdk"));
23
+ const hatchet = sdk_1.default.init();
24
+ function main() {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ var _a, e_1, _b, _c;
27
+ const workflowRunResponse = hatchet.admin.runWorkflow('sticky-workflow', {}, {
28
+ additionalMetadata: {
29
+ key: 'value',
30
+ },
31
+ });
32
+ const result = yield workflowRunResponse;
33
+ try {
34
+ for (var _d = true, _e = __asyncValues(yield result.stream()), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
35
+ _c = _f.value;
36
+ _d = false;
37
+ const event = _c;
38
+ console.log('event received', event);
39
+ }
40
+ }
41
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
42
+ finally {
43
+ try {
44
+ if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
45
+ }
46
+ finally { if (e_1) throw e_1.error; }
47
+ }
48
+ });
49
+ }
50
+ main();
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const sdk_1 = __importDefault(require("../sdk"));
16
+ const workflow_1 = require("../workflow");
17
+ const hatchet = sdk_1.default.init();
18
+ const workflow = {
19
+ id: 'sticky-workflow',
20
+ description: 'test',
21
+ steps: [
22
+ {
23
+ name: 'step1',
24
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
25
+ const results = [];
26
+ const count = 57;
27
+ hardChildWorkerId = undefined; // we reset this - if we run this multiple times at the same time it will break
28
+ // eslint-disable-next-line no-plusplus
29
+ for (let i = 0; i < count; i++) {
30
+ const result = yield ctx.spawnWorkflow(childWorkflow, {}, { sticky: true });
31
+ results.push(result.result());
32
+ const result2 = yield ctx.spawnWorkflow(softChildWorkflow, {}, { sticky: true });
33
+ results.push(result2.result());
34
+ }
35
+ console.log('Spawned ', count, ' child workflows of each type');
36
+ console.log('Results:', yield Promise.all(results));
37
+ return { step1: 'step1 results!' };
38
+ }),
39
+ },
40
+ ],
41
+ };
42
+ let hardChildWorkerId;
43
+ const childWorkflow = {
44
+ id: 'child-sticky-workflow',
45
+ description: 'test',
46
+ sticky: workflow_1.StickyStrategy.HARD,
47
+ steps: [
48
+ {
49
+ name: 'child-step1',
50
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
51
+ const workerId = ctx.worker.id();
52
+ console.log(`1: Worker ID: ${workerId}`);
53
+ if (!hardChildWorkerId) {
54
+ hardChildWorkerId = workerId;
55
+ }
56
+ else if (hardChildWorkerId !== workerId) {
57
+ throw new Error(`Expected worker ID ${hardChildWorkerId} but got ${workerId}`);
58
+ }
59
+ return { childStep1: `${workerId}` };
60
+ }),
61
+ },
62
+ {
63
+ name: 'child-step2',
64
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
65
+ const workerId = ctx.worker.id();
66
+ console.log(`2: Worker ID: ${workerId}`);
67
+ return { childStep2: `${workerId}` };
68
+ }),
69
+ },
70
+ ],
71
+ };
72
+ const softChildWorkflow = {
73
+ id: 'child-sticky-workflow-soft',
74
+ description: 'test',
75
+ sticky: workflow_1.StickyStrategy.SOFT,
76
+ steps: [
77
+ {
78
+ name: 'child-step1',
79
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
80
+ const workerId = ctx.worker.id();
81
+ console.log(`1: Worker ID: ${workerId}`);
82
+ return { childStep1: `SOFT ${workerId}` };
83
+ }),
84
+ },
85
+ {
86
+ name: 'child-step2',
87
+ run: (ctx) => __awaiter(void 0, void 0, void 0, function* () {
88
+ const workerId = ctx.worker.id();
89
+ console.log(`2: Worker ID: ${workerId}`);
90
+ return { childStep2: `SOFT ${workerId}` };
91
+ }),
92
+ },
93
+ ],
94
+ };
95
+ function main() {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ const worker1 = yield hatchet.worker('sticky-worker-1');
98
+ yield worker1.registerWorkflow(workflow);
99
+ yield worker1.registerWorkflow(childWorkflow);
100
+ yield worker1.registerWorkflow(softChildWorkflow);
101
+ worker1.start();
102
+ const worker2 = yield hatchet.worker('sticky-worker-2');
103
+ yield worker2.registerWorkflow(workflow);
104
+ yield worker2.registerWorkflow(childWorkflow);
105
+ yield worker2.registerWorkflow(softChildWorkflow);
106
+ worker2.start();
107
+ });
108
+ }
109
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.17.1",
3
+ "version": "0.18.0",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -41,6 +41,8 @@
41
41
  "worker:simple": "npm run exec -- ./src/examples/simple-worker.ts",
42
42
  "worker:affinity": "npm run exec -- ./src/examples/affinity-workers.ts",
43
43
  "worker:sticky": "npm run exec -- ./src/examples/sticky-worker.ts",
44
+ "worker:sticky-with-check": "npm run exec -- ./src/examples/sticky-worker-with-check.ts",
45
+ "trigger:sticky": "npm run exec -- ./src/examples/sticky-trigger.ts",
44
46
  "worker:on-failure": "npm run exec -- ./src/examples/on-failure.ts",
45
47
  "manual:trigger": "npm run exec -- ./src/examples/manual-trigger.ts",
46
48
  "manual:meta": "npm run exec -- ./src/examples/stream-by-additional-meta.ts",
@@ -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 v2.5.0
4
+ // protoc-gen-ts_proto v2.6.0
5
5
  // protoc v3.19.1
6
6
  // source: dispatcher/dispatcher.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 v2.5.0
4
+ // protoc-gen-ts_proto v2.6.0
5
5
  // protoc v3.19.1
6
6
  // source: events/events.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -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 v2.5.0
4
+ // protoc-gen-ts_proto v2.6.0
5
5
  // protoc v3.19.1
6
6
  // source: google/protobuf/timestamp.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -18,9 +18,12 @@ export declare function workflowKindFromJSON(object: any): WorkflowKind;
18
18
  export declare function workflowKindToJSON(object: WorkflowKind): string;
19
19
  export declare enum ConcurrencyLimitStrategy {
20
20
  CANCEL_IN_PROGRESS = 0,
21
+ /** DROP_NEWEST - deprecated */
21
22
  DROP_NEWEST = 1,
23
+ /** QUEUE_NEWEST - deprecated */
22
24
  QUEUE_NEWEST = 2,
23
25
  GROUP_ROUND_ROBIN = 3,
26
+ CANCEL_NEWEST = 4,
24
27
  UNRECOGNIZED = -1
25
28
  }
26
29
  export declare function concurrencyLimitStrategyFromJSON(object: any): ConcurrencyLimitStrategy;
@@ -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 v2.5.0
4
+ // protoc-gen-ts_proto v2.6.0
5
5
  // protoc v3.19.1
6
6
  // source: workflows/workflows.proto
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -91,9 +91,12 @@ function workflowKindToJSON(object) {
91
91
  var ConcurrencyLimitStrategy;
92
92
  (function (ConcurrencyLimitStrategy) {
93
93
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_IN_PROGRESS"] = 0] = "CANCEL_IN_PROGRESS";
94
+ /** DROP_NEWEST - deprecated */
94
95
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["DROP_NEWEST"] = 1] = "DROP_NEWEST";
96
+ /** QUEUE_NEWEST - deprecated */
95
97
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["QUEUE_NEWEST"] = 2] = "QUEUE_NEWEST";
96
98
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["GROUP_ROUND_ROBIN"] = 3] = "GROUP_ROUND_ROBIN";
99
+ ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["CANCEL_NEWEST"] = 4] = "CANCEL_NEWEST";
97
100
  ConcurrencyLimitStrategy[ConcurrencyLimitStrategy["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
98
101
  })(ConcurrencyLimitStrategy || (exports.ConcurrencyLimitStrategy = ConcurrencyLimitStrategy = {}));
99
102
  function concurrencyLimitStrategyFromJSON(object) {
@@ -110,6 +113,9 @@ function concurrencyLimitStrategyFromJSON(object) {
110
113
  case 3:
111
114
  case 'GROUP_ROUND_ROBIN':
112
115
  return ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN;
116
+ case 4:
117
+ case 'CANCEL_NEWEST':
118
+ return ConcurrencyLimitStrategy.CANCEL_NEWEST;
113
119
  case -1:
114
120
  case 'UNRECOGNIZED':
115
121
  default:
@@ -126,6 +132,8 @@ function concurrencyLimitStrategyToJSON(object) {
126
132
  return 'QUEUE_NEWEST';
127
133
  case ConcurrencyLimitStrategy.GROUP_ROUND_ROBIN:
128
134
  return 'GROUP_ROUND_ROBIN';
135
+ case ConcurrencyLimitStrategy.CANCEL_NEWEST:
136
+ return 'CANCEL_NEWEST';
129
137
  case ConcurrencyLimitStrategy.UNRECOGNIZED:
130
138
  default:
131
139
  return 'UNRECOGNIZED';
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "0.17.1";
1
+ export declare const HATCHET_VERSION = "0.18.0";
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.1';
4
+ exports.HATCHET_VERSION = '0.18.0';