@hatchet-dev/typescript-sdk 1.23.1 → 1.24.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.
- package/package.json +1 -1
- package/v1/client/features/runs.d.ts +27 -0
- package/v1/client/features/runs.js +68 -1
- package/v1/index.d.ts +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
package/package.json
CHANGED
|
@@ -3,6 +3,24 @@ import { V1TaskStatus } from '../../../clients/rest/generated/data-contracts';
|
|
|
3
3
|
import { RunListenerClient } from '../../../clients/listeners/run-listener/child-listener-client';
|
|
4
4
|
import { WorkflowsClient } from './workflows';
|
|
5
5
|
import { HatchetClient } from '../client';
|
|
6
|
+
import { runStatusToJSON } from '../../../protoc/v1/workflows';
|
|
7
|
+
export type RunDetail = {
|
|
8
|
+
status: V1TaskStatus;
|
|
9
|
+
done: boolean;
|
|
10
|
+
input: unknown;
|
|
11
|
+
additionalMetadata: unknown;
|
|
12
|
+
isEvicted: boolean;
|
|
13
|
+
taskRuns: Record<string, TaskRunDetail>;
|
|
14
|
+
};
|
|
15
|
+
export type TaskRunDetail = {
|
|
16
|
+
externalId: string;
|
|
17
|
+
readableId: string;
|
|
18
|
+
status: V1TaskStatus;
|
|
19
|
+
output: unknown;
|
|
20
|
+
error?: string;
|
|
21
|
+
isEvicted: boolean;
|
|
22
|
+
};
|
|
23
|
+
export { runStatusToJSON };
|
|
6
24
|
export type RunFilter = {
|
|
7
25
|
since?: Date;
|
|
8
26
|
until?: Date;
|
|
@@ -72,7 +90,10 @@ export declare class RunsClient {
|
|
|
72
90
|
tenantId: string;
|
|
73
91
|
workflows: WorkflowsClient;
|
|
74
92
|
listener: RunListenerClient;
|
|
93
|
+
private _config;
|
|
94
|
+
private _adminGrpc;
|
|
75
95
|
constructor(client: HatchetClient);
|
|
96
|
+
private get adminGrpc();
|
|
76
97
|
/**
|
|
77
98
|
* Gets a task or workflow run by its ID.
|
|
78
99
|
* @param run - The ID of the run to get.
|
|
@@ -85,6 +106,12 @@ export declare class RunsClient {
|
|
|
85
106
|
* @returns A promise that resolves to the status of the run.
|
|
86
107
|
*/
|
|
87
108
|
get_status<T = any>(run: string | WorkflowRunRef<T>): Promise<V1TaskStatus>;
|
|
109
|
+
/**
|
|
110
|
+
* Gets run details
|
|
111
|
+
* @param run - The workflow run ID (string) or a WorkflowRunRef.
|
|
112
|
+
* @returns A promise resolving to GetRunDetailsResponse with task run statuses and outputs.
|
|
113
|
+
*/
|
|
114
|
+
getDetails<T = any>(run: string | WorkflowRunRef<T>): Promise<RunDetail>;
|
|
88
115
|
/**
|
|
89
116
|
* Lists all task and workflow runs for the current tenant.
|
|
90
117
|
* @param opts - The options for the list operation.
|
|
@@ -32,9 +32,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
32
32
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
33
|
};
|
|
34
34
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
-
exports.RunsClient = void 0;
|
|
35
|
+
exports.RunsClient = exports.runStatusToJSON = void 0;
|
|
36
36
|
const workflow_run_ref_1 = __importDefault(require("../../../util/workflow-run-ref"));
|
|
37
|
+
const data_contracts_1 = require("../../../clients/rest/generated/data-contracts");
|
|
37
38
|
const child_listener_client_1 = require("../../../clients/listeners/run-listener/child-listener-client");
|
|
39
|
+
const workflows_1 = require("../../../protoc/v1/workflows");
|
|
40
|
+
Object.defineProperty(exports, "runStatusToJSON", { enumerable: true, get: function () { return workflows_1.runStatusToJSON; } });
|
|
41
|
+
const grpc_helpers_1 = require("../../../util/grpc-helpers");
|
|
42
|
+
// EVICTED is not in V1TaskStatus; treat as RUNNING per the proto comment.
|
|
43
|
+
const PROTO_STATUS_MAP = {
|
|
44
|
+
[workflows_1.RunStatus.QUEUED]: data_contracts_1.V1TaskStatus.QUEUED,
|
|
45
|
+
[workflows_1.RunStatus.RUNNING]: data_contracts_1.V1TaskStatus.RUNNING,
|
|
46
|
+
[workflows_1.RunStatus.COMPLETED]: data_contracts_1.V1TaskStatus.COMPLETED,
|
|
47
|
+
[workflows_1.RunStatus.FAILED]: data_contracts_1.V1TaskStatus.FAILED,
|
|
48
|
+
[workflows_1.RunStatus.CANCELLED]: data_contracts_1.V1TaskStatus.CANCELLED,
|
|
49
|
+
[workflows_1.RunStatus.EVICTED]: data_contracts_1.V1TaskStatus.RUNNING,
|
|
50
|
+
[workflows_1.RunStatus.UNRECOGNIZED]: data_contracts_1.V1TaskStatus.RUNNING,
|
|
51
|
+
};
|
|
52
|
+
function decodeBytes(b) {
|
|
53
|
+
if (!(b === null || b === void 0 ? void 0 : b.length))
|
|
54
|
+
return null;
|
|
55
|
+
try {
|
|
56
|
+
return JSON.parse(new TextDecoder().decode(b));
|
|
57
|
+
}
|
|
58
|
+
catch (_a) {
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function toRunDetail(raw) {
|
|
63
|
+
var _a;
|
|
64
|
+
return {
|
|
65
|
+
status: (_a = PROTO_STATUS_MAP[raw.status]) !== null && _a !== void 0 ? _a : data_contracts_1.V1TaskStatus.RUNNING,
|
|
66
|
+
done: raw.done,
|
|
67
|
+
input: decodeBytes(raw.input),
|
|
68
|
+
additionalMetadata: decodeBytes(raw.additionalMetadata),
|
|
69
|
+
isEvicted: raw.isEvicted,
|
|
70
|
+
taskRuns: Object.fromEntries(Object.entries(raw.taskRuns).map(([id, tr]) => {
|
|
71
|
+
var _a;
|
|
72
|
+
return [
|
|
73
|
+
id,
|
|
74
|
+
{
|
|
75
|
+
externalId: tr.externalId,
|
|
76
|
+
readableId: tr.readableId,
|
|
77
|
+
status: (_a = PROTO_STATUS_MAP[tr.status]) !== null && _a !== void 0 ? _a : data_contracts_1.V1TaskStatus.RUNNING,
|
|
78
|
+
output: decodeBytes(tr.output),
|
|
79
|
+
error: tr.error,
|
|
80
|
+
isEvicted: tr.isEvicted,
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
})),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
38
86
|
/**
|
|
39
87
|
* The runs client is a client for interacting with task and workflow runs within Hatchet.
|
|
40
88
|
*/
|
|
@@ -44,6 +92,14 @@ class RunsClient {
|
|
|
44
92
|
this.tenantId = client.tenantId;
|
|
45
93
|
this.workflows = client.workflows;
|
|
46
94
|
this.listener = client._listener;
|
|
95
|
+
this._config = client.config;
|
|
96
|
+
}
|
|
97
|
+
get adminGrpc() {
|
|
98
|
+
if (!this._adminGrpc) {
|
|
99
|
+
const { client } = (0, grpc_helpers_1.createGrpcClient)(this._config, workflows_1.AdminServiceDefinition);
|
|
100
|
+
this._adminGrpc = client;
|
|
101
|
+
}
|
|
102
|
+
return this._adminGrpc;
|
|
47
103
|
}
|
|
48
104
|
/**
|
|
49
105
|
* Gets a task or workflow run by its ID.
|
|
@@ -69,6 +125,17 @@ class RunsClient {
|
|
|
69
125
|
return data;
|
|
70
126
|
});
|
|
71
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Gets run details
|
|
130
|
+
* @param run - The workflow run ID (string) or a WorkflowRunRef.
|
|
131
|
+
* @returns A promise resolving to GetRunDetailsResponse with task run statuses and outputs.
|
|
132
|
+
*/
|
|
133
|
+
getDetails(run) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const runId = typeof run === 'string' ? run : yield run.getWorkflowRunId();
|
|
136
|
+
return toRunDetail(yield this.adminGrpc.getRunDetails({ externalId: runId }));
|
|
137
|
+
});
|
|
138
|
+
}
|
|
72
139
|
/**
|
|
73
140
|
* Lists all task and workflow runs for the current tenant.
|
|
74
141
|
* @param opts - The options for the list operation.
|
package/v1/index.d.ts
CHANGED
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "1.
|
|
1
|
+
export declare const HATCHET_VERSION = "1.24.0";
|
package/version.js
CHANGED