@nocobase/plugin-workflow 2.0.18 → 2.0.19

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.7",
13
13
  "@formily/react": "2.3.7",
14
- "@nocobase/client": "2.0.18",
15
- "@nocobase/utils": "2.0.18",
14
+ "@nocobase/client": "2.0.19",
15
+ "@nocobase/utils": "2.0.19",
16
16
  "antd": "5.24.2",
17
17
  "@ant-design/icons": "5.6.1",
18
18
  "react-router-dom": "6.30.1",
@@ -20,18 +20,18 @@ module.exports = {
20
20
  "lodash": "4.17.21",
21
21
  "@dnd-kit/core": "6.1.0",
22
22
  "@formily/shared": "2.3.7",
23
- "@nocobase/flow-engine": "2.0.18",
24
- "@nocobase/plugin-mobile": "2.0.18",
23
+ "@nocobase/flow-engine": "2.0.19",
24
+ "@nocobase/plugin-mobile": "2.0.19",
25
25
  "sequelize": "6.35.2",
26
- "@nocobase/server": "2.0.18",
27
- "@nocobase/database": "2.0.18",
28
- "@nocobase/data-source-manager": "2.0.18",
29
- "@nocobase/logger": "2.0.18",
30
- "@nocobase/evaluators": "2.0.18",
26
+ "@nocobase/server": "2.0.19",
27
+ "@nocobase/database": "2.0.19",
28
+ "@nocobase/data-source-manager": "2.0.19",
29
+ "@nocobase/logger": "2.0.19",
30
+ "@nocobase/evaluators": "2.0.19",
31
31
  "@formily/antd-v5": "1.2.3",
32
32
  "@formily/reactive": "2.3.7",
33
- "@nocobase/actions": "2.0.18",
33
+ "@nocobase/actions": "2.0.19",
34
34
  "dayjs": "1.11.13",
35
- "@nocobase/plugin-workflow-test": "2.0.18",
36
- "@nocobase/test": "2.0.18"
35
+ "@nocobase/plugin-workflow-test": "2.0.19",
36
+ "@nocobase/test": "2.0.19"
37
37
  };
@@ -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-03-17T03:09:46.166Z"}
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-03-17T17:17:57.623Z"}
@@ -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-03-17T03:09:45.810Z"}
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-03-17T17:17:57.266Z"}
@@ -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-03-17T03:09:45.620Z"}
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-03-17T17:17:57.072Z"}
@@ -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,15 +40,15 @@ 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>;
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 createExecution;
50
- private prepare;
51
52
  private acquirePendingExecution;
52
53
  private acquireQueueingExecution;
53
54
  private process;
