import { ComputedRef, Ref } from 'vue'; import { EventStreamMessage, UseEventStreamReturn } from './useEventStream'; import { ExperimentSummary, GeneratedJobDefinition, PageSelectorItem, SettingsModalSchema, TopBarSettingsConfig } from '../types'; export { buildPluginEndpointUrl, resolvePluginBaseUrl, } from './pluginEndpointBuilder'; export type PluginHttpMethod = 'get' | 'post' | 'put' | 'patch' | 'delete'; export interface PluginEndpointContract { name: string; operationId?: string; method: PluginHttpMethod; path: string; requiresAuth?: boolean; pathParams?: PluginEndpointParamContract[]; queryParams?: PluginEndpointParamContract[]; requestType?: string | null; requestContentType?: string | null; responseType?: string | null; responseContentType?: string | null; eventStream?: boolean; } export interface PluginEndpointParamContract { name: string; fieldName: string; type?: string; required?: boolean; } export interface PluginNavItemContract { path: string; label: string; id?: string; icon?: string; description?: string; requiresAuth?: boolean; requiresAdmin?: boolean; requiresFeature?: string; } export interface PluginContractSettings { modelName: string | null; /** Pydantic JSON Schema used to generate typed settings values. */ valueSchema: Record | null; /** SDK SettingsModal schema used to render the settings form. */ formSchema: SettingsModalSchema | null; } export interface PluginContract { schemaVersion: 2; plugin: { name?: string; packageName?: string; version?: string; description?: string; routesPrefix: string; apiPrefix: string; type: 'analysis' | 'experiment-design' | string; analysisType?: string; icon?: string; color?: string; navItems?: PluginNavItemContract[]; analysisResultReaders?: string[]; analysisResultWriters?: string[]; capabilities?: Record; }; settings: PluginContractSettings; endpoints: PluginEndpointContract[]; schemas?: Record>; jobs?: GeneratedJobDefinition[]; hash: string; } export interface PluginEndpointDefinition { method: PluginHttpMethod; path: string; requiresAuth?: boolean; pathParams?: PluginEndpointParamDefinition[]; queryParams?: PluginEndpointParamDefinition[]; hasBody?: boolean; requestContentType?: string | null; eventStream?: boolean; responseType?: string | null; responseContentType?: string | null; } export type PluginEndpointParamDefinition = string | { name: string; fieldName?: string; type?: string; required?: boolean; }; export interface CreatePluginClientOptions { endpoints: Record; baseUrl?: string; } export interface BuildPluginEndpointUrlOptions { /** Override the generated or platform-injected API base URL. */ baseUrl?: string; /** Return only the endpoint path and query string instead of base URL + path. */ includeBaseUrl?: boolean; } export interface PluginEndpointRequestOptions { /** Override the generated or platform-injected API base URL. */ baseUrl?: string; /** Cancel the request without changing its endpoint or authentication behavior. */ signal?: AbortSignal; } export interface PluginClientRequestOptions { /** Cancel the generated endpoint request. */ signal?: AbortSignal; } export interface DownloadPluginEndpointOptions extends PluginEndpointRequestOptions { /** Browser download filename. When omitted, the blob is returned without triggering a download. */ filename?: string; /** Delay before revoking the object URL after a browser download is triggered. */ revokeObjectUrlDelayMs?: number; } export interface DownloadBlobOptions { /** Delay before revoking the object URL after a browser download is triggered. */ revokeObjectUrlDelayMs?: number; } export type PluginSettingsValues = Partial & Record; export interface UsePluginSettingsOptions { /** Plugin name for platform persistence. Defaults to the integrated platform plugin name. */ pluginName?: string; /** Plugin API base URL for standalone/local settings routes. Generated clients pass pluginApiPrefix. */ apiBaseUrl?: string; /** Platform API base URL for /plugins/{name}/config. Defaults to the injected platform API URL. */ platformApiBaseUrl?: string; /** SettingsModal schema generated from the backend plugin config model. */ schema?: SettingsModalSchema | null; /** SettingsModal title when using settingsConfig. */ title?: string; /** Whether SettingsModal should include SDK appearance controls. */ showAppearance?: boolean; /** Load persisted values on component mount. */ loadOnMount?: boolean; } export interface UsePluginSettingsReturn> { /** Current typed settings values. */ settings: ComputedRef>; /** Editable settings values for SettingsModal. */ values: Ref>; /** Alias for values, kept for callers that think in platform config terms. */ config: Ref>; /** Ready-to-pass AppTopBar/PluginWorkspaceView settingsConfig. */ settingsConfig: ComputedRef; isLoading: Ref; isSaving: Ref; error: Ref; lastLoadedAt: Ref; lastSavedAt: Ref; isDirty: ComputedRef; setValues: (values: Record) => void; load: () => Promise; save: (values?: Record) => Promise; reset: () => void; } export type PluginEventStreamMessage = EventStreamMessage; export interface PluginEventStreamOptions { /** Override the generated or platform-injected API base URL. */ baseUrl?: string; /** Start the stream immediately. Defaults to true. */ immediate?: boolean; /** Reconnect after errors or server closes. Defaults to true. */ reconnect?: boolean; /** Delay before reconnecting after a stream failure or close. Defaults to 2000ms. */ reconnectDelayMs?: number; /** Parse `data:` as JSON. Defaults to true for typed endpoints and false otherwise. */ parseJson?: boolean; /** Fetch credentials mode. Defaults to same-origin. */ credentials?: RequestCredentials; /** Extra request headers. Authorization is injected unless already supplied. */ headers?: Record; onOpen?: () => void; onMessage?: (message: PluginEventStreamMessage) => void; onError?: (error: unknown) => void; } export type UsePluginEventStreamReturn = UseEventStreamReturn; export type PluginFormDataValue = string | number | boolean | Blob | null | undefined | Record; export type PluginFormDataPayload = Record; export interface UseCurrentExperimentOptions { apiBaseUrl?: string; immediate?: boolean; } export interface UseCurrentExperimentReturn { /** Current experiment id resolved from platform injection or URL conventions. */ experimentId: ComputedRef; /** Whether a current experiment id is available. */ hasExperiment: ComputedRef; /** Current experiment payload, if injected or successfully fetched. */ experiment: Ref; /** Whether the current experiment is currently loading. */ isLoading: Ref; /** Error message from the last failed current-experiment fetch, or null. */ error: Ref; /** Timestamp of the last successful current-experiment fetch, or null. */ lastLoadedAt: Ref; /** Return the current experiment id or throw a clear SDK error when absent. */ requireExperimentId: () => number; /** Fetch a specific experiment id, defaulting to the current experiment id. */ fetch: (experimentId?: number) => Promise; /** Refetch the currently resolved experiment id. */ refresh: () => Promise; } export type PluginEndpointCaller = (payloadOrOptions?: unknown, options?: PluginClientRequestOptions) => Promise; export type GeneratedPluginClient = Record Promise>; /** Convert plain upload payloads into FormData using the same encoding across generated plugin clients. */ export declare function pluginFormDataFromPayload(payload: unknown): FormData; /** Trigger a browser download for an already-created Blob. */ export declare function downloadBlob(blob: Blob, filename: string, options?: DownloadBlobOptions): void; /** Convert resolved @mint_plugin nav_items into page selectors for the topbar and homepage PluginCards. */ export declare function getPluginPageSelectorItems(contract: PluginContract): PageSelectorItem[]; /** Create a typed plugin API client from a generated MINT plugin contract. */ export declare function createPluginClient(contract: PluginContract, options: CreatePluginClientOptions): TClient; /** Send multipart or raw binary data to a generated endpoint with contract URL, cancellation, and auth handling. */ export declare function uploadPluginEndpoint(contract: PluginContract, endpoint: PluginEndpointDefinition, payload?: unknown, options?: PluginEndpointRequestOptions): Promise; /** Fetch a generated plugin endpoint as a Blob and optionally trigger a browser download. */ export declare function downloadPluginEndpoint(contract: PluginContract, endpoint: PluginEndpointDefinition, payload?: unknown, options?: DownloadPluginEndpointOptions): Promise; /** @deprecated Removed in MINT 1.4; use `useGeneratedPluginClient()` for generated clients. */ export declare function usePluginClient(client: TClient): TClient; /** Load, edit, and persist plugin settings from platform config or the plugin-local settings router. */ export declare function usePluginSettings>(options?: UsePluginSettingsOptions | string): UsePluginSettingsReturn; /** Consume a generated plugin SSE endpoint with auth headers, reconnect, and teardown. */ export declare function usePluginEventStream(contract: PluginContract, endpoint: PluginEndpointDefinition, options?: PluginEventStreamOptions): UsePluginEventStreamReturn; export declare function usePluginEventStream(contract: PluginContract, endpoint: PluginEndpointDefinition, payload?: unknown, options?: PluginEventStreamOptions): UsePluginEventStreamReturn; /** Read and optionally load the current platform experiment for integrated plugin views. */ export declare function useCurrentExperiment(options?: UseCurrentExperimentOptions): UseCurrentExperimentReturn;