UNPKG

ts-freebox

Version:

251 lines (240 loc) 10.9 kB
import request from './utils/fetch.mjs'; import { Configuration as Configuration$1, App } from './@types/app.mjs'; import { Response, VoidResponse } from './@types/index.mjs'; import { config } from './@types/wifi/config.mjs'; import { state } from './@types/wifi/state.mjs'; import { AP } from './@types/wifi/AP.mjs'; import { WifiCustomKeyParams } from './@types/wifi/guest.mjs'; import { LanHost } from './@types/lan/host.mjs'; import { LanInterface } from './@types/lan/interfaces.mjs'; import { LanConfig } from './@types/lan/config.mjs'; import { ConnectionStatus } from './@types/connection/status.mjs'; import { ConnectionConfig, IPv6ConnectionConfiguration } from './@types/connection/config.mjs'; import Port from './@types/port.mjs'; import { Player as Player$1, PlayerStatus, commands, volume } from './@types/player.mjs'; declare class Submodule { private _freebox; baseUrl: string; token: string; constructor(freebox: Freebox); } declare class Wifi extends Submodule { guest: Guest; constructor(freebox: Freebox); config(): Promise<Response<config>>; state(): Promise<Response<state>>; AP<T = AP[]>(id?: number): Promise<Response<T>>; BSS(): Promise<Response<any>>; } declare class Guest extends Submodule { constructor(freebox: Freebox); create(config: WifiCustomKeyParams): Promise<Response<WifiCustomKeyParams>>; delete(id: number): Promise<Response<VoidResponse>>; get_list(): Promise<Response<WifiCustomKeyParams[]>>; get(id: number): Promise<Response<WifiCustomKeyParams>>; } /** * Lan browser API allow you to discover hosts on the local network * @link https://mafreebox.freebox.fr/doc/index.html#lan-browser-api * @class LAN * @extends Submodule */ declare class LAN extends Submodule { constructor(freebox: Freebox); /** * Returns the current LanConfig * @link https://mafreebox.freebox.fr/doc/index.html#get-the-current-lan-configuration * @returns {Promise<Response<LanConfig>>} */ config(): Promise<Response<LanConfig>>; /** * Update the current LanConfig * @link https://mafreebox.freebox.fr/doc/index.html#update-the-current-lan-configuration * @param config The new partial LanConfig * @returns {Promise<Response<Partial<LanConfig>>>} */ update(config: Partial<LanConfig>): Promise<Response<Partial<LanConfig>>>; /** * Getting the list of browsable LAN interfaces * @link https://mafreebox.freebox.fr/doc/index.html#getting-the-list-of-browsable-lan-interfaces * @returns {Promise<Response<LanInterface[]>>} */ interfaces(): Promise<Response<LanInterface[]>>; /** * Getting the list of hosts on a given interface * @link https://mafreebox.freebox.fr/doc/index.html#getting-the-list-of-hosts-on-a-given-interface * @param _interface Returns the list of LanHost on this interface * @returns {Promise<Response<LanHost[]>>} */ hosts(_interface?: string): Promise<Response<LanHost[]>>; /** * Getting an host information * @link https://mafreebox.freebox.fr/doc/index.html#getting-an-host-information * @param _interface - The interface to which the host is connected * @param id - The id of the host * @returns {Promise<Response<LanHost>>} */ host(_interface: string, id: string): Promise<Response<LanHost>>; /** * Updating an host information * @link https://mafreebox.freebox.fr/doc/index.html#updating-an-host-information * @param _interface The interface to which the host is connected * @param id The id of the host * @param data The data to update * @returns {Promise<Response<Partial<LanHost>>>} */ updateHost(_interface: string, id: string, data: Partial<Omit<LanHost, "id">> & Required<Pick<LanHost, "id">>): Promise<Response<Partial<LanHost>>>; /** * Send a wake on LAN packet to the specified host with an optional password * @link https://mafreebox.freebox.fr/doc/index.html#send-wake-ok-lan-packet-to-an-host * @param _interface The interface to which the host is connected * @param mac The MAC address of the host * @param password - [OPTIONAL] The password to use to send the WOL packet * @returns */ WOL(_interface: string, mac: string, password?: string): Promise<VoidResponse>; } declare class Connection extends Submodule { constructor(freebox: Freebox); /** * Get the current Connection status * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#connection-status-object * @returns {Promise<Response<ConnectionStatus>>} */ status(): Promise<Response<ConnectionStatus>>; /** * Get the current Connection configuration * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#get-the-current-connection-configuration * @returns {Promise<Response<ConnectionConfig>>} */ config(): Promise<Response<ConnectionConfig>>; /** * Update the Connection configuration * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#update-the-connection-configuration * @param body The new configuration * @returns {Promise<Response<ConnectionConfig>>} */ updateConfig(body: Partial<ConnectionConfig>): Promise<Response<ConnectionConfig>>; /** * Get the current IPv6 Connection configuration * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#get-the-current-ipv6-connection-configuration * @returns {Promise<Response<IPv6ConnectionConfiguration>>} */ IPv6config(): Promise<Response<IPv6ConnectionConfiguration>>; /** * Update the IPv6 Connection configuration * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#update-the-ipv6-connection-configuration * @param body The new configuration * @returns {Promise<Response<IPv6ConnectionConfiguration>>} */ updateIPv6Config(body: Partial<IPv6ConnectionConfiguration>): Promise<Response<IPv6ConnectionConfiguration>>; } type TPort = Port; declare class PortForwarding extends Submodule { constructor(freebox: Freebox); /** * Retrieves the status of a port or all ports. * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#getting-the-list-of-port-forwarding * @param id - The ID of the port to retrieve the status for. If not provided, retrieves the status of all ports. * @returns {Promise<Response<T>>} */ status<T = TPort[]>(id?: number): Promise<Response<T>>; /** * Updating a port forwarding * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#updating-a-port-forwarding * @param id The id of the port to update * @param data The data to update * @returns {Promise<Response<T>>} */ update(id: number, data: Partial<TPort>): Promise<Response<TPort>>; /** * Add a port forwarding * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#add-a-port-forwarding * @param data Add a port forwarding * @returns {Promise<Response<T>>} */ add(data: Required<TPort>): Promise<Response<TPort>>; /** * Delete a port forwarding * @link https://mafreebox.freebox.fr/doc/index.html?v=b828168f17942dd3e241fff4f01ccdd14bcc89aa#delete-a-port-forwarding * @param id The id of the port to delete * @returns {Promise<VoidResponse>} */ delete(id: number): Promise<VoidResponse>; } declare class Player extends Submodule { constructor(freebox: Freebox); /** * Returns the list of all player devices registered on the local network * @link https://mafreebox.freebox.fr/doc/index.html?v=875e3d530bd643b2bd857397ff6c2984154acf58#list-every-player-devices * @returns {Promise<Response<TPlayer[]>>} */ list(): Promise<Response<Player$1[]>>; /** * Get player device status * @link https://mafreebox.freebox.fr/doc/index.html?v=875e3d530bd643b2bd857397ff6c2984154acf58#get-player-device-status * @param id The ID of the player device to get the status for * @returns {Promise<Response<Partial<PlayerStatus>>>} */ status(id: number): Promise<Response<Partial<PlayerStatus>>>; /** * Control the active media player of a device * @link https://mafreebox.freebox.fr/doc/index.html?v=875e3d530bd643b2bd857397ff6c2984154acf58#control-the-active-media-player-of-a-device * @param id The ID of the player device to control * @param cmd The command to send to the player device * @returns {Promise<VoidResponse>} */ command(id: number, cmd: keyof typeof commands): Promise<VoidResponse>; /** * Control the playback volume of the device * @link https://mafreebox.freebox.fr/doc/index.html?v=875e3d530bd643b2bd857397ff6c2984154acf58#control-the-playback-volume-of-the-device * @param id The ID of the player device to control * @param volume The volume to set on the player device or to mute the player device * @returns {Promise<Response<Partial<volume>>>} */ volume(id: number, volume?: Partial<volume>): Promise<Response<Partial<volume>>>; /** * Open a url on a player device * @link https://mafreebox.freebox.fr/doc/index.html?v=875e3d530bd643b2bd857397ff6c2984154acf58#open-a-url-on-a-player-device * @param id The ID of the player device to control * @param url Url to open on the Freebox Player * @param type Mime type of the content to open on the Freebox Player (optional: default is empty) * @returns {Promise<VoidResponse>} */ open(id: number, url: string, type?: string): Promise<VoidResponse>; } declare class System extends Submodule { constructor(freebox: Freebox); config(): Promise<Response<Configuration$1>>; reboot(): Promise<VoidResponse>; /** * @requires API v11 - Freebox Ultra Only * @returns */ shutdown(): Promise<VoidResponse>; } declare class Configuration extends Submodule { system: System; constructor(freebox: Freebox); } type OnLoginApp = Pick<App, "app_id" | "app_name" | "app_version" | "device_name" | "app_token" | "debug">; declare class Freebox { wifi: Wifi; LAN: LAN; connection: Connection; port: PortForwarding; player: Player; configuration: Configuration; request: typeof request; private readonly logger; readonly _configuration?: Configuration$1; _app: App; token: string; constructor(app: OnLoginApp); login(): Promise<void>; /** * @todo */ logout(): void; } export { Connection as C, Freebox as F, LAN as L, PortForwarding as P, Submodule as S, Wifi as W, Player as a, System as b, Configuration as c };