@hatchet-dev/typescript-sdk 0.8.0-alpha.2 → 0.8.0-alpha.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/clients/admin/admin-client.d.ts +82 -14
- package/clients/admin/admin-client.js +114 -28
- package/clients/dispatcher/heartbeat/heartbeat-controller.d.ts +0 -1
- package/clients/hatchet-client/hatchet-client.d.ts +1 -1
- package/clients/hatchet-client/hatchet-client.js +4 -4
- package/clients/listener/child-listener-client.d.ts +0 -1
- package/clients/listener/listener-client.d.ts +6 -14
- package/clients/listener/listener-client.js +16 -85
- package/clients/rest/generated/Api.d.ts +44 -117
- package/clients/rest/generated/Api.js +34 -112
- package/clients/rest/generated/data-contracts.d.ts +33 -54
- package/clients/rest/generated/http-client.js +2 -2
- package/clients/worker/handler.d.ts +5 -3
- package/clients/worker/handler.js +72 -31
- package/clients/worker/worker.d.ts +6 -4
- package/clients/worker/worker.js +18 -14
- package/index.d.ts +1 -0
- package/index.js +1 -0
- package/package.json +2 -2
- package/protoc/dispatcher/dispatcher.js +14 -14
- package/protoc/events/events.js +1 -1
- package/protoc/google/protobuf/timestamp.js +1 -1
- package/protoc/workflows/workflows.js +6 -6
- package/step.d.ts +12 -14
- package/step.js +13 -70
- package/util/config-loader/token.js +2 -3
- package/util/parse.js +1 -2
- package/util/retrier.js +1 -2
- package/util/thread-helper.d.ts +0 -1
- package/util/thread-helper.js +1 -2
- package/util/workflow-run-ref.d.ts +17 -0
- package/util/workflow-run-ref.js +94 -0
- package/workflow.d.ts +12 -12
- package/workflow.js +1 -1
|
@@ -2,8 +2,10 @@ import { Channel, ClientFactory } from 'nice-grpc';
|
|
|
2
2
|
import { CreateWorkflowVersionOpts, RateLimitDuration, WorkflowServiceClient } from '../../protoc/workflows';
|
|
3
3
|
import { ClientConfig } from '../hatchet-client/client-config';
|
|
4
4
|
import { Logger } from '../../util/logger';
|
|
5
|
+
import WorkflowRunRef from '../../util/workflow-run-ref';
|
|
5
6
|
import { Api } from '../rest';
|
|
6
|
-
import { WebhookWorkerCreateRequest, WorkflowRunStatus } from '../rest/generated/data-contracts';
|
|
7
|
+
import { WebhookWorkerCreateRequest, WorkflowRunStatus, WorkflowRunStatusList } from '../rest/generated/data-contracts';
|
|
8
|
+
import { ListenerClient } from '../listener/listener-client';
|
|
7
9
|
type WorkflowMetricsQuery = {
|
|
8
10
|
workflowId?: string;
|
|
9
11
|
workflowName?: string;
|
|
@@ -32,72 +34,138 @@ export declare class AdminClient {
|
|
|
32
34
|
api: Api;
|
|
33
35
|
tenantId: string;
|
|
34
36
|
logger: Logger;
|
|
35
|
-
|
|
37
|
+
listenerClient: ListenerClient;
|
|
38
|
+
constructor(config: ClientConfig, channel: Channel, factory: ClientFactory, api: Api, tenantId: string, listenerClient: ListenerClient);
|
|
39
|
+
/**
|
|
40
|
+
* @deprecated use putWorkflow instead
|
|
41
|
+
*/
|
|
42
|
+
put_workflow(opts: CreateWorkflowVersionOpts): Promise<void>;
|
|
36
43
|
/**
|
|
37
44
|
* Creates a new workflow or updates an existing workflow. If the workflow already exists, Hatchet will automatically
|
|
38
45
|
* determine if the workflow definition has changed and create a new version if necessary.
|
|
39
46
|
* @param workflow a workflow definition to create
|
|
40
47
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
putWorkflow(workflow: CreateWorkflowVersionOpts): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* @deprecated use putRateLimit instead
|
|
51
|
+
*/
|
|
52
|
+
put_rate_limit(key: string, limit: number, duration: RateLimitDuration): Promise<void>;
|
|
53
|
+
putRateLimit(key: string, limit: number, duration?: RateLimitDuration): Promise<void>;
|
|
54
|
+
webhook_create(data: WebhookWorkerCreateRequest): Promise<import("axios").AxiosResponse<import("../rest/generated/data-contracts").WebhookWorkerCreated, any>>;
|
|
55
|
+
/**
|
|
56
|
+
* @deprecated use runWorkflow instead
|
|
57
|
+
*/
|
|
58
|
+
run_workflow<T = object>(workflowName: string, input: T, options?: {
|
|
59
|
+
parentId?: string | undefined;
|
|
60
|
+
parentStepRunId?: string | undefined;
|
|
61
|
+
childIndex?: number | undefined;
|
|
62
|
+
childKey?: string | undefined;
|
|
63
|
+
additionalMetadata?: Record<string, string> | undefined;
|
|
64
|
+
}): Promise<WorkflowRunRef<object>>;
|
|
44
65
|
/**
|
|
45
66
|
* Run a new instance of a workflow with the given input. This will create a new workflow run and return the ID of the
|
|
46
67
|
* new run.
|
|
47
68
|
* @param workflowName the name of the workflow to run
|
|
48
69
|
* @param input an object containing the input to the workflow
|
|
70
|
+
* @param options an object containing the options to run the workflow
|
|
49
71
|
* @returns the ID of the new workflow run
|
|
50
72
|
*/
|
|
51
|
-
|
|
73
|
+
runWorkflow<Q = object, P = object>(workflowName: string, input: Q, options?: {
|
|
52
74
|
parentId?: string | undefined;
|
|
53
75
|
parentStepRunId?: string | undefined;
|
|
54
76
|
childIndex?: number | undefined;
|
|
55
77
|
childKey?: string | undefined;
|
|
56
78
|
additionalMetadata?: Record<string, string> | undefined;
|
|
57
|
-
}):
|
|
79
|
+
}): WorkflowRunRef<P>;
|
|
80
|
+
/**
|
|
81
|
+
* @deprecated use listWorkflows instead
|
|
82
|
+
*/
|
|
83
|
+
list_workflows(): Promise<import("../rest/generated/data-contracts").WorkflowList>;
|
|
58
84
|
/**
|
|
59
85
|
* List workflows in the tenant associated with the API token.
|
|
60
86
|
* @returns a list of all workflows in the tenant
|
|
61
87
|
*/
|
|
62
|
-
|
|
88
|
+
listWorkflows(): Promise<import("../rest/generated/data-contracts").WorkflowList>;
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated use getWorkflow instead
|
|
91
|
+
*/
|
|
92
|
+
get_workflow(workflowId: string): Promise<import("../rest/generated/data-contracts").Workflow>;
|
|
63
93
|
/**
|
|
64
94
|
* Get a workflow by its ID.
|
|
65
95
|
* @param workflowId the workflow ID (**note:** this is not the same as the workflow version id)
|
|
66
96
|
* @returns
|
|
67
97
|
*/
|
|
68
|
-
|
|
98
|
+
getWorkflow(workflowId: string): Promise<import("../rest/generated/data-contracts").Workflow>;
|
|
99
|
+
/**
|
|
100
|
+
* @deprecated use getWorkflowVersion instead
|
|
101
|
+
*/
|
|
102
|
+
get_workflow_version(workflowId: string, version?: string): Promise<import("../rest/generated/data-contracts").WorkflowVersion>;
|
|
69
103
|
/**
|
|
70
104
|
* Get a workflow version.
|
|
71
105
|
* @param workflowId the workflow ID
|
|
72
106
|
* @param version the version of the workflow to get. If not provided, the latest version will be returned.
|
|
73
107
|
* @returns the workflow version
|
|
74
108
|
*/
|
|
75
|
-
|
|
109
|
+
getWorkflowVersion(workflowId: string, version?: string): Promise<import("../rest/generated/data-contracts").WorkflowVersion>;
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated use getWorkflowRun instead
|
|
112
|
+
*/
|
|
113
|
+
get_workflow_run(workflowRunId: string): Promise<WorkflowRunRef<unknown>>;
|
|
76
114
|
/**
|
|
77
115
|
* Get a workflow run.
|
|
78
116
|
* @param workflowRunId the id of the workflow run to get
|
|
79
117
|
* @returns the workflow run
|
|
80
118
|
*/
|
|
81
|
-
|
|
119
|
+
getWorkflowRun(workflowRunId: string): Promise<WorkflowRunRef<unknown>>;
|
|
120
|
+
/**
|
|
121
|
+
* @deprecated use listWorkflowRuns instead
|
|
122
|
+
*/
|
|
123
|
+
list_workflow_runs(query: {
|
|
124
|
+
offset?: number | undefined;
|
|
125
|
+
limit?: number | undefined;
|
|
126
|
+
eventId?: string | undefined;
|
|
127
|
+
workflowId?: string | undefined;
|
|
128
|
+
parentWorkflowRunId?: string | undefined;
|
|
129
|
+
parentStepRunId?: string | undefined;
|
|
130
|
+
statuses?: WorkflowRunStatusList | undefined;
|
|
131
|
+
additionalMetadata?: string[] | undefined;
|
|
132
|
+
}): Promise<import("../rest/generated/data-contracts").WorkflowRunList>;
|
|
82
133
|
/**
|
|
83
134
|
* List workflow runs in the tenant associated with the API token.
|
|
84
135
|
* @param query the query to filter the list of workflow runs
|
|
85
136
|
* @returns
|
|
86
137
|
*/
|
|
87
|
-
|
|
138
|
+
listWorkflowRuns(query: {
|
|
88
139
|
offset?: number | undefined;
|
|
89
140
|
limit?: number | undefined;
|
|
90
141
|
eventId?: string | undefined;
|
|
91
142
|
workflowId?: string | undefined;
|
|
143
|
+
parentWorkflowRunId?: string | undefined;
|
|
144
|
+
parentStepRunId?: string | undefined;
|
|
145
|
+
statuses?: WorkflowRunStatusList | undefined;
|
|
146
|
+
additionalMetadata?: string[] | undefined;
|
|
92
147
|
}): Promise<import("../rest/generated/data-contracts").WorkflowRunList>;
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated use scheduleWorkflow instead
|
|
150
|
+
*/
|
|
151
|
+
schedule_workflow(name: string, options?: {
|
|
152
|
+
schedules?: Date[];
|
|
153
|
+
input?: object;
|
|
154
|
+
}): Promise<void>;
|
|
93
155
|
/**
|
|
94
156
|
* Schedule a workflow to run at a specific time or times.
|
|
95
157
|
* @param name the name of the workflow to schedule
|
|
96
158
|
* @param options an object containing the schedules to set
|
|
159
|
+
* @param input an object containing the input to the workflow
|
|
97
160
|
*/
|
|
98
|
-
|
|
161
|
+
scheduleWorkflow(name: string, options?: {
|
|
99
162
|
schedules?: Date[];
|
|
163
|
+
input?: object;
|
|
100
164
|
}): void;
|
|
165
|
+
/**
|
|
166
|
+
* @deprecated use getWorkflowMetrics instead
|
|
167
|
+
*/
|
|
168
|
+
get_workflow_metrics(data: WorkflowMetricsQuery): Promise<import("axios").AxiosResponse<import("../rest/generated/data-contracts").WorkflowMetrics, any>>;
|
|
101
169
|
/**
|
|
102
170
|
* Get the metrics for a workflow.
|
|
103
171
|
*
|
|
@@ -105,6 +173,6 @@ export declare class AdminClient {
|
|
|
105
173
|
* @param workflowName the name of the workflow to get metrics for
|
|
106
174
|
* @param query an object containing query parameters to filter the metrics
|
|
107
175
|
*/
|
|
108
|
-
|
|
176
|
+
getWorkflowMetrics({ workflowId, workflowName, status, groupKey }: WorkflowMetricsQuery): Promise<import("axios").AxiosResponse<import("../rest/generated/data-contracts").WorkflowMetrics, any>>;
|
|
109
177
|
}
|
|
110
178
|
export {};
|
|
@@ -17,6 +17,7 @@ const workflows_1 = require("../../protoc/workflows");
|
|
|
17
17
|
const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
|
|
18
18
|
const logger_1 = require("../../util/logger");
|
|
19
19
|
const retrier_1 = require("../../util/retrier");
|
|
20
|
+
const workflow_run_ref_1 = __importDefault(require("../../util/workflow-run-ref"));
|
|
20
21
|
/**
|
|
21
22
|
* AdminClient is a client for interacting with the Hatchet Admin API. This allows you to configure, trigger,
|
|
22
23
|
* and monitor workflows.
|
|
@@ -34,19 +35,28 @@ const retrier_1 = require("../../util/retrier");
|
|
|
34
35
|
* ```
|
|
35
36
|
*/
|
|
36
37
|
class AdminClient {
|
|
37
|
-
constructor(config, channel, factory, api, tenantId) {
|
|
38
|
+
constructor(config, channel, factory, api, tenantId, listenerClient) {
|
|
38
39
|
this.config = config;
|
|
39
40
|
this.client = factory.create(workflows_1.WorkflowServiceDefinition, channel);
|
|
40
41
|
this.api = api;
|
|
41
42
|
this.tenantId = tenantId;
|
|
42
43
|
this.logger = new logger_1.Logger(`Admin`, config.log_level);
|
|
44
|
+
this.listenerClient = listenerClient;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* @deprecated use putWorkflow instead
|
|
48
|
+
*/
|
|
49
|
+
put_workflow(opts) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return this.putWorkflow(opts);
|
|
52
|
+
});
|
|
43
53
|
}
|
|
44
54
|
/**
|
|
45
55
|
* Creates a new workflow or updates an existing workflow. If the workflow already exists, Hatchet will automatically
|
|
46
56
|
* determine if the workflow definition has changed and create a new version if necessary.
|
|
47
57
|
* @param workflow a workflow definition to create
|
|
48
58
|
*/
|
|
49
|
-
|
|
59
|
+
putWorkflow(workflow) {
|
|
50
60
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
61
|
try {
|
|
52
62
|
yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () { return this.client.putWorkflow({ opts: workflow }); }), this.logger);
|
|
@@ -56,7 +66,15 @@ class AdminClient {
|
|
|
56
66
|
}
|
|
57
67
|
});
|
|
58
68
|
}
|
|
59
|
-
|
|
69
|
+
/**
|
|
70
|
+
* @deprecated use putRateLimit instead
|
|
71
|
+
*/
|
|
72
|
+
put_rate_limit(key, limit, duration) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
return this.putRateLimit(key, limit, duration);
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
putRateLimit(key_1, limit_1) {
|
|
60
78
|
return __awaiter(this, arguments, void 0, function* (key, limit, duration = workflows_1.RateLimitDuration.SECOND) {
|
|
61
79
|
try {
|
|
62
80
|
yield (0, retrier_1.retrier)(() => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -77,59 +95,90 @@ class AdminClient {
|
|
|
77
95
|
return this.api.webhookCreate(this.tenantId, data);
|
|
78
96
|
});
|
|
79
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* @deprecated use runWorkflow instead
|
|
100
|
+
*/
|
|
101
|
+
run_workflow(workflowName, input, options) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
return this.runWorkflow(workflowName, input, options);
|
|
104
|
+
});
|
|
105
|
+
}
|
|
80
106
|
/**
|
|
81
107
|
* Run a new instance of a workflow with the given input. This will create a new workflow run and return the ID of the
|
|
82
108
|
* new run.
|
|
83
109
|
* @param workflowName the name of the workflow to run
|
|
84
110
|
* @param input an object containing the input to the workflow
|
|
111
|
+
* @param options an object containing the options to run the workflow
|
|
85
112
|
* @returns the ID of the new workflow run
|
|
86
113
|
*/
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
computedName = this.config.namespace + workflowName;
|
|
93
|
-
}
|
|
94
|
-
const inputStr = JSON.stringify(input);
|
|
95
|
-
const resp = yield this.client.triggerWorkflow(Object.assign(Object.assign({ name: computedName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
96
|
-
? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
97
|
-
: undefined }));
|
|
98
|
-
return resp.workflowRunId;
|
|
99
|
-
}
|
|
100
|
-
catch (e) {
|
|
101
|
-
throw new hatchet_error_1.default(e.message);
|
|
114
|
+
runWorkflow(workflowName, input, options) {
|
|
115
|
+
let computedName = workflowName;
|
|
116
|
+
try {
|
|
117
|
+
if (this.config.namespace && !workflowName.startsWith(this.config.namespace)) {
|
|
118
|
+
computedName = this.config.namespace + workflowName;
|
|
102
119
|
}
|
|
120
|
+
const inputStr = JSON.stringify(input);
|
|
121
|
+
const resp = this.client.triggerWorkflow(Object.assign(Object.assign({ name: computedName, input: inputStr }, options), { additionalMetadata: (options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
122
|
+
? JSON.stringify(options === null || options === void 0 ? void 0 : options.additionalMetadata)
|
|
123
|
+
: undefined }));
|
|
124
|
+
return new workflow_run_ref_1.default(resp, this.listenerClient, options === null || options === void 0 ? void 0 : options.parentId);
|
|
125
|
+
}
|
|
126
|
+
catch (e) {
|
|
127
|
+
throw new hatchet_error_1.default(e.message);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated use listWorkflows instead
|
|
132
|
+
*/
|
|
133
|
+
list_workflows() {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
return this.listWorkflows();
|
|
103
136
|
});
|
|
104
137
|
}
|
|
105
138
|
/**
|
|
106
139
|
* List workflows in the tenant associated with the API token.
|
|
107
140
|
* @returns a list of all workflows in the tenant
|
|
108
141
|
*/
|
|
109
|
-
|
|
142
|
+
listWorkflows() {
|
|
110
143
|
return __awaiter(this, void 0, void 0, function* () {
|
|
111
144
|
const res = yield this.api.workflowList(this.tenantId);
|
|
112
145
|
return res.data;
|
|
113
146
|
});
|
|
114
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated use getWorkflow instead
|
|
150
|
+
*/
|
|
151
|
+
get_workflow(workflowId) {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
return this.getWorkflow(workflowId);
|
|
154
|
+
});
|
|
155
|
+
}
|
|
115
156
|
/**
|
|
116
157
|
* Get a workflow by its ID.
|
|
117
158
|
* @param workflowId the workflow ID (**note:** this is not the same as the workflow version id)
|
|
118
159
|
* @returns
|
|
119
160
|
*/
|
|
120
|
-
|
|
161
|
+
getWorkflow(workflowId) {
|
|
121
162
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
163
|
const res = yield this.api.workflowGet(workflowId);
|
|
123
164
|
return res.data;
|
|
124
165
|
});
|
|
125
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated use getWorkflowVersion instead
|
|
169
|
+
*/
|
|
170
|
+
get_workflow_version(workflowId, version) {
|
|
171
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
172
|
+
return this.getWorkflowVersion(workflowId, version);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
126
175
|
/**
|
|
127
176
|
* Get a workflow version.
|
|
128
177
|
* @param workflowId the workflow ID
|
|
129
178
|
* @param version the version of the workflow to get. If not provided, the latest version will be returned.
|
|
130
179
|
* @returns the workflow version
|
|
131
180
|
*/
|
|
132
|
-
|
|
181
|
+
getWorkflowVersion(workflowId, version) {
|
|
133
182
|
return __awaiter(this, void 0, void 0, function* () {
|
|
134
183
|
const res = yield this.api.workflowVersionGet(workflowId, {
|
|
135
184
|
version,
|
|
@@ -137,15 +186,30 @@ class AdminClient {
|
|
|
137
186
|
return res.data;
|
|
138
187
|
});
|
|
139
188
|
}
|
|
189
|
+
/**
|
|
190
|
+
* @deprecated use getWorkflowRun instead
|
|
191
|
+
*/
|
|
192
|
+
get_workflow_run(workflowRunId) {
|
|
193
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
194
|
+
return this.getWorkflowRun(workflowRunId);
|
|
195
|
+
});
|
|
196
|
+
}
|
|
140
197
|
/**
|
|
141
198
|
* Get a workflow run.
|
|
142
199
|
* @param workflowRunId the id of the workflow run to get
|
|
143
200
|
* @returns the workflow run
|
|
144
201
|
*/
|
|
145
|
-
|
|
202
|
+
getWorkflowRun(workflowRunId) {
|
|
146
203
|
return __awaiter(this, void 0, void 0, function* () {
|
|
147
|
-
|
|
148
|
-
|
|
204
|
+
return new workflow_run_ref_1.default(workflowRunId, this.listenerClient);
|
|
205
|
+
});
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated use listWorkflowRuns instead
|
|
209
|
+
*/
|
|
210
|
+
list_workflow_runs(query) {
|
|
211
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
212
|
+
return this.listWorkflowRuns(query);
|
|
149
213
|
});
|
|
150
214
|
}
|
|
151
215
|
/**
|
|
@@ -153,28 +217,50 @@ class AdminClient {
|
|
|
153
217
|
* @param query the query to filter the list of workflow runs
|
|
154
218
|
* @returns
|
|
155
219
|
*/
|
|
156
|
-
|
|
220
|
+
listWorkflowRuns(query) {
|
|
157
221
|
return __awaiter(this, void 0, void 0, function* () {
|
|
158
222
|
const res = yield this.api.workflowRunList(this.tenantId, query);
|
|
159
223
|
return res.data;
|
|
160
224
|
});
|
|
161
225
|
}
|
|
226
|
+
/**
|
|
227
|
+
* @deprecated use scheduleWorkflow instead
|
|
228
|
+
*/
|
|
229
|
+
schedule_workflow(name, options) {
|
|
230
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
231
|
+
return this.scheduleWorkflow(name, options);
|
|
232
|
+
});
|
|
233
|
+
}
|
|
162
234
|
/**
|
|
163
235
|
* Schedule a workflow to run at a specific time or times.
|
|
164
236
|
* @param name the name of the workflow to schedule
|
|
165
237
|
* @param options an object containing the schedules to set
|
|
238
|
+
* @param input an object containing the input to the workflow
|
|
166
239
|
*/
|
|
167
|
-
|
|
240
|
+
scheduleWorkflow(name, options) {
|
|
168
241
|
try {
|
|
242
|
+
let input;
|
|
243
|
+
if (options === null || options === void 0 ? void 0 : options.input) {
|
|
244
|
+
input = JSON.stringify(options.input);
|
|
245
|
+
}
|
|
169
246
|
this.client.scheduleWorkflow({
|
|
170
247
|
name,
|
|
171
248
|
schedules: options === null || options === void 0 ? void 0 : options.schedules,
|
|
249
|
+
input,
|
|
172
250
|
});
|
|
173
251
|
}
|
|
174
252
|
catch (e) {
|
|
175
253
|
throw new hatchet_error_1.default(e.message);
|
|
176
254
|
}
|
|
177
255
|
}
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated use getWorkflowMetrics instead
|
|
258
|
+
*/
|
|
259
|
+
get_workflow_metrics(data) {
|
|
260
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
261
|
+
return this.getWorkflowMetrics(data);
|
|
262
|
+
});
|
|
263
|
+
}
|
|
178
264
|
/**
|
|
179
265
|
* Get the metrics for a workflow.
|
|
180
266
|
*
|
|
@@ -182,13 +268,13 @@ class AdminClient {
|
|
|
182
268
|
* @param workflowName the name of the workflow to get metrics for
|
|
183
269
|
* @param query an object containing query parameters to filter the metrics
|
|
184
270
|
*/
|
|
185
|
-
|
|
271
|
+
getWorkflowMetrics({ workflowId, workflowName, status, groupKey }) {
|
|
186
272
|
const params = {
|
|
187
273
|
status,
|
|
188
274
|
groupKey,
|
|
189
275
|
};
|
|
190
276
|
if (workflowName) {
|
|
191
|
-
this.
|
|
277
|
+
this.listWorkflows().then((res) => {
|
|
192
278
|
var _a;
|
|
193
279
|
const workflow = (_a = res.rows) === null || _a === void 0 ? void 0 : _a.find((row) => row.name === workflowName);
|
|
194
280
|
if (workflow) {
|
|
@@ -29,5 +29,5 @@ export declare class HatchetClient {
|
|
|
29
29
|
static init(config?: Partial<ClientConfig>, options?: HatchetClientOptions, axiosConfig?: AxiosRequestConfig): HatchetClient;
|
|
30
30
|
run(workflow: string | Workflow): Promise<Worker>;
|
|
31
31
|
worker(workflow: string | Workflow, maxRuns?: number): Promise<Worker>;
|
|
32
|
-
webhooks(
|
|
32
|
+
webhooks(workflows: Workflow[]): import("../worker/handler").WebhookHandler;
|
|
33
33
|
}
|
|
@@ -111,8 +111,8 @@ class HatchetClient {
|
|
|
111
111
|
this.api = (0, rest_1.default)(this.config.api_url, this.config.token, axiosOpts);
|
|
112
112
|
this.event = new event_client_1.EventClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory);
|
|
113
113
|
this.dispatcher = new dispatcher_client_1.DispatcherClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory);
|
|
114
|
-
this.admin = new admin_client_1.AdminClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory, this.api, this.tenantId);
|
|
115
114
|
this.listener = new listener_client_1.ListenerClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory, this.api);
|
|
115
|
+
this.admin = new admin_client_1.AdminClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory, this.api, this.tenantId, this.listener);
|
|
116
116
|
this.logger = new logger_1.default('HatchetClient', this.config.log_level);
|
|
117
117
|
this.logger.info(`Initialized HatchetClient`);
|
|
118
118
|
}
|
|
@@ -142,11 +142,11 @@ class HatchetClient {
|
|
|
142
142
|
return worker;
|
|
143
143
|
});
|
|
144
144
|
}
|
|
145
|
-
webhooks(
|
|
145
|
+
webhooks(workflows) {
|
|
146
146
|
const worker = new worker_1.Worker(this, {
|
|
147
|
-
name:
|
|
147
|
+
name: 'webhook-worker',
|
|
148
148
|
});
|
|
149
|
-
return worker.getHandler(
|
|
149
|
+
return worker.getHandler(workflows);
|
|
150
150
|
}
|
|
151
151
|
}
|
|
152
152
|
exports.HatchetClient = HatchetClient;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
1
|
import { Channel, ClientFactory } from 'nice-grpc';
|
|
3
2
|
import { EventEmitter } from 'events';
|
|
4
|
-
import { DispatcherClient as PbDispatcherClient } from '../../protoc/dispatcher';
|
|
3
|
+
import { DispatcherClient as PbDispatcherClient, DispatcherClient } from '../../protoc/dispatcher';
|
|
5
4
|
import { ClientConfig } from '../hatchet-client/client-config';
|
|
6
5
|
import { Logger } from '../../util/logger';
|
|
7
6
|
import { Api } from '../rest';
|
|
@@ -23,21 +22,15 @@ export interface StepRunEvent {
|
|
|
23
22
|
type: RunEventType;
|
|
24
23
|
payload: string;
|
|
25
24
|
}
|
|
26
|
-
export declare class
|
|
27
|
-
client:
|
|
25
|
+
export declare class RunEventListener {
|
|
26
|
+
client: DispatcherClient;
|
|
28
27
|
q: Array<StepRunEvent>;
|
|
29
28
|
eventEmitter: EventEmitter<[never]>;
|
|
30
29
|
pollInterval: any;
|
|
31
|
-
constructor(workflowRunid: string, client:
|
|
30
|
+
constructor(workflowRunid: string, client: DispatcherClient);
|
|
32
31
|
emit(event: StepRunEvent): void;
|
|
33
32
|
listen(workflowRunId: string): Promise<void>;
|
|
34
33
|
retrySubscribe(workflowRunId: string): Promise<AsyncIterable<import("../../protoc/dispatcher").WorkflowEvent>>;
|
|
35
|
-
getWorkflowRun(workflowRunId: string): Promise<{
|
|
36
|
-
type: RunEventType;
|
|
37
|
-
payload: string;
|
|
38
|
-
} | undefined>;
|
|
39
|
-
polling(workflowRunId: string): Promise<void>;
|
|
40
|
-
close(): void;
|
|
41
34
|
stream(): AsyncGenerator<StepRunEvent, void, unknown>;
|
|
42
35
|
}
|
|
43
36
|
export declare class ListenerClient {
|
|
@@ -45,9 +38,8 @@ export declare class ListenerClient {
|
|
|
45
38
|
client: PbDispatcherClient;
|
|
46
39
|
logger: Logger;
|
|
47
40
|
api: Api;
|
|
48
|
-
|
|
41
|
+
pooledListener: GrpcPooledListener | undefined;
|
|
49
42
|
constructor(config: ClientConfig, channel: Channel, factory: ClientFactory, api: Api);
|
|
50
|
-
|
|
51
|
-
get(workflowRunId: string): PollingAsyncListener;
|
|
43
|
+
get(workflowRunId: string): import("./child-listener-client").Streamable;
|
|
52
44
|
stream(workflowRunId: string): Promise<AsyncGenerator<StepRunEvent, void, unknown>>;
|
|
53
45
|
}
|