@kohost/api-client 5.0.7 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{index-CjXs7rFc.d.cts → index-DGdGZN91.d.cts} +1 -10
- package/dist/cjs/index.d.cts +4 -10
- package/dist/cjs/models/index.cjs +0 -9
- package/dist/cjs/models/index.cjs.map +1 -1
- package/dist/cjs/models/index.d.cts +3 -9
- package/dist/cjs/models/property.cjs +0 -2
- package/dist/cjs/models/property.cjs.map +1 -1
- package/dist/cjs/models/space.cjs +0 -7
- package/dist/cjs/models/space.cjs.map +1 -1
- package/dist/cjs/models/user.cjs +0 -1
- package/dist/cjs/models/user.cjs.map +1 -1
- package/dist/cjs/schemas/index.cjs +0 -13
- package/dist/cjs/schemas/index.cjs.map +1 -1
- package/dist/cjs/schemas/index.d.cts +0 -3
- package/dist/cjs/schemas/property.cjs +1 -39
- package/dist/cjs/schemas/property.cjs.map +1 -1
- package/dist/cjs/schemas/property.d.cts +1 -39
- package/dist/cjs/schemas/space.cjs +0 -26
- package/dist/cjs/schemas/space.cjs.map +1 -1
- package/dist/cjs/schemas/space.d.cts +0 -26
- package/dist/cjs/schemas/ticket.cjs +0 -1
- package/dist/cjs/schemas/ticket.cjs.map +1 -1
- package/dist/cjs/schemas/ticket.d.cts +1 -1
- package/dist/cjs/schemas/user.cjs +0 -3
- package/dist/cjs/schemas/user.cjs.map +1 -1
- package/dist/cjs/schemas/user.d.cts +0 -3
- package/dist/cjs/validate.cjs +0 -15
- package/dist/cjs/validate.cjs.map +1 -1
- package/dist/cjs/validate.d.cts +1 -61
- package/dist/esm/{index-BLHzohDV.d.ts → index-BmUDCO4d.d.ts} +1 -10
- package/dist/esm/index.d.ts +4 -10
- package/dist/esm/models/index.d.ts +3 -9
- package/dist/esm/models/index.js +0 -6
- package/dist/esm/models/index.js.map +1 -1
- package/dist/esm/models/property.js +0 -2
- package/dist/esm/models/property.js.map +1 -1
- package/dist/esm/models/space.js +0 -7
- package/dist/esm/models/space.js.map +1 -1
- package/dist/esm/models/user.js +0 -1
- package/dist/esm/models/user.js.map +1 -1
- package/dist/esm/schemas/index.d.ts +0 -3
- package/dist/esm/schemas/index.js +2 -10
- package/dist/esm/schemas/index.js.map +1 -1
- package/dist/esm/schemas/property.d.ts +1 -39
- package/dist/esm/schemas/property.js +1 -39
- package/dist/esm/schemas/property.js.map +1 -1
- package/dist/esm/schemas/space.d.ts +0 -26
- package/dist/esm/schemas/space.js +0 -26
- package/dist/esm/schemas/space.js.map +1 -1
- package/dist/esm/schemas/ticket.d.ts +1 -1
- package/dist/esm/schemas/ticket.js +0 -1
- package/dist/esm/schemas/ticket.js.map +1 -1
- package/dist/esm/schemas/user.d.ts +0 -3
- package/dist/esm/schemas/user.js +0 -3
- package/dist/esm/schemas/user.js.map +1 -1
- package/dist/esm/validate.d.ts +155 -215
- package/dist/esm/validate.js +0 -12
- package/dist/esm/validate.js.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/models/deviceRouter.cjs +0 -52
- package/dist/cjs/models/deviceRouter.cjs.map +0 -1
- package/dist/cjs/models/deviceRouter.d.cts +0 -23
- package/dist/cjs/models/room.cjs +0 -169
- package/dist/cjs/models/room.cjs.map +0 -1
- package/dist/cjs/models/room.d.cts +0 -48
- package/dist/cjs/models/scene.cjs +0 -54
- package/dist/cjs/models/scene.cjs.map +0 -1
- package/dist/cjs/models/scene.d.cts +0 -23
- package/dist/cjs/schemas/deviceRouter.cjs +0 -57
- package/dist/cjs/schemas/deviceRouter.cjs.map +0 -1
- package/dist/cjs/schemas/deviceRouter.d.cts +0 -46
- package/dist/cjs/schemas/room.cjs +0 -317
- package/dist/cjs/schemas/room.cjs.map +0 -1
- package/dist/cjs/schemas/room.d.cts +0 -223
- package/dist/cjs/schemas/scene.cjs +0 -174
- package/dist/cjs/schemas/scene.cjs.map +0 -1
- package/dist/cjs/schemas/scene.d.cts +0 -163
- package/dist/esm/models/deviceRouter.d.ts +0 -23
- package/dist/esm/models/deviceRouter.js +0 -32
- package/dist/esm/models/deviceRouter.js.map +0 -1
- package/dist/esm/models/room.d.ts +0 -48
- package/dist/esm/models/room.js +0 -147
- package/dist/esm/models/room.js.map +0 -1
- package/dist/esm/models/scene.d.ts +0 -23
- package/dist/esm/models/scene.js +0 -32
- package/dist/esm/models/scene.js.map +0 -1
- package/dist/esm/schemas/deviceRouter.d.ts +0 -46
- package/dist/esm/schemas/deviceRouter.js +0 -34
- package/dist/esm/schemas/deviceRouter.js.map +0 -1
- package/dist/esm/schemas/room.d.ts +0 -223
- package/dist/esm/schemas/room.js +0 -292
- package/dist/esm/schemas/room.js.map +0 -1
- package/dist/esm/schemas/scene.d.ts +0 -163
- package/dist/esm/schemas/scene.js +0 -151
- package/dist/esm/schemas/scene.js.map +0 -1
|
@@ -1,317 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
var __export = (target, all) => {
|
|
6
|
-
for (var name in all)
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
var room_exports = {};
|
|
19
|
-
__export(room_exports, {
|
|
20
|
-
getters: () => getters,
|
|
21
|
-
roomSchema: () => roomSchema,
|
|
22
|
-
statics: () => statics
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(room_exports);
|
|
25
|
-
const roomSchema = {
|
|
26
|
-
$schema: "http://json-schema.org/draft-07/schema",
|
|
27
|
-
$id: "room.json",
|
|
28
|
-
title: "Room",
|
|
29
|
-
description: "A room represents a physical space of controllable IoT devices",
|
|
30
|
-
type: "object",
|
|
31
|
-
required: [
|
|
32
|
-
"id",
|
|
33
|
-
"name",
|
|
34
|
-
"dimmers",
|
|
35
|
-
"thermostats",
|
|
36
|
-
"switches",
|
|
37
|
-
"windowCoverings",
|
|
38
|
-
"courtesy",
|
|
39
|
-
"cameras",
|
|
40
|
-
"mediaSources",
|
|
41
|
-
"motionSensors",
|
|
42
|
-
"alarms"
|
|
43
|
-
],
|
|
44
|
-
properties: {
|
|
45
|
-
id: {
|
|
46
|
-
$ref: "definitions.json#/definitions/id"
|
|
47
|
-
},
|
|
48
|
-
type: {
|
|
49
|
-
type: "string",
|
|
50
|
-
enum: ["room"],
|
|
51
|
-
default: "room"
|
|
52
|
-
},
|
|
53
|
-
name: {
|
|
54
|
-
type: "string"
|
|
55
|
-
},
|
|
56
|
-
floor: {
|
|
57
|
-
type: "string"
|
|
58
|
-
},
|
|
59
|
-
dimmers: {
|
|
60
|
-
type: "array",
|
|
61
|
-
default: [],
|
|
62
|
-
items: {
|
|
63
|
-
$ref: "dimmer.json"
|
|
64
|
-
}
|
|
65
|
-
},
|
|
66
|
-
switches: {
|
|
67
|
-
type: "array",
|
|
68
|
-
default: [],
|
|
69
|
-
items: {
|
|
70
|
-
$ref: "switch.json"
|
|
71
|
-
}
|
|
72
|
-
},
|
|
73
|
-
thermostats: {
|
|
74
|
-
type: "array",
|
|
75
|
-
default: [],
|
|
76
|
-
items: {
|
|
77
|
-
$ref: "thermostat.json"
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
locks: {
|
|
81
|
-
type: "array",
|
|
82
|
-
default: [],
|
|
83
|
-
items: {
|
|
84
|
-
$ref: "lock.json"
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
windowCoverings: {
|
|
88
|
-
type: "array",
|
|
89
|
-
default: [],
|
|
90
|
-
items: {
|
|
91
|
-
$ref: "windowCovering.json"
|
|
92
|
-
}
|
|
93
|
-
},
|
|
94
|
-
courtesy: {
|
|
95
|
-
type: "array",
|
|
96
|
-
default: [],
|
|
97
|
-
items: {
|
|
98
|
-
$ref: "courtesy.json"
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
cameras: {
|
|
102
|
-
type: "array",
|
|
103
|
-
default: [],
|
|
104
|
-
items: {
|
|
105
|
-
$ref: "camera.json"
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
mediaSources: {
|
|
109
|
-
type: "array",
|
|
110
|
-
default: [],
|
|
111
|
-
items: {
|
|
112
|
-
$ref: "mediaSource.json"
|
|
113
|
-
}
|
|
114
|
-
},
|
|
115
|
-
motionSensors: {
|
|
116
|
-
type: "array",
|
|
117
|
-
default: [],
|
|
118
|
-
items: {
|
|
119
|
-
$ref: "motionSensor.json"
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
alarms: {
|
|
123
|
-
type: "array",
|
|
124
|
-
default: [],
|
|
125
|
-
items: {
|
|
126
|
-
$ref: "alarm.json"
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
occupiedAt: {
|
|
130
|
-
$ref: "definitions.json#/definitions/date"
|
|
131
|
-
},
|
|
132
|
-
createdAt: {
|
|
133
|
-
$ref: "definitions.json#/definitions/date"
|
|
134
|
-
},
|
|
135
|
-
updatedAt: {
|
|
136
|
-
$ref: "definitions.json#/definitions/date"
|
|
137
|
-
},
|
|
138
|
-
deletedAt: {
|
|
139
|
-
$ref: "definitions.json#/definitions/date"
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
additionalProperties: false
|
|
143
|
-
};
|
|
144
|
-
const getters = {
|
|
145
|
-
/**
|
|
146
|
-
* Check if the room has any dimmers
|
|
147
|
-
* @returns {boolean} True if the room has dimmers, false otherwise
|
|
148
|
-
*/
|
|
149
|
-
hasDimmer() {
|
|
150
|
-
return this.dimmers?.length > 0;
|
|
151
|
-
},
|
|
152
|
-
/**
|
|
153
|
-
* Check if the room has any switches
|
|
154
|
-
* @returns {boolean} True if the room has switches, false otherwise
|
|
155
|
-
*/
|
|
156
|
-
hasSwitch() {
|
|
157
|
-
return this.switches?.length > 0;
|
|
158
|
-
},
|
|
159
|
-
/**
|
|
160
|
-
* Check if the room has any window coverings
|
|
161
|
-
* @returns {boolean} True if the room has window coverings, false otherwise
|
|
162
|
-
*/
|
|
163
|
-
hasWindowCovering() {
|
|
164
|
-
return this.windowCoverings?.length > 0;
|
|
165
|
-
},
|
|
166
|
-
/**
|
|
167
|
-
* Alias for hasWindowCovering
|
|
168
|
-
* @returns {boolean} True if the room has window coverings/shades, false otherwise
|
|
169
|
-
*/
|
|
170
|
-
hasShade() {
|
|
171
|
-
return this.hasWindowCovering;
|
|
172
|
-
},
|
|
173
|
-
/**
|
|
174
|
-
* Check if the room has any thermostats
|
|
175
|
-
* @returns {boolean} True if the room has thermostats, false otherwise
|
|
176
|
-
*/
|
|
177
|
-
hasThermostat() {
|
|
178
|
-
return this.thermostats?.length > 0;
|
|
179
|
-
},
|
|
180
|
-
/**
|
|
181
|
-
* Alias for hasThermostat
|
|
182
|
-
* @returns {boolean} True if the room has climate control, false otherwise
|
|
183
|
-
*/
|
|
184
|
-
hasClimate() {
|
|
185
|
-
return this.hasThermostat;
|
|
186
|
-
},
|
|
187
|
-
/**
|
|
188
|
-
* Check if the room has any locks
|
|
189
|
-
* @returns {boolean} True if the room has locks, false otherwise
|
|
190
|
-
*/
|
|
191
|
-
hasLock() {
|
|
192
|
-
return this.locks?.length > 0;
|
|
193
|
-
},
|
|
194
|
-
/**
|
|
195
|
-
* Check if the room has any courtesy devices
|
|
196
|
-
* @returns {boolean} True if the room has courtesy devices, false otherwise
|
|
197
|
-
*/
|
|
198
|
-
hasCourtesy() {
|
|
199
|
-
return this.courtesy?.length > 0;
|
|
200
|
-
},
|
|
201
|
-
/**
|
|
202
|
-
* Check if the room has any cameras
|
|
203
|
-
* @returns {boolean} True if the room has cameras, false otherwise
|
|
204
|
-
*/
|
|
205
|
-
hasCamera() {
|
|
206
|
-
return this.cameras?.length > 0;
|
|
207
|
-
},
|
|
208
|
-
/**
|
|
209
|
-
* Check if the room has any media sources
|
|
210
|
-
* @returns {boolean} True if the room has media sources, false otherwise
|
|
211
|
-
*/
|
|
212
|
-
hasMedia() {
|
|
213
|
-
return this.mediaSources?.length > 0;
|
|
214
|
-
},
|
|
215
|
-
/**
|
|
216
|
-
* Check if the room has any lighting devices (dimmers or switches marked as lights/fans)
|
|
217
|
-
* @returns {boolean} True if the room has lighting devices, false otherwise
|
|
218
|
-
*/
|
|
219
|
-
hasLight() {
|
|
220
|
-
const hasDiscriminatorLight = this.switches?.some(
|
|
221
|
-
(sw) => {
|
|
222
|
-
return sw.discriminator === "light" || sw.discriminator === "fan";
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
return this.hasDimmer || hasDiscriminatorLight;
|
|
226
|
-
},
|
|
227
|
-
hasAlarm() {
|
|
228
|
-
return this.alarms?.length > 0;
|
|
229
|
-
},
|
|
230
|
-
/**
|
|
231
|
-
* Check if the room is currently occupied (within the last 60 minutes)
|
|
232
|
-
* @returns {boolean} True if the room was occupied within the last hour, false otherwise
|
|
233
|
-
*/
|
|
234
|
-
occupied() {
|
|
235
|
-
if (!this.occupiedAt) return false;
|
|
236
|
-
const now = /* @__PURE__ */ new Date();
|
|
237
|
-
const lastOccupied = new Date(this.occupiedAt);
|
|
238
|
-
const diff = now.getTime() - lastOccupied.getTime();
|
|
239
|
-
return diff < 60 * 60 * 1e3;
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
const statics = {
|
|
243
|
-
/**
|
|
244
|
-
* Get the device path for a given device type
|
|
245
|
-
* @param {string} type - The device type
|
|
246
|
-
* @returns {"mediaSources" | "courtesy" | "dimmers" | "thermostats" | "locks" | "windowCoverings" | "switches" | "cameras" | "motionSensors" | "alarms"} The device path
|
|
247
|
-
* @throws {Error} If the device type is invalid
|
|
248
|
-
*/
|
|
249
|
-
getDevicePath(type) {
|
|
250
|
-
switch (type) {
|
|
251
|
-
case "tv":
|
|
252
|
-
case "dvr":
|
|
253
|
-
case "appleTv":
|
|
254
|
-
case "discPlayer":
|
|
255
|
-
case "mediaPlayer":
|
|
256
|
-
case "uncontrolledDevice":
|
|
257
|
-
case "mediaSource":
|
|
258
|
-
return "mediaSources";
|
|
259
|
-
case "courtesy":
|
|
260
|
-
return "courtesy";
|
|
261
|
-
case "switch":
|
|
262
|
-
return "switches";
|
|
263
|
-
case "dimmer":
|
|
264
|
-
return "dimmers";
|
|
265
|
-
case "thermostat":
|
|
266
|
-
return "thermostats";
|
|
267
|
-
case "lock":
|
|
268
|
-
return "locks";
|
|
269
|
-
case "windowCovering":
|
|
270
|
-
return "windowCoverings";
|
|
271
|
-
case "camera":
|
|
272
|
-
return "cameras";
|
|
273
|
-
case "motionSensor":
|
|
274
|
-
return "motionSensors";
|
|
275
|
-
case "alarm":
|
|
276
|
-
return "alarms";
|
|
277
|
-
default:
|
|
278
|
-
throw new Error("Invalid device type:" + type);
|
|
279
|
-
}
|
|
280
|
-
},
|
|
281
|
-
/**
|
|
282
|
-
*
|
|
283
|
-
* @param {string} path
|
|
284
|
-
* @returns
|
|
285
|
-
*/
|
|
286
|
-
getDeviceTypeFromPath(path) {
|
|
287
|
-
const validPaths = [
|
|
288
|
-
"dimmers",
|
|
289
|
-
"switches",
|
|
290
|
-
"thermostats",
|
|
291
|
-
"locks",
|
|
292
|
-
"windowCoverings",
|
|
293
|
-
"courtesy",
|
|
294
|
-
"cameras",
|
|
295
|
-
"mediaSources",
|
|
296
|
-
"motionSensors",
|
|
297
|
-
"alarms"
|
|
298
|
-
];
|
|
299
|
-
if (!validPaths.includes(path))
|
|
300
|
-
throw new Error("Invalid device path:" + path);
|
|
301
|
-
switch (path) {
|
|
302
|
-
case "courtesy":
|
|
303
|
-
return path;
|
|
304
|
-
case "switches":
|
|
305
|
-
return "switch";
|
|
306
|
-
default:
|
|
307
|
-
return path.slice(0, -1);
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
312
|
-
0 && (module.exports = {
|
|
313
|
-
getters,
|
|
314
|
-
roomSchema,
|
|
315
|
-
statics
|
|
316
|
-
});
|
|
317
|
-
//# sourceMappingURL=room.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../.generated/schemas/room.ts"],"sourcesContent":["import defs, { ISODateString } from \"./definitions\";\nimport type { FromSchema } from \"json-schema-to-ts\";\nimport type { dimmerSchema } from \"./dimmer\";\nimport type { switchSchema } from \"./switch\";\nimport type { thermostatSchema } from \"./thermostat\";\nimport type { lockSchema } from \"./lock\";\nimport type { windowCoveringSchema } from \"./windowCovering\";\nimport type { courtesySchema } from \"./courtesy\";\nimport type { cameraSchema } from \"./camera\";\nimport type { mediaSourceSchema } from \"./mediaSource\";\nimport type { motionSensorSchema } from \"./motionSensor\";\nimport type { alarmSchema } from \"./alarm\";\n\nexport const roomSchema = {\n $schema: \"http://json-schema.org/draft-07/schema\",\n $id: \"room.json\",\n title: \"Room\",\n description: \"A room represents a physical space of controllable IoT devices\",\n type: \"object\",\n required: [\n \"id\",\n \"name\",\n \"dimmers\",\n \"thermostats\",\n \"switches\",\n \"windowCoverings\",\n \"courtesy\",\n \"cameras\",\n \"mediaSources\",\n \"motionSensors\",\n \"alarms\",\n ],\n properties: {\n id: {\n $ref: \"definitions.json#/definitions/id\",\n },\n type: {\n type: \"string\",\n enum: [\"room\"],\n default: \"room\",\n },\n name: {\n type: \"string\",\n },\n floor: {\n type: \"string\",\n },\n dimmers: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"dimmer.json\",\n },\n },\n switches: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"switch.json\",\n },\n },\n thermostats: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"thermostat.json\",\n },\n },\n locks: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"lock.json\",\n },\n },\n windowCoverings: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"windowCovering.json\",\n },\n },\n courtesy: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"courtesy.json\",\n },\n },\n cameras: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"camera.json\",\n },\n },\n mediaSources: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"mediaSource.json\",\n },\n },\n motionSensors: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"motionSensor.json\",\n },\n },\n alarms: {\n type: \"array\",\n default: [],\n items: {\n $ref: \"alarm.json\",\n },\n },\n occupiedAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n createdAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n updatedAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n deletedAt: {\n $ref: \"definitions.json#/definitions/date\",\n },\n },\n additionalProperties: false,\n} as const;\n\nexport type RoomSchema = FromSchema<\n typeof roomSchema,\n {\n references: [\n typeof defs,\n typeof dimmerSchema,\n typeof switchSchema,\n typeof thermostatSchema,\n typeof lockSchema,\n typeof windowCoveringSchema,\n typeof courtesySchema,\n typeof cameraSchema,\n typeof mediaSourceSchema,\n typeof motionSensorSchema,\n typeof alarmSchema,\n ];\n deserialize: [\n {\n pattern: {\n format: \"date-time\";\n };\n output: Date | ISODateString;\n },\n ];\n }\n>;\n\nexport const getters = {\n /**\n * Check if the room has any dimmers\n * @returns {boolean} True if the room has dimmers, false otherwise\n */\n hasDimmer() {\n return this.dimmers?.length > 0;\n },\n\n /**\n * Check if the room has any switches\n * @returns {boolean} True if the room has switches, false otherwise\n */\n hasSwitch() {\n return this.switches?.length > 0;\n },\n\n /**\n * Check if the room has any window coverings\n * @returns {boolean} True if the room has window coverings, false otherwise\n */\n hasWindowCovering() {\n return this.windowCoverings?.length > 0;\n },\n\n /**\n * Alias for hasWindowCovering\n * @returns {boolean} True if the room has window coverings/shades, false otherwise\n */\n hasShade() {\n return this.hasWindowCovering;\n },\n\n /**\n * Check if the room has any thermostats\n * @returns {boolean} True if the room has thermostats, false otherwise\n */\n hasThermostat() {\n return this.thermostats?.length > 0;\n },\n\n /**\n * Alias for hasThermostat\n * @returns {boolean} True if the room has climate control, false otherwise\n */\n hasClimate() {\n return this.hasThermostat;\n },\n\n /**\n * Check if the room has any locks\n * @returns {boolean} True if the room has locks, false otherwise\n */\n hasLock() {\n return this.locks?.length > 0;\n },\n\n /**\n * Check if the room has any courtesy devices\n * @returns {boolean} True if the room has courtesy devices, false otherwise\n */\n hasCourtesy() {\n return this.courtesy?.length > 0;\n },\n\n /**\n * Check if the room has any cameras\n * @returns {boolean} True if the room has cameras, false otherwise\n */\n hasCamera() {\n return this.cameras?.length > 0;\n },\n\n /**\n * Check if the room has any media sources\n * @returns {boolean} True if the room has media sources, false otherwise\n */\n hasMedia() {\n return this.mediaSources?.length > 0;\n },\n\n /**\n * Check if the room has any lighting devices (dimmers or switches marked as lights/fans)\n * @returns {boolean} True if the room has lighting devices, false otherwise\n */\n hasLight() {\n const hasDiscriminatorLight = this.switches?.some(\n (sw: { discriminator?: string }) => {\n return sw.discriminator === \"light\" || sw.discriminator === \"fan\";\n }\n );\n return this.hasDimmer || hasDiscriminatorLight;\n },\n\n hasAlarm() {\n return this.alarms?.length > 0;\n },\n\n /**\n * Check if the room is currently occupied (within the last 60 minutes)\n * @returns {boolean} True if the room was occupied within the last hour, false otherwise\n */\n occupied() {\n if (!this.occupiedAt) return false;\n const now = new Date();\n const lastOccupied = new Date(this.occupiedAt as string | Date);\n const diff = now.getTime() - lastOccupied.getTime();\n return diff < 60 * 60 * 1000;\n },\n};\n\nexport const statics = {\n /**\n * Get the device path for a given device type\n * @param {string} type - The device type\n * @returns {\"mediaSources\" | \"courtesy\" | \"dimmers\" | \"thermostats\" | \"locks\" | \"windowCoverings\" | \"switches\" | \"cameras\" | \"motionSensors\" | \"alarms\"} The device path\n * @throws {Error} If the device type is invalid\n */\n getDevicePath(type: string) {\n switch (type) {\n case \"tv\":\n case \"dvr\":\n case \"appleTv\":\n case \"discPlayer\":\n case \"mediaPlayer\":\n case \"uncontrolledDevice\":\n case \"mediaSource\":\n return \"mediaSources\";\n case \"courtesy\":\n return \"courtesy\";\n case \"switch\":\n return \"switches\";\n case \"dimmer\":\n return \"dimmers\";\n case \"thermostat\":\n return \"thermostats\";\n case \"lock\":\n return \"locks\";\n case \"windowCovering\":\n return \"windowCoverings\";\n case \"camera\":\n return \"cameras\";\n case \"motionSensor\":\n return \"motionSensors\";\n case \"alarm\":\n return \"alarms\";\n\n default:\n throw new Error(\"Invalid device type:\" + type);\n }\n },\n /**\n *\n * @param {string} path\n * @returns\n */\n getDeviceTypeFromPath(path: string) {\n const validPaths = [\n \"dimmers\",\n \"switches\",\n \"thermostats\",\n \"locks\",\n \"windowCoverings\",\n \"courtesy\",\n \"cameras\",\n \"mediaSources\",\n \"motionSensors\",\n \"alarms\",\n ];\n if (!validPaths.includes(path))\n throw new Error(\"Invalid device path:\" + path);\n switch (path) {\n case \"courtesy\":\n return path;\n case \"switches\":\n return \"switch\";\n default:\n return path.slice(0, -1);\n }\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,aAAa;AAAA,EACxB,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,aAAa;AAAA,EACb,MAAM;AAAA,EACN,UAAU;AAAA,IACR;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EACA,YAAY;AAAA,IACV,IAAI;AAAA,MACF,MAAM;AAAA,IACR;A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C/C,YAAQ,MAAM;AAAA,MACZ,KAAK;AACH,eAAO;AAAA,MACT,KAAK;AACH,eAAO;AAAA,MACT;AACE,eAAO,KAAK,MAAM,GAAG,EAAE;AAAA,IAC3B;AAAA,EACF;AACF;","names":[]}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import defs, { ISODateString } from './definitions.cjs';
|
|
2
|
-
import { FromSchema } from 'json-schema-to-ts';
|
|
3
|
-
import { dimmerSchema } from './dimmer.cjs';
|
|
4
|
-
import { switchSchema } from './switch.cjs';
|
|
5
|
-
import { thermostatSchema } from './thermostat.cjs';
|
|
6
|
-
import { lockSchema } from './lock.cjs';
|
|
7
|
-
import { windowCoveringSchema } from './windowCovering.cjs';
|
|
8
|
-
import { courtesySchema } from './courtesy.cjs';
|
|
9
|
-
import { cameraSchema } from './camera.cjs';
|
|
10
|
-
import { mediaSourceSchema } from './mediaSource.cjs';
|
|
11
|
-
import { motionSensorSchema } from './motionSensor.cjs';
|
|
12
|
-
import { alarmSchema } from './alarm.cjs';
|
|
13
|
-
|
|
14
|
-
declare const roomSchema: {
|
|
15
|
-
readonly $schema: "http://json-schema.org/draft-07/schema";
|
|
16
|
-
readonly $id: "room.json";
|
|
17
|
-
readonly title: "Room";
|
|
18
|
-
readonly description: "A room represents a physical space of controllable IoT devices";
|
|
19
|
-
readonly type: "object";
|
|
20
|
-
readonly required: readonly ["id", "name", "dimmers", "thermostats", "switches", "windowCoverings", "courtesy", "cameras", "mediaSources", "motionSensors", "alarms"];
|
|
21
|
-
readonly properties: {
|
|
22
|
-
readonly id: {
|
|
23
|
-
readonly $ref: "definitions.json#/definitions/id";
|
|
24
|
-
};
|
|
25
|
-
readonly type: {
|
|
26
|
-
readonly type: "string";
|
|
27
|
-
readonly enum: readonly ["room"];
|
|
28
|
-
readonly default: "room";
|
|
29
|
-
};
|
|
30
|
-
readonly name: {
|
|
31
|
-
readonly type: "string";
|
|
32
|
-
};
|
|
33
|
-
readonly floor: {
|
|
34
|
-
readonly type: "string";
|
|
35
|
-
};
|
|
36
|
-
readonly dimmers: {
|
|
37
|
-
readonly type: "array";
|
|
38
|
-
readonly default: readonly [];
|
|
39
|
-
readonly items: {
|
|
40
|
-
readonly $ref: "dimmer.json";
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
readonly switches: {
|
|
44
|
-
readonly type: "array";
|
|
45
|
-
readonly default: readonly [];
|
|
46
|
-
readonly items: {
|
|
47
|
-
readonly $ref: "switch.json";
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
readonly thermostats: {
|
|
51
|
-
readonly type: "array";
|
|
52
|
-
readonly default: readonly [];
|
|
53
|
-
readonly items: {
|
|
54
|
-
readonly $ref: "thermostat.json";
|
|
55
|
-
};
|
|
56
|
-
};
|
|
57
|
-
readonly locks: {
|
|
58
|
-
readonly type: "array";
|
|
59
|
-
readonly default: readonly [];
|
|
60
|
-
readonly items: {
|
|
61
|
-
readonly $ref: "lock.json";
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
readonly windowCoverings: {
|
|
65
|
-
readonly type: "array";
|
|
66
|
-
readonly default: readonly [];
|
|
67
|
-
readonly items: {
|
|
68
|
-
readonly $ref: "windowCovering.json";
|
|
69
|
-
};
|
|
70
|
-
};
|
|
71
|
-
readonly courtesy: {
|
|
72
|
-
readonly type: "array";
|
|
73
|
-
readonly default: readonly [];
|
|
74
|
-
readonly items: {
|
|
75
|
-
readonly $ref: "courtesy.json";
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
readonly cameras: {
|
|
79
|
-
readonly type: "array";
|
|
80
|
-
readonly default: readonly [];
|
|
81
|
-
readonly items: {
|
|
82
|
-
readonly $ref: "camera.json";
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
readonly mediaSources: {
|
|
86
|
-
readonly type: "array";
|
|
87
|
-
readonly default: readonly [];
|
|
88
|
-
readonly items: {
|
|
89
|
-
readonly $ref: "mediaSource.json";
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
readonly motionSensors: {
|
|
93
|
-
readonly type: "array";
|
|
94
|
-
readonly default: readonly [];
|
|
95
|
-
readonly items: {
|
|
96
|
-
readonly $ref: "motionSensor.json";
|
|
97
|
-
};
|
|
98
|
-
};
|
|
99
|
-
readonly alarms: {
|
|
100
|
-
readonly type: "array";
|
|
101
|
-
readonly default: readonly [];
|
|
102
|
-
readonly items: {
|
|
103
|
-
readonly $ref: "alarm.json";
|
|
104
|
-
};
|
|
105
|
-
};
|
|
106
|
-
readonly occupiedAt: {
|
|
107
|
-
readonly $ref: "definitions.json#/definitions/date";
|
|
108
|
-
};
|
|
109
|
-
readonly createdAt: {
|
|
110
|
-
readonly $ref: "definitions.json#/definitions/date";
|
|
111
|
-
};
|
|
112
|
-
readonly updatedAt: {
|
|
113
|
-
readonly $ref: "definitions.json#/definitions/date";
|
|
114
|
-
};
|
|
115
|
-
readonly deletedAt: {
|
|
116
|
-
readonly $ref: "definitions.json#/definitions/date";
|
|
117
|
-
};
|
|
118
|
-
};
|
|
119
|
-
readonly additionalProperties: false;
|
|
120
|
-
};
|
|
121
|
-
type RoomSchema = FromSchema<typeof roomSchema, {
|
|
122
|
-
references: [
|
|
123
|
-
typeof defs,
|
|
124
|
-
typeof dimmerSchema,
|
|
125
|
-
typeof switchSchema,
|
|
126
|
-
typeof thermostatSchema,
|
|
127
|
-
typeof lockSchema,
|
|
128
|
-
typeof windowCoveringSchema,
|
|
129
|
-
typeof courtesySchema,
|
|
130
|
-
typeof cameraSchema,
|
|
131
|
-
typeof mediaSourceSchema,
|
|
132
|
-
typeof motionSensorSchema,
|
|
133
|
-
typeof alarmSchema
|
|
134
|
-
];
|
|
135
|
-
deserialize: [
|
|
136
|
-
{
|
|
137
|
-
pattern: {
|
|
138
|
-
format: "date-time";
|
|
139
|
-
};
|
|
140
|
-
output: Date | ISODateString;
|
|
141
|
-
}
|
|
142
|
-
];
|
|
143
|
-
}>;
|
|
144
|
-
declare const getters: {
|
|
145
|
-
/**
|
|
146
|
-
* Check if the room has any dimmers
|
|
147
|
-
* @returns {boolean} True if the room has dimmers, false otherwise
|
|
148
|
-
*/
|
|
149
|
-
hasDimmer(): boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Check if the room has any switches
|
|
152
|
-
* @returns {boolean} True if the room has switches, false otherwise
|
|
153
|
-
*/
|
|
154
|
-
hasSwitch(): boolean;
|
|
155
|
-
/**
|
|
156
|
-
* Check if the room has any window coverings
|
|
157
|
-
* @returns {boolean} True if the room has window coverings, false otherwise
|
|
158
|
-
*/
|
|
159
|
-
hasWindowCovering(): boolean;
|
|
160
|
-
/**
|
|
161
|
-
* Alias for hasWindowCovering
|
|
162
|
-
* @returns {boolean} True if the room has window coverings/shades, false otherwise
|
|
163
|
-
*/
|
|
164
|
-
hasShade(): any;
|
|
165
|
-
/**
|
|
166
|
-
* Check if the room has any thermostats
|
|
167
|
-
* @returns {boolean} True if the room has thermostats, false otherwise
|
|
168
|
-
*/
|
|
169
|
-
hasThermostat(): boolean;
|
|
170
|
-
/**
|
|
171
|
-
* Alias for hasThermostat
|
|
172
|
-
* @returns {boolean} True if the room has climate control, false otherwise
|
|
173
|
-
*/
|
|
174
|
-
hasClimate(): any;
|
|
175
|
-
/**
|
|
176
|
-
* Check if the room has any locks
|
|
177
|
-
* @returns {boolean} True if the room has locks, false otherwise
|
|
178
|
-
*/
|
|
179
|
-
hasLock(): boolean;
|
|
180
|
-
/**
|
|
181
|
-
* Check if the room has any courtesy devices
|
|
182
|
-
* @returns {boolean} True if the room has courtesy devices, false otherwise
|
|
183
|
-
*/
|
|
184
|
-
hasCourtesy(): boolean;
|
|
185
|
-
/**
|
|
186
|
-
* Check if the room has any cameras
|
|
187
|
-
* @returns {boolean} True if the room has cameras, false otherwise
|
|
188
|
-
*/
|
|
189
|
-
hasCamera(): boolean;
|
|
190
|
-
/**
|
|
191
|
-
* Check if the room has any media sources
|
|
192
|
-
* @returns {boolean} True if the room has media sources, false otherwise
|
|
193
|
-
*/
|
|
194
|
-
hasMedia(): boolean;
|
|
195
|
-
/**
|
|
196
|
-
* Check if the room has any lighting devices (dimmers or switches marked as lights/fans)
|
|
197
|
-
* @returns {boolean} True if the room has lighting devices, false otherwise
|
|
198
|
-
*/
|
|
199
|
-
hasLight(): any;
|
|
200
|
-
hasAlarm(): boolean;
|
|
201
|
-
/**
|
|
202
|
-
* Check if the room is currently occupied (within the last 60 minutes)
|
|
203
|
-
* @returns {boolean} True if the room was occupied within the last hour, false otherwise
|
|
204
|
-
*/
|
|
205
|
-
occupied(): boolean;
|
|
206
|
-
};
|
|
207
|
-
declare const statics: {
|
|
208
|
-
/**
|
|
209
|
-
* Get the device path for a given device type
|
|
210
|
-
* @param {string} type - The device type
|
|
211
|
-
* @returns {"mediaSources" | "courtesy" | "dimmers" | "thermostats" | "locks" | "windowCoverings" | "switches" | "cameras" | "motionSensors" | "alarms"} The device path
|
|
212
|
-
* @throws {Error} If the device type is invalid
|
|
213
|
-
*/
|
|
214
|
-
getDevicePath(type: string): "courtesy" | "dimmers" | "thermostats" | "switches" | "windowCoverings" | "cameras" | "mediaSources" | "motionSensors" | "alarms" | "locks";
|
|
215
|
-
/**
|
|
216
|
-
*
|
|
217
|
-
* @param {string} path
|
|
218
|
-
* @returns
|
|
219
|
-
*/
|
|
220
|
-
getDeviceTypeFromPath(path: string): string;
|
|
221
|
-
};
|
|
222
|
-
|
|
223
|
-
export { type RoomSchema, getters, roomSchema, statics };
|