@hatchet-dev/typescript-sdk 0.0.7 → 0.0.8

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.
Files changed (57) hide show
  1. package/clients/admin/admin-client.d.ts +12 -0
  2. package/clients/admin/admin-client.js +47 -0
  3. package/clients/dispatcher/action-listener.d.ts +26 -0
  4. package/clients/dispatcher/action-listener.js +113 -0
  5. package/clients/dispatcher/dispatcher-client.d.ts +20 -0
  6. package/clients/dispatcher/dispatcher-client.js +58 -0
  7. package/clients/event/event-client.d.ts +11 -0
  8. package/clients/event/event-client.js +32 -0
  9. package/clients/hatchet-client/client-config.d.ts +72 -0
  10. package/clients/hatchet-client/client-config.js +17 -0
  11. package/clients/hatchet-client/hatchet-client.d.ts +26 -0
  12. package/clients/hatchet-client/hatchet-client.js +133 -0
  13. package/clients/hatchet-client/index.d.ts +2 -0
  14. package/clients/hatchet-client/index.js +18 -0
  15. package/clients/worker/index.d.ts +1 -0
  16. package/clients/worker/index.js +17 -0
  17. package/clients/worker/worker.d.ts +34 -0
  18. package/clients/worker/worker.js +317 -0
  19. package/index.d.ts +2 -0
  20. package/index.js +4 -0
  21. package/package.json +2 -2
  22. package/protoc/dispatcher/dispatcher.d.ts +333 -0
  23. package/protoc/dispatcher/dispatcher.js +1152 -0
  24. package/protoc/dispatcher/index.d.ts +1 -0
  25. package/protoc/dispatcher/index.js +17 -0
  26. package/protoc/events/events.d.ts +165 -0
  27. package/protoc/events/events.js +443 -0
  28. package/protoc/events/index.d.ts +1 -0
  29. package/protoc/events/index.js +17 -0
  30. package/protoc/google/protobuf/timestamp.d.ts +121 -0
  31. package/protoc/google/protobuf/timestamp.js +110 -0
  32. package/protoc/google/protobuf/wrappers.d.ts +160 -0
  33. package/protoc/google/protobuf/wrappers.js +527 -0
  34. package/protoc/workflows/index.d.ts +1 -0
  35. package/protoc/workflows/index.js +17 -0
  36. package/protoc/workflows/workflows.d.ts +464 -0
  37. package/protoc/workflows/workflows.js +1951 -0
  38. package/sdk.d.ts +2 -0
  39. package/sdk.js +4 -0
  40. package/step.d.ts +33 -0
  41. package/step.js +65 -0
  42. package/util/config-loader/config-loader.d.ts +13 -0
  43. package/util/config-loader/config-loader.js +85 -0
  44. package/util/config-loader/index.d.ts +1 -0
  45. package/util/config-loader/index.js +17 -0
  46. package/util/errors/hatchet-error.d.ts +4 -0
  47. package/util/errors/hatchet-error.js +9 -0
  48. package/util/hatchet-promise/hatchet-promise.d.ts +6 -0
  49. package/util/hatchet-promise/hatchet-promise.js +12 -0
  50. package/util/logger/index.d.ts +1 -0
  51. package/util/logger/index.js +17 -0
  52. package/util/logger/logger.d.ts +12 -0
  53. package/util/logger/logger.js +37 -0
  54. package/util/sleep.d.ts +2 -0
  55. package/util/sleep.js +6 -0
  56. package/workflow.d.ts +111 -0
  57. package/workflow.js +54 -0
