@kaleido-io/workflow-engine-sdk 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +486 -362
- package/bin/init.js +14 -15
- package/dist/src/client/client.d.ts +22 -0
- package/dist/src/client/client.d.ts.map +1 -1
- package/dist/src/client/client.js +1 -0
- package/dist/src/client/client.js.map +1 -1
- package/dist/src/client/client_factory.d.ts +14 -0
- package/dist/src/client/client_factory.d.ts.map +1 -0
- package/dist/src/client/client_factory.js +64 -0
- package/dist/src/client/client_factory.js.map +1 -0
- package/dist/src/client/rest-client.d.ts.map +1 -1
- package/dist/src/client/rest-client.js +1 -1
- package/dist/src/client/rest-client.js.map +1 -1
- package/dist/src/config/config.d.ts +81 -1
- package/dist/src/config/config.d.ts.map +1 -1
- package/dist/src/config/config.js +269 -24
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config_helpers.d.ts +44 -0
- package/dist/src/config/config_helpers.d.ts.map +1 -0
- package/dist/src/config/config_helpers.js +68 -0
- package/dist/src/config/config_helpers.js.map +1 -0
- package/dist/src/helpers/stage_director.js +2 -2
- package/dist/src/i18n/errors.d.ts +5 -0
- package/dist/src/i18n/errors.d.ts.map +1 -1
- package/dist/src/i18n/errors.js +8 -3
- package/dist/src/i18n/errors.js.map +1 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +5 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/runtime/handler_runtime.d.ts +22 -0
- package/dist/src/runtime/handler_runtime.d.ts.map +1 -1
- package/dist/src/runtime/handler_runtime.js +43 -3
- package/dist/src/runtime/handler_runtime.js.map +1 -1
- package/dist/src/utils/patch.d.ts +1 -1
- package/dist-esm/src/client/client.js +2 -1
- package/dist-esm/src/client/client.js.map +1 -1
- package/dist-esm/src/client/client_factory.js +60 -0
- package/dist-esm/src/client/client_factory.js.map +1 -0
- package/dist-esm/src/client/rest-client.js +1 -1
- package/dist-esm/src/client/rest-client.js.map +1 -1
- package/dist-esm/src/config/config.js +235 -25
- package/dist-esm/src/config/config.js.map +1 -1
- package/dist-esm/src/config/config_helpers.js +61 -0
- package/dist-esm/src/config/config_helpers.js.map +1 -0
- package/dist-esm/src/helpers/stage_director.js +2 -2
- package/dist-esm/src/i18n/errors.js +8 -3
- package/dist-esm/src/i18n/errors.js.map +1 -1
- package/dist-esm/src/index.js +2 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/runtime/handler_runtime.js +38 -2
- package/dist-esm/src/runtime/handler_runtime.js.map +1 -1
- package/dist-esm/src/utils/patch.js +2 -2
- package/package.json +1 -1
- package/template/README.md +5 -8
- package/template/config/config.yaml +12 -0
- package/template/config/wfe-config.yaml +12 -0
- package/template/package-lock.json +1908 -0
- package/template/package.json +4 -2
- package/template/src/connect.ts +35 -37
- package/template/src/provider.ts +4 -4
- package/template/src/samples/event-source/echo-handler.ts +2 -2
- package/template/src/samples/event-source/event-processor.ts +1 -1
- package/template/src/samples/event-source/event-source.ts +1 -1
- package/template/src/samples/event-source/stream.ts +11 -11
- package/template/src/samples/hello/flow.ts +36 -36
- package/template/src/samples/hello/handlers.ts +2 -2
- package/template/src/samples/hello/transaction.ts +4 -4
- package/template/src/samples/http-invoke/flow.ts +29 -29
- package/template/src/samples/http-invoke/handlers.ts +88 -39
- package/template/src/samples/http-invoke/transaction.ts +3 -3
- package/template/src/samples/snap/event-source.ts +1 -1
- package/template/src/samples/snap/flow.ts +40 -40
- package/template/src/samples/snap/snap-handler.ts +2 -2
- package/template/src/samples/snap/transaction.ts +6 -6
- package/template/.env.sample +0 -14
|
@@ -13,9 +13,75 @@
|
|
|
13
13
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
// See the License for the specific language governing permissions and
|
|
15
15
|
// limitations under the License.
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
|
|
16
|
+
import * as fs from "fs";
|
|
17
|
+
import * as yaml from "js-yaml";
|
|
18
|
+
import { cfgStrField, cfgStrOrNumAsString, cfgNumField, cfgObjField, parseInboundServerAddressPort, } from "./config_helpers.js";
|
|
19
|
+
import { newLogger } from "../log/logger.js";
|
|
20
|
+
import { SDKErrors, newError } from "../i18n/errors.js";
|
|
21
|
+
/**
|
|
22
|
+
* Environment variable name for the workflow engine config file path.
|
|
23
|
+
*/
|
|
24
|
+
export const WFE_CONFIG_FILE = "WFE_CONFIG_FILE";
|
|
25
|
+
/**
|
|
26
|
+
* Config key names
|
|
27
|
+
*/
|
|
28
|
+
export const ConfigWorkflowEngineProviderName = "providerName";
|
|
29
|
+
export const ConfigWorkflowEngineProviderMetadata = "providerMetadata";
|
|
30
|
+
export const ConfigWorkflowEngineUrl = "url";
|
|
31
|
+
export const ConfigWorkflowEngineAuth = "auth";
|
|
32
|
+
export const ConfigWorkflowEngineMaxRetries = "maxRetries";
|
|
33
|
+
export const ConfigWorkflowEngineRetryDelay = "retryDelay";
|
|
34
|
+
export const ConfigWorkflowEngineServer = "server";
|
|
35
|
+
/**
|
|
36
|
+
* Config key names for server subsection
|
|
37
|
+
*/
|
|
38
|
+
export const ConfigServerAddress = "address";
|
|
39
|
+
export const ConfigServerPort = "port";
|
|
40
|
+
export const ConfigServerReadBufferSize = "readBufferSize";
|
|
41
|
+
export const ConfigServerWriteBufferSize = "writeBufferSize";
|
|
42
|
+
export const ConfigServerHeartbeatInterval = "heartbeatInterval";
|
|
43
|
+
export const ConfigServerThrottleRPS = "requestsPerSecond";
|
|
44
|
+
export const ConfigServerThrottleBurst = "burst";
|
|
45
|
+
export const ConfigServerTls = "tls";
|
|
46
|
+
/**
|
|
47
|
+
* Config key names for server.tls subsection
|
|
48
|
+
*/
|
|
49
|
+
export const ConfigTlsEnabled = "enabled";
|
|
50
|
+
export const ConfigTlsCaFile = "caFile";
|
|
51
|
+
export const ConfigTlsCertFile = "certFile";
|
|
52
|
+
export const ConfigTlsKeyFile = "keyFile";
|
|
53
|
+
export const ConfigTlsClientAuth = "clientAuth";
|
|
54
|
+
const log = newLogger("config");
|
|
55
|
+
/**
|
|
56
|
+
* Parse a time string to milliseconds. Supports: ms, s, m, h (e.g. "30s", "100ms", "1m").
|
|
57
|
+
* Returns NaN if the string is invalid.
|
|
58
|
+
*/
|
|
59
|
+
export function parseTimeStringToMs(value) {
|
|
60
|
+
const s = value.trim();
|
|
61
|
+
const match = s.match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h)$/i);
|
|
62
|
+
if (!match)
|
|
63
|
+
return NaN;
|
|
64
|
+
const n = parseFloat(match[1]);
|
|
65
|
+
// Group 2 is always ms|s|m|h when the full pattern matches.
|
|
66
|
+
const unit = match[2].toLowerCase();
|
|
67
|
+
return timeStringUnitToMs(n, unit);
|
|
68
|
+
}
|
|
69
|
+
/** @internal exposed for tests — defensive NaN when unit is not ms|s|m|h */
|
|
70
|
+
export function timeStringUnitToMs(n, unitLower) {
|
|
71
|
+
if (unitLower === "ms") {
|
|
72
|
+
return n;
|
|
73
|
+
}
|
|
74
|
+
if (unitLower === "s") {
|
|
75
|
+
return n * 1000;
|
|
76
|
+
}
|
|
77
|
+
if (unitLower === "m") {
|
|
78
|
+
return n * 60 * 1000;
|
|
79
|
+
}
|
|
80
|
+
if (unitLower === "h") {
|
|
81
|
+
return n * 60 * 60 * 1000;
|
|
82
|
+
}
|
|
83
|
+
return NaN;
|
|
84
|
+
}
|
|
19
85
|
/**
|
|
20
86
|
* Authentication type enum
|
|
21
87
|
*/
|
|
@@ -41,14 +107,14 @@ export class ConfigLoader {
|
|
|
41
107
|
// Use discriminated union to handle different auth types
|
|
42
108
|
switch (auth.type) {
|
|
43
109
|
case AuthType.BASIC: {
|
|
44
|
-
headerName =
|
|
45
|
-
const credentials = Buffer.from(`${auth.username}:${auth.password}`).toString(
|
|
110
|
+
headerName = "Authorization";
|
|
111
|
+
const credentials = Buffer.from(`${auth.username}:${auth.password}`).toString("base64");
|
|
46
112
|
authValue = `Basic ${credentials}`;
|
|
47
113
|
break;
|
|
48
114
|
}
|
|
49
115
|
case AuthType.TOKEN: {
|
|
50
|
-
headerName = auth.header ||
|
|
51
|
-
const scheme = auth.scheme ||
|
|
116
|
+
headerName = auth.header || "Authorization";
|
|
117
|
+
const scheme = auth.scheme || "";
|
|
52
118
|
authValue = scheme ? `${scheme} ${auth.token}` : auth.token;
|
|
53
119
|
break;
|
|
54
120
|
}
|
|
@@ -58,35 +124,179 @@ export class ConfigLoader {
|
|
|
58
124
|
throw newError(SDKErrors.MsgSDKConfigUnknownAuthType, _exhaustive.type);
|
|
59
125
|
}
|
|
60
126
|
}
|
|
61
|
-
// Convert HTTP(S) URL to WebSocket URL with /ws path
|
|
62
|
-
let wsUrl = config.workflowEngine.url;
|
|
63
|
-
if (wsUrl.startsWith('http://')) {
|
|
64
|
-
wsUrl = 'ws://' + wsUrl.substring(7);
|
|
65
|
-
}
|
|
66
|
-
else if (wsUrl.startsWith('https://')) {
|
|
67
|
-
wsUrl = 'wss://' + wsUrl.substring(8);
|
|
68
|
-
}
|
|
69
|
-
// Add /ws path if not already present
|
|
70
|
-
if (!wsUrl.endsWith('/ws')) {
|
|
71
|
-
wsUrl = wsUrl.replace(/\/$/, '') + '/ws';
|
|
72
|
-
}
|
|
73
127
|
return {
|
|
74
|
-
url:
|
|
128
|
+
url: ConfigLoader.httpUrlToWsUrl(config.workflowEngine.url),
|
|
75
129
|
providerName,
|
|
76
130
|
options: {
|
|
77
131
|
headers: {
|
|
78
|
-
[headerName]: authValue
|
|
79
|
-
}
|
|
132
|
+
[headerName]: authValue,
|
|
133
|
+
},
|
|
80
134
|
},
|
|
81
135
|
maxAttempts: config.workflowEngine.maxRetries, // undefined = infinite retries
|
|
82
|
-
reconnectDelay:
|
|
136
|
+
reconnectDelay: ConfigLoader.retryDelayRawToMs(config.workflowEngine.retryDelay),
|
|
137
|
+
};
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Parse retry delay: plain integer (or digits-only string) = seconds; otherwise time string (2s, 100ms, 1m, 1h).
|
|
141
|
+
* Matches file-loader behavior for inbound/outbound.
|
|
142
|
+
*/
|
|
143
|
+
static retryDelayRawToMs(raw) {
|
|
144
|
+
const s = raw?.trim();
|
|
145
|
+
if (!s) {
|
|
146
|
+
return 2000;
|
|
147
|
+
}
|
|
148
|
+
const ms = parseTimeStringToMs(/^\d+$/.test(s) ? `${s}s` : s);
|
|
149
|
+
return Number.isNaN(ms) ? 2000 : ms;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Build WebSocket URL from HTTP(S) base URL (add /ws, convert scheme).
|
|
153
|
+
*/
|
|
154
|
+
static httpUrlToWsUrl(baseUrl) {
|
|
155
|
+
let wsUrl = baseUrl;
|
|
156
|
+
if (wsUrl.startsWith("http://")) {
|
|
157
|
+
wsUrl = "ws://" + wsUrl.substring(7);
|
|
158
|
+
}
|
|
159
|
+
else if (wsUrl.startsWith("https://")) {
|
|
160
|
+
wsUrl = "wss://" + wsUrl.substring(8);
|
|
161
|
+
}
|
|
162
|
+
if (!wsUrl.endsWith("/ws")) {
|
|
163
|
+
wsUrl = wsUrl.replace(/\/$/, "") + "/ws";
|
|
164
|
+
}
|
|
165
|
+
return wsUrl;
|
|
166
|
+
}
|
|
167
|
+
static retryDelayMsFromSection(section) {
|
|
168
|
+
return ConfigLoader.retryDelayRawToMs(cfgStrOrNumAsString(section, ConfigWorkflowEngineRetryDelay));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Load WorkflowEngineClientConfig from a YAML file.
|
|
172
|
+
* Uses WFE_CONFIG_FILE env if configFilePath is not provided.
|
|
173
|
+
* Only the root key "workflow-engine" is supported in the config file.
|
|
174
|
+
*
|
|
175
|
+
* - Outbound: use "url" and "auth"; the app connects to the workflow engine.
|
|
176
|
+
* - Inbound: use "server" (address, port, etc.); the app creates a WebSocket server and the engine connects to it. Auth is not used.
|
|
177
|
+
*/
|
|
178
|
+
static loadClientConfigFromFile(configFilePath) {
|
|
179
|
+
const configPath = (configFilePath ??
|
|
180
|
+
process.env[WFE_CONFIG_FILE] ??
|
|
181
|
+
"").trim();
|
|
182
|
+
if (!configPath) {
|
|
183
|
+
throw newError(SDKErrors.MsgSDKConfigFileNotSet, WFE_CONFIG_FILE);
|
|
184
|
+
}
|
|
185
|
+
const raw = fs.readFileSync(configPath, "utf8");
|
|
186
|
+
const parsed = yaml.load(raw);
|
|
187
|
+
if (!parsed || typeof parsed !== "object") {
|
|
188
|
+
throw newError(SDKErrors.MsgSDKConfigFileInvalid, configPath);
|
|
189
|
+
}
|
|
190
|
+
const section = parsed["workflow-engine"];
|
|
191
|
+
if (!section || typeof section !== "object") {
|
|
192
|
+
throw newError(SDKErrors.MsgSDKConfigSectionMissing, configPath);
|
|
193
|
+
}
|
|
194
|
+
const providerName = cfgStrField(section, ConfigWorkflowEngineProviderName);
|
|
195
|
+
if (!providerName) {
|
|
196
|
+
throw newError(SDKErrors.MsgSDKProviderNameNotSet);
|
|
197
|
+
}
|
|
198
|
+
const serverSection = cfgObjField(section, ConfigWorkflowEngineServer);
|
|
199
|
+
const url = cfgStrField(section, ConfigWorkflowEngineUrl) || undefined;
|
|
200
|
+
const auth = section[ConfigWorkflowEngineAuth];
|
|
201
|
+
// Inbound: server section only → app creates WebSocket server (no url, no auth)
|
|
202
|
+
const inbound = !url && serverSection;
|
|
203
|
+
if (inbound && serverSection) {
|
|
204
|
+
const addrPort = parseInboundServerAddressPort(serverSection, ConfigServerAddress, ConfigServerPort);
|
|
205
|
+
if (addrPort) {
|
|
206
|
+
const tlsSection = cfgObjField(serverSection, ConfigServerTls);
|
|
207
|
+
const serverConfig = {
|
|
208
|
+
address: addrPort.address,
|
|
209
|
+
port: addrPort.port,
|
|
210
|
+
};
|
|
211
|
+
if (tlsSection && tlsSection[ConfigTlsEnabled] === true) {
|
|
212
|
+
serverConfig.tls = ConfigLoader.buildServerTlsFromSection(tlsSection);
|
|
213
|
+
}
|
|
214
|
+
const clientConfig = {
|
|
215
|
+
server: serverConfig,
|
|
216
|
+
providerName,
|
|
217
|
+
maxAttempts: cfgNumField(section, ConfigWorkflowEngineMaxRetries),
|
|
218
|
+
reconnectDelay: ConfigLoader.retryDelayMsFromSection(section),
|
|
219
|
+
};
|
|
220
|
+
ConfigLoader.applyProviderMetadata(clientConfig, section);
|
|
221
|
+
return clientConfig;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
if (!url) {
|
|
225
|
+
throw newError(SDKErrors.MsgSDKConfigUrlAuthMissing, configPath);
|
|
226
|
+
}
|
|
227
|
+
// Outbound: url + auth → use createClientConfig
|
|
228
|
+
if (auth && typeof auth === "object") {
|
|
229
|
+
const engineConfig = {
|
|
230
|
+
workflowEngine: {
|
|
231
|
+
url,
|
|
232
|
+
auth,
|
|
233
|
+
maxRetries: cfgNumField(section, ConfigWorkflowEngineMaxRetries),
|
|
234
|
+
retryDelay: cfgStrOrNumAsString(section, ConfigWorkflowEngineRetryDelay),
|
|
235
|
+
},
|
|
236
|
+
};
|
|
237
|
+
const clientConfig = ConfigLoader.createClientConfig(engineConfig, providerName);
|
|
238
|
+
ConfigLoader.applyProviderMetadata(clientConfig, section);
|
|
239
|
+
return clientConfig;
|
|
240
|
+
}
|
|
241
|
+
throw newError(SDKErrors.MsgSDKConfigUrlAuthMissing, configPath);
|
|
242
|
+
}
|
|
243
|
+
/**
|
|
244
|
+
* Build server TLS config from server.tls section (for inbound WebSocket server).
|
|
245
|
+
* Reads caFile, certFile, keyFile and returns { enabled, ca?, cert?, key? }.
|
|
246
|
+
*/
|
|
247
|
+
static buildServerTlsFromSection(tlsSection) {
|
|
248
|
+
const certFile = cfgStrField(tlsSection, ConfigTlsCertFile);
|
|
249
|
+
const keyFile = cfgStrField(tlsSection, ConfigTlsKeyFile);
|
|
250
|
+
const caFile = cfgStrField(tlsSection, ConfigTlsCaFile);
|
|
251
|
+
return {
|
|
252
|
+
enabled: true,
|
|
253
|
+
...(caFile && { ca: fs.readFileSync(caFile) }),
|
|
254
|
+
...(certFile && { cert: fs.readFileSync(certFile) }),
|
|
255
|
+
...(keyFile && { key: fs.readFileSync(keyFile) }),
|
|
83
256
|
};
|
|
84
257
|
}
|
|
258
|
+
/**
|
|
259
|
+
* Build WebSocket client TLS options from server.tls config section (outbound client).
|
|
260
|
+
* Reads caFile, certFile, keyFile and returns options suitable for ws client (ca, cert, key, rejectUnauthorized).
|
|
261
|
+
*/
|
|
262
|
+
static buildTlsOptionsFromSection(tlsSection) {
|
|
263
|
+
const opts = {};
|
|
264
|
+
const caFile = cfgStrField(tlsSection, ConfigTlsCaFile);
|
|
265
|
+
const certFile = cfgStrField(tlsSection, ConfigTlsCertFile);
|
|
266
|
+
const keyFile = cfgStrField(tlsSection, ConfigTlsKeyFile);
|
|
267
|
+
if (caFile) {
|
|
268
|
+
opts.ca = fs.readFileSync(caFile);
|
|
269
|
+
opts.rejectUnauthorized = true;
|
|
270
|
+
}
|
|
271
|
+
else {
|
|
272
|
+
opts.rejectUnauthorized = false;
|
|
273
|
+
}
|
|
274
|
+
if (certFile)
|
|
275
|
+
opts.cert = fs.readFileSync(certFile);
|
|
276
|
+
if (keyFile)
|
|
277
|
+
opts.key = fs.readFileSync(keyFile);
|
|
278
|
+
return opts;
|
|
279
|
+
}
|
|
280
|
+
static applyProviderMetadata(clientConfig, section) {
|
|
281
|
+
const metaObj = cfgObjField(section, ConfigWorkflowEngineProviderMetadata);
|
|
282
|
+
if (!metaObj) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const meta = {};
|
|
286
|
+
for (const [k, v] of Object.entries(metaObj)) {
|
|
287
|
+
if (typeof v === "string") {
|
|
288
|
+
meta[k] = v;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
if (Object.keys(meta).length > 0) {
|
|
292
|
+
clientConfig.providerMetadata = meta;
|
|
293
|
+
}
|
|
294
|
+
}
|
|
85
295
|
/**
|
|
86
296
|
* Log configuration summary (without sensitive data)
|
|
87
297
|
*/
|
|
88
298
|
static logConfigSummary(config) {
|
|
89
|
-
log.info(
|
|
299
|
+
log.info("Configuration loaded:");
|
|
90
300
|
log.info(` Workflow Engine: ${config.workflowEngine.url}`);
|
|
91
301
|
const auth = config.workflowEngine.auth;
|
|
92
302
|
switch (auth.type) {
|
|
@@ -96,7 +306,7 @@ export class ConfigLoader {
|
|
|
96
306
|
break;
|
|
97
307
|
case AuthType.TOKEN:
|
|
98
308
|
log.info(` Auth Type: ${AuthType.TOKEN}`);
|
|
99
|
-
log.info(` Auth Header: ${auth.header ||
|
|
309
|
+
log.info(` Auth Header: ${auth.header || "Authorization"}`);
|
|
100
310
|
if (auth.scheme) {
|
|
101
311
|
log.info(` Auth Scheme: ${auth.scheme}`);
|
|
102
312
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.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;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/config/config.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;AAEjC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAEhC,OAAO,EACL,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,WAAW,EACX,6BAA6B,GAC9B,MAAM,kBAAkB,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Ac,CAAC,IAAI,CAAC;QACxC,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;YAClB,KAAK,QAAQ,CAAC,KAAK;gBACjB,GAAG,CAAC,IAAI,CAAC,gBAAgB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;gBAC3C,GAAG,CAAC,IAAI,CAAC,eAAe,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACzC,MAAM;YACR,KAAK,QAAQ,CAAC,KAAK;gBACjB,GAAG,CAAC,IAAI,CAAC,gBAAgB,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;gBAC3C,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,MAAM,IAAI,eAAe,EAAE,CAAC,CAAC;gBAC7D,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;oBAChB,GAAG,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;gBAC5C,CAAC;gBACD,MAAM;QACV,CAAC;QAED,IAAI,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;QACjE,CAAC;QAED,IAAI,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC;YACrC,GAAG,CAAC,IAAI,CAAC,kBAAkB,MAAM,CAAC,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;QACjE,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright © 2026 Kaleido, Inc.
|
|
2
|
+
//
|
|
3
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
//
|
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
// you may not use this file except in compliance with the License.
|
|
7
|
+
// You may obtain a copy of the License at
|
|
8
|
+
//
|
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
//
|
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
// See the License for the specific language governing permissions and
|
|
15
|
+
// limitations under the License.
|
|
16
|
+
/** Non-empty trimmed string from record[key], or empty string. */
|
|
17
|
+
export function cfgStrField(rec, key) {
|
|
18
|
+
const v = rec[key];
|
|
19
|
+
return typeof v === "string" ? v.trim() : "";
|
|
20
|
+
}
|
|
21
|
+
/** String field; if value is number, coerces to string (e.g. retry delay seconds). */
|
|
22
|
+
export function cfgStrOrNumAsString(rec, key) {
|
|
23
|
+
const v = rec[key];
|
|
24
|
+
if (typeof v === "string" && v.trim()) {
|
|
25
|
+
return v.trim();
|
|
26
|
+
}
|
|
27
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
28
|
+
return String(v);
|
|
29
|
+
}
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
/** Finite number from record[key] (number or numeric string), or undefined. */
|
|
33
|
+
export function cfgNumField(rec, key) {
|
|
34
|
+
const v = rec[key];
|
|
35
|
+
if (typeof v === "number" && Number.isFinite(v)) {
|
|
36
|
+
return v;
|
|
37
|
+
}
|
|
38
|
+
if (typeof v === "string") {
|
|
39
|
+
const n = parseInt(v, 10);
|
|
40
|
+
return Number.isNaN(n) ? undefined : n;
|
|
41
|
+
}
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
/** Plain object (not array) at record[key], or undefined. */
|
|
45
|
+
export function cfgObjField(rec, key) {
|
|
46
|
+
const v = rec[key];
|
|
47
|
+
if (v != null && typeof v === "object" && !Array.isArray(v)) {
|
|
48
|
+
return v;
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
/** Parsed server address + port for inbound mode; undefined if invalid. */
|
|
53
|
+
export function parseInboundServerAddressPort(server, addressKey, portKey) {
|
|
54
|
+
const address = cfgStrField(server, addressKey);
|
|
55
|
+
const port = cfgNumField(server, portKey);
|
|
56
|
+
if (!address || port === undefined) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return { address, port };
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=config_helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config_helpers.js","sourceRoot":"","sources":["../../../src/config/config_helpers.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;AAmCjC,kEAAkE;AAClE,MAAM,UAAU,WAAW,CACzB,GAA4B,EAC5B,GAAW;IAEX,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC/C,CAAC;AAED,sFAAsF;AACtF,MAAM,UAAU,mBAAmB,CACjC,GAA4B,EAC5B,GAAW;IAEX,MAAM,CAAC,GAAG,GAAG,CAAC,GAAG,CAAC,CAAC;IACnB,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;QACtC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC;IAClB,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAChD,OAAO,MAAM,CAAC,CAAC,CAAC,CAAC;IACnB,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,WAAW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Helper.mapOutput(input.getStageDirector(), transaction, result, output, error, triggers, extraUpdates, customStage, events);
|
|
266
266
|
}
|
|
267
267
|
catch (error) {
|
|
268
|
-
log.error(
|
|
268
|
+
log.error('Handler execution failed:', error);
|
|
269
269
|
return {
|
|
270
270
|
error: getErrorMessage(error)
|
|
271
271
|
};
|
|
@@ -289,7 +289,7 @@ async function execBatchMapped(config, transactions) {
|
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
catch (error) {
|
|
292
|
-
log.error(
|
|
292
|
+
log.error('Batch handler execution failed:', error);
|
|
293
293
|
return transactions.map(() => ({
|
|
294
294
|
error: getErrorMessage(error)
|
|
295
295
|
}));
|
|
@@ -27,7 +27,7 @@ export const SDKErrors = {
|
|
|
27
27
|
MsgSDKObservedPanic: fe('KA140600', 'Observed panic: %s'),
|
|
28
28
|
MsgSDKUnknownHandler: fe('KA140601', "Unknown handler '%s'"),
|
|
29
29
|
MsgSDKUnknownNoListenerConfig: fe('KA140602', "Listener config for stream '%s' not supplied by workflow engine"),
|
|
30
|
-
MsgSDKOutputSerializationError: fe('KA140603',
|
|
30
|
+
MsgSDKOutputSerializationError: fe('KA140603', 'Unable to serialize output to %s'),
|
|
31
31
|
MsgSDKDirectorNextStageMissing: fe('KA140604', "Handler called with 'nextStage' missing from input"),
|
|
32
32
|
MsgSDKDirectorOutputPathMissing: fe('KA140605', "Handler called with 'outputPath' missing from input"),
|
|
33
33
|
MsgSDKDirectorFailureStageMissing: fe('KA140606', "Handler resulted in a failure, but 'failureStage' missing from input"),
|
|
@@ -40,8 +40,8 @@ export const SDKErrors = {
|
|
|
40
40
|
MsgSDKCheckpointInvalid: fe('KA140612', "Checkpoint generated by handler '%s' cannot be serialized"),
|
|
41
41
|
MsgSDKEventSourceDataInvalid: fe('KA140613', "Event source data could not be serialized for handler '%s'"),
|
|
42
42
|
// Engine API errors
|
|
43
|
-
MsgSDKEngineReplyInvalidData: fe('KA140614',
|
|
44
|
-
MsgSDKEngineReplyInvalidType: fe('KA140615',
|
|
43
|
+
MsgSDKEngineReplyInvalidData: fe('KA140614', 'Engine API reply for transaction %s invalid: %s'),
|
|
44
|
+
MsgSDKEngineReplyInvalidType: fe('KA140615', 'Engine API reply type for transaction %s invalid: %s'),
|
|
45
45
|
MsgSDKEngineReqNoActiveRequest: fe('KA140616', 'No engine handler is active on the supplied context'),
|
|
46
46
|
MsgSDKEngineFailMarshalEngineRequest: fe('KA140617', 'Failed to marshal engine transaction data'),
|
|
47
47
|
MsgSDKEngineFailSendEngineRequest: fe('KA140618', 'Failed to send engine transaction'),
|
|
@@ -61,6 +61,11 @@ export const SDKErrors = {
|
|
|
61
61
|
MsgSDKMissingActionField: fe('KA140629', 'Input is missing required "action" field in stage %s. Available fields: %s'),
|
|
62
62
|
// Configuration validation errors
|
|
63
63
|
MsgSDKConfigUnknownAuthType: fe('KA140626', 'Unknown auth type: %s'),
|
|
64
|
+
MsgSDKConfigFileNotSet: fe('KA140635', 'Workflow engine config file not set: pass a config file or set %s'),
|
|
65
|
+
MsgSDKConfigFileInvalid: fe('KA140636', 'Invalid workflow engine config file: %s'),
|
|
66
|
+
MsgSDKConfigSectionMissing: fe('KA140637', 'Missing "workflow-engine" section in %s'),
|
|
67
|
+
MsgSDKConfigUrlAuthMissing: fe('KA140638', 'Missing url or auth in workflow-engine section in %s'),
|
|
68
|
+
MsgSDKHandlerInvalidType: fe('KA140639', 'Handler "%s" does not implement TransactionHandler, EventSource, or EventProcessor'),
|
|
64
69
|
// Engine connection errors
|
|
65
70
|
MsgSDKEngineNotConnected: fe('KA140627', 'WebSocket is not connected. Cannot submit async transactions'),
|
|
66
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/i18n/errors.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDA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DAAsD,CAAC;IAClG,wBAAwB,EAAE,EAAE,CAAC,UAAU,EAAE,oFAAoF,CAAC;IAE9H,2BAA2B;IAC3B,wBAAwB,EAAE,EAAE,CAAC,UAAU,EAAE,8DAA8D,CAAC;CAChG,CAAC;AAEX;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,QAAsB,EAAE,GAAG,IAAW;IAChE,IAAI,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC;IAEjC,KAAK,MAAM,GAAG,IAAI,IAAI,EAAE,CAAC;QACvB,uCAAuC;QACvC,SAAS,GAAG,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,GAAG,QAAQ,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,QAAQ,CAAC,QAAsB,EAAE,GAAG,IAAW;IAC7D,OAAO,IAAI,KAAK,CAAC,WAAW,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
package/dist-esm/src/index.js
CHANGED
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
// ============================================================================
|
|
22
22
|
export { WorkflowEngineClient, } from './client/client.js';
|
|
23
23
|
export { WorkflowEngineRestClient, } from './client/rest-client.js';
|
|
24
|
-
export { ConfigLoader, } from './config/config.js';
|
|
24
|
+
export { ConfigLoader, WFE_CONFIG_FILE, } from './config/config.js';
|
|
25
|
+
export { HandlerSetFor, NewWorkflowEngineClient, } from './client/client_factory.js';
|
|
25
26
|
export { newLogger } from './log/logger.js';
|
|
26
27
|
// ============================================================================
|
|
27
28
|
// Core Types & Interfaces
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,EAAE;AACF,sCAAsC;AACtC,EAAE;AACF,kEAAkE;AAClE,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uB;AACvB,OAAO,EACL,KAAK,EACL,KAAK,EACL,QAAQ,EACR,SAAS,EACT,MAAM,EACN,MAAM,EACN,MAAM,GACP,MAAM,eAAe,CAAC;AAEvB,SAAS;AACT,cAAc,cAAc,CAAC;AAE7B,cAAc,eAAe,CAAC;AAI9B,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
// See the License for the specific language governing permissions and
|
|
15
15
|
// limitations under the License.
|
|
16
|
+
import https from 'https';
|
|
16
17
|
import WebSocket, { WebSocketServer } from 'ws';
|
|
17
18
|
import { backOff } from 'exponential-backoff';
|
|
18
19
|
import { WSMessageType, WSHandlerType, } from '../types/core.js';
|
|
@@ -30,6 +31,11 @@ export var HandlerRuntimeMode;
|
|
|
30
31
|
HandlerRuntimeMode["OUTBOUND"] = "outbound";
|
|
31
32
|
HandlerRuntimeMode["INBOUND"] = "inbound";
|
|
32
33
|
})(HandlerRuntimeMode || (HandlerRuntimeMode = {}));
|
|
34
|
+
/** Default listen port for inbound WebSocket server when `server.port` is omitted. */
|
|
35
|
+
export const DEFAULT_INBOUND_WS_PORT = 6000;
|
|
36
|
+
export function resolveInboundListenPort(port) {
|
|
37
|
+
return port ?? DEFAULT_INBOUND_WS_PORT;
|
|
38
|
+
}
|
|
33
39
|
/**
|
|
34
40
|
* Internal runtime that manages WebSocket connection and handler lifecycle.
|
|
35
41
|
*/
|
|
@@ -42,7 +48,12 @@ export class HandlerRuntime {
|
|
|
42
48
|
this.eventProcessors = new Map();
|
|
43
49
|
this.isConnected = false;
|
|
44
50
|
this.shouldReconnect = true;
|
|
45
|
-
if (
|
|
51
|
+
if (config.server) {
|
|
52
|
+
this.mode = HandlerRuntimeMode.INBOUND;
|
|
53
|
+
this.port = config.server.port;
|
|
54
|
+
this.serverConfig = config.server;
|
|
55
|
+
}
|
|
56
|
+
else if (process.env.WORKFLOW_ENGINE_MODE === 'inbound') {
|
|
46
57
|
this.mode = HandlerRuntimeMode.INBOUND;
|
|
47
58
|
if (!process.env.WEBSOCKET_PORT) {
|
|
48
59
|
throw newError(SDKErrors.MsgSDKWebSocketPortRequiredInbound);
|
|
@@ -135,6 +146,10 @@ export class HandlerRuntime {
|
|
|
135
146
|
if (this.wsServer) {
|
|
136
147
|
this.wsServer.close();
|
|
137
148
|
}
|
|
149
|
+
if (this.inboundHttpsServer) {
|
|
150
|
+
this.inboundHttpsServer.close();
|
|
151
|
+
this.inboundHttpsServer = undefined;
|
|
152
|
+
}
|
|
138
153
|
for (const [name, handler] of this.transactionHandlers.entries()) {
|
|
139
154
|
handler.close();
|
|
140
155
|
log.debug('Closed transaction handler', { name });
|
|
@@ -187,7 +202,28 @@ export class HandlerRuntime {
|
|
|
187
202
|
// WebSocket Connection Management
|
|
188
203
|
// ============================================================================
|
|
189
204
|
createWebSocketServer() {
|
|
190
|
-
|
|
205
|
+
const port = resolveInboundListenPort(this.port);
|
|
206
|
+
const address = this.serverConfig?.address ?? '0.0.0.0';
|
|
207
|
+
const tls = this.serverConfig?.tls;
|
|
208
|
+
if (tls?.enabled && tls.cert && tls.key) {
|
|
209
|
+
const httpsOptions = {
|
|
210
|
+
cert: tls.cert,
|
|
211
|
+
key: tls.key,
|
|
212
|
+
};
|
|
213
|
+
if (tls.ca) {
|
|
214
|
+
httpsOptions.ca = tls.ca;
|
|
215
|
+
}
|
|
216
|
+
const httpsServer = https.createServer(httpsOptions);
|
|
217
|
+
this.inboundHttpsServer = httpsServer;
|
|
218
|
+
httpsServer.listen(port, address, () => {
|
|
219
|
+
log.info('WebSocket server (TLS) listening', { address, port, provider: this.config.providerName });
|
|
220
|
+
});
|
|
221
|
+
this.wsServer = new WebSocketServer({ server: httpsServer });
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
this.wsServer = new WebSocketServer({ port, host: address });
|
|
225
|
+
log.info('WebSocket server listening', { address, port, provider: this.config.providerName });
|
|
226
|
+
}
|
|
191
227
|
this.wsServer.on('connection', (ws, req) => {
|
|
192
228
|
log.info('WebSocket server connection', { remoteAddress: req.socket.remoteAddress, remotePort: req.socket.remotePort });
|
|
193
229
|
this.ws = ws;
|