@usebruno/filestore 0.7.1 → 0.8.0

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.
@@ -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;AA6P5C,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,IAqOlF,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,SAmLlD,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
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,gBA0M5C,CAAC;AAEF,eAAe,eAAe,CAAC"}
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,MA2MpE,CAAC;AAEF,eAAe,mBAAmB,CAAC"}
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.7.1",
3
+ "version": "0.8.0",
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.2.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.34.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"
@@ -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
- if (refreshTokenRequest) {
152
- flow.additionalParameters = { refreshTokenRequest };
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
- if (refreshTokenRequest) {
188
- flow.additionalParameters = { refreshTokenRequest };
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
- if (refreshTokenRequest) {
226
- flow.additionalParameters = { refreshTokenRequest };
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 !== undefined ? String(example.response.status) : null,
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 script extensions
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);