runner-runtime 1.0.11 → 1.0.13

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/events/api.js CHANGED
@@ -9,7 +9,7 @@ const FileType = require("file-type"),
9
9
  tough = require("tough-cookie"),
10
10
  Buffer = require("buffer/").Buffer,
11
11
  isImage = require("is-image");
12
- const { getAPIFromCollection, smartUrlJoin, replace2RegExp, getParentTargetIDs, base64toCacheFile, getInsideVariables, getCaseInsensitive } = require('../libs/utils'),
12
+ const { getAPIFromCollection, smartUrlJoin, replace2RegExp, getParentTargetIDs, base64toCacheFile, getInsideVariables, getCaseInsensitive, camelCaseToSnakeCase } = require('../libs/utils'),
13
13
  _ = require('lodash');
14
14
  const sdk = require("postman-collection"),
15
15
  Url = sdk.Url,
@@ -1552,7 +1552,10 @@ async function convert2EchoResponse(response, history) {
1552
1552
  }
1553
1553
 
1554
1554
  _.assign(cloneResponse, { mimeType, fitForShow });
1555
- } catch (e) { }
1555
+ } catch (e) {
1556
+
1557
+ console.log(e, 1111)
1558
+ }
1556
1559
 
1557
1560
  // 响应头对象
1558
1561
  const responseHeader = {};
@@ -2225,11 +2228,14 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2225
2228
 
2226
2229
  responseData(cursor, data) {
2227
2230
  callback({
2228
- action: "sse",
2231
+ event: "sse",
2229
2232
  data: {
2230
- stream: data,
2231
- size: _.size(data),
2232
- time: Date.now()
2233
+ action: "sse",
2234
+ data: {
2235
+ stream: data,
2236
+ size: _.size(data),
2237
+ time: Date.now()
2238
+ },
2233
2239
  },
2234
2240
  msg: "success",
2235
2241
  error: null,
@@ -2252,7 +2258,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2252
2258
 
2253
2259
  // 写入到自动化测试结果
2254
2260
  if (scene === 'auto_test' && _.includes(['assert', 'assert_visual', 'api', 'sample'], event?.type)) {
2255
- eventResultList.push(_.assign(_.get(eventRuntimeData, event?.event_id), _.pick(event, ['type', 'event_id', 'test_id']), {
2261
+ eventResultList.push(_.assign(camelCaseToSnakeCase(_.get(eventRuntimeData, event?.event_id)), _.pick(event, ['type', 'event_id', 'test_id']), {
2256
2262
  iteration_id: aTools.snowflakeId()
2257
2263
  }))
2258
2264
  }
@@ -2260,7 +2266,7 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2260
2266
 
2261
2267
  resolve(_.assign({
2262
2268
  action: 'httpRequestCompleted',
2263
- data: _.get(eventRuntimeData, event?.event_id),
2269
+ data: camelCaseToSnakeCase(_.get(eventRuntimeData, event?.event_id)),
2264
2270
  error: _.get(eventRuntimeData, [event?.event_id, 'error', 'message']) || null,
2265
2271
  event_id: event?.event_id,
2266
2272
  iteration_id: aTools.snowflakeId(),
package/libs/utils.js CHANGED
@@ -485,6 +485,20 @@ const formatAutotestReport = (startTimeAt, eventResultList) => {
485
485
  report.total_response_size = totalResponseSize;
486
486
  return report;
487
487
  }
488
+
489
+
490
+ const camelCaseToSnakeCase = (obj) => {
491
+ ["arrCookies", "fitForShow", "mimeType", "requestStart", "responseSize", "responseTime",].forEach((key) => {
492
+ const _key = _.snakeCase(key);
493
+ const objValue = _.get(obj, `response.${key}`);
494
+ if (!_.isUndefined(objValue)) {
495
+ _.set(obj, `response.${_key}`, objValue);
496
+ _.unset(obj, `response.${key}`);
497
+ }
498
+ });
499
+
500
+ return obj;
501
+ }
488
502
  module.exports = {
489
503
  atomicSleep,
490
504
  getAPIFromCollection,
@@ -495,6 +509,7 @@ module.exports = {
495
509
  repeatArrayToLength,
496
510
  returnBoolean,
497
511
  getCaseInsensitive,
512
+ camelCaseToSnakeCase,
498
513
  variableReplace,
499
514
  // createPipeServer,
500
515
  formatAutotestReport,
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
2
  "name": "runner-runtime",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "Processing data returned by AI.",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
8
  },
9
9
  "repository": {
10
- "type": "git",
11
- "url": "git+https://github.com/Apipost-Team/runner-runtime.git"
10
+ "type": "git",
11
+ "url": "git+https://github.com/Apipost-Team/runner-runtime.git"
12
12
  },
13
13
  "keywords": [
14
- "auto-json-faker"
14
+ "auto-json-faker"
15
15
  ],
16
16
  "author": "Daniel Anderson <support@echoapi.com> (https://github.com/Apipost-Team)",
17
17
  "license": "MIT",
18
18
  "bugs": {
19
- "url": "https://github.com/Apipost-Team/runner-runtime/issues"
19
+ "url": "https://github.com/Apipost-Team/runner-runtime/issues"
20
20
  },
21
21
  "homepage": "https://github.com/Apipost-Team/runner-runtime#readme",
22
22
  "dependencies": {