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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user