@@ -0,0 +1,317 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
18
+ var __importDefault = (this && this.__importDefault) || function (mod) {
19
+ return (mod && mod.__esModule) ? mod : { "default": mod };
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.Worker = void 0;
23
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
24
+ const dispatcher_1 = require("../../protoc/dispatcher");
25
+ const hatchet_promise_1 = __importDefault(require("../../util/hatchet-promise/hatchet-promise"));
26
+ const workflows_1 = require("../../protoc/workflows");
27
+ const logger_1 = require("../../util/logger");
28
+ const sleep_1 = __importDefault(require("../../util/sleep"));
29
+ const step_1 = require("../../step");
30
+ class Worker {
31
+ constructor(client, options) {
32
+ this.serviceName = 'default';
33
+ this.futures = {};
34
+ this.contexts = {};
35
+ this.client = client;
36
+ this.name = options.name;
37
+ this.action_registry = {};
38
+ this.concurrency_action_registry = {};
39
+ process.on('SIGTERM', () => this.exitGracefully());
40
+ process.on('SIGINT', () => this.exitGracefully());
41
+ this.killing = false;
42
+ this.handle_kill = options.handleKill === undefined ? true : options.handleKill;
43
+ this.logger = new logger_1.Logger(`Worker/${this.name}`, this.client.config.log_level);
44
+ }
45
+ registerWorkflow(workflow) {
46
+ var _a, _b;
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ try {
49
+ const concurrency = ((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.action)
50
+ ? {
51
+ action: `${this.serviceName}:${workflow.concurrency.action}`,
52
+ maxRuns: workflow.concurrency.maxRuns || 1,
53
+ limitStrategy: workflow.concurrency.limitStrategy || workflows_1.ConcurrencyLimitStrategy.CANCEL_IN_PROGRESS,
54
+ }
55
+ : undefined;
56
+ yield this.client.admin.put_workflow({
57
+ name: workflow.id,
58
+ description: workflow.description,
59
+ version: workflow.version || '',
60
+ eventTriggers: workflow.on.event ? [workflow.on.event] : [],
61
+ cronTriggers: workflow.on.cron ? [workflow.on.cron] : [],
62
+ scheduledTriggers: [],
63
+ concurrency,
64
+ jobs: [
65
+ {
66
+ name: workflow.id,
67
+ timeout: workflow.timeout || '60s',
68
+ description: workflow.description,
69
+ steps: workflow.steps.map((step) => {
70
+ var _a;
71
+ return ({
72
+ readableId: step.name,
73
+ action: `${this.serviceName}:${step.name}`,
74
+ timeout: step.timeout || '60s',
75
+ inputs: '{}',
76
+ parents: (_a = step.parents) !== null && _a !== void 0 ? _a : [],
77
+ });
78
+ }),
79
+ },
80
+ ],
81
+ });
82
+ }
83
+ catch (e) {
84
+ throw new hatchet_error_1.default(`Could not register workflow: ${e.message}`);
85
+ }
86
+ this.action_registry = workflow.steps.reduce((acc, step) => {
87
+ acc[`${this.serviceName}:${step.name}`] = step.run;
88
+ return acc;
89
+ }, {});
90
+ this.concurrency_action_registry = ((_b = workflow.concurrency) === null || _b === void 0 ? void 0 : _b.action)
91
+ ? {
92
+ [`${this.serviceName}:${workflow.concurrency.action}`]: workflow.concurrency.key,
93
+ }
94
+ : {};
95
+ });
96
+ }
97
+ handleStartStepRun(action) {
98
+ const { actionId } = action;
99
+ const context = new step_1.Context(action.actionPayload);
100
+ this.contexts[action.stepRunId] = context;
101
+ const step = this.action_registry[actionId];
102
+ if (!step) {
103
+ this.logger.error(`Could not find step '${actionId}'`);
104
+ return;
105
+ }
106
+ const run = () => __awaiter(this, void 0, void 0, function* () {
107
+ return step(context);
108
+ });
109
+ const success = (result) => {
110
+ this.logger.info(`Step run ${action.stepRunId} succeeded`);
111
+ try {
112
+ // Send the action event to the dispatcher
113
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_COMPLETED, result);
114
+ this.client.dispatcher.sendStepActionEvent(event);
115
+ // delete the run from the futures
116
+ delete this.futures[action.stepRunId];
117
+ }
118
+ catch (e) {
119
+ this.logger.error(`Could not send action event: ${e.message}`);
120
+ }
121
+ };
122
+ const failure = (error) => {
123
+ this.logger.error(`Step run ${action.stepRunId} failed: ${error.message}`);
124
+ try {
125
+ // Send the action event to the dispatcher
126
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_FAILED, error);
127
+ this.client.dispatcher.sendStepActionEvent(event);
128
+ // delete the run from the futures
129
+ delete this.futures[action.stepRunId];
130
+ }
131
+ catch (e) {
132
+ this.logger.error(`Could not send action event: ${e.message}`);
133
+ }
134
+ };
135
+ const future = new hatchet_promise_1.default(run().then(success).catch(failure));
136
+ this.futures[action.stepRunId] = future;
137
+ try {
138
+ // Send the action event to the dispatcher
139
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
140
+ this.client.dispatcher.sendStepActionEvent(event);
141
+ }
142
+ catch (e) {
143
+ this.logger.error(`Could not send action event: ${e.message}`);
144
+ }
145
+ }
146
+ handleStartGroupKeyRun(action) {
147
+ const { actionId } = action;
148
+ const context = new step_1.Context(action.actionPayload);
149
+ const key = action.getGroupKeyRunId;
150
+ this.contexts[key] = context;
151
+ const step = this.action_registry[actionId];
152
+ if (!step) {
153
+ this.logger.error(`Could not find step '${actionId}'`);
154
+ return;
155
+ }
156
+ const run = () => __awaiter(this, void 0, void 0, function* () {
157
+ return step(context);
158
+ });
159
+ const success = (result) => {
160
+ this.logger.info(`Step run ${action.stepRunId} succeeded`);
161
+ try {
162
+ // Send the action event to the dispatcher
163
+ const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_COMPLETED, result);
164
+ this.client.dispatcher.sendGroupKeyActionEvent(event);
165
+ // delete the run from the futures
166
+ delete this.futures[key];
167
+ }
168
+ catch (e) {
169
+ this.logger.error(`Could not send action event: ${e.message}`);
170
+ }
171
+ };
172
+ const failure = (error) => {
173
+ this.logger.error(`Step run ${key} failed: ${error.message}`);
174
+ try {
175
+ // Send the action event to the dispatcher
176
+ const event = this.getGroupKeyActionEvent(action, dispatcher_1.GroupKeyActionEventType.GROUP_KEY_EVENT_TYPE_FAILED, error);
177
+ this.client.dispatcher.sendGroupKeyActionEvent(event);
178
+ // delete the run from the futures
179
+ delete this.futures[key];
180
+ }
181
+ catch (e) {
182
+ this.logger.error(`Could not send action event: ${e.message}`);
183
+ }
184
+ };
185
+ const future = new hatchet_promise_1.default(run().then(success).catch(failure));
186
+ this.futures[action.getGroupKeyRunId] = future;
187
+ try {
188
+ // Send the action event to the dispatcher
189
+ const event = this.getStepActionEvent(action, dispatcher_1.StepActionEventType.STEP_EVENT_TYPE_STARTED);
190
+ this.client.dispatcher.sendStepActionEvent(event);
191
+ }
192
+ catch (e) {
193
+ this.logger.error(`Could not send action event: ${e.message}`);
194
+ }
195
+ }
196
+ getStepActionEvent(action, eventType, payload = '') {
197
+ return {
198
+ workerId: this.name,
199
+ jobId: action.jobId,
200
+ jobRunId: action.jobRunId,
201
+ stepId: action.stepId,
202
+ stepRunId: action.stepRunId,
203
+ actionId: action.actionId,
204
+ eventTimestamp: new Date(),
205
+ eventType,
206
+ eventPayload: JSON.stringify(payload),
207
+ };
208
+ }
209
+ getGroupKeyActionEvent(action, eventType, payload = '') {
210
+ return {
211
+ workerId: this.name,
212
+ workflowRunId: action.workflowRunId,
213
+ getGroupKeyRunId: action.getGroupKeyRunId,
214
+ actionId: action.actionId,
215
+ eventTimestamp: new Date(),
216
+ eventType,
217
+ eventPayload: JSON.stringify(payload),
218
+ };
219
+ }
220
+ handleCancelStepRun(action) {
221
+ const { stepRunId } = action;
222
+ const future = this.futures[stepRunId];
223
+ const context = this.contexts[stepRunId];
224
+ // TODO send cancel signal to context
225
+ // if (context && context.cancel) {
226
+ // context.cancel();
227
+ // delete this.contexts[stepRunId];
228
+ // }
229
+ if (future) {
230
+ future.cancel();
231
+ delete this.futures[stepRunId];
232
+ }
233
+ }
234
+ stop() {
235
+ return __awaiter(this, void 0, void 0, function* () {
236
+ yield this.exitGracefully();
237
+ });
238
+ }
239
+ exitGracefully() {
240
+ var _a;
241
+ return __awaiter(this, void 0, void 0, function* () {
242
+ this.killing = true;
243
+ this.logger.info('Starting to exit...');
244
+ try {
245
+ (_a = this.listener) === null || _a === void 0 ? void 0 : _a.unregister();
246
+ }
247
+ catch (e) {
248
+ this.logger.error(`Could not unregister listener: ${e.message}`);
249
+ }
250
+ this.logger.info('Gracefully exiting hatchet worker, running tasks will attempt to finish...');
251
+ // attempt to wait for futures to finish
252
+ yield Promise.all(Object.values(this.futures).map(({ promise }) => promise));
253
+ if (this.handle_kill) {
254
+ this.logger.info('Exiting hatchet worker...');
255
+ process.exit(0);
256
+ }
257
+ });
258
+ }
259
+ start() {
260
+ var _a, e_1, _b, _c;
261
+ return __awaiter(this, void 0, void 0, function* () {
262
+ let retries = 0;
263
+ while (retries < 5) {
264
+ try {
265
+ this.listener = yield this.client.dispatcher.getActionListener({
266
+ workerName: this.name,
267
+ services: ['default'],
268
+ actions: Object.keys(this.action_registry),
269
+ });
270
+ const generator = this.listener.actions();
271
+ this.logger.info(`Worker ${this.name} listening for actions`);
272
+ try {
273
+ for (var _d = true, generator_1 = (e_1 = void 0, __asyncValues(generator)), generator_1_1; generator_1_1 = yield generator_1.next(), _a = generator_1_1.done, !_a; _d = true) {
274
+ _c = generator_1_1.value;
275
+ _d = false;
276
+ const action = _c;
277
+ this.logger.info(`Worker ${this.name} received action ${action.actionId}:${action.actionType}`);
278
+ if (action.actionType === dispatcher_1.ActionType.START_STEP_RUN) {
279
+ this.handleStartStepRun(action);
280
+ }
281
+ else if (action.actionType === dispatcher_1.ActionType.CANCEL_STEP_RUN) {
282
+ this.handleCancelStepRun(action);
283
+ }
284
+ else if (action.actionType === dispatcher_1.ActionType.START_GET_GROUP_KEY) {
285
+ this.handleStartGroupKeyRun(action);
286
+ }
287
+ else {
288
+ this.logger.error(`Worker ${this.name} received unknown action type ${action.actionType}`);
289
+ }
290
+ }
291
+ }
292
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
293
+ finally {
294
+ try {
295
+ if (!_d && !_a && (_b = generator_1.return)) yield _b.call(generator_1);
296
+ }
297
+ finally { if (e_1) throw e_1.error; }
298
+ }
299
+ break;
300
+ }
301
+ catch (e) {
302
+ this.logger.error(`Could not start worker: ${e.message}`);
303
+ retries += 1;
304
+ const wait = 500;
305
+ this.logger.error(`Could not start worker, retrying in ${500} seconds`);
306
+ yield (0, sleep_1.default)(wait);
307
+ }
308
+ }
309
+ if (this.killing)
310
+ return;
311
+ if (retries > 5) {
312
+ throw new hatchet_error_1.default('Could not start worker after 5 retries');
313
+ }
314
+ });
315
+ }
316
+ }
317
+ exports.Worker = Worker;
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { HatchetClient as Hatchet } from './clients/hatchet-client';
2
+ export default Hatchet;
package/index.js ADDED
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const hatchet_client_1 = require("./clients/hatchet-client");
4
+ exports.default = hatchet_client_1.HatchetClient;
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "files": [
8
- "dist",
8
+ "*",
9
9
  "!**/*.test.js",
10
10
  "!**/*.test.d.ts"
11
11
  ],
