@nocobase/plugin-workflow 1.7.0-beta.15 → 1.7.0-beta.16

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.
@@ -11,24 +11,24 @@ module.exports = {
11
11
  "react": "18.2.0",
12
12
  "@formily/core": "2.3.0",
13
13
  "@formily/react": "2.3.0",
14
- "@nocobase/client": "1.7.0-beta.15",
15
- "@nocobase/utils": "1.7.0-beta.15",
14
+ "@nocobase/client": "1.7.0-beta.16",
15
+ "@nocobase/utils": "1.7.0-beta.16",
16
16
  "antd": "5.24.2",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "react-router-dom": "6.28.1",
19
19
  "react-i18next": "11.18.6",
20
20
  "lodash": "4.17.21",
21
21
  "sequelize": "6.35.2",
22
- "@nocobase/database": "1.7.0-beta.15",
23
- "@nocobase/server": "1.7.0-beta.15",
24
- "@nocobase/data-source-manager": "1.7.0-beta.15",
25
- "@nocobase/logger": "1.7.0-beta.15",
26
- "@nocobase/evaluators": "1.7.0-beta.15",
22
+ "@nocobase/database": "1.7.0-beta.16",
23
+ "@nocobase/server": "1.7.0-beta.16",
24
+ "@nocobase/data-source-manager": "1.7.0-beta.16",
25
+ "@nocobase/logger": "1.7.0-beta.16",
26
+ "@nocobase/evaluators": "1.7.0-beta.16",
27
27
  "@formily/antd-v5": "1.2.3",
28
28
  "@formily/reactive": "2.3.0",
29
29
  "@formily/shared": "2.3.2",
30
- "@nocobase/actions": "1.7.0-beta.15",
30
+ "@nocobase/actions": "1.7.0-beta.16",
31
31
  "dayjs": "1.11.13",
32
- "@nocobase/plugin-workflow-test": "1.7.0-beta.15",
33
- "@nocobase/test": "1.7.0-beta.15"
32
+ "@nocobase/plugin-workflow-test": "1.7.0-beta.16",
33
+ "@nocobase/test": "1.7.0-beta.16"
34
34
  };
