import { useQuery } from "@tanstack/react-query"; import { listMemoryRequests } from "@/services/memory"; import { queryKeys } from "@/lib/query-keys"; import { useRuntimeContext } from "@/providers/runtime-context-provider"; import type { MemoryScope } from "@/types/memory"; export function useMemoryRequests( memoryStoreName: string, scope: MemoryScope | null, nextToken?: string, limit = 20, operation?: string, ) { const { context, ready } = useRuntimeContext(); return useQuery({ queryKey: queryKeys.memoryRequests( context.dataScopeKey, memoryStoreName, scope, nextToken, limit, operation, ), queryFn: () => listMemoryRequests(memoryStoreName, scope!, { nextToken, limit, operation, }), enabled: ready && !!memoryStoreName && !!scope?.appId, }); }