@nocobase/plugin-workflow-action-trigger 2.1.0-alpha.46 → 2.1.0-alpha.47

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.
@@ -9,19 +9,19 @@
9
9
 
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.7",
12
- "@nocobase/client": "2.1.0-alpha.46",
13
- "@nocobase/plugin-workflow": "2.1.0-alpha.46",
12
+ "@nocobase/client": "2.1.0-alpha.47",
13
+ "@nocobase/plugin-workflow": "2.1.0-alpha.47",
14
14
  "react": "18.2.0",
15
- "@nocobase/flow-engine": "2.1.0-alpha.46",
15
+ "@nocobase/flow-engine": "2.1.0-alpha.47",
16
16
  "react-i18next": "11.18.6",
17
17
  "lodash": "4.18.1",
18
18
  "sequelize": "6.35.2",
19
- "@nocobase/database": "2.1.0-alpha.46",
20
- "@nocobase/server": "2.1.0-alpha.46",
21
- "@nocobase/actions": "2.1.0-alpha.46",
22
- "@nocobase/plugin-error-handler": "2.1.0-alpha.46",
23
- "@nocobase/data-source-manager": "2.1.0-alpha.46",
24
- "@nocobase/plugin-workflow-test": "2.1.0-alpha.46",
25
- "@nocobase/test": "2.1.0-alpha.46",
26
- "@nocobase/utils": "2.1.0-alpha.46"
19
+ "@nocobase/database": "2.1.0-alpha.47",
20
+ "@nocobase/server": "2.1.0-alpha.47",
21
+ "@nocobase/actions": "2.1.0-alpha.47",
22
+ "@nocobase/plugin-error-handler": "2.1.0-alpha.47",
23
+ "@nocobase/data-source-manager": "2.1.0-alpha.47",
24
+ "@nocobase/plugin-workflow-test": "2.1.0-alpha.47",
25
+ "@nocobase/test": "2.1.0-alpha.47",
26
+ "@nocobase/utils": "2.1.0-alpha.47"
27
27
  };
@@ -1 +1 @@
1
- {"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-04T11:31:16.560Z"}
1
+ {"name":"joi","description":"Object schema validation","version":"17.13.3","repository":"git://github.com/hapijs/joi","main":"lib/index.js","types":"lib/index.d.ts","browser":"dist/joi-browser.min.js","files":["lib/**/*","dist/*"],"keywords":["schema","validation"],"dependencies":{"@hapi/hoek":"^9.3.0","@hapi/topo":"^5.1.0","@sideway/address":"^4.1.5","@sideway/formula":"^3.0.1","@sideway/pinpoint":"^2.0.0"},"devDependencies":{"@hapi/bourne":"2.x.x","@hapi/code":"8.x.x","@hapi/joi-legacy-test":"npm:@hapi/joi@15.x.x","@hapi/lab":"^25.1.3","@types/node":"^14.18.63","typescript":"4.3.x"},"scripts":{"prepublishOnly":"cd browser && npm install && npm run build","test":"lab -t 100 -a @hapi/code -L -Y","test-cov-html":"lab -r html -o coverage.html -a @hapi/code"},"license":"BSD-3-Clause","_lastModified":"2026-06-08T04:02:55.097Z"}
@@ -16,6 +16,7 @@ export default class extends Trigger {
16
16
  constructor(workflow: WorkflowPlugin);
17
17
  getTargetCollection(collection: Collection, association: string): Collection<any, any>;
18
18
  private collectionTriggerAction;
19
+ private scheduleAsyncWorkflowTriggers;
19
20
  execute(workflow: WorkflowModel, values: any, options: EventOptions): Promise<void | import("@nocobase/plugin-workflow").Processor>;
20
21
  validateContext(values: any): {
21
22
  data: string;
@@ -45,6 +45,7 @@ var import_plugin_error_handler = __toESM(require("@nocobase/plugin-error-handle
45
45
  var import_joi = __toESM(require("joi"));
46
46
  var import_plugin_workflow = require("@nocobase/plugin-workflow");
47
47
  var import_data_source_manager = require("@nocobase/data-source-manager");
48
+ const ASYNC_WORKFLOW_TRIGGER_DELAY_MS = 200;
48
49
  class RequestOnActionTriggerError extends Error {
49
50
  status = 400;
50
51
  messages = [];
@@ -276,9 +277,34 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
276
277
  });
277
278
  return context.throw(500, "Workflow on your action hangs, please contact the administrator");
278
279
  }
279
- for (const event of asyncGroup) {
280
- this.workflow.trigger(event[0], event[1]);
280
+ this.scheduleAsyncWorkflowTriggers(context, asyncGroup);
281
+ }
282
+ scheduleAsyncWorkflowTriggers(context, events) {
283
+ if (!events.length) {
284
+ return;
285
+ }
286
+ const triggerAsyncWorkflows = () => {
287
+ const triggerAsyncWorkflow = async (workflow, values) => {
288
+ await this.workflow.trigger(workflow, values);
289
+ };
290
+ setTimeout(() => {
291
+ for (const [workflow, values] of events) {
292
+ triggerAsyncWorkflow(workflow, values).catch((error) => {
293
+ context.logger.error("[Workflow post-action]: async workflow trigger failed", {
294
+ error,
295
+ workflowId: workflow.id,
296
+ workflowKey: workflow.key,
297
+ workflowTitle: workflow.title
298
+ });
299
+ });
300
+ }
301
+ }, ASYNC_WORKFLOW_TRIGGER_DELAY_MS);
302
+ };
303
+ if (context.res.writableEnded) {
304
+ triggerAsyncWorkflows();
305
+ return;
281
306
  }
307
+ context.res.once("finish", triggerAsyncWorkflows);
282
308
  }
283
309
  async execute(workflow, values, options) {
284
310
  var _a, _b;
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Triggered after the completion of a request initiated through an action button or API, such as after adding, updating, deleting data, or \"submit to workflow\". Suitable for data processing, sending notifications, etc., after actions are completed.",
7
7
  "description.ru-RU": "Срабатывает после завершения запроса, инициированного кнопкой действия или API, например после добавления, обновления, удаления данных или «отправки в рабочий процесс». Подходит для обработки данных, отправки уведомлений и т.д. после выполнения действий.",
8
8
  "description.zh-CN": "通过操作按钮或 API 发起请求并在执行完成后触发,比如新增、更新、删除数据或者“提交至工作流”之后。适用于在操作完成后进行数据处理、发送通知等。",
9
- "version": "2.1.0-alpha.46",
9
+ "version": "2.1.0-alpha.47",
10
10
  "license": "Apache-2.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
@@ -26,7 +26,7 @@
26
26
  "@nocobase/server": "2.x",
27
27
  "@nocobase/test": "2.x"
28
28
  },
29
- "gitHead": "42b269944cdd1908d7a848c0af4936fe94c03bb7",
29
+ "gitHead": "66196b57f9043ea0ac6ebdafbc732bfb98af1396",
30
30
  "keywords": [
31
31
  "Workflow"
32
32
  ]