From db612679d6ad567c2fd2ae6cbcb1bab0bd2b0f86 Mon Sep 17 00:00:00 2001 From: naman-bruno Date: Tue, 17 Feb 2026 15:15:32 +0530 Subject: [PATCH] fix: update protobuf and import path handling in opencollection (#7166) --- .../opencollection/bruno-to-opencollection.ts | 2 +- .../opencollection/opencollection-to-bruno.ts | 2 +- .../src/opencollection/types.ts | 2 +- .../src/formats/yml/parseCollection.ts | 4 +-- .../src/formats/yml/stringifyCollection.ts | 28 ++++++++++++------- 5 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts b/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts index 3cdbf6688..6fa5dc92e 100644 --- a/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts +++ b/packages/bruno-converters/src/opencollection/bruno-to-opencollection.ts @@ -24,7 +24,7 @@ const toOpenCollectionConfig = (brunoConfig: BrunoConfig | undefined): Collectio if (brunoConfig.protobuf.importPaths?.length) { config.protobuf.importPaths = brunoConfig.protobuf.importPaths.map((p) => { const importPath: { path: string; disabled?: boolean } = { path: p.path }; - if (p.disabled) { + if (p.enabled === false) { importPath.disabled = true; } return importPath; diff --git a/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts b/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts index 76a8c476b..c934c435d 100644 --- a/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts +++ b/packages/bruno-converters/src/opencollection/opencollection-to-bruno.ts @@ -48,7 +48,7 @@ const fromOpenCollectionConfig = (oc: OpenCollection): BrunoConfig => { })), importPaths: config.protobuf.importPaths?.map((p) => ({ path: p.path, - disabled: p.disabled || false + enabled: p.disabled !== true })) }; } diff --git a/packages/bruno-converters/src/opencollection/types.ts b/packages/bruno-converters/src/opencollection/types.ts index 0750407a2..5512ef8a9 100644 --- a/packages/bruno-converters/src/opencollection/types.ts +++ b/packages/bruno-converters/src/opencollection/types.ts @@ -177,7 +177,7 @@ export interface BrunoConfig { }; protobuf?: { protoFiles?: { path: string }[]; - importPaths?: { path: string; disabled?: boolean }[]; + importPaths?: { path: string; enabled?: boolean }[]; }; proxy?: { disabled?: boolean; diff --git a/packages/bruno-filestore/src/formats/yml/parseCollection.ts b/packages/bruno-filestore/src/formats/yml/parseCollection.ts index 3fa916a3f..55555bdad 100644 --- a/packages/bruno-filestore/src/formats/yml/parseCollection.ts +++ b/packages/bruno-filestore/src/formats/yml/parseCollection.ts @@ -58,12 +58,12 @@ const parseCollection = (ymlString: string): ParsedCollection => { // protobuf if (oc.config?.protobuf) { brunoConfig.protobuf = { - protofFiles: oc.config.protobuf.protoFiles?.map((protoFile: any) => ({ + protoFiles: oc.config.protobuf.protoFiles?.map((protoFile: any) => ({ path: protoFile.path })) || [], importPaths: oc.config.protobuf.importPaths?.map((importPath: any) => ({ path: importPath.path, - disabled: importPath.disabled || false + enabled: importPath.disabled !== true })) || [] }; } diff --git a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts index b66a86dd7..6ceb416fb 100644 --- a/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts +++ b/packages/bruno-filestore/src/formats/yml/stringifyCollection.ts @@ -16,7 +16,7 @@ import type { Auth } from '@opencollection/types/common/auth'; const hasCollectionConfig = (brunoConfig: any): boolean => { // protobuf const hasProtobuf = ( - brunoConfig.protobuf?.protofFiles?.length > 0 + brunoConfig.protobuf?.protoFiles?.length > 0 || brunoConfig.protobuf?.importPaths?.length > 0 ); @@ -77,17 +77,25 @@ const stringifyCollection = (collectionRoot: any, brunoConfig: any): string => { if (hasCollectionConfig(brunoConfig)) { oc.config = {}; - if (brunoConfig.protobuf?.protofFiles?.length) { - oc.config.protobuf = { - protoFiles: brunoConfig.protobuf.protofFiles.map((protoFile: any): ProtoFileItem => ({ + if (brunoConfig.protobuf?.protoFiles?.length || brunoConfig.protobuf?.importPaths?.length) { + oc.config.protobuf = {}; + + if (brunoConfig.protobuf.protoFiles?.length) { + oc.config.protobuf.protoFiles = brunoConfig.protobuf.protoFiles.map((protoFile: any): ProtoFileItem => ({ type: 'file' as const, path: protoFile.path - })), - importPaths: brunoConfig.protobuf.importPaths.map((importPath: any): ProtoFileImportPath => ({ - path: importPath.path, - disabled: importPath.disabled - })) - }; + })); + } + + if (brunoConfig.protobuf.importPaths?.length) { + oc.config.protobuf.importPaths = brunoConfig.protobuf.importPaths.map((importPath: any): ProtoFileImportPath => { + const item: ProtoFileImportPath = { path: importPath.path }; + if (importPath.enabled === false) { + item.disabled = true; + } + return item; + }); + } } // proxy - only write newer format