@nocobase/plugin-workflow-javascript 2.1.0-alpha.39 → 2.1.0-alpha.45
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-alpha.
|
|
17
|
-
"@nocobase/plugin-workflow": "2.1.0-alpha.
|
|
16
|
+
"@nocobase/client": "2.1.0-alpha.45",
|
|
17
|
+
"@nocobase/plugin-workflow": "2.1.0-alpha.45",
|
|
18
18
|
"antd": "5.24.2",
|
|
19
|
-
"@nocobase/flow-engine": "2.1.0-alpha.
|
|
19
|
+
"@nocobase/flow-engine": "2.1.0-alpha.45",
|
|
20
20
|
"react-i18next": "11.18.6",
|
|
21
21
|
"winston": "3.13.0",
|
|
22
|
-
"@nocobase/server": "2.1.0-alpha.
|
|
22
|
+
"@nocobase/server": "2.1.0-alpha.45"
|
|
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-05-
|
|
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-05-29T12:51:13.396Z"}
|
|
@@ -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-05-
|
|
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-05-29T12:51:13.683Z"}
|
|
@@ -27,6 +27,7 @@ export default class ScriptInstruction extends Instruction {
|
|
|
27
27
|
static run(source: any, args: any, options: {
|
|
28
28
|
logger: Logger;
|
|
29
29
|
timeout?: number;
|
|
30
|
+
signal?: AbortSignal;
|
|
30
31
|
}): Promise<{
|
|
31
32
|
status: -2;
|
|
32
33
|
result: any;
|
|
@@ -35,7 +36,9 @@ export default class ScriptInstruction extends Instruction {
|
|
|
35
36
|
result: any;
|
|
36
37
|
}>;
|
|
37
38
|
configSchema: Joi.ObjectSchema<any>;
|
|
38
|
-
run(node: FlowNodeModel, prevJob: any, processor: Processor
|
|
39
|
+
run(node: FlowNodeModel, prevJob: any, processor: Processor, options?: {
|
|
40
|
+
signal?: AbortSignal;
|
|
41
|
+
}): Promise<{
|
|
39
42
|
result: any;
|
|
40
43
|
status: -2 | 1;
|
|
41
44
|
}>;
|
|
@@ -58,11 +58,15 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
58
58
|
return import_node_path.default.join(__dirname, hasModules ? "Vm.js" : "QuickJs.js");
|
|
59
59
|
}
|
|
60
60
|
static async run(source, args, options) {
|
|
61
|
-
const { logger, timeout } = options;
|
|
61
|
+
const { logger, timeout, signal } = options;
|
|
62
62
|
let result;
|
|
63
63
|
const worker = new import_node_worker_threads.Worker(this.workerScript, {
|
|
64
64
|
workerData: { source, args, options: timeout ? { timeout } : {} }
|
|
65
65
|
});
|
|
66
|
+
const abortListener = () => {
|
|
67
|
+
void worker.terminate();
|
|
68
|
+
};
|
|
69
|
+
signal == null ? void 0 : signal.addEventListener("abort", abortListener, { once: true });
|
|
66
70
|
worker.on("message", (message) => {
|
|
67
71
|
if (message.type === "result") {
|
|
68
72
|
result = message.result;
|
|
@@ -92,12 +96,16 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
92
96
|
try {
|
|
93
97
|
await excution;
|
|
94
98
|
} catch (e) {
|
|
95
|
-
|
|
99
|
+
signal == null ? void 0 : signal.removeEventListener("abort", abortListener);
|
|
100
|
+
if (signal == null ? void 0 : signal.aborted) {
|
|
101
|
+
throw signal.reason instanceof Error ? signal.reason : new import_plugin_workflow.WorkflowTimeoutError();
|
|
102
|
+
}
|
|
96
103
|
return {
|
|
97
104
|
status: import_plugin_workflow.JOB_STATUS.ERROR,
|
|
98
105
|
result: e.message
|
|
99
106
|
};
|
|
100
107
|
}
|
|
108
|
+
signal == null ? void 0 : signal.removeEventListener("abort", abortListener);
|
|
101
109
|
return {
|
|
102
110
|
status: import_plugin_workflow.JOB_STATUS.RESOLVED,
|
|
103
111
|
result
|
|
@@ -114,7 +122,7 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
114
122
|
})
|
|
115
123
|
).optional()
|
|
116
124
|
});
|
|
117
|
-
async run(node, prevJob, processor) {
|
|
125
|
+
async run(node, prevJob, processor, options) {
|
|
118
126
|
const { content = "", continue: cont, timeout } = node.config;
|
|
119
127
|
const args = processor.getParsedValue(node.config.arguments ?? [], node.id);
|
|
120
128
|
const _args = args.reduce((pre, item) => ({ ...pre, [item.name]: item.value }), {});
|
|
@@ -124,7 +132,8 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
124
132
|
if (sync) {
|
|
125
133
|
const result = await this.constructor.run(content, _args, {
|
|
126
134
|
timeout,
|
|
127
|
-
logger: processor.logger
|
|
135
|
+
logger: processor.logger,
|
|
136
|
+
signal: options == null ? void 0 : options.signal
|
|
128
137
|
});
|
|
129
138
|
if (result.status === import_plugin_workflow.JOB_STATUS.RESOLVED) {
|
|
130
139
|
processor.logger.info(`run script test success, node id: ${node.id},the result is ${result.result}`);
|
|
@@ -147,7 +156,7 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
147
156
|
const jobResult = {
|
|
148
157
|
status: import_plugin_workflow.JOB_STATUS.PENDING
|
|
149
158
|
};
|
|
150
|
-
this.constructor.run(content, _args, { timeout, logger: processor.logger }).then((res) => {
|
|
159
|
+
this.constructor.run(content, _args, { timeout, logger: processor.logger, signal: options == null ? void 0 : options.signal }).then((res) => {
|
|
151
160
|
if (res.status === import_plugin_workflow.JOB_STATUS.RESOLVED) {
|
|
152
161
|
processor.logger.info(`script (#${node.id}) get result success`);
|
|
153
162
|
jobResult.status = import_plugin_workflow.JOB_STATUS.RESOLVED;
|
|
@@ -172,7 +181,13 @@ class ScriptInstruction extends import_plugin_workflow.Instruction {
|
|
|
172
181
|
processor.logger.debug(`script (#${node.id}) ended, resume workflow...`);
|
|
173
182
|
setImmediate(async () => {
|
|
174
183
|
const job = await this.workflow.db.getRepository("jobs").findOne({ filterByTk: id });
|
|
184
|
+
const execution = await job.getExecution();
|
|
185
|
+
if (execution.status !== 0) {
|
|
186
|
+
processor.logger.warn(`script (#${node.id}) result discarded because execution (${execution.id}) is ended`);
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
175
189
|
job.set(jobResult);
|
|
190
|
+
job.execution = execution;
|
|
176
191
|
this.workflow.resume(job);
|
|
177
192
|
});
|
|
178
193
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow-javascript",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.45",
|
|
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": "e9e24987e12d0ad10a5db8815b1e1b7b447f1938"
|
|
37
37
|
}
|