@graphql-hive/laboratory
Version:
35 lines (34 loc) • 1.6 kB
TypeScript
import { LaboratoryEnv, LaboratoryEnvActions, LaboratoryEnvState } from './env';
import { LaboratoryPlugin } from './plugins';
export interface LaboratoryPreflightLog {
level: 'log' | 'warn' | 'error' | 'info' | 'system';
message: unknown[];
createdAt: string;
}
export interface LaboratoryPreflightResult {
status: 'success' | 'error';
error?: string;
logs: LaboratoryPreflightLog[];
env: LaboratoryEnv;
headers: Record<string, string>;
pluginsState: Record<string, any>;
}
export interface LaboratoryPreflight {
enabled: boolean;
script: string;
lastTestResult?: LaboratoryPreflightResult | null;
}
export interface LaboratoryPreflightState {
preflight: LaboratoryPreflight | null;
}
export interface LaboratoryPreflightActions {
setPreflight: (preflight: LaboratoryPreflight) => void;
runPreflight: (plugins?: LaboratoryPlugin[], pluginsState?: Record<string, any>) => Promise<LaboratoryPreflightResult | null>;
setLastTestResult: (result: LaboratoryPreflightResult | null) => void;
}
export declare const usePreflight: (props: {
defaultPreflight?: LaboratoryPreflight | null;
onPreflightChange?: (preflight: LaboratoryPreflight | null) => void;
envApi: LaboratoryEnvState & LaboratoryEnvActions;
}) => LaboratoryPreflightState & LaboratoryPreflightActions;
export declare function runIsolatedLabScript(script: string, env: LaboratoryEnv, prompt?: (placeholder: string, defaultValue: string) => Promise<string | null>, plugins?: LaboratoryPlugin[], pluginsState?: Record<string, any>): Promise<LaboratoryPreflightResult>;