@kaleido-io/workflow-engine-sdk 0.0.1 → 0.9.2
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/LICENSE +201 -0
- package/README.md +1121 -0
- package/bin/init.js +200 -0
- package/bin/wesdk.js +57 -0
- package/dist/package.json +3 -0
- package/dist/src/client/client.d.ts +24 -0
- package/dist/src/client/client.d.ts.map +1 -0
- package/dist/src/client/client.js +58 -0
- package/dist/src/client/client.js.map +1 -0
- package/dist/src/client/rest-client.d.ts +222 -0
- package/dist/src/client/rest-client.d.ts.map +1 -0
- package/dist/src/client/rest-client.js +242 -0
- package/dist/src/client/rest-client.js.map +1 -0
- package/dist/src/config/config.d.ts +60 -0
- package/dist/src/config/config.d.ts.map +1 -0
- package/dist/src/config/config.js +117 -0
- package/dist/src/config/config.js.map +1 -0
- package/dist/src/factories/event_source.d.ts +54 -0
- package/dist/src/factories/event_source.d.ts.map +1 -0
- package/dist/src/factories/event_source.js +170 -0
- package/dist/src/factories/event_source.js.map +1 -0
- package/dist/src/factories/transaction_handler.d.ts +27 -0
- package/dist/src/factories/transaction_handler.d.ts.map +1 -0
- package/dist/src/factories/transaction_handler.js +66 -0
- package/dist/src/factories/transaction_handler.js.map +1 -0
- package/dist/src/helpers/stage_director.d.ts +42 -0
- package/dist/src/helpers/stage_director.d.ts.map +1 -0
- package/dist/src/helpers/stage_director.js +304 -0
- package/dist/src/helpers/stage_director.js.map +1 -0
- package/dist/src/i18n/errors.d.ts +61 -0
- package/dist/src/i18n/errors.d.ts.map +1 -0
- package/dist/src/i18n/errors.js +90 -0
- package/dist/src/i18n/errors.js.map +1 -0
- package/dist/src/index.d.ts +20 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +85 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/handlers.d.ts +112 -0
- package/dist/src/interfaces/handlers.d.ts.map +1 -0
- package/dist/src/interfaces/handlers.js +18 -0
- package/dist/src/interfaces/handlers.js.map +1 -0
- package/dist/src/interfaces/messages.d.ts +6 -0
- package/dist/src/interfaces/messages.d.ts.map +1 -0
- package/dist/src/interfaces/messages.js +18 -0
- package/dist/src/interfaces/messages.js.map +1 -0
- package/dist/src/log/logger.d.ts +8 -0
- package/dist/src/log/logger.d.ts.map +1 -0
- package/dist/src/log/logger.js +39 -0
- package/dist/src/log/logger.js.map +1 -0
- package/dist/src/runtime/engine_client.d.ts +37 -0
- package/dist/src/runtime/engine_client.d.ts.map +1 -0
- package/dist/src/runtime/engine_client.js +99 -0
- package/dist/src/runtime/engine_client.js.map +1 -0
- package/dist/src/runtime/handler_runtime.d.ts +124 -0
- package/dist/src/runtime/handler_runtime.d.ts.map +1 -0
- package/dist/src/runtime/handler_runtime.js +623 -0
- package/dist/src/runtime/handler_runtime.js.map +1 -0
- package/dist/src/types/core.d.ts +258 -0
- package/dist/src/types/core.d.ts.map +1 -0
- package/dist/src/types/core.js +71 -0
- package/dist/src/types/core.js.map +1 -0
- package/dist/src/types/flows.d.ts +144 -0
- package/dist/src/types/flows.d.ts.map +1 -0
- package/dist/src/types/flows.js +30 -0
- package/dist/src/types/flows.js.map +1 -0
- package/dist/src/utils/errors.d.ts +2 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +23 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/patch.d.ts +9 -0
- package/dist/src/utils/patch.d.ts.map +1 -0
- package/dist/src/utils/patch.js +99 -0
- package/dist/src/utils/patch.js.map +1 -0
- package/dist-esm/src/client/client.js +54 -0
- package/dist-esm/src/client/client.js.map +1 -0
- package/dist-esm/src/client/rest-client.js +238 -0
- package/dist-esm/src/client/rest-client.js.map +1 -0
- package/dist-esm/src/config/config.js +113 -0
- package/dist-esm/src/config/config.js.map +1 -0
- package/dist-esm/src/factories/event_source.js +167 -0
- package/dist-esm/src/factories/event_source.js.map +1 -0
- package/dist-esm/src/factories/transaction_handler.js +63 -0
- package/dist-esm/src/factories/transaction_handler.js.map +1 -0
- package/dist-esm/src/helpers/stage_director.js +298 -0
- package/dist-esm/src/helpers/stage_director.js.map +1 -0
- package/dist-esm/src/i18n/errors.js +85 -0
- package/dist-esm/src/i18n/errors.js.map +1 -0
- package/dist-esm/src/index.js +51 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/interfaces/handlers.js +17 -0
- package/dist-esm/src/interfaces/handlers.js.map +1 -0
- package/dist-esm/src/interfaces/messages.js +17 -0
- package/dist-esm/src/interfaces/messages.js.map +1 -0
- package/dist-esm/src/log/logger.js +36 -0
- package/dist-esm/src/log/logger.js.map +1 -0
- package/dist-esm/src/runtime/engine_client.js +95 -0
- package/dist-esm/src/runtime/engine_client.js.map +1 -0
- package/dist-esm/src/runtime/handler_runtime.js +586 -0
- package/dist-esm/src/runtime/handler_runtime.js.map +1 -0
- package/dist-esm/src/types/core.js +68 -0
- package/dist-esm/src/types/core.js.map +1 -0
- package/dist-esm/src/types/flows.js +27 -0
- package/dist-esm/src/types/flows.js.map +1 -0
- package/dist-esm/src/utils/errors.js +19 -0
- package/dist-esm/src/utils/errors.js.map +1 -0
- package/dist-esm/src/utils/patch.js +56 -0
- package/dist-esm/src/utils/patch.js.map +1 -0
- package/package.json +79 -11
- package/template/.env.sample +14 -0
- package/template/.vscode/launch.json +23 -0
- package/template/README.md +37 -0
- package/template/package.json +36 -0
- package/template/src/connect.ts +58 -0
- package/template/src/provider.ts +24 -0
- package/template/src/samples/event-source/README.md +50 -0
- package/template/src/samples/event-source/echo-handler.ts +65 -0
- package/template/src/samples/event-source/event-processor.ts +46 -0
- package/template/src/samples/event-source/event-source.ts +70 -0
- package/template/src/samples/event-source/stream.ts +34 -0
- package/template/src/samples/hello/README.md +52 -0
- package/template/src/samples/hello/flow.ts +74 -0
- package/template/src/samples/hello/handlers.test.ts +147 -0
- package/template/src/samples/hello/handlers.ts +72 -0
- package/template/src/samples/hello/transaction.ts +24 -0
- package/template/src/samples/http-invoke/README.md +42 -0
- package/template/src/samples/http-invoke/flow.ts +63 -0
- package/template/src/samples/http-invoke/handlers.ts +66 -0
- package/template/src/samples/http-invoke/transaction.ts +22 -0
- package/template/src/samples/snap/README.md +98 -0
- package/template/src/samples/snap/event-source.ts +104 -0
- package/template/src/samples/snap/flow.ts +85 -0
- package/template/src/samples/snap/snap-handler.ts +84 -0
- package/template/src/samples/snap/stream.ts +26 -0
- package/template/src/samples/snap/transaction.ts +26 -0
- package/template/src/utils/post-stream.ts +67 -0
- package/template/src/utils/post-transaction.ts +64 -0
- package/template/src/utils/post-workflow.ts +63 -0
- package/template/tsconfig.json +24 -0
- package/template/vitest.config.ts +42 -0
- package/CODEOWNERS +0 -5
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kaleido Workflow Engine SDK - TypeScript
|
|
3
|
+
*/
|
|
4
|
+
export { WorkflowEngineClient, WorkflowEngineClientConfig, } from './client/client';
|
|
5
|
+
export { WorkflowEngineRestClient, CreateWorkflowRequest, CreateWorkflowResponse, CreateTransactionRequest, CreateTransactionResponse, CreateStreamRequest, CreateStreamResponse, UpdateStreamRequest, TransactionInput, } from './client/rest-client';
|
|
6
|
+
export { WorkflowEngineConfig, ConfigLoader, } from './config/config';
|
|
7
|
+
export { newLogger } from './log/logger';
|
|
8
|
+
export * from './types/core';
|
|
9
|
+
export * from './interfaces/handlers';
|
|
10
|
+
export * from './interfaces/messages';
|
|
11
|
+
export { newDirectedTransactionHandler, TransactionHandlerFactory, } from './factories/transaction_handler';
|
|
12
|
+
export { newEventSource, EventSourceFactory, EventSourceConf, EventSourceEvent, EventSourcePollFn, EventSourceBuildInitialCheckpointFn, EventSourceDeleteFn, EventSourceConfigParserFn, } from './factories/event_source';
|
|
13
|
+
export { BasicStageDirector, StageDirectorHelper, evalDirected, } from './helpers/stage_director';
|
|
14
|
+
export * from './config/config';
|
|
15
|
+
export { apply, addOp, removeOp, replaceOp, moveOp, copyOp, testOp, } from './utils/patch';
|
|
16
|
+
export * from './log/logger';
|
|
17
|
+
export * from './i18n/errors';
|
|
18
|
+
export type { HandlerBindingTarget } from './types/flows';
|
|
19
|
+
export { HandlerRuntimeMode } from './runtime/handler_runtime';
|
|
20
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAiBA;;GAEG;AAMH,OAAO,EACL,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,yBAAyB,EACzB,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,oBAAoB,EACpB,YAAY,GACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAMzC,cAAc,cAAc,CAAC;AAC7B,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AAOtC,OAAO,EACL,6BAA6B,EAC7B,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,mCAAmC,EACnC,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,YAAY,GACb,MAAM,0BAA0B,CAAC;AAGlC,cAAc,iBAAiB,CAAC;AAMhC,OAAO,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,MAAM,EACN,MAAM,GACP,MAAM,eAAe,CAAC;AAGvB,cAAc,cAAc,CAAC;AAE7B,cAAc,eAAe,CAAC;AAE9B,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright © 2026 Kaleido, Inc.
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
// you may not use this file except in compliance with the License.
|
|
8
|
+
// You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
// See the License for the specific language governing permissions and
|
|
16
|
+
// limitations under the License.
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
29
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
30
|
+
};
|
|
31
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
32
|
+
exports.HandlerRuntimeMode = exports.testOp = exports.copyOp = exports.moveOp = exports.replaceOp = exports.removeOp = exports.addOp = exports.apply = exports.evalDirected = exports.StageDirectorHelper = exports.BasicStageDirector = exports.newEventSource = exports.newDirectedTransactionHandler = exports.newLogger = exports.ConfigLoader = exports.WorkflowEngineRestClient = exports.WorkflowEngineClient = void 0;
|
|
33
|
+
/**
|
|
34
|
+
* Kaleido Workflow Engine SDK - TypeScript
|
|
35
|
+
*/
|
|
36
|
+
// ============================================================================
|
|
37
|
+
// Client Entry Point
|
|
38
|
+
// ============================================================================
|
|
39
|
+
var client_1 = require("./client/client");
|
|
40
|
+
Object.defineProperty(exports, "WorkflowEngineClient", { enumerable: true, get: function () { return client_1.WorkflowEngineClient; } });
|
|
41
|
+
var rest_client_1 = require("./client/rest-client");
|
|
42
|
+
Object.defineProperty(exports, "WorkflowEngineRestClient", { enumerable: true, get: function () { return rest_client_1.WorkflowEngineRestClient; } });
|
|
43
|
+
var config_1 = require("./config/config");
|
|
44
|
+
Object.defineProperty(exports, "ConfigLoader", { enumerable: true, get: function () { return config_1.ConfigLoader; } });
|
|
45
|
+
var logger_1 = require("./log/logger");
|
|
46
|
+
Object.defineProperty(exports, "newLogger", { enumerable: true, get: function () { return logger_1.newLogger; } });
|
|
47
|
+
// ============================================================================
|
|
48
|
+
// Core Types & Interfaces
|
|
49
|
+
// ============================================================================
|
|
50
|
+
__exportStar(require("./types/core"), exports);
|
|
51
|
+
__exportStar(require("./interfaces/handlers"), exports);
|
|
52
|
+
__exportStar(require("./interfaces/messages"), exports);
|
|
53
|
+
// ============================================================================
|
|
54
|
+
// Factories & Helpers
|
|
55
|
+
// ============================================================================
|
|
56
|
+
// Transaction handler factory
|
|
57
|
+
var transaction_handler_1 = require("./factories/transaction_handler");
|
|
58
|
+
Object.defineProperty(exports, "newDirectedTransactionHandler", { enumerable: true, get: function () { return transaction_handler_1.newDirectedTransactionHandler; } });
|
|
59
|
+
// Event source factory
|
|
60
|
+
var event_source_1 = require("./factories/event_source");
|
|
61
|
+
Object.defineProperty(exports, "newEventSource", { enumerable: true, get: function () { return event_source_1.newEventSource; } });
|
|
62
|
+
// Stage director helpers
|
|
63
|
+
var stage_director_1 = require("./helpers/stage_director");
|
|
64
|
+
Object.defineProperty(exports, "BasicStageDirector", { enumerable: true, get: function () { return stage_director_1.BasicStageDirector; } });
|
|
65
|
+
Object.defineProperty(exports, "StageDirectorHelper", { enumerable: true, get: function () { return stage_director_1.StageDirectorHelper; } });
|
|
66
|
+
Object.defineProperty(exports, "evalDirected", { enumerable: true, get: function () { return stage_director_1.evalDirected; } });
|
|
67
|
+
// Configuration
|
|
68
|
+
__exportStar(require("./config/config"), exports);
|
|
69
|
+
// Utilities
|
|
70
|
+
// ============================================================================
|
|
71
|
+
// JSON Patch utilities
|
|
72
|
+
var patch_1 = require("./utils/patch");
|
|
73
|
+
Object.defineProperty(exports, "apply", { enumerable: true, get: function () { return patch_1.apply; } });
|
|
74
|
+
Object.defineProperty(exports, "addOp", { enumerable: true, get: function () { return patch_1.addOp; } });
|
|
75
|
+
Object.defineProperty(exports, "removeOp", { enumerable: true, get: function () { return patch_1.removeOp; } });
|
|
76
|
+
Object.defineProperty(exports, "replaceOp", { enumerable: true, get: function () { return patch_1.replaceOp; } });
|
|
77
|
+
Object.defineProperty(exports, "moveOp", { enumerable: true, get: function () { return patch_1.moveOp; } });
|
|
78
|
+
Object.defineProperty(exports, "copyOp", { enumerable: true, get: function () { return patch_1.copyOp; } });
|
|
79
|
+
Object.defineProperty(exports, "testOp", { enumerable: true, get: function () { return patch_1.testOp; } });
|
|
80
|
+
// Logger
|
|
81
|
+
__exportStar(require("./log/logger"), exports);
|
|
82
|
+
__exportStar(require("./i18n/errors"), exports);
|
|
83
|
+
var handler_runtime_1 = require("./runtime/handler_runtime");
|
|
84
|
+
Object.defineProperty(exports, "HandlerRuntimeMode", { enumerable: true, get: function () { return handler_runtime_1.HandlerRuntimeMode; } });
|
|
85
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRo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
+
import { EvalResult, InvocationMode, WSEvaluateTransaction, WSHandleTransactionsResult, WSHandleTransactions, WSEvaluateReplyResult, WSEventSourceConfig, WSListenerPollRequest, WSListenerPollResult, WithStageDirector, Trigger, Patch, AsyncTransactionInput, IdempotentSubmitResult, HandlerEvent, WSEventProcessorBatchRequest, WSEventProcessorBatchResult } from '../types/core';
|
|
2
|
+
/**
|
|
3
|
+
* EngineAPI interface
|
|
4
|
+
*/
|
|
5
|
+
export interface EngineAPI {
|
|
6
|
+
submitAsyncTransactions(authRef: string, transactions: AsyncTransactionInput[]): Promise<IdempotentSubmitResult[]>;
|
|
7
|
+
}
|
|
8
|
+
export interface Handler {
|
|
9
|
+
name(): string;
|
|
10
|
+
init(engAPI: EngineAPI): Promise<void>;
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Event source handler interface
|
|
15
|
+
*/
|
|
16
|
+
export interface EventSource extends Handler {
|
|
17
|
+
/**
|
|
18
|
+
* Poll for events and update the result object
|
|
19
|
+
*/
|
|
20
|
+
eventSourcePoll(config: WSEventSourceConfig, result: WSListenerPollResult, request: WSListenerPollRequest): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Validate the event source config
|
|
23
|
+
*/
|
|
24
|
+
eventSourceValidateConfig(result: any, request: any): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Delete the event source
|
|
27
|
+
*/
|
|
28
|
+
eventSourceDelete(result: any, request: any): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Transaction handler interface
|
|
32
|
+
*/
|
|
33
|
+
export interface TransactionHandler extends Handler {
|
|
34
|
+
transactionHandlerBatch(result: WSHandleTransactionsResult, batch: WSHandleTransactions): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Event processor handler interface
|
|
38
|
+
*/
|
|
39
|
+
export interface EventProcessor extends Handler {
|
|
40
|
+
eventProcessorBatch(result: WSEventProcessorBatchResult, batch: WSEventProcessorBatchRequest): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Function type for handling individual directed requests
|
|
44
|
+
*/
|
|
45
|
+
export type DirectedTransactionHandler<T extends WithStageDirector> = (transaction: WSEvaluateTransaction, input: T) => Promise<{
|
|
46
|
+
result: EvalResult;
|
|
47
|
+
output?: any;
|
|
48
|
+
error?: Error;
|
|
49
|
+
triggers?: Trigger[];
|
|
50
|
+
events?: HandlerEvent[];
|
|
51
|
+
extraUpdates?: Patch;
|
|
52
|
+
customStage?: string;
|
|
53
|
+
}>;
|
|
54
|
+
/**
|
|
55
|
+
* Input for batch directed transaction handling
|
|
56
|
+
*/
|
|
57
|
+
export interface DirectedTransactionBatchIn<T extends WithStageDirector> {
|
|
58
|
+
transaction: WSEvaluateTransaction;
|
|
59
|
+
value: T;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Output for batch directed transaction handling
|
|
63
|
+
*/
|
|
64
|
+
export interface DirectedTransactionBatchOut<_T extends WithStageDirector> {
|
|
65
|
+
result: EvalResult;
|
|
66
|
+
output?: any;
|
|
67
|
+
error?: Error;
|
|
68
|
+
triggers?: Trigger[];
|
|
69
|
+
extraUpdates?: Patch;
|
|
70
|
+
customStage?: string;
|
|
71
|
+
events?: HandlerEvent[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Function type for handling batch directed transactions.
|
|
75
|
+
*/
|
|
76
|
+
export type DirectedTransactionBatchHandler<T extends WithStageDirector> = (transactions: DirectedTransactionBatchIn<T>[]) => Promise<DirectedTransactionBatchOut<T>[]>;
|
|
77
|
+
/**
|
|
78
|
+
* Configuration for a directed action
|
|
79
|
+
*/
|
|
80
|
+
export interface DirectedActionConfig<T extends WithStageDirector> {
|
|
81
|
+
invocationMode: InvocationMode;
|
|
82
|
+
handler?: DirectedTransactionHandler<T>;
|
|
83
|
+
batchHandler?: DirectedTransactionBatchHandler<T>;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Simple handler interface compatible with existing code
|
|
87
|
+
*/
|
|
88
|
+
export interface IHandler {
|
|
89
|
+
init(): Promise<void>;
|
|
90
|
+
handle(transactions: WSEvaluateTransaction[]): Promise<WSEvaluateReplyResult[]>;
|
|
91
|
+
close?(): void;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Transaction handler for batch evaluation with services support
|
|
95
|
+
*/
|
|
96
|
+
export interface TransactionHandler<SVCS = any> extends Handler {
|
|
97
|
+
transactionHandlerBatch(reply: WSHandleTransactionsResult, batch: WSHandleTransactions, svcs?: SVCS): Promise<void>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Listener handler for event streams with services support
|
|
101
|
+
*/
|
|
102
|
+
export interface ListenerHandler<SVCS = any> extends Handler {
|
|
103
|
+
/**
|
|
104
|
+
* Configure the listener when it's first set up
|
|
105
|
+
*/
|
|
106
|
+
configure?(config: WSEventSourceConfig, svcs?: SVCS): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Poll for events and update the result object
|
|
109
|
+
*/
|
|
110
|
+
poll(request: WSListenerPollRequest, svcs?: SVCS): Promise<WSListenerPollResult>;
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.d.ts","sourceRoot":"","sources":["../../../src/interfaces/handlers.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,UAAU,EACV,cAAc,EACd,qBAAqB,EACrB,0BAA0B,EAC1B,oBAAoB,EACpB,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACpB,iBAAiB,EACjB,OAAO,EACP,KAAK,EACL,qBAAqB,EACrB,sBAAsB,EACtB,YAAY,EACZ,4BAA4B,EAC5B,2BAA2B,EAC5B,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,uBAAuB,CAAC,OAA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,IAAI,IAAI,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,IAAI,GAAG,GAAG,CAAE,SAAQ,OAAO;IAC7D,uBAAuB,CACrB,KAAK,EAAE,0BAA0B,EACjC,KAAK,EAAE,oBAAoB,EAC3B,IAAI,CAAC,EAAE,IAAI,GACV,OAAO,CAAC,IAAI,CAAC,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,IAAI,GAAG,GAAG,CAAE,SAAQ,OAAO;IAC1D;;OAEG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;OAEG;IACH,IAAI,CAAC,OAAO,EAAE,qBAAqB,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAAC;CAClF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright © 2026 Kaleido, Inc.
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
// you may not use this file except in compliance with the License.
|
|
8
|
+
// You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
// See the License for the specific language governing permissions and
|
|
16
|
+
// limitations under the License.
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=handlers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlers.js","sourceRoot":"","sources":["../../../src/interfaces/handlers.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WSHandleTransactions, WSHandleTransactionsResult, WSRegisterHandler, WSEventSourceConfig, WSListenerPollRequest, WSListenerPollResult } from '../types/core';
|
|
2
|
+
/**
|
|
3
|
+
* All possible WebSocket message types
|
|
4
|
+
*/
|
|
5
|
+
export type WSMessage = WSHandleTransactions | WSHandleTransactionsResult | WSRegisterHandler | WSEventSourceConfig | WSListenerPollRequest | WSListenerPollResult;
|
|
6
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/interfaces/messages.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,oBAAoB,EACpB,0BAA0B,EAC1B,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,oBAAoB,EACrB,MAAM,eAAe,CAAC;AAEvB;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,oBAAoB,GACpB,0BAA0B,GAC1B,iBAAiB,GACjB,mBAAmB,GACnB,qBAAqB,GACrB,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright © 2026 Kaleido, Inc.
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
// you may not use this file except in compliance with the License.
|
|
8
|
+
// You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
// See the License for the specific language governing permissions and
|
|
16
|
+
// limitations under the License.
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/interfaces/messages.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface Logger {
|
|
2
|
+
debug(message: string, ...args: any[]): void;
|
|
3
|
+
info(message: string, ...args: any[]): void;
|
|
4
|
+
warn(message: string, ...args: any[]): void;
|
|
5
|
+
error(message: string, ...args: any[]): void;
|
|
6
|
+
}
|
|
7
|
+
export declare function newLogger(context: string): Logger;
|
|
8
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/log/logger.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC7C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAC5C,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC9C;AAsBD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEjD"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright © 2026 Kaleido, Inc.
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
// you may not use this file except in compliance with the License.
|
|
8
|
+
// You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
// See the License for the specific language governing permissions and
|
|
16
|
+
// limitations under the License.
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.newLogger = newLogger;
|
|
19
|
+
class ConsoleLogger {
|
|
20
|
+
constructor(context) {
|
|
21
|
+
this.context = context;
|
|
22
|
+
}
|
|
23
|
+
debug(message, ...args) {
|
|
24
|
+
console.debug(`[${this.context}] ${message}`, ...args);
|
|
25
|
+
}
|
|
26
|
+
info(message, ...args) {
|
|
27
|
+
console.info(`[${this.context}] ${message}`, ...args);
|
|
28
|
+
}
|
|
29
|
+
warn(message, ...args) {
|
|
30
|
+
console.warn(`[${this.context}] ${message}`, ...args);
|
|
31
|
+
}
|
|
32
|
+
error(message, ...args) {
|
|
33
|
+
console.error(`[${this.context}] ${message}`, ...args);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function newLogger(context) {
|
|
37
|
+
return new ConsoleLogger(context);
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../src/log/logger.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AA8BjC,8BAEC;AAtBD,MAAM,aAAa;IACjB,YAAoB,OAAe;QAAf,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAEvC,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,CAAC,OAAe,EAAE,GAAG,IAAW;QAClC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACxD,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,GAAG,IAAW;QACnC,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,KAAK,OAAO,EAAE,EAAE,GAAG,IAAI,CAAC,CAAC;IACzD,CAAC;CACF;AAED,SAAgB,SAAS,CAAC,OAAe;IACvC,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAC;AACpC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AsyncTransactionInput, IdempotentSubmitResult, WSEngineAPISubmitTransactionsResult } from '../types/core';
|
|
2
|
+
import { EngineAPI } from '../interfaces/handlers';
|
|
3
|
+
/**
|
|
4
|
+
* Interface for the runtime that EngineClient depends on
|
|
5
|
+
*/
|
|
6
|
+
export interface EngineClientRuntime {
|
|
7
|
+
sendMessage(message: any): void;
|
|
8
|
+
getActiveHandlerContext(): {
|
|
9
|
+
requestId: string;
|
|
10
|
+
authTokens: Record<string, string>;
|
|
11
|
+
} | undefined;
|
|
12
|
+
isWebSocketConnected(): boolean;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Client for handlers to call back to the workflow engine.
|
|
16
|
+
* Implements the EngineAPI interface and handles the round-trip
|
|
17
|
+
* communication pattern for async operations like submitting transactions.
|
|
18
|
+
*/
|
|
19
|
+
export declare class EngineClient implements EngineAPI {
|
|
20
|
+
private runtime;
|
|
21
|
+
private inflightRequests;
|
|
22
|
+
constructor(runtime: EngineClientRuntime);
|
|
23
|
+
/**
|
|
24
|
+
* Submit async transactions to the workflow engine
|
|
25
|
+
*/
|
|
26
|
+
submitAsyncTransactions(authRef: string, transactions: AsyncTransactionInput[]): Promise<IdempotentSubmitResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Handle response for inflight request
|
|
29
|
+
*/
|
|
30
|
+
handleResponse(message: WSEngineAPISubmitTransactionsResult): void;
|
|
31
|
+
/**
|
|
32
|
+
* Round-trip request/response pattern
|
|
33
|
+
*/
|
|
34
|
+
private roundTrip;
|
|
35
|
+
private generateId;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=engine_client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine_client.d.ts","sourceRoot":"","sources":["../../../src/runtime/engine_client.ts"],"names":[],"mappings":"AAiBA,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EAGtB,mCAAmC,EACpC,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAMnD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC;IAChC,uBAAuB,IAAI;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GAAG,SAAS,CAAC;IACjG,oBAAoB,IAAI,OAAO,CAAC;CACjC;AAED;;;;GAIG;AACH,qBAAa,YAAa,YAAW,SAAS;IAC5C,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,gBAAgB,CAGT;gBAEH,OAAO,EAAE,mBAAmB;IAIxC;;OAEG;IACG,uBAAuB,CAC3B,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,qBAAqB,EAAE,GACpC,OAAO,CAAC,sBAAsB,EAAE,CAAC;IA+BpC;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,mCAAmC,GAAG,IAAI;IAsBlE;;OAEG;IACH,OAAO,CAAC,SAAS;IAOjB,OAAO,CAAC,UAAU;CAGnB"}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright © 2026 Kaleido, Inc.
|
|
3
|
+
//
|
|
4
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
//
|
|
6
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
7
|
+
// you may not use this file except in compliance with the License.
|
|
8
|
+
// You may obtain a copy of the License at
|
|
9
|
+
//
|
|
10
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
11
|
+
//
|
|
12
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
13
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
14
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
15
|
+
// See the License for the specific language governing permissions and
|
|
16
|
+
// limitations under the License.
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.EngineClient = void 0;
|
|
19
|
+
const core_1 = require("../types/core");
|
|
20
|
+
const logger_1 = require("../log/logger");
|
|
21
|
+
const errors_1 = require("../i18n/errors");
|
|
22
|
+
const log = (0, logger_1.newLogger)('engine_client');
|
|
23
|
+
/**
|
|
24
|
+
* Client for handlers to call back to the workflow engine.
|
|
25
|
+
* Implements the EngineAPI interface and handles the round-trip
|
|
26
|
+
* communication pattern for async operations like submitting transactions.
|
|
27
|
+
*/
|
|
28
|
+
class EngineClient {
|
|
29
|
+
constructor(runtime) {
|
|
30
|
+
this.inflightRequests = new Map();
|
|
31
|
+
this.runtime = runtime;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Submit async transactions to the workflow engine
|
|
35
|
+
*/
|
|
36
|
+
async submitAsyncTransactions(authRef, transactions) {
|
|
37
|
+
if (!this.runtime.isWebSocketConnected()) {
|
|
38
|
+
throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKEngineNotConnected);
|
|
39
|
+
}
|
|
40
|
+
const activeContext = this.runtime.getActiveHandlerContext();
|
|
41
|
+
if (!activeContext) {
|
|
42
|
+
throw (0, errors_1.newError)(errors_1.SDKErrors.MsgSDKEngineReqNoActiveRequest);
|
|
43
|
+
}
|
|
44
|
+
const requestId = this.generateId();
|
|
45
|
+
log.debug('Submitting async transactions', {
|
|
46
|
+
requestId,
|
|
47
|
+
authRef,
|
|
48
|
+
count: transactions.length
|
|
49
|
+
});
|
|
50
|
+
const request = {
|
|
51
|
+
messageType: core_1.WSMessageType.ENGINE_API_SUBMIT_TRANSACTIONS,
|
|
52
|
+
id: requestId,
|
|
53
|
+
activeRequestId: activeContext.requestId,
|
|
54
|
+
authRef: authRef,
|
|
55
|
+
transactions: transactions,
|
|
56
|
+
};
|
|
57
|
+
return this.roundTrip(request, requestId);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Handle response for inflight request
|
|
61
|
+
*/
|
|
62
|
+
handleResponse(message) {
|
|
63
|
+
const inflight = this.inflightRequests.get(message.id);
|
|
64
|
+
if (inflight) {
|
|
65
|
+
this.inflightRequests.delete(message.id);
|
|
66
|
+
if (message.error) {
|
|
67
|
+
log.error('EngineAPI request failed', {
|
|
68
|
+
id: message.id,
|
|
69
|
+
error: message.error
|
|
70
|
+
});
|
|
71
|
+
inflight.reject(new Error(message.error));
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
log.debug('EngineAPI request succeeded', {
|
|
75
|
+
id: message.id,
|
|
76
|
+
results: message.submissions?.length
|
|
77
|
+
});
|
|
78
|
+
inflight.resolve(message.submissions || []);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
log.warn('Received response for unknown request', { id: message.id });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Round-trip request/response pattern
|
|
87
|
+
*/
|
|
88
|
+
roundTrip(request, requestId) {
|
|
89
|
+
return new Promise((resolve, reject) => {
|
|
90
|
+
this.inflightRequests.set(requestId, { resolve, reject });
|
|
91
|
+
this.runtime.sendMessage(request);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
generateId() {
|
|
95
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
exports.EngineClient = EngineClient;
|
|
99
|
+
//# sourceMappingURL=engine_client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine_client.js","sourceRoot":"","sources":["../../../src/runtime/engine_client.ts"],"names":[],"mappings":";AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;;AAGjC,wCAM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;IACpE,CAAC;CACF;AAtFD,oCAsFC"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { ClientOptions } from 'ws';
|
|
2
|
+
import { Handler, TransactionHandler, EventSource, EventProcessor } from '../interfaces/handlers';
|
|
3
|
+
/**
|
|
4
|
+
* outbound mode connects to the configured URL via a WebSocket connection
|
|
5
|
+
* inbound mode creates a websocket server and waits for connections
|
|
6
|
+
*/
|
|
7
|
+
export declare enum HandlerRuntimeMode {
|
|
8
|
+
OUTBOUND = "outbound",
|
|
9
|
+
INBOUND = "inbound"
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the handler runtime
|
|
13
|
+
*/
|
|
14
|
+
export interface HandlerRuntimeConfig {
|
|
15
|
+
url?: string;
|
|
16
|
+
providerName: string;
|
|
17
|
+
providerMetadata?: Record<string, string>;
|
|
18
|
+
authToken?: string;
|
|
19
|
+
authHeaderName?: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
options?: ClientOptions;
|
|
22
|
+
reconnectDelay?: number;
|
|
23
|
+
maxAttempts?: number;
|
|
24
|
+
pingIntervalMs?: number;
|
|
25
|
+
pongTimeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Internal runtime that manages WebSocket connection and handler lifecycle.
|
|
29
|
+
*/
|
|
30
|
+
export declare class HandlerRuntime {
|
|
31
|
+
private ws?;
|
|
32
|
+
private wsServer?;
|
|
33
|
+
private config;
|
|
34
|
+
private mode;
|
|
35
|
+
private port?;
|
|
36
|
+
private transactionHandlers;
|
|
37
|
+
private eventSources;
|
|
38
|
+
private eventSourceConfigs;
|
|
39
|
+
private eventProcessors;
|
|
40
|
+
private reconnectResolve?;
|
|
41
|
+
private reconnectReject?;
|
|
42
|
+
private isConnected;
|
|
43
|
+
private shouldReconnect;
|
|
44
|
+
private pingInterval?;
|
|
45
|
+
private pongTimeout?;
|
|
46
|
+
private readonly PING_INTERVAL_MS;
|
|
47
|
+
private readonly PONG_TIMEOUT_MS;
|
|
48
|
+
private engineClient;
|
|
49
|
+
private activeHandlerContext?;
|
|
50
|
+
constructor(config: HandlerRuntimeConfig);
|
|
51
|
+
/**
|
|
52
|
+
* Register a transaction handler
|
|
53
|
+
*/
|
|
54
|
+
registerTransactionHandler(name: string, handler: TransactionHandler): void;
|
|
55
|
+
/**
|
|
56
|
+
* Register an event source handler
|
|
57
|
+
*/
|
|
58
|
+
registerEventSource(name: string, handler: EventSource): void;
|
|
59
|
+
/**
|
|
60
|
+
* Register an event processor handler
|
|
61
|
+
*/
|
|
62
|
+
registerEventProcessor(name: string, handler: EventProcessor): void;
|
|
63
|
+
/**
|
|
64
|
+
* Get all registered handlers
|
|
65
|
+
*/
|
|
66
|
+
getAllHandlers(): Handler[];
|
|
67
|
+
/**
|
|
68
|
+
* Initialize all handlers and connect to WebSocket
|
|
69
|
+
*/
|
|
70
|
+
start(): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Stop the runtime and close all handlers
|
|
73
|
+
*/
|
|
74
|
+
stop(): void;
|
|
75
|
+
/**
|
|
76
|
+
* Check if connected to the workflow engine
|
|
77
|
+
*/
|
|
78
|
+
isWebSocketConnected(): boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Set active handler context for EngineAPI calls
|
|
81
|
+
*/
|
|
82
|
+
setActiveHandlerContext(requestId: string, authTokens: Record<string, string>): void;
|
|
83
|
+
/**
|
|
84
|
+
* Clear active handler context
|
|
85
|
+
*/
|
|
86
|
+
clearActiveHandlerContext(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Get active handler context
|
|
89
|
+
*/
|
|
90
|
+
getActiveHandlerContext(): {
|
|
91
|
+
requestId: string;
|
|
92
|
+
authTokens: Record<string, string>;
|
|
93
|
+
} | undefined;
|
|
94
|
+
/**
|
|
95
|
+
* Send a message over WebSocket
|
|
96
|
+
*/
|
|
97
|
+
sendMessage(message: any): void;
|
|
98
|
+
private createWebSocketServer;
|
|
99
|
+
private connectWebSocket;
|
|
100
|
+
private onError;
|
|
101
|
+
private onOpen;
|
|
102
|
+
private onClose;
|
|
103
|
+
private onMessage;
|
|
104
|
+
private registerProviderAndHandlers;
|
|
105
|
+
private registerHandler;
|
|
106
|
+
private handleMessage;
|
|
107
|
+
private handleTransactionsMessage;
|
|
108
|
+
private handleEventProcessorBatch;
|
|
109
|
+
private handleEventSourceConfig;
|
|
110
|
+
private handleEventSourcePoll;
|
|
111
|
+
private handleEventSourceValidateConfig;
|
|
112
|
+
private handleEventSourceDelete;
|
|
113
|
+
/**
|
|
114
|
+
* Setup WebSocket heartbeat for connection liveness detection.
|
|
115
|
+
* Sends periodic pings and detects missing pongs to identify dead connections.
|
|
116
|
+
*/
|
|
117
|
+
private setupHeartbeat;
|
|
118
|
+
/**
|
|
119
|
+
* Cleanup heartbeat timers and handlers
|
|
120
|
+
*/
|
|
121
|
+
private cleanupHeartbeat;
|
|
122
|
+
private generateId;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=handler_runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler_runtime.d.ts","sourceRoot":"","sources":["../../../src/runtime/handler_runtime.ts"],"names":[],"mappings":"AAiBA,OAAkB,EAAE,aAAa,EAAmB,MAAM,IAAI,CAAC;AAa/D,OAAO,EACL,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,cAAc,EACf,MAAM,wBAAwB,CAAC;AAQhC;;;GAGG;AACH,oBAAY,kBAAkB;IAC5B,QAAQ,aAAa;IACrB,OAAO,YAAY;CACpB;AACD;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAEnC,GAAG,CAAC,EAAE,MAAM,CAAC;IAEb,YAAY,EAAE,MAAM,CAAC;IAErB,gBAAgB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAE1C,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,cAAc,CAAC,EAAE,MAAM,CAAC;IAExB,OAAO,CAAC,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