@openfn/ws-worker 0.8.1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/index.d.ts +49 -121
- package/dist/index.js +328 -193
- package/dist/start.js +427 -272
- package/package.json +7 -6
package/dist/start.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
4
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
3
5
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
4
6
|
}) : x)(function(x) {
|
|
@@ -6,6 +8,110 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
|
|
|
6
8
|
return require.apply(this, arguments);
|
|
7
9
|
throw new Error('Dynamic require of "' + x + '" is not supported');
|
|
8
10
|
});
|
|
11
|
+
var __esm = (fn, res) => function __init() {
|
|
12
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
13
|
+
};
|
|
14
|
+
var __export = (target, all) => {
|
|
15
|
+
for (var name2 in all)
|
|
16
|
+
__defProp(target, name2, { get: all[name2], enumerable: true });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// package.json
|
|
20
|
+
var package_exports = {};
|
|
21
|
+
__export(package_exports, {
|
|
22
|
+
author: () => author,
|
|
23
|
+
bin: () => bin,
|
|
24
|
+
default: () => package_default,
|
|
25
|
+
dependencies: () => dependencies,
|
|
26
|
+
description: () => description,
|
|
27
|
+
devDependencies: () => devDependencies,
|
|
28
|
+
files: () => files,
|
|
29
|
+
license: () => license,
|
|
30
|
+
main: () => main,
|
|
31
|
+
name: () => name,
|
|
32
|
+
scripts: () => scripts,
|
|
33
|
+
type: () => type,
|
|
34
|
+
version: () => version
|
|
35
|
+
});
|
|
36
|
+
var name, version, description, main, type, scripts, bin, author, license, dependencies, devDependencies, files, package_default;
|
|
37
|
+
var init_package = __esm({
|
|
38
|
+
"package.json"() {
|
|
39
|
+
name = "@openfn/ws-worker";
|
|
40
|
+
version = "1.1.0";
|
|
41
|
+
description = "A Websocket Worker to connect Lightning to a Runtime Engine";
|
|
42
|
+
main = "dist/index.js";
|
|
43
|
+
type = "module";
|
|
44
|
+
scripts = {
|
|
45
|
+
test: "pnpm ava --serial",
|
|
46
|
+
"test:types": "pnpm tsc --noEmit --project tsconfig.json",
|
|
47
|
+
build: "tsup --config tsup.config.js",
|
|
48
|
+
"build:watch": "pnpm build --watch",
|
|
49
|
+
start: "ts-node-esm --transpile-only src/start.ts",
|
|
50
|
+
"start:prod": "node dist/start.js",
|
|
51
|
+
"start:watch": "nodemon -e ts,js --watch ../runtime-manager/dist --watch ./src --exec 'pnpm start'",
|
|
52
|
+
pack: "pnpm pack --pack-destination ../../dist"
|
|
53
|
+
};
|
|
54
|
+
bin = {
|
|
55
|
+
worker: "dist/start.js"
|
|
56
|
+
};
|
|
57
|
+
author = "Open Function Group <admin@openfn.org>";
|
|
58
|
+
license = "ISC";
|
|
59
|
+
dependencies = {
|
|
60
|
+
"@koa/router": "^12.0.0",
|
|
61
|
+
"@openfn/engine-multi": "workspace:*",
|
|
62
|
+
"@openfn/lexicon": "workspace:^",
|
|
63
|
+
"@openfn/logger": "workspace:*",
|
|
64
|
+
"@openfn/runtime": "workspace:*",
|
|
65
|
+
"@types/koa-logger": "^3.1.2",
|
|
66
|
+
"@types/ws": "^8.5.6",
|
|
67
|
+
"fast-safe-stringify": "^2.1.1",
|
|
68
|
+
figures: "^5.0.0",
|
|
69
|
+
"human-id": "^4.1.0",
|
|
70
|
+
jose: "^4.14.6",
|
|
71
|
+
koa: "^2.13.4",
|
|
72
|
+
"koa-bodyparser": "^4.4.0",
|
|
73
|
+
"koa-logger": "^3.2.1",
|
|
74
|
+
phoenix: "1.7.10",
|
|
75
|
+
ws: "^8.14.1"
|
|
76
|
+
};
|
|
77
|
+
devDependencies = {
|
|
78
|
+
"@openfn/lightning-mock": "workspace:*",
|
|
79
|
+
"@types/koa": "^2.13.5",
|
|
80
|
+
"@types/koa-bodyparser": "^4.3.10",
|
|
81
|
+
"@types/koa__router": "^12.0.1",
|
|
82
|
+
"@types/node": "^18.15.3",
|
|
83
|
+
"@types/nodemon": "1.19.3",
|
|
84
|
+
"@types/phoenix": "^1.6.2",
|
|
85
|
+
"@types/yargs": "^17.0.12",
|
|
86
|
+
ava: "5.1.0",
|
|
87
|
+
nodemon: "3.0.1",
|
|
88
|
+
"ts-node": "^10.9.1",
|
|
89
|
+
tslib: "^2.4.0",
|
|
90
|
+
tsup: "^6.2.3",
|
|
91
|
+
typescript: "^4.6.4",
|
|
92
|
+
yargs: "^17.6.2"
|
|
93
|
+
};
|
|
94
|
+
files = [
|
|
95
|
+
"dist",
|
|
96
|
+
"README.md",
|
|
97
|
+
"CHANGELOG.md"
|
|
98
|
+
];
|
|
99
|
+
package_default = {
|
|
100
|
+
name,
|
|
101
|
+
version,
|
|
102
|
+
description,
|
|
103
|
+
main,
|
|
104
|
+
type,
|
|
105
|
+
scripts,
|
|
106
|
+
bin,
|
|
107
|
+
author,
|
|
108
|
+
license,
|
|
109
|
+
dependencies,
|
|
110
|
+
devDependencies,
|
|
111
|
+
files
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
});
|
|
9
115
|
|
|
10
116
|
// ../../node_modules/.pnpm/yargs@17.7.2/node_modules/yargs/lib/platform-shims/esm.mjs
|
|
11
117
|
import { notStrictEqual, strictEqual } from "assert";
|
|
@@ -1167,26 +1273,26 @@ var YargsParser = class {
|
|
|
1167
1273
|
return defaultForType(guessType2(key));
|
|
1168
1274
|
}
|
|
1169
1275
|
}
|
|
1170
|
-
function defaultForType(
|
|
1276
|
+
function defaultForType(type2) {
|
|
1171
1277
|
const def = {
|
|
1172
1278
|
[DefaultValuesForTypeKey.BOOLEAN]: true,
|
|
1173
1279
|
[DefaultValuesForTypeKey.STRING]: "",
|
|
1174
1280
|
[DefaultValuesForTypeKey.NUMBER]: void 0,
|
|
1175
1281
|
[DefaultValuesForTypeKey.ARRAY]: []
|
|
1176
1282
|
};
|
|
1177
|
-
return def[
|
|
1283
|
+
return def[type2];
|
|
1178
1284
|
}
|
|
1179
1285
|
function guessType2(key) {
|
|
1180
|
-
let
|
|
1286
|
+
let type2 = DefaultValuesForTypeKey.BOOLEAN;
|
|
1181
1287
|
if (checkAllAliases(key, flags.strings))
|
|
1182
|
-
|
|
1288
|
+
type2 = DefaultValuesForTypeKey.STRING;
|
|
1183
1289
|
else if (checkAllAliases(key, flags.numbers))
|
|
1184
|
-
|
|
1290
|
+
type2 = DefaultValuesForTypeKey.NUMBER;
|
|
1185
1291
|
else if (checkAllAliases(key, flags.bools))
|
|
1186
|
-
|
|
1292
|
+
type2 = DefaultValuesForTypeKey.BOOLEAN;
|
|
1187
1293
|
else if (checkAllAliases(key, flags.arrays))
|
|
1188
|
-
|
|
1189
|
-
return
|
|
1294
|
+
type2 = DefaultValuesForTypeKey.ARRAY;
|
|
1295
|
+
return type2;
|
|
1190
1296
|
}
|
|
1191
1297
|
function isUndefined(num) {
|
|
1192
1298
|
return num === void 0;
|
|
@@ -1560,7 +1666,7 @@ var esm_default = {
|
|
|
1560
1666
|
process: {
|
|
1561
1667
|
argv: () => process.argv,
|
|
1562
1668
|
cwd: process.cwd,
|
|
1563
|
-
emitWarning: (warning,
|
|
1669
|
+
emitWarning: (warning, type2) => process.emitWarning(warning, type2),
|
|
1564
1670
|
execPath: () => process.execPath,
|
|
1565
1671
|
exit: process.exit,
|
|
1566
1672
|
nextTick: process.nextTick,
|
|
@@ -1658,7 +1764,7 @@ function argsert(arg1, arg2, arg3) {
|
|
|
1658
1764
|
parsed.demanded.forEach((demanded) => {
|
|
1659
1765
|
const arg = args2.shift();
|
|
1660
1766
|
const observedType = guessType(arg);
|
|
1661
|
-
const matchingTypes = demanded.cmd.filter((
|
|
1767
|
+
const matchingTypes = demanded.cmd.filter((type2) => type2 === observedType || type2 === "*");
|
|
1662
1768
|
if (matchingTypes.length === 0)
|
|
1663
1769
|
argumentTypeError(observedType, demanded.cmd, position);
|
|
1664
1770
|
position += 1;
|
|
@@ -1668,7 +1774,7 @@ function argsert(arg1, arg2, arg3) {
|
|
|
1668
1774
|
return;
|
|
1669
1775
|
const arg = args2.shift();
|
|
1670
1776
|
const observedType = guessType(arg);
|
|
1671
|
-
const matchingTypes = optional.cmd.filter((
|
|
1777
|
+
const matchingTypes = optional.cmd.filter((type2) => type2 === observedType || type2 === "*");
|
|
1672
1778
|
if (matchingTypes.length === 0)
|
|
1673
1779
|
argumentTypeError(observedType, optional.cmd, position);
|
|
1674
1780
|
position += 1;
|
|
@@ -1790,8 +1896,8 @@ function isFunction(arg) {
|
|
|
1790
1896
|
function whichModule(exported) {
|
|
1791
1897
|
if (typeof __require === "undefined")
|
|
1792
1898
|
return null;
|
|
1793
|
-
for (let i = 0,
|
|
1794
|
-
mod = __require.cache[
|
|
1899
|
+
for (let i = 0, files2 = Object.keys(__require.cache), mod; i < files2.length; i++) {
|
|
1900
|
+
mod = __require.cache[files2[i]];
|
|
1795
1901
|
if (mod.exports === exported)
|
|
1796
1902
|
return mod;
|
|
1797
1903
|
}
|
|
@@ -1831,7 +1937,7 @@ var CommandInstance = class {
|
|
|
1831
1937
|
};
|
|
1832
1938
|
this.shim.requireDirectory({ require: req, filename: callerFile }, dir, opts);
|
|
1833
1939
|
}
|
|
1834
|
-
addHandler(cmd,
|
|
1940
|
+
addHandler(cmd, description2, builder, handler, commandMiddleware, deprecated) {
|
|
1835
1941
|
let aliases = [];
|
|
1836
1942
|
const middlewares = commandMiddlewareFactory(commandMiddleware);
|
|
1837
1943
|
handler = handler || (() => {
|
|
@@ -1851,7 +1957,7 @@ var CommandInstance = class {
|
|
|
1851
1957
|
this.addHandler(command2, this.extractDesc(cmd), cmd.builder, cmd.handler, cmd.middlewares, cmd.deprecated);
|
|
1852
1958
|
return;
|
|
1853
1959
|
} else if (isCommandBuilderDefinition(builder)) {
|
|
1854
|
-
this.addHandler([cmd].concat(aliases),
|
|
1960
|
+
this.addHandler([cmd].concat(aliases), description2, builder.builder, builder.handler, builder.middlewares, builder.deprecated);
|
|
1855
1961
|
return;
|
|
1856
1962
|
}
|
|
1857
1963
|
if (typeof cmd === "string") {
|
|
@@ -1875,12 +1981,12 @@ var CommandInstance = class {
|
|
|
1875
1981
|
aliases.forEach((alias) => {
|
|
1876
1982
|
this.aliasMap[alias] = parsedCommand.cmd;
|
|
1877
1983
|
});
|
|
1878
|
-
if (
|
|
1879
|
-
this.usage.command(cmd,
|
|
1984
|
+
if (description2 !== false) {
|
|
1985
|
+
this.usage.command(cmd, description2, isDefault, aliases, deprecated);
|
|
1880
1986
|
}
|
|
1881
1987
|
this.handlers[parsedCommand.cmd] = {
|
|
1882
1988
|
original: cmd,
|
|
1883
|
-
description,
|
|
1989
|
+
description: description2,
|
|
1884
1990
|
handler,
|
|
1885
1991
|
builder: builder || {},
|
|
1886
1992
|
middlewares,
|
|
@@ -2139,8 +2245,8 @@ var CommandInstance = class {
|
|
|
2139
2245
|
commandFromFilename(filename) {
|
|
2140
2246
|
return this.shim.path.basename(filename, this.shim.path.extname(filename));
|
|
2141
2247
|
}
|
|
2142
|
-
extractDesc({ describe, description, desc }) {
|
|
2143
|
-
for (const test of [describe,
|
|
2248
|
+
extractDesc({ describe, description: description2, desc }) {
|
|
2249
|
+
for (const test of [describe, description2, desc]) {
|
|
2144
2250
|
if (typeof test === "string" || test === false)
|
|
2145
2251
|
return test;
|
|
2146
2252
|
assertNotStrictEqual(test, true, this.shim);
|
|
@@ -2281,14 +2387,14 @@ function usage(yargs, shim3) {
|
|
|
2281
2387
|
};
|
|
2282
2388
|
let usages = [];
|
|
2283
2389
|
let usageDisabled = false;
|
|
2284
|
-
self.usage = (msg,
|
|
2390
|
+
self.usage = (msg, description2) => {
|
|
2285
2391
|
if (msg === null) {
|
|
2286
2392
|
usageDisabled = true;
|
|
2287
2393
|
usages = [];
|
|
2288
2394
|
return self;
|
|
2289
2395
|
}
|
|
2290
2396
|
usageDisabled = false;
|
|
2291
|
-
usages.push([msg,
|
|
2397
|
+
usages.push([msg, description2 || ""]);
|
|
2292
2398
|
return self;
|
|
2293
2399
|
};
|
|
2294
2400
|
self.getUsage = () => {
|
|
@@ -2301,18 +2407,18 @@ function usage(yargs, shim3) {
|
|
|
2301
2407
|
return __("Positionals:");
|
|
2302
2408
|
};
|
|
2303
2409
|
let examples = [];
|
|
2304
|
-
self.example = (cmd,
|
|
2305
|
-
examples.push([cmd,
|
|
2410
|
+
self.example = (cmd, description2) => {
|
|
2411
|
+
examples.push([cmd, description2 || ""]);
|
|
2306
2412
|
};
|
|
2307
2413
|
let commands = [];
|
|
2308
|
-
self.command = function command2(cmd,
|
|
2414
|
+
self.command = function command2(cmd, description2, isDefault, aliases, deprecated = false) {
|
|
2309
2415
|
if (isDefault) {
|
|
2310
2416
|
commands = commands.map((cmdArray) => {
|
|
2311
2417
|
cmdArray[2] = false;
|
|
2312
2418
|
return cmdArray;
|
|
2313
2419
|
});
|
|
2314
2420
|
}
|
|
2315
|
-
commands.push([cmd,
|
|
2421
|
+
commands.push([cmd, description2 || "", isDefault, aliases, deprecated]);
|
|
2316
2422
|
};
|
|
2317
2423
|
self.getCommands = () => commands;
|
|
2318
2424
|
let descriptions = {};
|
|
@@ -2485,25 +2591,25 @@ function usage(yargs, shim3) {
|
|
|
2485
2591
|
normalizedKeys.forEach((key) => {
|
|
2486
2592
|
const kswitch = switches[key];
|
|
2487
2593
|
let desc = descriptions[key] || "";
|
|
2488
|
-
let
|
|
2594
|
+
let type2 = null;
|
|
2489
2595
|
if (desc.includes(deferY18nLookupPrefix))
|
|
2490
2596
|
desc = __(desc.substring(deferY18nLookupPrefix.length));
|
|
2491
2597
|
if (options.boolean.includes(key))
|
|
2492
|
-
|
|
2598
|
+
type2 = `[${__("boolean")}]`;
|
|
2493
2599
|
if (options.count.includes(key))
|
|
2494
|
-
|
|
2600
|
+
type2 = `[${__("count")}]`;
|
|
2495
2601
|
if (options.string.includes(key))
|
|
2496
|
-
|
|
2602
|
+
type2 = `[${__("string")}]`;
|
|
2497
2603
|
if (options.normalize.includes(key))
|
|
2498
|
-
|
|
2604
|
+
type2 = `[${__("string")}]`;
|
|
2499
2605
|
if (options.array.includes(key))
|
|
2500
|
-
|
|
2606
|
+
type2 = `[${__("array")}]`;
|
|
2501
2607
|
if (options.number.includes(key))
|
|
2502
|
-
|
|
2608
|
+
type2 = `[${__("number")}]`;
|
|
2503
2609
|
const deprecatedExtra = (deprecated) => typeof deprecated === "string" ? `[${__("deprecated: %s", deprecated)}]` : `[${__("deprecated")}]`;
|
|
2504
2610
|
const extra = [
|
|
2505
2611
|
key in deprecatedOptions ? deprecatedExtra(deprecatedOptions[key]) : null,
|
|
2506
|
-
|
|
2612
|
+
type2,
|
|
2507
2613
|
key in demandedOptions ? `[${__("required")}]` : null,
|
|
2508
2614
|
options.choices && options.choices[key] ? `[${__("choices:")} ${self.stringifiedValues(options.choices[key])}]` : null,
|
|
2509
2615
|
defaultString(options.default[key], options.defaultDescription[key])
|
|
@@ -2622,8 +2728,8 @@ function usage(yargs, shim3) {
|
|
|
2622
2728
|
emit(self.help());
|
|
2623
2729
|
};
|
|
2624
2730
|
self.functionDescription = (fn) => {
|
|
2625
|
-
const
|
|
2626
|
-
return ["(",
|
|
2731
|
+
const description2 = fn.name ? shim3.Parser.decamelize(fn.name, "-") : __("generated-value");
|
|
2732
|
+
return ["(", description2, ")"].join("");
|
|
2627
2733
|
};
|
|
2628
2734
|
self.stringifiedValues = function stringifiedValues(values, separator) {
|
|
2629
2735
|
let string = "";
|
|
@@ -2666,16 +2772,16 @@ function usage(yargs, shim3) {
|
|
|
2666
2772
|
return maxWidth2;
|
|
2667
2773
|
}
|
|
2668
2774
|
}
|
|
2669
|
-
let
|
|
2775
|
+
let version2 = null;
|
|
2670
2776
|
self.version = (ver) => {
|
|
2671
|
-
|
|
2777
|
+
version2 = ver;
|
|
2672
2778
|
};
|
|
2673
2779
|
self.showVersion = (level) => {
|
|
2674
2780
|
const logger2 = yargs.getInternalMethods().getLoggerInstance();
|
|
2675
2781
|
if (!level)
|
|
2676
2782
|
level = "error";
|
|
2677
2783
|
const emit = typeof level === "function" ? level : logger2[level];
|
|
2678
|
-
emit(
|
|
2784
|
+
emit(version2);
|
|
2679
2785
|
};
|
|
2680
2786
|
self.reset = function reset(localLookup) {
|
|
2681
2787
|
failMessage = null;
|
|
@@ -2979,10 +3085,10 @@ var Completion = class {
|
|
|
2979
3085
|
}
|
|
2980
3086
|
generateCompletionScript($0, cmd) {
|
|
2981
3087
|
let script = this.zshShell ? completionZshTemplate : completionShTemplate;
|
|
2982
|
-
const
|
|
3088
|
+
const name2 = this.shim.path.basename($0);
|
|
2983
3089
|
if ($0.match(/\.js$/))
|
|
2984
3090
|
$0 = `./${$0}`;
|
|
2985
|
-
script = script.replace(/{{app_name}}/g,
|
|
3091
|
+
script = script.replace(/{{app_name}}/g, name2);
|
|
2986
3092
|
script = script.replace(/{{completion_command}}/g, cmd);
|
|
2987
3093
|
return script.replace(/{{app_path}}/g, $0);
|
|
2988
3094
|
}
|
|
@@ -3663,13 +3769,13 @@ var YargsInstance = class {
|
|
|
3663
3769
|
__classPrivateFieldGet(this, _YargsInstance_completion, "f").registerFunction(fn);
|
|
3664
3770
|
return this;
|
|
3665
3771
|
}
|
|
3666
|
-
command(cmd,
|
|
3667
|
-
argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [cmd,
|
|
3668
|
-
__classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd,
|
|
3772
|
+
command(cmd, description2, builder, handler, middlewares, deprecated) {
|
|
3773
|
+
argsert("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]", [cmd, description2, builder, handler, middlewares, deprecated], arguments.length);
|
|
3774
|
+
__classPrivateFieldGet(this, _YargsInstance_command, "f").addHandler(cmd, description2, builder, handler, middlewares, deprecated);
|
|
3669
3775
|
return this;
|
|
3670
3776
|
}
|
|
3671
|
-
commands(cmd,
|
|
3672
|
-
return this.command(cmd,
|
|
3777
|
+
commands(cmd, description2, builder, handler, middlewares, deprecated) {
|
|
3778
|
+
return this.command(cmd, description2, builder, handler, middlewares, deprecated);
|
|
3673
3779
|
}
|
|
3674
3780
|
commandDir(dir, opts) {
|
|
3675
3781
|
argsert("<string> [object]", [dir, opts], arguments.length);
|
|
@@ -3754,10 +3860,10 @@ var YargsInstance = class {
|
|
|
3754
3860
|
__classPrivateFieldGet(this, _YargsInstance_options, "f").deprecatedOptions[option] = message;
|
|
3755
3861
|
return this;
|
|
3756
3862
|
}
|
|
3757
|
-
describe(keys,
|
|
3758
|
-
argsert("<object|string|array> [string]", [keys,
|
|
3863
|
+
describe(keys, description2) {
|
|
3864
|
+
argsert("<object|string|array> [string]", [keys, description2], arguments.length);
|
|
3759
3865
|
this[kSetKey](keys, true);
|
|
3760
|
-
__classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys,
|
|
3866
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").describe(keys, description2);
|
|
3761
3867
|
return this;
|
|
3762
3868
|
}
|
|
3763
3869
|
detectLocale(detect) {
|
|
@@ -3781,12 +3887,12 @@ var YargsInstance = class {
|
|
|
3781
3887
|
epilog(msg) {
|
|
3782
3888
|
return this.epilogue(msg);
|
|
3783
3889
|
}
|
|
3784
|
-
example(cmd,
|
|
3785
|
-
argsert("<string|array> [string]", [cmd,
|
|
3890
|
+
example(cmd, description2) {
|
|
3891
|
+
argsert("<string|array> [string]", [cmd, description2], arguments.length);
|
|
3786
3892
|
if (Array.isArray(cmd)) {
|
|
3787
3893
|
cmd.forEach((exampleParams) => this.example(...exampleParams));
|
|
3788
3894
|
} else {
|
|
3789
|
-
__classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd,
|
|
3895
|
+
__classPrivateFieldGet(this, _YargsInstance_usage, "f").example(cmd, description2);
|
|
3790
3896
|
}
|
|
3791
3897
|
return this;
|
|
3792
3898
|
}
|
|
@@ -4271,12 +4377,12 @@ var YargsInstance = class {
|
|
|
4271
4377
|
__classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.updateLocale(obj);
|
|
4272
4378
|
return this;
|
|
4273
4379
|
}
|
|
4274
|
-
usage(msg,
|
|
4275
|
-
argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [msg,
|
|
4276
|
-
if (
|
|
4380
|
+
usage(msg, description2, builder, handler) {
|
|
4381
|
+
argsert("<string|null|undefined> [string|boolean] [function|object] [function]", [msg, description2, builder, handler], arguments.length);
|
|
4382
|
+
if (description2 !== void 0) {
|
|
4277
4383
|
assertNotStrictEqual(msg, null, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
|
|
4278
4384
|
if ((msg || "").match(/^\$0( |$)/)) {
|
|
4279
|
-
return this.command(msg,
|
|
4385
|
+
return this.command(msg, description2, builder, handler);
|
|
4280
4386
|
} else {
|
|
4281
4387
|
throw new YError(".usage() description must start with $0 if being used as alias for .command()");
|
|
4282
4388
|
}
|
|
@@ -4367,9 +4473,9 @@ var YargsInstance = class {
|
|
|
4367
4473
|
});
|
|
4368
4474
|
delete __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions()[optionKey];
|
|
4369
4475
|
}
|
|
4370
|
-
[kEmitWarning](warning,
|
|
4476
|
+
[kEmitWarning](warning, type2, deduplicationId) {
|
|
4371
4477
|
if (!__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId]) {
|
|
4372
|
-
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning,
|
|
4478
|
+
__classPrivateFieldGet(this, _YargsInstance_shim, "f").process.emitWarning(warning, type2);
|
|
4373
4479
|
__classPrivateFieldGet(this, _YargsInstance_emittedWarnings, "f")[deduplicationId] = true;
|
|
4374
4480
|
}
|
|
4375
4481
|
}
|
|
@@ -4461,24 +4567,24 @@ var YargsInstance = class {
|
|
|
4461
4567
|
__classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath] = obj || {};
|
|
4462
4568
|
return __classPrivateFieldGet(this, _YargsInstance_pkgs, "f")[npath];
|
|
4463
4569
|
}
|
|
4464
|
-
[kPopulateParserHintArray](
|
|
4570
|
+
[kPopulateParserHintArray](type2, keys) {
|
|
4465
4571
|
keys = [].concat(keys);
|
|
4466
4572
|
keys.forEach((key) => {
|
|
4467
4573
|
key = this[kSanitizeKey](key);
|
|
4468
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f")[
|
|
4574
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type2].push(key);
|
|
4469
4575
|
});
|
|
4470
4576
|
}
|
|
4471
|
-
[kPopulateParserHintSingleValueDictionary](builder,
|
|
4472
|
-
this[kPopulateParserHintDictionary](builder,
|
|
4473
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f")[
|
|
4577
|
+
[kPopulateParserHintSingleValueDictionary](builder, type2, key, value) {
|
|
4578
|
+
this[kPopulateParserHintDictionary](builder, type2, key, value, (type3, key2, value2) => {
|
|
4579
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] = value2;
|
|
4474
4580
|
});
|
|
4475
4581
|
}
|
|
4476
|
-
[kPopulateParserHintArrayDictionary](builder,
|
|
4477
|
-
this[kPopulateParserHintDictionary](builder,
|
|
4478
|
-
__classPrivateFieldGet(this, _YargsInstance_options, "f")[
|
|
4582
|
+
[kPopulateParserHintArrayDictionary](builder, type2, key, value) {
|
|
4583
|
+
this[kPopulateParserHintDictionary](builder, type2, key, value, (type3, key2, value2) => {
|
|
4584
|
+
__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] = (__classPrivateFieldGet(this, _YargsInstance_options, "f")[type3][key2] || []).concat(value2);
|
|
4479
4585
|
});
|
|
4480
4586
|
}
|
|
4481
|
-
[kPopulateParserHintDictionary](builder,
|
|
4587
|
+
[kPopulateParserHintDictionary](builder, type2, key, value, singleKeyHandler) {
|
|
4482
4588
|
if (Array.isArray(key)) {
|
|
4483
4589
|
key.forEach((k) => {
|
|
4484
4590
|
builder(k, value);
|
|
@@ -4488,7 +4594,7 @@ var YargsInstance = class {
|
|
|
4488
4594
|
builder(k, key[k]);
|
|
4489
4595
|
}
|
|
4490
4596
|
} else {
|
|
4491
|
-
singleKeyHandler(
|
|
4597
|
+
singleKeyHandler(type2, this[kSanitizeKey](key), value);
|
|
4492
4598
|
}
|
|
4493
4599
|
}
|
|
4494
4600
|
[kSanitizeKey](key) {
|
|
@@ -4899,24 +5005,26 @@ async function createMock() {
|
|
|
4899
5005
|
const activeWorkflows = {};
|
|
4900
5006
|
const bus = new EventEmitter();
|
|
4901
5007
|
const listeners = {};
|
|
4902
|
-
const dispatch = (
|
|
5008
|
+
const dispatch = (type2, args2) => {
|
|
4903
5009
|
if (args2.workflowId) {
|
|
4904
|
-
listeners[args2.workflowId]?.[
|
|
5010
|
+
listeners[args2.workflowId]?.[type2]?.(args2);
|
|
4905
5011
|
}
|
|
4906
|
-
bus.emit(
|
|
5012
|
+
bus.emit(type2, args2);
|
|
4907
5013
|
};
|
|
4908
5014
|
const on = (event, fn) => bus.on(event, fn);
|
|
4909
5015
|
const once = (event, fn) => bus.once(event, fn);
|
|
4910
5016
|
const listen = (planId, events) => {
|
|
4911
5017
|
listeners[planId] = events;
|
|
4912
5018
|
};
|
|
4913
|
-
const execute2 = async (xplan, options = {
|
|
5019
|
+
const execute2 = async (xplan, input, options = {
|
|
4914
5020
|
resolvers: resolvers_default
|
|
4915
5021
|
}) => {
|
|
4916
|
-
const { id
|
|
5022
|
+
const { id } = xplan;
|
|
5023
|
+
const { steps } = xplan.workflow;
|
|
4917
5024
|
activeWorkflows[id] = true;
|
|
4918
5025
|
const threadId = crypto.randomUUID();
|
|
4919
|
-
for (const
|
|
5026
|
+
for (const step of steps) {
|
|
5027
|
+
const job = step;
|
|
4920
5028
|
if (typeof job.configuration === "string") {
|
|
4921
5029
|
job.configuration = await options.resolvers?.credential?.(
|
|
4922
5030
|
job.configuration
|
|
@@ -4934,6 +5042,7 @@ async function createMock() {
|
|
|
4934
5042
|
level: "info",
|
|
4935
5043
|
json: true,
|
|
4936
5044
|
message: JSON.stringify(args2),
|
|
5045
|
+
name: "JOB",
|
|
4937
5046
|
time: Date.now()
|
|
4938
5047
|
});
|
|
4939
5048
|
}
|
|
@@ -4944,8 +5053,8 @@ async function createMock() {
|
|
|
4944
5053
|
...options,
|
|
4945
5054
|
globals: helpers,
|
|
4946
5055
|
callbacks: {
|
|
4947
|
-
notify: (
|
|
4948
|
-
dispatch(
|
|
5056
|
+
notify: (name2, payload) => {
|
|
5057
|
+
dispatch(name2, {
|
|
4949
5058
|
workflowId: id,
|
|
4950
5059
|
threadId,
|
|
4951
5060
|
...payload
|
|
@@ -4956,7 +5065,7 @@ async function createMock() {
|
|
|
4956
5065
|
setTimeout(async () => {
|
|
4957
5066
|
dispatch("workflow-start", { workflowId: id, threadId });
|
|
4958
5067
|
try {
|
|
4959
|
-
await run(xplan,
|
|
5068
|
+
await run(xplan, input, opts);
|
|
4960
5069
|
dispatch("workflow-complete", { workflowId: id, threadId });
|
|
4961
5070
|
} catch (e) {
|
|
4962
5071
|
dispatch("workflow-error", {
|
|
@@ -4999,8 +5108,8 @@ import { createMockLogger as createMockLogger2 } from "@openfn/logger";
|
|
|
4999
5108
|
// src/events.ts
|
|
5000
5109
|
var CLAIM = "claim";
|
|
5001
5110
|
var GET_PLAN = "fetch:plan";
|
|
5002
|
-
var GET_CREDENTIAL = "fetch:credential";
|
|
5003
5111
|
var GET_DATACLIP = "fetch:dataclip";
|
|
5112
|
+
var GET_CREDENTIAL = "fetch:credential";
|
|
5004
5113
|
var RUN_START = "run:start";
|
|
5005
5114
|
var RUN_COMPLETE = "run:complete";
|
|
5006
5115
|
var RUN_LOG = "run:log";
|
|
@@ -5024,6 +5133,7 @@ var destroy = async (app, logger2) => {
|
|
|
5024
5133
|
await waitForRuns(app, logger2);
|
|
5025
5134
|
await app.engine.destroy();
|
|
5026
5135
|
app.socket?.disconnect();
|
|
5136
|
+
logger2.info("Server closed....");
|
|
5027
5137
|
resolve5();
|
|
5028
5138
|
})
|
|
5029
5139
|
]);
|
|
@@ -5048,6 +5158,7 @@ var waitForRuns = (app, logger2) => new Promise((resolve5) => {
|
|
|
5048
5158
|
log();
|
|
5049
5159
|
app.events.on(INTERNAL_RUN_COMPLETE, onRunComplete);
|
|
5050
5160
|
} else {
|
|
5161
|
+
logger2.debug("No active rns detected");
|
|
5051
5162
|
resolve5();
|
|
5052
5163
|
}
|
|
5053
5164
|
});
|
|
@@ -5095,10 +5206,22 @@ var tryWithBackoff = (fn, opts = {}) => {
|
|
|
5095
5206
|
var try_with_backoff_default = tryWithBackoff;
|
|
5096
5207
|
|
|
5097
5208
|
// src/api/claim.ts
|
|
5209
|
+
import crypto2 from "node:crypto";
|
|
5210
|
+
import * as jose from "jose";
|
|
5098
5211
|
import { createMockLogger } from "@openfn/logger";
|
|
5099
5212
|
var mockLogger = createMockLogger();
|
|
5100
|
-
var
|
|
5213
|
+
var verifyToken = async (token, publicKey) => {
|
|
5214
|
+
const key = crypto2.createPublicKey(publicKey);
|
|
5215
|
+
const { payload } = await jose.jwtVerify(token, key, {
|
|
5216
|
+
issuer: "Lightning"
|
|
5217
|
+
});
|
|
5218
|
+
if (payload) {
|
|
5219
|
+
return true;
|
|
5220
|
+
}
|
|
5221
|
+
};
|
|
5222
|
+
var claim = (app, logger2 = mockLogger, options = {}) => {
|
|
5101
5223
|
return new Promise((resolve5, reject) => {
|
|
5224
|
+
const { maxWorkers = 5 } = options;
|
|
5102
5225
|
const activeWorkers = Object.keys(app.workflows).length;
|
|
5103
5226
|
if (activeWorkers >= maxWorkers) {
|
|
5104
5227
|
return reject(new Error("Server at capacity"));
|
|
@@ -5112,7 +5235,21 @@ var claim = (app, logger2 = mockLogger, maxWorkers = 5) => {
|
|
|
5112
5235
|
if (!runs?.length) {
|
|
5113
5236
|
return reject(new Error("No runs returned"));
|
|
5114
5237
|
}
|
|
5115
|
-
runs.forEach((run2) => {
|
|
5238
|
+
runs.forEach(async (run2) => {
|
|
5239
|
+
if (app.options?.runPublicKey) {
|
|
5240
|
+
try {
|
|
5241
|
+
await verifyToken(run2.token, app.options.runPublicKey);
|
|
5242
|
+
logger2.debug("verified run token for", run2.id);
|
|
5243
|
+
} catch (e) {
|
|
5244
|
+
logger2.error("Error validating run token");
|
|
5245
|
+
logger2.error(e);
|
|
5246
|
+
reject();
|
|
5247
|
+
app.destroy();
|
|
5248
|
+
return;
|
|
5249
|
+
}
|
|
5250
|
+
} else {
|
|
5251
|
+
logger2.debug("skipping run token validation for", run2.id);
|
|
5252
|
+
}
|
|
5116
5253
|
logger2.debug("starting run", run2.id);
|
|
5117
5254
|
app.execute(run2);
|
|
5118
5255
|
resolve5();
|
|
@@ -5133,10 +5270,15 @@ var startWorkloop = (app, logger2, minBackoff2, maxBackoff2, maxWorkers) => {
|
|
|
5133
5270
|
let cancelled = false;
|
|
5134
5271
|
const workLoop = () => {
|
|
5135
5272
|
if (!cancelled) {
|
|
5136
|
-
promise = try_with_backoff_default(
|
|
5137
|
-
|
|
5138
|
-
|
|
5139
|
-
|
|
5273
|
+
promise = try_with_backoff_default(
|
|
5274
|
+
() => claim_default(app, logger2, {
|
|
5275
|
+
maxWorkers
|
|
5276
|
+
}),
|
|
5277
|
+
{
|
|
5278
|
+
min: minBackoff2,
|
|
5279
|
+
max: maxBackoff2
|
|
5280
|
+
}
|
|
5281
|
+
);
|
|
5140
5282
|
promise.then(() => {
|
|
5141
5283
|
if (!cancelled) {
|
|
5142
5284
|
setTimeout(workLoop, minBackoff2);
|
|
@@ -5154,8 +5296,8 @@ var startWorkloop = (app, logger2, minBackoff2, maxBackoff2, maxWorkers) => {
|
|
|
5154
5296
|
};
|
|
5155
5297
|
var workloop_default = startWorkloop;
|
|
5156
5298
|
|
|
5157
|
-
// src/util/convert-
|
|
5158
|
-
import
|
|
5299
|
+
// src/util/convert-lightning-plan.ts
|
|
5300
|
+
import crypto3 from "node:crypto";
|
|
5159
5301
|
var conditions = {
|
|
5160
5302
|
on_job_success: (upstreamId) => `Boolean(!state?.errors?.["${upstreamId}"] ?? true)`,
|
|
5161
5303
|
on_job_failure: (upstreamId) => `Boolean(state?.errors && state.errors["${upstreamId}"])`,
|
|
@@ -5175,19 +5317,30 @@ var mapTriggerEdgeCondition = (edge) => {
|
|
|
5175
5317
|
return true;
|
|
5176
5318
|
return condition;
|
|
5177
5319
|
};
|
|
5178
|
-
var
|
|
5179
|
-
|
|
5180
|
-
};
|
|
5181
|
-
|
|
5182
|
-
|
|
5320
|
+
var convert_lightning_plan_default = (run2) => {
|
|
5321
|
+
const runtimeOpts = {};
|
|
5322
|
+
const engineOpts = {};
|
|
5323
|
+
if (run2.options) {
|
|
5324
|
+
if (run2.options.runTimeoutMs) {
|
|
5325
|
+
engineOpts.runTimeoutMs = run2.options.runTimeoutMs;
|
|
5326
|
+
}
|
|
5327
|
+
if (run2.options.sanitize) {
|
|
5328
|
+
engineOpts.sanitize = run2.options.sanitize;
|
|
5329
|
+
}
|
|
5330
|
+
if (run2.options.hasOwnProperty("output_dataclips")) {
|
|
5331
|
+
engineOpts.outputDataclips = run2.options.output_dataclips;
|
|
5332
|
+
}
|
|
5333
|
+
}
|
|
5183
5334
|
const plan = {
|
|
5184
|
-
id: run2.id
|
|
5335
|
+
id: run2.id,
|
|
5336
|
+
options: runtimeOpts
|
|
5185
5337
|
};
|
|
5338
|
+
let initialState;
|
|
5186
5339
|
if (run2.dataclip_id) {
|
|
5187
|
-
|
|
5340
|
+
initialState = run2.dataclip_id;
|
|
5188
5341
|
}
|
|
5189
5342
|
if (run2.starting_node_id) {
|
|
5190
|
-
|
|
5343
|
+
runtimeOpts.start = run2.starting_node_id;
|
|
5191
5344
|
}
|
|
5192
5345
|
const nodes = {};
|
|
5193
5346
|
const edges = run2.edges ?? [];
|
|
@@ -5199,27 +5352,33 @@ var convert_run_default = (run2) => {
|
|
|
5199
5352
|
};
|
|
5200
5353
|
const connectedEdges = edges.filter((e) => e.source_trigger_id === id);
|
|
5201
5354
|
if (connectedEdges.length) {
|
|
5202
|
-
nodes[id].next = connectedEdges.reduce(
|
|
5203
|
-
|
|
5204
|
-
|
|
5205
|
-
|
|
5206
|
-
|
|
5207
|
-
|
|
5355
|
+
nodes[id].next = connectedEdges.reduce(
|
|
5356
|
+
(obj, edge) => {
|
|
5357
|
+
if (edge.enabled !== false) {
|
|
5358
|
+
obj[edge.target_job_id] = mapTriggerEdgeCondition(edge);
|
|
5359
|
+
}
|
|
5360
|
+
return obj;
|
|
5361
|
+
},
|
|
5362
|
+
{}
|
|
5363
|
+
);
|
|
5208
5364
|
} else {
|
|
5209
5365
|
}
|
|
5210
5366
|
});
|
|
5211
5367
|
}
|
|
5212
5368
|
if (run2.jobs?.length) {
|
|
5213
|
-
run2.jobs.forEach((
|
|
5214
|
-
const id =
|
|
5215
|
-
|
|
5369
|
+
run2.jobs.forEach((step) => {
|
|
5370
|
+
const id = step.id || crypto3.randomUUID();
|
|
5371
|
+
const job = {
|
|
5216
5372
|
id,
|
|
5217
|
-
configuration:
|
|
5218
|
-
expression:
|
|
5219
|
-
adaptor:
|
|
5373
|
+
configuration: step.credential || step.credential_id,
|
|
5374
|
+
expression: step.body,
|
|
5375
|
+
adaptor: step.adaptor
|
|
5220
5376
|
};
|
|
5221
|
-
if (
|
|
5222
|
-
|
|
5377
|
+
if (step.name) {
|
|
5378
|
+
job.name = step.name;
|
|
5379
|
+
}
|
|
5380
|
+
if (step.state) {
|
|
5381
|
+
job.state = step.state;
|
|
5223
5382
|
}
|
|
5224
5383
|
const next = edges.filter((e) => e.source_job_id === id).reduce((obj, edge) => {
|
|
5225
5384
|
const newEdge = {};
|
|
@@ -5234,21 +5393,32 @@ var convert_run_default = (run2) => {
|
|
|
5234
5393
|
return obj;
|
|
5235
5394
|
}, {});
|
|
5236
5395
|
if (Object.keys(next).length) {
|
|
5237
|
-
|
|
5396
|
+
job.next = next;
|
|
5238
5397
|
}
|
|
5398
|
+
nodes[id] = job;
|
|
5239
5399
|
});
|
|
5240
5400
|
}
|
|
5241
|
-
plan.
|
|
5401
|
+
plan.workflow = {
|
|
5402
|
+
steps: Object.values(nodes)
|
|
5403
|
+
};
|
|
5404
|
+
if (run2.name) {
|
|
5405
|
+
plan.workflow.name = run2.name;
|
|
5406
|
+
}
|
|
5242
5407
|
return {
|
|
5243
5408
|
plan,
|
|
5244
|
-
options:
|
|
5409
|
+
options: engineOpts,
|
|
5410
|
+
input: initialState || {}
|
|
5245
5411
|
};
|
|
5246
5412
|
};
|
|
5247
5413
|
|
|
5248
5414
|
// src/util/get-with-reply.ts
|
|
5249
|
-
var get_with_reply_default = (channel, event, payload) => new Promise((resolve5) => {
|
|
5415
|
+
var get_with_reply_default = (channel, event, payload) => new Promise((resolve5, reject) => {
|
|
5250
5416
|
channel.push(event, payload).receive("ok", (evt) => {
|
|
5251
5417
|
resolve5(evt);
|
|
5418
|
+
}).receive("error", (e) => {
|
|
5419
|
+
reject(e);
|
|
5420
|
+
}).receive("timeout", (e) => {
|
|
5421
|
+
reject(e);
|
|
5252
5422
|
});
|
|
5253
5423
|
});
|
|
5254
5424
|
|
|
@@ -5262,19 +5432,20 @@ var stringify_default = (obj) => stringify(obj, (_key, value) => {
|
|
|
5262
5432
|
});
|
|
5263
5433
|
|
|
5264
5434
|
// src/util/create-run-state.ts
|
|
5265
|
-
var create_run_state_default = (plan,
|
|
5435
|
+
var create_run_state_default = (plan, input) => {
|
|
5266
5436
|
const state = {
|
|
5267
|
-
plan,
|
|
5268
5437
|
lastDataclipId: "",
|
|
5269
5438
|
dataclips: {},
|
|
5270
5439
|
inputDataclips: {},
|
|
5271
5440
|
reasons: {},
|
|
5272
|
-
|
|
5441
|
+
plan,
|
|
5442
|
+
input
|
|
5273
5443
|
};
|
|
5274
|
-
if (typeof
|
|
5275
|
-
|
|
5276
|
-
|
|
5277
|
-
|
|
5444
|
+
if (typeof input === "string") {
|
|
5445
|
+
const jobs = plan.workflow.steps;
|
|
5446
|
+
let startNode = jobs[0];
|
|
5447
|
+
if (plan.options.start) {
|
|
5448
|
+
startNode = jobs.find(({ id }) => id === plan.options.start);
|
|
5278
5449
|
}
|
|
5279
5450
|
const initialRuns = [];
|
|
5280
5451
|
if (!startNode.expression) {
|
|
@@ -5283,7 +5454,7 @@ var create_run_state_default = (plan, options = {}) => {
|
|
|
5283
5454
|
initialRuns.push(startNode.id);
|
|
5284
5455
|
}
|
|
5285
5456
|
initialRuns.forEach((id) => {
|
|
5286
|
-
state.inputDataclips[id] =
|
|
5457
|
+
state.inputDataclips[id] = input;
|
|
5287
5458
|
});
|
|
5288
5459
|
} else {
|
|
5289
5460
|
}
|
|
@@ -5317,8 +5488,59 @@ var createThrottler = () => {
|
|
|
5317
5488
|
};
|
|
5318
5489
|
var throttle_default = createThrottler;
|
|
5319
5490
|
|
|
5491
|
+
// src/events/run-start.ts
|
|
5492
|
+
import { timestamp } from "@openfn/logger";
|
|
5493
|
+
|
|
5494
|
+
// src/util/versions.ts
|
|
5495
|
+
import { mainSymbols } from "figures";
|
|
5496
|
+
var { triangleRightSmall: t } = mainSymbols;
|
|
5497
|
+
var versions_default = (versions) => {
|
|
5498
|
+
let longest = "worker".length;
|
|
5499
|
+
for (const v in versions) {
|
|
5500
|
+
longest = Math.max(v.length, longest);
|
|
5501
|
+
}
|
|
5502
|
+
const { node, worker, compiler, runtime, engine, ...adaptors } = versions;
|
|
5503
|
+
const prefix = (str2) => ` ${t} ${str2.padEnd(longest + 4, " ")}`;
|
|
5504
|
+
let str = `Versions:
|
|
5505
|
+
${prefix("node.js")}${versions.node || "unknown"}
|
|
5506
|
+
${prefix("worker")}${versions.worker || "unknown"}`;
|
|
5507
|
+
if (Object.keys(adaptors).length) {
|
|
5508
|
+
let allAdaptors = Object.keys(adaptors);
|
|
5509
|
+
str += "\n" + allAdaptors.sort().map(
|
|
5510
|
+
(adaptorName) => `${prefix(adaptorName)}${adaptors[adaptorName].sort().join(", ")}`
|
|
5511
|
+
).join("\n");
|
|
5512
|
+
}
|
|
5513
|
+
return str;
|
|
5514
|
+
};
|
|
5515
|
+
|
|
5516
|
+
// src/events/run-start.ts
|
|
5517
|
+
init_package();
|
|
5518
|
+
async function onRunStart(context, event) {
|
|
5519
|
+
const { channel, state } = context;
|
|
5520
|
+
const time = (timestamp() - BigInt(1e7)).toString();
|
|
5521
|
+
const versionLogContext = {
|
|
5522
|
+
...context,
|
|
5523
|
+
state: {
|
|
5524
|
+
...state,
|
|
5525
|
+
activeStep: state.activeStep
|
|
5526
|
+
}
|
|
5527
|
+
};
|
|
5528
|
+
const versions = {
|
|
5529
|
+
worker: package_default.version,
|
|
5530
|
+
...event.versions
|
|
5531
|
+
};
|
|
5532
|
+
await sendEvent(channel, RUN_START, { versions });
|
|
5533
|
+
const versionMessage = versions_default(versions);
|
|
5534
|
+
await onJobLog(versionLogContext, {
|
|
5535
|
+
time,
|
|
5536
|
+
message: [versionMessage],
|
|
5537
|
+
level: "info",
|
|
5538
|
+
name: "VER"
|
|
5539
|
+
});
|
|
5540
|
+
}
|
|
5541
|
+
|
|
5320
5542
|
// src/events/step-complete.ts
|
|
5321
|
-
import
|
|
5543
|
+
import crypto4 from "node:crypto";
|
|
5322
5544
|
|
|
5323
5545
|
// src/api/reasons.ts
|
|
5324
5546
|
var calculateJobExitReason = (jobId, state = { data: {} }, error) => {
|
|
@@ -5344,7 +5566,7 @@ var isLeafNode = (state, job) => {
|
|
|
5344
5566
|
};
|
|
5345
5567
|
var calculateRunExitReason = (state) => {
|
|
5346
5568
|
if (state.plan && state.reasons) {
|
|
5347
|
-
const leafJobReasons = state.plan.
|
|
5569
|
+
const leafJobReasons = state.plan.workflow.steps.filter((job) => isLeafNode(state, job)).map(({ id }) => state.reasons[id]);
|
|
5348
5570
|
const fail = leafJobReasons.find((r) => r && r.reason === "fail");
|
|
5349
5571
|
if (fail) {
|
|
5350
5572
|
return fail;
|
|
@@ -5354,8 +5576,8 @@ var calculateRunExitReason = (state) => {
|
|
|
5354
5576
|
};
|
|
5355
5577
|
|
|
5356
5578
|
// src/events/step-complete.ts
|
|
5357
|
-
function onStepComplete({ channel, state }, event, error) {
|
|
5358
|
-
const dataclipId =
|
|
5579
|
+
function onStepComplete({ channel, state, options }, event, error) {
|
|
5580
|
+
const dataclipId = crypto4.randomUUID();
|
|
5359
5581
|
const step_id = state.activeStep;
|
|
5360
5582
|
const job_id = state.activeJob;
|
|
5361
5583
|
if (!state.dataclips) {
|
|
@@ -5379,7 +5601,6 @@ function onStepComplete({ channel, state }, event, error) {
|
|
|
5379
5601
|
step_id,
|
|
5380
5602
|
job_id,
|
|
5381
5603
|
output_dataclip_id: dataclipId,
|
|
5382
|
-
output_dataclip: stringify_default(outputState),
|
|
5383
5604
|
reason,
|
|
5384
5605
|
error_message,
|
|
5385
5606
|
error_type,
|
|
@@ -5387,137 +5608,24 @@ function onStepComplete({ channel, state }, event, error) {
|
|
|
5387
5608
|
duration: event.duration,
|
|
5388
5609
|
thread_id: event.threadId
|
|
5389
5610
|
};
|
|
5611
|
+
if (!options || options.outputDataclips !== false) {
|
|
5612
|
+
evt.output_dataclip = stringify_default(outputState);
|
|
5613
|
+
}
|
|
5390
5614
|
return sendEvent(channel, STEP_COMPLETE, evt);
|
|
5391
5615
|
}
|
|
5392
5616
|
|
|
5393
5617
|
// src/events/step-start.ts
|
|
5394
|
-
import
|
|
5395
|
-
import { timestamp } from "@openfn/logger";
|
|
5396
|
-
|
|
5397
|
-
// package.json
|
|
5398
|
-
var package_default = {
|
|
5399
|
-
name: "@openfn/ws-worker",
|
|
5400
|
-
version: "0.8.1",
|
|
5401
|
-
description: "A Websocket Worker to connect Lightning to a Runtime Engine",
|
|
5402
|
-
main: "dist/index.js",
|
|
5403
|
-
type: "module",
|
|
5404
|
-
scripts: {
|
|
5405
|
-
test: "pnpm ava --serial",
|
|
5406
|
-
"test:types": "pnpm tsc --noEmit --project tsconfig.json",
|
|
5407
|
-
build: "tsup --config tsup.config.js",
|
|
5408
|
-
"build:watch": "pnpm build --watch",
|
|
5409
|
-
start: "ts-node-esm --transpile-only src/start.ts",
|
|
5410
|
-
"start:prod": "node dist/start.js",
|
|
5411
|
-
"start:watch": "nodemon -e ts,js --watch ../runtime-manager/dist --watch ./src --exec 'pnpm start'",
|
|
5412
|
-
pack: "pnpm pack --pack-destination ../../dist"
|
|
5413
|
-
},
|
|
5414
|
-
bin: {
|
|
5415
|
-
worker: "dist/start.js"
|
|
5416
|
-
},
|
|
5417
|
-
author: "Open Function Group <admin@openfn.org>",
|
|
5418
|
-
license: "ISC",
|
|
5419
|
-
dependencies: {
|
|
5420
|
-
"@koa/router": "^12.0.0",
|
|
5421
|
-
"@openfn/engine-multi": "workspace:*",
|
|
5422
|
-
"@openfn/logger": "workspace:*",
|
|
5423
|
-
"@openfn/runtime": "workspace:*",
|
|
5424
|
-
"@types/koa-logger": "^3.1.2",
|
|
5425
|
-
"@types/ws": "^8.5.6",
|
|
5426
|
-
"fast-safe-stringify": "^2.1.1",
|
|
5427
|
-
figures: "^5.0.0",
|
|
5428
|
-
"human-id": "^4.1.0",
|
|
5429
|
-
jose: "^4.14.6",
|
|
5430
|
-
koa: "^2.13.4",
|
|
5431
|
-
"koa-bodyparser": "^4.4.0",
|
|
5432
|
-
"koa-logger": "^3.2.1",
|
|
5433
|
-
phoenix: "^1.7.7",
|
|
5434
|
-
ws: "^8.14.1"
|
|
5435
|
-
},
|
|
5436
|
-
devDependencies: {
|
|
5437
|
-
"@openfn/lightning-mock": "workspace:*",
|
|
5438
|
-
"@types/koa": "^2.13.5",
|
|
5439
|
-
"@types/koa-bodyparser": "^4.3.10",
|
|
5440
|
-
"@types/koa__router": "^12.0.1",
|
|
5441
|
-
"@types/node": "^18.15.3",
|
|
5442
|
-
"@types/nodemon": "1.19.3",
|
|
5443
|
-
"@types/phoenix": "^1.6.2",
|
|
5444
|
-
"@types/yargs": "^17.0.12",
|
|
5445
|
-
ava: "5.1.0",
|
|
5446
|
-
nodemon: "3.0.1",
|
|
5447
|
-
"ts-node": "^10.9.1",
|
|
5448
|
-
tslib: "^2.4.0",
|
|
5449
|
-
tsup: "^6.2.3",
|
|
5450
|
-
typescript: "^4.6.4",
|
|
5451
|
-
yargs: "^17.6.2"
|
|
5452
|
-
},
|
|
5453
|
-
files: [
|
|
5454
|
-
"dist",
|
|
5455
|
-
"README.md",
|
|
5456
|
-
"CHANGELOG.md"
|
|
5457
|
-
]
|
|
5458
|
-
};
|
|
5459
|
-
|
|
5460
|
-
// src/util/versions.ts
|
|
5461
|
-
import { mainSymbols } from "figures";
|
|
5462
|
-
var { triangleRightSmall: t } = mainSymbols;
|
|
5463
|
-
var versions_default = (stepId, versions, adaptor) => {
|
|
5464
|
-
let longest = "compiler".length;
|
|
5465
|
-
for (const v in versions) {
|
|
5466
|
-
longest = Math.max(v.length, longest);
|
|
5467
|
-
}
|
|
5468
|
-
const { node, compiler, engine, worker, runtime, ...adaptors } = versions;
|
|
5469
|
-
const prefix = (str2) => ` ${t} ${str2.padEnd(longest + 4, " ")}`;
|
|
5470
|
-
let str = `Versions for step ${stepId}:
|
|
5471
|
-
${prefix("node.js")}${versions.node || "unknown"}
|
|
5472
|
-
${prefix("worker")}${versions.worker || "unknown"}
|
|
5473
|
-
${prefix("engine")}${versions.engine || "unknown"}`;
|
|
5474
|
-
if (Object.keys(adaptors).length) {
|
|
5475
|
-
let allAdaptors = Object.keys(adaptors);
|
|
5476
|
-
if (adaptor) {
|
|
5477
|
-
allAdaptors = allAdaptors.filter((name) => adaptor.startsWith(name));
|
|
5478
|
-
}
|
|
5479
|
-
str += "\n" + allAdaptors.sort().map((adaptorName) => `${prefix(adaptorName)}${adaptors[adaptorName]}`).join("\n");
|
|
5480
|
-
}
|
|
5481
|
-
return str;
|
|
5482
|
-
};
|
|
5483
|
-
|
|
5484
|
-
// src/events/step-start.ts
|
|
5618
|
+
import crypto5 from "node:crypto";
|
|
5485
5619
|
async function onStepStart(context, event) {
|
|
5486
|
-
const time = (timestamp() - BigInt(1e7)).toString();
|
|
5487
5620
|
const { channel, state } = context;
|
|
5488
|
-
state.activeStep =
|
|
5621
|
+
state.activeStep = crypto5.randomUUID();
|
|
5489
5622
|
state.activeJob = event.jobId;
|
|
5490
|
-
const job = state.plan.jobs.find(({ id }) => id === event.jobId);
|
|
5491
5623
|
const input_dataclip_id = state.inputDataclips[event.jobId];
|
|
5492
|
-
const versions = {
|
|
5493
|
-
worker: package_default.version,
|
|
5494
|
-
...event.versions
|
|
5495
|
-
};
|
|
5496
|
-
const versionLogContext = {
|
|
5497
|
-
...context,
|
|
5498
|
-
state: {
|
|
5499
|
-
...state,
|
|
5500
|
-
activeStep: state.activeStep
|
|
5501
|
-
}
|
|
5502
|
-
};
|
|
5503
5624
|
await sendEvent(channel, STEP_START, {
|
|
5504
5625
|
step_id: state.activeStep,
|
|
5505
5626
|
job_id: state.activeJob,
|
|
5506
|
-
input_dataclip_id
|
|
5507
|
-
versions
|
|
5508
|
-
});
|
|
5509
|
-
const versionMessage = versions_default(
|
|
5510
|
-
versionLogContext.state.activeStep,
|
|
5511
|
-
versions,
|
|
5512
|
-
job?.adaptor
|
|
5513
|
-
);
|
|
5514
|
-
await onJobLog(versionLogContext, {
|
|
5515
|
-
time,
|
|
5516
|
-
message: [versionMessage],
|
|
5517
|
-
level: "info",
|
|
5518
|
-
name: "VER"
|
|
5627
|
+
input_dataclip_id
|
|
5519
5628
|
});
|
|
5520
|
-
return;
|
|
5521
5629
|
}
|
|
5522
5630
|
|
|
5523
5631
|
// src/util/log-final-reason.ts
|
|
@@ -5565,7 +5673,7 @@ async function onRunError(context, event) {
|
|
|
5565
5673
|
});
|
|
5566
5674
|
onFinish({ reason });
|
|
5567
5675
|
} catch (e) {
|
|
5568
|
-
logger2.error("ERROR in
|
|
5676
|
+
logger2.error("ERROR in run-error handler:", e.message);
|
|
5569
5677
|
logger2.error(e);
|
|
5570
5678
|
onFinish({});
|
|
5571
5679
|
}
|
|
@@ -5580,11 +5688,18 @@ var eventMap = {
|
|
|
5580
5688
|
"workflow-log": RUN_LOG,
|
|
5581
5689
|
"workflow-complete": RUN_COMPLETE
|
|
5582
5690
|
};
|
|
5583
|
-
function execute(channel, engine, logger2, plan, options = {}, onFinish = (_result) => {
|
|
5691
|
+
function execute(channel, engine, logger2, plan, input, options = {}, onFinish = (_result) => {
|
|
5584
5692
|
}) {
|
|
5585
5693
|
logger2.info("executing ", plan.id);
|
|
5586
|
-
const state = create_run_state_default(plan,
|
|
5587
|
-
const context = {
|
|
5694
|
+
const state = create_run_state_default(plan, input);
|
|
5695
|
+
const context = {
|
|
5696
|
+
channel,
|
|
5697
|
+
state,
|
|
5698
|
+
logger: logger2,
|
|
5699
|
+
engine,
|
|
5700
|
+
options,
|
|
5701
|
+
onFinish
|
|
5702
|
+
};
|
|
5588
5703
|
const throttle = throttle_default();
|
|
5589
5704
|
const addEvent = (eventName, handler) => {
|
|
5590
5705
|
const wrappedFn = async (event) => {
|
|
@@ -5605,7 +5720,7 @@ function execute(channel, engine, logger2, plan, options = {}, onFinish = (_resu
|
|
|
5605
5720
|
};
|
|
5606
5721
|
const listeners = Object.assign(
|
|
5607
5722
|
{},
|
|
5608
|
-
addEvent("workflow-start", throttle(
|
|
5723
|
+
addEvent("workflow-start", throttle(onRunStart)),
|
|
5609
5724
|
addEvent("job-start", throttle(onStepStart)),
|
|
5610
5725
|
addEvent("job-complete", throttle(onStepComplete)),
|
|
5611
5726
|
addEvent("job-error", throttle(onJobError)),
|
|
@@ -5617,17 +5732,24 @@ function execute(channel, engine, logger2, plan, options = {}, onFinish = (_resu
|
|
|
5617
5732
|
const resolvers = {
|
|
5618
5733
|
credential: (id) => loadCredential(channel, id)
|
|
5619
5734
|
};
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5623
|
-
|
|
5624
|
-
|
|
5625
|
-
|
|
5626
|
-
|
|
5627
|
-
|
|
5628
|
-
|
|
5735
|
+
setTimeout(async () => {
|
|
5736
|
+
let loadedInput = input;
|
|
5737
|
+
if (typeof input === "string") {
|
|
5738
|
+
logger2.debug("loading dataclip", input);
|
|
5739
|
+
try {
|
|
5740
|
+
loadedInput = await loadDataclip(channel, input);
|
|
5741
|
+
logger2.success("dataclip loaded");
|
|
5742
|
+
} catch (e) {
|
|
5743
|
+
return onRunError(context, {
|
|
5744
|
+
workflowId: plan.id,
|
|
5745
|
+
message: `Failed to load dataclip ${input}${e.message ? `: ${e.message}` : ""}`,
|
|
5746
|
+
type: "DataClipError",
|
|
5747
|
+
severity: "exception"
|
|
5748
|
+
});
|
|
5749
|
+
}
|
|
5750
|
+
}
|
|
5629
5751
|
try {
|
|
5630
|
-
engine.execute(plan, { resolvers, ...options });
|
|
5752
|
+
engine.execute(plan, loadedInput, { resolvers, ...options });
|
|
5631
5753
|
} catch (e) {
|
|
5632
5754
|
onRunError(context, {
|
|
5633
5755
|
workflowId: plan.id,
|
|
@@ -5652,9 +5774,6 @@ function onJobError(context, event) {
|
|
|
5652
5774
|
return onStepComplete(context, event, event.error);
|
|
5653
5775
|
}
|
|
5654
5776
|
}
|
|
5655
|
-
function onWorkflowStart({ channel }, _event) {
|
|
5656
|
-
return sendEvent(channel, RUN_START);
|
|
5657
|
-
}
|
|
5658
5777
|
function onJobLog({ channel, state }, event) {
|
|
5659
5778
|
const timeInMicroseconds = BigInt(event.time) / BigInt(1e3);
|
|
5660
5779
|
const log = {
|
|
@@ -5696,9 +5815,9 @@ var joinRunChannel = (socket, token, runId, logger2) => {
|
|
|
5696
5815
|
if (!didReceiveOk) {
|
|
5697
5816
|
didReceiveOk = true;
|
|
5698
5817
|
logger2.success(`connected to ${channelName}`, e);
|
|
5699
|
-
const { plan, options } = await loadRun(channel);
|
|
5818
|
+
const { plan, options, input } = await loadRun(channel);
|
|
5700
5819
|
logger2.debug("converted run as execution plan:", plan);
|
|
5701
|
-
resolve5({ channel, plan, options });
|
|
5820
|
+
resolve5({ channel, plan, options, input });
|
|
5702
5821
|
}
|
|
5703
5822
|
}).receive("error", (err) => {
|
|
5704
5823
|
logger2.error(`error connecting to ${channelName}`, err);
|
|
@@ -5709,16 +5828,17 @@ var joinRunChannel = (socket, token, runId, logger2) => {
|
|
|
5709
5828
|
var run_default = joinRunChannel;
|
|
5710
5829
|
async function loadRun(channel) {
|
|
5711
5830
|
const runBody = await get_with_reply_default(channel, GET_PLAN);
|
|
5712
|
-
return
|
|
5831
|
+
return convert_lightning_plan_default(runBody);
|
|
5713
5832
|
}
|
|
5714
5833
|
|
|
5715
5834
|
// src/channels/worker-queue.ts
|
|
5716
5835
|
import EventEmitter2 from "node:events";
|
|
5717
5836
|
import { Socket as PhxSocket } from "phoenix";
|
|
5718
5837
|
import { WebSocket } from "ws";
|
|
5838
|
+
import { API_VERSION } from "@openfn/lexicon/lightning";
|
|
5719
5839
|
|
|
5720
5840
|
// src/util/worker-token.ts
|
|
5721
|
-
import * as
|
|
5841
|
+
import * as jose2 from "jose";
|
|
5722
5842
|
var alg = "HS256";
|
|
5723
5843
|
var generateWorkerToken = async (secret, workerId, logger2) => {
|
|
5724
5844
|
if (!secret) {
|
|
@@ -5733,7 +5853,7 @@ var generateWorkerToken = async (secret, workerId, logger2) => {
|
|
|
5733
5853
|
const claims = {
|
|
5734
5854
|
worker_id: workerId
|
|
5735
5855
|
};
|
|
5736
|
-
const jwt = await new
|
|
5856
|
+
const jwt = await new jose2.SignJWT(claims).setProtectedHeader({ alg }).setIssuedAt().setIssuer("urn:openfn:worker").sign(encodedSecret);
|
|
5737
5857
|
return jwt;
|
|
5738
5858
|
};
|
|
5739
5859
|
var worker_token_default = generateWorkerToken;
|
|
@@ -5741,9 +5861,15 @@ var worker_token_default = generateWorkerToken;
|
|
|
5741
5861
|
// src/channels/worker-queue.ts
|
|
5742
5862
|
var connectToWorkerQueue = (endpoint, serverId, secret, logger2, SocketConstructor = PhxSocket) => {
|
|
5743
5863
|
const events = new EventEmitter2();
|
|
5744
|
-
worker_token_default(secret, serverId, logger2).then((token) => {
|
|
5864
|
+
worker_token_default(secret, serverId, logger2).then(async (token) => {
|
|
5865
|
+
const pkg = await Promise.resolve().then(() => (init_package(), package_exports));
|
|
5866
|
+
const params = {
|
|
5867
|
+
token,
|
|
5868
|
+
api_version: API_VERSION,
|
|
5869
|
+
worker_version: pkg.default.version
|
|
5870
|
+
};
|
|
5745
5871
|
const socket = new SocketConstructor(endpoint, {
|
|
5746
|
-
params
|
|
5872
|
+
params,
|
|
5747
5873
|
transport: WebSocket
|
|
5748
5874
|
});
|
|
5749
5875
|
let didOpen = false;
|
|
@@ -5782,6 +5908,9 @@ var MAX_BACKOFF = 1e3 * 30;
|
|
|
5782
5908
|
function connect(app, logger2, options = {}) {
|
|
5783
5909
|
logger2.debug("Connecting to Lightning at", options.lightning);
|
|
5784
5910
|
const onConnect = ({ socket, channel }) => {
|
|
5911
|
+
if (app.destroyed) {
|
|
5912
|
+
return;
|
|
5913
|
+
}
|
|
5785
5914
|
logger2.success("Connected to Lightning at", options.lightning);
|
|
5786
5915
|
app.socket = socket;
|
|
5787
5916
|
app.queueChannel = channel;
|
|
@@ -5816,6 +5945,9 @@ function connect(app, logger2, options = {}) {
|
|
|
5816
5945
|
}
|
|
5817
5946
|
};
|
|
5818
5947
|
const onError = (e) => {
|
|
5948
|
+
if (app.destroyed) {
|
|
5949
|
+
return;
|
|
5950
|
+
}
|
|
5819
5951
|
logger2.error(
|
|
5820
5952
|
"CRITICAL ERROR: could not connect to lightning at",
|
|
5821
5953
|
options.lightning
|
|
@@ -5845,13 +5977,15 @@ function createServer(engine, options = {}) {
|
|
|
5845
5977
|
process.send?.("READY");
|
|
5846
5978
|
router.get("/livez", healthcheck_default);
|
|
5847
5979
|
router.get("/", healthcheck_default);
|
|
5980
|
+
app.options = options || {};
|
|
5848
5981
|
app.execute = async ({ id, token }) => {
|
|
5849
5982
|
if (app.socket) {
|
|
5850
5983
|
app.workflows[id] = true;
|
|
5851
5984
|
const {
|
|
5852
5985
|
channel: runChannel,
|
|
5853
5986
|
plan,
|
|
5854
|
-
options: options2
|
|
5987
|
+
options: options2,
|
|
5988
|
+
input
|
|
5855
5989
|
} = await run_default(app.socket, token, id, logger2);
|
|
5856
5990
|
const onFinish = () => {
|
|
5857
5991
|
delete app.workflows[id];
|
|
@@ -5863,6 +5997,7 @@ function createServer(engine, options = {}) {
|
|
|
5863
5997
|
engine,
|
|
5864
5998
|
logger2,
|
|
5865
5999
|
plan,
|
|
6000
|
+
input,
|
|
5866
6001
|
options2,
|
|
5867
6002
|
onFinish
|
|
5868
6003
|
);
|
|
@@ -5873,7 +6008,9 @@ function createServer(engine, options = {}) {
|
|
|
5873
6008
|
};
|
|
5874
6009
|
router.post("/claim", async (ctx) => {
|
|
5875
6010
|
logger2.info("triggering claim from POST request");
|
|
5876
|
-
return claim_default(app, logger2,
|
|
6011
|
+
return claim_default(app, logger2, {
|
|
6012
|
+
maxWorkers: options.maxWorkflows
|
|
6013
|
+
}).then(() => {
|
|
5877
6014
|
logger2.info("claim complete: 1 run claimed");
|
|
5878
6015
|
ctx.body = "complete";
|
|
5879
6016
|
ctx.status = 200;
|
|
@@ -5912,6 +6049,7 @@ var server_default = createServer;
|
|
|
5912
6049
|
var {
|
|
5913
6050
|
WORKER_BACKOFF,
|
|
5914
6051
|
WORKER_CAPACITY,
|
|
6052
|
+
WORKER_LIGHTNING_PUBLIC_KEY,
|
|
5915
6053
|
WORKER_LIGHTNING_SERVICE_URL,
|
|
5916
6054
|
WORKER_LOG_LEVEL,
|
|
5917
6055
|
WORKER_MAX_RUN_DURATION_SECONDS,
|
|
@@ -5938,6 +6076,9 @@ var args = yargs_default(hideBin(process.argv)).command("server", "Start a ws-wo
|
|
|
5938
6076
|
alias: "s",
|
|
5939
6077
|
description: "Worker secret. (comes from WORKER_SECRET by default). Env: WORKER_SECRET",
|
|
5940
6078
|
default: WORKER_SECRET
|
|
6079
|
+
}).option("lightning-public-key", {
|
|
6080
|
+
description: "Base64-encoded public key. Used to verify run tokens. Env: WORKER_LIGHTNING_PUBLIC_KEY",
|
|
6081
|
+
default: WORKER_LIGHTNING_PUBLIC_KEY
|
|
5941
6082
|
}).option("log", {
|
|
5942
6083
|
description: "Set the log level for stdout (default to info, set to debug for verbose output). Env: WORKER_LOG_LEVEL",
|
|
5943
6084
|
default: WORKER_LOG_LEVEL || "debug",
|
|
@@ -5996,7 +6137,21 @@ function engineReady(engine) {
|
|
|
5996
6137
|
},
|
|
5997
6138
|
maxWorkflows: args.capacity
|
|
5998
6139
|
};
|
|
5999
|
-
|
|
6140
|
+
if (args.lightningPublicKey) {
|
|
6141
|
+
logger.info(
|
|
6142
|
+
"Lightning public key found: run tokens from Lightning will be verified by this worker"
|
|
6143
|
+
);
|
|
6144
|
+
workerOptions.runPublicKey = Buffer.from(
|
|
6145
|
+
args.lightningPublicKey,
|
|
6146
|
+
"base64"
|
|
6147
|
+
).toString();
|
|
6148
|
+
}
|
|
6149
|
+
const {
|
|
6150
|
+
logger: _l,
|
|
6151
|
+
secret: _s,
|
|
6152
|
+
runPublicKey,
|
|
6153
|
+
...humanOptions
|
|
6154
|
+
} = workerOptions;
|
|
6000
6155
|
logger.debug("Worker options:", humanOptions);
|
|
6001
6156
|
server_default(engine, workerOptions);
|
|
6002
6157
|
}
|