@nocobase/plugin-workflow-action-trigger 2.0.0-alpha.51 → 2.0.0-alpha.52

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,18 +9,18 @@
9
9
 
10
10
  module.exports = {
11
11
  "@formily/react": "2.3.7",
12
- "@nocobase/client": "2.0.0-alpha.51",
13
- "@nocobase/plugin-workflow": "2.0.0-alpha.51",
12
+ "@nocobase/client": "2.0.0-alpha.52",
13
+ "@nocobase/plugin-workflow": "2.0.0-alpha.52",
14
14
  "react": "18.2.0",
15
15
  "react-i18next": "11.18.6",
16
16
  "lodash": "4.17.21",
17
17
  "sequelize": "6.35.2",
18
- "@nocobase/database": "2.0.0-alpha.51",
19
- "@nocobase/server": "2.0.0-alpha.51",
20
- "@nocobase/actions": "2.0.0-alpha.51",
21
- "@nocobase/plugin-error-handler": "2.0.0-alpha.51",
22
- "@nocobase/data-source-manager": "2.0.0-alpha.51",
23
- "@nocobase/plugin-workflow-test": "2.0.0-alpha.51",
24
- "@nocobase/test": "2.0.0-alpha.51",
25
- "@nocobase/utils": "2.0.0-alpha.51"
18
+ "@nocobase/database": "2.0.0-alpha.52",
19
+ "@nocobase/server": "2.0.0-alpha.52",
20
+ "@nocobase/actions": "2.0.0-alpha.52",
21
+ "@nocobase/plugin-error-handler": "2.0.0-alpha.52",
22
+ "@nocobase/data-source-manager": "2.0.0-alpha.52",
23
+ "@nocobase/plugin-workflow-test": "2.0.0-alpha.52",
24
+ "@nocobase/test": "2.0.0-alpha.52",
25
+ "@nocobase/utils": "2.0.0-alpha.52"
26
26
  };
@@ -57,15 +57,14 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
57
57
  constructor(workflow) {
58
58
  super(workflow);
59
59
  const self = this;
60
- async function triggerWorkflowActionMiddleware(context, next) {
60
+ workflow.app.dataSourceManager.use(async function triggerWorkflowActionMiddleware(context, next) {
61
61
  await next();
62
62
  const { actionName } = context.action;
63
63
  if (!["create", "update"].includes(actionName)) {
64
64
  return;
65
65
  }
66
66
  return self.collectionTriggerAction(context);
67
- }
68
- workflow.app.dataSourceManager.use(triggerWorkflowActionMiddleware);
67
+ });
69
68
  workflow.app.pm.get(import_plugin_error_handler.default).errorHandler.register(
70
69
  (err) => err instanceof RequestOnActionTriggerError || err.name === "RequestOnActionTriggerError",
71
70
  async (err, ctx) => {
@@ -175,9 +174,13 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
175
174
  if (collectionName !== model.collection.name) {
176
175
  continue;
177
176
  }
177
+ const filterByTk = model.collection.isMultiFilterTargetKey() ? (0, import_lodash.pick)(
178
+ payload.get(),
179
+ model.collection.filterTargetKey.sort((a, b) => a.localeCompare(b))
180
+ ) : payload.get(model.collection.filterTargetKey);
178
181
  if (appends.length) {
179
182
  payload = await model.collection.repository.findOne({
180
- filterByTk: payload.get(model.collection.filterTargetKey),
183
+ filterByTk,
181
184
  appends
182
185
  });
183
186
  }
@@ -185,6 +188,9 @@ class ActionTrigger_default extends import_plugin_workflow.Trigger {
185
188
  (workflow.sync ? syncGroup : asyncGroup).push([workflow, { data: (0, import_plugin_workflow.toJSON)(payload), ...userInfo }]);
186
189
  }
187
190
  } else {
191
+ context.logger.warn(
192
+ "[Workflow post-action]: post-action to trigger on workflow resource is deprecated, and will be removed in 2.0"
193
+ );
188
194
  const { filterTargetKey, repository } = context.app.dataSourceManager.dataSources.get(dataSourceName).collectionManager.getCollection(collectionName);
189
195
  let data = dataPath ? (0, import_lodash.get)(values, dataPath) : values;
190
196
  const pk = (0, import_lodash.get)(data, filterTargetKey);
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.0.0-alpha.51",
9
+ "version": "2.0.0-alpha.52",
10
10
  "license": "AGPL-3.0",
11
11
  "main": "./dist/server/index.js",
12
12
  "homepage": "https://docs.nocobase.com/plugins/workflow-action-trigger",
@@ -24,7 +24,7 @@
24
24
  "@nocobase/server": "2.x",
25
25
  "@nocobase/test": "2.x"
26
26
  },
27
- "gitHead": "a1e34dd97f370d54f3d80a6b83ab7ddb9c72dc18",
27
+ "gitHead": "b32992d8baeb4ca6616d839ca2f9c023d49476a9",
28
28
  "keywords": [
29
29
  "Workflow"
30
30
  ]