@usebruno/filestore 0.7.1 → 0.8.1
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/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/workers/worker-script.js +1 -1
- package/dist/cjs/workers/worker-script.js.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/workers/worker-script.js +1 -1
- package/dist/esm/workers/worker-script.js.map +1 -1
- package/dist/formats/bru/index.d.ts.map +1 -1
- package/dist/formats/bru/tests/example-status-swap.spec.d.ts +2 -0
- package/dist/formats/bru/tests/example-status-swap.spec.d.ts.map +1 -0
- package/dist/formats/yml/common/auth-oauth2.d.ts.map +1 -1
- package/dist/formats/yml/items/parseHttpRequest.d.ts.map +1 -1
- package/dist/formats/yml/parseCollection.d.ts.map +1 -1
- package/dist/formats/yml/stringifyCollection.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/formats/bru/index.ts +13 -2
- package/src/formats/bru/tests/example-status-swap.spec.js +109 -0
- package/src/formats/yml/common/auth-oauth2.ts +37 -22
- package/src/formats/yml/items/parseHttpRequest.ts +2 -1
- package/src/formats/yml/parseCollection.ts +11 -1
- package/src/formats/yml/stringifyCollection.ts +15 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formats/bru/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe,SAAU,MAAM,GAAG,GAAG,WAAU,OAAO,KAAW,GAuG7E,CAAC;AAEF,eAAO,MAAM,mBAAmB,SAAU,GAAG,KAAG,MA+G/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAU,MAAM,GAAG,GAAG,WAAU,OAAO,KAAW,GA4ChF,CAAC;AAEF,eAAO,MAAM,sBAAsB,SAAU,GAAG,aAAa,OAAO,KAAG,MAuCtE,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,GAejD,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAAU,GAAG,KAAG,MAOnD,CAAC;AAGF,eAAO,MAAM,gBAAgB,SAAU,MAAM,GAAG,GAAG,WAAU,OAAO,eAAuB,MAAM,iBAAiB,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/formats/bru/index.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,eAAe,SAAU,MAAM,GAAG,GAAG,WAAU,OAAO,KAAW,GAuG7E,CAAC;AAEF,eAAO,MAAM,mBAAmB,SAAU,GAAG,KAAG,MA+G/C,CAAC;AAEF,eAAO,MAAM,kBAAkB,SAAU,MAAM,GAAG,GAAG,WAAU,OAAO,KAAW,GA4ChF,CAAC;AAEF,eAAO,MAAM,sBAAsB,SAAU,GAAG,aAAa,OAAO,KAAG,MAuCtE,CAAC;AAEF,eAAO,MAAM,mBAAmB,QAAS,MAAM,KAAG,GAejD,CAAC;AAEF,eAAO,MAAM,uBAAuB,SAAU,GAAG,KAAG,MAOnD,CAAC;AAGF,eAAO,MAAM,gBAAgB,SAAU,MAAM,GAAG,GAAG,WAAU,OAAO,eAAuB,MAAM,iBAAiB,MAAM,KAAG,GAwE1H,CAAC;AAEF,eAAO,MAAM,gBAAgB,SAAU,GAAG;;;;;;;;;;;CAsBzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"example-status-swap.spec.d.ts","sourceRoot":"","sources":["../../../../src/formats/bru/tests/example-status-swap.spec.js"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth-oauth2.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/common/auth-oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAWX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,MAAM,IAAI,WAAW,EAEtB,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"auth-oauth2.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/common/auth-oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EAWX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EACV,MAAM,IAAI,WAAW,EAEtB,MAAM,oCAAoC,CAAC;AAuQ5C,eAAO,MAAM,sBAAsB,WAAY,WAAW,GAAG,IAAI,KAAG,UAAU,GAAG,SAkBhF,CAAC;AAsCF,eAAO,MAAM,aAAa,UAAW,UAAU,GAAG,IAAI,GAAG,SAAS,KAAG,WAAW,GAAG,IA0OlF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseHttpRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/parseHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAE3H,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,qCAAqC,CAAC;AAWxF,QAAA,MAAM,gBAAgB,cAAe,WAAW,KAAG,
|
|
1
|
+
{"version":3,"file":"parseHttpRequest.d.ts","sourceRoot":"","sources":["../../../../src/formats/yml/items/parseHttpRequest.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,IAAI,SAAS,EAA6C,MAAM,wCAAwC,CAAC;AAE3H,OAAO,KAAK,EAAE,WAAW,EAAmB,MAAM,qCAAqC,CAAC;AAWxF,QAAA,MAAM,gBAAgB,cAAe,WAAW,KAAG,SAoLlD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parseCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAS3E,UAAU,gBAAgB;IACxB,cAAc,EAAE,UAAU,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,QAAA,MAAM,eAAe,cAAe,MAAM,KAAG,
|
|
1
|
+
{"version":3,"file":"parseCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/parseCollection.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAS3E,UAAU,gBAAgB;IACxB,cAAc,EAAE,UAAU,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAClC;AAED,QAAA,MAAM,eAAe,cAAe,MAAM,KAAG,gBAoN5C,CAAC;AAEF,eAAe,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stringifyCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyCollection.ts"],"names":[],"mappings":"AAkEA,QAAA,MAAM,mBAAmB,mBAAoB,GAAG,eAAe,GAAG,KAAG,
|
|
1
|
+
{"version":3,"file":"stringifyCollection.d.ts","sourceRoot":"","sources":["../../../src/formats/yml/stringifyCollection.ts"],"names":[],"mappings":"AAkEA,QAAA,MAAM,mBAAmB,mBAAoB,GAAG,eAAe,GAAG,KAAG,MA0NpE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@usebruno/filestore",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"@types/jest": "^29.5.11",
|
|
30
30
|
"@types/lodash": "^4.14.191",
|
|
31
31
|
"@types/node": "^24.1.0",
|
|
32
|
-
"@usebruno/schema-types": "0.
|
|
32
|
+
"@usebruno/schema-types": "0.3.0",
|
|
33
33
|
"babel-jest": "^29.7.0",
|
|
34
34
|
"jest": "^29.2.0",
|
|
35
35
|
"nanoid": "3.3.8",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
47
|
"@types/nanoid": "^2.1.0",
|
|
48
|
-
"@usebruno/lang": "0.
|
|
48
|
+
"@usebruno/lang": "0.35.0",
|
|
49
49
|
"ajv": "^8.17.1",
|
|
50
50
|
"lodash": "^4.17.21",
|
|
51
51
|
"yaml": "^2.3.4"
|
package/src/formats/bru/index.ts
CHANGED
|
@@ -367,6 +367,17 @@ export const bruExampleToJson = (data: string | any, parsed: boolean = false, pa
|
|
|
367
367
|
transformedType = 'http-request';
|
|
368
368
|
}
|
|
369
369
|
|
|
370
|
+
/**
|
|
371
|
+
* Backward compatibility (pre-v3.0.2 - v3.2.0): Postman imports before PR #6876 stored status/statusText swapped
|
|
372
|
+
* (code: "OK", text: "202" instead of code: 202, text: "OK"). Detect and swap back.
|
|
373
|
+
* TODO(Sid / Shubh): Remove after v5 — all collections should be migrated by then.
|
|
374
|
+
*/
|
|
375
|
+
let status = _.get(json, 'response.status', '200');
|
|
376
|
+
let statusText = _.get(json, 'response.statusText', 'OK');
|
|
377
|
+
if (isNaN(Number(status)) && !isNaN(Number(statusText))) {
|
|
378
|
+
[status, statusText] = [statusText, status];
|
|
379
|
+
}
|
|
380
|
+
|
|
370
381
|
// Follow the same structure as the main request, but with missing fields for examples
|
|
371
382
|
const transformedJson = {
|
|
372
383
|
type: transformedType,
|
|
@@ -388,8 +399,8 @@ export const bruExampleToJson = (data: string | any, parsed: boolean = false, pa
|
|
|
388
399
|
name: header.name,
|
|
389
400
|
value: header.value
|
|
390
401
|
})),
|
|
391
|
-
status:
|
|
392
|
-
statusText:
|
|
402
|
+
status: Number(status) || 200,
|
|
403
|
+
statusText: statusText || 'OK',
|
|
393
404
|
body: {
|
|
394
405
|
type: _.get(json, 'response.body.type', 'json'),
|
|
395
406
|
content: _.get(json, 'response.body.content', '')
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
const { bruExampleToJson } = require('../index');
|
|
2
|
+
|
|
3
|
+
describe('bruExampleToJson - status/statusText swap fix', () => {
|
|
4
|
+
it('should parse normal status and statusText correctly', () => {
|
|
5
|
+
const parsed = {
|
|
6
|
+
name: 'Normal Example',
|
|
7
|
+
description: '',
|
|
8
|
+
request: { url: 'https://api.example.com/test', method: 'get' },
|
|
9
|
+
response: {
|
|
10
|
+
headers: [],
|
|
11
|
+
status: '200',
|
|
12
|
+
statusText: 'OK',
|
|
13
|
+
body: { type: 'json', content: '{}' }
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
const result = bruExampleToJson(parsed, true, 'http', 'GET');
|
|
18
|
+
expect(result.response.status).toBe(200);
|
|
19
|
+
expect(result.response.statusText).toBe('OK');
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it('should swap back status and statusText when they are reversed (pre-fix Postman import)', () => {
|
|
23
|
+
const parsed = {
|
|
24
|
+
name: 'Swapped Example',
|
|
25
|
+
description: '',
|
|
26
|
+
request: { url: 'https://api.example.com/test', method: 'get' },
|
|
27
|
+
response: {
|
|
28
|
+
headers: [],
|
|
29
|
+
status: 'Accepted',
|
|
30
|
+
statusText: '202',
|
|
31
|
+
body: { type: 'json', content: '{}' }
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const result = bruExampleToJson(parsed, true, 'http', 'GET');
|
|
36
|
+
expect(result.response.status).toBe(202);
|
|
37
|
+
expect(result.response.statusText).toBe('Accepted');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should swap back status OK and statusText 200', () => {
|
|
41
|
+
const parsed = {
|
|
42
|
+
name: 'Swapped OK Example',
|
|
43
|
+
description: '',
|
|
44
|
+
request: { url: 'https://api.example.com/test', method: 'get' },
|
|
45
|
+
response: {
|
|
46
|
+
headers: [],
|
|
47
|
+
status: 'OK',
|
|
48
|
+
statusText: '200',
|
|
49
|
+
body: { type: 'json', content: '{}' }
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const result = bruExampleToJson(parsed, true, 'http', 'GET');
|
|
54
|
+
expect(result.response.status).toBe(200);
|
|
55
|
+
expect(result.response.statusText).toBe('OK');
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('should swap back status Not Found and statusText 404', () => {
|
|
59
|
+
const parsed = {
|
|
60
|
+
name: 'Swapped Not Found Example',
|
|
61
|
+
description: '',
|
|
62
|
+
request: { url: 'https://api.example.com/test', method: 'get' },
|
|
63
|
+
response: {
|
|
64
|
+
headers: [],
|
|
65
|
+
status: 'Not Found',
|
|
66
|
+
statusText: '404',
|
|
67
|
+
body: { type: 'json', content: '{}' }
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
const result = bruExampleToJson(parsed, true, 'http', 'GET');
|
|
72
|
+
expect(result.response.status).toBe(404);
|
|
73
|
+
expect(result.response.statusText).toBe('Not Found');
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('should not swap when status is already numeric and statusText is text (correct order)', () => {
|
|
77
|
+
const parsed = {
|
|
78
|
+
name: 'Correct Order Example',
|
|
79
|
+
description: '',
|
|
80
|
+
request: { url: 'https://api.example.com/test', method: 'get' },
|
|
81
|
+
response: {
|
|
82
|
+
headers: [],
|
|
83
|
+
status: '404',
|
|
84
|
+
statusText: 'Not Found',
|
|
85
|
+
body: { type: 'json', content: '{}' }
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
const result = bruExampleToJson(parsed, true, 'http', 'GET');
|
|
90
|
+
expect(result.response.status).toBe(404);
|
|
91
|
+
expect(result.response.statusText).toBe('Not Found');
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should use defaults when response has no status', () => {
|
|
95
|
+
const parsed = {
|
|
96
|
+
name: 'No Status Example',
|
|
97
|
+
description: '',
|
|
98
|
+
request: { url: 'https://api.example.com/test', method: 'get' },
|
|
99
|
+
response: {
|
|
100
|
+
headers: [],
|
|
101
|
+
body: { type: 'json', content: '{}' }
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const result = bruExampleToJson(parsed, true, 'http', 'GET');
|
|
106
|
+
expect(result.response.status).toBe(200);
|
|
107
|
+
expect(result.response.statusText).toBe('OK');
|
|
108
|
+
});
|
|
109
|
+
});
|
|
@@ -114,6 +114,8 @@ const buildTokenConfig = (oauth: BrunoOAuth2): OAuth2TokenConfig | undefined =>
|
|
|
114
114
|
};
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
+
tokenConfig.source = oauth.tokenSource || 'access_token';
|
|
118
|
+
|
|
117
119
|
return Object.keys(tokenConfig).length > 0 ? tokenConfig : undefined;
|
|
118
120
|
};
|
|
119
121
|
|
|
@@ -143,13 +145,16 @@ const buildClientCredentialsFlow = (oauth: BrunoOAuth2): OAuth2ClientCredentials
|
|
|
143
145
|
isNonEmptyString(oauth.scope) && (flow.scope = oauth.scope);
|
|
144
146
|
|
|
145
147
|
const accessTokenRequest = mapAdditionalParameters(oauth.additionalParameters?.token);
|
|
146
|
-
if (accessTokenRequest) {
|
|
147
|
-
flow.additionalParameters = { accessTokenRequest };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
148
|
const refreshTokenRequest = mapAdditionalParameters(oauth.additionalParameters?.refresh);
|
|
151
|
-
|
|
152
|
-
|
|
149
|
+
|
|
150
|
+
if (accessTokenRequest || refreshTokenRequest) {
|
|
151
|
+
flow.additionalParameters = {};
|
|
152
|
+
if (accessTokenRequest) {
|
|
153
|
+
flow.additionalParameters.accessTokenRequest = accessTokenRequest;
|
|
154
|
+
}
|
|
155
|
+
if (refreshTokenRequest) {
|
|
156
|
+
flow.additionalParameters.refreshTokenRequest = refreshTokenRequest;
|
|
157
|
+
}
|
|
153
158
|
}
|
|
154
159
|
|
|
155
160
|
const tokenConfig = buildTokenConfig(oauth);
|
|
@@ -179,13 +184,16 @@ const buildResourceOwnerPasswordFlow = (oauth: BrunoOAuth2): OAuth2ResourceOwner
|
|
|
179
184
|
isNonEmptyString(oauth.scope) && (flow.scope = oauth.scope);
|
|
180
185
|
|
|
181
186
|
const accessTokenRequest = mapAdditionalParameters(oauth.additionalParameters?.token);
|
|
182
|
-
if (accessTokenRequest) {
|
|
183
|
-
flow.additionalParameters = { accessTokenRequest };
|
|
184
|
-
}
|
|
185
|
-
|
|
186
187
|
const refreshTokenRequest = mapAdditionalParameters(oauth.additionalParameters?.refresh);
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
|
|
189
|
+
if (accessTokenRequest || refreshTokenRequest) {
|
|
190
|
+
flow.additionalParameters = {};
|
|
191
|
+
if (accessTokenRequest) {
|
|
192
|
+
flow.additionalParameters.accessTokenRequest = accessTokenRequest;
|
|
193
|
+
}
|
|
194
|
+
if (refreshTokenRequest) {
|
|
195
|
+
flow.additionalParameters.refreshTokenRequest = refreshTokenRequest;
|
|
196
|
+
}
|
|
189
197
|
}
|
|
190
198
|
|
|
191
199
|
const tokenConfig = buildTokenConfig(oauth);
|
|
@@ -212,18 +220,20 @@ const buildAuthorizationCodeFlow = (oauth: BrunoOAuth2): OAuth2AuthorizationCode
|
|
|
212
220
|
if (credentials) flow.credentials = credentials;
|
|
213
221
|
|
|
214
222
|
const authorizationRequest = mapAdditionalParameters(oauth.additionalParameters?.authorization);
|
|
215
|
-
if (authorizationRequest) {
|
|
216
|
-
flow.additionalParameters = { authorizationRequest };
|
|
217
|
-
}
|
|
218
|
-
|
|
219
223
|
const accessTokenRequest = mapAdditionalParameters(oauth.additionalParameters?.token);
|
|
220
|
-
if (accessTokenRequest) {
|
|
221
|
-
flow.additionalParameters = { accessTokenRequest };
|
|
222
|
-
}
|
|
223
|
-
|
|
224
224
|
const refreshTokenRequest = mapAdditionalParameters(oauth.additionalParameters?.refresh);
|
|
225
|
-
|
|
226
|
-
|
|
225
|
+
|
|
226
|
+
if (authorizationRequest || accessTokenRequest || refreshTokenRequest) {
|
|
227
|
+
flow.additionalParameters = {};
|
|
228
|
+
if (authorizationRequest) {
|
|
229
|
+
flow.additionalParameters.authorizationRequest = authorizationRequest;
|
|
230
|
+
}
|
|
231
|
+
if (accessTokenRequest) {
|
|
232
|
+
flow.additionalParameters.accessTokenRequest = accessTokenRequest;
|
|
233
|
+
}
|
|
234
|
+
if (refreshTokenRequest) {
|
|
235
|
+
flow.additionalParameters.refreshTokenRequest = refreshTokenRequest;
|
|
236
|
+
}
|
|
227
237
|
}
|
|
228
238
|
|
|
229
239
|
isNonEmptyString(oauth.scope) && (flow.scope = oauth.scope);
|
|
@@ -345,6 +355,7 @@ export const toBrunoOAuth2 = (oauth: AuthOAuth2 | null | undefined): BrunoOAuth2
|
|
|
345
355
|
tokenPlacement: null,
|
|
346
356
|
tokenHeaderPrefix: null,
|
|
347
357
|
tokenQueryKey: null,
|
|
358
|
+
tokenSource: 'access_token',
|
|
348
359
|
refreshTokenUrl: null,
|
|
349
360
|
autoRefreshToken: false, // Default to false
|
|
350
361
|
autoFetchToken: true, // Default to true
|
|
@@ -363,6 +374,7 @@ export const toBrunoOAuth2 = (oauth: AuthOAuth2 | null | undefined): BrunoOAuth2
|
|
|
363
374
|
|
|
364
375
|
// token config
|
|
365
376
|
if (oauth.tokenConfig?.id) brunoOAuth.credentialsId = oauth.tokenConfig.id;
|
|
377
|
+
if (oauth.tokenConfig?.source) brunoOAuth.tokenSource = oauth.tokenConfig.source || 'access_token';
|
|
366
378
|
if (oauth.tokenConfig?.placement) {
|
|
367
379
|
if ('header' in oauth.tokenConfig.placement) {
|
|
368
380
|
brunoOAuth.tokenPlacement = 'header';
|
|
@@ -408,6 +420,7 @@ export const toBrunoOAuth2 = (oauth: AuthOAuth2 | null | undefined): BrunoOAuth2
|
|
|
408
420
|
|
|
409
421
|
// token config
|
|
410
422
|
if (oauth.tokenConfig?.id) brunoOAuth.credentialsId = oauth.tokenConfig.id;
|
|
423
|
+
if (oauth.tokenConfig?.source) brunoOAuth.tokenSource = oauth.tokenConfig.source || 'access_token';
|
|
411
424
|
if (oauth.tokenConfig?.placement) {
|
|
412
425
|
if ('header' in oauth.tokenConfig.placement) {
|
|
413
426
|
brunoOAuth.tokenPlacement = 'header';
|
|
@@ -454,6 +467,7 @@ export const toBrunoOAuth2 = (oauth: AuthOAuth2 | null | undefined): BrunoOAuth2
|
|
|
454
467
|
|
|
455
468
|
// token config
|
|
456
469
|
if (oauth.tokenConfig?.id) brunoOAuth.credentialsId = oauth.tokenConfig.id;
|
|
470
|
+
if (oauth.tokenConfig?.source) brunoOAuth.tokenSource = oauth.tokenConfig.source || 'access_token';
|
|
457
471
|
if (oauth.tokenConfig?.placement) {
|
|
458
472
|
if ('header' in oauth.tokenConfig.placement) {
|
|
459
473
|
brunoOAuth.tokenPlacement = 'header';
|
|
@@ -502,6 +516,7 @@ export const toBrunoOAuth2 = (oauth: AuthOAuth2 | null | undefined): BrunoOAuth2
|
|
|
502
516
|
|
|
503
517
|
// token config
|
|
504
518
|
if (oauth.tokenConfig?.id) brunoOAuth.credentialsId = oauth.tokenConfig.id;
|
|
519
|
+
if (oauth.tokenConfig?.source) brunoOAuth.tokenSource = oauth.tokenConfig.source || 'access_token';
|
|
505
520
|
if (oauth.tokenConfig?.placement) {
|
|
506
521
|
if ('header' in oauth.tokenConfig.placement) {
|
|
507
522
|
brunoOAuth.tokenPlacement = 'header';
|
|
@@ -171,7 +171,8 @@ const parseHttpRequest = (ocRequest: HttpRequest): BrunoItem => {
|
|
|
171
171
|
|
|
172
172
|
if (example.response) {
|
|
173
173
|
brunoExample.response = {
|
|
174
|
-
status: example.response.status
|
|
174
|
+
status: typeof example.response.status === 'number' ? example.response.status
|
|
175
|
+
: example.response.status !== undefined ? Number(example.response.status) : null,
|
|
175
176
|
statusText: example.response.statusText || null,
|
|
176
177
|
headers: toBrunoHttpHeaders(example.response.headers) || [],
|
|
177
178
|
body: null
|
|
@@ -41,7 +41,7 @@ const parseCollection = (ymlString: string): ParsedCollection => {
|
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// bruno-specific
|
|
44
|
+
// bruno-specific extensions
|
|
45
45
|
const brunoExtensions = oc.extensions?.bruno as any;
|
|
46
46
|
if (Array.isArray(brunoExtensions?.scripts?.additionalContextRoots)) {
|
|
47
47
|
const sanitizedRoots = brunoExtensions.scripts.additionalContextRoots
|
|
@@ -54,6 +54,16 @@ const parseCollection = (ymlString: string): ParsedCollection => {
|
|
|
54
54
|
};
|
|
55
55
|
}
|
|
56
56
|
}
|
|
57
|
+
if (Array.isArray(brunoExtensions?.openapi) && brunoExtensions.openapi.length > 0) {
|
|
58
|
+
brunoConfig.openapi = brunoExtensions.openapi.map((entry: any) => ({
|
|
59
|
+
sourceUrl: entry.sourceUrl,
|
|
60
|
+
groupBy: entry.groupBy,
|
|
61
|
+
...(entry.lastSyncDate && { lastSyncDate: entry.lastSyncDate }),
|
|
62
|
+
...(entry.specHash && { specHash: entry.specHash }),
|
|
63
|
+
autoCheck: entry.autoCheck !== false,
|
|
64
|
+
autoCheckInterval: entry.autoCheckInterval || 5
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
57
67
|
|
|
58
68
|
// protobuf
|
|
59
69
|
if (oc.config?.protobuf) {
|
|
@@ -262,6 +262,21 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => {
|
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
+
// bruno-specific extensions
|
|
266
|
+
if (Array.isArray(brunoConfig.openapi) && brunoConfig.openapi.length > 0) {
|
|
267
|
+
if (!oc.extensions.bruno) {
|
|
268
|
+
oc.extensions.bruno = {};
|
|
269
|
+
}
|
|
270
|
+
(oc.extensions.bruno as any).openapi = brunoConfig.openapi.map((entry: any) => ({
|
|
271
|
+
sourceUrl: entry.sourceUrl,
|
|
272
|
+
groupBy: entry.groupBy,
|
|
273
|
+
...(entry.lastSyncDate && { lastSyncDate: entry.lastSyncDate }),
|
|
274
|
+
...(entry.specHash && { specHash: entry.specHash }),
|
|
275
|
+
autoCheck: entry.autoCheck !== false,
|
|
276
|
+
autoCheckInterval: entry.autoCheckInterval || 5
|
|
277
|
+
}));
|
|
278
|
+
}
|
|
279
|
+
|
|
265
280
|
return stringifyYml(oc);
|
|
266
281
|
} catch (error) {
|
|
267
282
|
console.error('Error stringifying opencollection.yml:', error);
|