biz-a-cli 2.3.73 → 2.3.74
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/bin/app.js +23 -0
- package/bin/hub.js +42 -2
- package/bin/hubEvent.js +100 -35
- package/bin/migrate.js +169 -0
- package/callbackController.js +58 -36
- package/db/db.js +37 -0
- package/db/ds.js +189 -0
- package/engine/bpm/routes.js +61 -0
- package/engine/bpm/workflow-runtime.js +1136 -0
- package/engine/bpm/workflow.js +235 -0
- package/migrations/1777727873750__apps.sql +16 -0
- package/migrations/1777727892577__bpm.sql +274 -0
- package/package.json +17 -2
- package/scheduler/datalib.js +266 -182
- package/worker/cliScriptWorker.js +55 -22
- package/worker/cliWorkerPool.js +63 -10
- package/.editorconfig +0 -16
- package/log/debug.log +0 -0
- package/log/error.log +0 -0
- package/log/exception.log +0 -0
- package/log/info.log +0 -0
- package/tests/app.test.js +0 -1208
- package/tests/callback.test.js +0 -42
- package/tests/config.test.js +0 -39
- package/tests/converter.test.js +0 -106
- package/tests/data.test.js +0 -487
- package/tests/deployment.test.js +0 -339
- package/tests/hub.test.js +0 -998
- package/tests/hubPublish.test.js +0 -231
- package/tests/mailCtl.test.js +0 -44
- package/tests/timer.test.js +0 -187
- package/tests/watcher.test.js +0 -352
- package/tests/watcherCtl.test.js +0 -124
package/worker/cliWorkerPool.js
CHANGED
|
@@ -1,18 +1,71 @@
|
|
|
1
|
-
import workerpool from
|
|
1
|
+
import workerpool from "workerpool";
|
|
2
2
|
|
|
3
3
|
export const cliScriptWorkerPool = workerpool.pool(
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
"./worker/cliScriptWorker.js",
|
|
5
|
+
{
|
|
6
|
+
workerType: "thread",
|
|
7
|
+
emitStdStreams: true, // the worker will emit stdout and stderr events instead of passing it through to the parent streams
|
|
8
|
+
workerThreadOpts: {
|
|
9
|
+
env: { NODE_ENV: process.env.NODE_ENV || "production" },
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
);
|
|
10
13
|
|
|
11
|
-
export const execCLIScriptWorker = async (
|
|
14
|
+
export const execCLIScriptWorker = async (
|
|
15
|
+
apiConfig,
|
|
16
|
+
scriptName,
|
|
17
|
+
scriptData,
|
|
18
|
+
) => {
|
|
19
|
+
// callback
|
|
20
|
+
// {
|
|
21
|
+
// arguments: args,
|
|
22
|
+
// body: req.body.body,
|
|
23
|
+
// path: req.path,
|
|
24
|
+
// query: req.body.query,
|
|
25
|
+
// headers: req.body.headers,
|
|
26
|
+
// },
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
// watcher
|
|
29
|
+
// const urlAndPort = config.url.split(":");
|
|
30
|
+
// {
|
|
31
|
+
// arguments: {
|
|
32
|
+
// hostname: urlAndPort[1].split("//")[1],
|
|
33
|
+
// port: +urlAndPort[2],
|
|
34
|
+
// dbindex: config.dbindex,
|
|
35
|
+
// finaDbIndex: config.finaDbIndex,
|
|
36
|
+
// subdomain: config.subdomain,
|
|
37
|
+
// smtp: config.smtp,
|
|
38
|
+
// },
|
|
39
|
+
// body: trigger.data ?? null,
|
|
40
|
+
// };
|
|
41
|
+
|
|
42
|
+
// live Trigger
|
|
43
|
+
// {
|
|
44
|
+
// arguments: argv,
|
|
45
|
+
// body: data.scriptData ?? null,
|
|
46
|
+
// path: "/live-trigger",
|
|
47
|
+
// query: { scriptName: data.scriptName },
|
|
48
|
+
// headers: { "user-agent": "biz-a-client-socket" },
|
|
49
|
+
// };
|
|
50
|
+
|
|
51
|
+
// Worker threads can only accept strings, numbers, booleans, and pure JSON objects/arrays.
|
|
52
|
+
// It cannot serialize live functions, object or DOM nodes
|
|
53
|
+
const safeData = JSON.parse(JSON.stringify(scriptData));
|
|
54
|
+
return cliScriptWorkerPool.exec("run", [apiConfig, scriptName, safeData]);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export const workerStats = () => {
|
|
58
|
+
return { cliScript: cliScriptWorkerPool.stats() };
|
|
59
|
+
};
|
|
14
60
|
|
|
15
61
|
// note: if process.exit is explicitly executed by internal code, then
|
|
16
62
|
// ensure to manually call workerpool.terminate() if available
|
|
17
63
|
// ortherwise ensure Operating system clean up worker when main thread terminated
|
|
18
|
-
|
|
64
|
+
async function cliWorkerPoolBeforeExitHandler() {
|
|
65
|
+
await cliScriptWorkerPool.terminate();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (!process.__cliWorkerPoolBeforeExitAttached) {
|
|
69
|
+
process.on("beforeexit", cliWorkerPoolBeforeExitHandler);
|
|
70
|
+
process.__cliWorkerPoolBeforeExitAttached = true;
|
|
71
|
+
}
|
package/.editorconfig
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Editor configuration, see https://editorconfig.org
|
|
2
|
-
root = true
|
|
3
|
-
|
|
4
|
-
[*]
|
|
5
|
-
charset = utf-8
|
|
6
|
-
indent_style = tab
|
|
7
|
-
tab_width = 4
|
|
8
|
-
insert_final_newline = true
|
|
9
|
-
trim_trailing_whitespace = true
|
|
10
|
-
|
|
11
|
-
[*.ts]
|
|
12
|
-
quote_type = single
|
|
13
|
-
|
|
14
|
-
[*.md]
|
|
15
|
-
max_line_length = off
|
|
16
|
-
trim_trailing_whitespace = false
|
package/log/debug.log
DELETED
|
File without changes
|
package/log/error.log
DELETED
|
File without changes
|
package/log/exception.log
DELETED
|
File without changes
|
package/log/info.log
DELETED
|
File without changes
|