mirror of
https://github.com/usebruno/bruno.git
synced 2026-07-08 22:45:25 +00:00
fix: grpc import paths (#6726)
* fix: grpc import paths * refactor: extract protobuf include directory logic into a separate function * rm: comment * fix: improve filtering of enabled import paths in protobuf configuration * refactor: streamline import path handling in protobuf configuration
This commit is contained in:
@@ -1,6 +1,3 @@
|
||||
import cloneDeep from 'lodash/cloneDeep';
|
||||
import { resolvePath } from 'utils/filesystem';
|
||||
|
||||
export const sendNetworkRequest = async (item, collection, environment, runtimeVariables) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (['http-request', 'graphql-request'].includes(item.type)) {
|
||||
@@ -143,25 +140,10 @@ export const endGrpcStream = async (requestId) => {
|
||||
};
|
||||
|
||||
export const loadGrpcMethodsFromProtoFile = async (filePath, collection = null) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
const { ipcRenderer } = window;
|
||||
|
||||
// Extract import paths from collection's gRPC config if available
|
||||
let importPaths = [];
|
||||
|
||||
if (collection) {
|
||||
const config = cloneDeep(collection.brunoConfig);
|
||||
|
||||
if (config.protobuf && config.protobuf.importPaths) {
|
||||
// Use Promise.all to wait for all resolvePath calls to complete
|
||||
const enabledImportPaths = config.protobuf.importPaths.filter((importPath) => importPath.enabled);
|
||||
importPaths = await Promise.all(enabledImportPaths.map((importPath) => {
|
||||
return resolvePath(importPath.path, collection.pathname);
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
ipcRenderer.invoke('grpc:load-methods-proto', { filePath, includeDirs: importPaths }).then(resolve).catch(reject);
|
||||
ipcRenderer.invoke('grpc:load-methods-proto', { filePath, collection }).then(resolve).catch(reject);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user