biz-a-cli 2.3.73 → 2.3.75

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.
@@ -1,18 +1,78 @@
1
- import workerpool from 'workerpool';
1
+ import workerpool from "workerpool";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const __filename = fileURLToPath(import.meta.url);
6
+ const __dirname = path.dirname(__filename);
2
7
 
3
8
  export const cliScriptWorkerPool = workerpool.pool(
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: {env: {NODE_ENV: process.env.NODE_ENV || 'production'}}
9
- });
9
+ // "./worker/cliScriptWorker.js",
10
+ // path.join(import.meta.dirname, "cliScriptWorker.js"),
11
+ path.join(__dirname, "cliScriptWorker.js"),
12
+ {
13
+ workerType: "thread",
14
+ emitStdStreams: true, // the worker will emit stdout and stderr events instead of passing it through to the parent streams
15
+ workerThreadOpts: {
16
+ env: { NODE_ENV: process.env.NODE_ENV || "production" },
17
+ },
18
+ },
19
+ );
20
+
21
+ export const execCLIScriptWorker = async (
22
+ apiConfig,
23
+ scriptName,
24
+ scriptData,
25
+ ) => {
26
+ // callback
27
+ // {
28
+ // arguments: args,
29
+ // body: req.body.body,
30
+ // path: req.path,
31
+ // query: req.body.query,
32
+ // headers: req.body.headers,
33
+ // },
34
+
35
+ // watcher
36
+ // const urlAndPort = config.url.split(":");
37
+ // {
38
+ // arguments: {
39
+ // hostname: urlAndPort[1].split("//")[1],
40
+ // port: +urlAndPort[2],
41
+ // dbindex: config.dbindex,
42
+ // finaDbIndex: config.finaDbIndex,
43
+ // subdomain: config.subdomain,
44
+ // smtp: config.smtp,
45
+ // },
46
+ // body: trigger.data ?? null,
47
+ // };
10
48
 
11
- export const execCLIScriptWorker = async (apiConfig, scriptName, scriptData)=>cliScriptWorkerPool.exec('run', [apiConfig, scriptName, scriptData]);
49
+ // live Trigger
50
+ // {
51
+ // arguments: argv,
52
+ // body: data.scriptData ?? null,
53
+ // path: "/live-trigger",
54
+ // query: { scriptName: data.scriptName },
55
+ // headers: { "user-agent": "biz-a-client-socket" },
56
+ // };
12
57
 
13
- export const workerStats = ()=>{return {cliScript: cliScriptWorkerPool.stats()}};
58
+ // Worker threads can only accept strings, numbers, booleans, and pure JSON objects/arrays.
59
+ // It cannot serialize live functions, object or DOM nodes
60
+ const safeData = JSON.parse(JSON.stringify(scriptData));
61
+ return cliScriptWorkerPool.exec("run", [apiConfig, scriptName, safeData]);
62
+ };
63
+
64
+ export const workerStats = () => {
65
+ return { cliScript: cliScriptWorkerPool.stats() };
66
+ };
14
67
 
15
68
  // note: if process.exit is explicitly executed by internal code, then
16
69
  // ensure to manually call workerpool.terminate() if available
17
70
  // ortherwise ensure Operating system clean up worker when main thread terminated
18
- process.on('beforeexit', async ()=>{await cliScriptWorkerPool.terminate()});
71
+ async function cliWorkerPoolBeforeExitHandler() {
72
+ await cliScriptWorkerPool.terminate();
73
+ }
74
+
75
+ if (!process.__cliWorkerPoolBeforeExitAttached) {
76
+ process.on("beforeexit", cliWorkerPoolBeforeExitHandler);
77
+ process.__cliWorkerPoolBeforeExitAttached = true;
78
+ }
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