/** * Convex Client Wrapper * * Handles authentication and communication with Convex Cloud. * Uses Convex system APIs to fetch schema and document information. * * System queries used: * - /api/shapes2 for inferred schema * - _system/frontend/getSchemas for declared schema * - _system/cli/tables for table list * - _system/cli/tableSize:default for document counts * - _system/cli/tableData for paginated document retrieval */ export interface TableInfo { name: string; documentCount: number; indexes: string[]; } export interface SchemaField { name: string; type: string; optional: boolean; } export interface TableSchema { tableName: string; declaredFields: SchemaField[]; inferredFields: SchemaField[]; } export interface Document { _id: string; _creationTime: number; [key: string]: unknown; } export interface ConnectionTestResult { success: boolean; deploymentUrl?: string; tableCount?: number; tables?: string[]; error?: string; } export interface PaginatedResult { documents: T[]; continueCursor?: string; isDone: boolean; } export interface ConfigSource { source: string; path: string; hasUrl: boolean; hasKey: boolean; deployment?: string; } export declare class ConvexClient { private deploymentUrl; private adminKey; private urlSource; private keySource; constructor(); /** * Get all detected config sources for debugging */ static getConfigSources(): ConfigSource[]; /** * Get which source provided the current URL */ getUrlSource(): string; /** * Get which source provided the current key */ getKeySource(): string; private initialize; /** * Check if admin key is available for system queries */ hasAdminAccess(): boolean; isConnected(): boolean; getDeploymentUrl(): string | null; private fetchConvex; testConnection(): Promise; listTables(): Promise; /** * Get document count for a table using system query */ getTableCount(tableName: string): Promise; getTableSchema(tableName: string): Promise; private parseShapeToFields; private shapeToTypeString; private parseDocumentTypeToFields; private docTypeToString; /** * Query documents from a table using system query * Requires admin access for document retrieval */ queryDocuments(tableName: string, options?: { limit?: number; cursor?: string; order?: "asc" | "desc"; }): Promise>; /** * Get sample documents from all tables * Fetches up to DEFAULT_DOC_SAMPLE_LIMIT documents per table */ getAllDocuments(): Promise>; /** * Run a custom query function by path * Requires admin access */ runQuery(queryPath: string, args?: Record): Promise; /** * Get scheduled functions from the _scheduled_functions system table * Returns pending, running, completed, and failed scheduled functions * Requires admin access */ getScheduledFunctions(): Promise; /** * Parse the state object from scheduled functions */ private parseScheduledState; /** * Get cron jobs configuration * Parses cron jobs from the deployment's cron configuration * Requires admin access */ getCronJobs(): Promise; /** * List all installed Convex components by detecting namespaced tables * Components use the "componentName:tableName" naming convention */ listComponents(): Promise; /** * Detect if a component matches a known Convex component type */ private detectKnownComponentType; /** * Get detailed schema for a specific component */ getComponentSchema(componentName: string): Promise; /** * Get all tables grouped by component (including app-level tables) */ getTablesGroupedByComponent(): Promise<{ app: TableInfo[]; components: ConvexComponent[]; }>; /** * Detect if the @convex-dev/agent component is installed * Checks for agent-specific tables in the schema * * NOTE: The agent component uses namespaced tables. Common patterns include: * - agent:threads, agent:messages, agent:steps (component namespace) * - Custom tables if user defined their own agent storage * * This detection is best-effort and may not work for all agent configurations. */ detectAgentComponent(): Promise; /** * Get agent threads from the agent component * Works with @convex-dev/agent or custom agent implementations * * NOTE: This requires the agent component to be installed. * If using a custom agent implementation, specify the table name. */ getAgentThreads(tableName?: string): Promise; /** * Infer thread status from document fields */ private inferThreadStatus; /** * Get agent messages for a specific thread or all recent messages */ getAgentMessages(threadId?: string, tableName?: string): Promise; } /** * Scheduled function from _scheduled_functions system table */ export interface ScheduledFunction { _id: string; _creationTime: number; name: string; scheduledTime: number; completedTime?: number; state: "pending" | "inProgress" | "success" | "failed" | "canceled"; args?: unknown; } /** * Cron job configuration */ export interface CronJob { _id: string; _creationTime: number; name: string; cronSpec?: string; functionPath: string; lastRun?: number; nextRun?: number; } /** * Agent component detection result * * NOTE: The @convex-dev/agent component must be installed for agent features. * See: https://www.convex.dev/components/agent */ export interface AgentComponentInfo { installed: boolean; tables: string[]; isOfficialComponent?: boolean; } /** * Agent thread from agent component * * NOTE: Requires @convex-dev/agent component or compatible agent implementation. * The agent component manages threads where conversations happen between * users and AI agents. */ export interface AgentThread { _id: string; _creationTime: number; title: string; status: "idle" | "processing" | "waiting" | "completed" | "error"; agentId?: string; userId?: string; messageCount: number; lastMessageAt: number; } /** * Agent message from agent component */ export interface AgentMessage { _id: string; _creationTime: number; threadId: string; role: string; content: string; status: string; agentId?: string; } /** * Convex Component information * Components use namespaced tables with "componentName:tableName" format */ export interface ConvexComponent { name: string; tables: ComponentTable[]; tableCount: number; totalDocuments: number; isKnownComponent: boolean; knownComponentType?: string; } /** * Table belonging to a component */ export interface ComponentTable { name: string; fullName: string; documentCount: number; indexes: string[]; fields: SchemaField[]; } //# sourceMappingURL=convex-client.d.ts.map