import { zSearchTypes } from '../enums/SearchTypes'; import { Query, QueryEdit } from '../services/QueryService'; const latestEdit = (query: Query | null): QueryEdit | null => { if (!query) return null; return query.edits[query.edits.length - 1] ?? null; }; const currentValue = (query: Query | null): string | null => { const edit = latestEdit(query); return edit?.value ?? query?.output ?? null; }; const typeName = (query: Query | null): string => { if (!query) return ''; switch (query.type) { case zSearchTypes.enum.Semantic: return 'Search'; case zSearchTypes.enum.Question: return 'Question'; default: return 'Question'; } }; const QueryUtil = { latestEdit, currentValue, typeName, }; export default QueryUtil;