import { Collection } from '../core/collection'; import { Meeting } from '../core/meeting'; import { CaptureSession } from '../core/captureSession'; import { WebSocketConnection } from '../core/websocket'; import type { RecordMeetingConfig, VideoConfig, AudioConfig } from '../interfaces/core'; import type { FileUploadConfig, URLUploadConfig } from '../types/collection'; import type { ListCaptureSessionsConfig, CreateCaptureSessionConfig } from '../types/capture'; import { HttpClient, type HttpClientAuthConfig, type HttpClientOptions } from '../utils/httpClient'; /** * Connection class for initializing the VideoDB SDK * Supports dual authentication modes: * - API key: Full backend access * - Session token: Limited client access */ export declare class Connection { vhttp: HttpClient; /** * Create a connection with auth configuration * @param baseURL - Base URL for the API * @param authConfig - Authentication configuration (apiKey or sessionToken) * @param options - Optional client configuration (custom headers). * `headers` are auto-formatted to `x-kebab-case`, mirroring * the kwarg-to-header behavior of `videodb-python`. */ constructor(baseURL: string, authConfig: HttpClientAuthConfig, options?: HttpClientOptions); /** * Create a connection with API key (legacy signature) * @param baseURL - Base URL for the API * @param apiKey - API key for authentication * @param options - Optional client configuration (custom headers) * @deprecated Use the object-based constructor instead */ constructor(baseURL: string, apiKey: string, options?: HttpClientOptions); /** * Get an instance of the Collection class * @param id - [Optional] ID of the collection * @returns * If ID is provided, returns the corresponding collection, * else returns the default collection. */ getCollection(id?: string): Promise; /** * Get all Collections from db * @returns * Returns an array of Collection objects */ getCollections(): Promise; /** * Create a new collection * @param name - Name of the collection * @param description - Description of the collection * @param isPublic - Make collection public (optional, default: false) * @returns * Returns a new Collection object */ createCollection: (name: string, description: string, isPublic?: boolean) => Promise; /** * Update a collection * @param id - ID of the collection * @param name - Name of the collection * @param desscription - Description of the collection * @returns * Returns an updated Collection object */ updateCollection(id: string, name: string, description: string): Promise; /** * Unified upload method for files and URLs * @param source - Local path or URL of the file to upload * @param mediaType - Type of media (video, audio, image) - optional * @param name - Name of the file - optional * @param description - Description of the file - optional * @param callbackUrl - URL to receive the callback - optional * @returns Video, Audio, or Image object. Returns undefined if callbackUrl is provided. */ upload: (source: string, mediaType?: 'video' | 'audio' | 'image', name?: string, description?: string, callbackUrl?: string) => Promise; /** * @param filePath - absolute path to a file * @param callbackUrl- [optional] A url that will be called once upload is finished * @param name - [optional] Name of the file * @param description - [optional] Description of the file * * @see * Providing a callbackUrl will return undefined and not providing one * will return a Job object (TODO: Implement proper type for this condition) */ uploadFile: (collectionId: string | undefined, data: FileUploadConfig) => Promise; /** * @param URL - URL of the hosted file * @param callbackUrl- [optional] A url that will be called once upload is finished * @param name - [optional] Name of the file * @param description - [optional] Description of the file * * @see * Providing a callbackUrl will return undefined and not providing one * will return a Job object (TODO: Implement proper type for this condition) */ uploadURL: (collectionId: string | undefined, data: URLUploadConfig) => Promise; /** * Check the account usage * @returns Usage data */ checkUsage: () => Promise>; /** * Get a list of all invoices * @returns List of invoices */ getInvoices: () => Promise; /** * Create an rtstream event * @param eventPrompt - Prompt for the event * @param label - Label for the event * @returns Event ID * * @example * ```typescript * const eventId = await conn.createEvent('Detect when someone enters the room', 'room_entry'); * ``` */ createEvent: (eventPrompt: string, label: string) => Promise; /** * List all rtstream events * @returns List of events */ listEvents: () => Promise; /** * Download a file from a stream link * @param streamLink - URL of the stream to download * @param name - Name to save the downloaded file as * @returns Download response data */ download: (streamLink: string, name: string) => Promise>; /** * Search for a query on YouTube * @param query - Query to search for * @param resultThreshold - Number of results to return (optional) * @param duration - Duration of the video (optional) * @returns List of YouTube search results */ youtubeSearch: (query: string, resultThreshold?: number, duration?: string) => Promise; /** * Transcode the video * @param source - URL of the video to transcode * @param callbackUrl - URL to receive the callback * @param mode - Mode of the transcoding * @param videoConfig - Video configuration (optional) * @param audioConfig - Audio configuration (optional) * @returns Transcode job ID */ transcode: (source: string, callbackUrl: string, mode?: string, videoConfig?: VideoConfig, audioConfig?: AudioConfig) => Promise; /** * Get the details of a transcode job * @param jobId - ID of the transcode job * @returns Details of the transcode job */ getTranscodeDetails: (jobId: string) => Promise>; /** * Record a meeting and upload it to the default collection * @param config - Meeting recording configuration * @returns Meeting object representing the recording bot */ recordMeeting: (config: RecordMeetingConfig) => Promise; /** * Get a meeting by its ID * @param meetingId - ID of the meeting * @returns Meeting object */ getMeeting: (meetingId: string) => Promise; /** * Connect to the VideoDB WebSocket service for real-time events * @param collectionId - ID of the collection (default: "default") * @returns WebSocketConnection object (call .connect() to establish connection) * * @example * ```typescript * const ws = await conn.connectWebsocket(); * await ws.connect(); * * for await (const message of ws.receive()) { * console.log('Event:', message); * } * ``` */ connectWebsocket: (collectionId?: string) => Promise; /** * Get an existing capture session by ID * @param sessionId - ID of the capture session (cap-xxx) * @param collectionId - ID of the collection (default: "default") * @returns CaptureSession object * * @example * ```typescript * const session = await conn.getCaptureSession('cap-xxx'); * await session.refresh(); * console.log(session.status); * ``` */ getCaptureSession: (sessionId: string, collectionId?: string) => Promise; /** * List all capture sessions in a collection * @param collectionId - ID of the collection (default: "default") * @param config - Filter configuration * @returns List of CaptureSession objects * * @example * ```typescript * const sessions = await conn.listCaptureSessions('default', { status: 'active' }); * ``` */ listCaptureSessions: (collectionId?: string, config?: ListCaptureSessionsConfig) => Promise; /** * Create a capture session (convenience method) * Creates in the default collection * @param config - Capture session configuration * @returns CaptureSession object * * @example * ```typescript * const session = await conn.createCaptureSession({ * endUserId: 'user_abc', * callbackUrl: 'https://example.com/webhook', * }); * const token = await conn.generateClientToken(86400); * ``` */ createCaptureSession: (config: CreateCaptureSessionConfig) => Promise; /** * Generate a client token for capture operations * This is an account-scoped token that can be used for capture sessions and WebSocket connections * * @param expiresIn - Token expiration time in seconds (default: 86400 = 24 hours) * @returns Client token string (st-xxx format) * * @example * ```typescript * // Generate a token valid for 24 hours * const token = await conn.generateClientToken(); * * // Generate a token valid for 1 hour * const token = await conn.generateClientToken(3600); * * // Use with CaptureClient * const client = new CaptureClient({ sessionToken: token }); * ``` */ generateClientToken: (expiresIn?: number) => Promise; }