@nocobase/plugin-workflow-request-interceptor 2.0.32 → 2.0.34
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.
package/dist/externalVersion.js
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
module.exports = {
|
|
11
|
-
"@nocobase/client": "2.0.
|
|
12
|
-
"@nocobase/plugin-workflow": "2.0.
|
|
11
|
+
"@nocobase/client": "2.0.34",
|
|
12
|
+
"@nocobase/plugin-workflow": "2.0.34",
|
|
13
13
|
"@formily/react": "2.3.7",
|
|
14
14
|
"react": "18.2.0",
|
|
15
|
-
"@nocobase/flow-engine": "2.0.
|
|
16
|
-
"@nocobase/server": "2.0.
|
|
15
|
+
"@nocobase/flow-engine": "2.0.34",
|
|
16
|
+
"@nocobase/server": "2.0.34",
|
|
17
17
|
"lodash": "4.17.21",
|
|
18
|
-
"@nocobase/plugin-error-handler": "2.0.
|
|
19
|
-
"@nocobase/data-source-manager": "2.0.
|
|
18
|
+
"@nocobase/plugin-error-handler": "2.0.34",
|
|
19
|
+
"@nocobase/data-source-manager": "2.0.34"
|
|
20
20
|
};
|
|
@@ -101,10 +101,19 @@ class RequestInterceptionTrigger extends import_plugin_workflow.Trigger {
|
|
|
101
101
|
}
|
|
102
102
|
return aIndex - bIndex;
|
|
103
103
|
});
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
104
|
+
const syncWorkflows = localWorkflows.filter((workflow) => triggerWorkflowsMap.has(workflow.key)).concat(globalWorkflows);
|
|
105
|
+
for (const [index, workflow] of syncWorkflows.entries()) {
|
|
106
|
+
const syncLogMeta = {
|
|
107
|
+
workflowId: workflow.id,
|
|
108
|
+
workflowKey: workflow.key,
|
|
109
|
+
workflowTitle: workflow.title,
|
|
110
|
+
resourceName,
|
|
111
|
+
actionName,
|
|
112
|
+
currentSyncOrder: index + 1,
|
|
113
|
+
totalSyncWorkflows: syncWorkflows.length,
|
|
114
|
+
remainingSyncWorkflows: syncWorkflows.length - index - 1
|
|
115
|
+
};
|
|
116
|
+
context.logger.debug("[Workflow pre-action]: executing sync workflow", syncLogMeta);
|
|
108
117
|
const processor = await this.workflow.trigger(
|
|
109
118
|
workflow,
|
|
110
119
|
{
|
|
@@ -119,25 +128,49 @@ class RequestInterceptionTrigger extends import_plugin_workflow.Trigger {
|
|
|
119
128
|
{ httpContext: context }
|
|
120
129
|
);
|
|
121
130
|
if (!processor) {
|
|
122
|
-
|
|
131
|
+
context.logger.error(
|
|
132
|
+
"[Workflow pre-action]: sync workflow trigger failed before execution created",
|
|
133
|
+
syncLogMeta
|
|
134
|
+
);
|
|
135
|
+
return context.throw(500, "Workflow on your action failed, please contact the administrator");
|
|
123
136
|
}
|
|
124
137
|
const { lastSavedJob, nodesMap } = processor;
|
|
125
138
|
const lastNode = nodesMap.get(lastSavedJob == null ? void 0 : lastSavedJob.nodeId);
|
|
126
139
|
if (processor.execution.status === import_plugin_workflow.EXECUTION_STATUS.RESOLVED) {
|
|
127
140
|
if ((lastNode == null ? void 0 : lastNode.type) === "end") {
|
|
141
|
+
context.logger.debug("[Workflow pre-action]: sync workflow ended request chain on end node", {
|
|
142
|
+
...syncLogMeta,
|
|
143
|
+
...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
|
|
144
|
+
});
|
|
128
145
|
return;
|
|
129
146
|
}
|
|
147
|
+
context.logger.debug("[Workflow pre-action]: sync workflow finished successfully", {
|
|
148
|
+
...syncLogMeta,
|
|
149
|
+
...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
|
|
150
|
+
});
|
|
130
151
|
continue;
|
|
131
152
|
}
|
|
132
153
|
if (processor.execution.status < import_plugin_workflow.EXECUTION_STATUS.STARTED) {
|
|
133
154
|
if ((lastNode == null ? void 0 : lastNode.type) !== "end") {
|
|
155
|
+
context.logger.error("[Workflow pre-action]: sync workflow failed", {
|
|
156
|
+
...syncLogMeta,
|
|
157
|
+
...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
|
|
158
|
+
});
|
|
134
159
|
return context.throw(500, "Workflow on your action failed, please contact the administrator");
|
|
135
160
|
}
|
|
161
|
+
context.logger.warn("[Workflow pre-action]: sync workflow intercepted request on end node", {
|
|
162
|
+
...syncLogMeta,
|
|
163
|
+
...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
|
|
164
|
+
});
|
|
136
165
|
const err = new RequestInterceptionError("Request is intercepted by workflow");
|
|
137
166
|
err.status = 400;
|
|
138
167
|
err.messages = context.state.messages;
|
|
139
168
|
return context.throw(err.status, err);
|
|
140
169
|
}
|
|
170
|
+
context.logger.error("[Workflow pre-action]: sync workflow is still pending after trigger", {
|
|
171
|
+
...syncLogMeta,
|
|
172
|
+
...(0, import_plugin_workflow.getWorkflowExecutionLogMeta)(workflow, processor)
|
|
173
|
+
});
|
|
141
174
|
return context.throw(500, "Workflow on your action hangs, please contact the administrator");
|
|
142
175
|
}
|
|
143
176
|
await next();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nocobase/plugin-workflow-request-interceptor",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.34",
|
|
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.",
|
|
@@ -27,6 +27,6 @@
|
|
|
27
27
|
"keywords": [
|
|
28
28
|
"Workflow"
|
|
29
29
|
],
|
|
30
|
-
"gitHead": "
|
|
30
|
+
"gitHead": "c1ab70fd5ea49ec889c93838b78e633fe78b97dd",
|
|
31
31
|
"license": "Apache-2.0"
|
|
32
32
|
}
|