UNPKG

6.18 kBTypeScriptView Raw
1import { Formats, Perms, Units } from "./lib/Characteristic";
2import { ResourceRequestReason } from "./lib/controller";
3import { HAPStatus } from "./lib/HAPServer";
4/**
5 * @group Utils
6 */
7export type Nullable<T> = T | null;
8/**
9 * @group Utils
10 */
11export type WithUUID<T> = T & {
12 UUID: string;
13};
14/**
15 * Like TypeScripts `Partial` but allowing null as a value.
16 *
17 * @group Utils
18 */
19export type PartialAllowingNull<T> = {
20 [P in keyof T]?: T[P] | null;
21};
22/**
23 * Type of the constructor arguments of the provided constructor type.
24 *
25 * @group Utils
26 */
27export type ConstructorArgs<C> = C extends new (...args: infer A) => any ? A : never;
28/**
29 * UUID string uniquely identifying every HAP connection.
30 *
31 * @group HAP Accessory Server
32 */
33export type SessionIdentifier = string;
34/**
35 * Defines a mac address.
36 * Must have a format like 'XX:XX:XX:XX:XX:XX' with XX being a valid hexadecimal string
37 *
38 * @group Utils
39 */
40export type MacAddress = string;
41/**
42 * Defines a pincode for the HAP accessory.
43 * Must have a format like "XXX-XX-XXX".
44 *
45 * @group Accessory
46 */
47export type HAPPincode = string;
48/**
49 * @group Utils
50 */
51export type InterfaceName = string;
52/**
53 * @group Utils
54 */
55export type IPv4Address = string;
56/**
57 * @group Utils
58 */
59export type IPv6Address = string;
60/**
61 * @group Utils
62 */
63export type IPAddress = IPv4Address | IPv6Address;
64/**
65 * @group Utils
66 */
67export type NodeCallback<T> = (err: Nullable<Error> | undefined, data?: T) => void;
68/**
69 * @group Utils
70 */
71export type VoidCallback = (err?: Nullable<Error>) => void;
72/**
73 * @group Utils
74 */
75export type PrimitiveTypes = string | number | boolean;
76/**
77 * @group Characteristic
78 */
79export type CharacteristicValue = PrimitiveTypes | PrimitiveTypes[] | {
80 [key: string]: PrimitiveTypes;
81};
82/**
83 * @group HAP Accessory Server
84 */
85export interface CharacteristicJsonObject {
86 type: string;
87 iid: number;
88 value?: Nullable<CharacteristicValue>;
89 perms: Perms[];
90 format: Formats | string;
91 description?: string;
92 unit?: Units | string;
93 minValue?: number;
94 maxValue?: number;
95 minStep?: number;
96 maxLen?: number;
97 maxDataLen?: number;
98 "valid-values"?: number[];
99 "valid-values-range"?: [min: number, max: number];
100}
101/**
102 * @group HAP Accessory Server
103 */
104export interface ServiceJsonObject {
105 type: string;
106 iid: number;
107 characteristics: CharacteristicJsonObject[];
108 hidden?: boolean;
109 primary?: boolean;
110 linked?: number[];
111}
112/**
113 * @group HAP Accessory Server
114 */
115export interface AccessoryJsonObject {
116 aid: number;
117 services: ServiceJsonObject[];
118}
119/**
120 * @group HAP Accessory Server
121 */
122export interface AccessoriesResponse {
123 accessories: AccessoryJsonObject[];
124}
125/**
126 * @group HAP Accessory Server
127 */
128export interface CharacteristicId {
129 aid: number;
130 iid: number;
131}
132/**
133 * @group HAP Accessory Server
134 */
135export interface CharacteristicsReadRequest {
136 ids: CharacteristicId[];
137 includeMeta: boolean;
138 includePerms: boolean;
139 includeType: boolean;
140 includeEvent: boolean;
141}
142/**
143 * @group HAP Accessory Server
144 */
145export interface PartialCharacteristicReadDataValue {
146 value: CharacteristicValue | null;
147 status?: HAPStatus.SUCCESS;
148 type?: string;
149 format?: string;
150 unit?: string;
151 minValue?: number;
152 maxValue?: number;
153 minStep?: number;
154 maxLen?: number;
155 perms?: Perms[];
156 ev?: boolean;
157}
158/**
159 * @group HAP Accessory Server
160 */
161export interface PartialCharacteristicReadError {
162 status: HAPStatus;
163}
164/**
165 * @group HAP Accessory Server
166 */
167export interface CharacteristicReadDataValue extends PartialCharacteristicReadDataValue {
168 aid: number;
169 iid: number;
170}
171/**
172 * @group HAP Accessory Server
173 */
174export interface CharacteristicReadError extends PartialCharacteristicReadError {
175 aid: number;
176 iid: number;
177}
178/**
179 * @group HAP Accessory Server
180 */
181export type PartialCharacteristicReadData = PartialCharacteristicReadDataValue | PartialCharacteristicReadError;
182/**
183 * @group HAP Accessory Server
184 */
185export type CharacteristicReadData = CharacteristicReadDataValue | CharacteristicReadError;
186/**
187 * @group HAP Accessory Server
188 */
189export interface CharacteristicsReadResponse {
190 characteristics: CharacteristicReadData[];
191}
192/**
193 * @group HAP Accessory Server
194 */
195export interface CharacteristicWrite {
196 aid: number;
197 iid: number;
198 value?: CharacteristicValue;
199 ev?: boolean;
200 authData?: string;
201 remote?: boolean;
202 r?: boolean;
203}
204/**
205 * @group HAP Accessory Server
206 */
207export interface CharacteristicsWriteRequest {
208 characteristics: CharacteristicWrite[];
209 pid?: number;
210}
211/**
212 * @group HAP Accessory Server
213 */
214export interface PartialCharacteristicWriteDataValue {
215 value?: CharacteristicValue | null;
216 status: HAPStatus.SUCCESS;
217}
218/**
219 * @group HAP Accessory Server
220 */
221export interface PartialCharacteristicWriteError {
222 status: HAPStatus;
223 value?: undefined;
224}
225/**
226 * @group HAP Accessory Server
227 */
228export interface CharacteristicWriteDataValue extends PartialCharacteristicWriteDataValue {
229 aid: number;
230 iid: number;
231}
232/**
233 * @group HAP Accessory Server
234 */
235export interface CharacteristicWriteError extends PartialCharacteristicWriteError {
236 aid: number;
237 iid: number;
238}
239/**
240 * @group HAP Accessory Server
241 */
242export type PartialCharacteristicWriteData = PartialCharacteristicWriteDataValue | PartialCharacteristicWriteError;
243/**
244 * @group HAP Accessory Server
245 */
246export type CharacteristicWriteData = CharacteristicWriteDataValue | CharacteristicWriteError;
247/**
248 * @group HAP Accessory Server
249 */
250export interface CharacteristicsWriteResponse {
251 characteristics: CharacteristicWriteData[];
252}
253/**
254 * @group HAP Accessory Server
255 */
256export type PrepareWriteRequest = {
257 ttl: number;
258 pid: number;
259};
260/**
261 * @group HAP Accessory Server
262 */
263export declare const enum ResourceRequestType {
264 IMAGE = "image"
265}
266/**
267 * @group HAP Accessory Server
268 */
269export interface ResourceRequest {
270 aid?: number;
271 "image-height": number;
272 "image-width": number;
273 "reason"?: ResourceRequestReason;
274 "resource-type": ResourceRequestType;
275}
276//# sourceMappingURL=types.d.ts.map
\No newline at end of file