@nocobase/plugin-workflow 0.17.0-alpha.6 → 0.18.0-alpha.1
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 +16 -16
- package/dist/node_modules/cron-parser/package.json +1 -1
- package/dist/node_modules/lru-cache/package.json +1 -1
- package/dist/server/Plugin.d.ts +1 -0
- package/dist/server/Plugin.js +67 -45
- package/dist/server/Processor.js +2 -2
- package/dist/server/migrations/20230612021134-manual-collection-block.js +1 -0
- package/package.json +2 -2
package/dist/externalVersion.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
module.exports = {
|
|
2
2
|
"react": "18.2.0",
|
|
3
|
-
"antd": "5.
|
|
4
|
-
"@ant-design/icons": "5.
|
|
5
|
-
"@nocobase/client": "0.
|
|
6
|
-
"react-router-dom": "6.
|
|
7
|
-
"@nocobase/utils": "0.
|
|
3
|
+
"antd": "5.12.2",
|
|
4
|
+
"@ant-design/icons": "5.2.6",
|
|
5
|
+
"@nocobase/client": "0.18.0-alpha.1",
|
|
6
|
+
"react-router-dom": "6.21.0",
|
|
7
|
+
"@nocobase/utils": "0.18.0-alpha.1",
|
|
8
8
|
"react-i18next": "11.18.6",
|
|
9
|
-
"winston": "3.
|
|
10
|
-
"@nocobase/database": "0.
|
|
11
|
-
"@nocobase/server": "0.
|
|
12
|
-
"@nocobase/logger": "0.
|
|
13
|
-
"@nocobase/evaluators": "0.
|
|
14
|
-
"@formily/react": "2.
|
|
15
|
-
"@formily/core": "2.
|
|
9
|
+
"winston": "3.11.0",
|
|
10
|
+
"@nocobase/database": "0.18.0-alpha.1",
|
|
11
|
+
"@nocobase/server": "0.18.0-alpha.1",
|
|
12
|
+
"@nocobase/logger": "0.18.0-alpha.1",
|
|
13
|
+
"@nocobase/evaluators": "0.18.0-alpha.1",
|
|
14
|
+
"@formily/react": "2.3.0",
|
|
15
|
+
"@formily/core": "2.3.0",
|
|
16
16
|
"lodash": "4.17.21",
|
|
17
|
-
"@formily/antd-v5": "1.1.
|
|
18
|
-
"@nocobase/actions": "0.
|
|
19
|
-
"sequelize": "6.
|
|
20
|
-
"dayjs": "1.11.
|
|
17
|
+
"@formily/antd-v5": "1.1.9",
|
|
18
|
+
"@nocobase/actions": "0.18.0-alpha.1",
|
|
19
|
+
"sequelize": "6.35.2",
|
|
20
|
+
"dayjs": "1.11.10"
|
|
21
21
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2023-12-
|
|
1
|
+
{"name":"cron-parser","version":"4.4.0","description":"Node.js library for parsing crontab instructions","main":"lib/parser.js","types":"index.d.ts","typesVersions":{"<4.1":{"*":["types/ts3/*"]}},"directories":{"test":"test"},"scripts":{"test:tsd":"tsd","test:unit":"TZ=UTC tap ./test/*.js","test:cover":"TZ=UTC tap --coverage-report=html ./test/*.js","lint":"eslint .","lint:fix":"eslint --fix .","test":"npm run lint && npm run test:unit && npm run test:tsd"},"repository":{"type":"git","url":"https://github.com/harrisiirak/cron-parser.git"},"keywords":["cron","crontab","parser"],"author":"Harri Siirak","contributors":["Nicholas Clawson","Daniel Prentis <daniel@salsitasoft.com>","Renault John Lecoultre","Richard Astbury <richard.astbury@gmail.com>","Meaglin Wasabi <Meaglin.wasabi@gmail.com>","Mike Kusold <hello@mikekusold.com>","Alex Kit <alex.kit@atmajs.com>","Santiago Gimeno <santiago.gimeno@gmail.com>","Daniel <darc.tec@gmail.com>","Christian Steininger <christian.steininger.cs@gmail.com>","Mykola Piskovyi <m.piskovyi@gmail.com>","Brian Vaughn <brian.david.vaughn@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Yasuhiroki <yasuhiroki.duck@gmail.com>","Nicholas Clawson <nickclaw@gmail.com>","Brendan Warkentin <faazshift@gmail.com>","Charlie Fish <fishcharlie.code@gmail.com>","Ian Graves <ian+diskimage@iangrav.es>","Andy Thompson <me@andytson.com>","Regev Brody <regevbr@gmail.com>"],"license":"MIT","dependencies":{"luxon":"^1.28.0"},"devDependencies":{"eslint":"^8.2.0","sinon":"^10.0.0","tap":"^16.0.1","tsd":"^0.19.0"},"engines":{"node":">=0.8"},"browser":{"fs":false},"tap":{"check-coverage":false},"tsd":{"directory":"test","compilerOptions":{"lib":["es2017","dom"]}},"_lastModified":"2023-12-21T12:51:37.067Z"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2023-12-
|
|
1
|
+
{"name":"lru-cache","description":"A cache object that deletes the least-recently-used items.","version":"8.0.5","author":"Isaac Z. Schlueter <i@izs.me>","keywords":["mru","lru","cache"],"sideEffects":false,"scripts":{"build":"npm run prepare","preprepare":"rm -rf dist","prepare":"tsc -p tsconfig.json && tsc -p tsconfig-esm.json","postprepare":"bash fixup.sh","pretest":"npm run prepare","presnap":"npm run prepare","test":"c8 tap","snap":"c8 tap","preversion":"npm test","postversion":"npm publish","prepublishOnly":"git push origin --follow-tags","format":"prettier --write .","typedoc":"typedoc --tsconfig tsconfig-esm.json ./src/*.ts","benchmark-results-typedoc":"bash scripts/benchmark-results-typedoc.sh","prebenchmark":"npm run prepare","benchmark":"make -C benchmark","preprofile":"npm run prepare","profile":"make -C benchmark profile"},"main":"./dist/cjs/index-cjs.js","module":"./dist/mjs/index.js","types":"./dist/mjs/index.d.ts","exports":{"./min":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.min.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index.min.js"}},".":{"import":{"types":"./dist/mjs/index.d.ts","default":"./dist/mjs/index.js"},"require":{"types":"./dist/cjs/index.d.ts","default":"./dist/cjs/index-cjs.js"}}},"repository":"git://github.com/isaacs/node-lru-cache.git","devDependencies":{"@size-limit/preset-small-lib":"^7.0.8","@types/node":"^17.0.31","@types/tap":"^15.0.6","benchmark":"^2.1.4","c8":"^7.11.2","clock-mock":"^1.0.6","esbuild":"^0.17.11","eslint-config-prettier":"^8.5.0","marked":"^4.2.12","mkdirp":"^2.1.5","prettier":"^2.6.2","size-limit":"^7.0.8","tap":"^16.3.4","ts-node":"^10.7.0","tslib":"^2.4.0","typedoc":"^0.23.24","typescript":"^4.6.4"},"license":"ISC","files":["dist"],"engines":{"node":">=16.14"},"prettier":{"semi":false,"printWidth":70,"tabWidth":2,"useTabs":false,"singleQuote":true,"jsxSingleQuote":false,"bracketSameLine":true,"arrowParens":"avoid","endOfLine":"lf"},"tap":{"coverage":false,"node-arg":["--expose-gc","--no-warnings","--loader","ts-node/esm"],"ts":false},"size-limit":[{"path":"./dist/mjs/index.js"}],"_lastModified":"2023-12-21T12:51:36.734Z"}
|
package/dist/server/Plugin.d.ts
CHANGED
|
@@ -35,6 +35,7 @@ export default class WorkflowPlugin extends Plugin {
|
|
|
35
35
|
}): void;
|
|
36
36
|
resume(job: any): Promise<void>;
|
|
37
37
|
createProcessor(execution: ExecutionModel, options?: {}): Processor;
|
|
38
|
+
private createExecution;
|
|
38
39
|
private prepare;
|
|
39
40
|
private dispatch;
|
|
40
41
|
private process;
|
package/dist/server/Plugin.js
CHANGED
|
@@ -202,7 +202,9 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
202
202
|
this.toggle(workflow, false);
|
|
203
203
|
});
|
|
204
204
|
this.ready = false;
|
|
205
|
-
|
|
205
|
+
if (this.events.length) {
|
|
206
|
+
await this.prepare();
|
|
207
|
+
}
|
|
206
208
|
if (this.executing) {
|
|
207
209
|
await this.executing;
|
|
208
210
|
}
|
|
@@ -222,12 +224,19 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
222
224
|
}
|
|
223
225
|
}
|
|
224
226
|
trigger(workflow, context, options = {}) {
|
|
225
|
-
|
|
227
|
+
const logger = this.getLogger(workflow.id);
|
|
228
|
+
if (!this.ready) {
|
|
229
|
+
logger.warn(`app is not ready, event of workflow ${workflow.id} will be ignored`);
|
|
230
|
+
logger.debug(`ignored event data:`, { data: context });
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
if (context == null) {
|
|
234
|
+
logger.warn(`workflow ${workflow.id} event data context is null, event will be ignored`);
|
|
226
235
|
return;
|
|
227
236
|
}
|
|
228
237
|
this.events.push([workflow, context, options]);
|
|
229
|
-
|
|
230
|
-
|
|
238
|
+
logger.info(`new event triggered, now events: ${this.events.length}`);
|
|
239
|
+
logger.debug(`event data:`, {
|
|
231
240
|
data: context
|
|
232
241
|
});
|
|
233
242
|
if (this.events.length > 1) {
|
|
@@ -239,20 +248,18 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
239
248
|
if (!job.execution) {
|
|
240
249
|
job.execution = await job.getExecution();
|
|
241
250
|
}
|
|
251
|
+
this.getLogger(job.execution.workflowId).info(
|
|
252
|
+
`execution (${job.execution.id}) resuming from job (${job.id}) added to pending list`
|
|
253
|
+
);
|
|
242
254
|
this.pending.push([job.execution, job]);
|
|
243
255
|
this.dispatch();
|
|
244
256
|
}
|
|
245
257
|
createProcessor(execution, options = {}) {
|
|
246
258
|
return new import_Processor.default(execution, { ...options, plugin: this });
|
|
247
259
|
}
|
|
248
|
-
|
|
260
|
+
async createExecution(event) {
|
|
249
261
|
var _a;
|
|
250
|
-
const [event] = this.events;
|
|
251
|
-
if (!event) {
|
|
252
|
-
return;
|
|
253
|
-
}
|
|
254
262
|
const [workflow, context, options] = event;
|
|
255
|
-
let valid = true;
|
|
256
263
|
if ((_a = options.context) == null ? void 0 : _a.executionId) {
|
|
257
264
|
const existed = await workflow.countExecutions({
|
|
258
265
|
where: {
|
|
@@ -263,45 +270,55 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
263
270
|
this.getLogger(workflow.id).warn(
|
|
264
271
|
`workflow ${workflow.id} has already been triggered in same execution (${options.context.executionId}), and newly triggering will be skipped.`
|
|
265
272
|
);
|
|
266
|
-
|
|
273
|
+
return null;
|
|
267
274
|
}
|
|
268
275
|
}
|
|
269
|
-
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
+
const execution = await this.db.sequelize.transaction(async (transaction) => {
|
|
277
|
+
const execution2 = await workflow.createExecution(
|
|
278
|
+
{
|
|
279
|
+
context,
|
|
280
|
+
key: workflow.key,
|
|
281
|
+
status: import_constants.EXECUTION_STATUS.QUEUEING
|
|
282
|
+
},
|
|
283
|
+
{ transaction }
|
|
284
|
+
);
|
|
285
|
+
await workflow.increment(["executed", "allExecuted"], { transaction });
|
|
286
|
+
if (this.db.options.dialect !== "postgres") {
|
|
287
|
+
await workflow.reload({ transaction });
|
|
288
|
+
}
|
|
289
|
+
await workflow.constructor.update(
|
|
290
|
+
{
|
|
291
|
+
allExecuted: workflow.allExecuted
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
where: {
|
|
295
|
+
key: workflow.key
|
|
276
296
|
},
|
|
277
|
-
|
|
278
|
-
);
|
|
279
|
-
await workflow.increment(["executed", "allExecuted"], { transaction });
|
|
280
|
-
if (this.db.options.dialect !== "postgres") {
|
|
281
|
-
await workflow.reload({ transaction });
|
|
297
|
+
transaction
|
|
282
298
|
}
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
299
|
+
);
|
|
300
|
+
execution2.workflow = workflow;
|
|
301
|
+
return execution2;
|
|
302
|
+
});
|
|
303
|
+
this.getLogger(workflow.id).info(`execution of workflow ${workflow.id} created as ${execution.id}`);
|
|
304
|
+
if (!this.executing && !this.pending.length) {
|
|
305
|
+
this.pending.push([execution]);
|
|
306
|
+
}
|
|
307
|
+
return execution;
|
|
308
|
+
}
|
|
309
|
+
prepare = async () => {
|
|
310
|
+
const event = this.events.shift();
|
|
311
|
+
if (!event) {
|
|
312
|
+
this.getLogger("dispatcher").warn(`events queue is empty, no need to prepare`);
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const logger = this.getLogger(event[0].id);
|
|
316
|
+
logger.info(`preparing execution for event`);
|
|
317
|
+
try {
|
|
318
|
+
await this.createExecution(event);
|
|
319
|
+
} catch (err) {
|
|
320
|
+
logger.error(`failed to create execution: ${err.message}`, err);
|
|
303
321
|
}
|
|
304
|
-
this.events.shift();
|
|
305
322
|
if (this.events.length) {
|
|
306
323
|
await this.prepare();
|
|
307
324
|
} else {
|
|
@@ -309,7 +326,12 @@ class WorkflowPlugin extends import_server.Plugin {
|
|
|
309
326
|
}
|
|
310
327
|
};
|
|
311
328
|
dispatch() {
|
|
312
|
-
if (!this.ready
|
|
329
|
+
if (!this.ready) {
|
|
330
|
+
this.getLogger("dispatcher").warn(`app is not ready, new dispatching will be ignored`);
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
if (this.executing) {
|
|
334
|
+
this.getLogger("dispatcher").warn(`workflow executing is not finished, new dispatching will be ignored`);
|
|
313
335
|
return;
|
|
314
336
|
}
|
|
315
337
|
this.executing = (async () => {
|
package/dist/server/Processor.js
CHANGED
|
@@ -94,7 +94,7 @@ class Processor {
|
|
|
94
94
|
async start() {
|
|
95
95
|
const { execution } = this;
|
|
96
96
|
if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
|
|
97
|
-
throw new Error(`execution was ended with status ${execution.status}`);
|
|
97
|
+
throw new Error(`execution was ended with status ${execution.status} before, could not be started again`);
|
|
98
98
|
}
|
|
99
99
|
await this.prepare();
|
|
100
100
|
if (this.nodes.length) {
|
|
@@ -107,7 +107,7 @@ class Processor {
|
|
|
107
107
|
async resume(job) {
|
|
108
108
|
const { execution } = this;
|
|
109
109
|
if (execution.status !== import_constants.EXECUTION_STATUS.STARTED) {
|
|
110
|
-
throw new Error(`execution was ended with status ${execution.status}`);
|
|
110
|
+
throw new Error(`execution was ended with status ${execution.status} before, could not be resumed`);
|
|
111
111
|
}
|
|
112
112
|
await this.prepare();
|
|
113
113
|
const node = this.nodesMap.get(job.nodeId);
|
|
@@ -113,6 +113,7 @@ class manual_collection_block_default extends import_server.Migration {
|
|
|
113
113
|
}
|
|
114
114
|
const { db } = this.context;
|
|
115
115
|
const NodeRepo = db.getRepository("flow_nodes");
|
|
116
|
+
await NodeRepo.collection.sync();
|
|
116
117
|
await db.sequelize.transaction(async (transaction) => {
|
|
117
118
|
const nodes = await NodeRepo.find({
|
|
118
119
|
filter: {
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"displayName.zh-CN": "工作流",
|
|
5
5
|
"description": "A powerful workflow plugin designed to support business process management and automation.",
|
|
6
6
|
"description.zh-CN": "工作流插件,为业务流程管理和自动化提供支持。",
|
|
7
|
-
"version": "0.
|
|
7
|
+
"version": "0.18.0-alpha.1",
|
|
8
8
|
"license": "AGPL-3.0",
|
|
9
9
|
"main": "./dist/server/index.js",
|
|
10
10
|
"devDependencies": {
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@nocobase/test": "0.x",
|
|
43
43
|
"@nocobase/utils": "0.x"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "0f5f1c0a37dc397a9dc4c8eec0c4ec20fd8107b0"
|
|
46
46
|
}
|