@nocobase/plugin-workflow 1.9.70 → 1.9.74

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,8 +11,8 @@ 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.9.70",
15
- "@nocobase/utils": "1.9.70",
14
+ "@nocobase/client": "1.9.74",
15
+ "@nocobase/utils": "1.9.74",
16
16
  "antd": "5.24.2",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "react-router-dom": "6.28.1",
@@ -20,17 +20,17 @@ module.exports = {
20
20
  "lodash": "4.18.1",
21
21
  "@dnd-kit/core": "6.1.0",
22
22
  "@formily/shared": "2.3.2",
23
- "@nocobase/plugin-mobile": "1.9.70",
23
+ "@nocobase/plugin-mobile": "1.9.74",
24
24
  "sequelize": "6.35.2",
25
- "@nocobase/server": "1.9.70",
26
- "@nocobase/database": "1.9.70",
27
- "@nocobase/data-source-manager": "1.9.70",
28
- "@nocobase/logger": "1.9.70",
29
- "@nocobase/evaluators": "1.9.70",
25
+ "@nocobase/server": "1.9.74",
26
+ "@nocobase/database": "1.9.74",
27
+ "@nocobase/data-source-manager": "1.9.74",
28
+ "@nocobase/logger": "1.9.74",
29
+ "@nocobase/evaluators": "1.9.74",
30
30
  "@formily/antd-v5": "1.2.3",
31
31
  "@formily/reactive": "2.3.0",
32
- "@nocobase/actions": "1.9.70",
32
+ "@nocobase/actions": "1.9.74",
33
33
  "dayjs": "1.11.13",
34
- "@nocobase/plugin-workflow-test": "1.9.70",
35
- "@nocobase/test": "1.9.70"
34
+ "@nocobase/plugin-workflow-test": "1.9.74",
35
+ "@nocobase/test": "1.9.74"
36
36
  };
