/** * Enhanced Command API with more elegant type-safe command execution * * This approach provides several elegant improvements to the current sendCommand implementation: * * 1. **Overloaded Methods**: Method overloads for better type inference without params * 2. **Command Builders**: Fluent builder pattern for complex commands * 3. **Smart Defaults**: Intelligent parameter handling with sensible defaults * 4. **Enhanced Type Safety**: Better generic constraints and inference * 5. **Command Grouping**: Logical organization of related commands * 6. **Performance Optimization**: Efficient method dispatch and minimal overhead * * @example Basic Usage * ```typescript * // Enhanced command execution * await api.commands.device("12345").getProperties(); * await api.commands.driver().connect(); * await api.commands.server().startListening(); * * // Direct command execution with automatic parameter inference * await api.commands.command(DEVICE_COMMANDS.GET_PROPERTIES, { serialNumber: "12345" }); * await api.commands.command(DRIVER_COMMANDS.CONNECT); // No params needed * ``` * * @public * @since 1.0.0 */ export interface ApiManagerInterface { sendCommand(command: T, params: ParamsForCommand): Promise>; } import { ResponseForCommand, SupportedCommandType, ParamsForCommand } from "./types/commands"; import { DEVICE_COMMANDS } from "./device/constants"; import { STATION_COMMANDS } from "./station/constants"; import { DRIVER_COMMANDS } from "./driver/constants"; import { DeviceProperties } from "./device/properties"; import { StationProperties } from "./station/properties"; /** * Enhanced command API for Eufy Security WebSocket API * * Provides a fluent interface for building and executing commands with improved * type safety and developer experience. Supports both direct command execution * and builder pattern for complex operations. * * @public * @since 1.0.0 */ export declare class EnhancedCommandAPI { private apiManager; /** * Creates a new EnhancedCommandAPI instance * * @param apiManager - API manager instance for command execution */ constructor(apiManager: ApiManagerInterface); /** * Enhanced sendCommand with automatic parameter handling * * Usage examples: * - await api.command(DEVICE_COMMANDS.GET_PROPERTIES, { serialNumber: "12345" }) * - await api.command(DRIVER_COMMANDS.CONNECT) // No params needed * - await api.command(DEVICE_COMMANDS.SET_PROPERTY, { serialNumber: "12345", name: "enabled", value: true }) */ command(command: T, ...args: {} extends ParamsForCommand ? [ParamsForCommand?] : [ParamsForCommand]): Promise>; /** * Device command builder for more elegant device operations * * Usage: await api.device("12345").getProperties() * await api.device("12345").setProperty("enabled", true) */ device(serialNumber: string): DeviceCommandBuilder; /** * Station command builder for more elegant station operations * * Usage: await api.station("12345").getProperties() * await api.station("12345").setGuardMode("home") */ station(serialNumber: string): StationCommandBuilder; /** * Driver command builder for driver operations * * Usage: await api.driver().connect() * await api.driver().isConnected() */ driver(): DriverCommandBuilder; /** * Server command builder for server operations * * Usage: await api.server().startListening() * await api.server().setApiSchema(21) */ server(): ServerCommandBuilder; } /** * Device command builder with fluent interface * * Provides a convenient way to execute device-specific commands with automatic * serial number injection and type safety. * * @public */ export declare class DeviceCommandBuilder { private serialNumber; private api; /** * Creates a new DeviceCommandBuilder instance * * @param serialNumber - Device serial number for all commands * @param api - Enhanced command API instance */ constructor(serialNumber: string, api: EnhancedCommandAPI); /** * Get all properties for this device * * @returns Promise resolving to device properties object * * @example * ```typescript * const properties = await api.device("T8210N20123456789").getProperties(); * console.log('Device name:', properties.name); * ``` */ getProperties(): Promise; /** * Get device properties metadata */ getPropertiesMetadata(): Promise; /** * Check if the device has a specific property */ hasProperty(propertyName: keyof DeviceProperties): Promise; /** * Check if the device supports a specific command */ hasCommand(commandName: string): Promise; /** * Get a list of commands supported by the device */ getCommands(): Promise; /** * Check if the device is currently livestreaming */ isLivestreaming(): Promise; /** * Start livestreaming from the device * * @returns Promise resolving when livestream starts successfully * @throws {Error} If device doesn't support livestreaming or command fails * * @example * ```typescript * await api.device("T8210N20123456789").startLivestream(); * console.log('Livestream started'); * ``` */ startLivestream(): Promise<{}>; /** * Stop livestreaming on the device * * @returns Promise resolving when livestream stops successfully * * @example * ```typescript * await api.device("T8210N20123456789").stopLivestream(); * console.log('Livestream stopped'); * ``` */ stopLivestream(): Promise<{}>; /** * Check if RTSP livestreaming is active */ isRtspLivestreaming(): Promise; /** * Start RTSP livestreaming */ startRtspLivestream(): Promise<{}>; /** * Stop RTSP livestreaming */ stopRtspLivestream(): Promise<{}>; /** * Check if the device is currently downloading */ isDownloading(): Promise; /** * Start downloading with the device */ startDownload(params: Omit, "serialNumber">): Promise<{}>; /** * Cancel an ongoing download */ cancelDownload(): Promise<{}>; /** * Trigger the device alarm */ triggerAlarm(params?: Omit, "serialNumber">): Promise<{}>; /** * Reset the device alarm */ resetAlarm(): Promise<{}>; /** * Pan and tilt the device camera */ panAndTilt(params: Omit, "serialNumber">): Promise<{}>; /** * Calibrate the device */ calibrate(): Promise<{}>; /** * Set a property on the device */ setProperty(name: K, value: any): Promise<{}>; /** * Send a quick response from the device */ quickResponse(params: Omit, "serialNumber">): Promise<{}>; /** * Get the list of voices supported by the device */ getVoices(): Promise; /** * Start the talkback feature */ startTalkback(): Promise<{}>; /** * Stop the talkback feature */ stopTalkback(): Promise<{}>; /** * Check if a talkback session is ongoing */ isTalkbackOngoing(): Promise; /** * Send raw audio data to the device during a talkback session */ talkbackAudioData(buffer: Buffer): Promise<{}>; /** * Calibrate the lock mechanism */ calibrateLock(): Promise<{}>; /** * Unlock the device */ unlock(): Promise<{}>; /** * Snooze the device (temporary disable) */ snooze(params?: Omit, "serialNumber">): Promise<{}>; /** * Add a new user to the device */ addUser(params: Omit, "serialNumber">): Promise<{}>; /** * Delete a user from the device */ deleteUser(params: Omit, "serialNumber">): Promise<{}>; /** * Get the list of users configured on the device */ getUsers(): Promise; /** * Update user information */ updateUser(params: Omit, "serialNumber">): Promise<{}>; /** * Update a user's passcode */ updateUserPasscode(params: Omit, "serialNumber">): Promise<{}>; /** * Update a user's schedule */ updateUserSchedule(params: Omit, "serialNumber">): Promise<{}>; /** * Verify a user's PIN */ verifyPin(params: Omit, "serialNumber">): Promise<{}>; /** * Open the device (wake up from sleep) */ open(): Promise<{}>; /** * Set the status LED behavior */ setStatusLed(params: Omit, "serialNumber">): Promise<{}>; /** * Configure auto night vision settings */ setAutoNightVision(params: Omit, "serialNumber">): Promise<{}>; /** * Configure motion detection settings */ setMotionDetection(params: Omit, "serialNumber">): Promise<{}>; /** * Configure sound detection settings */ setSoundDetection(params: Omit, "serialNumber">): Promise<{}>; /** * Configure pet detection settings */ setPetDetection(params: Omit, "serialNumber">): Promise<{}>; /** * Configure RTSP stream settings */ setRtspStream(params: Omit, "serialNumber">): Promise<{}>; /** * Configure anti-theft detection settings */ setAntiTheftDetection(params: Omit, "serialNumber">): Promise<{}>; /** * Configure watermark settings for the device */ setWatermark(params: Omit, "serialNumber">): Promise<{}>; /** * Enable or activate the device */ enableDevice(params: Omit, "serialNumber">): Promise<{}>; /** * Lock the device (secure it) */ lockDevice(params: Omit, "serialNumber">): Promise<{}>; } /** * Station command builder with fluent interface */ export declare class StationCommandBuilder { private serialNumber; private api; constructor(serialNumber: string, api: EnhancedCommandAPI); /** * Get station properties */ getProperties(): Promise; /** * Get station properties metadata */ getPropertiesMetadata(): Promise; /** * Check if the station has a specific property */ hasProperty(propertyName: keyof StationProperties): Promise; /** * Check if the station supports a specific command */ hasCommand(commandName: string): Promise; /** * Get a list of commands supported by the station */ getCommands(): Promise; /** * Check if the station is connected */ isConnected(): Promise; /** * Connect the station */ connect(): Promise<{}>; /** * Disconnect the station */ disconnect(): Promise<{}>; /** * Set a property on the station */ setProperty(name: K, value: any): Promise<{}>; /** * Trigger the station alarm */ triggerAlarm(params?: Omit, "serialNumber">): Promise<{}>; /** * Reset the station alarm */ resetAlarm(): Promise<{}>; /** * Reboot the station */ reboot(): Promise<{}>; /** * Activate the station chime */ chime(params: Omit, never>): Promise<{}>; /** * Download an image from the station */ downloadImage(params: Omit, never>): Promise<{}>; /** * Query the latest information from the station's database */ databaseQueryLatestInfo(params: Omit, "serialNumber">): Promise; /** * Query local data from the station's database */ databaseQueryLocal(params: Omit, "serialNumber">): Promise; /** * Count database entries by date */ databaseCountByDate(params: Omit, "serialNumber">): Promise; /** * Delete entries from the station's database */ databaseDelete(params: Omit, "serialNumber">): Promise<{}>; } /** * Driver command builder with fluent interface */ export declare class DriverCommandBuilder { private api; constructor(api: EnhancedCommandAPI); /** * Connect the driver */ connect(): Promise; /** * Disconnect the driver */ disconnect(): Promise<{}>; /** * Check if the driver is connected */ isConnected(): Promise; /** * Check if the push service is connected */ isPushConnected(): Promise; /** * Check if the MQTT service is connected */ isMqttConnected(): Promise; /** * Set the verification code for the driver */ setVerifyCode(params: ParamsForCommand): Promise; /** * Set the captcha for the driver */ setCaptcha(params: ParamsForCommand): Promise; /** * Refresh the poll data */ pollRefresh(): Promise<{}>; /** * Get video event data */ getVideoEvents(params: ParamsForCommand): Promise; /** * Get alarm event data */ getAlarmEvents(params: ParamsForCommand): Promise; /** * Get history event data */ getHistoryEvents(params: ParamsForCommand): Promise; /** * Set the log level for the driver */ setLogLevel(params: ParamsForCommand): Promise<{}>; /** * Get the current log level */ getLogLevel(): Promise; /** * Start listening to logs */ startListeningLogs(): Promise<{}>; /** * Stop listening to logs */ stopListeningLogs(): Promise<{}>; /** * Check if log listening is active */ isListeningLogs(): Promise; } /** * Server command builder with fluent interface */ export declare class ServerCommandBuilder { private api; constructor(api: EnhancedCommandAPI); /** * Start the server listening for connections */ startListening(): Promise; /** * Set the API schema version for the server */ setApiSchema(schemaVersion: number): Promise; } //# sourceMappingURL=api-manager-commands.d.ts.map