feat(unifi): implement comprehensive UniFi API client with controllers, protect, access, account, managers, resources, HTTP client, interfaces, logging, plugins, and tests
This commit is contained in:
284
ts/interfaces/access.ts
Normal file
284
ts/interfaces/access.ts
Normal file
@@ -0,0 +1,284 @@
|
||||
/**
|
||||
* Access API interfaces
|
||||
* Base URL: https://{host}:12445/api/v1/developer
|
||||
*/
|
||||
|
||||
/**
|
||||
* Access device (door controller, hub, reader)
|
||||
*/
|
||||
export interface IAccessDevice {
|
||||
/** Device unique ID */
|
||||
unique_id: string;
|
||||
/** Device name */
|
||||
name: string;
|
||||
/** Device alias */
|
||||
alias?: string;
|
||||
/** Device model */
|
||||
device_type: string;
|
||||
/** Hardware revision */
|
||||
revision?: number;
|
||||
/** Firmware version */
|
||||
version?: string;
|
||||
/** Firmware version */
|
||||
version_update_to?: string;
|
||||
/** Adopted */
|
||||
adopted?: boolean;
|
||||
/** Connected */
|
||||
connected?: boolean;
|
||||
/** IP address */
|
||||
ip?: string;
|
||||
/** MAC address */
|
||||
mac?: string;
|
||||
/** Start timestamp */
|
||||
start_time?: number;
|
||||
/** Security level */
|
||||
security_check?: boolean;
|
||||
/** Location */
|
||||
location?: IAccessLocation;
|
||||
/** Capabilities */
|
||||
capabilities?: string[];
|
||||
/** Device configuration */
|
||||
configs?: IAccessDeviceConfig[];
|
||||
/** Connected devices (for hub) */
|
||||
connected_devices?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Access door
|
||||
*/
|
||||
export interface IAccessDoor {
|
||||
/** Door unique ID */
|
||||
unique_id: string;
|
||||
/** Door name */
|
||||
name: string;
|
||||
/** Door alias */
|
||||
alias?: string;
|
||||
/** Door type */
|
||||
door_type?: string;
|
||||
/** Whether door is locked */
|
||||
door_lock_relay_status?: 'lock' | 'unlock';
|
||||
/** Whether door is open (contact sensor) */
|
||||
door_position_status?: 'open' | 'close';
|
||||
/** Door controller device ID */
|
||||
device_id?: string;
|
||||
/** Associated camera ID */
|
||||
camera_resource_id?: string;
|
||||
/** Location */
|
||||
location_id?: string;
|
||||
/** Full */
|
||||
full_name?: string;
|
||||
/** Extra type */
|
||||
extra_type?: string;
|
||||
/** Door guard */
|
||||
door_guard?: boolean;
|
||||
/** Rules */
|
||||
rules?: IAccessDoorRule[];
|
||||
/** Level ID */
|
||||
level_id?: string;
|
||||
/** Floor info */
|
||||
floor?: IAccessFloor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Door rule
|
||||
*/
|
||||
export interface IAccessDoorRule {
|
||||
/** Rule unique ID */
|
||||
unique_id: string;
|
||||
/** Rule name */
|
||||
name?: string;
|
||||
/** Rule type */
|
||||
type?: string;
|
||||
/** Enabled */
|
||||
enabled?: boolean;
|
||||
/** Interval start */
|
||||
interval_start?: string;
|
||||
/** Interval end */
|
||||
interval_end?: string;
|
||||
/** Days of week */
|
||||
days?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Access user/credential holder
|
||||
*/
|
||||
export interface IAccessUser {
|
||||
/** User unique ID */
|
||||
unique_id: string;
|
||||
/** User ID */
|
||||
id?: string;
|
||||
/** First name */
|
||||
first_name: string;
|
||||
/** Last name */
|
||||
last_name: string;
|
||||
/** Full name */
|
||||
full_name?: string;
|
||||
/** Email */
|
||||
email?: string;
|
||||
/** Phone */
|
||||
phone?: string;
|
||||
/** Employee number */
|
||||
employee_number?: string;
|
||||
/** Status */
|
||||
status?: 'active' | 'inactive' | 'pending';
|
||||
/** Avatar */
|
||||
avatar?: string;
|
||||
/** PIN code (hashed) */
|
||||
pin_code?: string;
|
||||
/** NFC cards */
|
||||
nfc_cards?: IAccessNfcCard[];
|
||||
/** Access groups */
|
||||
access_groups?: string[];
|
||||
/** Notes */
|
||||
notes?: string;
|
||||
/** Start date */
|
||||
start_date?: string;
|
||||
/** End date */
|
||||
end_date?: string;
|
||||
/** Onboarding timestamp */
|
||||
onboarding_timestamp?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* NFC card
|
||||
*/
|
||||
export interface IAccessNfcCard {
|
||||
/** Card unique ID */
|
||||
unique_id?: string;
|
||||
/** Token (card number) */
|
||||
token: string;
|
||||
/** Card type */
|
||||
card_type?: string;
|
||||
/** Card alias */
|
||||
alias?: string;
|
||||
/** Status */
|
||||
status?: 'active' | 'inactive' | 'pending';
|
||||
/** Is lost */
|
||||
is_lost?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access policy/group
|
||||
*/
|
||||
export interface IAccessPolicy {
|
||||
/** Policy unique ID */
|
||||
unique_id: string;
|
||||
/** Policy name */
|
||||
name: string;
|
||||
/** Description */
|
||||
description?: string;
|
||||
/** Resources (doors) */
|
||||
resources?: IAccessPolicyResource[];
|
||||
/** Schedules */
|
||||
schedules?: IAccessSchedule[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Policy resource
|
||||
*/
|
||||
export interface IAccessPolicyResource {
|
||||
/** Resource unique ID */
|
||||
unique_id: string;
|
||||
/** Resource type */
|
||||
type?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Schedule
|
||||
*/
|
||||
export interface IAccessSchedule {
|
||||
/** Schedule unique ID */
|
||||
unique_id: string;
|
||||
/** Name */
|
||||
name?: string;
|
||||
/** Type */
|
||||
type?: string;
|
||||
/** Days */
|
||||
days?: string[];
|
||||
/** Start time */
|
||||
start_time?: string;
|
||||
/** End time */
|
||||
end_time?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Location (building/area)
|
||||
*/
|
||||
export interface IAccessLocation {
|
||||
/** Location unique ID */
|
||||
unique_id: string;
|
||||
/** Location name */
|
||||
name: string;
|
||||
/** Address */
|
||||
address?: string;
|
||||
/** Timezone */
|
||||
timezone?: string;
|
||||
/** Latitude */
|
||||
latitude?: number;
|
||||
/** Longitude */
|
||||
longitude?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Floor
|
||||
*/
|
||||
export interface IAccessFloor {
|
||||
/** Floor unique ID */
|
||||
unique_id: string;
|
||||
/** Floor name */
|
||||
name: string;
|
||||
/** Floor number */
|
||||
number?: number;
|
||||
/** Floor plan image */
|
||||
floor_plan_id?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device configuration
|
||||
*/
|
||||
export interface IAccessDeviceConfig {
|
||||
/** Config key */
|
||||
key: string;
|
||||
/** Config value */
|
||||
value: string | number | boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access event (entry/exit log)
|
||||
*/
|
||||
export interface IAccessEvent {
|
||||
/** Event unique ID */
|
||||
unique_id: string;
|
||||
/** Event type */
|
||||
type: 'access.door.unlock' | 'access.door.lock' | 'access.door.open' | 'access.door.close' | 'access.entry.granted' | 'access.entry.denied';
|
||||
/** Timestamp */
|
||||
timestamp: number;
|
||||
/** Door ID */
|
||||
door_id?: string;
|
||||
/** User ID */
|
||||
user_id?: string;
|
||||
/** Device ID */
|
||||
device_id?: string;
|
||||
/** Reason */
|
||||
reason?: string;
|
||||
/** Extra data */
|
||||
extra?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access API response wrapper
|
||||
*/
|
||||
export interface IAccessApiResponse<T> {
|
||||
/** Code (SUCCESS, etc.) */
|
||||
code: string;
|
||||
/** Message */
|
||||
msg?: string;
|
||||
/** Data payload */
|
||||
data: T;
|
||||
/** Pagination info */
|
||||
pagination?: {
|
||||
page?: number;
|
||||
page_size?: number;
|
||||
total?: number;
|
||||
};
|
||||
}
|
||||
75
ts/interfaces/common.ts
Normal file
75
ts/interfaces/common.ts
Normal file
@@ -0,0 +1,75 @@
|
||||
/**
|
||||
* Common interfaces shared across all UniFi APIs
|
||||
*/
|
||||
|
||||
/**
|
||||
* Standard UniFi API response wrapper
|
||||
*/
|
||||
export interface IUnifiApiResponse<T> {
|
||||
meta: {
|
||||
rc: 'ok' | 'error';
|
||||
msg?: string;
|
||||
};
|
||||
data: T[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for UniFi Account (Site Manager cloud API)
|
||||
*/
|
||||
export interface IUnifiAccountOptions {
|
||||
/** API key from ui.com */
|
||||
apiKey: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for UniFi Controller (Network Controller local API)
|
||||
* Supports either API key auth OR username/password session auth
|
||||
*/
|
||||
export interface IUnifiControllerOptions {
|
||||
/** Controller host (IP or hostname) */
|
||||
host: string;
|
||||
/** API key for authentication (preferred) */
|
||||
apiKey?: string;
|
||||
/** Username for session authentication */
|
||||
username?: string;
|
||||
/** Password for session authentication */
|
||||
password?: string;
|
||||
/** Controller type - affects API paths */
|
||||
controllerType?: 'unifi-os' | 'udm-pro' | 'standalone';
|
||||
/** Whether to verify SSL certificates (default: false for self-signed) */
|
||||
verifySsl?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for UniFi Protect (NVR local API)
|
||||
* Supports either API key auth OR username/password session auth
|
||||
*/
|
||||
export interface IUnifiProtectOptions {
|
||||
/** Protect host (IP or hostname) */
|
||||
host: string;
|
||||
/** API key for authentication (preferred) */
|
||||
apiKey?: string;
|
||||
/** Username for session authentication */
|
||||
username?: string;
|
||||
/** Password for session authentication */
|
||||
password?: string;
|
||||
/** Whether to verify SSL certificates (default: false for self-signed) */
|
||||
verifySsl?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options for UniFi Access (Access Controller local API)
|
||||
*/
|
||||
export interface IUnifiAccessOptions {
|
||||
/** Access host (IP or hostname) */
|
||||
host: string;
|
||||
/** Bearer token for authentication */
|
||||
token: string;
|
||||
/** Whether to verify SSL certificates (default: false for self-signed) */
|
||||
verifySsl?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* HTTP request method types
|
||||
*/
|
||||
export type THttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
||||
9
ts/interfaces/index.ts
Normal file
9
ts/interfaces/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Re-export all interfaces
|
||||
*/
|
||||
|
||||
export * from './common.js';
|
||||
export * from './sitemanager.js';
|
||||
export * from './network.js';
|
||||
export * from './protect.js';
|
||||
export * from './access.js';
|
||||
272
ts/interfaces/network.ts
Normal file
272
ts/interfaces/network.ts
Normal file
@@ -0,0 +1,272 @@
|
||||
/**
|
||||
* Network Controller API interfaces
|
||||
* Base URL: https://{host}/api or https://{host}/proxy/network/api
|
||||
*/
|
||||
|
||||
/**
|
||||
* Network site
|
||||
*/
|
||||
export interface INetworkSite {
|
||||
/** Site ID (e.g., 'default') */
|
||||
_id: string;
|
||||
/** Site name */
|
||||
name: string;
|
||||
/** Site description */
|
||||
desc?: string;
|
||||
/** Whether anonymous ID is enabled */
|
||||
anonymous_id?: string;
|
||||
/** Role for the site */
|
||||
role?: string;
|
||||
/** Attribute for hidden ID */
|
||||
attr_hidden_id?: string;
|
||||
/** Attribute for hidden and no delete */
|
||||
attr_no_delete?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network device (switch, AP, gateway, etc.)
|
||||
*/
|
||||
export interface INetworkDevice {
|
||||
/** Device ID */
|
||||
_id: string;
|
||||
/** Device MAC address */
|
||||
mac: string;
|
||||
/** Device model */
|
||||
model: string;
|
||||
/** Device type (ugw, usw, uap, etc.) */
|
||||
type: string;
|
||||
/** Device name */
|
||||
name?: string;
|
||||
/** Site ID */
|
||||
site_id: string;
|
||||
/** Whether device is adopted */
|
||||
adopted: boolean;
|
||||
/** Device IP address */
|
||||
ip: string;
|
||||
/** Device state (0=offline, 1=connected, etc.) */
|
||||
state: number;
|
||||
/** Serial number */
|
||||
serial?: string;
|
||||
/** Firmware version */
|
||||
version?: string;
|
||||
/** Uptime in seconds */
|
||||
uptime?: number;
|
||||
/** Last seen timestamp */
|
||||
last_seen?: number;
|
||||
/** Whether device is upgradable */
|
||||
upgradable?: boolean;
|
||||
/** Available upgrade version */
|
||||
upgrade_to_firmware?: string;
|
||||
/** Device configuration */
|
||||
config_network?: {
|
||||
type?: string;
|
||||
ip?: string;
|
||||
};
|
||||
/** Device ethernet table */
|
||||
ethernet_table?: Array<{
|
||||
name: string;
|
||||
mac: string;
|
||||
num_port?: number;
|
||||
}>;
|
||||
/** Port overrides configuration */
|
||||
port_overrides?: Array<{
|
||||
port_idx: number;
|
||||
name?: string;
|
||||
poe_mode?: string;
|
||||
}>;
|
||||
/** System stats */
|
||||
sys_stats?: {
|
||||
loadavg_1?: number;
|
||||
loadavg_5?: number;
|
||||
loadavg_15?: number;
|
||||
mem_total?: number;
|
||||
mem_used?: number;
|
||||
};
|
||||
/** LED override */
|
||||
led_override?: string;
|
||||
/** LED override color */
|
||||
led_override_color?: string;
|
||||
/** LED override brightness */
|
||||
led_override_color_brightness?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network client (connected device)
|
||||
*/
|
||||
export interface INetworkClient {
|
||||
/** Client ID */
|
||||
_id: string;
|
||||
/** MAC address */
|
||||
mac: string;
|
||||
/** Site ID */
|
||||
site_id: string;
|
||||
/** Whether client is authorized (for guest network) */
|
||||
is_guest?: boolean;
|
||||
/** Whether client is wired */
|
||||
is_wired: boolean;
|
||||
/** First seen timestamp */
|
||||
first_seen?: number;
|
||||
/** Last seen timestamp */
|
||||
last_seen?: number;
|
||||
/** Hostname */
|
||||
hostname?: string;
|
||||
/** Client name (user-assigned) */
|
||||
name?: string;
|
||||
/** Client IP address */
|
||||
ip?: string;
|
||||
/** Network ID */
|
||||
network_id?: string;
|
||||
/** Uplink MAC (AP or switch) */
|
||||
uplink_mac?: string;
|
||||
/** Connected AP name */
|
||||
ap_name?: string;
|
||||
/** SSID if wireless */
|
||||
essid?: string;
|
||||
/** BSSID if wireless */
|
||||
bssid?: string;
|
||||
/** Channel if wireless */
|
||||
channel?: number;
|
||||
/** Radio protocol (ng, na, ac, ax) */
|
||||
radio_proto?: string;
|
||||
/** Signal strength */
|
||||
signal?: number;
|
||||
/** TX rate */
|
||||
tx_rate?: number;
|
||||
/** RX rate */
|
||||
rx_rate?: number;
|
||||
/** TX bytes */
|
||||
tx_bytes?: number;
|
||||
/** RX bytes */
|
||||
rx_bytes?: number;
|
||||
/** TX packets */
|
||||
tx_packets?: number;
|
||||
/** RX packets */
|
||||
rx_packets?: number;
|
||||
/** Connected switch port */
|
||||
sw_port?: number;
|
||||
/** User group ID */
|
||||
usergroup_id?: string;
|
||||
/** OUI (device manufacturer) */
|
||||
oui?: string;
|
||||
/** Noted status */
|
||||
noted?: boolean;
|
||||
/** User ID if fixed IP */
|
||||
user_id?: string;
|
||||
/** Fingerprint data */
|
||||
fingerprint_source?: number;
|
||||
/** Device fingerprint */
|
||||
dev_cat?: number;
|
||||
dev_family?: number;
|
||||
dev_vendor?: number;
|
||||
dev_id?: number;
|
||||
/** OS name */
|
||||
os_name?: number;
|
||||
/** Satisfaction score */
|
||||
satisfaction?: number;
|
||||
/** Anomalies count */
|
||||
anomalies?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network WLAN configuration
|
||||
*/
|
||||
export interface INetworkWlan {
|
||||
/** WLAN ID */
|
||||
_id: string;
|
||||
/** WLAN name */
|
||||
name: string;
|
||||
/** Site ID */
|
||||
site_id: string;
|
||||
/** SSID */
|
||||
x_passphrase?: string;
|
||||
/** Whether WLAN is enabled */
|
||||
enabled: boolean;
|
||||
/** Security mode */
|
||||
security?: string;
|
||||
/** WPA mode */
|
||||
wpa_mode?: string;
|
||||
/** WPA encryption */
|
||||
wpa_enc?: string;
|
||||
/** VLAN ID */
|
||||
networkconf_id?: string;
|
||||
/** User group ID */
|
||||
usergroup_id?: string;
|
||||
/** Whether hidden */
|
||||
hide_ssid?: boolean;
|
||||
/** Whether PMF is enabled */
|
||||
pmf_mode?: string;
|
||||
/** Group rekey interval */
|
||||
group_rekey?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Network configuration (VLAN/subnet)
|
||||
*/
|
||||
export interface INetworkConfig {
|
||||
/** Config ID */
|
||||
_id: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Site ID */
|
||||
site_id: string;
|
||||
/** Purpose (corporate, guest, wan, etc.) */
|
||||
purpose: string;
|
||||
/** VLAN ID */
|
||||
vlan?: number;
|
||||
/** VLAN enabled */
|
||||
vlan_enabled?: boolean;
|
||||
/** Subnet */
|
||||
ip_subnet?: string;
|
||||
/** DHCP enabled */
|
||||
dhcpd_enabled?: boolean;
|
||||
/** DHCP start */
|
||||
dhcpd_start?: string;
|
||||
/** DHCP stop */
|
||||
dhcpd_stop?: string;
|
||||
/** Domain name */
|
||||
domain_name?: string;
|
||||
/** Whether this is the default network */
|
||||
is_nat?: boolean;
|
||||
/** Network group */
|
||||
networkgroup?: string;
|
||||
/** IGMP snooping */
|
||||
igmp_snooping?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Device port configuration
|
||||
*/
|
||||
export interface IPortConfig {
|
||||
port_idx: number;
|
||||
name?: string;
|
||||
poe_mode?: string;
|
||||
port_poe?: boolean;
|
||||
portconf_id?: string;
|
||||
speed_caps?: number;
|
||||
op_mode?: string;
|
||||
autoneg?: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auth response from controller
|
||||
*/
|
||||
export interface INetworkAuthResponse {
|
||||
/** Response code */
|
||||
rc: string;
|
||||
/** Session token/unique ID */
|
||||
unique_id?: string;
|
||||
/** First name */
|
||||
first_name?: string;
|
||||
/** Last name */
|
||||
last_name?: string;
|
||||
/** Full name */
|
||||
full_name?: string;
|
||||
/** Email */
|
||||
email?: string;
|
||||
/** Is super admin */
|
||||
is_super?: boolean;
|
||||
/** Device ID */
|
||||
device_id?: string;
|
||||
/** UI settings */
|
||||
ui_settings?: Record<string, unknown>;
|
||||
}
|
||||
564
ts/interfaces/protect.ts
Normal file
564
ts/interfaces/protect.ts
Normal file
@@ -0,0 +1,564 @@
|
||||
/**
|
||||
* Protect API interfaces
|
||||
* Base URL: https://{host}/proxy/protect/api
|
||||
*/
|
||||
|
||||
/**
|
||||
* Protect bootstrap response containing system configuration
|
||||
*/
|
||||
export interface IProtectBootstrap {
|
||||
/** Auth user info */
|
||||
authUser?: IProtectUser;
|
||||
/** Access key */
|
||||
accessKey?: string;
|
||||
/** Cameras list */
|
||||
cameras: IProtectCamera[];
|
||||
/** Users list */
|
||||
users?: IProtectUser[];
|
||||
/** Groups list */
|
||||
groups?: IProtectGroup[];
|
||||
/** Liveviews */
|
||||
liveviews?: IProtectLiveview[];
|
||||
/** Viewers */
|
||||
viewers?: IProtectViewer[];
|
||||
/** Lights */
|
||||
lights?: IProtectLight[];
|
||||
/** Bridges */
|
||||
bridges?: IProtectBridge[];
|
||||
/** Sensors */
|
||||
sensors?: IProtectSensor[];
|
||||
/** Doorbells */
|
||||
doorbells?: IProtectDoorbell[];
|
||||
/** Chimes */
|
||||
chimes?: IProtectChime[];
|
||||
/** NVR info */
|
||||
nvr: IProtectNvr;
|
||||
/** Last update ID */
|
||||
lastUpdateId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect camera
|
||||
*/
|
||||
export interface IProtectCamera {
|
||||
/** Camera ID */
|
||||
id: string;
|
||||
/** MAC address */
|
||||
mac: string;
|
||||
/** Host address */
|
||||
host: string;
|
||||
/** Camera name */
|
||||
name: string;
|
||||
/** Camera type/model */
|
||||
type: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
/** Camera state */
|
||||
state: 'CONNECTED' | 'DISCONNECTED' | 'CONNECTING' | 'ADOPTING' | 'MANAGED';
|
||||
/** Hardware revision */
|
||||
hardwareRevision?: string;
|
||||
/** Firmware version */
|
||||
firmwareVersion?: string;
|
||||
/** Firmware build */
|
||||
firmwareBuild?: string;
|
||||
/** Whether camera is updating */
|
||||
isUpdating?: boolean;
|
||||
/** Whether camera is adopting */
|
||||
isAdopting?: boolean;
|
||||
/** Whether camera is managed */
|
||||
isManaged?: boolean;
|
||||
/** Whether camera is connected */
|
||||
isConnected?: boolean;
|
||||
/** Whether recording is enabled */
|
||||
isRecording?: boolean;
|
||||
/** Whether motion detection is enabled */
|
||||
isMotionDetected?: boolean;
|
||||
/** Whether camera is dark (IR mode) */
|
||||
isDark?: boolean;
|
||||
/** Recording settings */
|
||||
recordingSettings?: IProtectRecordingSettings;
|
||||
/** Smart detect settings */
|
||||
smartDetectSettings?: IProtectSmartDetectSettings;
|
||||
/** ISP settings (image settings) */
|
||||
ispSettings?: IProtectIspSettings;
|
||||
/** Microphone settings */
|
||||
micVolume?: number;
|
||||
/** Speaker settings */
|
||||
speakerVolume?: number;
|
||||
/** Last motion timestamp */
|
||||
lastMotion?: number;
|
||||
/** Last ring timestamp (for doorbells) */
|
||||
lastRing?: number;
|
||||
/** Uptime */
|
||||
uptime?: number;
|
||||
/** Connected since */
|
||||
connectedSince?: number;
|
||||
/** Up since */
|
||||
upSince?: number;
|
||||
/** Last seen */
|
||||
lastSeen?: number;
|
||||
/** Channels info */
|
||||
channels?: IProtectCameraChannel[];
|
||||
/** Feature flags */
|
||||
featureFlags?: IProtectFeatureFlags;
|
||||
/** Stats */
|
||||
stats?: IProtectCameraStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera channel configuration
|
||||
*/
|
||||
export interface IProtectCameraChannel {
|
||||
/** Channel ID */
|
||||
id: number;
|
||||
/** Video mode */
|
||||
videoMode?: string;
|
||||
/** Enabled */
|
||||
enabled: boolean;
|
||||
/** FPS mode */
|
||||
fpsValues?: number[];
|
||||
/** Is RTSP enabled */
|
||||
isRtspEnabled?: boolean;
|
||||
/** RTSP alias */
|
||||
rtspAlias?: string;
|
||||
/** Width */
|
||||
width?: number;
|
||||
/** Height */
|
||||
height?: number;
|
||||
/** FPS */
|
||||
fps?: number;
|
||||
/** Bitrate */
|
||||
bitrate?: number;
|
||||
/** Min bitrate */
|
||||
minBitrate?: number;
|
||||
/** Max bitrate */
|
||||
maxBitrate?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recording settings
|
||||
*/
|
||||
export interface IProtectRecordingSettings {
|
||||
/** Pre-padding seconds */
|
||||
prePaddingSecs?: number;
|
||||
/** Post-padding seconds */
|
||||
postPaddingSecs?: number;
|
||||
/** Min motion event trigger */
|
||||
minMotionEventTrigger?: number;
|
||||
/** End motion event delay */
|
||||
endMotionEventDelay?: number;
|
||||
/** Suppress illumination surge */
|
||||
suppressIlluminationSurge?: boolean;
|
||||
/** Mode */
|
||||
mode?: 'always' | 'detections' | 'never' | 'schedule';
|
||||
/** Enable PIR timelapse */
|
||||
enablePirTimelapse?: boolean;
|
||||
/** Use new motion algorithm */
|
||||
useNewMotionAlgorithm?: boolean;
|
||||
/** In schedule mode */
|
||||
inScheduleMode?: string;
|
||||
/** Out schedule mode */
|
||||
outScheduleMode?: string;
|
||||
/** Geofencing */
|
||||
geofencing?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smart detect settings
|
||||
*/
|
||||
export interface IProtectSmartDetectSettings {
|
||||
/** Object types to detect */
|
||||
objectTypes?: string[];
|
||||
/** Audio types to detect */
|
||||
audioTypes?: string[];
|
||||
/** Auto tracking object types */
|
||||
autoTrackingObjectTypes?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* ISP (Image Signal Processor) settings
|
||||
*/
|
||||
export interface IProtectIspSettings {
|
||||
/** AE mode */
|
||||
aeMode?: string;
|
||||
/** IR LED mode */
|
||||
irLedMode?: string;
|
||||
/** IR LED level */
|
||||
irLedLevel?: number;
|
||||
/** WDR */
|
||||
wdr?: number;
|
||||
/** ICR sensitivity */
|
||||
icrSensitivity?: number;
|
||||
/** Brightness */
|
||||
brightness?: number;
|
||||
/** Contrast */
|
||||
contrast?: number;
|
||||
/** Hue */
|
||||
hue?: number;
|
||||
/** Saturation */
|
||||
saturation?: number;
|
||||
/** Sharpness */
|
||||
sharpness?: number;
|
||||
/** Denoise */
|
||||
denoise?: number;
|
||||
/** Is flip enabled */
|
||||
isFlippedVertical?: boolean;
|
||||
/** Is mirror enabled */
|
||||
isFlippedHorizontal?: boolean;
|
||||
/** Is auto rotate enabled */
|
||||
isAutoRotateEnabled?: boolean;
|
||||
/** HDR mode */
|
||||
hdrMode?: string;
|
||||
/** Is color night vision enabled */
|
||||
isColorNightVisionEnabled?: boolean;
|
||||
/** Spotlight duration */
|
||||
spotlightDuration?: number;
|
||||
/** Focus mode */
|
||||
focusMode?: string;
|
||||
/** Focus position */
|
||||
focusPosition?: number;
|
||||
/** Zoom position */
|
||||
zoomPosition?: number;
|
||||
/** Touch focus X */
|
||||
touchFocusX?: number;
|
||||
/** Touch focus Y */
|
||||
touchFocusY?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera feature flags
|
||||
*/
|
||||
export interface IProtectFeatureFlags {
|
||||
/** Can adjust IR LED level */
|
||||
canAdjustIrLedLevel?: boolean;
|
||||
/** Has chime */
|
||||
hasChime?: boolean;
|
||||
/** Has flash */
|
||||
hasFlash?: boolean;
|
||||
/** Has HDR */
|
||||
hasHdr?: boolean;
|
||||
/** Has IR LED */
|
||||
hasIrLed?: boolean;
|
||||
/** Has LCD screen */
|
||||
hasLcdScreen?: boolean;
|
||||
/** Has LED status */
|
||||
hasLedStatus?: boolean;
|
||||
/** Has line in */
|
||||
hasLineIn?: boolean;
|
||||
/** Has mic */
|
||||
hasMic?: boolean;
|
||||
/** Has privacy mask */
|
||||
hasPrivacyMask?: boolean;
|
||||
/** Has RTSP */
|
||||
hasRtsp?: boolean;
|
||||
/** Has SD card */
|
||||
hasSdCard?: boolean;
|
||||
/** Has smart detect */
|
||||
hasSmartDetect?: boolean;
|
||||
/** Has speaker */
|
||||
hasSpeaker?: boolean;
|
||||
/** Has WiFi */
|
||||
hasWifi?: boolean;
|
||||
/** Video modes */
|
||||
videoModes?: string[];
|
||||
/** Privacy mask capability */
|
||||
privacyMaskCapability?: {
|
||||
maxMasks?: number;
|
||||
rectangleOnly?: boolean;
|
||||
};
|
||||
/** Smart detect types */
|
||||
smartDetectTypes?: string[];
|
||||
/** Smart detect audio types */
|
||||
smartDetectAudioTypes?: string[];
|
||||
/** Motion algorithms */
|
||||
motionAlgorithms?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera stats
|
||||
*/
|
||||
export interface IProtectCameraStats {
|
||||
/** RX bytes */
|
||||
rxBytes?: number;
|
||||
/** TX bytes */
|
||||
txBytes?: number;
|
||||
/** WiFi quality */
|
||||
wifiQuality?: number;
|
||||
/** WiFi strength */
|
||||
wifiStrength?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect user
|
||||
*/
|
||||
export interface IProtectUser {
|
||||
/** User ID */
|
||||
id: string;
|
||||
/** Is owner */
|
||||
isOwner?: boolean;
|
||||
/** Name */
|
||||
name?: string;
|
||||
/** Email */
|
||||
email?: string;
|
||||
/** Local username */
|
||||
localUsername?: string;
|
||||
/** Has accepted invite */
|
||||
hasAcceptedInvite?: boolean;
|
||||
/** All permissions */
|
||||
allPermissions?: string[];
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect group
|
||||
*/
|
||||
export interface IProtectGroup {
|
||||
/** Group ID */
|
||||
id: string;
|
||||
/** Group name */
|
||||
name: string;
|
||||
/** Group type */
|
||||
type?: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect liveview
|
||||
*/
|
||||
export interface IProtectLiveview {
|
||||
/** Liveview ID */
|
||||
id: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Is default */
|
||||
isDefault?: boolean;
|
||||
/** Layout */
|
||||
layout?: number;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
/** Slots */
|
||||
slots?: IProtectLiveviewSlot[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect liveview slot
|
||||
*/
|
||||
export interface IProtectLiveviewSlot {
|
||||
/** Camera IDs */
|
||||
cameras?: string[];
|
||||
/** Cycle mode */
|
||||
cycleMode?: string;
|
||||
/** Cycle interval */
|
||||
cycleInterval?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect viewer
|
||||
*/
|
||||
export interface IProtectViewer {
|
||||
/** Viewer ID */
|
||||
id: string;
|
||||
/** Name */
|
||||
name?: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect light
|
||||
*/
|
||||
export interface IProtectLight {
|
||||
/** Light ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
/** Is light on */
|
||||
isLightOn?: boolean;
|
||||
/** Light device settings */
|
||||
lightDeviceSettings?: {
|
||||
ledLevel?: number;
|
||||
luxSensitivity?: string;
|
||||
pirDuration?: number;
|
||||
pirSensitivity?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect bridge
|
||||
*/
|
||||
export interface IProtectBridge {
|
||||
/** Bridge ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect sensor
|
||||
*/
|
||||
export interface IProtectSensor {
|
||||
/** Sensor ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
/** Battery status */
|
||||
batteryStatus?: {
|
||||
percentage?: number;
|
||||
isLow?: boolean;
|
||||
};
|
||||
/** Mount type */
|
||||
mountType?: string;
|
||||
/** Is motion detected */
|
||||
isMotionDetected?: boolean;
|
||||
/** Is opened */
|
||||
isOpened?: boolean;
|
||||
/** Humidity */
|
||||
humidity?: number;
|
||||
/** Temperature */
|
||||
temperature?: number;
|
||||
/** Light */
|
||||
light?: number;
|
||||
/** Alarm triggered type */
|
||||
alarmTriggeredType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect doorbell (extends camera)
|
||||
*/
|
||||
export interface IProtectDoorbell extends IProtectCamera {
|
||||
/** LCD message */
|
||||
lcdMessage?: {
|
||||
text?: string;
|
||||
resetAt?: number;
|
||||
type?: string;
|
||||
};
|
||||
/** Chime duration */
|
||||
chimeDuration?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect chime
|
||||
*/
|
||||
export interface IProtectChime {
|
||||
/** Chime ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
/** Is paired with doorbell */
|
||||
isPaired?: boolean;
|
||||
/** Volume */
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect NVR info
|
||||
*/
|
||||
export interface IProtectNvr {
|
||||
/** NVR ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Host */
|
||||
host: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** Is connected to cloud */
|
||||
isConnectedToCloud?: boolean;
|
||||
/** Firmware version */
|
||||
firmwareVersion?: string;
|
||||
/** Hardware */
|
||||
hardware?: {
|
||||
shortname?: string;
|
||||
name?: string;
|
||||
};
|
||||
/** Uptime */
|
||||
uptime?: number;
|
||||
/** Last seen */
|
||||
lastSeen?: number;
|
||||
/** Is recording disabled */
|
||||
isRecordingDisabled?: boolean;
|
||||
/** Is recording motion only */
|
||||
isRecordingMotionOnly?: boolean;
|
||||
/** Storage info */
|
||||
storageInfo?: {
|
||||
totalSize?: number;
|
||||
totalSpaceUsed?: number;
|
||||
devices?: Array<{
|
||||
model?: string;
|
||||
size?: number;
|
||||
healthy?: boolean;
|
||||
}>;
|
||||
};
|
||||
/** Timezone */
|
||||
timezone?: string;
|
||||
/** Version */
|
||||
version?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auth response from Protect
|
||||
*/
|
||||
export interface IProtectAuthResponse {
|
||||
/** CSRF token in response */
|
||||
csrfToken?: string;
|
||||
/** User info */
|
||||
user?: IProtectUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Motion event from Protect
|
||||
*/
|
||||
export interface IProtectMotionEvent {
|
||||
/** Event ID */
|
||||
id: string;
|
||||
/** Event type */
|
||||
type: 'motion' | 'ring' | 'smartDetectZone' | 'smartAudioDetect';
|
||||
/** Start timestamp */
|
||||
start: number;
|
||||
/** End timestamp */
|
||||
end?: number;
|
||||
/** Score (confidence) */
|
||||
score?: number;
|
||||
/** Smart detect types */
|
||||
smartDetectTypes?: string[];
|
||||
/** Smart detect events */
|
||||
smartDetectEvents?: string[];
|
||||
/** Camera ID */
|
||||
camera?: string;
|
||||
/** Partition (for storage) */
|
||||
partition?: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
/** Thumbnail ID */
|
||||
thumbnail?: string;
|
||||
/** Has heatmap */
|
||||
heatmap?: string;
|
||||
}
|
||||
78
ts/interfaces/sitemanager.ts
Normal file
78
ts/interfaces/sitemanager.ts
Normal file
@@ -0,0 +1,78 @@
|
||||
/**
|
||||
* Site Manager (Cloud) API interfaces
|
||||
* Base URL: https://api.ui.com/v1
|
||||
*/
|
||||
|
||||
/**
|
||||
* Site from Site Manager API
|
||||
*/
|
||||
export interface IUnifiSite {
|
||||
/** Unique site ID */
|
||||
siteId: string;
|
||||
/** Site name */
|
||||
name: string;
|
||||
/** Site description */
|
||||
description?: string;
|
||||
/** Whether this is the default site */
|
||||
isDefault?: boolean;
|
||||
/** Timezone for the site */
|
||||
timezone?: string;
|
||||
/** Site meta info */
|
||||
meta?: {
|
||||
/** Site type */
|
||||
type?: string;
|
||||
/** Site address */
|
||||
address?: string;
|
||||
};
|
||||
/** Creation timestamp */
|
||||
createdAt?: string;
|
||||
/** Last modified timestamp */
|
||||
updatedAt?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Host device from Site Manager API
|
||||
*/
|
||||
export interface IUnifiHost {
|
||||
/** Unique host ID */
|
||||
id: string;
|
||||
/** Hardware UUID */
|
||||
hardwareId?: string;
|
||||
/** Host name */
|
||||
name?: string;
|
||||
/** Host type (e.g., 'udm-pro', 'cloud-key-gen2-plus') */
|
||||
type?: string;
|
||||
/** Firmware version */
|
||||
firmwareVersion?: string;
|
||||
/** Whether the host is online */
|
||||
isOnline?: boolean;
|
||||
/** IP address */
|
||||
ipAddress?: string;
|
||||
/** MAC address */
|
||||
macAddress?: string;
|
||||
/** Associated site ID */
|
||||
siteId?: string;
|
||||
/** Host status info */
|
||||
status?: {
|
||||
/** Connection state */
|
||||
state?: string;
|
||||
/** Last seen timestamp */
|
||||
lastSeen?: string;
|
||||
};
|
||||
/** Features/applications running */
|
||||
features?: string[];
|
||||
/** Reported state from host */
|
||||
reportedState?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Site Manager API list response
|
||||
*/
|
||||
export interface ISiteManagerListResponse<T> {
|
||||
data: T[];
|
||||
meta?: {
|
||||
total?: number;
|
||||
page?: number;
|
||||
pageSize?: number;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user