@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.
Files changed (95) hide show
  1. package/dist/cjs/{index-CjXs7rFc.d.cts → index-DGdGZN91.d.cts} +1 -10
  2. package/dist/cjs/index.d.cts +4 -10
  3. package/dist/cjs/models/index.cjs +0 -9
  4. package/dist/cjs/models/index.cjs.map +1 -1
  5. package/dist/cjs/models/index.d.cts +3 -9
  6. package/dist/cjs/models/property.cjs +0 -2
  7. package/dist/cjs/models/property.cjs.map +1 -1
  8. package/dist/cjs/models/space.cjs +0 -7
  9. package/dist/cjs/models/space.cjs.map +1 -1
  10. package/dist/cjs/models/user.cjs +0 -1
  11. package/dist/cjs/models/user.cjs.map +1 -1
  12. package/dist/cjs/schemas/index.cjs +0 -13
  13. package/dist/cjs/schemas/index.cjs.map +1 -1
  14. package/dist/cjs/schemas/index.d.cts +0 -3
  15. package/dist/cjs/schemas/property.cjs +1 -39
  16. package/dist/cjs/schemas/property.cjs.map +1 -1
  17. package/dist/cjs/schemas/property.d.cts +1 -39
  18. package/dist/cjs/schemas/space.cjs +0 -26
  19. package/dist/cjs/schemas/space.cjs.map +1 -1
  20. package/dist/cjs/schemas/space.d.cts +0 -26
  21. package/dist/cjs/schemas/ticket.cjs +0 -1
  22. package/dist/cjs/schemas/ticket.cjs.map +1 -1
  23. package/dist/cjs/schemas/ticket.d.cts +1 -1
  24. package/dist/cjs/schemas/user.cjs +0 -3
  25. package/dist/cjs/schemas/user.cjs.map +1 -1
  26. package/dist/cjs/schemas/user.d.cts +0 -3
  27. package/dist/cjs/validate.cjs +0 -15
  28. package/dist/cjs/validate.cjs.map +1 -1
  29. package/dist/cjs/validate.d.cts +1 -61
  30. package/dist/esm/{index-BLHzohDV.d.ts → index-BmUDCO4d.d.ts} +1 -10
  31. package/dist/esm/index.d.ts +4 -10
  32. package/dist/esm/models/index.d.ts +3 -9
  33. package/dist/esm/models/index.js +0 -6
  34. package/dist/esm/models/index.js.map +1 -1
  35. package/dist/esm/models/property.js +0 -2
  36. package/dist/esm/models/property.js.map +1 -1
  37. package/dist/esm/models/space.js +0 -7
  38. package/dist/esm/models/space.js.map +1 -1
  39. package/dist/esm/models/user.js +0 -1
  40. package/dist/esm/models/user.js.map +1 -1
  41. package/dist/esm/schemas/index.d.ts +0 -3
  42. package/dist/esm/schemas/index.js +2 -10
  43. package/dist/esm/schemas/index.js.map +1 -1
  44. package/dist/esm/schemas/property.d.ts +1 -39
  45. package/dist/esm/schemas/property.js +1 -39
  46. package/dist/esm/schemas/property.js.map +1 -1
  47. package/dist/esm/schemas/space.d.ts +0 -26
  48. package/dist/esm/schemas/space.js +0 -26
  49. package/dist/esm/schemas/space.js.map +1 -1
  50. package/dist/esm/schemas/ticket.d.ts +1 -1
  51. package/dist/esm/schemas/ticket.js +0 -1
  52. package/dist/esm/schemas/ticket.js.map +1 -1
  53. package/dist/esm/schemas/user.d.ts +0 -3
  54. package/dist/esm/schemas/user.js +0 -3
  55. package/dist/esm/schemas/user.js.map +1 -1
  56. package/dist/esm/validate.d.ts +155 -215
  57. package/dist/esm/validate.js +0 -12
  58. package/dist/esm/validate.js.map +1 -1
  59. package/package.json +1 -1
  60. package/dist/cjs/models/deviceRouter.cjs +0 -52
  61. package/dist/cjs/models/deviceRouter.cjs.map +0 -1
  62. package/dist/cjs/models/deviceRouter.d.cts +0 -23
  63. package/dist/cjs/models/room.cjs +0 -169
  64. package/dist/cjs/models/room.cjs.map +0 -1
  65. package/dist/cjs/models/room.d.cts +0 -48
  66. package/dist/cjs/models/scene.cjs +0 -54
  67. package/dist/cjs/models/scene.cjs.map +0 -1
  68. package/dist/cjs/models/scene.d.cts +0 -23
  69. package/dist/cjs/schemas/deviceRouter.cjs +0 -57
  70. package/dist/cjs/schemas/deviceRouter.cjs.map +0 -1
  71. package/dist/cjs/schemas/deviceRouter.d.cts +0 -46
  72. package/dist/cjs/schemas/room.cjs +0 -317
  73. package/dist/cjs/schemas/room.cjs.map +0 -1
  74. package/dist/cjs/schemas/room.d.cts +0 -223
  75. package/dist/cjs/schemas/scene.cjs +0 -174
  76. package/dist/cjs/schemas/scene.cjs.map +0 -1
  77. package/dist/cjs/schemas/scene.d.cts +0 -163
  78. package/dist/esm/models/deviceRouter.d.ts +0 -23
  79. package/dist/esm/models/deviceRouter.js +0 -32
  80. package/dist/esm/models/deviceRouter.js.map +0 -1
  81. package/dist/esm/models/room.d.ts +0 -48
  82. package/dist/esm/models/room.js +0 -147
  83. package/dist/esm/models/room.js.map +0 -1
  84. package/dist/esm/models/scene.d.ts +0 -23
  85. package/dist/esm/models/scene.js +0 -32
  86. package/dist/esm/models/scene.js.map +0 -1
  87. package/dist/esm/schemas/deviceRouter.d.ts +0 -46
  88. package/dist/esm/schemas/deviceRouter.js +0 -34
  89. package/dist/esm/schemas/deviceRouter.js.map +0 -1
  90. package/dist/esm/schemas/room.d.ts +0 -223
  91. package/dist/esm/schemas/room.js +0 -292
  92. package/dist/esm/schemas/room.js.map +0 -1
  93. package/dist/esm/schemas/scene.d.ts +0 -163
  94. package/dist/esm/schemas/scene.js +0 -151
  95. package/dist/esm/schemas/scene.js.map +0 -1
