runner-runtime 1.0.69 → 1.0.71

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
@@ -21,7 +21,7 @@ const { v4: uuidv4 } = require("uuid");
21
21
 
22
22
  const fs = require("fs");
23
23
  const { minimatch } = require("minimatch");
24
- const runtime = require("postman-runtime-plus");
24
+ const runtime = require("postman-runtime-pro");
25
25
 
26
26
  // 将api转postman请求参数
27
27
  const convert2PostmanRequest = (request, option) => {
@@ -614,9 +614,10 @@ const convert2PostmanOptions = (request, option, variables) => {
614
614
  values: globalsVariables,
615
615
  });
616
616
 
617
+ const protocolVersion = requestJson?.protocol == 'http/1.1' ? 'http1' : (requestJson?.protocol == 'auto' ? 'auto' : 'http2');
617
618
  const requester = {
618
619
  strictSSL: false,
619
- protocolVersion: requestJson?.protocol == 'http/1.1' ? 'http1' : 'http2',
620
+ protocolVersion,
620
621
  timings: true,
621
622
  verbose: false,
622
623
  implicitCacheControl: true,
@@ -1043,7 +1044,7 @@ const convert2PostmanEvent = (request, listen, option) => {
1043
1044
  " pm.response.originalText = function () {",
1044
1045
  " return originalText;",
1045
1046
  " };",
1046
- " pm.response.stream = Buffer.from(body);",
1047
+ ` pm.response.stream = {type: "Buffer", data:Array.from(Buffer.from(body))};`,
1047
1048
  ` pm.variables.set("_pm.response.setBody", body);`,
1048
1049
  " }",
1049
1050
  " };",
@@ -2316,7 +2317,6 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2316
2317
  test(err, cursor, results, item) {
2317
2318
  if (!err) {
2318
2319
  if (!_.includes(['get_parsed_request'], scene)) {
2319
-
2320
2320
  _.forEach(results, (result) => {
2321
2321
  _.forEach(['_variables', 'environment', 'globals'], (varType) => {
2322
2322
  const currentVar = _.get(result, `result.${varType}`);
@@ -2336,6 +2336,22 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2336
2336
  } catch (e) { }
2337
2337
  })
2338
2338
  })
2339
+
2340
+ const tmpResponseBody = _.get(eventRuntimeData, ['variables', 'variables', '_pm.response.setBody']);
2341
+ const tmpResponseCode = _.toInteger(_.get(eventRuntimeData, ['variables', 'variables', '_pm.response.code']));
2342
+
2343
+ if (_.isString(tmpResponseBody)) {
2344
+ _.set(eventRuntimeData, [event?.event_id, "response", "stream"], {
2345
+ type: "Buffer",
2346
+ data: Array.from(Buffer.from(tmpResponseBody))
2347
+ })
2348
+
2349
+ _.set(eventRuntimeData, [event?.event_id, "response", "body"], tmpResponseBody)
2350
+ }
2351
+
2352
+ if (tmpResponseCode >= 0) {
2353
+ _.set(eventRuntimeData, [event?.event_id, "response", "code"], tmpResponseCode)
2354
+ }
2339
2355
  }
2340
2356
  }
2341
2357
  },
@@ -2354,8 +2370,8 @@ module.exports = (event, option, callback, eventRuntimeData, eventResultList) =>
2354
2370
 
2355
2371
  item(err, cursor, item, visualizer, result) {
2356
2372
  if (!err && _.isObject(visualizer)) {
2357
- const { error, processed_template } = visualizer;
2358
- _.set(eventRuntimeData[event?.event_id], "visualizer", { error, processed_template });
2373
+ const { error, processedTemplate } = visualizer;
2374
+ _.set(eventRuntimeData[event?.event_id], "visualizer", { error, processed_template: processedTemplate });
2359
2375
  } else {
2360
2376
  _.set(eventRuntimeData[event?.event_id], "visualizer", { error: null, processed_template: "" });
2361
2377
  }
package/libs/utils.js CHANGED
@@ -557,18 +557,20 @@ const convertEndRuntimeState = (eventRuntimeData, event_id) => {
557
557
  const currentVariables = {};
558
558
 
559
559
  _.forEach(endAllVars, (value, key) => {
560
- let actedUpon = undefined;
561
- ["variables", "iterationData", "environment", "globals"].some((type) => {
562
- if (!_.isUndefined(_.get(endVariables, [`${type}`, key]))) {
563
- actedUpon = type;
564
- return true;
565
- }
566
- })
560
+ if (!_.includes(['_pm.response.code', '_pm.response.setBody'], key)) {
561
+ let actedUpon = undefined;
562
+ ["variables", "iterationData", "environment", "globals"].some((type) => {
563
+ if (!_.isUndefined(_.get(endVariables, [`${type}`, key]))) {
564
+ actedUpon = type;
565
+ return true;
566
+ }
567
+ })
567
568
 
568
- _.set(currentVariables, [key], {
569
- start: _.pick(startAllActedUponVars[key], ['value', 'actedUpon']),
570
- current: { value, actedUpon }
571
- })
569
+ _.set(currentVariables, [key], {
570
+ start: _.pick(startAllActedUponVars[key], ['value', 'actedUpon']),
571
+ current: { value, actedUpon }
572
+ })
573
+ }
572
574
  })
573
575
 
574
576
  return { startTime, endTime, currentVariables };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runner-runtime",
3
- "version": "1.0.69",
3
+ "version": "1.0.71",
4
4
  "description": "runner-runtime.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -40,7 +40,7 @@
40
40
  "msgpack5": "^6.0.2",
41
41
  "net": "^1.0.2",
42
42
  "postman-collection": "^5.0.2",
43
- "postman-runtime-pro": "^7.43.19",
43
+ "postman-runtime-pro": "^7.43.20",
44
44
  "request-har": "^1.0.0",
45
45
  "strip-json-comments": "^3.1.1",
46
46
  "tough": "^0.6.0",
package/test.js CHANGED
@@ -1,9 +1,9 @@
1
- const _ =require('lodash');
2
- const { run,request2HAR} = require('./index');
1
+ const _ = require('lodash');
2
+ const { run, request2HAR } = require('./index');
3
3
 
4
4
  // 以下为调用示例
5
5
  const callback = (res) => {
6
- console.warn("callback", res)
6
+ console.warn("callback", JSON.stringify(res, null, 2))
7
7
  }
8
8
 
9
9
 
package/tmp/request.js CHANGED
@@ -1,9 +1,7 @@
1
- module.exports ={
1
+ module.exports = {
2
2
  "option": {
3
3
  "scene": "http_request",
4
- "globals": {
5
- "name": ""
6
- },
4
+ "globals": {},
7
5
  "project": {
8
6
  "request": {
9
7
  "header": {
@@ -55,28 +53,65 @@ module.exports ={
55
53
  }
56
54
  },
57
55
  "env": {
58
- "env_id": "f5e217678302b",
59
- "env_name": "演示环境",
60
- "env_pre_url": "https://demo-api.apipost.cn/api",
56
+ "env_id": "1",
57
+ "env_name": "默认环境",
58
+ "env_pre_url": "",
61
59
  "env_pre_urls": {
62
60
  "1": {
63
61
  "server_id": "1",
64
62
  "name": "默认服务",
65
63
  "sort": 1000,
66
- "uri": "https://demo-api.apipost.cn/api"
64
+ "uri": ""
67
65
  },
68
66
  "default": {
69
67
  "server_id": "1",
70
68
  "name": "默认服务",
71
69
  "sort": 1000,
72
- "uri": "https://demo-api.apipost.cn/api"
70
+ "uri": ""
73
71
  }
74
72
  },
75
73
  "environment": {}
76
74
  },
77
75
  "cookies": {
78
76
  "switch": 1,
79
- "data": []
77
+ "data": [
78
+ {
79
+ "key": "security_session_verify",
80
+ "value": "d0f1daeaa990e130b35bbda1e947a503",
81
+ "expires": "2025-05-10T19:46:19.000Z",
82
+ "path": "/",
83
+ "httpOnly": true,
84
+ "creation": "2025-05-07T11:46:19.440Z",
85
+ "name": "security_session_verify",
86
+ "cookie_id": "1ecc0422764032",
87
+ "domain": "echo.apipost.cn",
88
+ "project_id": "2a8c4e3bbc65001"
89
+ },
90
+ {
91
+ "key": "security_session_verify",
92
+ "value": "d0f1daeaa990e130b35bbda1e947a503",
93
+ "expires": "2025-05-10T19:46:19.000Z",
94
+ "path": "/",
95
+ "httpOnly": true,
96
+ "creation": "2025-05-07T11:46:19.441Z",
97
+ "name": "security_session_verify",
98
+ "cookie_id": "1ecc0422764033",
99
+ "domain": "echo.apipost.cn",
100
+ "project_id": "2a8c4e3bbc65001"
101
+ },
102
+ {
103
+ "key": "security_session_verify",
104
+ "value": "d0f1daeaa990e130b35bbda1e947a503",
105
+ "expires": "2025-05-10T19:46:19.000Z",
106
+ "path": "/",
107
+ "httpOnly": true,
108
+ "creation": "2025-05-07T11:46:19.441Z",
109
+ "name": "security_session_verify",
110
+ "cookie_id": "1ecc0422764034",
111
+ "domain": "echo.apipost.cn",
112
+ "project_id": "2a8c4e3bbc65001"
113
+ }
114
+ ]
80
115
  },
81
116
  "system_configs": {
82
117
  "send_timeout": 0,
@@ -100,48 +135,32 @@ module.exports ={
100
135
  },
101
136
  "ca_cert": {
102
137
  "open": -1,
103
- "path": "",
104
- "base64": ""
138
+ "path": ""
105
139
  },
106
140
  "client_cert": {}
107
141
  },
108
142
  "custom_functions": {},
109
143
  "collection": [
110
144
  {
111
- "target_id": "f5e2176783030",
145
+ "target_id": "567",
112
146
  "target_type": "api",
113
- "parent_id": "f5e217678302f",
114
- "name": "登录接口token",
147
+ "parent_id": "f4e31",
148
+ "name": "下单接口",
115
149
  "request": {
116
150
  "auth": {
117
151
  "type": "inherit"
118
152
  },
119
153
  "body": {
120
- "mode": "form-data",
154
+ "mode": "json",
121
155
  "parameter": [
122
156
  {
123
- "param_id": "f5e2171783018",
124
- "description": "手机号",
125
- "field_type": "String",
157
+ "param_id": "2a8c4e42506500e",
158
+ "description": "",
159
+ "field_type": "string",
126
160
  "is_checked": 1,
127
- "key": "mobile",
128
- "not_null": -1,
129
- "value": "17710994566",
130
- "content_type": "",
131
- "file_name": "",
132
- "file_base64": "",
133
- "schema": {
134
- "type": "string"
135
- }
136
- },
137
- {
138
- "param_id": "f5e2171783019",
139
- "description": "验证码",
140
- "field_type": "String",
141
- "is_checked": 1,
142
- "key": "ver_code",
143
- "not_null": -1,
144
- "value": "5643",
161
+ "key": "",
162
+ "not_null": 1,
163
+ "value": "",
145
164
  "content_type": "",
146
165
  "file_name": "",
147
166
  "file_base64": "",
@@ -155,16 +174,62 @@ module.exports ={
155
174
  "raw_schema": {
156
175
  "type": "object"
157
176
  },
158
- "binary": null
177
+ "binary": {}
159
178
  },
160
- "pre_tasks": [],
161
- "post_tasks": [],
179
+ "pre_tasks": [
180
+ {
181
+ "type": "customScript",
182
+ "enabled": 1,
183
+ "data": "apt.setRequestBody({\"key\": \"value\"}); // 将请求的body完全替换为新的内容\n\napt.environment.set(\"new_var\", \"value\");\napt.environment.clear();\n",
184
+ "name": "自定义脚本",
185
+ "id": "1fd601f376400e"
186
+ }
187
+ ],
188
+ "post_tasks": [
189
+ {
190
+ "type": "customScript",
191
+ "enabled": 1,
192
+ "data": "// pm.response.setBody({\"id\":1});\n// 模板字符串 \nvar template = `<table> \n <thead> \n <tr> \n <th>ID</th> \n </tr> \n </thead> \n <tbody> \n {{#each response}} \n <tr> \n <td>{{id}}</td> \n </tr> \n {{/each}} \n </tbody> \n</table>`;\nvar responseData = pm.response.json()[\"data\"][\"list\"]; \npm.visualizer.set(template, { response: responseData });\npm.response.setBody({\"id\":1});\n",
193
+ "name": "自定义脚本",
194
+ "id": "1fd60b01f6400f"
195
+ }
196
+ ],
162
197
  "header": {
163
- "parameter": []
198
+ "parameter": [
199
+ {
200
+ "param_id": "2a8c4e425065010",
201
+ "description": "",
202
+ "field_type": "string",
203
+ "is_checked": 1,
204
+ "key": "",
205
+ "not_null": 1,
206
+ "value": "",
207
+ "schema": {
208
+ "type": "string"
209
+ }
210
+ }
211
+ ]
164
212
  },
165
213
  "query": {
166
214
  "query_add_equal": 1,
167
- "parameter": []
215
+ "parameter": [
216
+ {
217
+ "param_id": "1fd7e2ad39b02f",
218
+ "description": "这是文章ID",
219
+ "field_type": "string",
220
+ "is_checked": 1,
221
+ "key": "id",
222
+ "not_null": 1,
223
+ "value": "",
224
+ "schema": {
225
+ "enum": [
226
+ "aaa",
227
+ "bbb"
228
+ ],
229
+ "type": "string"
230
+ }
231
+ }
232
+ ]
168
233
  },
169
234
  "cookie": {
170
235
  "cookie_encode": 1,
@@ -176,20 +241,22 @@ module.exports ={
176
241
  },
177
242
  "parents": [
178
243
  {
179
- "target_id": "f5e217678302f",
180
- "target_type": "folder"
244
+ "target_id": "f4e31",
245
+ "target_type": "folder",
246
+ "server_id": "1"
181
247
  }
182
248
  ],
249
+ "server_id": "1",
183
250
  "method": "POST",
184
251
  "protocol": "http/1.1",
185
- "url": "/demo/login",
186
- "pre_url": "https://demo-api.apipost.cn/api"
252
+ "url": "https://echo.apipost.cn/array.php?id=",
253
+ "pre_url": ""
187
254
  },
188
255
  {
189
- "target_id": "f5e217678302f",
256
+ "target_id": "f4e31",
190
257
  "target_type": "folder",
191
258
  "parent_id": "0",
192
- "name": "新闻App",
259
+ "name": "备用目录-1",
193
260
  "request": {
194
261
  "auth": {
195
262
  "type": "inherit"
@@ -210,8 +277,8 @@ module.exports ={
210
277
  }
211
278
  },
212
279
  "parents": [],
213
- "server_id": "0",
214
- "pre_url": "https://demo-api.apipost.cn/api"
280
+ "server_id": "1",
281
+ "pre_url": ""
215
282
  }
216
283
  ],
217
284
  "database_configs": {}
@@ -220,9 +287,9 @@ module.exports ={
220
287
  {
221
288
  "type": "api",
222
289
  "data": {
223
- "target_id": "f5e2176783030",
224
- "project_id": "292dc7283464000",
225
- "parent_id": "f5e217678302f",
290
+ "target_id": "567",
291
+ "project_id": "2a8c4e3bbc65001",
292
+ "parent_id": "f4e31",
226
293
  "target_type": "api"
227
294
  }
228
295
  }