@@ -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":"2026-08-03T07:27:58.150Z"}
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":"2026-08-04T11:05:27.207Z"}
@@ -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":"2026-08-03T07:27:57.819Z"}
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":"2026-08-04T11:05:26.868Z"}
@@ -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":"2026-08-03T07:27:57.622Z"}
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":"2026-08-04T11:05:26.662Z"}
@@ -30,6 +30,7 @@ export default class Dispatcher {
30
30
  private readonly plugin;
31
31
  private ready;
32
32
  private executing;
33
+ private preparing;
33
34
  private pending;
34
35
  private events;
35
36
  private eventsCount;
@@ -39,16 +40,16 @@ export default class Dispatcher {
39
40
  setReady(ready: boolean): void;
40
41
  getEventsCount(): number;
41
42
  trigger(workflow: WorkflowModel, context: object, options?: EventOptions): void | Promise<Processor | null | void>;
43
+ private prepare;
42
44
  resume(job: any): Promise<void>;
43
45
  start(execution: ExecutionModel): Promise<void>;
44
46
  beforeStop(): Promise<void>;
45
- dispatch(): Promise<void>;
47
+ dispatch(): void;
46
48
  run(pending: Pending): Promise<void>;
47
49
  private triggerSync;
48
50
  private validateEvent;
49
51
  private handleTriggerFail;
50
52
  private createExecution;
51
- private prepare;
52
53
  private acquirePendingExecution;
53
54
  private acquireQueueingExecution;
54
55
  private acquireWithRetry;
@@ -29,7 +29,7 @@ __export(Dispatcher_exports, {
29
29
  default: () => Dispatcher
30
30
  });
31
31
  module.exports = __toCommonJS(Dispatcher_exports);
32
- var import_crypto = require("crypto");
32
+ var import_node_crypto = require("node:crypto");
33
33
  var import_sequelize = require("sequelize");
34
34
  var import_constants = require("./constants");
35
35
  var import_Plugin = require("./Plugin");
@@ -37,15 +37,15 @@ const EXECUTION_ACQUIRE_MAX_ATTEMPTS = 5;
37
37
  class Dispatcher {
38
38
  constructor(plugin) {
39
39
  this.plugin = plugin;
40
- this.prepare = this.prepare.bind(this);
41
40
  }
42
41
  ready = false;
43
42
  executing = null;
43
+ preparing = null;
44
44
  pending = [];
45
45
  events = [];
46
46
  eventsCount = 0;
47
47
  get idle() {
48
- return this.ready && !this.executing && !this.pending.length && !this.events.length;
48
+ return this.ready && !this.executing && !this.preparing && !this.pending.length && !this.events.length;
49
49
  }
50
50
  onQueueExecution = async (event) => {
51
51
  const ExecutionRepo = this.plugin.db.getRepository("executions");
@@ -97,11 +97,55 @@ class Dispatcher {
97
97
  this.eventsCount = this.events.length;
98
98
  logger.info(`new event triggered, now events: ${this.events.length}`);
99
99
  logger.debug(`event data:`, { context });
100
- if (this.events.length > 1) {
101
- logger.info(`new event is pending to be prepared after previous preparation is finished`);
100
+ this.prepare();
101
+ }
102
+ prepare() {
103
+ if (this.preparing) {
102
104
  return;
103
105
  }
104
- setImmediate(this.prepare);
106
+ this.preparing = (async () => {
107
+ try {
108
+ while (this.events.length) {
109
+ if (this.executing && this.plugin.db.options.dialect === "sqlite") {
110
+ await this.executing;
111
+ }
112
+ const event = this.events.shift();
113
+ this.eventsCount = this.events.length;
114
+ if (!event) continue;
115
+ const logger = this.plugin.getLogger(event[0].id);
116
+ logger.info(`preparing execution for event`);
117
+ try {
118
+ const execution = await this.createExecution(...event);
119
+ if (!(execution == null ? void 0 : execution.dispatched)) {
120
+ if (this.plugin.serving() && !this.executing && !this.pending.length) {
121
+ logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
122
+ this.pending.push({ execution });
123
+ } else {
124
+ logger.info(
125
+ `instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
126
+ );
127
+ try {
128
+ await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
129
+ executionId: execution.id
130
+ });
131
+ } catch (qErr) {
132
+ logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
133
+ }
134
+ }
135
+ }
136
+ } catch (error) {
137
+ logger.error(`failed to create execution:`, { error });
138
+ }
139
+ }
140
+ } finally {
141
+ this.preparing = null;
142
+ if (this.events.length) {
143
+ this.prepare();
144
+ } else {
145
+ this.dispatch();
146
+ }
147
+ }
148
+ })();
105
149
  }
106
150
  async resume(job) {
107
151
  let { execution } = job;
@@ -120,16 +164,26 @@ class Dispatcher {
120
164
  }
121
165
  async beforeStop() {
122
166
  this.ready = false;
123
- if (this.events.length) {
124
- await this.prepare();
125
- }
126
- if (this.executing) {
127
- await this.executing;
167
+ this.plugin.getLogger("dispatcher").info("app is stopping, draining local queues...");
168
+ while (this.preparing || this.executing || this.events.length || this.pending.length) {
169
+ if (this.preparing) {
170
+ await this.preparing;
171
+ }
172
+ if (this.executing) {
173
+ await this.executing;
174
+ }
175
+ if (this.events.length && !this.preparing) {
176
+ this.prepare();
177
+ }
178
+ if (this.pending.length && !this.executing) {
179
+ this.dispatch();
180
+ }
181
+ await new Promise((resolve) => setImmediate(resolve));
128
182
  }
183
+ this.plugin.getLogger("dispatcher").info("local queues drained");
129
184
  }
130
185
  dispatch() {
131
- if (!this.ready) {
132
- this.plugin.getLogger("dispatcher").warn(`app is not ready, new dispatching will be ignored`);
186
+ if (!this.ready && !this.pending.length && !this.events.length) {
133
187
  return;
134
188
  }
135
189
  if (this.executing) {
@@ -137,7 +191,8 @@ class Dispatcher {
137
191
  return;
138
192
  }
139
193
  if (this.events.length) {
140
- return this.prepare();
194
+ this.prepare();
195
+ return;
141
196
  }
142
197
  this.executing = (async () => {
143
198
  let next = null;
@@ -150,13 +205,15 @@ class Dispatcher {
150
205
  this.plugin.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
151
206
  }
152
207
  } else {
153
- if (this.plugin.serving()) {
208
+ if (this.ready && this.plugin.serving()) {
154
209
  execution = await this.acquireQueueingExecution();
155
210
  if (execution) {
156
211
  next = [execution];
157
212
  }
158
213
  } else {
159
- this.plugin.getLogger("dispatcher").warn(`${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance, new dispatching will be ignored`);
214
+ this.plugin.getLogger("dispatcher").warn(
215
+ `${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance or app not ready, new dispatching will be ignored`
216
+ );
160
217
  }
161
218
  }
162
219
  if (next) {
@@ -251,7 +308,7 @@ class Dispatcher {
251
308
  {
252
309
  context,
253
310
  key: workflow.key,
254
- eventKey: options.eventKey ?? (0, import_crypto.randomUUID)(),
311
+ eventKey: options.eventKey ?? (0, import_node_crypto.randomUUID)(),
255
312
  stack: options.stack,
256
313
  dispatched: deferred ?? false,
257
314
  status: deferred ? import_constants.EXECUTION_STATUS.STARTED : import_constants.EXECUTION_STATUS.QUEUEING,
@@ -287,50 +344,6 @@ class Dispatcher {
287
344
  execution.workflow = workflow;
288
345
  return execution;
289
346
  }
290
- prepare = async () => {
291
- if (this.executing && this.plugin.db.options.dialect === "sqlite") {
292
- await this.executing;
293
- }
294
- const event = this.events.shift();
295
- this.eventsCount = this.events.length;
296
- if (!event) {
297
- this.plugin.getLogger("dispatcher").info(`events queue is empty, no need to prepare`);
298
- return;
299
- }
300
- const logger = this.plugin.getLogger(event[0].id);
301
- logger.info(`preparing execution for event`);
302
- try {
303
- const execution = await this.createExecution(...event);
304
- if (!(execution == null ? void 0 : execution.dispatched)) {
305
- if (this.plugin.serving() && !this.executing && !this.pending.length) {
306
- logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
307
- this.pending.push({ execution });
308
- } else {
309
- logger.info(
310
- `instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
311
- );
312
- try {
313
- await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
314
- executionId: execution.id
315
- });
316
- } catch (qErr) {
317
- logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
318
- }
319
- }
320
- }
321
- } catch (error) {
322
- logger.error(`failed to create execution:`, { error });
323
- }
324
- if (this.events.length) {
325
- await this.prepare();
326
- } else {
327
- this.plugin.getLogger("dispatcher").info("no more events need to be prepared, dispatching...");
328
- if (this.executing) {
329
- await this.executing;
330
- }
331
- this.dispatch();
332
- }
333
- };
334
347
  async acquirePendingExecution(execution) {
335
348
  const logger = this.plugin.getLogger(execution.workflowId);
336
349
  const isolationLevel = this.plugin.db.options.dialect === "sqlite" ? [][0] : import_sequelize.Transaction.ISOLATION_LEVELS.REPEATABLE_READ;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "A powerful BPM tool that provides foundational support for business automation, with the capability to extend unlimited triggers and nodes.",
7
7
  "description.zh-CN": "一个强大的 BPM 工具,为业务自动化提供基础支持,并且可任意扩展更多的触发器和节点。",
8
8
  "description.ru-RU": "Мощный инструмент BPM, обеспечивающий базовую поддержку автоматизации бизнес-процессов с возможностью неограниченного расширения триггеров и узлов.",
9
- "version": "1.9.70",
9
+ "version": "1.9.74",
10
10
  "license": "AGPL-3.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/handbook/workflow",
@@ -48,7 +48,7 @@
48
48
  "@nocobase/test": "1.x",
49
49
  "@nocobase/utils": "1.x"
50
50
  },
51
- "gitHead": "9e2cb3553be10b8ea595f4c907272adb23f86043",
51
+ "gitHead": "521bc1b1f74671103e04f8a33ebc087dc13f0000",
52
52
  "keywords": [
53
53
  "Workflow"
54
54
  ]