UNPKG

@graphql-hive/laboratory

Version:

44 lines (43 loc) 1.58 kB
import { LaboratoryOperation } from './operations'; import { LaboratoryPreflightLog } from './preflight'; export interface LaboratoryHistoryRequest { id: string; status?: number; duration?: number; size?: number; response: string; headers: string; operation: LaboratoryOperation; preflightLogs?: LaboratoryPreflightLog[]; createdAt: string; } export interface LaboratoryHistorySubscription { id: string; responses: { createdAt: string; data: string; }[]; preflightLogs?: LaboratoryPreflightLog[]; operation: LaboratoryOperation; createdAt: string; } export type LaboratoryHistory = LaboratoryHistoryRequest | LaboratoryHistorySubscription; export interface LaboratoryHistoryState { history: LaboratoryHistory[]; } export interface LaboratoryHistoryActions { addHistory: (history: Omit<LaboratoryHistory, "id">) => LaboratoryHistory; addResponseToHistory: (historyId: string, response: string) => void; deleteHistory: (historyId: string) => void; deleteHistoryByDay: (day: string) => void; deleteAllHistory: () => void; } export interface LaboratoryHistoryCallbacks { onHistoryCreate?: (history: LaboratoryHistory) => void; onHistoryUpdate?: (history: LaboratoryHistory) => void; onHistoryDelete?: (history: LaboratoryHistory) => void; } export declare const useHistory: (props: { defaultHistory?: LaboratoryHistory[]; onHistoryChange?: (history: LaboratoryHistory[]) => void; } & LaboratoryHistoryCallbacks) => LaboratoryHistoryState & LaboratoryHistoryActions;