import type { RoleInfo } from '../permissions' // Plugin information provided by the platform export interface PluginInfo { id: string name: string /** Name to show in the UI; the platform falls back to the plugin ID. Absent before MINT 1.3. */ display_name?: string version: string plugin_type?: string description?: string icon?: string color?: string route_prefix: string api_prefix: string /** Settings route selected by the platform for this plugin runtime. */ settings_api?: 'plugin' | 'platform' /** Content identity of the HTML that booted this integrated plugin tab. */ frontend_revision?: string nav_items?: PluginNavItem[] settings?: PluginSettings } // Plugin navigation item export interface PluginNavItem { id?: string label: string path: string icon?: string description?: string requiresAuth?: boolean requiresAdmin?: boolean requiresFeature?: string children?: PluginNavItem[] } // Plugin settings schema export interface PluginSettings { [key: string]: PluginSettingField } export interface PluginSettingField { type: 'string' | 'number' | 'boolean' | 'select' | 'multiselect' label: string description?: string default?: unknown options?: Array<{ value: string; label: string }> validation?: { required?: boolean min?: number max?: number pattern?: string } } // Minimal user representation used across experiment payloads and // the injected platform context. shortname is a short attribution // code (initials) used e.g. in generated filenames. export interface UserSummary { id: number username: string shortname?: string first_name?: string last_name?: string } // Platform context - available to plugins when running under MINT Platform export interface PlatformContext { // Is running under the MINT Platform isIntegrated: boolean // Plugin info (only available when integrated) plugin?: PluginInfo // Platform API base URL platformApiUrl?: string // Platform origin for message validation // Used to verify postMessage sources and targets platformOrigin?: string // Current user info (if authenticated) user?: { id: number username: string role: string role_obj?: RoleInfo | null roleObj?: RoleInfo | null shortname?: string } // Theme preference theme: 'light' | 'dark' | 'system' // Allowed experiment types for this plugin (from admin config) allowedExperimentTypes?: string[] | null // Features enabled in platform features?: { admin?: boolean experiments?: boolean samples?: boolean passkey?: boolean multiUser?: boolean } } // Configuration options for usePlatformContext export interface PlatformContextOptions { // Allowed origins for postMessage communication // If not specified, derives from platformApiUrl or uses same-origin only allowedOrigins?: string[] // Whether to allow messages from any origin (UNSAFE - only for development) // Default: false allowAnyOrigin?: boolean } // Platform event types for communication between plugin and platform export type PlatformEventType = | 'mint:theme-changed' | 'mint:user-changed' | 'mint:navigate' | 'mint:notification' export interface PlatformEvent { type: PlatformEventType payload: T } // Settings state types export type ThemeMode = 'light' | 'dark' | 'system' export type ColorPalette = 'default' | 'colorblind' | 'viridis' | 'pastel' export type TableDensity = 'compact' | 'normal' | 'comfortable'