@nocobase/plugin-workflow-javascript 2.1.0-beta.42 → 2.1.0-beta.43
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/dist/externalVersion.js
CHANGED
|
@@ -13,11 +13,11 @@ module.exports = {
|
|
|
13
13
|
"antd-style": "3.7.1",
|
|
14
14
|
"@formily/antd-v5": "1.2.3",
|
|
15
15
|
"@ant-design/icons": "5.6.1",
|
|
16
|
-
"@nocobase/client": "2.1.0-beta.
|
|
17
|
-
"@nocobase/plugin-workflow": "2.1.0-beta.
|
|
16
|
+
"@nocobase/client": "2.1.0-beta.43",
|
|
17
|
+
"@nocobase/plugin-workflow": "2.1.0-beta.43",
|
|
18
18
|
"antd": "5.24.2",
|
|
19
|
-
"@nocobase/flow-engine": "2.1.0-beta.
|
|
19
|
+
"@nocobase/flow-engine": "2.1.0-beta.43",
|
|
20
20
|
"react-i18next": "11.18.6",
|
|
21
21
|
"winston": "3.13.0",
|
|
22
|
-
"@nocobase/server": "2.1.0-beta.
|
|
22
|
+
"@nocobase/server": "2.1.0-beta.43"
|
|
23
23
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-
|
|
1
|
+
{"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-02T14:17:32.646Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-06-
|
|
1
|
+
{"name":"winston-transport","description":"Base stream implementations for winston@3 and up.","version":"4.7.0","main":"index.js","browser":"dist/index.js","scripts":{"lint":"eslint test/*.js index.js --resolve-plugins-relative-to ./node_modules/@dabh/eslint-config-populist","pretest":"npm run lint && npm run build","test":"nyc mocha test/*.test.js","report":"nyc report --reporter=lcov","build":"rimraf dist && babel *.js -d ./dist","prepublishOnly":"npm run build"},"repository":{"type":"git","url":"git@github.com:winstonjs/winston-transport.git"},"keywords":["winston","transport","winston3"],"author":"Charlie Robbins <charlie.robbins@gmail.com>","license":"MIT","bugs":{"url":"https://github.com/winstonjs/winston-transport/issues"},"homepage":"https://github.com/winstonjs/winston-transport#readme","dependencies":{"logform":"^2.3.2","readable-stream":"^3.6.0","triple-beam":"^1.3.0"},"devDependencies":{"@types/node":"^20.8.6","abstract-winston-transport":">=0.5.1","assume":"^2.3.0","babel-cli":"^6.26.0","babel-preset-env":"^1.7.0","deep-equal":"^2.0.5","eslint":"^8.8.0","@dabh/eslint-config-populist":"^5.0.0","mocha":"^10.0.0","nyc":"^15.1.0","rimraf":"^5.0.5","winston-compat":"^0.1.5"},"engines":{"node":">= 12.0.0"},"_lastModified":"2026-06-02T14:17:32.941Z"}
|
|
@@ -9,48 +9,51 @@
|
|
|
9
9
|
import { Logger } from 'winston';
|
|
10
10
|
import Joi from 'joi';
|
|
11
11
|
import { Processor, Instruction, FlowNodeModel } from '@nocobase/plugin-workflow';
|
|
12
|
+
type ScriptArgument = {
|
|
13
|
+
name: string;
|
|
14
|
+
value?: unknown;
|
|
15
|
+
};
|
|
12
16
|
type ScriptConfig = {
|
|
13
17
|
content?: string;
|
|
14
18
|
timeout?: number;
|
|
15
19
|
continue?: boolean;
|
|
16
|
-
arguments?:
|
|
17
|
-
[key: string]: any;
|
|
18
|
-
}[];
|
|
20
|
+
arguments?: ScriptArgument[];
|
|
19
21
|
};
|
|
22
|
+
type ScriptArguments = Record<string, unknown> | unknown[];
|
|
20
23
|
export default class ScriptInstruction extends Instruction {
|
|
21
24
|
/**
|
|
22
25
|
* Returns the worker script path based on whether WORKFLOW_SCRIPT_MODULES is configured.
|
|
23
|
-
* - WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (
|
|
26
|
+
* - WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (unsafe; not a security boundary)
|
|
24
27
|
* - WORKFLOW_SCRIPT_MODULES unset: uses QuickJS (WASM) for maximum security (no require, no Node.js APIs)
|
|
25
28
|
*/
|
|
26
29
|
static get workerScript(): string;
|
|
27
|
-
static run(source:
|
|
30
|
+
static run(source: string, args: ScriptArguments, options: {
|
|
28
31
|
logger: Logger;
|
|
29
32
|
timeout?: number;
|
|
30
33
|
signal?: AbortSignal;
|
|
31
34
|
}): Promise<{
|
|
32
35
|
status: -2;
|
|
33
|
-
result:
|
|
36
|
+
result: string;
|
|
34
37
|
} | {
|
|
35
38
|
status: 1;
|
|
36
|
-
result:
|
|
39
|
+
result: unknown;
|
|
37
40
|
}>;
|
|
38
41
|
configSchema: Joi.ObjectSchema<any>;
|
|
39
42
|
run(node: FlowNodeModel, prevJob: any, processor: Processor, options?: {
|
|
40
43
|
signal?: AbortSignal;
|
|
41
44
|
}): Promise<{
|
|
42
|
-
result:
|
|
45
|
+
result: unknown;
|
|
43
46
|
status: -2 | 1;
|
|
44
47
|
}>;
|
|
45
48
|
resume(node: FlowNodeModel, job: any, processor: Processor): Promise<any>;
|
|
46
49
|
test(config?: ScriptConfig): Promise<{
|
|
47
50
|
log: string;
|
|
48
51
|
status: -2;
|
|
49
|
-
result:
|
|
52
|
+
result: string;
|
|
50
53
|
} | {
|
|
51
54
|
log: string;
|
|
52
55
|
status: 1;
|
|
53
|
-
result:
|
|
56
|
+
result: unknown;
|
|
54
57
|
}>;
|
|
55
58
|
}
|
|
56
59
|
export {};
|
|
@@ -49,12 +49,11 @@ var import_cache_logger = require("./cache-logger");
|
|
|
49
49
|
class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
50
50
|
/**
|
|
51
51
|
* Returns the worker script path based on whether WORKFLOW_SCRIPT_MODULES is configured.
|
|
52
|
-
* - WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (
|
|
52
|
+
* - WORKFLOW_SCRIPT_MODULES set: uses Node.js vm with require support (unsafe; not a security boundary)
|
|
53
53
|
* - WORKFLOW_SCRIPT_MODULES unset: uses QuickJS (WASM) for maximum security (no require, no Node.js APIs)
|
|
54
54
|
*/
|
|
55
55
|
static get workerScript() {
|
|
56
|
-
|
|
57
|
-
const hasModules = ((_a = process.env.WORKFLOW_SCRIPT_MODULES) == null ? void 0 : _a.split(",").filter(Boolean).length) > 0;
|
|
56
|
+
const hasModules = (process.env.WORKFLOW_SCRIPT_MODULES ?? "").split(",").filter(Boolean).length > 0;
|
|
58
57
|
return import_node_path.default.join(__dirname, hasModules ? "Vm.js" : "QuickJs.js");
|
|
59
58
|
}
|
|
60
59
|
static async run(source, args, options) {
|
|
@@ -64,7 +63,7 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
64
63
|
workerData: { source, args, options: timeout ? { timeout } : {} }
|
|
65
64
|
});
|
|
66
65
|
const abortListener = () => {
|
|
67
|
-
|
|
66
|
+
worker.terminate();
|
|
68
67
|
};
|
|
69
68
|
signal == null ? void 0 : signal.addEventListener("abort", abortListener, { once: true });
|
|
70
69
|
worker.on("message", (message) => {
|
|
@@ -102,7 +101,7 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
102
101
|
}
|
|
103
102
|
return {
|
|
104
103
|
status: import_plugin_workflow.JOB_STATUS.ERROR,
|
|
105
|
-
result: e.message
|
|
104
|
+
result: e instanceof Error ? e.message : String(e)
|
|
106
105
|
};
|
|
107
106
|
}
|
|
108
107
|
signal == null ? void 0 : signal.removeEventListener("abort", abortListener);
|
|
@@ -174,9 +173,10 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
174
173
|
jobResult.status = import_plugin_workflow.JOB_STATUS.ERROR;
|
|
175
174
|
jobResult.result = res.result;
|
|
176
175
|
}).catch((e) => {
|
|
177
|
-
|
|
176
|
+
const message = e instanceof Error ? e.message : String(e);
|
|
177
|
+
processor.logger.error(`script (#${node.id}) get result failed, the reason is ${message}`);
|
|
178
178
|
jobResult.status = import_plugin_workflow.JOB_STATUS.ERROR;
|
|
179
|
-
jobResult.result =
|
|
179
|
+
jobResult.result = message;
|
|
180
180
|
}).finally(() => {
|
|
181
181
|
processor.logger.debug(`script (#${node.id}) ended, resume workflow...`);
|
|
182
182
|
setImmediate(async () => {
|
|
@@ -197,12 +197,15 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
197
197
|
}
|
|
198
198
|
async test(config = {}) {
|
|
199
199
|
const { content, timeout } = config;
|
|
200
|
-
const args = (config.arguments ?? []).reduce(
|
|
200
|
+
const args = (config.arguments ?? []).reduce(
|
|
201
|
+
(pre, item) => ({ ...pre, [item.name]: item.value }),
|
|
202
|
+
{}
|
|
203
|
+
);
|
|
201
204
|
const transport = new import_cache_logger.CacheTransport();
|
|
202
205
|
const logger = import_winston.default.createLogger({
|
|
203
206
|
transports: [transport]
|
|
204
207
|
});
|
|
205
|
-
const result = await this.constructor.run(content, args, { timeout, logger });
|
|
208
|
+
const result = await this.constructor.run(content ?? "", args, { timeout, logger });
|
|
206
209
|
const log = transport.getLogs();
|
|
207
210
|
return {
|
|
208
211
|
...result,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow-javascript",
|
|
3
|
-
"version": "2.1.0-beta.
|
|
3
|
+
"version": "2.1.0-beta.43",
|
|
4
4
|
"displayName": "Workflow: JavaScript",
|
|
5
5
|
"displayName.zh-CN": "工作流:JavaScript 节点",
|
|
6
6
|
"description": "Execute a piece of JavaScript in an isolated Node.js environment.",
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"Workflow"
|
|
34
34
|
],
|
|
35
35
|
"license": "Apache-2.0",
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "6d7750e2373bf2451d246de88cc1f62491685e18"
|
|
37
37
|
}
|