@hatchet-dev/typescript-sdk 1.5.3 → 1.5.4

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.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
@@ -158,7 +158,12 @@ export interface AssignedAction {
158
158
  childWorkflowKey?: string | undefined;
159
159
  /** (optional) the parent workflow run id (if this is a child workflow) */
160
160
  parentWorkflowRunId?: string | undefined;
161
+ /** (optional) the priority of the run */
161
162
  priority: number;
163
+ /** (optional) the workflow id */
164
+ workflowId?: string | undefined;
165
+ /** (optional) the workflow version id */
166
+ workflowVersionId?: string | undefined;
162
167
  }
163
168
  export interface WorkerListenRequest {
164
169
  /** the id of the worker */
@@ -1094,6 +1094,8 @@ function createBaseAssignedAction() {
1094
1094
  childWorkflowKey: undefined,
1095
1095
  parentWorkflowRunId: undefined,
1096
1096
  priority: 0,
1097
+ workflowId: undefined,
1098
+ workflowVersionId: undefined,
1097
1099
  };
1098
1100
  }
1099
1101
  exports.AssignedAction = {
@@ -1152,6 +1154,12 @@ exports.AssignedAction = {
1152
1154
  if (message.priority !== 0) {
1153
1155
  writer.uint32(144).int32(message.priority);
1154
1156
  }
1157
+ if (message.workflowId !== undefined) {
1158
+ writer.uint32(154).string(message.workflowId);
1159
+ }
1160
+ if (message.workflowVersionId !== undefined) {
1161
+ writer.uint32(162).string(message.workflowVersionId);
1162
+ }
1155
1163
  return writer;
1156
1164
  },
1157
1165
  decode(input, length) {
@@ -1287,6 +1295,20 @@ exports.AssignedAction = {
1287
1295
  message.priority = reader.int32();
1288
1296
  continue;
1289
1297
  }
1298
+ case 19: {
1299
+ if (tag !== 154) {
1300
+ break;
1301
+ }
1302
+ message.workflowId = reader.string();
1303
+ continue;
1304
+ }
1305
+ case 20: {
1306
+ if (tag !== 162) {
1307
+ break;
1308
+ }
1309
+ message.workflowVersionId = reader.string();
1310
+ continue;
1311
+ }
1290
1312
  }
1291
1313
  if ((tag & 7) === 4 || tag === 0) {
1292
1314
  break;
@@ -1325,6 +1347,10 @@ exports.AssignedAction = {
1325
1347
  ? globalThis.String(object.parentWorkflowRunId)
1326
1348
  : undefined,
1327
1349
  priority: isSet(object.priority) ? globalThis.Number(object.priority) : 0,
1350
+ workflowId: isSet(object.workflowId) ? globalThis.String(object.workflowId) : undefined,
1351
+ workflowVersionId: isSet(object.workflowVersionId)
1352
+ ? globalThis.String(object.workflowVersionId)
1353
+ : undefined,
1328
1354
  };
1329
1355
  },
1330
1356
  toJSON(message) {
@@ -1383,13 +1409,19 @@ exports.AssignedAction = {
1383
1409
  if (message.priority !== 0) {
1384
1410
  obj.priority = Math.round(message.priority);
1385
1411
  }
1412
+ if (message.workflowId !== undefined) {
1413
+ obj.workflowId = message.workflowId;
1414
+ }
1415
+ if (message.workflowVersionId !== undefined) {
1416
+ obj.workflowVersionId = message.workflowVersionId;
1417
+ }
1386
1418
  return obj;
1387
1419
  },
1388
1420
  create(base) {
1389
1421
  return exports.AssignedAction.fromPartial(base !== null && base !== void 0 ? base : {});
1390
1422
  },
1391
1423
  fromPartial(object) {
1392
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
1424
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
1393
1425
  const message = createBaseAssignedAction();
1394
1426
  message.tenantId = (_a = object.tenantId) !== null && _a !== void 0 ? _a : '';
1395
1427
  message.workflowRunId = (_b = object.workflowRunId) !== null && _b !== void 0 ? _b : '';
@@ -1409,6 +1441,8 @@ exports.AssignedAction = {
1409
1441
  message.childWorkflowKey = (_r = object.childWorkflowKey) !== null && _r !== void 0 ? _r : undefined;
1410
1442
  message.parentWorkflowRunId = (_s = object.parentWorkflowRunId) !== null && _s !== void 0 ? _s : undefined;
1411
1443
  message.priority = (_t = object.priority) !== null && _t !== void 0 ? _t : 0;
1444
+ message.workflowId = (_u = object.workflowId) !== null && _u !== void 0 ? _u : undefined;
1445
+ message.workflowVersionId = (_v = object.workflowVersionId) !== null && _v !== void 0 ? _v : undefined;
1412
1446
  return message;
1413
1447
  },
1414
1448
  };
@@ -41,6 +41,7 @@ export declare class Context<T, K = {}> {
41
41
  constructor(action: Action, v1: HatchetClient, worker: V1Worker);
42
42
  get abortController(): AbortController;
43
43
  get cancelled(): boolean;
44
+ cancel(): Promise<void>;
44
45
  /**
45
46
  * Retrieves the output of a parent task.
46
47
  * @param parentTask - The a CreateTaskOpts or string of the parent task name.
@@ -91,6 +92,16 @@ export declare class Context<T, K = {}> {
91
92
  * @returns The workflow run ID.
92
93
  */
93
94
  workflowRunId(): string;
95
+ /**
96
+ * Gets the workflow ID of the currently running workflow.
97
+ * @returns The workflow id.
98
+ */
99
+ workflowId(): string | undefined;
100
+ /**
101
+ * Gets the workflow version ID of the currently running workflow.
102
+ * @returns The workflow version ID.
103
+ */
104
+ workflowVersionId(): string | undefined;
94
105
  /**
95
106
  * Gets the ID of the current task run.
96
107
  * @returns The task run ID.
@@ -54,6 +54,15 @@ class Context {
54
54
  get cancelled() {
55
55
  return this.controller.signal.aborted;
56
56
  }
57
+ cancel() {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ yield this.v1.runs.cancel({
60
+ ids: [this.action.stepRunId],
61
+ });
62
+ // optimistically abort the run
63
+ this.controller.abort();
64
+ });
65
+ }
57
66
  /**
58
67
  * Retrieves the output of a parent task.
59
68
  * @param parentTask - The a CreateTaskOpts or string of the parent task name.
@@ -140,6 +149,20 @@ class Context {
140
149
  workflowRunId() {
141
150
  return this.action.workflowRunId;
142
151
  }
152
+ /**
153
+ * Gets the workflow ID of the currently running workflow.
154
+ * @returns The workflow id.
155
+ */
156
+ workflowId() {
157
+ return this.action.workflowId;
158
+ }
159
+ /**
160
+ * Gets the workflow version ID of the currently running workflow.
161
+ * @returns The workflow version ID.
162
+ */
163
+ workflowVersionId() {
164
+ return this.action.workflowVersionId;
165
+ }
143
166
  /**
144
167
  * Gets the ID of the current task run.
145
168
  * @returns The task run ID.
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "1.5.3";
1
+ export declare const HATCHET_VERSION = "1.5.4";
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.5.3';
4
+ exports.HATCHET_VERSION = '1.5.4';