1 | import { Formats, Perms, Units } from "./lib/Characteristic";
|
2 | import { ResourceRequestReason } from "./lib/controller";
|
3 | import { HAPStatus } from "./lib/HAPServer";
|
4 |
|
5 |
|
6 |
|
7 | export type Nullable<T> = T | null;
|
8 |
|
9 |
|
10 |
|
11 | export type WithUUID<T> = T & {
|
12 | UUID: string;
|
13 | };
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 | export type PartialAllowingNull<T> = {
|
20 | [P in keyof T]?: T[P] | null;
|
21 | };
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 | export type ConstructorArgs<C> = C extends new (...args: infer A) => any ? A : never;
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | export type SessionIdentifier = string;
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | export type MacAddress = string;
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 | export type HAPPincode = string;
|
48 |
|
49 |
|
50 |
|
51 | export type InterfaceName = string;
|
52 |
|
53 |
|
54 |
|
55 | export type IPv4Address = string;
|
56 |
|
57 |
|
58 |
|
59 | export type IPv6Address = string;
|
60 |
|
61 |
|
62 |
|
63 | export type IPAddress = IPv4Address | IPv6Address;
|
64 |
|
65 |
|
66 |
|
67 | export type NodeCallback<T> = (err: Nullable<Error> | undefined, data?: T) => void;
|
68 |
|
69 |
|
70 |
|
71 | export type VoidCallback = (err?: Nullable<Error>) => void;
|
72 |
|
73 |
|
74 |
|
75 | export type PrimitiveTypes = string | number | boolean;
|
76 |
|
77 |
|
78 |
|
79 | export type CharacteristicValue = PrimitiveTypes | PrimitiveTypes[] | {
|
80 | [key: string]: PrimitiveTypes;
|
81 | };
|
82 |
|
83 |
|
84 |
|
85 | export 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 |
|
103 |
|
104 | export interface ServiceJsonObject {
|
105 | type: string;
|
106 | iid: number;
|
107 | characteristics: CharacteristicJsonObject[];
|
108 | hidden?: boolean;
|
109 | primary?: boolean;
|
110 | linked?: number[];
|
111 | }
|
112 |
|
113 |
|
114 |
|
115 | export interface AccessoryJsonObject {
|
116 | aid: number;
|
117 | services: ServiceJsonObject[];
|
118 | }
|
119 |
|
120 |
|
121 |
|
122 | export interface AccessoriesResponse {
|
123 | accessories: AccessoryJsonObject[];
|
124 | }
|
125 |
|
126 |
|
127 |
|
128 | export interface CharacteristicId {
|
129 | aid: number;
|
130 | iid: number;
|
131 | }
|
132 |
|
133 |
|
134 |
|
135 | export interface CharacteristicsReadRequest {
|
136 | ids: CharacteristicId[];
|
137 | includeMeta: boolean;
|
138 | includePerms: boolean;
|
139 | includeType: boolean;
|
140 | includeEvent: boolean;
|
141 | }
|
142 |
|
143 |
|
144 |
|
145 | export 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 |
|
160 |
|
161 | export interface PartialCharacteristicReadError {
|
162 | status: HAPStatus;
|
163 | }
|
164 |
|
165 |
|
166 |
|
167 | export interface CharacteristicReadDataValue extends PartialCharacteristicReadDataValue {
|
168 | aid: number;
|
169 | iid: number;
|
170 | }
|
171 |
|
172 |
|
173 |
|
174 | export interface CharacteristicReadError extends PartialCharacteristicReadError {
|
175 | aid: number;
|
176 | iid: number;
|
177 | }
|
178 |
|
179 |
|
180 |
|
181 | export type PartialCharacteristicReadData = PartialCharacteristicReadDataValue | PartialCharacteristicReadError;
|
182 |
|
183 |
|
184 |
|
185 | export type CharacteristicReadData = CharacteristicReadDataValue | CharacteristicReadError;
|
186 |
|
187 |
|
188 |
|
189 | export interface CharacteristicsReadResponse {
|
190 | characteristics: CharacteristicReadData[];
|
191 | }
|
192 |
|
193 |
|
194 |
|
195 | export 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 |
|
206 |
|
207 | export interface CharacteristicsWriteRequest {
|
208 | characteristics: CharacteristicWrite[];
|
209 | pid?: number;
|
210 | }
|
211 |
|
212 |
|
213 |
|
214 | export interface PartialCharacteristicWriteDataValue {
|
215 | value?: CharacteristicValue | null;
|
216 | status: HAPStatus.SUCCESS;
|
217 | }
|
218 |
|
219 |
|
220 |
|
221 | export interface PartialCharacteristicWriteError {
|
222 | status: HAPStatus;
|
223 | value?: undefined;
|
224 | }
|
225 |
|
226 |
|
227 |
|
228 | export interface CharacteristicWriteDataValue extends PartialCharacteristicWriteDataValue {
|
229 | aid: number;
|
230 | iid: number;
|
231 | }
|
232 |
|
233 |
|
234 |
|
235 | export interface CharacteristicWriteError extends PartialCharacteristicWriteError {
|
236 | aid: number;
|
237 | iid: number;
|
238 | }
|
239 |
|
240 |
|
241 |
|
242 | export type PartialCharacteristicWriteData = PartialCharacteristicWriteDataValue | PartialCharacteristicWriteError;
|
243 |
|
244 |
|
245 |
|
246 | export type CharacteristicWriteData = CharacteristicWriteDataValue | CharacteristicWriteError;
|
247 |
|
248 |
|
249 |
|
250 | export interface CharacteristicsWriteResponse {
|
251 | characteristics: CharacteristicWriteData[];
|
252 | }
|
253 |
|
254 |
|
255 |
|
256 | export type PrepareWriteRequest = {
|
257 | ttl: number;
|
258 | pid: number;
|
259 | };
|
260 |
|
261 |
|
262 |
|
263 | export declare const enum ResourceRequestType {
|
264 | IMAGE = "image"
|
265 | }
|
266 |
|
267 |
|
268 |
|
269 | export interface ResourceRequest {
|
270 | aid?: number;
|
271 | "image-height": number;
|
272 | "image-width": number;
|
273 | "reason"?: ResourceRequestReason;
|
274 | "resource-type": ResourceRequestType;
|
275 | }
|
276 |
|
\ | No newline at end of file |