UNPKG

@graphql-hive/laboratory

Version:

[Hive](https://the-guild.dev/graphql/hive) is a fully open-source schema registry, analytics, metrics and gateway for [GraphQL federation](https://the-guild.dev/graphql/hive/federation) and other GraphQL APIs.

42 lines (41 loc) 1.83 kB
import { LaboratoryContextProps } from '../components/laboratory/context'; import { LaboratoryTabCustom } from './tabs'; export interface LaboratoryPluginTab<State = Record<string, unknown>> { type: string; name: string | ((laboratory: LaboratoryContextProps, state: State) => string); icon?: React.ReactNode | ((laboratory: LaboratoryContextProps, state: State) => React.ReactNode); component: (tab: LaboratoryTabCustom, laboratory: LaboratoryContextProps, state: State, setState: (state: State) => void) => React.ReactNode; } export interface LaboratoryPlugin<State = Record<string, unknown>> { id: string; name: string; description?: string; icon?: React.ReactNode; defaultState?: State; onStateChange?: (state: State) => void; tabs?: LaboratoryPluginTab<State>[]; commands?: { name: string | ((laboratory: LaboratoryContextProps, state: State) => string); icon?: React.ReactNode | ((laboratory: LaboratoryContextProps, state: State) => React.ReactNode); onClick: (laboratory: LaboratoryContextProps, state: State) => void; }[]; preflight?: { lab?: { definition?: string; props?: Record<string, string>; object: (props: Record<string, string>, state: State, setState: (state: State) => void) => Record<string, unknown>; }; }; } export interface LaboratoryPluginsState { plugins: LaboratoryPlugin[]; pluginsState: Record<string, any>; } export interface LaboratoryPluginsActions { setPluginsState: (state: Record<string, any>) => void; } export declare const usePlugins: (props: { plugins?: LaboratoryPlugin[]; defaultPluginsState?: Record<string, any>; onPluginsStateChange?: (state: Record<string, any>) => void; }) => LaboratoryPluginsState & LaboratoryPluginsActions;