@hatchet-dev/typescript-sdk 0.4.3 → 0.5.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/clients/dispatcher/action-listener.js +4 -2
- package/clients/hatchet-client/hatchet-client.d.ts +1 -2
- package/clients/hatchet-client/hatchet-client.js +5 -5
- package/clients/listener/child-listener-client.d.ts +24 -0
- package/clients/listener/child-listener-client.js +160 -0
- package/clients/listener/listener-client.d.ts +3 -0
- package/clients/listener/listener-client.js +13 -0
- package/clients/worker/worker.js +7 -2
- package/package.json +2 -1
- package/protoc/dispatcher/dispatcher.d.ts +72 -0
- package/protoc/dispatcher/dispatcher.js +298 -1
- package/protoc/workflows/workflows.d.ts +2 -2
- package/protoc/workflows/workflows.js +19 -18
- package/step.d.ts +4 -6
- package/step.js +14 -17
- package/util/config-loader/config-loader.js +1 -1
|
@@ -134,6 +134,7 @@ class ActionListener {
|
|
|
134
134
|
catch (e) {
|
|
135
135
|
if (e.code === nice_grpc_1.Status.UNIMPLEMENTED) {
|
|
136
136
|
// break out of interval
|
|
137
|
+
this.logger.error('Heartbeat not implemented, closing heartbeat');
|
|
137
138
|
this.closeHeartbeat();
|
|
138
139
|
return;
|
|
139
140
|
}
|
|
@@ -148,13 +149,14 @@ class ActionListener {
|
|
|
148
149
|
closeHeartbeat() {
|
|
149
150
|
if (this.heartbeatInterval) {
|
|
150
151
|
clearInterval(this.heartbeatInterval);
|
|
152
|
+
this.heartbeatInterval = null;
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
getListenClient() {
|
|
154
156
|
return __awaiter(this, void 0, void 0, function* () {
|
|
155
157
|
const currentTime = Math.floor(Date.now());
|
|
156
|
-
//
|
|
157
|
-
if (currentTime - this.lastConnectionAttempt
|
|
158
|
+
// attempt to account for the time it takes to establish the listener
|
|
159
|
+
if (currentTime - this.lastConnectionAttempt > this.retryInterval * 4) {
|
|
158
160
|
this.retries = 0;
|
|
159
161
|
}
|
|
160
162
|
this.lastConnectionAttempt = currentTime;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventClient } from '../event/event-client';
|
|
2
2
|
import { DispatcherClient } from '../dispatcher/dispatcher-client';
|
|
3
3
|
import { AdminClient } from '../admin/admin-client';
|
|
4
|
-
import {
|
|
4
|
+
import { ChannelCredentials } from 'nice-grpc';
|
|
5
5
|
import { Workflow } from '../../workflow';
|
|
6
6
|
import { Worker } from '../worker';
|
|
7
7
|
import Logger from '../../util/logger/logger';
|
|
@@ -16,7 +16,6 @@ export interface HatchetClientOptions {
|
|
|
16
16
|
export declare class HatchetClient {
|
|
17
17
|
config: ClientConfig;
|
|
18
18
|
credentials: ChannelCredentials;
|
|
19
|
-
channel: Channel;
|
|
20
19
|
event: EventClient;
|
|
21
20
|
dispatcher: DispatcherClient;
|
|
22
21
|
admin: AdminClient;
|
|
@@ -95,7 +95,7 @@ class HatchetClient {
|
|
|
95
95
|
}
|
|
96
96
|
this.credentials =
|
|
97
97
|
(_a = options === null || options === void 0 ? void 0 : options.credentials) !== null && _a !== void 0 ? _a : config_loader_1.ConfigLoader.createCredentials(this.config.tls_config);
|
|
98
|
-
|
|
98
|
+
const channelFactory = () => (0, nice_grpc_1.createChannel)(this.config.host_port, this.credentials, {
|
|
99
99
|
'grpc.ssl_target_name_override': this.config.tls_config.server_name,
|
|
100
100
|
'grpc.keepalive_timeout_ms': 60 * 1000,
|
|
101
101
|
'grpc.client_idle_timeout_ms': 60 * 1000,
|
|
@@ -107,10 +107,10 @@ class HatchetClient {
|
|
|
107
107
|
const clientFactory = (0, nice_grpc_1.createClientFactory)().use(addTokenMiddleware(this.config.token));
|
|
108
108
|
this.tenantId = this.config.tenant_id;
|
|
109
109
|
this.api = (0, rest_1.default)(this.config.api_url, this.config.token, axiosOpts);
|
|
110
|
-
this.event = new event_client_1.EventClient(this.config,
|
|
111
|
-
this.dispatcher = new dispatcher_client_1.DispatcherClient(this.config,
|
|
112
|
-
this.admin = new admin_client_1.AdminClient(this.config,
|
|
113
|
-
this.listener = new listener_client_1.ListenerClient(this.config,
|
|
110
|
+
this.event = new event_client_1.EventClient(this.config, channelFactory(), clientFactory);
|
|
111
|
+
this.dispatcher = new dispatcher_client_1.DispatcherClient(this.config, channelFactory(), clientFactory);
|
|
112
|
+
this.admin = new admin_client_1.AdminClient(this.config, channelFactory(), clientFactory, this.api, this.tenantId);
|
|
113
|
+
this.listener = new listener_client_1.ListenerClient(this.config, channelFactory(), clientFactory, this.api);
|
|
114
114
|
this.logger = new logger_1.default('HatchetClient', this.config.log_level);
|
|
115
115
|
this.logger.info(`Initialized HatchetClient`);
|
|
116
116
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { EventEmitter } from 'events';
|
|
3
|
+
import { WorkflowRunEvent, SubscribeToWorkflowRunsRequest } from '../../protoc/dispatcher';
|
|
4
|
+
import { ListenerClient } from './listener-client';
|
|
5
|
+
export declare class Streamable {
|
|
6
|
+
listener: AsyncIterable<WorkflowRunEvent>;
|
|
7
|
+
id: string;
|
|
8
|
+
responseEmitter: EventEmitter;
|
|
9
|
+
constructor(listener: AsyncIterable<WorkflowRunEvent>, id: string);
|
|
10
|
+
stream(): AsyncGenerator<WorkflowRunEvent, void, unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare class GrpcPooledListener {
|
|
13
|
+
listener: AsyncIterable<WorkflowRunEvent> | undefined;
|
|
14
|
+
requestEmitter: EventEmitter;
|
|
15
|
+
signal: AbortController;
|
|
16
|
+
client: ListenerClient;
|
|
17
|
+
subscribers: Record<string, Streamable>;
|
|
18
|
+
onFinish: () => void;
|
|
19
|
+
constructor(client: ListenerClient, onFinish: () => void);
|
|
20
|
+
private init;
|
|
21
|
+
subscribe(request: SubscribeToWorkflowRunsRequest): Streamable;
|
|
22
|
+
replayRequests(): void;
|
|
23
|
+
private request;
|
|
24
|
+
}
|
|
@@ -0,0 +1,160 @@
|
|
|
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 __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
12
|
+
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
13
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
14
|
+
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
15
|
+
return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
16
|
+
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
17
|
+
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
18
|
+
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
19
|
+
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
20
|
+
function fulfill(value) { resume("next", value); }
|
|
21
|
+
function reject(value) { resume("throw", value); }
|
|
22
|
+
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
23
|
+
};
|
|
24
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
25
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
26
|
+
var m = o[Symbol.asyncIterator], i;
|
|
27
|
+
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);
|
|
28
|
+
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); }); }; }
|
|
29
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
30
|
+
};
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.GrpcPooledListener = exports.Streamable = void 0;
|
|
36
|
+
// eslint-disable-next-line max-classes-per-file
|
|
37
|
+
const events_1 = require("events");
|
|
38
|
+
const dispatcher_1 = require("../../protoc/dispatcher");
|
|
39
|
+
const abort_controller_x_1 = require("abort-controller-x");
|
|
40
|
+
const sleep_1 = __importDefault(require("../../util/sleep"));
|
|
41
|
+
const DEFAULT_EVENT_LISTENER_RETRY_INTERVAL = 5; // seconds
|
|
42
|
+
const DEFAULT_EVENT_LISTENER_RETRY_COUNT = 20;
|
|
43
|
+
class Streamable {
|
|
44
|
+
constructor(listener, id) {
|
|
45
|
+
this.responseEmitter = new events_1.EventEmitter();
|
|
46
|
+
this.listener = listener;
|
|
47
|
+
this.id = id;
|
|
48
|
+
}
|
|
49
|
+
stream() {
|
|
50
|
+
return __asyncGenerator(this, arguments, function* stream_1() {
|
|
51
|
+
while (true) {
|
|
52
|
+
const req = yield __await(new Promise((resolve) => {
|
|
53
|
+
this.responseEmitter.once('response', resolve);
|
|
54
|
+
}));
|
|
55
|
+
yield yield __await(req);
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Streamable = Streamable;
|
|
61
|
+
class GrpcPooledListener {
|
|
62
|
+
constructor(client, onFinish) {
|
|
63
|
+
this.requestEmitter = new events_1.EventEmitter();
|
|
64
|
+
this.signal = new AbortController();
|
|
65
|
+
this.subscribers = {};
|
|
66
|
+
this.onFinish = () => { };
|
|
67
|
+
this.client = client;
|
|
68
|
+
this.init();
|
|
69
|
+
this.onFinish = onFinish;
|
|
70
|
+
}
|
|
71
|
+
init(retries = 0) {
|
|
72
|
+
var _a, e_1, _b, _c;
|
|
73
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
74
|
+
if (retries > DEFAULT_EVENT_LISTENER_RETRY_COUNT)
|
|
75
|
+
return;
|
|
76
|
+
if (retries > 0) {
|
|
77
|
+
this.client.logger.info(`Retrying in ... ${DEFAULT_EVENT_LISTENER_RETRY_INTERVAL} seconds`);
|
|
78
|
+
yield (0, sleep_1.default)(DEFAULT_EVENT_LISTENER_RETRY_INTERVAL * 1000);
|
|
79
|
+
}
|
|
80
|
+
try {
|
|
81
|
+
this.client.logger.debug('Initializing child-listener');
|
|
82
|
+
this.listener = this.client.client.subscribeToWorkflowRuns(this.request(), {
|
|
83
|
+
signal: this.signal.signal,
|
|
84
|
+
});
|
|
85
|
+
if (retries > 0)
|
|
86
|
+
setTimeout(() => this.replayRequests(), 100);
|
|
87
|
+
try {
|
|
88
|
+
for (var _d = true, _e = __asyncValues(this.listener), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
89
|
+
_c = _f.value;
|
|
90
|
+
_d = false;
|
|
91
|
+
const event = _c;
|
|
92
|
+
const emitter = this.subscribers[event.workflowRunId];
|
|
93
|
+
if (emitter) {
|
|
94
|
+
emitter.responseEmitter.emit('response', event);
|
|
95
|
+
if (event.eventType === dispatcher_1.WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED) {
|
|
96
|
+
delete this.subscribers[event.workflowRunId];
|
|
97
|
+
if (Object.keys(this.subscribers).length === 0) {
|
|
98
|
+
// FIXME it would be better to cleanup on parent complete
|
|
99
|
+
this.client.logger.debug('All subscriptions finished, cleaning up listener');
|
|
100
|
+
this.signal.abort();
|
|
101
|
+
this.onFinish();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
108
|
+
finally {
|
|
109
|
+
try {
|
|
110
|
+
if (!_d && !_a && (_b = _e.return)) yield _b.call(_e);
|
|
111
|
+
}
|
|
112
|
+
finally { if (e_1) throw e_1.error; }
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch (e) {
|
|
116
|
+
if ((0, abort_controller_x_1.isAbortError)(e)) {
|
|
117
|
+
this.client.logger.debug('Child Listener aborted');
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
this.client.logger.error(`Error in child-listener: ${e.message}`);
|
|
121
|
+
this.init(retries + 1);
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
subscribe(request) {
|
|
126
|
+
if (!this.listener)
|
|
127
|
+
throw new Error('listener not initialized');
|
|
128
|
+
this.subscribers[request.workflowRunId] = new Streamable(this.listener, request.workflowRunId);
|
|
129
|
+
this.requestEmitter.emit('subscribe', request);
|
|
130
|
+
return this.subscribers[request.workflowRunId];
|
|
131
|
+
}
|
|
132
|
+
replayRequests() {
|
|
133
|
+
const subs = Object.values(this.subscribers);
|
|
134
|
+
this.client.logger.debug(`Replaying ${subs.length} requests...`);
|
|
135
|
+
for (const subscriber of subs) {
|
|
136
|
+
this.requestEmitter.emit('subscribe', { workflowRunId: subscriber.id });
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
request() {
|
|
140
|
+
return __asyncGenerator(this, arguments, function* request_1() {
|
|
141
|
+
var _a, e_2, _b, _c;
|
|
142
|
+
try {
|
|
143
|
+
for (var _d = true, _e = __asyncValues((0, events_1.on)(this.requestEmitter, 'subscribe')), _f; _f = yield __await(_e.next()), _a = _f.done, !_a; _d = true) {
|
|
144
|
+
_c = _f.value;
|
|
145
|
+
_d = false;
|
|
146
|
+
const e = _c;
|
|
147
|
+
yield yield __await(e[0]);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
151
|
+
finally {
|
|
152
|
+
try {
|
|
153
|
+
if (!_d && !_a && (_b = _e.return)) yield __await(_b.call(_e));
|
|
154
|
+
}
|
|
155
|
+
finally { if (e_2) throw e_2.error; }
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
exports.GrpcPooledListener = GrpcPooledListener;
|
|
@@ -5,6 +5,7 @@ import { DispatcherClient as PbDispatcherClient } from '../../protoc/dispatcher'
|
|
|
5
5
|
import { ClientConfig } from '../hatchet-client/client-config';
|
|
6
6
|
import { Logger } from '../../util/logger';
|
|
7
7
|
import { Api } from '../rest';
|
|
8
|
+
import { GrpcPooledListener } from './child-listener-client';
|
|
8
9
|
export declare enum RunEventType {
|
|
9
10
|
STEP_RUN_EVENT_TYPE_STARTED = "STEP_RUN_EVENT_TYPE_STARTED",
|
|
10
11
|
STEP_RUN_EVENT_TYPE_COMPLETED = "STEP_RUN_EVENT_TYPE_COMPLETED",
|
|
@@ -44,7 +45,9 @@ export declare class ListenerClient {
|
|
|
44
45
|
client: PbDispatcherClient;
|
|
45
46
|
logger: Logger;
|
|
46
47
|
api: Api;
|
|
48
|
+
childListeners: Record<string, GrpcPooledListener>;
|
|
47
49
|
constructor(config: ClientConfig, channel: Channel, factory: ClientFactory, api: Api);
|
|
50
|
+
getChildListener(workflowRunId: string, parentWorkflowRunId: string): import("./child-listener-client").Streamable;
|
|
48
51
|
get(workflowRunId: string): PollingAsyncListener;
|
|
49
52
|
stream(workflowRunId: string): Promise<AsyncGenerator<StepRunEvent, void, unknown>>;
|
|
50
53
|
}
|
|
@@ -41,6 +41,7 @@ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error
|
|
|
41
41
|
const logger_1 = require("../../util/logger");
|
|
42
42
|
const sleep_1 = __importDefault(require("../../util/sleep"));
|
|
43
43
|
const data_contracts_1 = require("../rest/generated/data-contracts");
|
|
44
|
+
const child_listener_client_1 = require("./child-listener-client");
|
|
44
45
|
const DEFAULT_EVENT_LISTENER_RETRY_INTERVAL = 5; // seconds
|
|
45
46
|
const DEFAULT_EVENT_LISTENER_RETRY_COUNT = 5;
|
|
46
47
|
const DEFAULT_EVENT_LISTENER_POLL_INTERVAL = 5000; // milliseconds
|
|
@@ -255,11 +256,23 @@ class PollingAsyncListener {
|
|
|
255
256
|
exports.PollingAsyncListener = PollingAsyncListener;
|
|
256
257
|
class ListenerClient {
|
|
257
258
|
constructor(config, channel, factory, api) {
|
|
259
|
+
this.childListeners = {};
|
|
258
260
|
this.config = config;
|
|
259
261
|
this.client = factory.create(dispatcher_1.DispatcherDefinition, channel);
|
|
260
262
|
this.logger = new logger_1.Logger(`Listener`, config.log_level);
|
|
261
263
|
this.api = api;
|
|
262
264
|
}
|
|
265
|
+
getChildListener(workflowRunId, parentWorkflowRunId) {
|
|
266
|
+
if (!this.childListeners[parentWorkflowRunId]) {
|
|
267
|
+
this.childListeners[parentWorkflowRunId] = new child_listener_client_1.GrpcPooledListener(this, () => {
|
|
268
|
+
// cleanup listener when all children are done
|
|
269
|
+
delete this.childListeners[parentWorkflowRunId];
|
|
270
|
+
});
|
|
271
|
+
}
|
|
272
|
+
return this.childListeners[parentWorkflowRunId].subscribe({
|
|
273
|
+
workflowRunId,
|
|
274
|
+
});
|
|
275
|
+
}
|
|
263
276
|
get(workflowRunId) {
|
|
264
277
|
const listener = new PollingAsyncListener(workflowRunId, this);
|
|
265
278
|
return listener;
|
package/clients/worker/worker.js
CHANGED
|
@@ -72,7 +72,6 @@ class Worker {
|
|
|
72
72
|
jobs: [
|
|
73
73
|
{
|
|
74
74
|
name: workflow.id,
|
|
75
|
-
timeout: workflow.timeout || '60s',
|
|
76
75
|
description: workflow.description,
|
|
77
76
|
steps: workflow.steps.map((step) => {
|
|
78
77
|
var _a, _b;
|
|
@@ -136,9 +135,15 @@ class Worker {
|
|
|
136
135
|
};
|
|
137
136
|
const failure = (error) => {
|
|
138
137
|
this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
|
|
138
|
+
if (error.stack) {
|
|
139
|
+
this.logger.error(error.stack);
|
|
140
|
+
}
|
|
139
141
|
try {
|
|
140
142
|
// Send the action event to the dispatcher
|
|
141
|
-
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED,
|
|
143
|
+
const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, {
|
|
144
|
+
message: error === null || error === void 0 ? void 0 : error.message,
|
|
145
|
+
stack: error === null || error === void 0 ? void 0 : error.stack,
|
|
146
|
+
});
|
|
142
147
|
this.client.dispatcher.sendStepActionEvent(event);
|
|
143
148
|
// delete the run from the futures
|
|
144
149
|
delete this.futures[action.stepRunId];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hatchet-dev/typescript-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Background task orchestration & visibility for developers",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
},
|
|
90
90
|
"dependencies": {
|
|
91
91
|
"@types/qs": "^6.9.11",
|
|
92
|
+
"abort-controller-x": "^0.4.3",
|
|
92
93
|
"axios": "^1.6.7",
|
|
93
94
|
"long": "^5.2.3",
|
|
94
95
|
"nice-grpc": "^2.1.7",
|
|
@@ -47,6 +47,12 @@ export declare enum ResourceEventType {
|
|
|
47
47
|
}
|
|
48
48
|
export declare function resourceEventTypeFromJSON(object: any): ResourceEventType;
|
|
49
49
|
export declare function resourceEventTypeToJSON(object: ResourceEventType): string;
|
|
50
|
+
export declare enum WorkflowRunEventType {
|
|
51
|
+
WORKFLOW_RUN_EVENT_TYPE_FINISHED = 0,
|
|
52
|
+
UNRECOGNIZED = -1
|
|
53
|
+
}
|
|
54
|
+
export declare function workflowRunEventTypeFromJSON(object: any): WorkflowRunEventType;
|
|
55
|
+
export declare function workflowRunEventTypeToJSON(object: WorkflowRunEventType): string;
|
|
50
56
|
export interface WorkerRegisterRequest {
|
|
51
57
|
/** the name of the worker */
|
|
52
58
|
workerName: string;
|
|
@@ -148,6 +154,10 @@ export interface SubscribeToWorkflowEventsRequest {
|
|
|
148
154
|
/** the id of the workflow run */
|
|
149
155
|
workflowRunId: string;
|
|
150
156
|
}
|
|
157
|
+
export interface SubscribeToWorkflowRunsRequest {
|
|
158
|
+
/** the id of the workflow run */
|
|
159
|
+
workflowRunId: string;
|
|
160
|
+
}
|
|
151
161
|
export interface WorkflowEvent {
|
|
152
162
|
/** the id of the workflow run */
|
|
153
163
|
workflowRunId: string;
|
|
@@ -167,6 +177,20 @@ export interface WorkflowEvent {
|
|
|
167
177
|
/** (optional) the retry count of this step */
|
|
168
178
|
retryCount?: number | undefined;
|
|
169
179
|
}
|
|
180
|
+
export interface WorkflowRunEvent {
|
|
181
|
+
/** the id of the workflow run */
|
|
182
|
+
workflowRunId: string;
|
|
183
|
+
eventType: WorkflowRunEventType;
|
|
184
|
+
eventTimestamp: Date | undefined;
|
|
185
|
+
results: StepRunResult[];
|
|
186
|
+
}
|
|
187
|
+
export interface StepRunResult {
|
|
188
|
+
stepRunId: string;
|
|
189
|
+
stepReadableId: string;
|
|
190
|
+
jobRunId: string;
|
|
191
|
+
error?: string | undefined;
|
|
192
|
+
output?: string | undefined;
|
|
193
|
+
}
|
|
170
194
|
export interface OverridesData {
|
|
171
195
|
/** the step run id */
|
|
172
196
|
stepRunId: string;
|
|
@@ -267,6 +291,14 @@ export declare const SubscribeToWorkflowEventsRequest: {
|
|
|
267
291
|
create(base?: DeepPartial<SubscribeToWorkflowEventsRequest>): SubscribeToWorkflowEventsRequest;
|
|
268
292
|
fromPartial(object: DeepPartial<SubscribeToWorkflowEventsRequest>): SubscribeToWorkflowEventsRequest;
|
|
269
293
|
};
|
|
294
|
+
export declare const SubscribeToWorkflowRunsRequest: {
|
|
295
|
+
encode(message: SubscribeToWorkflowRunsRequest, writer?: _m0.Writer): _m0.Writer;
|
|
296
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeToWorkflowRunsRequest;
|
|
297
|
+
fromJSON(object: any): SubscribeToWorkflowRunsRequest;
|
|
298
|
+
toJSON(message: SubscribeToWorkflowRunsRequest): unknown;
|
|
299
|
+
create(base?: DeepPartial<SubscribeToWorkflowRunsRequest>): SubscribeToWorkflowRunsRequest;
|
|
300
|
+
fromPartial(object: DeepPartial<SubscribeToWorkflowRunsRequest>): SubscribeToWorkflowRunsRequest;
|
|
301
|
+
};
|
|
270
302
|
export declare const WorkflowEvent: {
|
|
271
303
|
encode(message: WorkflowEvent, writer?: _m0.Writer): _m0.Writer;
|
|
272
304
|
decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowEvent;
|
|
@@ -275,6 +307,22 @@ export declare const WorkflowEvent: {
|
|
|
275
307
|
create(base?: DeepPartial<WorkflowEvent>): WorkflowEvent;
|
|
276
308
|
fromPartial(object: DeepPartial<WorkflowEvent>): WorkflowEvent;
|
|
277
309
|
};
|
|
310
|
+
export declare const WorkflowRunEvent: {
|
|
311
|
+
encode(message: WorkflowRunEvent, writer?: _m0.Writer): _m0.Writer;
|
|
312
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowRunEvent;
|
|
313
|
+
fromJSON(object: any): WorkflowRunEvent;
|
|
314
|
+
toJSON(message: WorkflowRunEvent): unknown;
|
|
315
|
+
create(base?: DeepPartial<WorkflowRunEvent>): WorkflowRunEvent;
|
|
316
|
+
fromPartial(object: DeepPartial<WorkflowRunEvent>): WorkflowRunEvent;
|
|
317
|
+
};
|
|
318
|
+
export declare const StepRunResult: {
|
|
319
|
+
encode(message: StepRunResult, writer?: _m0.Writer): _m0.Writer;
|
|
320
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): StepRunResult;
|
|
321
|
+
fromJSON(object: any): StepRunResult;
|
|
322
|
+
toJSON(message: StepRunResult): unknown;
|
|
323
|
+
create(base?: DeepPartial<StepRunResult>): StepRunResult;
|
|
324
|
+
fromPartial(object: DeepPartial<StepRunResult>): StepRunResult;
|
|
325
|
+
};
|
|
278
326
|
export declare const OverridesData: {
|
|
279
327
|
encode(message: OverridesData, writer?: _m0.Writer): _m0.Writer;
|
|
280
328
|
decode(input: _m0.Reader | Uint8Array, length?: number): OverridesData;
|
|
@@ -427,6 +475,28 @@ export declare const DispatcherDefinition: {
|
|
|
427
475
|
readonly responseStream: true;
|
|
428
476
|
readonly options: {};
|
|
429
477
|
};
|
|
478
|
+
readonly subscribeToWorkflowRuns: {
|
|
479
|
+
readonly name: "SubscribeToWorkflowRuns";
|
|
480
|
+
readonly requestType: {
|
|
481
|
+
encode(message: SubscribeToWorkflowRunsRequest, writer?: _m0.Writer): _m0.Writer;
|
|
482
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): SubscribeToWorkflowRunsRequest;
|
|
483
|
+
fromJSON(object: any): SubscribeToWorkflowRunsRequest;
|
|
484
|
+
toJSON(message: SubscribeToWorkflowRunsRequest): unknown;
|
|
485
|
+
create(base?: DeepPartial<SubscribeToWorkflowRunsRequest>): SubscribeToWorkflowRunsRequest;
|
|
486
|
+
fromPartial(object: DeepPartial<SubscribeToWorkflowRunsRequest>): SubscribeToWorkflowRunsRequest;
|
|
487
|
+
};
|
|
488
|
+
readonly requestStream: true;
|
|
489
|
+
readonly responseType: {
|
|
490
|
+
encode(message: WorkflowRunEvent, writer?: _m0.Writer): _m0.Writer;
|
|
491
|
+
decode(input: _m0.Reader | Uint8Array, length?: number): WorkflowRunEvent;
|
|
492
|
+
fromJSON(object: any): WorkflowRunEvent;
|
|
493
|
+
toJSON(message: WorkflowRunEvent): unknown;
|
|
494
|
+
create(base?: DeepPartial<WorkflowRunEvent>): WorkflowRunEvent;
|
|
495
|
+
fromPartial(object: DeepPartial<WorkflowRunEvent>): WorkflowRunEvent;
|
|
496
|
+
};
|
|
497
|
+
readonly responseStream: true;
|
|
498
|
+
readonly options: {};
|
|
499
|
+
};
|
|
430
500
|
readonly sendStepActionEvent: {
|
|
431
501
|
readonly name: "SendStepActionEvent";
|
|
432
502
|
readonly requestType: {
|
|
@@ -528,6 +598,7 @@ export interface DispatcherServiceImplementation<CallContextExt = {}> {
|
|
|
528
598
|
/** Heartbeat is a method for workers to send heartbeats to the dispatcher */
|
|
529
599
|
heartbeat(request: HeartbeatRequest, context: CallContext & CallContextExt): Promise<DeepPartial<HeartbeatResponse>>;
|
|
530
600
|
subscribeToWorkflowEvents(request: SubscribeToWorkflowEventsRequest, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<WorkflowEvent>>;
|
|
601
|
+
subscribeToWorkflowRuns(request: AsyncIterable<SubscribeToWorkflowRunsRequest>, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<WorkflowRunEvent>>;
|
|
531
602
|
sendStepActionEvent(request: StepActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
|
|
532
603
|
sendGroupKeyActionEvent(request: GroupKeyActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
|
|
533
604
|
putOverridesData(request: OverridesData, context: CallContext & CallContextExt): Promise<DeepPartial<OverridesDataResponse>>;
|
|
@@ -544,6 +615,7 @@ export interface DispatcherClient<CallOptionsExt = {}> {
|
|
|
544
615
|
/** Heartbeat is a method for workers to send heartbeats to the dispatcher */
|
|
545
616
|
heartbeat(request: DeepPartial<HeartbeatRequest>, options?: CallOptions & CallOptionsExt): Promise<HeartbeatResponse>;
|
|
546
617
|
subscribeToWorkflowEvents(request: DeepPartial<SubscribeToWorkflowEventsRequest>, options?: CallOptions & CallOptionsExt): AsyncIterable<WorkflowEvent>;
|
|
618
|
+
subscribeToWorkflowRuns(request: AsyncIterable<DeepPartial<SubscribeToWorkflowRunsRequest>>, options?: CallOptions & CallOptionsExt): AsyncIterable<WorkflowRunEvent>;
|
|
547
619
|
sendStepActionEvent(request: DeepPartial<StepActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
|
|
548
620
|
sendGroupKeyActionEvent(request: DeepPartial<GroupKeyActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
|
|
549
621
|
putOverridesData(request: DeepPartial<OverridesData>, options?: CallOptions & CallOptionsExt): Promise<OverridesDataResponse>;
|
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.DispatcherDefinition = exports.HeartbeatResponse = exports.HeartbeatRequest = exports.OverridesDataResponse = exports.OverridesData = exports.WorkflowEvent = exports.SubscribeToWorkflowEventsRequest = exports.ActionEventResponse = exports.StepActionEvent = exports.GroupKeyActionEvent = exports.WorkerUnsubscribeResponse = exports.WorkerUnsubscribeRequest = exports.WorkerListenRequest = exports.AssignedAction = exports.WorkerRegisterResponse = exports.WorkerRegisterRequest = exports.resourceEventTypeToJSON = exports.resourceEventTypeFromJSON = exports.ResourceEventType = exports.resourceTypeToJSON = exports.resourceTypeFromJSON = exports.ResourceType = exports.stepActionEventTypeToJSON = exports.stepActionEventTypeFromJSON = exports.StepActionEventType = exports.groupKeyActionEventTypeToJSON = exports.groupKeyActionEventTypeFromJSON = exports.GroupKeyActionEventType = exports.actionTypeToJSON = exports.actionTypeFromJSON = exports.ActionType = exports.protobufPackage = void 0;
|
|
26
|
+
exports.DispatcherDefinition = exports.HeartbeatResponse = exports.HeartbeatRequest = exports.OverridesDataResponse = exports.OverridesData = exports.StepRunResult = exports.WorkflowRunEvent = exports.WorkflowEvent = exports.SubscribeToWorkflowRunsRequest = exports.SubscribeToWorkflowEventsRequest = exports.ActionEventResponse = exports.StepActionEvent = exports.GroupKeyActionEvent = exports.WorkerUnsubscribeResponse = exports.WorkerUnsubscribeRequest = exports.WorkerListenRequest = exports.AssignedAction = exports.WorkerRegisterResponse = exports.WorkerRegisterRequest = exports.workflowRunEventTypeToJSON = exports.workflowRunEventTypeFromJSON = exports.WorkflowRunEventType = exports.resourceEventTypeToJSON = exports.resourceEventTypeFromJSON = exports.ResourceEventType = exports.resourceTypeToJSON = exports.resourceTypeFromJSON = exports.ResourceType = exports.stepActionEventTypeToJSON = exports.stepActionEventTypeFromJSON = exports.StepActionEventType = exports.groupKeyActionEventTypeToJSON = exports.groupKeyActionEventTypeFromJSON = exports.GroupKeyActionEventType = exports.actionTypeToJSON = exports.actionTypeFromJSON = exports.ActionType = exports.protobufPackage = void 0;
|
|
27
27
|
const _m0 = __importStar(require("protobufjs/minimal"));
|
|
28
28
|
const timestamp_1 = require("../google/protobuf/timestamp");
|
|
29
29
|
exports.protobufPackage = '';
|
|
@@ -258,6 +258,33 @@ function resourceEventTypeToJSON(object) {
|
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
exports.resourceEventTypeToJSON = resourceEventTypeToJSON;
|
|
261
|
+
var WorkflowRunEventType;
|
|
262
|
+
(function (WorkflowRunEventType) {
|
|
263
|
+
WorkflowRunEventType[WorkflowRunEventType["WORKFLOW_RUN_EVENT_TYPE_FINISHED"] = 0] = "WORKFLOW_RUN_EVENT_TYPE_FINISHED";
|
|
264
|
+
WorkflowRunEventType[WorkflowRunEventType["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
265
|
+
})(WorkflowRunEventType || (exports.WorkflowRunEventType = WorkflowRunEventType = {}));
|
|
266
|
+
function workflowRunEventTypeFromJSON(object) {
|
|
267
|
+
switch (object) {
|
|
268
|
+
case 0:
|
|
269
|
+
case 'WORKFLOW_RUN_EVENT_TYPE_FINISHED':
|
|
270
|
+
return WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED;
|
|
271
|
+
case -1:
|
|
272
|
+
case 'UNRECOGNIZED':
|
|
273
|
+
default:
|
|
274
|
+
return WorkflowRunEventType.UNRECOGNIZED;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
exports.workflowRunEventTypeFromJSON = workflowRunEventTypeFromJSON;
|
|
278
|
+
function workflowRunEventTypeToJSON(object) {
|
|
279
|
+
switch (object) {
|
|
280
|
+
case WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED:
|
|
281
|
+
return 'WORKFLOW_RUN_EVENT_TYPE_FINISHED';
|
|
282
|
+
case WorkflowRunEventType.UNRECOGNIZED:
|
|
283
|
+
default:
|
|
284
|
+
return 'UNRECOGNIZED';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
exports.workflowRunEventTypeToJSON = workflowRunEventTypeToJSON;
|
|
261
288
|
function createBaseWorkerRegisterRequest() {
|
|
262
289
|
return { workerName: '', actions: [], services: [], maxRuns: undefined };
|
|
263
290
|
}
|
|
@@ -1276,6 +1303,59 @@ exports.SubscribeToWorkflowEventsRequest = {
|
|
|
1276
1303
|
return message;
|
|
1277
1304
|
},
|
|
1278
1305
|
};
|
|
1306
|
+
function createBaseSubscribeToWorkflowRunsRequest() {
|
|
1307
|
+
return { workflowRunId: '' };
|
|
1308
|
+
}
|
|
1309
|
+
exports.SubscribeToWorkflowRunsRequest = {
|
|
1310
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
1311
|
+
if (message.workflowRunId !== '') {
|
|
1312
|
+
writer.uint32(10).string(message.workflowRunId);
|
|
1313
|
+
}
|
|
1314
|
+
return writer;
|
|
1315
|
+
},
|
|
1316
|
+
decode(input, length) {
|
|
1317
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
1318
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1319
|
+
const message = createBaseSubscribeToWorkflowRunsRequest();
|
|
1320
|
+
while (reader.pos < end) {
|
|
1321
|
+
const tag = reader.uint32();
|
|
1322
|
+
switch (tag >>> 3) {
|
|
1323
|
+
case 1:
|
|
1324
|
+
if (tag !== 10) {
|
|
1325
|
+
break;
|
|
1326
|
+
}
|
|
1327
|
+
message.workflowRunId = reader.string();
|
|
1328
|
+
continue;
|
|
1329
|
+
}
|
|
1330
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1331
|
+
break;
|
|
1332
|
+
}
|
|
1333
|
+
reader.skipType(tag & 7);
|
|
1334
|
+
}
|
|
1335
|
+
return message;
|
|
1336
|
+
},
|
|
1337
|
+
fromJSON(object) {
|
|
1338
|
+
return {
|
|
1339
|
+
workflowRunId: isSet(object.workflowRunId) ? globalThis.String(object.workflowRunId) : '',
|
|
1340
|
+
};
|
|
1341
|
+
},
|
|
1342
|
+
toJSON(message) {
|
|
1343
|
+
const obj = {};
|
|
1344
|
+
if (message.workflowRunId !== '') {
|
|
1345
|
+
obj.workflowRunId = message.workflowRunId;
|
|
1346
|
+
}
|
|
1347
|
+
return obj;
|
|
1348
|
+
},
|
|
1349
|
+
create(base) {
|
|
1350
|
+
return exports.SubscribeToWorkflowRunsRequest.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
1351
|
+
},
|
|
1352
|
+
fromPartial(object) {
|
|
1353
|
+
var _a;
|
|
1354
|
+
const message = createBaseSubscribeToWorkflowRunsRequest();
|
|
1355
|
+
message.workflowRunId = (_a = object.workflowRunId) !== null && _a !== void 0 ? _a : '';
|
|
1356
|
+
return message;
|
|
1357
|
+
},
|
|
1358
|
+
};
|
|
1279
1359
|
function createBaseWorkflowEvent() {
|
|
1280
1360
|
return {
|
|
1281
1361
|
workflowRunId: '',
|
|
@@ -1453,6 +1533,215 @@ exports.WorkflowEvent = {
|
|
|
1453
1533
|
return message;
|
|
1454
1534
|
},
|
|
1455
1535
|
};
|
|
1536
|
+
function createBaseWorkflowRunEvent() {
|
|
1537
|
+
return { workflowRunId: '', eventType: 0, eventTimestamp: undefined, results: [] };
|
|
1538
|
+
}
|
|
1539
|
+
exports.WorkflowRunEvent = {
|
|
1540
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
1541
|
+
if (message.workflowRunId !== '') {
|
|
1542
|
+
writer.uint32(10).string(message.workflowRunId);
|
|
1543
|
+
}
|
|
1544
|
+
if (message.eventType !== 0) {
|
|
1545
|
+
writer.uint32(16).int32(message.eventType);
|
|
1546
|
+
}
|
|
1547
|
+
if (message.eventTimestamp !== undefined) {
|
|
1548
|
+
timestamp_1.Timestamp.encode(toTimestamp(message.eventTimestamp), writer.uint32(26).fork()).ldelim();
|
|
1549
|
+
}
|
|
1550
|
+
for (const v of message.results) {
|
|
1551
|
+
exports.StepRunResult.encode(v, writer.uint32(34).fork()).ldelim();
|
|
1552
|
+
}
|
|
1553
|
+
return writer;
|
|
1554
|
+
},
|
|
1555
|
+
decode(input, length) {
|
|
1556
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
1557
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1558
|
+
const message = createBaseWorkflowRunEvent();
|
|
1559
|
+
while (reader.pos < end) {
|
|
1560
|
+
const tag = reader.uint32();
|
|
1561
|
+
switch (tag >>> 3) {
|
|
1562
|
+
case 1:
|
|
1563
|
+
if (tag !== 10) {
|
|
1564
|
+
break;
|
|
1565
|
+
}
|
|
1566
|
+
message.workflowRunId = reader.string();
|
|
1567
|
+
continue;
|
|
1568
|
+
case 2:
|
|
1569
|
+
if (tag !== 16) {
|
|
1570
|
+
break;
|
|
1571
|
+
}
|
|
1572
|
+
message.eventType = reader.int32();
|
|
1573
|
+
continue;
|
|
1574
|
+
case 3:
|
|
1575
|
+
if (tag !== 26) {
|
|
1576
|
+
break;
|
|
1577
|
+
}
|
|
1578
|
+
message.eventTimestamp = fromTimestamp(timestamp_1.Timestamp.decode(reader, reader.uint32()));
|
|
1579
|
+
continue;
|
|
1580
|
+
case 4:
|
|
1581
|
+
if (tag !== 34) {
|
|
1582
|
+
break;
|
|
1583
|
+
}
|
|
1584
|
+
message.results.push(exports.StepRunResult.decode(reader, reader.uint32()));
|
|
1585
|
+
continue;
|
|
1586
|
+
}
|
|
1587
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1588
|
+
break;
|
|
1589
|
+
}
|
|
1590
|
+
reader.skipType(tag & 7);
|
|
1591
|
+
}
|
|
1592
|
+
return message;
|
|
1593
|
+
},
|
|
1594
|
+
fromJSON(object) {
|
|
1595
|
+
return {
|
|
1596
|
+
workflowRunId: isSet(object.workflowRunId) ? globalThis.String(object.workflowRunId) : '',
|
|
1597
|
+
eventType: isSet(object.eventType) ? workflowRunEventTypeFromJSON(object.eventType) : 0,
|
|
1598
|
+
eventTimestamp: isSet(object.eventTimestamp)
|
|
1599
|
+
? fromJsonTimestamp(object.eventTimestamp)
|
|
1600
|
+
: undefined,
|
|
1601
|
+
results: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.results)
|
|
1602
|
+
? object.results.map((e) => exports.StepRunResult.fromJSON(e))
|
|
1603
|
+
: [],
|
|
1604
|
+
};
|
|
1605
|
+
},
|
|
1606
|
+
toJSON(message) {
|
|
1607
|
+
var _a;
|
|
1608
|
+
const obj = {};
|
|
1609
|
+
if (message.workflowRunId !== '') {
|
|
1610
|
+
obj.workflowRunId = message.workflowRunId;
|
|
1611
|
+
}
|
|
1612
|
+
if (message.eventType !== 0) {
|
|
1613
|
+
obj.eventType = workflowRunEventTypeToJSON(message.eventType);
|
|
1614
|
+
}
|
|
1615
|
+
if (message.eventTimestamp !== undefined) {
|
|
1616
|
+
obj.eventTimestamp = message.eventTimestamp.toISOString();
|
|
1617
|
+
}
|
|
1618
|
+
if ((_a = message.results) === null || _a === void 0 ? void 0 : _a.length) {
|
|
1619
|
+
obj.results = message.results.map((e) => exports.StepRunResult.toJSON(e));
|
|
1620
|
+
}
|
|
1621
|
+
return obj;
|
|
1622
|
+
},
|
|
1623
|
+
create(base) {
|
|
1624
|
+
return exports.WorkflowRunEvent.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
1625
|
+
},
|
|
1626
|
+
fromPartial(object) {
|
|
1627
|
+
var _a, _b, _c, _d;
|
|
1628
|
+
const message = createBaseWorkflowRunEvent();
|
|
1629
|
+
message.workflowRunId = (_a = object.workflowRunId) !== null && _a !== void 0 ? _a : '';
|
|
1630
|
+
message.eventType = (_b = object.eventType) !== null && _b !== void 0 ? _b : 0;
|
|
1631
|
+
message.eventTimestamp = (_c = object.eventTimestamp) !== null && _c !== void 0 ? _c : undefined;
|
|
1632
|
+
message.results = ((_d = object.results) === null || _d === void 0 ? void 0 : _d.map((e) => exports.StepRunResult.fromPartial(e))) || [];
|
|
1633
|
+
return message;
|
|
1634
|
+
},
|
|
1635
|
+
};
|
|
1636
|
+
function createBaseStepRunResult() {
|
|
1637
|
+
return { stepRunId: '', stepReadableId: '', jobRunId: '', error: undefined, output: undefined };
|
|
1638
|
+
}
|
|
1639
|
+
exports.StepRunResult = {
|
|
1640
|
+
encode(message, writer = _m0.Writer.create()) {
|
|
1641
|
+
if (message.stepRunId !== '') {
|
|
1642
|
+
writer.uint32(10).string(message.stepRunId);
|
|
1643
|
+
}
|
|
1644
|
+
if (message.stepReadableId !== '') {
|
|
1645
|
+
writer.uint32(18).string(message.stepReadableId);
|
|
1646
|
+
}
|
|
1647
|
+
if (message.jobRunId !== '') {
|
|
1648
|
+
writer.uint32(26).string(message.jobRunId);
|
|
1649
|
+
}
|
|
1650
|
+
if (message.error !== undefined) {
|
|
1651
|
+
writer.uint32(34).string(message.error);
|
|
1652
|
+
}
|
|
1653
|
+
if (message.output !== undefined) {
|
|
1654
|
+
writer.uint32(42).string(message.output);
|
|
1655
|
+
}
|
|
1656
|
+
return writer;
|
|
1657
|
+
},
|
|
1658
|
+
decode(input, length) {
|
|
1659
|
+
const reader = input instanceof _m0.Reader ? input : _m0.Reader.create(input);
|
|
1660
|
+
let end = length === undefined ? reader.len : reader.pos + length;
|
|
1661
|
+
const message = createBaseStepRunResult();
|
|
1662
|
+
while (reader.pos < end) {
|
|
1663
|
+
const tag = reader.uint32();
|
|
1664
|
+
switch (tag >>> 3) {
|
|
1665
|
+
case 1:
|
|
1666
|
+
if (tag !== 10) {
|
|
1667
|
+
break;
|
|
1668
|
+
}
|
|
1669
|
+
message.stepRunId = reader.string();
|
|
1670
|
+
continue;
|
|
1671
|
+
case 2:
|
|
1672
|
+
if (tag !== 18) {
|
|
1673
|
+
break;
|
|
1674
|
+
}
|
|
1675
|
+
message.stepReadableId = reader.string();
|
|
1676
|
+
continue;
|
|
1677
|
+
case 3:
|
|
1678
|
+
if (tag !== 26) {
|
|
1679
|
+
break;
|
|
1680
|
+
}
|
|
1681
|
+
message.jobRunId = reader.string();
|
|
1682
|
+
continue;
|
|
1683
|
+
case 4:
|
|
1684
|
+
if (tag !== 34) {
|
|
1685
|
+
break;
|
|
1686
|
+
}
|
|
1687
|
+
message.error = reader.string();
|
|
1688
|
+
continue;
|
|
1689
|
+
case 5:
|
|
1690
|
+
if (tag !== 42) {
|
|
1691
|
+
break;
|
|
1692
|
+
}
|
|
1693
|
+
message.output = reader.string();
|
|
1694
|
+
continue;
|
|
1695
|
+
}
|
|
1696
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1697
|
+
break;
|
|
1698
|
+
}
|
|
1699
|
+
reader.skipType(tag & 7);
|
|
1700
|
+
}
|
|
1701
|
+
return message;
|
|
1702
|
+
},
|
|
1703
|
+
fromJSON(object) {
|
|
1704
|
+
return {
|
|
1705
|
+
stepRunId: isSet(object.stepRunId) ? globalThis.String(object.stepRunId) : '',
|
|
1706
|
+
stepReadableId: isSet(object.stepReadableId) ? globalThis.String(object.stepReadableId) : '',
|
|
1707
|
+
jobRunId: isSet(object.jobRunId) ? globalThis.String(object.jobRunId) : '',
|
|
1708
|
+
error: isSet(object.error) ? globalThis.String(object.error) : undefined,
|
|
1709
|
+
output: isSet(object.output) ? globalThis.String(object.output) : undefined,
|
|
1710
|
+
};
|
|
1711
|
+
},
|
|
1712
|
+
toJSON(message) {
|
|
1713
|
+
const obj = {};
|
|
1714
|
+
if (message.stepRunId !== '') {
|
|
1715
|
+
obj.stepRunId = message.stepRunId;
|
|
1716
|
+
}
|
|
1717
|
+
if (message.stepReadableId !== '') {
|
|
1718
|
+
obj.stepReadableId = message.stepReadableId;
|
|
1719
|
+
}
|
|
1720
|
+
if (message.jobRunId !== '') {
|
|
1721
|
+
obj.jobRunId = message.jobRunId;
|
|
1722
|
+
}
|
|
1723
|
+
if (message.error !== undefined) {
|
|
1724
|
+
obj.error = message.error;
|
|
1725
|
+
}
|
|
1726
|
+
if (message.output !== undefined) {
|
|
1727
|
+
obj.output = message.output;
|
|
1728
|
+
}
|
|
1729
|
+
return obj;
|
|
1730
|
+
},
|
|
1731
|
+
create(base) {
|
|
1732
|
+
return exports.StepRunResult.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
1733
|
+
},
|
|
1734
|
+
fromPartial(object) {
|
|
1735
|
+
var _a, _b, _c, _d, _e;
|
|
1736
|
+
const message = createBaseStepRunResult();
|
|
1737
|
+
message.stepRunId = (_a = object.stepRunId) !== null && _a !== void 0 ? _a : '';
|
|
1738
|
+
message.stepReadableId = (_b = object.stepReadableId) !== null && _b !== void 0 ? _b : '';
|
|
1739
|
+
message.jobRunId = (_c = object.jobRunId) !== null && _c !== void 0 ? _c : '';
|
|
1740
|
+
message.error = (_d = object.error) !== null && _d !== void 0 ? _d : undefined;
|
|
1741
|
+
message.output = (_e = object.output) !== null && _e !== void 0 ? _e : undefined;
|
|
1742
|
+
return message;
|
|
1743
|
+
},
|
|
1744
|
+
};
|
|
1456
1745
|
function createBaseOverridesData() {
|
|
1457
1746
|
return { stepRunId: '', path: '', value: '', callerFilename: '' };
|
|
1458
1747
|
}
|
|
@@ -1738,6 +2027,14 @@ exports.DispatcherDefinition = {
|
|
|
1738
2027
|
responseStream: true,
|
|
1739
2028
|
options: {},
|
|
1740
2029
|
},
|
|
2030
|
+
subscribeToWorkflowRuns: {
|
|
2031
|
+
name: 'SubscribeToWorkflowRuns',
|
|
2032
|
+
requestType: exports.SubscribeToWorkflowRunsRequest,
|
|
2033
|
+
requestStream: true,
|
|
2034
|
+
responseType: exports.WorkflowRunEvent,
|
|
2035
|
+
responseStream: true,
|
|
2036
|
+
options: {},
|
|
2037
|
+
},
|
|
1741
2038
|
sendStepActionEvent: {
|
|
1742
2039
|
name: 'SendStepActionEvent',
|
|
1743
2040
|
requestType: exports.StepActionEvent,
|
|
@@ -41,6 +41,8 @@ export interface CreateWorkflowVersionOpts {
|
|
|
41
41
|
concurrency: WorkflowConcurrencyOpts | undefined;
|
|
42
42
|
/** (optional) the timeout for the schedule */
|
|
43
43
|
scheduleTimeout?: string | undefined;
|
|
44
|
+
/** (optional) the input for the cron trigger */
|
|
45
|
+
cronInput?: string | undefined;
|
|
44
46
|
}
|
|
45
47
|
export interface WorkflowConcurrencyOpts {
|
|
46
48
|
/** (required) the action id for getting the concurrency group */
|
|
@@ -56,8 +58,6 @@ export interface CreateWorkflowJobOpts {
|
|
|
56
58
|
name: string;
|
|
57
59
|
/** (optional) the job description */
|
|
58
60
|
description: string;
|
|
59
|
-
/** (optional) the job timeout */
|
|
60
|
-
timeout: string;
|
|
61
61
|
/** (required) the job steps */
|
|
62
62
|
steps: CreateWorkflowStepOpts[];
|
|
63
63
|
}
|
|
@@ -177,6 +177,7 @@ function createBaseCreateWorkflowVersionOpts() {
|
|
|
177
177
|
jobs: [],
|
|
178
178
|
concurrency: undefined,
|
|
179
179
|
scheduleTimeout: undefined,
|
|
180
|
+
cronInput: undefined,
|
|
180
181
|
};
|
|
181
182
|
}
|
|
182
183
|
exports.CreateWorkflowVersionOpts = {
|
|
@@ -208,6 +209,9 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
208
209
|
if (message.scheduleTimeout !== undefined) {
|
|
209
210
|
writer.uint32(74).string(message.scheduleTimeout);
|
|
210
211
|
}
|
|
212
|
+
if (message.cronInput !== undefined) {
|
|
213
|
+
writer.uint32(82).string(message.cronInput);
|
|
214
|
+
}
|
|
211
215
|
return writer;
|
|
212
216
|
},
|
|
213
217
|
decode(input, length) {
|
|
@@ -271,6 +275,12 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
271
275
|
}
|
|
272
276
|
message.scheduleTimeout = reader.string();
|
|
273
277
|
continue;
|
|
278
|
+
case 10:
|
|
279
|
+
if (tag !== 82) {
|
|
280
|
+
break;
|
|
281
|
+
}
|
|
282
|
+
message.cronInput = reader.string();
|
|
283
|
+
continue;
|
|
274
284
|
}
|
|
275
285
|
if ((tag & 7) === 4 || tag === 0) {
|
|
276
286
|
break;
|
|
@@ -302,6 +312,7 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
302
312
|
scheduleTimeout: isSet(object.scheduleTimeout)
|
|
303
313
|
? globalThis.String(object.scheduleTimeout)
|
|
304
314
|
: undefined,
|
|
315
|
+
cronInput: isSet(object.cronInput) ? globalThis.String(object.cronInput) : undefined,
|
|
305
316
|
};
|
|
306
317
|
},
|
|
307
318
|
toJSON(message) {
|
|
@@ -334,13 +345,16 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
334
345
|
if (message.scheduleTimeout !== undefined) {
|
|
335
346
|
obj.scheduleTimeout = message.scheduleTimeout;
|
|
336
347
|
}
|
|
348
|
+
if (message.cronInput !== undefined) {
|
|
349
|
+
obj.cronInput = message.cronInput;
|
|
350
|
+
}
|
|
337
351
|
return obj;
|
|
338
352
|
},
|
|
339
353
|
create(base) {
|
|
340
354
|
return exports.CreateWorkflowVersionOpts.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
341
355
|
},
|
|
342
356
|
fromPartial(object) {
|
|
343
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
357
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
344
358
|
const message = createBaseCreateWorkflowVersionOpts();
|
|
345
359
|
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
|
|
346
360
|
message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
|
|
@@ -354,6 +368,7 @@ exports.CreateWorkflowVersionOpts = {
|
|
|
354
368
|
? exports.WorkflowConcurrencyOpts.fromPartial(object.concurrency)
|
|
355
369
|
: undefined;
|
|
356
370
|
message.scheduleTimeout = (_h = object.scheduleTimeout) !== null && _h !== void 0 ? _h : undefined;
|
|
371
|
+
message.cronInput = (_j = object.cronInput) !== null && _j !== void 0 ? _j : undefined;
|
|
357
372
|
return message;
|
|
358
373
|
},
|
|
359
374
|
};
|
|
@@ -441,7 +456,7 @@ exports.WorkflowConcurrencyOpts = {
|
|
|
441
456
|
},
|
|
442
457
|
};
|
|
443
458
|
function createBaseCreateWorkflowJobOpts() {
|
|
444
|
-
return { name: '', description: '',
|
|
459
|
+
return { name: '', description: '', steps: [] };
|
|
445
460
|
}
|
|
446
461
|
exports.CreateWorkflowJobOpts = {
|
|
447
462
|
encode(message, writer = _m0.Writer.create()) {
|
|
@@ -451,9 +466,6 @@ exports.CreateWorkflowJobOpts = {
|
|
|
451
466
|
if (message.description !== '') {
|
|
452
467
|
writer.uint32(18).string(message.description);
|
|
453
468
|
}
|
|
454
|
-
if (message.timeout !== '') {
|
|
455
|
-
writer.uint32(26).string(message.timeout);
|
|
456
|
-
}
|
|
457
469
|
for (const v of message.steps) {
|
|
458
470
|
exports.CreateWorkflowStepOpts.encode(v, writer.uint32(34).fork()).ldelim();
|
|
459
471
|
}
|
|
@@ -478,12 +490,6 @@ exports.CreateWorkflowJobOpts = {
|
|
|
478
490
|
}
|
|
479
491
|
message.description = reader.string();
|
|
480
492
|
continue;
|
|
481
|
-
case 3:
|
|
482
|
-
if (tag !== 26) {
|
|
483
|
-
break;
|
|
484
|
-
}
|
|
485
|
-
message.timeout = reader.string();
|
|
486
|
-
continue;
|
|
487
493
|
case 4:
|
|
488
494
|
if (tag !== 34) {
|
|
489
495
|
break;
|
|
@@ -502,7 +508,6 @@ exports.CreateWorkflowJobOpts = {
|
|
|
502
508
|
return {
|
|
503
509
|
name: isSet(object.name) ? globalThis.String(object.name) : '',
|
|
504
510
|
description: isSet(object.description) ? globalThis.String(object.description) : '',
|
|
505
|
-
timeout: isSet(object.timeout) ? globalThis.String(object.timeout) : '',
|
|
506
511
|
steps: globalThis.Array.isArray(object === null || object === void 0 ? void 0 : object.steps)
|
|
507
512
|
? object.steps.map((e) => exports.CreateWorkflowStepOpts.fromJSON(e))
|
|
508
513
|
: [],
|
|
@@ -517,9 +522,6 @@ exports.CreateWorkflowJobOpts = {
|
|
|
517
522
|
if (message.description !== '') {
|
|
518
523
|
obj.description = message.description;
|
|
519
524
|
}
|
|
520
|
-
if (message.timeout !== '') {
|
|
521
|
-
obj.timeout = message.timeout;
|
|
522
|
-
}
|
|
523
525
|
if ((_a = message.steps) === null || _a === void 0 ? void 0 : _a.length) {
|
|
524
526
|
obj.steps = message.steps.map((e) => exports.CreateWorkflowStepOpts.toJSON(e));
|
|
525
527
|
}
|
|
@@ -529,12 +531,11 @@ exports.CreateWorkflowJobOpts = {
|
|
|
529
531
|
return exports.CreateWorkflowJobOpts.fromPartial(base !== null && base !== void 0 ? base : {});
|
|
530
532
|
},
|
|
531
533
|
fromPartial(object) {
|
|
532
|
-
var _a, _b, _c
|
|
534
|
+
var _a, _b, _c;
|
|
533
535
|
const message = createBaseCreateWorkflowJobOpts();
|
|
534
536
|
message.name = (_a = object.name) !== null && _a !== void 0 ? _a : '';
|
|
535
537
|
message.description = (_b = object.description) !== null && _b !== void 0 ? _b : '';
|
|
536
|
-
message.
|
|
537
|
-
message.steps = ((_d = object.steps) === null || _d === void 0 ? void 0 : _d.map((e) => exports.CreateWorkflowStepOpts.fromPartial(e))) || [];
|
|
538
|
+
message.steps = ((_c = object.steps) === null || _c === void 0 ? void 0 : _c.map((e) => exports.CreateWorkflowStepOpts.fromPartial(e))) || [];
|
|
538
539
|
return message;
|
|
539
540
|
},
|
|
540
541
|
};
|
package/step.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Action } from './clients/dispatcher/action-listener';
|
|
|
3
3
|
import { LogLevel } from './clients/event/event-client';
|
|
4
4
|
import { Logger } from './util/logger';
|
|
5
5
|
import { HatchetClient } from './clients/hatchet-client';
|
|
6
|
-
import {
|
|
6
|
+
import { WorkflowRunEvent } from './protoc/dispatcher';
|
|
7
7
|
export declare const CreateRateLimitSchema: z.ZodObject<{
|
|
8
8
|
key: z.ZodString;
|
|
9
9
|
units: z.ZodNumber;
|
|
@@ -60,12 +60,10 @@ interface ContextData<T, K> {
|
|
|
60
60
|
}
|
|
61
61
|
declare class ChildWorkflowRef<T> {
|
|
62
62
|
workflowRunId: Promise<string>;
|
|
63
|
+
parentWorkflowRunId: string;
|
|
63
64
|
client: HatchetClient;
|
|
64
|
-
constructor(workflowRunId: Promise<string>, client: HatchetClient);
|
|
65
|
-
stream(): Promise<AsyncGenerator<
|
|
66
|
-
type: RunEventType;
|
|
67
|
-
payload: string;
|
|
68
|
-
}, void, unknown>>;
|
|
65
|
+
constructor(workflowRunId: Promise<string>, parentWorkflowRunId: string, client: HatchetClient);
|
|
66
|
+
stream(): Promise<AsyncGenerator<WorkflowRunEvent, void, unknown>>;
|
|
69
67
|
result(): Promise<T>;
|
|
70
68
|
toJSON(): Promise<string>;
|
|
71
69
|
}
|
package/step.js
CHANGED
|
@@ -49,7 +49,7 @@ const z = __importStar(require("zod"));
|
|
|
49
49
|
const workflow_1 = require("./workflow");
|
|
50
50
|
const logger_1 = require("./util/logger");
|
|
51
51
|
const parse_1 = require("./util/parse");
|
|
52
|
-
const
|
|
52
|
+
const dispatcher_1 = require("./protoc/dispatcher");
|
|
53
53
|
exports.CreateRateLimitSchema = z.object({
|
|
54
54
|
key: z.string(),
|
|
55
55
|
units: z.number().min(1),
|
|
@@ -62,38 +62,35 @@ exports.CreateStepSchema = z.object({
|
|
|
62
62
|
rate_limits: z.array(exports.CreateRateLimitSchema).optional(),
|
|
63
63
|
});
|
|
64
64
|
class ChildWorkflowRef {
|
|
65
|
-
constructor(workflowRunId, client) {
|
|
65
|
+
constructor(workflowRunId, parentWorkflowRunId, client) {
|
|
66
66
|
this.workflowRunId = workflowRunId;
|
|
67
|
+
this.parentWorkflowRunId = parentWorkflowRunId;
|
|
67
68
|
this.client = client;
|
|
68
69
|
}
|
|
69
70
|
stream() {
|
|
70
71
|
return __awaiter(this, void 0, void 0, function* () {
|
|
71
72
|
const workflowRunId = yield this.workflowRunId;
|
|
72
|
-
|
|
73
|
+
const listener = yield this.client.listener.getChildListener(workflowRunId, this.parentWorkflowRunId);
|
|
74
|
+
return listener.stream();
|
|
73
75
|
});
|
|
74
76
|
}
|
|
75
77
|
result() {
|
|
76
78
|
return __awaiter(this, void 0, void 0, function* () {
|
|
77
|
-
const
|
|
78
|
-
const listener = yield this.client.listener.get(workflowRunId);
|
|
79
|
+
const listener = yield this.stream();
|
|
79
80
|
return new Promise((resolve, reject) => {
|
|
80
81
|
(() => __awaiter(this, void 0, void 0, function* () {
|
|
81
82
|
var _a, e_1, _b, _c;
|
|
82
83
|
try {
|
|
83
|
-
for (var _d = true, _e = __asyncValues(yield listener
|
|
84
|
+
for (var _d = true, _e = __asyncValues(yield listener), _f; _f = yield _e.next(), _a = _f.done, !_a; _d = true) {
|
|
84
85
|
_c = _f.value;
|
|
85
86
|
_d = false;
|
|
86
87
|
const event = _c;
|
|
87
|
-
if (event.
|
|
88
|
-
event.
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
if (event.type === listener_client_1.RunEventType.WORKFLOW_RUN_EVENT_TYPE_COMPLETED) {
|
|
95
|
-
resolve(JSON.parse(event.payload));
|
|
96
|
-
listener.close();
|
|
88
|
+
if (event.eventType === dispatcher_1.WorkflowRunEventType.WORKFLOW_RUN_EVENT_TYPE_FINISHED) {
|
|
89
|
+
if (event.results.some((r) => !!r.error)) {
|
|
90
|
+
reject(event.results);
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
resolve(event.results);
|
|
97
94
|
return;
|
|
98
95
|
}
|
|
99
96
|
}
|
|
@@ -210,7 +207,7 @@ class Context {
|
|
|
210
207
|
childIndex: this.spawnIndex,
|
|
211
208
|
});
|
|
212
209
|
this.spawnIndex += 1;
|
|
213
|
-
return new ChildWorkflowRef(childWorkflowRunIdPromise, this.client);
|
|
210
|
+
return new ChildWorkflowRef(childWorkflowRunIdPromise, workflowRunId, this.client);
|
|
214
211
|
}
|
|
215
212
|
}
|
|
216
213
|
exports.Context = Context;
|
|
@@ -72,7 +72,7 @@ class ConfigLoader {
|
|
|
72
72
|
tls_config: tlsConfig,
|
|
73
73
|
log_level: (_4 = (_3 = (_2 = override === null || override === void 0 ? void 0 : override.log_level) !== null && _2 !== void 0 ? _2 : yaml === null || yaml === void 0 ? void 0 : yaml.log_level) !== null && _3 !== void 0 ? _3 : this.env('HATCHET_CLIENT_LOG_LEVEL')) !== null && _4 !== void 0 ? _4 : 'INFO',
|
|
74
74
|
tenant_id: tenantId,
|
|
75
|
-
namespace: namespace ? `${namespace}_
|
|
75
|
+
namespace: namespace ? `${namespace}_`.toLowerCase() : '',
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
static get default_yaml_config_path() {
|