mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-23 18:01:08 +01:00
Proto files off model
This commit is contained in:
@@ -11,12 +11,16 @@ export interface ReflectResponseService {
|
||||
methods: { name: string; schema: string; serverStreaming: boolean; clientStreaming: boolean }[];
|
||||
}
|
||||
|
||||
export function useGrpc(req: GrpcRequest | null, conn: GrpcConnection | null) {
|
||||
export function useGrpc(
|
||||
req: GrpcRequest | null,
|
||||
conn: GrpcConnection | null,
|
||||
protoFiles: string[],
|
||||
) {
|
||||
const requestId = req?.id ?? 'n/a';
|
||||
const environmentId = useActiveEnvironmentId();
|
||||
|
||||
const go = useMutation<void, string>({
|
||||
mutationFn: async () => await invoke('cmd_grpc_go', { requestId, environmentId }),
|
||||
mutationFn: async () => await invoke('cmd_grpc_go', { requestId, environmentId, protoFiles }),
|
||||
});
|
||||
|
||||
const send = useMutation({
|
||||
@@ -35,13 +39,13 @@ export function useGrpc(req: GrpcRequest | null, conn: GrpcConnection | null) {
|
||||
});
|
||||
|
||||
const debouncedUrl = useDebouncedValue<string>(req?.url ?? 'n/a', 1000);
|
||||
const reflect = useQuery<ReflectResponseService[] | null, string>({
|
||||
const reflect = useQuery<ReflectResponseService[], string>({
|
||||
enabled: req != null,
|
||||
queryKey: ['grpc_reflect', req?.id ?? 'n/a', debouncedUrl],
|
||||
refetchOnWindowFocus: false,
|
||||
queryFn: async () => {
|
||||
return (await minPromiseMillis(
|
||||
invoke('cmd_grpc_reflect', { requestId }),
|
||||
invoke('cmd_grpc_reflect', { requestId, protoFiles }),
|
||||
300,
|
||||
)) as ReflectResponseService[];
|
||||
},
|
||||
|
||||
10
src-web/hooks/useGrpcProtoFiles.ts
Normal file
10
src-web/hooks/useGrpcProtoFiles.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { NAMESPACE_GLOBAL } from '../lib/keyValueStore';
|
||||
import { useKeyValue } from './useKeyValue';
|
||||
|
||||
export function useGrpcProtoFiles(activeRequestId: string | null) {
|
||||
return useKeyValue<string[]>({
|
||||
namespace: NAMESPACE_GLOBAL,
|
||||
key: ['proto_files', activeRequestId ?? 'n/a'],
|
||||
defaultValue: [],
|
||||
});
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { NAMESPACE_APP } from '../lib/keyValueStore';
|
||||
import { useKeyValue } from './useKeyValue';
|
||||
|
||||
export function useUpdateMode() {
|
||||
const kv = useKeyValue<'stable' | 'beta'>({
|
||||
namespace: NAMESPACE_APP,
|
||||
key: 'update_mode',
|
||||
defaultValue: 'stable',
|
||||
});
|
||||
|
||||
return [kv.value, kv.set] as const;
|
||||
}
|
||||
Reference in New Issue
Block a user