@@ -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":"2025-04-10T03:42:36.413Z"}
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":"2025-04-11T17:09:13.880Z"}
@@ -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":"2025-04-10T03:42:36.067Z"}
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":"2025-04-11T17:09:13.517Z"}
@@ -1 +1 @@
1
- {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2025-04-10T03:42:35.872Z"}
1
+ {"name":"nodejs-snowflake","collaborators":["Utkarsh Srivastava <utkarsh@sagacious.dev>"],"description":"Generate time sortable 64 bits unique ids for distributed systems (inspired from twitter snowflake)","version":"2.0.1","license":"Apache 2.0","repository":{"type":"git","url":"https://github.com/utkarsh-pro/nodejs-snowflake.git"},"files":["nodejs_snowflake_bg.wasm","nodejs_snowflake.js","nodejs_snowflake.d.ts"],"main":"nodejs_snowflake.js","types":"nodejs_snowflake.d.ts","_lastModified":"2025-04-11T17:09:13.294Z"}
@@ -42,6 +42,11 @@ export default class PluginWorkflowServer extends Plugin {
42
42
  private meter;
43
43
  private checker;
44
44
  private onBeforeSave;
45
+ private onAfterCreate;
46
+ private onAfterUpdate;
47
+ private onAfterDestroy;
48
+ private onAfterStart;
49
+ private onBeforeStop;
45
50
  handleSyncMessage(message: any): Promise<void>;
46
51
  /**
47
52
  * @experimental
@@ -108,6 +108,80 @@ class PluginWorkflowServer extends import_server.Plugin {
108
108
  this.toggle(previous, false, { transaction });
109
109
  }
110
110
  };
111
+ onAfterCreate = async (model, { transaction }) => {
112
+ const WorkflowStatsModel = this.db.getModel("workflowStats");
113
+ const [stats, created] = await WorkflowStatsModel.findOrCreate({
114
+ where: { key: model.key },
115
+ defaults: { key: model.key },
116
+ transaction
117
+ });
118
+ model.stats = stats;
119
+ model.versionStats = await model.createVersionStats({ id: model.id }, { transaction });
120
+ if (model.enabled) {
121
+ this.toggle(model, true, { transaction });
122
+ }
123
+ };
124
+ onAfterUpdate = async (model, { transaction }) => {
125
+ model.stats = await model.getStats({ transaction });
126
+ model.versionStats = await model.getVersionStats({ transaction });
127
+ this.toggle(model, model.enabled, { transaction });
128
+ };
129
+ onAfterDestroy = async (model, { transaction }) => {
130
+ this.toggle(model, false, { transaction });
131
+ const TaskRepo = this.db.getRepository("workflowTasks");
132
+ await TaskRepo.destroy({
133
+ filter: {
134
+ workflowId: model.id
135
+ },
136
+ transaction
137
+ });
138
+ };
139
+ // [Life Cycle]:
140
+ // * load all workflows in db
141
+ // * add all hooks for enabled workflows
142
+ // * add hooks for create/update[enabled]/delete workflow to add/remove specific hooks
143
+ onAfterStart = async () => {
144
+ this.ready = true;
145
+ const collection = this.db.getCollection("workflows");
146
+ const workflows = await collection.repository.find({
147
+ filter: { enabled: true },
148
+ appends: ["stats", "versionStats"]
149
+ });
150
+ for (const workflow of workflows) {
151
+ if (!workflow.stats) {
152
+ workflow.stats = await workflow.createStats({ executed: 0 });
153
+ }
154
+ if (!workflow.versionStats) {
155
+ workflow.versionStats = await workflow.createVersionStats({ executed: 0 });
156
+ }
157
+ this.toggle(workflow, true, { silent: true });
158
+ }
159
+ this.checker = setInterval(() => {
160
+ this.getLogger("dispatcher").info(`(cycling) check for queueing executions`);
161
+ this.dispatch();
162
+ }, 3e5);
163
+ this.app.on("workflow:dispatch", () => {
164
+ this.app.logger.info("workflow:dispatch");
165
+ this.dispatch();
166
+ });
167
+ this.getLogger("dispatcher").info("(starting) check for queueing executions");
168
+ this.dispatch();
169
+ };
170
+ onBeforeStop = async () => {
171
+ for (const workflow of this.enabledCache.values()) {
172
+ this.toggle(workflow, false, { silent: true });
173
+ }
174
+ this.ready = false;
175
+ if (this.events.length) {
176
+ await this.prepare();
177
+ }
178
+ if (this.executing) {
179
+ await this.executing;
180
+ }
181
+ if (this.checker) {
182
+ clearInterval(this.checker);
183
+ }
184
+ };
111
185
  async handleSyncMessage(message) {
112
186
  if (message.type === "statusChange") {
113
187
  if (message.enabled) {
@@ -259,69 +333,11 @@ class PluginWorkflowServer extends import_server.Plugin {
259
333
  }
260
334
  });
261
335
  db.on("workflows.beforeSave", this.onBeforeSave);
262
- db.on("workflows.afterCreate", async (model, { transaction }) => {
263
- const WorkflowStatsModel = this.db.getModel("workflowStats");
264
- const [stats, created] = await WorkflowStatsModel.findOrCreate({
265
- where: { key: model.key },
266
- defaults: { key: model.key },
267
- transaction
268
- });
269
- model.stats = stats;
270
- model.versionStats = await model.createVersionStats({ id: model.id }, { transaction });
271
- if (model.enabled) {
272
- this.toggle(model, true, { transaction });
273
- }
274
- });
275
- db.on("workflows.afterUpdate", async (model, { transaction }) => {
276
- model.stats = await model.getStats({ transaction });
277
- model.versionStats = await model.getVersionStats({ transaction });
278
- this.toggle(model, model.enabled, { transaction });
279
- });
280
- db.on("workflows.afterDestroy", async (model, { transaction }) => {
281
- this.toggle(model, false, { transaction });
282
- const TaskRepo = this.db.getRepository("workflowTasks");
283
- await TaskRepo.destroy({
284
- filter: {
285
- workflowId: model.id
286
- },
287
- transaction
288
- });
289
- });
290
- this.app.on("afterStart", async () => {
291
- this.ready = true;
292
- const collection = db.getCollection("workflows");
293
- const workflows = await collection.repository.find({
294
- filter: { enabled: true }
295
- });
296
- workflows.forEach((workflow) => {
297
- this.toggle(workflow, true, { silent: true });
298
- });
299
- this.checker = setInterval(() => {
300
- this.getLogger("dispatcher").info(`(cycling) check for queueing executions`);
301
- this.dispatch();
302
- }, 3e5);
303
- this.app.on("workflow:dispatch", () => {
304
- this.app.logger.info("workflow:dispatch");
305
- this.dispatch();
306
- });
307
- this.getLogger("dispatcher").info("(starting) check for queueing executions");
308
- this.dispatch();
309
- });
310
- this.app.on("beforeStop", async () => {
311
- for (const workflow of this.enabledCache.values()) {
312
- this.toggle(workflow, false, { silent: true });
313
- }
314
- this.ready = false;
315
- if (this.events.length) {
316
- await this.prepare();
317
- }
318
- if (this.executing) {
319
- await this.executing;
320
- }
321
- if (this.checker) {
322
- clearInterval(this.checker);
323
- }
324
- });
336
+ db.on("workflows.afterCreate", this.onAfterCreate);
337
+ db.on("workflows.afterUpdate", this.onAfterUpdate);
338
+ db.on("workflows.afterDestroy", this.onAfterDestroy);
339
+ this.app.on("afterStart", this.onAfterStart);
340
+ this.app.on("beforeStop", this.onBeforeStop);
325
341
  }
326
342
  toggle(workflow, enable, { silent, transaction } = {}) {
327
343
  const type = workflow.get("type");
package/package.json CHANGED
@@ -4,13 +4,13 @@
4
4
  "displayName.zh-CN": "工作流",
5
5
  "description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
6
6
  "description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
7
- "version": "1.7.0-beta.15",
7
+ "version": "1.7.0-beta.16",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow",
11
11
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/workflow",
12
12
  "dependencies": {
13
- "@nocobase/plugin-workflow-test": "1.7.0-beta.15"
13
+ "@nocobase/plugin-workflow-test": "1.7.0-beta.16"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@ant-design/icons": "5.x",
@@ -45,7 +45,7 @@
45
45
  "@nocobase/test": "1.x",
46
46
  "@nocobase/utils": "1.x"
47
47
  },
48
- "gitHead": "b0792740852a55981b2f23ad622faeee332cf678",
48
+ "gitHead": "cc3f336b5ab6e0180cfcfb7642181b955f2b8b2a",
49
49
  "keywords": [
50
50
  "Workflow"
51
51
  ]