@@ -0,0 +1,333 @@
1
+ import type { CallContext, CallOptions } from "nice-grpc-common";
2
+ import * as _m0 from "protobufjs/minimal";
3
+ export declare const protobufPackage = "";
4
+ export declare enum ActionType {
5
+ START_STEP_RUN = 0,
6
+ CANCEL_STEP_RUN = 1,
7
+ START_GET_GROUP_KEY = 2,
8
+ UNRECOGNIZED = -1
9
+ }
10
+ export declare function actionTypeFromJSON(object: any): ActionType;
11
+ export declare function actionTypeToJSON(object: ActionType): string;
12
+ export declare enum GroupKeyActionEventType {
13
+ GROUP_KEY_EVENT_TYPE_UNKNOWN = 0,
14
+ GROUP_KEY_EVENT_TYPE_STARTED = 1,
15
+ GROUP_KEY_EVENT_TYPE_COMPLETED = 2,
16
+ GROUP_KEY_EVENT_TYPE_FAILED = 3,
17
+ UNRECOGNIZED = -1
18
+ }
19
+ export declare function groupKeyActionEventTypeFromJSON(object: any): GroupKeyActionEventType;
20
+ export declare function groupKeyActionEventTypeToJSON(object: GroupKeyActionEventType): string;
21
+ export declare enum StepActionEventType {
22
+ STEP_EVENT_TYPE_UNKNOWN = 0,
23
+ STEP_EVENT_TYPE_STARTED = 1,
24
+ STEP_EVENT_TYPE_COMPLETED = 2,
25
+ STEP_EVENT_TYPE_FAILED = 3,
26
+ UNRECOGNIZED = -1
27
+ }
28
+ export declare function stepActionEventTypeFromJSON(object: any): StepActionEventType;
29
+ export declare function stepActionEventTypeToJSON(object: StepActionEventType): string;
30
+ export interface WorkerRegisterRequest {
31
+ /** the name of the worker */
32
+ workerName: string;
33
+ /** a list of actions that this worker can run */
34
+ actions: string[];
35
+ /** (optional) the services for this worker */
36
+ services: string[];
37
+ }
38
+ export interface WorkerRegisterResponse {
39
+ /** the tenant id */
40
+ tenantId: string;
41
+ /** the id of the worker */
42
+ workerId: string;
43
+ /** the name of the worker */
44
+ workerName: string;
45
+ }
46
+ export interface AssignedAction {
47
+ /** the tenant id */
48
+ tenantId: string;
49
+ /** the workflow run id (optional) */
50
+ workflowRunId: string;
51
+ /** the get group key run id (optional) */
52
+ getGroupKeyRunId: string;
53
+ /** the job id */
54
+ jobId: string;
55
+ /** the job name */
56
+ jobName: string;
57
+ /** the job run id */
58
+ jobRunId: string;
59
+ /** the step id */
60
+ stepId: string;
61
+ /** the step run id */
62
+ stepRunId: string;
63
+ /** the action id */
64
+ actionId: string;
65
+ /** the action type */
66
+ actionType: ActionType;
67
+ /** the action payload */
68
+ actionPayload: string;
69
+ }
70
+ export interface WorkerListenRequest {
71
+ /** the id of the worker */
72
+ workerId: string;
73
+ }
74
+ export interface WorkerUnsubscribeRequest {
75
+ /** the id of the worker */
76
+ workerId: string;
77
+ }
78
+ export interface WorkerUnsubscribeResponse {
79
+ /** the tenant id to unsubscribe from */
80
+ tenantId: string;
81
+ /** the id of the worker */
82
+ workerId: string;
83
+ }
84
+ export interface GroupKeyActionEvent {
85
+ /** the id of the worker */
86
+ workerId: string;
87
+ /** the id of the job */
88
+ workflowRunId: string;
89
+ getGroupKeyRunId: string;
90
+ /** the action id */
91
+ actionId: string;
92
+ eventTimestamp: Date | undefined;
93
+ /** the step event type */
94
+ eventType: GroupKeyActionEventType;
95
+ /** the event payload */
96
+ eventPayload: string;
97
+ }
98
+ export interface StepActionEvent {
99
+ /** the id of the worker */
100
+ workerId: string;
101
+ /** the id of the job */
102
+ jobId: string;
103
+ /** the job run id */
104
+ jobRunId: string;
105
+ /** the id of the step */
106
+ stepId: string;
107
+ /** the step run id */
108
+ stepRunId: string;
109
+ /** the action id */
110
+ actionId: string;
111
+ eventTimestamp: Date | undefined;
112
+ /** the step event type */
113
+ eventType: StepActionEventType;
114
+ /** the event payload */
115
+ eventPayload: string;
116
+ }
117
+ export interface ActionEventResponse {
118
+ /** the tenant id */
119
+ tenantId: string;
120
+ /** the id of the worker */
121
+ workerId: string;
122
+ }
123
+ export declare const WorkerRegisterRequest: {
124
+ encode(message: WorkerRegisterRequest, writer?: _m0.Writer): _m0.Writer;
125
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerRegisterRequest;
126
+ fromJSON(object: any): WorkerRegisterRequest;
127
+ toJSON(message: WorkerRegisterRequest): unknown;
128
+ create(base?: DeepPartial<WorkerRegisterRequest>): WorkerRegisterRequest;
129
+ fromPartial(object: DeepPartial<WorkerRegisterRequest>): WorkerRegisterRequest;
130
+ };
131
+ export declare const WorkerRegisterResponse: {
132
+ encode(message: WorkerRegisterResponse, writer?: _m0.Writer): _m0.Writer;
133
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerRegisterResponse;
134
+ fromJSON(object: any): WorkerRegisterResponse;
135
+ toJSON(message: WorkerRegisterResponse): unknown;
136
+ create(base?: DeepPartial<WorkerRegisterResponse>): WorkerRegisterResponse;
137
+ fromPartial(object: DeepPartial<WorkerRegisterResponse>): WorkerRegisterResponse;
138
+ };
139
+ export declare const AssignedAction: {
140
+ encode(message: AssignedAction, writer?: _m0.Writer): _m0.Writer;
141
+ decode(input: _m0.Reader | Uint8Array, length?: number): AssignedAction;
142
+ fromJSON(object: any): AssignedAction;
143
+ toJSON(message: AssignedAction): unknown;
144
+ create(base?: DeepPartial<AssignedAction>): AssignedAction;
145
+ fromPartial(object: DeepPartial<AssignedAction>): AssignedAction;
146
+ };
147
+ export declare const WorkerListenRequest: {
148
+ encode(message: WorkerListenRequest, writer?: _m0.Writer): _m0.Writer;
149
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerListenRequest;
150
+ fromJSON(object: any): WorkerListenRequest;
151
+ toJSON(message: WorkerListenRequest): unknown;
152
+ create(base?: DeepPartial<WorkerListenRequest>): WorkerListenRequest;
153
+ fromPartial(object: DeepPartial<WorkerListenRequest>): WorkerListenRequest;
154
+ };
155
+ export declare const WorkerUnsubscribeRequest: {
156
+ encode(message: WorkerUnsubscribeRequest, writer?: _m0.Writer): _m0.Writer;
157
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerUnsubscribeRequest;
158
+ fromJSON(object: any): WorkerUnsubscribeRequest;
159
+ toJSON(message: WorkerUnsubscribeRequest): unknown;
160
+ create(base?: DeepPartial<WorkerUnsubscribeRequest>): WorkerUnsubscribeRequest;
161
+ fromPartial(object: DeepPartial<WorkerUnsubscribeRequest>): WorkerUnsubscribeRequest;
162
+ };
163
+ export declare const WorkerUnsubscribeResponse: {
164
+ encode(message: WorkerUnsubscribeResponse, writer?: _m0.Writer): _m0.Writer;
165
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerUnsubscribeResponse;
166
+ fromJSON(object: any): WorkerUnsubscribeResponse;
167
+ toJSON(message: WorkerUnsubscribeResponse): unknown;
168
+ create(base?: DeepPartial<WorkerUnsubscribeResponse>): WorkerUnsubscribeResponse;
169
+ fromPartial(object: DeepPartial<WorkerUnsubscribeResponse>): WorkerUnsubscribeResponse;
170
+ };
171
+ export declare const GroupKeyActionEvent: {
172
+ encode(message: GroupKeyActionEvent, writer?: _m0.Writer): _m0.Writer;
173
+ decode(input: _m0.Reader | Uint8Array, length?: number): GroupKeyActionEvent;
174
+ fromJSON(object: any): GroupKeyActionEvent;
175
+ toJSON(message: GroupKeyActionEvent): unknown;
176
+ create(base?: DeepPartial<GroupKeyActionEvent>): GroupKeyActionEvent;
177
+ fromPartial(object: DeepPartial<GroupKeyActionEvent>): GroupKeyActionEvent;
178
+ };
179
+ export declare const StepActionEvent: {
180
+ encode(message: StepActionEvent, writer?: _m0.Writer): _m0.Writer;
181
+ decode(input: _m0.Reader | Uint8Array, length?: number): StepActionEvent;
182
+ fromJSON(object: any): StepActionEvent;
183
+ toJSON(message: StepActionEvent): unknown;
184
+ create(base?: DeepPartial<StepActionEvent>): StepActionEvent;
185
+ fromPartial(object: DeepPartial<StepActionEvent>): StepActionEvent;
186
+ };
187
+ export declare const ActionEventResponse: {
188
+ encode(message: ActionEventResponse, writer?: _m0.Writer): _m0.Writer;
189
+ decode(input: _m0.Reader | Uint8Array, length?: number): ActionEventResponse;
190
+ fromJSON(object: any): ActionEventResponse;
191
+ toJSON(message: ActionEventResponse): unknown;
192
+ create(base?: DeepPartial<ActionEventResponse>): ActionEventResponse;
193
+ fromPartial(object: DeepPartial<ActionEventResponse>): ActionEventResponse;
194
+ };
195
+ export type DispatcherDefinition = typeof DispatcherDefinition;
196
+ export declare const DispatcherDefinition: {
197
+ readonly name: "Dispatcher";
198
+ readonly fullName: "Dispatcher";
199
+ readonly methods: {
200
+ readonly register: {
201
+ readonly name: "Register";
202
+ readonly requestType: {
203
+ encode(message: WorkerRegisterRequest, writer?: _m0.Writer): _m0.Writer;
204
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerRegisterRequest;
205
+ fromJSON(object: any): WorkerRegisterRequest;
206
+ toJSON(message: WorkerRegisterRequest): unknown;
207
+ create(base?: DeepPartial<WorkerRegisterRequest>): WorkerRegisterRequest;
208
+ fromPartial(object: DeepPartial<WorkerRegisterRequest>): WorkerRegisterRequest;
209
+ };
210
+ readonly requestStream: false;
211
+ readonly responseType: {
212
+ encode(message: WorkerRegisterResponse, writer?: _m0.Writer): _m0.Writer;
213
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerRegisterResponse;
214
+ fromJSON(object: any): WorkerRegisterResponse;
215
+ toJSON(message: WorkerRegisterResponse): unknown;
216
+ create(base?: DeepPartial<WorkerRegisterResponse>): WorkerRegisterResponse;
217
+ fromPartial(object: DeepPartial<WorkerRegisterResponse>): WorkerRegisterResponse;
218
+ };
219
+ readonly responseStream: false;
220
+ readonly options: {};
221
+ };
222
+ readonly listen: {
223
+ readonly name: "Listen";
224
+ readonly requestType: {
225
+ encode(message: WorkerListenRequest, writer?: _m0.Writer): _m0.Writer;
226
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerListenRequest;
227
+ fromJSON(object: any): WorkerListenRequest;
228
+ toJSON(message: WorkerListenRequest): unknown;
229
+ create(base?: DeepPartial<WorkerListenRequest>): WorkerListenRequest;
230
+ fromPartial(object: DeepPartial<WorkerListenRequest>): WorkerListenRequest;
231
+ };
232
+ readonly requestStream: false;
233
+ readonly responseType: {
234
+ encode(message: AssignedAction, writer?: _m0.Writer): _m0.Writer;
235
+ decode(input: _m0.Reader | Uint8Array, length?: number): AssignedAction;
236
+ fromJSON(object: any): AssignedAction;
237
+ toJSON(message: AssignedAction): unknown;
238
+ create(base?: DeepPartial<AssignedAction>): AssignedAction;
239
+ fromPartial(object: DeepPartial<AssignedAction>): AssignedAction;
240
+ };
241
+ readonly responseStream: true;
242
+ readonly options: {};
243
+ };
244
+ readonly sendStepActionEvent: {
245
+ readonly name: "SendStepActionEvent";
246
+ readonly requestType: {
247
+ encode(message: StepActionEvent, writer?: _m0.Writer): _m0.Writer;
248
+ decode(input: _m0.Reader | Uint8Array, length?: number): StepActionEvent;
249
+ fromJSON(object: any): StepActionEvent;
250
+ toJSON(message: StepActionEvent): unknown;
251
+ create(base?: DeepPartial<StepActionEvent>): StepActionEvent;
252
+ fromPartial(object: DeepPartial<StepActionEvent>): StepActionEvent;
253
+ };
254
+ readonly requestStream: false;
255
+ readonly responseType: {
256
+ encode(message: ActionEventResponse, writer?: _m0.Writer): _m0.Writer;
257
+ decode(input: _m0.Reader | Uint8Array, length?: number): ActionEventResponse;
258
+ fromJSON(object: any): ActionEventResponse;
259
+ toJSON(message: ActionEventResponse): unknown;
260
+ create(base?: DeepPartial<ActionEventResponse>): ActionEventResponse;
261
+ fromPartial(object: DeepPartial<ActionEventResponse>): ActionEventResponse;
262
+ };
263
+ readonly responseStream: false;
264
+ readonly options: {};
265
+ };
266
+ readonly sendGroupKeyActionEvent: {
267
+ readonly name: "SendGroupKeyActionEvent";
268
+ readonly requestType: {
269
+ encode(message: GroupKeyActionEvent, writer?: _m0.Writer): _m0.Writer;
270
+ decode(input: _m0.Reader | Uint8Array, length?: number): GroupKeyActionEvent;
271
+ fromJSON(object: any): GroupKeyActionEvent;
272
+ toJSON(message: GroupKeyActionEvent): unknown;
273
+ create(base?: DeepPartial<GroupKeyActionEvent>): GroupKeyActionEvent;
274
+ fromPartial(object: DeepPartial<GroupKeyActionEvent>): GroupKeyActionEvent;
275
+ };
276
+ readonly requestStream: false;
277
+ readonly responseType: {
278
+ encode(message: ActionEventResponse, writer?: _m0.Writer): _m0.Writer;
279
+ decode(input: _m0.Reader | Uint8Array, length?: number): ActionEventResponse;
280
+ fromJSON(object: any): ActionEventResponse;
281
+ toJSON(message: ActionEventResponse): unknown;
282
+ create(base?: DeepPartial<ActionEventResponse>): ActionEventResponse;
283
+ fromPartial(object: DeepPartial<ActionEventResponse>): ActionEventResponse;
284
+ };
285
+ readonly responseStream: false;
286
+ readonly options: {};
287
+ };
288
+ readonly unsubscribe: {
289
+ readonly name: "Unsubscribe";
290
+ readonly requestType: {
291
+ encode(message: WorkerUnsubscribeRequest, writer?: _m0.Writer): _m0.Writer;
292
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerUnsubscribeRequest;
293
+ fromJSON(object: any): WorkerUnsubscribeRequest;
294
+ toJSON(message: WorkerUnsubscribeRequest): unknown;
295
+ create(base?: DeepPartial<WorkerUnsubscribeRequest>): WorkerUnsubscribeRequest;
296
+ fromPartial(object: DeepPartial<WorkerUnsubscribeRequest>): WorkerUnsubscribeRequest;
297
+ };
298
+ readonly requestStream: false;
299
+ readonly responseType: {
300
+ encode(message: WorkerUnsubscribeResponse, writer?: _m0.Writer): _m0.Writer;
301
+ decode(input: _m0.Reader | Uint8Array, length?: number): WorkerUnsubscribeResponse;
302
+ fromJSON(object: any): WorkerUnsubscribeResponse;
303
+ toJSON(message: WorkerUnsubscribeResponse): unknown;
304
+ create(base?: DeepPartial<WorkerUnsubscribeResponse>): WorkerUnsubscribeResponse;
305
+ fromPartial(object: DeepPartial<WorkerUnsubscribeResponse>): WorkerUnsubscribeResponse;
306
+ };
307
+ readonly responseStream: false;
308
+ readonly options: {};
309
+ };
310
+ };
311
+ };
312
+ export interface DispatcherServiceImplementation<CallContextExt = {}> {
313
+ register(request: WorkerRegisterRequest, context: CallContext & CallContextExt): Promise<DeepPartial<WorkerRegisterResponse>>;
314
+ listen(request: WorkerListenRequest, context: CallContext & CallContextExt): ServerStreamingMethodResult<DeepPartial<AssignedAction>>;
315
+ sendStepActionEvent(request: StepActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
316
+ sendGroupKeyActionEvent(request: GroupKeyActionEvent, context: CallContext & CallContextExt): Promise<DeepPartial<ActionEventResponse>>;
317
+ unsubscribe(request: WorkerUnsubscribeRequest, context: CallContext & CallContextExt): Promise<DeepPartial<WorkerUnsubscribeResponse>>;
318
+ }
319
+ export interface DispatcherClient<CallOptionsExt = {}> {
320
+ register(request: DeepPartial<WorkerRegisterRequest>, options?: CallOptions & CallOptionsExt): Promise<WorkerRegisterResponse>;
321
+ listen(request: DeepPartial<WorkerListenRequest>, options?: CallOptions & CallOptionsExt): AsyncIterable<AssignedAction>;
322
+ sendStepActionEvent(request: DeepPartial<StepActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
323
+ sendGroupKeyActionEvent(request: DeepPartial<GroupKeyActionEvent>, options?: CallOptions & CallOptionsExt): Promise<ActionEventResponse>;
324
+ unsubscribe(request: DeepPartial<WorkerUnsubscribeRequest>, options?: CallOptions & CallOptionsExt): Promise<WorkerUnsubscribeResponse>;
325
+ }
326
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
327
+ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
328
+ [K in keyof T]?: DeepPartial<T[K]>;
329
+ } : Partial<T>;
330
+ export type ServerStreamingMethodResult<Response> = {
331
+ [Symbol.asyncIterator](): AsyncIterator<Response, void>;
332
+ };
333
+ export {};