/** * UI Bridge Server Types * * Shared types for server adapters. */ import type { UIBridgeConfig, ElementHistoryOptions } from '@qontinui/ui-bridge/core'; import type { UiBridgeErrorCode } from '@qontinui/ui-bridge/diagnostics'; import type { ControlActionRequest, ControlActionResponse, ComponentActionRequest, ComponentActionResponse, FindRequest, FindResponse, ControlSnapshot, WorkflowRunRequest, WorkflowRunResponse } from '@qontinui/ui-bridge/control'; import type { RenderLogEntry, RenderLogEntryType } from '@qontinui/ui-bridge/render-log'; import type { SearchCriteria, SearchResponse, NLActionRequest, NLActionResponse, AssertionRequest, AssertionResult, BatchAssertionRequest, BatchAssertionResult, SemanticSnapshot, SemanticDiff, SemanticSearchCriteria, SemanticSearchResponse, ScreenAnalysis } from '@qontinui/ui-bridge/ai'; import type { PageHealthReport } from './page-health'; /** * Server configuration */ export interface UIBridgeServerConfig extends UIBridgeConfig { /** Base path for API routes */ basePath?: string; /** Enable CORS */ cors?: boolean | CORSOptions; /** Authentication middleware */ authenticate?: (req: unknown) => boolean | Promise; /** Rate limiting */ rateLimit?: RateLimitOptions; } /** * CORS options */ export interface CORSOptions { /** Allowed origins */ origin?: string | string[] | boolean; /** Allowed methods */ methods?: string[]; /** Allowed headers */ headers?: string[]; /** Expose headers */ exposeHeaders?: string[]; /** Allow credentials */ credentials?: boolean; /** Max age for preflight cache */ maxAge?: number; } /** * Rate limit options */ export interface RateLimitOptions { /** Time window in milliseconds */ windowMs?: number; /** Max requests per window */ max?: number; /** Message when rate limited */ message?: string; } /** * API response wrapper */ export interface APIResponse { /** Whether the request succeeded */ success: boolean; /** Response data */ data?: T; /** Error message if failed (human-readable, dual-audience — plan goal #3) */ error?: string; /** * Stable machine-readable diagnostic code. Populated on every * `success: false` response (plan Phase 1 — required on failure; * optional at the type level only because successful responses omit it). * Always a canonical `UiBridgeErrorCode` (mapped from internal/legacy * codes via `error-mapper.ts`). */ code?: UiBridgeErrorCode; /** Request timestamp */ timestamp: number; /** Response time in milliseconds (set by server) */ durationMs?: number; } /** * Render log query parameters */ export interface RenderLogQuery { /** Filter by entry type */ type?: RenderLogEntryType; /** Filter entries since timestamp */ since?: number; /** Filter entries until timestamp */ until?: number; /** Limit number of results */ limit?: number; } /** * Server handler interface * * Implementations provide these handlers for different frameworks. */ export interface UIBridgeServerHandlers { getRenderLog: (query?: RenderLogQuery) => Promise>; clearRenderLog: () => Promise>; captureSnapshot: () => Promise>; getRenderLogPath: () => Promise>; getElements: () => Promise>; getElement: (id: string) => Promise>; getElementState: (id: string) => Promise>; executeElementAction: (id: string, request: ControlActionRequest) => Promise>; getComponents: () => Promise>; getComponent: (id: string) => Promise>; getComponentState: (id: string) => Promise; computed: Record; timestamp: number; }>>; executeComponentAction: (id: string, request: ComponentActionRequest) => Promise>; find: (request?: FindRequest) => Promise>; /** * @deprecated Use find() instead */ discover: (request?: FindRequest) => Promise>; getControlSnapshot: () => Promise>; getWorkflows: () => Promise>; runWorkflow: (id: string, request?: WorkflowRunRequest) => Promise>; getWorkflowStatus: (runId: string) => Promise>; getActionHistory: (limit?: number) => Promise>; getMetrics: () => Promise>; highlightElement: (id: string) => Promise>; getElementTree: () => Promise>; aiSearch: (criteria: SearchCriteria) => Promise>; aiExecute: (request: NLActionRequest) => Promise>; aiAssert: (request: AssertionRequest) => Promise>; aiAssertBatch: (request: BatchAssertionRequest) => Promise>; getSemanticSnapshot: () => Promise>; getSemanticDiff: (since?: number) => Promise>; getPageSummary: () => Promise>; getScreenAnalysis: () => Promise>; aiSemanticSearch: (criteria: SemanticSearchCriteria) => Promise>; getElementHistory: (elementId: string, options?: ElementHistoryOptions) => Promise>; getPerformanceEntries: () => Promise>; clearPerformanceEntries: () => Promise>; getBrowserEvents: (params?: { type?: string; since?: number; limit?: number; }) => Promise>; pageHealth?: () => Promise>; query: (request: { selector: string; limit?: number; includeState?: boolean; }) => Promise>; waitForElement: (request: { selector?: string; elementId?: string; timeout?: number; pollInterval?: number; }) => Promise>; clickByText: (request: { text: string; tag?: string; exact?: boolean; }) => Promise>; clickBySelector: (request: { selector: string; index?: number; }) => Promise>; typeInto: (request: { selector?: string; label?: string; text: string; clear?: boolean; }) => Promise>; readValue: (request: { selector: string; index?: number; }) => Promise>; findByText: (request: { text: string; tag?: string; exact?: boolean; }) => Promise>>; getDiagnostics: () => Promise>; /** * Diagnostic catalog endpoints (plan Phase 2). Read-only, backed by the * single source `diagnostics/codes.json` (via the generated * `@qontinui/ui-bridge/diagnostics` catalog). `getDiagnosticsCatalog` * returns every code (agent bootstrap); `getDiagnosticCode` returns one * code's entry, 404 + canonical `UiBridgeErrorCode` on an unknown code. */ getDiagnosticsCatalog: () => Promise>; getDiagnosticCode: (code: string) => Promise>; getRoutes: () => Promise>>; navigateByAdapter: (request: { page: string; }) => Promise>; } /** * Route definition */ export interface RouteDefinition { method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; path: string; handler: string; params?: string[]; bodyRequired?: boolean; } /** * All UI Bridge routes */ export declare const UI_BRIDGE_ROUTES: RouteDefinition[]; /** * WebSocket message types */ export type WebSocketMessageType = 'subscribe' | 'unsubscribe' | 'event' | 'snapshot' | 'action' | 'error'; /** * WebSocket message */ export interface WebSocketMessage { type: WebSocketMessageType; channel?: string; data?: T; error?: string; timestamp: number; } //# sourceMappingURL=types.d.ts.map