import { GQLResponse } from 'src/proxy/types'; export function getQueryType(query: string) { const actionMatch = query.match(/\b(query|mutation)\b/u); const action = actionMatch ? (actionMatch[1] as 'query' | 'mutation') : null; const entityMatch = query.match( /\b(mutation|query)\s+\w*([A-Z][A-Za-z0-9_]+)/u, ); const entity = entityMatch ? entityMatch[2] : null; return { action, entity }; } export function extractDocumentId(data: GQLResponse) { if (!data?.data) return null; const firstKey = Object.keys(data.data)[0]; if (!firstKey) return null; return data.data[firstKey]?.documentId || null; }