@nocobase/plugin-workflow 1.6.14 → 1.6.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.
@@ -7,7 +7,8 @@
7
7
  * For more information, please refer to: https://www.nocobase.com/agreement.
8
8
  */
9
9
  import React from 'react';
10
- export declare function RepeatField({ value, onChange }: {
10
+ export declare function RepeatField({ value, onChange, disabled }: {
11
11
  value?: any;
12
12
  onChange: any;
13
+ disabled: any;
13
14
  }): React.JSX.Element;
@@ -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.6.14",
15
- "@nocobase/utils": "1.6.14",
14
+ "@nocobase/client": "1.6.16",
15
+ "@nocobase/utils": "1.6.16",
16
16
  "antd": "5.12.8",
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.6.14",
23
- "@nocobase/server": "1.6.14",
24
- "@nocobase/data-source-manager": "1.6.14",
25
- "@nocobase/logger": "1.6.14",
26
- "@nocobase/evaluators": "1.6.14",
22
+ "@nocobase/database": "1.6.16",
23
+ "@nocobase/server": "1.6.16",
24
+ "@nocobase/data-source-manager": "1.6.16",
25
+ "@nocobase/logger": "1.6.16",
26
+ "@nocobase/evaluators": "1.6.16",
27
27
  "@formily/antd-v5": "1.1.9",
28
28
  "@formily/reactive": "2.3.0",
29
29
  "@formily/shared": "2.3.2",
30
- "@nocobase/actions": "1.6.14",
30
+ "@nocobase/actions": "1.6.16",
31
31
  "dayjs": "1.11.10",
32
- "@nocobase/plugin-workflow-test": "1.6.14",
33
- "@nocobase/test": "1.6.14"
32
+ "@nocobase/plugin-workflow-test": "1.6.16",
33
+ "@nocobase/test": "1.6.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-03-29T03:59:33.890Z"}
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-03T07:52:03.107Z"}
@@ -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-03-29T03:59:33.536Z"}
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-03T07:52:02.728Z"}
@@ -317,11 +317,14 @@ class PluginWorkflowServer extends import_server.Plugin {
317
317
  const prev = workflow.previous();
318
318
  if (prev.config) {
319
319
  trigger.off({ ...workflow.get(), ...prev });
320
+ this.getLogger(workflow.id).info(`toggle OFF workflow ${workflow.id} based on configuration before updated`);
320
321
  }
321
322
  trigger.on(workflow);
323
+ this.getLogger(workflow.id).info(`toggle ON workflow ${workflow.id}`);
322
324
  this.enabledCache.set(workflow.id, workflow);
323
325
  } else {
324
326
  trigger.off(workflow);
327
+ this.getLogger(workflow.id).info(`toggle OFF workflow ${workflow.id}`);
325
328
  this.enabledCache.delete(workflow.id);
326
329
  }
327
330
  if (!silent) {
@@ -27,9 +27,11 @@ export default class DateFieldScheduleTrigger {
27
27
  private timer;
28
28
  private cache;
29
29
  cacheCycle: number;
30
+ onAfterStart: () => void;
31
+ onBeforeStop: () => void;
30
32
  constructor(workflow: Plugin);
31
- reload(): Promise<void>;
32
- inspect(workflows: WorkflowModel[]): void;
33
+ reload(): void;
34
+ inspect(workflow: WorkflowModel): Promise<void>;
33
35
  loadRecordsToSchedule({ id, config: { collection, limit, startsOn, repeat, endsOn }, allExecuted }: WorkflowModel, currentDate: Date): Promise<import("@nocobase/database").Model<any, any>[]>;
34
36
  getRecordNextTime(workflow: WorkflowModel, record: any, nextSecond?: boolean): any;
35
37
  schedule(workflow: WorkflowModel, record: any, nextTime: any, toggle?: boolean, options?: {}): Promise<void>;
@@ -99,44 +99,49 @@ function getHookId(workflow, type) {
99
99
  class DateFieldScheduleTrigger {
100
100
  constructor(workflow) {
101
101
  this.workflow = workflow;
102
- workflow.app.on("afterStart", async () => {
103
- if (this.timer) {
104
- return;
105
- }
106
- this.timer = setInterval(() => this.reload(), this.cacheCycle);
107
- this.reload();
108
- });
109
- workflow.app.on("beforeStop", () => {
110
- if (this.timer) {
111
- clearInterval(this.timer);
112
- }
113
- for (const [key, timer] of this.cache.entries()) {
114
- clearTimeout(timer);
115
- this.cache.delete(key);
116
- }
117
- });
102
+ workflow.app.on("afterStart", this.onAfterStart);
103
+ workflow.app.on("beforeStop", this.onBeforeStop);
118
104
  }
119
105
  events = /* @__PURE__ */ new Map();
120
106
  timer = null;
121
107
  cache = /* @__PURE__ */ new Map();
122
108
  // caching workflows in range, default to 5min
123
109
  cacheCycle = 3e5;
124
- async reload() {
110
+ onAfterStart = () => {
111
+ if (this.timer) {
112
+ return;
113
+ }
114
+ this.timer = setInterval(() => this.reload(), this.cacheCycle);
115
+ this.reload();
116
+ };
117
+ onBeforeStop = () => {
118
+ if (this.timer) {
119
+ clearInterval(this.timer);
120
+ }
121
+ for (const [key, timer] of this.cache.entries()) {
122
+ clearTimeout(timer);
123
+ this.cache.delete(key);
124
+ }
125
+ };
126
+ reload() {
127
+ for (const [key, timer] of this.cache.entries()) {
128
+ clearTimeout(timer);
129
+ this.cache.delete(key);
130
+ }
125
131
  const workflows = Array.from(this.workflow.enabledCache.values()).filter(
126
132
  (item) => item.type === "schedule" && item.config.mode === import_utils.SCHEDULE_MODE.DATE_FIELD
127
133
  );
128
- this.cache = /* @__PURE__ */ new Map();
129
- this.inspect(workflows);
134
+ workflows.forEach((workflow) => {
135
+ this.inspect(workflow);
136
+ });
130
137
  }
131
- inspect(workflows) {
138
+ async inspect(workflow) {
132
139
  const now = /* @__PURE__ */ new Date();
133
- workflows.forEach(async (workflow) => {
134
- const records = await this.loadRecordsToSchedule(workflow, now);
135
- this.workflow.getLogger(workflow.id).info(`[Schedule on date field] ${records.length} records to schedule`);
136
- records.forEach((record) => {
137
- const nextTime = this.getRecordNextTime(workflow, record);
138
- this.schedule(workflow, record, nextTime, Boolean(nextTime));
139
- });
140
+ const records = await this.loadRecordsToSchedule(workflow, now);
141
+ this.workflow.getLogger(workflow.id).info(`[Schedule on date field] ${records.length} records to schedule`);
142
+ records.forEach((record) => {
143
+ const nextTime = this.getRecordNextTime(workflow, record);
144
+ this.schedule(workflow, record, nextTime, Boolean(nextTime));
140
145
  });
141
146
  }
142
147
  // 1. startsOn in range -> yes
@@ -210,8 +215,6 @@ class DateFieldScheduleTrigger {
210
215
  [import_database.Op.gte]: new Date(endTimestamp)
211
216
  }
212
217
  });
213
- } else {
214
- this.workflow.getLogger(id).warn(`[Schedule on date field] "endsOn.field" is not configured`);
215
218
  }
216
219
  }
217
220
  }
@@ -333,7 +336,7 @@ class DateFieldScheduleTrigger {
333
336
  }
334
337
  }
335
338
  on(workflow) {
336
- this.inspect([workflow]);
339
+ this.inspect(workflow);
337
340
  const { collection } = workflow.config;
338
341
  const [dataSourceName, collectionName] = (0, import_data_source_manager.parseCollectionName)(collection);
339
342
  const event = `${collectionName}.afterSaveWithAssociations`;
@@ -11,8 +11,10 @@ import { WorkflowModel } from '../../types';
11
11
  export default class StaticScheduleTrigger {
12
12
  workflow: Plugin;
13
13
  private timers;
14
+ onAfterStart: () => void;
15
+ onBeforeStop: () => void;
14
16
  constructor(workflow: Plugin);
15
- inspect(workflows: WorkflowModel[]): void;
17
+ inspect(workflow: WorkflowModel): void;
16
18
  getNextTime({ config, allExecuted }: WorkflowModel, currentDate: Date, nextSecond?: boolean): number;
17
19
  schedule(workflow: WorkflowModel, nextTime: number, toggle?: boolean): void;
18
20
  trigger(workflow: WorkflowModel, time: number): Promise<void>;
@@ -45,30 +45,32 @@ const MAX_SAFE_INTERVAL = 2147483647;
45
45
  class StaticScheduleTrigger {
46
46
  constructor(workflow) {
47
47
  this.workflow = workflow;
48
- workflow.app.on("afterStart", async () => {
49
- const workflows = Array.from(this.workflow.enabledCache.values()).filter(
50
- (item) => item.type === "schedule" && item.config.mode === import_utils.SCHEDULE_MODE.STATIC
51
- );
52
- this.inspect(workflows);
53
- });
54
- workflow.app.on("beforeStop", () => {
55
- for (const timer of this.timers.values()) {
56
- clearInterval(timer);
57
- }
58
- });
48
+ workflow.app.on("afterStart", this.onAfterStart);
49
+ workflow.app.on("beforeStop", this.onBeforeStop);
59
50
  }
60
51
  timers = /* @__PURE__ */ new Map();
61
- inspect(workflows) {
62
- const now = /* @__PURE__ */ new Date();
52
+ onAfterStart = () => {
53
+ const workflows = Array.from(this.workflow.enabledCache.values()).filter(
54
+ (item) => item.type === "schedule" && item.config.mode === import_utils.SCHEDULE_MODE.STATIC
55
+ );
63
56
  workflows.forEach((workflow) => {
64
- const nextTime = this.getNextTime(workflow, now);
65
- if (nextTime) {
66
- this.workflow.getLogger(workflow.id).info(`caching scheduled workflow will run at: ${new Date(nextTime).toISOString()}`);
67
- } else {
68
- this.workflow.getLogger(workflow.id).info("workflow will not be scheduled");
69
- }
70
- this.schedule(workflow, nextTime, nextTime >= now.getTime());
57
+ this.inspect(workflow);
71
58
  });
59
+ };
60
+ onBeforeStop = () => {
61
+ for (const timer of this.timers.values()) {
62
+ clearInterval(timer);
63
+ }
64
+ };
65
+ inspect(workflow) {
66
+ const now = /* @__PURE__ */ new Date();
67
+ const nextTime = this.getNextTime(workflow, now);
68
+ if (nextTime) {
69
+ this.workflow.getLogger(workflow.id).info(`caching scheduled workflow will run at: ${new Date(nextTime).toISOString()}`);
70
+ } else {
71
+ this.workflow.getLogger(workflow.id).info("workflow will not be scheduled");
72
+ }
73
+ this.schedule(workflow, nextTime, nextTime >= now.getTime());
72
74
  }
73
75
  getNextTime({ config, allExecuted }, currentDate, nextSecond = false) {
74
76
  if (config.limit && allExecuted >= config.limit) {
@@ -144,7 +146,7 @@ class StaticScheduleTrigger {
144
146
  }
145
147
  }
146
148
  on(workflow) {
147
- this.inspect([workflow]);
149
+ this.inspect(workflow);
148
150
  }
149
151
  off(workflow) {
150
152
  this.schedule(workflow, null, false);
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.6.14",
7
+ "version": "1.6.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.6.14"
13
+ "@nocobase/plugin-workflow-test": "1.6.16"
14
14
  },
15
15
  "devDependencies": {
16
16
  "@ant-design/icons": "5.x",
@@ -44,7 +44,7 @@
44
44
  "@nocobase/test": "1.x",
45
45
  "@nocobase/utils": "1.x"
46
46
  },
47
- "gitHead": "cfcd27a4e9d15873fc0d5f1bfa6e8b8711eea3fb",
47
+ "gitHead": "ce982faa1c9411285e1432faf9bc897c663914b3",
48
48
  "keywords": [
49
49
  "Workflow"
50
50
  ]