@@ -1,32 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
- import { Entity } from "./entity.js";
4
- import { validateScene as validate } from "../validate.js";
5
- import { sceneSchema } from "../schemas/scene.js";
6
- class Scene extends Entity {
7
- static {
8
- __name(this, "Scene");
9
- }
10
- constructor(data) {
11
- super(data);
12
- this.id = data.id;
13
- this.name = data.name;
14
- if (data.description !== void 0) this.description = data.description;
15
- this.type = data.type;
16
- if (data.devices !== void 0) this.devices = data.devices;
17
- if (data.isDefault !== void 0) this.isDefault = data.isDefault;
18
- if (data.showOnUi !== void 0) this.showOnUi = data.showOnUi;
19
- }
20
- }
21
- Object.defineProperty(Scene.prototype, "schema", {
22
- value: sceneSchema
23
- });
24
- Object.defineProperty(Scene.prototype, "validator", {
25
- get: /* @__PURE__ */ __name(function() {
26
- return validate;
27
- }, "get")
28
- });
29
- export {
30
- Scene
31
- };
32
- //# sourceMappingURL=scene.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../.generated/models/scene.ts"],"sourcesContent":["/* This file is automatically generated. Do not modify it manually. */\n\nimport { Entity } from \"./entity.js\";\nimport { validateScene as validate } from \"../validate.js\";\nimport { sceneSchema, type SceneSchema } from \"../schemas/scene.js\";\n\n/**\n * Data type for Scene constructor - exported for backwards compatibility\n */\nexport type SceneData = SceneSchema;\n\n/**\n * A room represents a physical space of controllable IoT devices\n */\nexport interface Scene extends SceneSchema {}\nexport class Scene extends Entity {\n declare schema: typeof sceneSchema;\n declare validator: typeof validate;\n\n constructor(data: SceneSchema) {\n super(data);\n this.id = data.id;\n this.name = data.name;\n if (data.description !== undefined) this.description = data.description;\n this.type = data.type;\n if (data.devices !== undefined) this.devices = data.devices;\n if (data.isDefault !== undefined) this.isDefault = data.isDefault;\n if (data.showOnUi !== undefined) this.showOnUi = data.showOnUi;\n }\n}\n\nObject.defineProperty(Scene.prototype, \"schema\", {\n value: sceneSchema,\n});\n\nObject.defineProperty(Scene.prototype, \"validator\", {\n get: function () {\n return validate;\n },\n});\n"],"mappings":";;AAEA,SAAS,cAAc;AACvB,SAAS,iBAAiB,gBAAgB;AAC1C,SAAS,mBAAqC;AAWvC,MAAM,cAAc,OAAO;AAAA,EAflC,OAekC;AAAA;AAAA;AAAA,EAIhC,YAAY,MAAmB;AAC7B,UAAM,IAAI;AACV,SAAK,KAAK,KAAK;AACf,SAAK,OAAO,KAAK;AACjB,QAAI,KAAK,gBAAgB,OAAW,MAAK,cAAc,KAAK;AAC5D,SAAK,OAAO,KAAK;AACjB,QAAI,KAAK,YAAY,OAAW,MAAK,UAAU,KAAK;AACpD,QAAI,KAAK,cAAc,OAAW,MAAK,YAAY,KAAK;AACxD,QAAI,KAAK,aAAa,OAAW,MAAK,WAAW,KAAK;AAAA,EACxD;AACF;AAEA,OAAO,eAAe,MAAM,WAAW,UAAU;AAAA,EAC/C,OAAO;AACT,CAAC;AAED,OAAO,eAAe,MAAM,WAAW,aAAa;AAAA,EAClD,KAAK,kCAAY;AACf,WAAO;AAAA,EACT,GAFK;AAGP,CAAC;","names":[]}
@@ -1,46 +0,0 @@
1
- import defs, { ISODateString } from './definitions.js';
2
- import { FromSchema } from 'json-schema-to-ts';
3
-
4
- declare const deviceRouterSchema: {
5
- readonly $schema: "http://json-schema.org/draft-07/schema";
6
- readonly $id: "deviceRouter.json";
7
- readonly title: "Device Router";
8
- readonly description: "A device router contains instructions on where to route devices based on their organization and driver.";
9
- readonly type: "object";
10
- readonly required: readonly ["id", "type", "driver", "organizationId"];
11
- readonly additionalProperties: false;
12
- readonly properties: {
13
- readonly id: {
14
- readonly $ref: "definitions.json#/definitions/id";
15
- };
16
- readonly type: {
17
- readonly type: "string";
18
- readonly default: "deviceRouter";
19
- readonly enum: readonly ["deviceRouter"];
20
- };
21
- readonly driver: {
22
- readonly type: "string";
23
- };
24
- readonly organizationId: {
25
- readonly type: readonly ["string", "null"];
26
- readonly description: "Reference (id) to the organization that owns this router";
27
- };
28
- readonly devices: {
29
- readonly type: "object";
30
- readonly additionalProperties: true;
31
- };
32
- };
33
- };
34
- type DeviceRouterSchema = FromSchema<typeof deviceRouterSchema, {
35
- references: [typeof defs];
36
- deserialize: [
37
- {
38
- pattern: {
39
- format: "date-time";
40
- };
41
- output: Date | ISODateString;
42
- }
43
- ];
44
- }>;
45
-
46
- export { type DeviceRouterSchema, deviceRouterSchema };
@@ -1,34 +0,0 @@
1
- const deviceRouterSchema = {
2
- $schema: "http://json-schema.org/draft-07/schema",
3
- $id: "deviceRouter.json",
4
- title: "Device Router",
5
- description: "A device router contains instructions on where to route devices based on their organization and driver.",
6
- type: "object",
7
- required: ["id", "type", "driver", "organizationId"],
8
- additionalProperties: false,
9
- properties: {
10
- id: {
11
- $ref: "definitions.json#/definitions/id"
12
- },
13
- type: {
14
- type: "string",
15
- default: "deviceRouter",
16
- enum: ["deviceRouter"]
17
- },
18
- driver: {
19
- type: "string"
20
- },
21
- organizationId: {
22
- type: ["string", "null"],
23
- description: "Reference (id) to the organization that owns this router"
24
- },
25
- devices: {
26
- type: "object",
27
- additionalProperties: true
28
- }
29
- }
30
- };
31
- export {
32
- deviceRouterSchema
33
- };
34
- //# sourceMappingURL=deviceRouter.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../.generated/schemas/deviceRouter.ts"],"sourcesContent":["import defs, { ISODateString } from \"./definitions\";\nimport type { FromSchema } from \"json-schema-to-ts\";\n\nexport const deviceRouterSchema = {\n $schema: \"http://json-schema.org/draft-07/schema\",\n $id: \"deviceRouter.json\",\n title: \"Device Router\",\n description:\n \"A device router contains instructions on where to route devices based on their organization and driver.\",\n type: \"object\",\n required: [\"id\", \"type\", \"driver\", \"organizationId\"],\n additionalProperties: false,\n properties: {\n id: {\n $ref: \"definitions.json#/definitions/id\",\n },\n type: {\n type: \"string\",\n default: \"deviceRouter\",\n enum: [\"deviceRouter\"],\n },\n driver: {\n type: \"string\",\n },\n organizationId: {\n type: [\"string\", \"null\"],\n description: \"Reference (id) to the organization that owns this router\",\n },\n devices: {\n type: \"object\",\n additionalProperties: true,\n },\n },\n} as const;\n\nexport type DeviceRouterSchema = FromSchema<\n typeof deviceRouterSchema,\n {\n references: [typeof defs];\n deserialize: [\n {\n pattern: {\n format: \"date-time\";\n };\n output: Date | ISODateString;\n },\n ];\n }\n>;\n"],"mappings":"AAGO,MAAM,qBAAqB;AAAA,EAChC,SAAS;AAAA,EACT,KAAK;AAAA,EACL,OAAO;AAAA,EACP,aACE;AAAA,EACF,MAAM;AAAA,EACN,UAAU,CAAC,MAAM,QAAQ,UAAU,gBAAgB;AAAA,EACnD,sBAAsB;AAAA,EACtB,YAAY;AAAA,IACV,IAAI;AAAA,MACF,MAAM;AAAA,IACR;AAAA,IACA,MAAM;AAAA,MACJ,MAAM;AAAA,MACN,SAAS;AAAA,MACT,MAAM,CAAC,cAAc;AAAA,IACvB;AAAA,IACA,QAAQ;AAAA,MACN,MAAM;AAAA,IACR;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM,CAAC,UAAU,MAAM;AAAA,MACvB,aAAa;AAAA,IACf;AAAA,IACA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,sBAAsB;AAAA,IACxB;AAAA,EACF;AACF;","names":[]}
@@ -1,223 +0,0 @@
1
- import defs, { ISODateString } from './definitions.js';
2
- import { FromSchema } from 'json-schema-to-ts';
3
- import { dimmerSchema } from './dimmer.js';
4
- import { switchSchema } from './switch.js';
5
- import { thermostatSchema } from './thermostat.js';
6
- import { lockSchema } from './lock.js';
7
- import { windowCoveringSchema } from './windowCovering.js';
8
- import { courtesySchema } from './courtesy.js';
9
- import { cameraSchema } from './camera.js';
10
- import { mediaSourceSchema } from './mediaSource.js';
11
- import { motionSensorSchema } from './motionSensor.js';
12
- import { alarmSchema } from './alarm.js';
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 };
@@ -1,292 +0,0 @@
1
- const roomSchema = {
2
- $schema: "http://json-schema.org/draft-07/schema",
3
- $id: "room.json",
4
- title: "Room",
5
- description: "A room represents a physical space of controllable IoT devices",
6
- type: "object",
7
- required: [
8
- "id",
9
- "name",
10
- "dimmers",
11
- "thermostats",
12
- "switches",
13
- "windowCoverings",
14
- "courtesy",
15
- "cameras",
16
- "mediaSources",
17
- "motionSensors",
18
- "alarms"
19
- ],
20
- properties: {
21
- id: {
22
- $ref: "definitions.json#/definitions/id"
23
- },
24
- type: {
25
- type: "string",
26
- enum: ["room"],
27
- default: "room"
28
- },
29
- name: {
30
- type: "string"
31
- },
32
- floor: {
33
- type: "string"
34
- },
35
- dimmers: {
36
- type: "array",
37
- default: [],
38
- items: {
39
- $ref: "dimmer.json"
40
- }
41
- },
42
- switches: {
43
- type: "array",
44
- default: [],
45
- items: {
46
- $ref: "switch.json"
47
- }
48
- },
49
- thermostats: {
50
- type: "array",
51
- default: [],
52
- items: {
53
- $ref: "thermostat.json"
54
- }
55
- },
56
- locks: {
57
- type: "array",
58
- default: [],
59
- items: {
60
- $ref: "lock.json"
61
- }
62
- },
63
- windowCoverings: {
64
- type: "array",
65
- default: [],
66
- items: {
67
- $ref: "windowCovering.json"
68
- }
69
- },
70
- courtesy: {
71
- type: "array",
72
- default: [],
73
- items: {
74
- $ref: "courtesy.json"
75
- }
76
- },
77
- cameras: {
78
- type: "array",
79
- default: [],
80
- items: {
81
- $ref: "camera.json"
82
- }
83
- },
84
- mediaSources: {
85
- type: "array",
86
- default: [],
87
- items: {
88
- $ref: "mediaSource.json"
89
- }
90
- },
91
- motionSensors: {
92
- type: "array",
93
- default: [],
94
- items: {
95
- $ref: "motionSensor.json"
96
- }
97
- },
98
- alarms: {
99
- type: "array",
100
- default: [],
101
- items: {
102
- $ref: "alarm.json"
103
- }
104
- },
105
- occupiedAt: {
106
- $ref: "definitions.json#/definitions/date"
107
- },
108
- createdAt: {
109
- $ref: "definitions.json#/definitions/date"
110
- },
111
- updatedAt: {
112
- $ref: "definitions.json#/definitions/date"
113
- },
114
- deletedAt: {
115
- $ref: "definitions.json#/definitions/date"
116
- }
117
- },
118
- additionalProperties: false
119
- };
120
- const getters = {
121
- /**
122
- * Check if the room has any dimmers
123
- * @returns {boolean} True if the room has dimmers, false otherwise
124
- */
125
- hasDimmer() {
126
- return this.dimmers?.length > 0;
127
- },
128
- /**
129
- * Check if the room has any switches
130
- * @returns {boolean} True if the room has switches, false otherwise
131
- */
132
- hasSwitch() {
133
- return this.switches?.length > 0;
134
- },
135
- /**
136
- * Check if the room has any window coverings
137
- * @returns {boolean} True if the room has window coverings, false otherwise
138
- */
139
- hasWindowCovering() {
140
- return this.windowCoverings?.length > 0;
141
- },
142
- /**
143
- * Alias for hasWindowCovering
144
- * @returns {boolean} True if the room has window coverings/shades, false otherwise
145
- */
146
- hasShade() {
147
- return this.hasWindowCovering;
148
- },
149
- /**
150
- * Check if the room has any thermostats
151
- * @returns {boolean} True if the room has thermostats, false otherwise
152
- */
153
- hasThermostat() {
154
- return this.thermostats?.length > 0;
155
- },
156
- /**
157
- * Alias for hasThermostat
158
- * @returns {boolean} True if the room has climate control, false otherwise
159
- */
160
- hasClimate() {
161
- return this.hasThermostat;
162
- },
163
- /**
164
- * Check if the room has any locks
165
- * @returns {boolean} True if the room has locks, false otherwise
166
- */
167
- hasLock() {
168
- return this.locks?.length > 0;
169
- },
170
- /**
171
- * Check if the room has any courtesy devices
172
- * @returns {boolean} True if the room has courtesy devices, false otherwise
173
- */
174
- hasCourtesy() {
175
- return this.courtesy?.length > 0;
176
- },
177
- /**
178
- * Check if the room has any cameras
179
- * @returns {boolean} True if the room has cameras, false otherwise
180
- */
181
- hasCamera() {
182
- return this.cameras?.length > 0;
183
- },
184
- /**
185
- * Check if the room has any media sources
186
- * @returns {boolean} True if the room has media sources, false otherwise
187
- */
188
- hasMedia() {
189
- return this.mediaSources?.length > 0;
190
- },
191
- /**
192
- * Check if the room has any lighting devices (dimmers or switches marked as lights/fans)
193
- * @returns {boolean} True if the room has lighting devices, false otherwise
194
- */
195
- hasLight() {
196
- const hasDiscriminatorLight = this.switches?.some(
197
- (sw) => {
198
- return sw.discriminator === "light" || sw.discriminator === "fan";
199
- }
200
- );
201
- return this.hasDimmer || hasDiscriminatorLight;
202
- },
203
- hasAlarm() {
204
- return this.alarms?.length > 0;
205
- },
206
- /**
207
- * Check if the room is currently occupied (within the last 60 minutes)
208
- * @returns {boolean} True if the room was occupied within the last hour, false otherwise
209
- */
210
- occupied() {
211
- if (!this.occupiedAt) return false;
212
- const now = /* @__PURE__ */ new Date();
213
- const lastOccupied = new Date(this.occupiedAt);
214
- const diff = now.getTime() - lastOccupied.getTime();
215
- return diff < 60 * 60 * 1e3;
216
- }
217
- };
218
- const statics = {
219
- /**
220
- * Get the device path for a given device type
221
- * @param {string} type - The device type
222
- * @returns {"mediaSources" | "courtesy" | "dimmers" | "thermostats" | "locks" | "windowCoverings" | "switches" | "cameras" | "motionSensors" | "alarms"} The device path
223
- * @throws {Error} If the device type is invalid
224
- */
225
- getDevicePath(type) {
226
- switch (type) {
227
- case "tv":
228
- case "dvr":
229
- case "appleTv":
230
- case "discPlayer":
231
- case "mediaPlayer":
232
- case "uncontrolledDevice":
233
- case "mediaSource":
234
- return "mediaSources";
235
- case "courtesy":
236
- return "courtesy";
237
- case "switch":
238
- return "switches";
239
- case "dimmer":
240
- return "dimmers";
241
- case "thermostat":
242
- return "thermostats";
243
- case "lock":
244
- return "locks";
245
- case "windowCovering":
246
- return "windowCoverings";
247
- case "camera":
248
- return "cameras";
249
- case "motionSensor":
250
- return "motionSensors";
251
- case "alarm":
252
- return "alarms";
253
- default:
254
- throw new Error("Invalid device type:" + type);
255
- }
256
- },
257
- /**
258
- *
259
- * @param {string} path
260
- * @returns
261
- */
262
- getDeviceTypeFromPath(path) {
263
- const validPaths = [
264
- "dimmers",
265
- "switches",
266
- "thermostats",
267
- "locks",
268
- "windowCoverings",
269
- "courtesy",
270
- "cameras",
271
- "mediaSources",
272
- "motionSensors",
273
- "alarms"
274
- ];
275
- if (!validPaths.includes(path))
276
- throw new Error("Invalid device path:" + path);
277
- switch (path) {
278
- case "courtesy":
279
- return path;
280
- case "switches":
281
- return "switch";
282
- default:
283
- return path.slice(0, -1);
284
- }
285
- }
286
- };
287
- export {
288
- getters,
289
- roomSchema,
290
- statics
291
- };
292
- //# sourceMappingURL=room.js.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":"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;A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