@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.
633 lines • 30.4 kB
TypeScript
import { ReactNode } from "react";
import { ExecutionResult, GraphQLSchema, IntrospectionQuery } from "graphql";
import { DebouncedFunc } from "lodash";
import * as monaco from "monaco-editor";
import MonacoEditor from "@monaco-editor/react";
import * as DialogPrimitive from "@radix-ui/react-dialog";
import * as TabsPrimitive from "@radix-ui/react-tabs";
export interface LaboratoryEnv {
variables: Record<string, string>;
}
export interface LaboratoryEnvState {
env: LaboratoryEnv | null;
}
export interface LaboratoryEnvActions {
setEnv: (env: LaboratoryEnv) => void;
}
export declare const useEnv: (props: {
defaultEnv?: LaboratoryEnv | null;
onEnvChange?: (env: LaboratoryEnv | null) => void;
}) => LaboratoryEnvState & LaboratoryEnvActions;
export interface LaboratoryPreflightLog {
level: 'log' | 'warn' | 'error' | 'info' | 'system';
message: unknown[];
createdAt: string;
/** Where in the script this came from, when the browser reports a usable stack. */
line?: number;
column?: number;
}
/**
* Maps a stack frame back onto the user's script. The script runs inside a generated
* `AsyncFunction`, so it starts three lines in (`async function anonymous(…`, `) {`,
* `with(lab){`). A `console.x` frame points at the member name rather than the statement,
* which is what `columnOffset` is for.
*/
export declare const readLineAndColumn: (stack?: string, columnOffset?: number) => {
line?: undefined;
column?: undefined;
} | {
line: number;
column: number;
};
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;
/** Logs from every run, oldest first, not just the ones started from the Test button. */
preflightLogs: LaboratoryPreflightLog[];
isPreflightRunning: boolean;
}
/** The script-supplied parts of a `lab.prompt()` call. */
export interface LaboratoryPreflightPromptField {
title?: string;
defaultValue?: string;
description?: string;
placeholder?: string;
}
/** A single `lab.prompt()` call waiting on the user. */
export interface LaboratoryPreflightPromptRequest extends LaboratoryPreflightPromptField {
onSubmit?: (value: string | null) => void;
}
export type LaboratoryPreflightPrompt = (title: string, defaultValue: string, options?: {
placeholder?: string;
description?: string;
}) => Promise<string | null>;
/**
* How long a script may run before the worker is killed.
* The clock only covers execution: it is paused while a
* prompt is waiting on the user.
*/
export declare const PREFLIGHT_TIMEOUT = 30000;
/**
* Environment values are interpolated into headers as text and persisted by the host, so a
* script can only store JSON scalars. Defined here and injected into the worker by source, so
* the rule is stated once.
*/
export declare const isValidEnvValue: (value: unknown) => boolean;
/**
* A function or `Headers` cannot cross postMessage; the clone error would fail the run.
* Injected by source like `isValidEnvValue`, so no outer references.
*/
export declare const toLogText: (value: unknown) => string;
export declare const blockedGlobalNames: (names: Iterable<string>, allowed: ReadonlySet<string>) => string[];
export interface LaboratoryPreflightRunOptions {
/** Aborting terminates the worker and settles the run as an error. */
signal?: AbortSignal;
/** Called as each log arrives, so a long-running script reports before it finishes. */
onLog?: (log: LaboratoryPreflightLog) => void;
}
export interface LaboratoryPreflightActions {
setPreflight: (preflight: LaboratoryPreflight) => void;
runPreflight: (plugins?: LaboratoryPlugin[], pluginsState?: Record<string, any>) => Promise<LaboratoryPreflightResult | null>;
/** Runs the script on demand, ignoring `preflight.enabled`, and records the result. */
testPreflight: (plugins?: LaboratoryPlugin[], pluginsState?: Record<string, any>) => Promise<LaboratoryPreflightResult | null>;
/** Stops every in-flight run and releases any prompt waiting on the user. */
abortPreflight: () => void;
clearPreflightLogs: () => void;
setLastTestResult: (result: LaboratoryPreflightResult | null) => void;
}
/**
* Owns the one prompt dialog every preflight run shares. Runs overlap in practice (an
* operation run while schema polling has a prompt open), and only one request can be on
* screen, so a displaced request is answered with null rather than left waiting.
*/
export declare const usePreflightPrompt: () => {
isPreflightPromptModalOpen: boolean;
setIsPreflightPromptModalOpen: import("react").Dispatch<import("react").SetStateAction<boolean>>;
preflightPromptModalProps: LaboratoryPreflightPromptRequest;
openPreflightPromptModal: (request: LaboratoryPreflightPromptRequest) => void;
closePreflightPromptModal: () => void;
};
export declare const usePreflight: (props: {
defaultPreflight?: LaboratoryPreflight | null;
onPreflightChange?: (preflight: LaboratoryPreflight | null) => void;
envApi: LaboratoryEnvState & LaboratoryEnvActions;
openPreflightPromptModal?: (request: LaboratoryPreflightPromptRequest) => void;
/** Releases a prompt still waiting on the user, so aborting doesn't strand the dialog. */
closePreflightPromptModal?: () => void;
}) => LaboratoryPreflightState & LaboratoryPreflightActions;
export declare function runIsolatedLabScript(script: string, env: LaboratoryEnv, prompt?: LaboratoryPreflightPrompt, plugins?: LaboratoryPlugin[], pluginsState?: Record<string, any>, options?: LaboratoryPreflightRunOptions): Promise<LaboratoryPreflightResult>;
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;
export interface LaboratoryTestTaskBase {
id: string;
next: string | null;
}
export interface LaboratoryTestTaskOperation extends LaboratoryTestTaskBase {
type: 'operation';
data: Pick<LaboratoryOperation, 'id'>;
}
export interface LaboratoryTestTaskUtlity extends LaboratoryTestTaskBase {
type: 'utility';
data: unknown;
}
export type LaboratoryTestTask = LaboratoryTestTaskOperation | LaboratoryTestTaskUtlity;
export interface LaboratoryTest {
id: string;
name: string;
description?: string;
createdAt: string;
tasks: LaboratoryTestTask[];
}
export interface LaboratoryTestState {
tests: LaboratoryTest[];
}
export interface LaboratoryTestActions {
addTest: (test: Omit<LaboratoryTest, 'id' | 'createdAt' | 'tasks'>) => LaboratoryTest;
addTaskToTest: (testId: string, task: Pick<LaboratoryTestTask, 'type' | 'data'>) => void;
deleteTaskFromTest: (testId: string, taskId: string) => void;
deleteTest: (testId: string) => void;
}
export declare const useTests: (props: {
defaultTests?: LaboratoryTest[];
onTestsChange?: (test: LaboratoryTest[]) => void;
}) => LaboratoryTestState & LaboratoryTestActions;
export interface LaboratoryTabOperation {
id: string;
type: 'operation';
data: Pick<LaboratoryOperation, 'id' | 'name'>;
readOnly?: boolean;
}
export interface LaboratoryTabHistory {
id: string;
type: 'history';
data: Pick<LaboratoryHistoryRequest, 'id'>;
readOnly?: boolean;
}
export interface LaboratoryTabPreflight {
id: string;
type: 'preflight';
data: LaboratoryPreflight;
readOnly?: boolean;
}
export interface LaboratoryTabEnv {
id: string;
type: 'env';
data: LaboratoryEnv;
readOnly?: boolean;
}
export interface LaboratoryTabTest {
id: string;
type: 'test';
data: Pick<LaboratoryTest, 'id' | 'name'>;
readOnly?: boolean;
}
export interface LaboratoryTabSettings {
id: string;
type: 'settings';
data: unknown;
readOnly?: boolean;
}
export interface LaboratoryTabCustom {
id: string;
type: string;
data: unknown;
readOnly?: boolean;
}
export type LaboratoryTabData = Pick<LaboratoryOperation, 'id' | 'name'> | Pick<LaboratoryHistoryRequest, 'id'> | LaboratoryPreflight | LaboratoryEnv;
export type LaboratoryTab = LaboratoryTabOperation | LaboratoryTabPreflight | LaboratoryTabEnv | LaboratoryTabHistory | LaboratoryTabSettings | LaboratoryTabTest | LaboratoryTabCustom;
export interface LaboratoryTabsState {
tabs: LaboratoryTab[];
}
export interface LaboratoryTabsActions {
activeTab: LaboratoryTab | null;
setActiveTab: (tab: LaboratoryTab) => void;
setTabs: (tabs: LaboratoryTab[]) => void;
addTab: (tab: Omit<LaboratoryTab, 'id'>) => LaboratoryTab;
updateTab: (id: string, data: LaboratoryTabData) => void;
deleteTab: (tabId: string) => void;
/** Points operation tabs at an operation's persisted id. */
replaceOperationId: (previousId: string, id: string) => void;
}
export declare const useTabs: (props: {
defaultTabs?: LaboratoryTab[] | null;
defaultActiveTabId?: string | null;
onTabsChange?: (tabs: LaboratoryTab[]) => void;
onActiveTabIdChange?: (tabId: string | null) => void;
}) => LaboratoryTabsState & LaboratoryTabsActions;
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;
export type LaboratorySettings = {
fetch: {
credentials: 'include' | 'omit' | 'same-origin';
timeout?: number;
useGETForQueries?: boolean;
};
subscriptions: {
protocol: 'SSE' | 'GRAPHQL_SSE' | 'WS' | 'LEGACY_WS';
};
introspection: {
method?: 'GET' | 'POST';
headers?: string;
includeActiveOperationHeaders?: boolean;
pollSchema?: boolean;
};
};
export declare const defaultLaboratorySettings: LaboratorySettings;
export declare const normalizeLaboratorySettings: (settings?: Partial<LaboratorySettings> | null) => LaboratorySettings;
export interface LaboratorySettingsState {
settings: LaboratorySettings;
}
export interface LaboratorySettingsActions {
setSettings: (settings: LaboratorySettings) => void;
}
export declare const useSettings: (props: {
defaultSettings?: LaboratorySettings | null;
onSettingsChange?: (settings: LaboratorySettings | null) => void;
}) => LaboratorySettingsState & LaboratorySettingsActions;
export interface LaboratoryOperation {
id: string;
name: string;
query: string;
variables: string;
headers: string;
extensions: string;
}
export interface LaboratoryOperationsState {
operations: LaboratoryOperation[];
activeOperation: LaboratoryOperation | null;
}
export interface LaboratoryOperationsActions {
setActiveOperation: (operationId: string) => void;
addOperation: (operation: Omit<LaboratoryOperation, 'id'> & {
id?: string;
}) => LaboratoryOperation;
setOperations: (operations: LaboratoryOperation[]) => void;
/** Renames an operation in place once the host has stored it under its own id. */
replaceOperationId: (previousId: string, id: string) => void;
updateActiveOperation: (operation: Partial<Omit<LaboratoryOperation, 'id'>>) => void;
deleteOperation: (operationId: string) => void;
/** With a schema, an abstract field is given `__typename` so it is never selection-less. */
addPathToActiveOperation: (path: string, operationName?: string | null, schema?: GraphQLSchema) => void;
deletePathFromActiveOperation: (path: string, operationName?: string | null) => void;
addArgToActiveOperation: (path: string, argName: string, schema: GraphQLSchema, operationName?: string | null) => void;
deleteArgFromActiveOperation: (path: string, argName: string, operationName?: string | null) => void;
runActiveOperation: (endpoint: string, options?: {
env?: LaboratoryEnv;
headers?: Record<string, string>;
operationName?: string;
onResponse?: (response: string) => void;
}) => Promise<ExecutionResult | null>;
stopActiveOperation: (() => void) | null;
isActiveOperationLoading: boolean;
isOperationLoading: (operationId: string) => boolean;
isOperationSubscription: (operation: LaboratoryOperation) => boolean;
isActiveOperationSubscription: boolean;
}
export interface LaboratoryOperationsCallbacks {
onOperationCreate?: (operation: LaboratoryOperation) => void;
onOperationUpdate?: (operation: LaboratoryOperation) => void;
onOperationDelete?: (operation: LaboratoryOperation) => void;
}
export declare const useOperations: (props: {
checkPermissions: (permission: `${keyof LaboratoryPermissions & string}:${keyof LaboratoryPermission & string}`) => boolean;
defaultOperations?: LaboratoryOperation[];
defaultActiveOperationId?: string;
onOperationsChange?: (operations: LaboratoryOperation[]) => void;
onActiveOperationIdChange?: (operationId: string) => void;
collectionsApi?: LaboratoryCollectionsState & LaboratoryCollectionsActions;
tabsApi?: LaboratoryTabsState & LaboratoryTabsActions;
envApi?: LaboratoryEnvState & LaboratoryEnvActions;
preflightApi?: LaboratoryPreflightState & LaboratoryPreflightActions;
settingsApi?: LaboratorySettingsState & LaboratorySettingsActions;
pluginsApi?: LaboratoryPluginsState & LaboratoryPluginsActions;
} & LaboratoryOperationsCallbacks) => LaboratoryOperationsState & LaboratoryOperationsActions;
export interface LaboratoryCollectionOperation extends LaboratoryOperation {
id: string;
name: string;
description: string;
createdAt: string;
}
export interface LaboratoryCollection {
id: string;
name: string;
description?: string;
createdAt: string;
operations: LaboratoryCollectionOperation[];
}
export interface LaboratoryCollectionsActions {
addCollection: (collection: Omit<LaboratoryCollection, 'id' | 'createdAt' | 'operations'> & {
operations?: Omit<LaboratoryCollectionOperation, 'createdAt'>[];
}) => LaboratoryCollection;
addOperationToCollection: (collectionId: string, operation: Omit<LaboratoryCollectionOperation, 'createdAt'>) => void;
deleteCollection: (collectionId: string) => void;
deleteOperationFromCollection: (collectionId: string, operationId: string) => void;
updateCollection: (collectionId: string, collection: Omit<LaboratoryCollection, 'id' | 'createdAt' | 'operations'>) => void;
updateOperationInCollection: (collectionId: string, operationId: string, operation: Omit<LaboratoryCollectionOperation, 'id' | 'createdAt'>) => void;
}
export interface LaboratoryCollectionsState {
collections: LaboratoryCollection[];
}
/** A host may answer a create with the id it stored, and the lab adopts it. */
export type LaboratoryPersisted = void | {
id: string;
} | Promise<void | {
id: string;
}>;
export interface LaboratoryCollectionsCallbacks {
onCollectionCreate?: (collection: LaboratoryCollection) => LaboratoryPersisted;
onCollectionUpdate?: (collection: LaboratoryCollection) => void;
onCollectionDelete?: (collection: LaboratoryCollection) => void;
onCollectionOperationCreate?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => LaboratoryPersisted;
onCollectionOperationUpdate?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
onCollectionOperationDelete?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
}
export declare const useCollections: (props: {
defaultCollections?: LaboratoryCollection[];
onCollectionsChange?: (collections: LaboratoryCollection[]) => void;
/** A saved operation took its persisted id; working copies and tabs follow it. */
onOperationIdChange?: (previousId: string, id: string) => void;
tabsApi?: LaboratoryTabsState & LaboratoryTabsActions;
} & LaboratoryCollectionsCallbacks) => LaboratoryCollectionsState & LaboratoryCollectionsActions;
export type LaboratoryActivePanel = 'collections' | 'history' | 'docs' | 'tests' | 'settings' | null;
/**
* Targets are held by name rather than by schema object: a poll or an endpoint
* switch replaces every type instance, and a stack of stale references would
* keep rendering a schema the user is no longer looking at.
*/
export type LaboratoryDocsTarget = {
kind: 'type';
name: string;
} | {
kind: 'field';
typeName: string;
fieldName: string;
};
/**
* Builder rows identify a field by its dotted path from an operation root
* (`query.me.id`), which carries no parent type. Walking it back to one is what
* lets a row open the field it actually represents rather than its return type.
*/
export declare const docsTargetFromPath: (path: string[], schema: GraphQLSchema | null) => LaboratoryDocsTarget | null;
export interface LaboratoryDocsState {
activePanel: LaboratoryActivePanel;
/** Empty means the root view listing the operation types. */
docsNavStack: LaboratoryDocsTarget[];
}
export interface LaboratoryDocsActions {
setActivePanel: (panel: LaboratoryActivePanel) => void;
openDocs: (target?: LaboratoryDocsTarget) => void;
pushDocs: (target: LaboratoryDocsTarget) => void;
popDocs: () => void;
resetDocs: () => void;
}
export declare const useDocs: (props: {
defaultActivePanel?: LaboratoryActivePanel;
}) => LaboratoryDocsState & LaboratoryDocsActions;
export interface LaboratoryEndpointState {
endpoint: string | null;
schema: GraphQLSchema | null;
introspection: IntrospectionQuery | null;
defaultEndpoint: string | null;
canIntrospect: boolean;
shouldPollSchema: boolean;
isFetchingSchema: boolean;
}
export type FetchSchemaOptions = {
env?: LaboratoryEnv;
pluginsState?: Record<string, any>;
/** Introspect over the network even when a default introspection is available. */
force?: boolean;
};
export type FetchSchema = DebouncedFunc<(signal?: AbortSignal, options?: FetchSchemaOptions) => Promise<void>>;
export interface LaboratoryEndpointActions {
setEndpoint: (endpoint: string) => void;
fetchSchema: FetchSchema;
reloadSchema: () => void;
restoreDefaultEndpoint: () => void;
}
export declare const EXPECTED_ERROR_REASON = "Expected error reason";
export declare const useEndpoint: (props: {
defaultEndpoint?: string | null;
onEndpointChange?: (endpoint: string | null) => void;
defaultSchemaIntrospection?: IntrospectionQuery | null;
enableDocs?: boolean;
settingsApi?: LaboratorySettingsState & LaboratorySettingsActions;
operationsApi?: LaboratoryOperationsState & LaboratoryOperationsActions;
envApi?: LaboratoryEnvState & LaboratoryEnvActions;
pluginsApi?: LaboratoryPluginsState & LaboratoryPluginsActions;
preflightApi?: LaboratoryPreflightState & LaboratoryPreflightActions;
}) => LaboratoryEndpointState & LaboratoryEndpointActions;
type LaboratoryContextState = LaboratoryCollectionsState & LaboratoryEndpointState & LaboratoryOperationsState & LaboratoryHistoryState & LaboratoryTabsState & LaboratoryPreflightState & LaboratoryEnvState & LaboratorySettingsState & LaboratoryPluginsState & LaboratoryDocsState & LaboratoryTestState & {
isFullScreen?: boolean;
enableFullScreen?: boolean;
enableDocs?: boolean;
preflightNotice?: ReactNode;
theme?: 'light' | 'dark';
};
type LaboratoryContextActions = LaboratoryCollectionsActions & LaboratoryEndpointActions & LaboratoryOperationsActions & LaboratoryHistoryActions & LaboratoryTabsActions & LaboratoryPreflightActions & LaboratoryEnvActions & LaboratorySettingsActions & LaboratoryPluginsActions & LaboratoryDocsActions & LaboratoryTestActions & {
openAddCollectionDialog?: () => void;
openUpdateEndpointDialog?: () => void;
openAddTestDialog?: () => void;
openPreflightPromptModal?: (request: LaboratoryPreflightPromptRequest) => void;
goToFullScreen?: () => void;
exitFullScreen?: () => void;
checkPermissions?: (permission: `${keyof LaboratoryPermissions & string}:${keyof LaboratoryPermission & string}`) => boolean;
};
type LaboratoryContext = LaboratoryContextState & LaboratoryContextActions & {
container: HTMLDivElement | null;
};
declare const LaboratoryContext: import("react").Context<LaboratoryContext>;
export declare const useLaboratory: () => LaboratoryContext;
export interface LaboratoryPermission {
read?: boolean;
create?: boolean;
update?: boolean;
delete?: boolean;
}
export interface LaboratoryPermissions {
preflight?: Partial<LaboratoryPermission>;
collections?: Partial<LaboratoryPermission>;
collectionsOperations?: Partial<LaboratoryPermission>;
}
export interface LaboratoryApi {
theme?: 'light' | 'dark';
defaultEndpoint?: string | null;
onEndpointChange?: (endpoint: string | null) => void;
defaultSchemaIntrospection?: IntrospectionQuery | null;
defaultCollections?: LaboratoryCollection[];
onCollectionsChange?: (collections: LaboratoryCollection[]) => void;
onCollectionCreate?: (collection: LaboratoryCollection) => void;
onCollectionUpdate?: (collection: LaboratoryCollection) => void;
onCollectionDelete?: (collection: LaboratoryCollection) => void;
onCollectionOperationCreate?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
onCollectionOperationUpdate?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
onCollectionOperationDelete?: (collection: LaboratoryCollection, operation: LaboratoryCollectionOperation) => void;
defaultOperations?: LaboratoryOperation[];
defaultActiveOperationId?: string;
onOperationsChange?: (operations: LaboratoryOperation[]) => void;
onActiveOperationIdChange?: (operationId: string) => void;
onOperationCreate?: (operation: LaboratoryOperation) => void;
onOperationUpdate?: (operation: LaboratoryOperation) => void;
onOperationDelete?: (operation: LaboratoryOperation) => void;
defaultHistory?: LaboratoryHistory[];
onHistoryChange?: (history: LaboratoryHistory[]) => void;
onHistoryCreate?: (history: LaboratoryHistory) => void;
onHistoryUpdate?: (history: LaboratoryHistory) => void;
onHistoryDelete?: (history: LaboratoryHistory) => void;
openAddCollectionDialog?: () => void;
openUpdateEndpointDialog?: () => void;
openAddTestDialog?: () => void;
openPreflightPromptModal?: (request: LaboratoryPreflightPromptRequest) => void;
isFullScreen?: boolean;
/** Show the full screen control. Off for hosts that already fill the viewport. */
enableFullScreen?: boolean;
/**
* Show the schema documentation pane. Off unless explicitly enabled. Also decides
* whether introspection asks for descriptions, so a host passing
* `defaultSchemaIntrospection` must build that with descriptions itself.
*/
enableDocs?: boolean;
/** Appended to the preflight warning. For hosts that share scripts between people. */
preflightNotice?: ReactNode;
goToFullScreen?: () => void;
exitFullScreen?: () => void;
defaultPreflight?: LaboratoryPreflight | null;
onPreflightChange?: (preflight: LaboratoryPreflight | null) => void;
defaultTabs?: LaboratoryTab[];
onTabsChange?: (tabs: LaboratoryTab[]) => void;
defaultActiveTabId?: string | null;
onActiveTabIdChange?: (tabId: string | null) => void;
defaultEnv?: LaboratoryEnv | null;
onEnvChange?: (env: LaboratoryEnv | null) => void;
defaultSettings?: LaboratorySettings | null;
onSettingsChange?: (settings: LaboratorySettings | null) => void;
defaultTests?: LaboratoryTest[];
onTestsChange?: (tests: LaboratoryTest[]) => void;
permissions?: LaboratoryPermissions;
checkPermissions?: (permission: `${keyof LaboratoryPermissions & string}:${keyof LaboratoryPermission & string}`) => boolean;
plugins?: LaboratoryPlugin<Record<string, any>>[];
defaultPluginsState?: Record<string, any>;
onPluginsStateChange?: (state: Record<string, any>) => void;
}
export type LaboratoryContextProps = LaboratoryContextState & LaboratoryContextActions & LaboratoryApi & {
container: HTMLDivElement | null;
};
export declare const LaboratoryProvider: (props: React.PropsWithChildren<LaboratoryContextProps>) => import("react/jsx-runtime").JSX.Element;
export type LaboratoryProps = LaboratoryApi;
export declare const Laboratory: (props: Partial<Pick<LaboratoryProps, 'permissions' | 'defaultEndpoint' | 'onEndpointChange' | 'defaultCollections' | 'onCollectionsChange' | 'onCollectionCreate' | 'onCollectionUpdate' | 'onCollectionDelete' | 'onCollectionOperationCreate' | 'onCollectionOperationUpdate' | 'onCollectionOperationDelete' | 'defaultOperations' | 'onOperationsChange' | 'defaultActiveOperationId' | 'onActiveOperationIdChange' | 'onOperationCreate' | 'onOperationUpdate' | 'onOperationDelete' | 'defaultHistory' | 'onHistoryChange' | 'onHistoryCreate' | 'onHistoryUpdate' | 'onHistoryDelete' | 'defaultTabs' | 'onTabsChange' | 'defaultPreflight' | 'onPreflightChange' | 'defaultEnv' | 'onEnvChange' | 'defaultActiveTabId' | 'onActiveTabIdChange' | 'defaultSettings' | 'onSettingsChange' | 'defaultTests' | 'onTestsChange' | 'plugins' | 'defaultPluginsState' | 'onPluginsStateChange' | 'theme' | 'defaultSchemaIntrospection' | 'enableFullScreen' | 'enableDocs'>>) => import("react/jsx-runtime").JSX.Element;
export type EditorHandle = {
setValue: (value: string) => void;
};
export type EditorProps = React.ComponentProps<typeof MonacoEditor> & {
uri?: monaco.Uri;
variablesUri?: monaco.Uri;
extraLibs?: string[];
onOperationNameChange?: (operationName: string | null) => void;
};
export declare const Editor: (props: EditorProps) => JSX.Element;
declare function Dialog({ ...props }: React.ComponentProps<typeof DialogPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
declare function DialogTrigger({ ...props }: React.ComponentProps<typeof DialogPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
declare function DialogPortal({ ...props }: React.ComponentProps<typeof DialogPrimitive.Portal>): import("react/jsx-runtime").JSX.Element;
declare function DialogClose({ ...props }: React.ComponentProps<typeof DialogPrimitive.Close>): import("react/jsx-runtime").JSX.Element;
declare function DialogOverlay({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Overlay>): import("react/jsx-runtime").JSX.Element;
declare function DialogContent({ className, children, showCloseButton, ...props }: React.ComponentProps<typeof DialogPrimitive.Content> & {
showCloseButton?: boolean;
}): import("react/jsx-runtime").JSX.Element;
declare function DialogHeader({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
declare function DialogFooter({ className, ...props }: React.ComponentProps<'div'>): import("react/jsx-runtime").JSX.Element;
declare function DialogTitle({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Title>): import("react/jsx-runtime").JSX.Element;
declare function DialogDescription({ className, ...props }: React.ComponentProps<typeof DialogPrimitive.Description>): import("react/jsx-runtime").JSX.Element;
declare function Tabs({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Root>): import("react/jsx-runtime").JSX.Element;
declare function TabsList({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.List>): import("react/jsx-runtime").JSX.Element;
declare function TabsTrigger({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Trigger>): import("react/jsx-runtime").JSX.Element;
declare function TabsContent({ className, ...props }: React.ComponentProps<typeof TabsPrimitive.Content>): import("react/jsx-runtime").JSX.Element;
export declare const renderLaboratory: (el: HTMLElement, props: LaboratoryProps) => void;
export { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogOverlay, DialogPortal, DialogTitle, DialogTrigger, Tabs, TabsContent, TabsList, TabsTrigger };