runner-runtime 1.0.49 → 1.0.50

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.
Files changed (2) hide show
  1. package/index.js +19 -15
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -3,6 +3,8 @@ const _ = require('lodash');
3
3
  const moment = require('moment');
4
4
  const aTools = require("apipost-tools");
5
5
  const { executeEvent, iterationEvent } = require('./events');
6
+ const { resolve } = require('superagent/lib/request-base');
7
+ const { da } = require('@faker-js/faker');
6
8
  const ABORT_RECURSION_ERROR = ['stystemError']; //需要跳出递归的错误
7
9
 
8
10
  // 执行场景
@@ -44,7 +46,7 @@ const run = async (events, option, callback) => {
44
46
  await executeEvent(event, _.assign(eventOptions, { iterationData: {} }), callback, eventRuntimeData, eventResultList);
45
47
  } catch (e) {
46
48
  if (_.includes(ABORT_RECURSION_ERROR, e?.action)) {
47
- throw new Error(String(e?.message));
49
+ throw (e);
48
50
  }
49
51
  }
50
52
  }
@@ -85,22 +87,24 @@ const run = async (events, option, callback) => {
85
87
  }
86
88
  }
87
89
 
88
- const request2HAR = async (events, option) => {
89
- const eventOptions = _.pick(option, ["scene", "lang", "project", "env", "globals", "cookies", "system_configs", "custom_functions", "collection", "database_configs", "enable_sandbox", "sleep", "name", "testing_id"]);
90
- const eventRuntimeData = {
91
- variables: {}
92
- };
93
- const eventResultList = [];
94
- const event = _.first(events);
90
+ const request2HAR = (events, option) => {
91
+ return new Promise(async (resolve, reject) => {
92
+ const eventOptions = _.pick(option, ["scene", "lang", "project", "env", "globals", "cookies", "system_configs", "custom_functions", "collection", "database_configs", "enable_sandbox", "sleep", "name", "testing_id"]);
93
+ const eventRuntimeData = {
94
+ variables: {}
95
+ };
96
+ const eventResultList = [];
97
+ const event = _.first(events);
95
98
 
96
- if (_.isObject(event) && _.has(event, 'type')) {
97
- try {
98
- return await executeEvent(event, _.assign(eventOptions, { scene: 'get_parsed_request' }), () => { }, eventRuntimeData, eventResultList);
99
- } catch (e) {
100
- if (_.includes(ABORT_RECURSION_ERROR, e?.action)) {
101
- throw new Error(String(e?.message));
99
+ if (_.isObject(event) && _.has(event, 'type')) {
100
+ try {
101
+ await executeEvent(event, _.assign(eventOptions, { scene: 'get_parsed_request' }), (data) => {
102
+ resolve(data)
103
+ }, eventRuntimeData, eventResultList);
104
+ } catch (e) {
105
+ reject(e)
102
106
  }
103
107
  }
104
- }
108
+ })
105
109
  }
106
110
  module.exports = { run, request2HAR }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runner-runtime",
3
- "version": "1.0.49",
3
+ "version": "1.0.50",
4
4
  "description": "runner-runtime.",
5
5
  "main": "index.js",
6
6
  "scripts": {