fix: update protobuf and import path handling in opencollection (#7166)

This commit is contained in:
naman-bruno
2026-02-17 15:15:32 +05:30
committed by Bijin A B
parent ec9a03f208
commit db612679d6
5 changed files with 23 additions and 15 deletions

View File

@@ -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;

View File

@@ -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
}))
};
}

View File

@@ -177,7 +177,7 @@ export interface BrunoConfig {
};
protobuf?: {
protoFiles?: { path: string }[];
importPaths?: { path: string; disabled?: boolean }[];
importPaths?: { path: string; enabled?: boolean }[];
};
proxy?: {
disabled?: boolean;

View File

@@ -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
})) || []
};
}

View File

@@ -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