@@ -29,22 +29,22 @@ __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");
36
36
  class Dispatcher {
37
37
  constructor(plugin) {
38
38
  this.plugin = plugin;
39
- this.prepare = this.prepare.bind(this);
40
39
  }
41
40
  ready = false;
42
41
  executing = null;
42
+ preparing = null;
43
43
  pending = [];
44
44
  events = [];
45
45
  eventsCount = 0;
46
46
  get idle() {
47
- return this.ready && !this.executing && !this.pending.length && !this.events.length;
47
+ return this.ready && !this.executing && !this.preparing && !this.pending.length && !this.events.length;
48
48
  }
49
49
  onQueueExecution = async (event) => {
50
50
  const ExecutionRepo = this.plugin.db.getRepository("executions");
@@ -96,11 +96,55 @@ class Dispatcher {
96
96
  this.eventsCount = this.events.length;
97
97
  logger.info(`new event triggered, now events: ${this.events.length}`);
98
98
  logger.debug(`event data:`, { context });
99
- if (this.events.length > 1) {
100
- logger.info(`new event is pending to be prepared after previous preparation is finished`);
99
+ this.prepare();
100
+ }
101
+ prepare() {
102
+ if (this.preparing) {
101
103
  return;
102
104
  }
103
- setImmediate(this.prepare);
105
+ this.preparing = (async () => {
106
+ try {
107
+ while (this.events.length) {
108
+ if (this.executing && this.plugin.db.options.dialect === "sqlite") {
109
+ await this.executing;
110
+ }
111
+ const event = this.events.shift();
112
+ this.eventsCount = this.events.length;
113
+ if (!event) continue;
114
+ const logger = this.plugin.getLogger(event[0].id);
115
+ logger.info(`preparing execution for event`);
116
+ try {
117
+ const execution = await this.createExecution(...event);
118
+ if (!(execution == null ? void 0 : execution.dispatched)) {
119
+ if (this.plugin.serving() && !this.executing && !this.pending.length) {
120
+ logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
121
+ this.pending.push({ execution });
122
+ } else {
123
+ logger.info(
124
+ `instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
125
+ );
126
+ try {
127
+ await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
128
+ executionId: execution.id
129
+ });
130
+ } catch (qErr) {
131
+ logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
132
+ }
133
+ }
134
+ }
135
+ } catch (error) {
136
+ logger.error(`failed to create execution:`, { error });
137
+ }
138
+ }
139
+ } finally {
140
+ this.preparing = null;
141
+ if (this.events.length) {
142
+ this.prepare();
143
+ } else {
144
+ this.dispatch();
145
+ }
146
+ }
147
+ })();
104
148
  }
105
149
  async resume(job) {
106
150
  let { execution } = job;
@@ -119,16 +163,26 @@ class Dispatcher {
119
163
  }
120
164
  async beforeStop() {
121
165
  this.ready = false;
122
- if (this.events.length) {
123
- await this.prepare();
124
- }
125
- if (this.executing) {
126
- await this.executing;
166
+ this.plugin.getLogger("dispatcher").info("app is stopping, draining local queues...");
167
+ while (this.preparing || this.executing || this.events.length || this.pending.length) {
168
+ if (this.preparing) {
169
+ await this.preparing;
170
+ }
171
+ if (this.executing) {
172
+ await this.executing;
173
+ }
174
+ if (this.events.length && !this.preparing) {
175
+ this.prepare();
176
+ }
177
+ if (this.pending.length && !this.executing) {
178
+ this.dispatch();
179
+ }
180
+ await new Promise((resolve) => setImmediate(resolve));
127
181
  }
182
+ this.plugin.getLogger("dispatcher").info("local queues drained");
128
183
  }
129
184
  dispatch() {
130
- if (!this.ready) {
131
- this.plugin.getLogger("dispatcher").warn(`app is not ready, new dispatching will be ignored`);
185
+ if (!this.ready && !this.pending.length && !this.events.length) {
132
186
  return;
133
187
  }
134
188
  if (this.executing) {
@@ -136,7 +190,8 @@ class Dispatcher {
136
190
  return;
137
191
  }
138
192
  if (this.events.length) {
139
- return this.prepare();
193
+ this.prepare();
194
+ return;
140
195
  }
141
196
  this.executing = (async () => {
142
197
  let next = null;
@@ -149,13 +204,15 @@ class Dispatcher {
149
204
  this.plugin.getLogger(next[0].workflowId).info(`pending execution (${next[0].id}) ready to process`);
150
205
  }
151
206
  } else {
152
- if (this.plugin.serving()) {
207
+ if (this.ready && this.plugin.serving()) {
153
208
  execution = await this.acquireQueueingExecution();
154
209
  if (execution) {
155
210
  next = [execution];
156
211
  }
157
212
  } else {
158
- this.plugin.getLogger("dispatcher").warn(`${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance, new dispatching will be ignored`);
213
+ this.plugin.getLogger("dispatcher").warn(
214
+ `${import_Plugin.WORKER_JOB_WORKFLOW_PROCESS} is not serving on this instance or app not ready, new dispatching will be ignored`
215
+ );
159
216
  }
160
217
  }
161
218
  if (next) {
@@ -233,7 +290,7 @@ class Dispatcher {
233
290
  {
234
291
  context,
235
292
  key: workflow.key,
236
- eventKey: options.eventKey ?? (0, import_crypto.randomUUID)(),
293
+ eventKey: options.eventKey ?? (0, import_node_crypto.randomUUID)(),
237
294
  stack: options.stack,
238
295
  dispatched: deferred ?? false,
239
296
  status: deferred ? import_constants.EXECUTION_STATUS.STARTED : import_constants.EXECUTION_STATUS.QUEUEING,
@@ -268,50 +325,6 @@ class Dispatcher {
268
325
  execution.workflow = workflow;
269
326
  return execution;
270
327
  }
271
- prepare = async () => {
272
- if (this.executing && this.plugin.db.options.dialect === "sqlite") {
273
- await this.executing;
274
- }
275
- const event = this.events.shift();
276
- this.eventsCount = this.events.length;
277
- if (!event) {
278
- this.plugin.getLogger("dispatcher").info(`events queue is empty, no need to prepare`);
279
- return;
280
- }
281
- const logger = this.plugin.getLogger(event[0].id);
282
- logger.info(`preparing execution for event`);
283
- try {
284
- const execution = await this.createExecution(...event);
285
- if (!(execution == null ? void 0 : execution.dispatched)) {
286
- if (this.plugin.serving() && !this.executing && !this.pending.length) {
287
- logger.info(`local pending list is empty, adding execution (${execution.id}) to pending list`);
288
- this.pending.push({ execution });
289
- } else {
290
- logger.info(
291
- `instance is not serving as worker or local pending list is not empty, sending execution (${execution.id}) to queue`
292
- );
293
- try {
294
- await this.plugin.app.eventQueue.publish(this.plugin.channelPendingExecution, {
295
- executionId: execution.id
296
- });
297
- } catch (qErr) {
298
- logger.error(`publishing execution (${execution.id}) to queue failed:`, { error: qErr });
299
- }
300
- }
301
- }
302
- } catch (error) {
303
- logger.error(`failed to create execution:`, { error });
304
- }
305
- if (this.events.length) {
306
- await this.prepare();
307
- } else {
308
- this.plugin.getLogger("dispatcher").info("no more events need to be prepared, dispatching...");
309
- if (this.executing) {
310
- await this.executing;
311
- }
312
- this.dispatch();
313
- }
314
- };
315
328
  async acquirePendingExecution(execution) {
316
329
  const logger = this.plugin.getLogger(execution.workflowId);
317
330
  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": "2.0.18",
9
+ "version": "2.0.19",
10
10
  "license": "Apache-2.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": "2.x",
49
49
  "@nocobase/utils": "2.x"
50
50
  },
51
- "gitHead": "f93082fd2c15618fe85e697a9cdd90614371732e",
51
+ "gitHead": "0b865bb88a155478d45ea0178b14d76d5250f4b8",
52
52
  "keywords": [
53
53
  "Workflow"
54
54
  ]