@nocobase/plugin-workflow-request 1.9.0-beta.5 → 1.9.0-beta.7

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.
@@ -14,11 +14,11 @@ module.exports = {
14
14
  "@formily/react": "2.3.0",
15
15
  "@formily/antd-v5": "1.2.3",
16
16
  "@ant-design/icons": "5.6.1",
17
- "@nocobase/client": "1.9.0-beta.5",
18
- "@nocobase/plugin-workflow": "1.9.0-beta.5",
17
+ "@nocobase/client": "1.9.0-beta.7",
18
+ "@nocobase/plugin-workflow": "1.9.0-beta.7",
19
19
  "react-i18next": "11.18.6",
20
- "@nocobase/server": "1.9.0-beta.5",
20
+ "@nocobase/server": "1.9.0-beta.7",
21
21
  "axios": "1.7.7",
22
22
  "lodash": "4.17.21",
23
- "@nocobase/plugin-file-manager": "1.9.0-beta.5"
23
+ "@nocobase/plugin-file-manager": "1.9.0-beta.7"
24
24
  };
@@ -161,43 +161,41 @@ class RequestInstruction_default extends import_plugin_workflow.Instruction {
161
161
  };
162
162
  }
163
163
  }
164
- const job = processor.saveJob({
164
+ const { id } = processor.saveJob({
165
165
  status: import_plugin_workflow.JOB_STATUS.PENDING,
166
166
  nodeId: node.id,
167
167
  nodeKey: node.key,
168
168
  upstreamId: (prevJob == null ? void 0 : prevJob.id) ?? null
169
169
  });
170
- request(config, this.workflow.app).then((response) => {
170
+ await processor.exit();
171
+ const jobDone = { status: import_plugin_workflow.JOB_STATUS.PENDING };
172
+ try {
173
+ processor.logger.info(`request (#${node.id}) sent to "${config.url}", waiting for response...`);
174
+ const response = await request(config, this.workflow.app);
171
175
  processor.logger.info(`request (#${node.id}) response success, status: ${response.status}`);
172
- job.set({
173
- status: import_plugin_workflow.JOB_STATUS.RESOLVED,
174
- result: responseSuccess(response, config.onlyData)
175
- });
176
- }).catch((error) => {
176
+ jobDone.status = import_plugin_workflow.JOB_STATUS.RESOLVED;
177
+ jobDone.result = responseSuccess(response, config.onlyData);
178
+ } catch (error) {
177
179
  if (error.isAxiosError) {
178
180
  if (error.response) {
179
181
  processor.logger.info(`request (#${node.id}) failed with response, status: ${error.response.status}`);
180
182
  } else if (error.request) {
181
- processor.logger.error(`request (#${node.id}) failed without resposne: ${error.message}`);
183
+ processor.logger.error(`request (#${node.id}) failed without response: ${error.message}`);
182
184
  } else {
183
185
  processor.logger.error(`request (#${node.id}) initiation failed: ${error.message}`);
184
186
  }
185
187
  } else {
186
188
  processor.logger.error(`request (#${node.id}) failed unexpectedly: ${error.message}`);
187
189
  }
188
- job.set({
189
- status: import_plugin_workflow.JOB_STATUS.FAILED,
190
- result: responseFailure(error)
191
- });
192
- }).finally(() => {
193
- processor.logger.debug(`request (#${node.id}) ended, resume workflow...`);
194
- setTimeout(() => {
195
- job.execution = processor.execution;
196
- this.workflow.resume(job);
190
+ jobDone.status = config.ignoreFail ? import_plugin_workflow.JOB_STATUS.RESOLVED : import_plugin_workflow.JOB_STATUS.FAILED;
191
+ jobDone.result = responseFailure(error);
192
+ } finally {
193
+ const job = await this.workflow.app.db.getRepository("jobs").findOne({
194
+ filterByTk: id
197
195
  });
198
- });
199
- processor.logger.info(`request (#${node.id}) sent to "${config.url}", waiting for response...`);
200
- return null;
196
+ job.set(jobDone);
197
+ this.workflow.resume(job);
198
+ }
201
199
  }
202
200
  async resume(node, job, processor) {
203
201
  const { ignoreFail } = node.config;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "displayName.zh-CN": "工作流:HTTP 请求节点",
5
5
  "description": "Send HTTP requests to any HTTP service for data interaction in workflow.",
6
6
  "description.zh-CN": "可用于在工作流中向任意 HTTP 服务发送请求,进行数据交互。",
7
- "version": "1.9.0-beta.5",
7
+ "version": "1.9.0-beta.7",
8
8
  "license": "AGPL-3.0",
9
9
  "main": "./dist/server/index.js",
10
10
  "homepage": "https://docs.nocobase.com/handbook/workflow-request",
@@ -23,7 +23,7 @@
23
23
  "@nocobase/server": "1.x",
24
24
  "@nocobase/test": "1.x"
25
25
  },
26
- "gitHead": "9a61c60dd3db5af64244e82447309b0cb17aabb6",
26
+ "gitHead": "4a5055c973b51611d5db1604aaaf6c1b73b4733c",
27
27
  "keywords": [
28
28
  "Workflow"
29
29
  ]