@nocobase/plugin-workflow-request-interceptor 2.1.0-alpha.14 → 2.1.0-alpha.15

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.
@@ -8,13 +8,13 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.1.0-alpha.14",
12
- "@nocobase/plugin-workflow": "2.1.0-alpha.14",
11
+ "@nocobase/client": "2.1.0-alpha.15",
12
+ "@nocobase/plugin-workflow": "2.1.0-alpha.15",
13
13
  "@formily/react": "2.3.7",
14
14
  "react": "18.2.0",
15
- "@nocobase/flow-engine": "2.1.0-alpha.14",
16
- "@nocobase/server": "2.1.0-alpha.14",
15
+ "@nocobase/flow-engine": "2.1.0-alpha.15",
16
+ "@nocobase/server": "2.1.0-alpha.15",
17
17
  "lodash": "4.17.21",
18
- "@nocobase/plugin-error-handler": "2.1.0-alpha.14",
19
- "@nocobase/data-source-manager": "2.1.0-alpha.14"
18
+ "@nocobase/plugin-error-handler": "2.1.0-alpha.15",
19
+ "@nocobase/data-source-manager": "2.1.0-alpha.15"
20
20
  };
@@ -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-04-07T15:55:37.766Z"}
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-04-10T12:41:09.854Z"}
@@ -125,10 +125,19 @@ class RequestInterceptionTrigger extends import_plugin_workflow.Trigger {
125
125
  }
126
126
  return aIndex - bIndex;
127
127
  });
128
- for (const workflow of localWorkflows.concat(globalWorkflows)) {
129
- if (!workflow.config.global && !triggerWorkflowsMap.has(workflow.key)) {
130
- continue;
131
- }
128
+ const syncWorkflows = localWorkflows.filter((workflow) => triggerWorkflowsMap.has(workflow.key)).concat(globalWorkflows);
129
+ for (const [index, workflow] of syncWorkflows.entries()) {
130
+ const syncLogMeta = {
131
+ workflowId: workflow.id,
132
+ workflowKey: workflow.key,
133
+ workflowTitle: workflow.title,
134
+ resourceName,
135
+ actionName,
136
+ currentSyncOrder: index + 1,
137
+ totalSyncWorkflows: syncWorkflows.length,
138
+ remainingSyncWorkflows: syncWorkflows.length - index - 1
139
+ };
140
+ context.logger.debug("[Workflow pre-action]: executing sync workflow", syncLogMeta);
132
141
  const processor = await this.workflow.trigger(
133
142
  workflow,
134
143
  {
@@ -143,25 +152,49 @@ class RequestInterceptionTrigger extends import_plugin_workflow.Trigger {
143
152
  { httpContext: context }
144
153
  );
145
154
  if (!processor) {
146
- return context.throw(500);
155
+ context.logger.error(
156
+ "[Workflow pre-action]: sync workflow trigger failed before execution created",
157
+ syncLogMeta
158
+ );
159
+ return context.throw(500, "Workflow on your action failed, please contact the administrator");
147
160
  }
148
161
  const { lastSavedJob, nodesMap } = processor;
149
162
  const lastNode = nodesMap.get(lastSavedJob == null ? void 0 : lastSavedJob.nodeId);
150
163
  if (processor.execution.status === import_plugin_workflow.EXECUTION_STATUS.RESOLVED) {
151
164
  if ((lastNode == null ? void 0 : lastNode.type) === "end") {
165
+ context.logger.debug("[Workflow pre-action]: sync workflow ended request chain on end node", {
166
+ ...syncLogMeta,
167
+ ...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
168
+ });
152
169
  return;
153
170
  }
171
+ context.logger.debug("[Workflow pre-action]: sync workflow finished successfully", {
172
+ ...syncLogMeta,
173
+ ...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
174
+ });
154
175
  continue;
155
176
  }
156
177
  if (processor.execution.status < import_plugin_workflow.EXECUTION_STATUS.STARTED) {
157
178
  if ((lastNode == null ? void 0 : lastNode.type) !== "end") {
179
+ context.logger.error("[Workflow pre-action]: sync workflow failed", {
180
+ ...syncLogMeta,
181
+ ...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
182
+ });
158
183
  return context.throw(500, "Workflow on your action failed, please contact the administrator");
159
184
  }
185
+ context.logger.warn("[Workflow pre-action]: sync workflow intercepted request on end node", {
186
+ ...syncLogMeta,
187
+ ...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
188
+ });
160
189
  const err = new RequestInterceptionError("Request is intercepted by workflow");
161
190
  err.status = 400;
162
191
  err.messages = context.state.messages;
163
192
  return context.throw(err.status, err);
164
193
  }
194
+ context.logger.error("[Workflow pre-action]: sync workflow is still pending after trigger", {
195
+ ...syncLogMeta,
196
+ ...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
197
+ });
165
198
  return context.throw(500, "Workflow on your action hangs, please contact the administrator");
166
199
  }
167
200
  await next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-workflow-request-interceptor",
3
- "version": "2.1.0-alpha.14",
3
+ "version": "2.1.0-alpha.15",
4
4
  "displayName": "Workflow: Pre-action event",
5
5
  "displayName.zh-CN": "工作流:操作前事件",
6
6
  "description": "Triggered before the execution of a request initiated through an action button or API, such as before adding, updating, or deleting data. Suitable for data validation and logic judgment before action, and the request could be rejected by using the \"End process\" node.",
@@ -30,6 +30,6 @@
30
30
  "keywords": [
31
31
  "Workflow"
32
32
  ],
33
- "gitHead": "d8735b541de0ff9557bba704de49c799b4962672",
33
+ "gitHead": "7c86e75b0af4b9f532c8ebf5ef96a7423b0ab60e",
34
34
  "license": "Apache-2.0"
35
35
  }