@kohost/api-client 1.0.0-beta.3 → 1.0.0-beta.5

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 (271) hide show
  1. package/dist/cjs/Client.js +5089 -0
  2. package/dist/cjs/Commands.js +568 -0
  3. package/dist/cjs/Errors.js +174 -0
  4. package/dist/cjs/Events.js +375 -0
  5. package/dist/cjs/Models.js +3584 -0
  6. package/dist/cjs/defs.js +175 -0
  7. package/dist/cjs/index.cjs.js +17 -0
  8. package/dist/cjs/utils.js +246 -0
  9. package/dist/esm/Client.js +7428 -0
  10. package/dist/esm/Client.js.map +7 -0
  11. package/dist/esm/Commands.js +574 -0
  12. package/dist/esm/Commands.js.map +7 -0
  13. package/dist/esm/Errors.js +180 -0
  14. package/dist/esm/Errors.js.map +7 -0
  15. package/dist/esm/Events.js +381 -0
  16. package/dist/esm/Events.js.map +7 -0
  17. package/dist/esm/Models.js +13220 -0
  18. package/dist/esm/Models.js.map +7 -0
  19. package/dist/esm/defs.js +2514 -0
  20. package/dist/esm/defs.js.map +7 -0
  21. package/dist/esm/index.js +11 -0
  22. package/dist/esm/utils.js +7281 -0
  23. package/dist/esm/utils.js.map +7 -0
  24. package/dist/useCases/AddDefaultScenesToRooms.js +32 -0
  25. package/dist/useCases/AddScenesToRoom.js +32 -0
  26. package/dist/useCases/AdminCreateProperty.js +32 -0
  27. package/dist/useCases/AdminDescribeProperty.js +32 -0
  28. package/dist/useCases/AdminListCustomers.js +32 -0
  29. package/dist/useCases/AdminListProperties.js +32 -0
  30. package/dist/useCases/AdminUpdateProperty.js +32 -0
  31. package/dist/useCases/BatchNotifyPreArrival.js +32 -0
  32. package/dist/useCases/CheckInReservation.js +32 -0
  33. package/dist/useCases/CheckVerificationCode.js +32 -0
  34. package/dist/useCases/CreateAlarm.js +32 -0
  35. package/dist/useCases/CreateCamera.js +32 -0
  36. package/dist/useCases/CreateCourtesy.js +32 -0
  37. package/dist/useCases/CreateDefaultScenes.js +32 -0
  38. package/dist/useCases/CreateDimmer.js +32 -0
  39. package/dist/useCases/CreateDiscoveredDevice.js +32 -0
  40. package/dist/useCases/CreateDiscoveredDeviceAssociation.js +32 -0
  41. package/dist/useCases/CreateIntegration.js +32 -0
  42. package/dist/useCases/CreateIntegrationDeviceMapEntry.js +32 -0
  43. package/dist/useCases/CreateLock.js +32 -0
  44. package/dist/useCases/CreateReservation.js +32 -0
  45. package/dist/useCases/CreateRoom.js +32 -0
  46. package/dist/useCases/CreateRoomInSpace.js +32 -0
  47. package/dist/useCases/CreateSource.js +32 -0
  48. package/dist/useCases/CreateSpace.js +32 -0
  49. package/dist/useCases/CreateSwitch.js +32 -0
  50. package/dist/useCases/CreateThermostat.js +32 -0
  51. package/dist/useCases/CreateTicket.js +32 -0
  52. package/dist/useCases/CreateTicketMessage.js +32 -0
  53. package/dist/useCases/CreateUser.js +32 -0
  54. package/dist/useCases/CreateWindowCovering.js +32 -0
  55. package/dist/useCases/DeleteAlarm.js +32 -0
  56. package/dist/useCases/DeleteCamera.js +32 -0
  57. package/dist/useCases/DeleteCourtesy.js +32 -0
  58. package/dist/useCases/DeleteDimmer.js +32 -0
  59. package/dist/useCases/DeleteDiscoveredDevice.js +32 -0
  60. package/dist/useCases/DeleteIntegration.js +32 -0
  61. package/dist/useCases/DeleteLock.js +32 -0
  62. package/dist/useCases/DeleteReservation.js +32 -0
  63. package/dist/useCases/DeleteRoom.js +32 -0
  64. package/dist/useCases/DeleteSource.js +32 -0
  65. package/dist/useCases/DeleteSpace.js +32 -0
  66. package/dist/useCases/DeleteSwitch.js +32 -0
  67. package/dist/useCases/DeleteThermostat.js +32 -0
  68. package/dist/useCases/DeleteTicket.js +32 -0
  69. package/dist/useCases/DeleteUser.js +32 -0
  70. package/dist/useCases/DeleteWindowCovering.js +32 -0
  71. package/dist/useCases/DescribeAlarm.js +32 -0
  72. package/dist/useCases/DescribeCamera.js +32 -0
  73. package/dist/useCases/DescribeCourtesy.js +32 -0
  74. package/dist/useCases/DescribeDimmer.js +32 -0
  75. package/dist/useCases/DescribeDiscoveredDevice.js +32 -0
  76. package/dist/useCases/DescribeIntegration.js +32 -0
  77. package/dist/useCases/DescribeLock.js +32 -0
  78. package/dist/useCases/DescribeMyProperty.js +32 -0
  79. package/dist/useCases/DescribeReservation.js +32 -0
  80. package/dist/useCases/DescribeReservationCheckinStatus.js +32 -0
  81. package/dist/useCases/DescribeRoom.js +32 -0
  82. package/dist/useCases/DescribeSelf.js +32 -0
  83. package/dist/useCases/DescribeSource.js +32 -0
  84. package/dist/useCases/DescribeSpace.js +32 -0
  85. package/dist/useCases/DescribeSwitch.js +32 -0
  86. package/dist/useCases/DescribeThermostat.js +32 -0
  87. package/dist/useCases/DescribeTicket.js +32 -0
  88. package/dist/useCases/DescribeUser.js +32 -0
  89. package/dist/useCases/DescribeWindowCovering.js +32 -0
  90. package/dist/useCases/DiscoverReservations.js +32 -0
  91. package/dist/useCases/EmailUserAccountSetup.js +32 -0
  92. package/dist/useCases/ListAlarms.js +32 -0
  93. package/dist/useCases/ListCameras.js +32 -0
  94. package/dist/useCases/ListCourtesy.js +32 -0
  95. package/dist/useCases/ListDimmers.js +32 -0
  96. package/dist/useCases/ListDiscoveredDevices.js +32 -0
  97. package/dist/useCases/ListIntegrations.js +32 -0
  98. package/dist/useCases/ListLocks.js +32 -0
  99. package/dist/useCases/ListMyReservations.js +32 -0
  100. package/dist/useCases/ListMySpaces.js +32 -0
  101. package/dist/useCases/ListReservations.js +32 -0
  102. package/dist/useCases/ListRooms.js +32 -0
  103. package/dist/useCases/ListRoomsInSpace.js +32 -0
  104. package/dist/useCases/ListSources.js +32 -0
  105. package/dist/useCases/ListSpaces.js +32 -0
  106. package/dist/useCases/ListSwitches.js +32 -0
  107. package/dist/useCases/ListThermostats.js +32 -0
  108. package/dist/useCases/ListTickets.js +32 -0
  109. package/dist/useCases/ListUserReservations.js +32 -0
  110. package/dist/useCases/ListUsers.js +32 -0
  111. package/dist/useCases/ListWindowCoverings.js +32 -0
  112. package/dist/useCases/LoginGateway.js +32 -0
  113. package/dist/useCases/LoginUser.js +32 -0
  114. package/dist/useCases/MatchUserIdentification.js +32 -0
  115. package/dist/useCases/OCRDocument.js +32 -0
  116. package/dist/useCases/RefreshToken.js +32 -0
  117. package/dist/useCases/RequestLoginLink.js +32 -0
  118. package/dist/useCases/SendPreArrivalEmail.js +32 -0
  119. package/dist/useCases/SendPreArrivalSMS.js +32 -0
  120. package/dist/useCases/SendVerificationCode.js +32 -0
  121. package/dist/useCases/SetCamera.js +32 -0
  122. package/dist/useCases/SetCourtesy.js +32 -0
  123. package/dist/useCases/SetLock.js +32 -0
  124. package/dist/useCases/SetSource.js +32 -0
  125. package/dist/useCases/SetSwitch.js +32 -0
  126. package/dist/useCases/SetThermostat.js +32 -0
  127. package/dist/useCases/SetWindowCovering.js +32 -0
  128. package/dist/useCases/UpdateAlarm.js +32 -0
  129. package/dist/useCases/UpdateCamera.js +32 -0
  130. package/dist/useCases/UpdateCourtesy.js +32 -0
  131. package/dist/useCases/UpdateDimmer.js +32 -0
  132. package/dist/useCases/UpdateDiscoveredDevice.js +32 -0
  133. package/dist/useCases/UpdateIntegration.js +32 -0
  134. package/dist/useCases/UpdateLock.js +32 -0
  135. package/dist/useCases/UpdateMessageReadStatus.js +32 -0
  136. package/dist/useCases/UpdateReservation.js +32 -0
  137. package/dist/useCases/UpdateRoom.js +32 -0
  138. package/dist/useCases/UpdateSelf.js +32 -0
  139. package/dist/useCases/UpdateSource.js +32 -0
  140. package/dist/useCases/UpdateSpace.js +32 -0
  141. package/dist/useCases/UpdateSwitch.js +32 -0
  142. package/dist/useCases/UpdateThermostat.js +32 -0
  143. package/dist/useCases/UpdateTicket.js +32 -0
  144. package/dist/useCases/UpdateTicketStatus.js +32 -0
  145. package/dist/useCases/UpdateUser.js +32 -0
  146. package/dist/useCases/UpdateWindowCovering.js +32 -0
  147. package/dist/useCases/UpsertDiscoveredDevice.js +32 -0
  148. package/package.json +26 -7
  149. package/.eslintrc.js +0 -10
  150. package/bitbucket-pipelines.yml +0 -71
  151. package/commands/CheckInReservationCommand.js +0 -23
  152. package/commands/Command.js +0 -38
  153. package/commands/DiscoverReservationsCommand.js +0 -24
  154. package/commands/DiscoverRoomsCommand.js +0 -21
  155. package/commands/DiscoverUsersCommand.js +0 -21
  156. package/commands/OCRDocumentCommand.js +0 -20
  157. package/commands/SendEmailCommand.js +0 -24
  158. package/commands/SendSMSCommand.js +0 -21
  159. package/commands/SetAlarmCommand.js +0 -21
  160. package/commands/SetCourtesyCommand.js +0 -21
  161. package/commands/SetDimmerCommand.js +0 -21
  162. package/commands/SetLockCommand.js +0 -21
  163. package/commands/SetSceneControllerCommand.js +0 -21
  164. package/commands/SetSwitchCommand.js +0 -21
  165. package/commands/SetThermostatCommand.js +0 -21
  166. package/commands/SetWindowCoveringCommand.js +0 -21
  167. package/commands/index.js +0 -31
  168. package/defs/deviceTypes.js +0 -15
  169. package/defs/formalDeviceTypes.js +0 -6
  170. package/defs/http.js +0 -7
  171. package/defs/index.js +0 -11
  172. package/errors/AppError.js +0 -8
  173. package/errors/AuthenticationError.js +0 -9
  174. package/errors/AuthorizationError.js +0 -9
  175. package/errors/DeviceCommError.js +0 -9
  176. package/errors/LoginError.js +0 -9
  177. package/errors/NotFoundError.js +0 -9
  178. package/errors/RequestError.js +0 -9
  179. package/errors/SystemCommError.js +0 -9
  180. package/errors/TokenExpiredError.js +0 -9
  181. package/errors/UnprocessableRequestError.js +0 -9
  182. package/errors/ValidationError.js +0 -9
  183. package/errors/index.js +0 -15
  184. package/events/EmailSentEvent.js +0 -17
  185. package/events/Event.js +0 -52
  186. package/events/SMSSentEvent.js +0 -17
  187. package/events/ShortLinkCreatedEvent.js +0 -17
  188. package/events/SystemCameraUpdatedEvent.js +0 -17
  189. package/events/SystemCourtesyUpdatedEvent.js +0 -17
  190. package/events/SystemDimmerUpdatedEvent.js +0 -17
  191. package/events/SystemLockUpdatedEvent.js +0 -17
  192. package/events/SystemReservationUpdatedEvent.js +0 -17
  193. package/events/SystemSceneControllerUpdatedEvent.js +0 -17
  194. package/events/SystemSourceUpdatedEvent.js +0 -17
  195. package/events/SystemSpaceUpdatedEvent.js +0 -17
  196. package/events/SystemSwitchUpdatedEvent.js +0 -17
  197. package/events/SystemThermostatUpdatedEvent.js +0 -17
  198. package/events/SystemUserUpdatedEvent.js +0 -17
  199. package/events/SystemWindowCoveringUpdatedEvent.js +0 -17
  200. package/events/index.js +0 -35
  201. package/http/handleResponseError.js +0 -33
  202. package/http/handleResponseSuccess.js +0 -15
  203. package/http/index.js +0 -169
  204. package/index.js +0 -23
  205. package/models/acl.js +0 -29
  206. package/models/admin/customer.js +0 -28
  207. package/models/admin/property.js +0 -28
  208. package/models/alarm.js +0 -29
  209. package/models/application.js +0 -28
  210. package/models/camera.js +0 -29
  211. package/models/courtesy.js +0 -33
  212. package/models/credential.js +0 -29
  213. package/models/dimmer.js +0 -49
  214. package/models/discoveredDevice.js +0 -30
  215. package/models/gateway.js +0 -29
  216. package/models/identification.js +0 -32
  217. package/models/index.js +0 -56
  218. package/models/integration.js +0 -76
  219. package/models/kohost.js +0 -96
  220. package/models/lock.js +0 -33
  221. package/models/mediaSource.js +0 -29
  222. package/models/motionSensor.js +0 -29
  223. package/models/product.js +0 -30
  224. package/models/reservation.js +0 -83
  225. package/models/room.js +0 -174
  226. package/models/scene.js +0 -28
  227. package/models/shortLink.js +0 -29
  228. package/models/space.js +0 -99
  229. package/models/switch.js +0 -33
  230. package/models/thermostat.js +0 -80
  231. package/models/ticket.js +0 -91
  232. package/models/user.js +0 -56
  233. package/models/windowCovering.js +0 -49
  234. package/prepare.js +0 -4
  235. package/schemas/acl.json +0 -111
  236. package/schemas/admin/customer.json +0 -32
  237. package/schemas/admin/property.json +0 -180
  238. package/schemas/alarm.json +0 -93
  239. package/schemas/application.json +0 -24
  240. package/schemas/camera.json +0 -41
  241. package/schemas/courtesy.json +0 -37
  242. package/schemas/credential.json +0 -28
  243. package/schemas/definitions/common.json +0 -74
  244. package/schemas/definitions/device.json +0 -76
  245. package/schemas/dimmer.json +0 -34
  246. package/schemas/discoveredDevice.json +0 -43
  247. package/schemas/gateway.json +0 -30
  248. package/schemas/identification.json +0 -49
  249. package/schemas/integration.json +0 -94
  250. package/schemas/lock.json +0 -36
  251. package/schemas/mediaSource.json +0 -151
  252. package/schemas/motionSensor.json +0 -26
  253. package/schemas/payment.json +0 -40
  254. package/schemas/product.json +0 -36
  255. package/schemas/reservation.json +0 -71
  256. package/schemas/room.json +0 -131
  257. package/schemas/scene.json +0 -118
  258. package/schemas/shortLink.json +0 -30
  259. package/schemas/space.json +0 -111
  260. package/schemas/switch.json +0 -33
  261. package/schemas/thermostat.json +0 -139
  262. package/schemas/ticket.json +0 -82
  263. package/schemas/user.json +0 -176
  264. package/schemas/windowCovering.json +0 -34
  265. package/tests/unit/models/space.test.js +0 -31
  266. package/tests/unit/models/thermostat.test.js +0 -146
  267. package/tests/unit/models/user.test.js +0 -28
  268. package/useCases/http.json +0 -1161
  269. package/utils/getDeviceTypes.js +0 -7
  270. package/utils/getFormalDeviceType.js +0 -5
  271. package/utils/schema.js +0 -28
@@ -0,0 +1,3584 @@
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+
6
+ // src/schemas/definitions/common.json
7
+ var require_common = __commonJS({
8
+ "src/schemas/definitions/common.json"(exports2, module2) {
9
+ module2.exports = {
10
+ $schema: "http://json-schema.org/draft-07/schema",
11
+ $id: "https://api.kohost.app/schemas/v3/definitions/common.json",
12
+ definitions: {
13
+ id: {
14
+ type: "string"
15
+ },
16
+ systemData: {
17
+ type: "object",
18
+ default: {}
19
+ },
20
+ metadata: {
21
+ type: "object",
22
+ default: {}
23
+ },
24
+ createdAt: {
25
+ type: ["string", "object"],
26
+ format: "date-time"
27
+ },
28
+ updatedAt: {
29
+ type: ["string", "object"],
30
+ format: "date-time"
31
+ },
32
+ file: {
33
+ type: "object",
34
+ required: ["name", "type", "data"],
35
+ properties: {
36
+ name: {
37
+ type: "string",
38
+ description: "Name of the file."
39
+ },
40
+ type: {
41
+ type: "string",
42
+ description: "MIME type of the file (e.g. application/pdf)."
43
+ },
44
+ data: {
45
+ type: "string",
46
+ description: "Base64-encoded data of the file."
47
+ }
48
+ }
49
+ },
50
+ address: {
51
+ type: "object",
52
+ properties: {
53
+ id: {
54
+ type: "string"
55
+ },
56
+ line1: {
57
+ type: "string"
58
+ },
59
+ line2: {
60
+ type: "string"
61
+ },
62
+ line3: {
63
+ type: "string"
64
+ },
65
+ city: {
66
+ type: "string"
67
+ },
68
+ state: {
69
+ type: "string"
70
+ },
71
+ postalCode: {
72
+ type: "string"
73
+ },
74
+ countryCode: {
75
+ type: "string",
76
+ minLength: 2,
77
+ maxLength: 2
78
+ }
79
+ }
80
+ }
81
+ }
82
+ };
83
+ }
84
+ });
85
+
86
+ // src/schemas/definitions/device.json
87
+ var require_device = __commonJS({
88
+ "src/schemas/definitions/device.json"(exports2, module2) {
89
+ module2.exports = {
90
+ $schema: "http://json-schema.org/draft-07/schema",
91
+ $id: "https://api.kohost.app/schemas/v3/definitions/device.json",
92
+ definitions: {
93
+ id: {
94
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
95
+ },
96
+ systemData: {
97
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
98
+ },
99
+ type: {
100
+ type: "string",
101
+ enum: [
102
+ "dimmer",
103
+ "switch",
104
+ "motionSensor",
105
+ "windowCovering",
106
+ "camera",
107
+ "mediaSource",
108
+ "thermostat",
109
+ "lock",
110
+ "courtesy",
111
+ "sceneController",
112
+ "gateway"
113
+ ]
114
+ },
115
+ name: {
116
+ type: "string"
117
+ },
118
+ subType: {
119
+ type: ["string", "null"]
120
+ },
121
+ supportedNotifications: {
122
+ type: "array",
123
+ uniqueItems: true,
124
+ items: {
125
+ enum: [
126
+ "button 1",
127
+ "button 2",
128
+ "button 3",
129
+ "button 4",
130
+ "button 5",
131
+ "idle",
132
+ "powerHasBeedApplied",
133
+ "acMainsDisconnected",
134
+ "acMainsReconnected",
135
+ "replaceBatterySoon",
136
+ "replaceBatteryNow",
137
+ "hardwareFailure",
138
+ "softwareFailure",
139
+ "hardwareFailureWithCode",
140
+ "softwareFailureWithCode",
141
+ "motionDetection"
142
+ ]
143
+ }
144
+ },
145
+ notification: {
146
+ type: ["object", "null"],
147
+ properties: {
148
+ name: {
149
+ type: "string",
150
+ $ref: "#/definitions/supportedNotifications/items"
151
+ },
152
+ timestamp: {
153
+ type: "number",
154
+ minimum: 1655907956593
155
+ }
156
+ }
157
+ },
158
+ batteryLevel: {
159
+ type: "number",
160
+ minimum: 0,
161
+ maximum: 100
162
+ }
163
+ }
164
+ };
165
+ }
166
+ });
167
+
168
+ // src/utils/schema.js
169
+ var require_schema = __commonJS({
170
+ "src/utils/schema.js"(exports2, module2) {
171
+ var Ajv = require("ajv");
172
+ var ajv = new Ajv({
173
+ allErrors: true,
174
+ useDefaults: true,
175
+ strict: false,
176
+ allowMatchingProperties: true,
177
+ allowUnionTypes: true,
178
+ strictRequired: false
179
+ });
180
+ var addFormats = require("ajv-formats");
181
+ var commonDefs = require_common();
182
+ var deviceDefs = require_device();
183
+ addFormats(ajv);
184
+ ajv.addSchema(commonDefs);
185
+ ajv.addSchema(deviceDefs);
186
+ module2.exports = {
187
+ add: function add(schema) {
188
+ ajv.addSchema(schema);
189
+ },
190
+ compile: function compile(schema) {
191
+ return ajv.compile(schema);
192
+ }
193
+ };
194
+ }
195
+ });
196
+
197
+ // src/schemas/switch.json
198
+ var require_switch = __commonJS({
199
+ "src/schemas/switch.json"(exports2, module2) {
200
+ module2.exports = {
201
+ $schema: "http://json-schema.org/draft-07/schema",
202
+ $id: "https://api.kohost.app/schemas/v3/switch.json",
203
+ title: "Switch",
204
+ description: "Any smart switch",
205
+ type: "object",
206
+ properties: {
207
+ id: {
208
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
209
+ },
210
+ type: {
211
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
212
+ },
213
+ subType: {
214
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
215
+ },
216
+ supportedNotifications: {
217
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
218
+ },
219
+ notification: {
220
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
221
+ },
222
+ state: {
223
+ type: "string",
224
+ enum: ["on", "off"]
225
+ },
226
+ systemData: {
227
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
228
+ }
229
+ },
230
+ additionalProperties: false,
231
+ required: ["id", "type", "systemData", "state"]
232
+ };
233
+ }
234
+ });
235
+
236
+ // src/Errors/AppError.js
237
+ var require_AppError = __commonJS({
238
+ "src/Errors/AppError.js"(exports2, module2) {
239
+ module2.exports = class AppError extends Error {
240
+ constructor(message = "Internal Server Error", options) {
241
+ super(message, options);
242
+ this.type = this.constructor.name;
243
+ this.statusCode = 500;
244
+ Object.setPrototypeOf(this, AppError.prototype);
245
+ }
246
+ };
247
+ }
248
+ });
249
+
250
+ // src/Errors/AuthenticationError.js
251
+ var require_AuthenticationError = __commonJS({
252
+ "src/Errors/AuthenticationError.js"(exports2, module2) {
253
+ var AppError = require_AppError();
254
+ module2.exports = class AuthenticationError extends AppError {
255
+ constructor(message = "Authentication Error", options = {}) {
256
+ super(message, options);
257
+ this.statusCode = 401;
258
+ Object.setPrototypeOf(this, AuthenticationError.prototype);
259
+ }
260
+ };
261
+ }
262
+ });
263
+
264
+ // src/Errors/AuthorizationError.js
265
+ var require_AuthorizationError = __commonJS({
266
+ "src/Errors/AuthorizationError.js"(exports2, module2) {
267
+ var AppError = require_AppError();
268
+ module2.exports = class AuthorizationError extends AppError {
269
+ constructor(message = "Authorization Error", options = {}) {
270
+ super(message, options);
271
+ this.statusCode = 403;
272
+ Object.setPrototypeOf(this, AuthorizationError.prototype);
273
+ }
274
+ };
275
+ }
276
+ });
277
+
278
+ // src/Errors/DeviceCommError.js
279
+ var require_DeviceCommError = __commonJS({
280
+ "src/Errors/DeviceCommError.js"(exports2, module2) {
281
+ var AppError = require_AppError();
282
+ module2.exports = class DeviceCommError extends AppError {
283
+ constructor(message = "Device Communication Error", options = {}) {
284
+ super(message, options);
285
+ this.statusCode = 503;
286
+ Object.setPrototypeOf(this, DeviceCommError.prototype);
287
+ }
288
+ };
289
+ }
290
+ });
291
+
292
+ // src/Errors/LoginError.js
293
+ var require_LoginError = __commonJS({
294
+ "src/Errors/LoginError.js"(exports2, module2) {
295
+ var AppError = require_AppError();
296
+ module2.exports = class LoginError extends AppError {
297
+ constructor(message = "Invalid Login information provided", options = {}) {
298
+ super(message, options);
299
+ this.statusCode = 401;
300
+ Object.setPrototypeOf(this, LoginError.prototype);
301
+ }
302
+ };
303
+ }
304
+ });
305
+
306
+ // src/Errors/NotFoundError.js
307
+ var require_NotFoundError = __commonJS({
308
+ "src/Errors/NotFoundError.js"(exports2, module2) {
309
+ var AppError = require_AppError();
310
+ module2.exports = class NotFoundError extends AppError {
311
+ constructor(message = "Resource Not Found", options = {}) {
312
+ super(message, options);
313
+ this.statusCode = 404;
314
+ Object.setPrototypeOf(this, NotFoundError.prototype);
315
+ }
316
+ };
317
+ }
318
+ });
319
+
320
+ // src/Errors/RequestError.js
321
+ var require_RequestError = __commonJS({
322
+ "src/Errors/RequestError.js"(exports2, module2) {
323
+ var AppError = require_AppError();
324
+ module2.exports = class RequestError extends AppError {
325
+ constructor(message = "Bad Request", options = {}) {
326
+ super(message, options);
327
+ this.statusCode = 400;
328
+ Object.setPrototypeOf(this, RequestError.prototype);
329
+ }
330
+ };
331
+ }
332
+ });
333
+
334
+ // src/Errors/SystemCommError.js
335
+ var require_SystemCommError = __commonJS({
336
+ "src/Errors/SystemCommError.js"(exports2, module2) {
337
+ var AppError = require_AppError();
338
+ module2.exports = class SystemCommError extends AppError {
339
+ constructor(message = "System Communication Error", options = {}) {
340
+ super(message, options);
341
+ this.statusCode = 503;
342
+ Object.setPrototypeOf(this, SystemCommError.prototype);
343
+ }
344
+ };
345
+ }
346
+ });
347
+
348
+ // src/Errors/TokenExpiredError.js
349
+ var require_TokenExpiredError = __commonJS({
350
+ "src/Errors/TokenExpiredError.js"(exports2, module2) {
351
+ var AppError = require_AppError();
352
+ module2.exports = class TokenExpiredError extends AppError {
353
+ constructor(message = "Token Expired", options = {}) {
354
+ super(message, options);
355
+ this.statusCode = 401;
356
+ Object.setPrototypeOf(this, TokenExpiredError.prototype);
357
+ }
358
+ };
359
+ }
360
+ });
361
+
362
+ // src/Errors/UnprocessableRequestError.js
363
+ var require_UnprocessableRequestError = __commonJS({
364
+ "src/Errors/UnprocessableRequestError.js"(exports2, module2) {
365
+ var AppError = require_AppError();
366
+ module2.exports = class UnprocessableRequestError extends AppError {
367
+ constructor(message = "Unprocessable Request Error", options = {}) {
368
+ super(message, options);
369
+ this.statusCode = 422;
370
+ Object.setPrototypeOf(this, UnprocessableRequestError.prototype);
371
+ }
372
+ };
373
+ }
374
+ });
375
+
376
+ // src/Errors/ValidationError.js
377
+ var require_ValidationError = __commonJS({
378
+ "src/Errors/ValidationError.js"(exports2, module2) {
379
+ var AppError = require_AppError();
380
+ module2.exports = class ValidationError extends AppError {
381
+ constructor(message = "Validation Error", options = {}) {
382
+ super(message, options);
383
+ this.statusCode = 400;
384
+ Object.setPrototypeOf(this, ValidationError.prototype);
385
+ }
386
+ };
387
+ }
388
+ });
389
+
390
+ // src/Errors/index.js
391
+ var require_Errors = __commonJS({
392
+ "src/Errors/index.js"(exports2, module2) {
393
+ var Errors = {
394
+ AppError: require_AppError(),
395
+ AuthenticationError: require_AuthenticationError(),
396
+ AuthorizationError: require_AuthorizationError(),
397
+ DeviceCommError: require_DeviceCommError(),
398
+ LoginError: require_LoginError(),
399
+ NotFoundError: require_NotFoundError(),
400
+ RequestError: require_RequestError(),
401
+ SystemCommError: require_SystemCommError(),
402
+ TokenExpiredError: require_TokenExpiredError(),
403
+ UnprocessableRequestError: require_UnprocessableRequestError(),
404
+ ValidationError: require_ValidationError()
405
+ };
406
+ module2.exports = Errors;
407
+ }
408
+ });
409
+
410
+ // src/Models/kohost.js
411
+ var require_kohost = __commonJS({
412
+ "src/Models/kohost.js"(exports2, module2) {
413
+ var { ValidationError } = require_Errors();
414
+ var { customAlphabet: generate } = require("nanoid");
415
+ var Kohost = class {
416
+ constructor(data) {
417
+ if (!this.schema) {
418
+ throw new Error("Schema is not defined");
419
+ }
420
+ if (!this.validator) {
421
+ throw new Error("Validator is not defined");
422
+ }
423
+ const isNew = (data == null ? void 0 : data.id) ? false : true;
424
+ this._setId(data);
425
+ this._validate(data);
426
+ this._setProperties(data);
427
+ this._setTimestamps(isNew);
428
+ }
429
+ static get validProperties() {
430
+ throw new Error("validProperties is not defined");
431
+ }
432
+ get schemaProperties() {
433
+ return Object.keys(this.validator.schema.properties);
434
+ }
435
+ _setId(data) {
436
+ if (data._id)
437
+ data.id = data._id;
438
+ if (!data.id) {
439
+ data.id = this.constructor.generateId();
440
+ }
441
+ delete data._id;
442
+ }
443
+ _setProperties(data) {
444
+ this.schemaProperties.forEach((key) => {
445
+ if (data[key] !== void 0)
446
+ this[key] = data[key];
447
+ });
448
+ }
449
+ _setTimestamps(isNew) {
450
+ const now = new Date();
451
+ if (isNew && this.schemaProperties.includes("createdAt") && !this.createdAt) {
452
+ this.createdAt = now;
453
+ }
454
+ }
455
+ _validate(data) {
456
+ const valid = this.validator(data);
457
+ if (!valid) {
458
+ throw new ValidationError(`Invalid ${this.constructor.name}`, {
459
+ cause: this.validator.errors
460
+ });
461
+ }
462
+ }
463
+ static generateId() {
464
+ const length = 8;
465
+ const characters = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
466
+ const id = generate(characters, length)();
467
+ return id;
468
+ }
469
+ static getActionDelta(old, _new) {
470
+ var _a;
471
+ const delta = {};
472
+ for (const action in _new) {
473
+ if ((_a = this.actionProperties) == null ? void 0 : _a.includes(action)) {
474
+ if (old[action] !== _new[action]) {
475
+ delta[action] = 1;
476
+ }
477
+ }
478
+ }
479
+ return delta;
480
+ }
481
+ toObject() {
482
+ const obj = { ...this };
483
+ Object.keys(obj).forEach((key) => {
484
+ if (!this.constructor.validProperties.includes(key)) {
485
+ delete obj[key];
486
+ }
487
+ });
488
+ return obj;
489
+ }
490
+ };
491
+ module2.exports = Kohost;
492
+ }
493
+ });
494
+
495
+ // src/Models/switch.js
496
+ var require_switch2 = __commonJS({
497
+ "src/Models/switch.js"(exports2, module2) {
498
+ var schemas = require_schema();
499
+ var schema = require_switch();
500
+ var Kohost = require_kohost();
501
+ schemas.add(schema);
502
+ var validator = schemas.compile(schema);
503
+ var Switch2 = class extends Kohost {
504
+ constructor(data) {
505
+ super(data);
506
+ }
507
+ };
508
+ Object.defineProperty(Switch2.prototype, "schema", {
509
+ value: schema
510
+ });
511
+ Object.defineProperty(Switch2.prototype, "validator", {
512
+ get: function() {
513
+ return validator;
514
+ }
515
+ });
516
+ Object.defineProperty(Switch2, "validProperties", {
517
+ value: Object.keys(schema.properties)
518
+ });
519
+ Object.defineProperty(Switch2, "actionProperties", {
520
+ value: ["state"]
521
+ });
522
+ module2.exports = Switch2;
523
+ }
524
+ });
525
+
526
+ // src/schemas/alarm.json
527
+ var require_alarm = __commonJS({
528
+ "src/schemas/alarm.json"(exports2, module2) {
529
+ module2.exports = {
530
+ $schema: "http://json-schema.org/draft-07/schema",
531
+ $id: "https://api.kohost.app/schemas/v3/alarm.json",
532
+ title: "Alarm",
533
+ description: "Any smart alarm system",
534
+ type: "object",
535
+ properties: {
536
+ id: {
537
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
538
+ },
539
+ type: {
540
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
541
+ },
542
+ systemData: {
543
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
544
+ },
545
+ supportedNotifications: {
546
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
547
+ },
548
+ notification: {
549
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
550
+ },
551
+ areas: {
552
+ type: "array",
553
+ items: {
554
+ type: "object",
555
+ properties: {
556
+ number: {
557
+ type: "number"
558
+ },
559
+ name: {
560
+ type: "string"
561
+ },
562
+ securityMode: {
563
+ type: "string",
564
+ enum: ["arming", "disarming", "armed", "disarmed", "alarm"]
565
+ },
566
+ readyToArm: {
567
+ type: "boolean"
568
+ }
569
+ },
570
+ additionalProperties: false
571
+ }
572
+ },
573
+ zones: {
574
+ type: "array",
575
+ items: {
576
+ type: "object",
577
+ properties: {
578
+ number: {
579
+ type: "number",
580
+ minimum: 0
581
+ },
582
+ name: {
583
+ type: "string"
584
+ },
585
+ secure: {
586
+ type: "boolean"
587
+ },
588
+ bypassed: {
589
+ type: "boolean"
590
+ }
591
+ },
592
+ additionalProperties: false
593
+ }
594
+ },
595
+ supportedTroubles: {
596
+ type: "array",
597
+ uniqueItems: true,
598
+ items: {
599
+ type: "string",
600
+ enum: ["battery", "ac", "phone", "bell", "fire"]
601
+ }
602
+ },
603
+ troubles: {
604
+ type: "array",
605
+ uniqueItems: true,
606
+ items: {
607
+ $ref: "#/properties/supportedTroubles/items"
608
+ }
609
+ }
610
+ },
611
+ additionalProperties: false,
612
+ required: [
613
+ "id",
614
+ "type",
615
+ "systemData",
616
+ "areas",
617
+ "zones",
618
+ "supportedTroubles",
619
+ "troubles"
620
+ ]
621
+ };
622
+ }
623
+ });
624
+
625
+ // src/Models/alarm.js
626
+ var require_alarm2 = __commonJS({
627
+ "src/Models/alarm.js"(exports2, module2) {
628
+ var schemas = require_schema();
629
+ var schema = require_alarm();
630
+ var Kohost = require_kohost();
631
+ schemas.add(schema);
632
+ var validator = schemas.compile(schema);
633
+ var Alarm2 = class extends Kohost {
634
+ constructor(data) {
635
+ super(data);
636
+ }
637
+ };
638
+ Object.defineProperty(Alarm2.prototype, "schema", {
639
+ value: schema
640
+ });
641
+ Object.defineProperty(Alarm2.prototype, "validator", {
642
+ get: function() {
643
+ return validator;
644
+ }
645
+ });
646
+ Object.defineProperty(Alarm2, "validProperties", {
647
+ value: Object.keys(schema.properties)
648
+ });
649
+ module2.exports = Alarm2;
650
+ }
651
+ });
652
+
653
+ // src/schemas/dimmer.json
654
+ var require_dimmer = __commonJS({
655
+ "src/schemas/dimmer.json"(exports2, module2) {
656
+ module2.exports = {
657
+ $schema: "http://json-schema.org/draft-07/schema",
658
+ $id: "https://api.kohost.app/schemas/v3/dimmer.json",
659
+ title: "Dimmer",
660
+ description: "Any smart dimmer",
661
+ type: "object",
662
+ properties: {
663
+ id: {
664
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
665
+ },
666
+ type: {
667
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
668
+ },
669
+ subType: {
670
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
671
+ },
672
+ supportedNotifications: {
673
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
674
+ },
675
+ notification: {
676
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
677
+ },
678
+ level: {
679
+ type: "number",
680
+ minimum: 0,
681
+ maximum: 100
682
+ },
683
+ systemData: {
684
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
685
+ }
686
+ },
687
+ additionalProperties: false,
688
+ required: ["id", "type", "systemData", "level"]
689
+ };
690
+ }
691
+ });
692
+
693
+ // src/Models/dimmer.js
694
+ var require_dimmer2 = __commonJS({
695
+ "src/Models/dimmer.js"(exports2, module2) {
696
+ var schemas = require_schema();
697
+ var schema = require_dimmer();
698
+ var Kohost = require_kohost();
699
+ schemas.add(schema);
700
+ var validator = schemas.compile(schema);
701
+ var Dimmer2 = class extends Kohost {
702
+ constructor(data) {
703
+ super(data);
704
+ }
705
+ static getActionDelta(old, _new) {
706
+ var _a;
707
+ const delta = {};
708
+ for (const action in _new) {
709
+ if ((_a = this.actionProperties) == null ? void 0 : _a.includes(action)) {
710
+ if (action === "level") {
711
+ const oldLevel = old[action];
712
+ const newLevel = _new[action];
713
+ delta[action] = newLevel - oldLevel / 100;
714
+ } else {
715
+ delta[action] = 1;
716
+ }
717
+ }
718
+ }
719
+ return delta;
720
+ }
721
+ };
722
+ Object.defineProperty(Dimmer2.prototype, "schema", {
723
+ value: schema
724
+ });
725
+ Object.defineProperty(Dimmer2.prototype, "validator", {
726
+ get: function() {
727
+ return validator;
728
+ }
729
+ });
730
+ Object.defineProperty(Dimmer2, "validProperties", {
731
+ value: Object.keys(schema.properties)
732
+ });
733
+ Object.defineProperty(Dimmer2, "actionProperties", {
734
+ value: ["level"]
735
+ });
736
+ module2.exports = Dimmer2;
737
+ }
738
+ });
739
+
740
+ // src/schemas/lock.json
741
+ var require_lock = __commonJS({
742
+ "src/schemas/lock.json"(exports2, module2) {
743
+ module2.exports = {
744
+ $schema: "http://json-schema.org/draft-07/schema",
745
+ $id: "https://api.kohost.app/schemas/v3/lock.json",
746
+ title: "Lock",
747
+ description: "Any smart lock",
748
+ type: "object",
749
+ properties: {
750
+ id: {
751
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
752
+ },
753
+ name: {
754
+ type: "string"
755
+ },
756
+ type: {
757
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
758
+ },
759
+ subType: {
760
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
761
+ },
762
+ supportedNotifications: {
763
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
764
+ },
765
+ notification: {
766
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
767
+ },
768
+ state: {
769
+ type: "string",
770
+ enum: ["locked", "unlocked"]
771
+ },
772
+ systemData: {
773
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
774
+ }
775
+ },
776
+ additionalProperties: false,
777
+ required: ["id", "type", "systemData", "state"]
778
+ };
779
+ }
780
+ });
781
+
782
+ // src/Models/lock.js
783
+ var require_lock2 = __commonJS({
784
+ "src/Models/lock.js"(exports2, module2) {
785
+ var schemas = require_schema();
786
+ var schema = require_lock();
787
+ var Kohost = require_kohost();
788
+ schemas.add(schema);
789
+ var validator = schemas.compile(schema);
790
+ var Lock2 = class extends Kohost {
791
+ constructor(data) {
792
+ super(data);
793
+ }
794
+ };
795
+ Object.defineProperty(Lock2.prototype, "schema", {
796
+ value: schema
797
+ });
798
+ Object.defineProperty(Lock2.prototype, "validator", {
799
+ get: function() {
800
+ return validator;
801
+ }
802
+ });
803
+ Object.defineProperty(Lock2, "validProperties", {
804
+ value: Object.keys(schema.properties)
805
+ });
806
+ Object.defineProperty(Lock2, "actionProperties", {
807
+ value: ["state"]
808
+ });
809
+ module2.exports = Lock2;
810
+ }
811
+ });
812
+
813
+ // src/schemas/thermostat.json
814
+ var require_thermostat = __commonJS({
815
+ "src/schemas/thermostat.json"(exports2, module2) {
816
+ module2.exports = {
817
+ $schema: "http://json-schema.org/draft-07/schema",
818
+ $id: "https://api.kohost.app/schemas/v3/thermostat.json",
819
+ title: "Thermostat",
820
+ description: "Any smart thermostat",
821
+ type: "object",
822
+ properties: {
823
+ id: {
824
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
825
+ },
826
+ name: {
827
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/name"
828
+ },
829
+ type: {
830
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type",
831
+ default: "thermostat"
832
+ },
833
+ subType: {
834
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
835
+ },
836
+ supportedNotifications: {
837
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
838
+ },
839
+ notification: {
840
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
841
+ },
842
+ currentTemperature: {
843
+ type: "number"
844
+ },
845
+ currentHumidity: {
846
+ type: "number",
847
+ minimum: 0,
848
+ maximum: 99
849
+ },
850
+ hvacMode: {
851
+ type: "string",
852
+ $ref: "#/properties/supportedHvacModes/items"
853
+ },
854
+ hvacState: {
855
+ type: "string",
856
+ enum: ["cooling", "heating", "off"]
857
+ },
858
+ fanMode: {
859
+ type: "string",
860
+ $ref: "#/properties/supportedFanModes/items"
861
+ },
862
+ fanState: {
863
+ type: "string",
864
+ enum: ["off", "low", "medium", "high"]
865
+ },
866
+ temperatureScale: {
867
+ type: "string",
868
+ enum: ["celsius", "fahrenheit"],
869
+ default: "fahrenheit"
870
+ },
871
+ humidityScale: {
872
+ type: ["string", "null"],
873
+ enum: ["absolute", "relative", null]
874
+ },
875
+ supportedHvacModes: {
876
+ type: "array",
877
+ uniqueItems: true,
878
+ minItems: 2,
879
+ items: {
880
+ enum: ["cool", "heat", "auto", "off"]
881
+ }
882
+ },
883
+ supportedFanModes: {
884
+ type: "array",
885
+ uniqueItems: true,
886
+ items: {
887
+ enum: ["auto", "low", "medium", "high", "off"]
888
+ }
889
+ },
890
+ setpoints: {
891
+ type: "object",
892
+ additionalProperties: false,
893
+ properties: {
894
+ cool: {
895
+ $ref: "#/$defs/setpoint"
896
+ },
897
+ heat: {
898
+ $ref: "#/$defs/setpoint"
899
+ },
900
+ auto: {
901
+ $ref: "#/$defs/setpoint"
902
+ }
903
+ }
904
+ },
905
+ batteryLevel: {
906
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/batteryLevel"
907
+ },
908
+ systemData: {
909
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData",
910
+ default: {}
911
+ }
912
+ },
913
+ additionalProperties: false,
914
+ $defs: {
915
+ setpoint: {
916
+ type: "object",
917
+ additionalProperties: false,
918
+ properties: {
919
+ value: {
920
+ $ref: "#/$defs/setpointValue"
921
+ },
922
+ min: {
923
+ $ref: "#/$defs/setpointMinMax"
924
+ },
925
+ max: {
926
+ $ref: "#/$defs/setpointMinMax"
927
+ }
928
+ }
929
+ },
930
+ setpointValue: {
931
+ type: "number",
932
+ minimum: 0,
933
+ maximum: 99
934
+ },
935
+ setpointMinMax: {
936
+ type: ["number", "null"],
937
+ minimum: 0,
938
+ maximum: 99
939
+ }
940
+ },
941
+ required: [
942
+ "id",
943
+ "type",
944
+ "systemData",
945
+ "hvacMode",
946
+ "fanMode",
947
+ "hvacState",
948
+ "fanState",
949
+ "setpoints",
950
+ "temperatureScale",
951
+ "supportedHvacModes",
952
+ "supportedFanModes"
953
+ ]
954
+ };
955
+ }
956
+ });
957
+
958
+ // src/Models/thermostat.js
959
+ var require_thermostat2 = __commonJS({
960
+ "src/Models/thermostat.js"(exports2, module2) {
961
+ var schemas = require_schema();
962
+ var schema = require_thermostat();
963
+ var Kohost = require_kohost();
964
+ schemas.add(schema);
965
+ var validator = schemas.compile(schema);
966
+ var Thermostat2 = class extends Kohost {
967
+ constructor(data) {
968
+ super(data);
969
+ }
970
+ toCelsius() {
971
+ if (this.temperatureScale === "fahrenheit")
972
+ this.currentTemperature = (this.currentTemperature - 32) * 5 / 9;
973
+ this.temperatureScale = "celsius";
974
+ return this.currentTemperature;
975
+ }
976
+ toFahrenheit() {
977
+ if (this.temperatureScale === "celsius")
978
+ this.currentTemperature = this.currentTemperature * 9 / 5 + 32;
979
+ this.temperatureScale = "fahrenheit";
980
+ return this.currentTemperature;
981
+ }
982
+ static getActionDelta(old, _new) {
983
+ const delta = {};
984
+ for (const action in _new) {
985
+ if (this.actionProperties.includes(action)) {
986
+ switch (action) {
987
+ case "hvacMode":
988
+ case "fanMode": {
989
+ if (old[action] !== _new[action])
990
+ delta[action] = 1;
991
+ break;
992
+ }
993
+ case "setpoints": {
994
+ const setpoints = _new[action];
995
+ for (const setpoint in setpoints) {
996
+ if (old[action][setpoint].value !== setpoints[setpoint].value) {
997
+ const min = setpoints[setpoint].min || old[action][setpoint].min;
998
+ const max = setpoints[setpoint].max || old[action][setpoint].max;
999
+ const oldValue = old[action][setpoint].value;
1000
+ const value = setpoints[setpoint].value;
1001
+ const percentChange = (value - oldValue) / (max - min);
1002
+ delta[`setpoints.${setpoint}`] = percentChange;
1003
+ }
1004
+ }
1005
+ }
1006
+ }
1007
+ }
1008
+ }
1009
+ return delta;
1010
+ }
1011
+ };
1012
+ Object.defineProperty(Thermostat2.prototype, "schema", {
1013
+ value: schema
1014
+ });
1015
+ Object.defineProperty(Thermostat2.prototype, "validator", {
1016
+ get: function() {
1017
+ return validator;
1018
+ }
1019
+ });
1020
+ Object.defineProperty(Thermostat2, "validProperties", {
1021
+ value: Object.keys(schema.properties)
1022
+ });
1023
+ Object.defineProperty(Thermostat2, "actionProperties", {
1024
+ value: ["hvacMode", "fanMode", "setpoints"]
1025
+ });
1026
+ module2.exports = Thermostat2;
1027
+ }
1028
+ });
1029
+
1030
+ // src/schemas/windowCovering.json
1031
+ var require_windowCovering = __commonJS({
1032
+ "src/schemas/windowCovering.json"(exports2, module2) {
1033
+ module2.exports = {
1034
+ $schema: "http://json-schema.org/draft-07/schema",
1035
+ $id: "https://api.kohost.app/schemas/v3/windowCovering.json",
1036
+ title: "Window Covering",
1037
+ description: "Any smart window covering",
1038
+ type: "object",
1039
+ properties: {
1040
+ id: {
1041
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1042
+ },
1043
+ type: {
1044
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1045
+ },
1046
+ subType: {
1047
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/subType"
1048
+ },
1049
+ supportedNotifications: {
1050
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1051
+ },
1052
+ notification: {
1053
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
1054
+ },
1055
+ position: {
1056
+ type: "number",
1057
+ minimum: 0,
1058
+ maximum: 100
1059
+ },
1060
+ systemData: {
1061
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
1062
+ }
1063
+ },
1064
+ additionalProperties: false,
1065
+ required: ["id", "type", "systemData", "position"]
1066
+ };
1067
+ }
1068
+ });
1069
+
1070
+ // src/Models/windowCovering.js
1071
+ var require_windowCovering2 = __commonJS({
1072
+ "src/Models/windowCovering.js"(exports2, module2) {
1073
+ var schemas = require_schema();
1074
+ var schema = require_windowCovering();
1075
+ var Kohost = require_kohost();
1076
+ schemas.add(schema);
1077
+ var validator = schemas.compile(schema);
1078
+ var WindowCovering2 = class extends Kohost {
1079
+ constructor(data) {
1080
+ super(data);
1081
+ }
1082
+ static getActionDelta(old, _new) {
1083
+ var _a;
1084
+ const delta = {};
1085
+ for (const action in _new) {
1086
+ if ((_a = this.actionProperties) == null ? void 0 : _a.includes(action)) {
1087
+ if (action === "position") {
1088
+ const oldPos = old[action];
1089
+ const newPos = _new[action];
1090
+ delta[action] = newPos - oldPos / 100;
1091
+ } else if (old[action] !== _new[action]) {
1092
+ delta[action] = 1;
1093
+ }
1094
+ }
1095
+ }
1096
+ return delta;
1097
+ }
1098
+ };
1099
+ Object.defineProperty(WindowCovering2.prototype, "schema", {
1100
+ value: schema
1101
+ });
1102
+ Object.defineProperty(WindowCovering2.prototype, "validator", {
1103
+ get: function() {
1104
+ return validator;
1105
+ }
1106
+ });
1107
+ Object.defineProperty(WindowCovering2, "validProperties", {
1108
+ value: Object.keys(schema.properties)
1109
+ });
1110
+ Object.defineProperty(WindowCovering2, "actionProperties", {
1111
+ value: ["position"]
1112
+ });
1113
+ module2.exports = WindowCovering2;
1114
+ }
1115
+ });
1116
+
1117
+ // src/schemas/identification.json
1118
+ var require_identification = __commonJS({
1119
+ "src/schemas/identification.json"(exports2, module2) {
1120
+ module2.exports = {
1121
+ $schema: "http://json-schema.org/draft-07/schema",
1122
+ $id: "https://api.kohost.app/schemas/v3/identification.json",
1123
+ title: "Identification",
1124
+ type: "object",
1125
+ required: ["type", "number", "expires"],
1126
+ properties: {
1127
+ id: {
1128
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
1129
+ },
1130
+ type: {
1131
+ type: "string",
1132
+ enum: ["driversLicense", "passport", "identityCard", "visa"]
1133
+ },
1134
+ number: {
1135
+ string: "string"
1136
+ },
1137
+ issued: {
1138
+ type: ["string", "object"],
1139
+ format: "date-time"
1140
+ },
1141
+ expires: {
1142
+ type: ["string", "object"],
1143
+ format: "date-time"
1144
+ },
1145
+ verified: {
1146
+ type: "boolean",
1147
+ default: false
1148
+ },
1149
+ matched: {
1150
+ type: "boolean",
1151
+ default: false
1152
+ },
1153
+ firstName: {
1154
+ type: "string"
1155
+ },
1156
+ lastName: {
1157
+ type: "string"
1158
+ },
1159
+ issuingCountry: {
1160
+ string: "string",
1161
+ minLength: 2,
1162
+ maxLength: 2
1163
+ },
1164
+ systemData: {
1165
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
1166
+ }
1167
+ }
1168
+ };
1169
+ }
1170
+ });
1171
+
1172
+ // src/Models/identification.js
1173
+ var require_identification2 = __commonJS({
1174
+ "src/Models/identification.js"(exports2, module2) {
1175
+ var schemas = require_schema();
1176
+ var schema = require_identification();
1177
+ var Kohost = require_kohost();
1178
+ schemas.add(schema);
1179
+ var validator = schemas.compile(schema);
1180
+ var Identification2 = class extends Kohost {
1181
+ constructor(data) {
1182
+ super(data);
1183
+ }
1184
+ get isExpired() {
1185
+ return new Date(this.expirationDate) < new Date();
1186
+ }
1187
+ };
1188
+ Object.defineProperty(Identification2.prototype, "schema", {
1189
+ value: schema
1190
+ });
1191
+ Object.defineProperty(Identification2.prototype, "validator", {
1192
+ get: function() {
1193
+ return validator;
1194
+ }
1195
+ });
1196
+ Object.defineProperty(Identification2, "validProperties", {
1197
+ value: Object.keys(schema.properties)
1198
+ });
1199
+ module2.exports = Identification2;
1200
+ }
1201
+ });
1202
+
1203
+ // src/schemas/user.json
1204
+ var require_user = __commonJS({
1205
+ "src/schemas/user.json"(exports2, module2) {
1206
+ module2.exports = {
1207
+ $schema: "http://json-schema.org/draft-07/schema",
1208
+ $id: "https://api.kohost.app/schemas/v3/user.json",
1209
+ title: "User",
1210
+ type: "object",
1211
+ required: ["active", "lastName", "roles"],
1212
+ properties: {
1213
+ id: {
1214
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
1215
+ },
1216
+ type: {
1217
+ type: "string",
1218
+ default: "user"
1219
+ },
1220
+ active: {
1221
+ type: "boolean",
1222
+ default: true
1223
+ },
1224
+ firstName: {
1225
+ type: "string"
1226
+ },
1227
+ lastName: {
1228
+ type: "string"
1229
+ },
1230
+ phone: {
1231
+ type: ["string", "null"],
1232
+ pattern: "^\\+[0-9]{1,14}$"
1233
+ },
1234
+ phoneVerified: {
1235
+ type: "boolean"
1236
+ },
1237
+ email: {
1238
+ type: ["string", "null"],
1239
+ format: "email"
1240
+ },
1241
+ emailVerified: {
1242
+ type: "boolean"
1243
+ },
1244
+ address: {
1245
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/address"
1246
+ },
1247
+ secretKey: {
1248
+ type: "string"
1249
+ },
1250
+ photo: {
1251
+ type: "string"
1252
+ },
1253
+ jobTitle: {
1254
+ type: "string"
1255
+ },
1256
+ dob: {
1257
+ type: "string"
1258
+ },
1259
+ gender: {
1260
+ type: "string",
1261
+ enum: ["male", "female"]
1262
+ },
1263
+ nationality: {
1264
+ type: "string",
1265
+ minLength: 2,
1266
+ maxLength: 2
1267
+ },
1268
+ notes: {
1269
+ type: "array",
1270
+ items: {
1271
+ type: "string"
1272
+ }
1273
+ },
1274
+ files: {
1275
+ type: "array",
1276
+ items: {
1277
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
1278
+ }
1279
+ },
1280
+ roles: {
1281
+ type: "array",
1282
+ items: {
1283
+ type: "string",
1284
+ enum: [
1285
+ "Guest",
1286
+ "Staff",
1287
+ "Faculty",
1288
+ "Student",
1289
+ "Visitor",
1290
+ "Manager",
1291
+ "Administrator",
1292
+ "SuperAdmin"
1293
+ ]
1294
+ }
1295
+ },
1296
+ identifications: {
1297
+ type: "array",
1298
+ items: {
1299
+ $ref: "https://api.kohost.app/schemas/v3/identification.json#"
1300
+ }
1301
+ },
1302
+ payments: {
1303
+ type: "array",
1304
+ items: {
1305
+ $ref: "https://api.kohost.app/schemas/v3/payment.json#"
1306
+ }
1307
+ },
1308
+ preferences: {
1309
+ type: "object",
1310
+ additionalProperties: false,
1311
+ properties: {
1312
+ notifications: {
1313
+ type: "array",
1314
+ items: {
1315
+ type: "string"
1316
+ },
1317
+ examples: [["roomControl", "marketing"]]
1318
+ },
1319
+ location: {
1320
+ title: "The location Schema",
1321
+ type: "boolean",
1322
+ default: false,
1323
+ examples: [true]
1324
+ }
1325
+ }
1326
+ },
1327
+ location: {
1328
+ type: "object",
1329
+ required: ["accuracy", "latitude", "longitude", "timestamp"],
1330
+ additionalProperties: false,
1331
+ properties: {
1332
+ accuracy: {
1333
+ type: ["number", "null"]
1334
+ },
1335
+ latitude: {
1336
+ type: ["number", "null"]
1337
+ },
1338
+ longitude: {
1339
+ type: ["number", "null"]
1340
+ },
1341
+ timestamp: {
1342
+ type: ["number", "null"]
1343
+ }
1344
+ }
1345
+ },
1346
+ registeredDevices: {
1347
+ type: "array",
1348
+ items: {
1349
+ type: "object",
1350
+ properties: {
1351
+ userAgent: {
1352
+ type: "string"
1353
+ },
1354
+ fingerPrint: {
1355
+ type: "string"
1356
+ },
1357
+ ip: {
1358
+ type: "string"
1359
+ },
1360
+ registeredAt: {
1361
+ type: "string",
1362
+ format: "date-time"
1363
+ },
1364
+ expiresAt: {
1365
+ type: "string",
1366
+ format: "date-time"
1367
+ }
1368
+ }
1369
+ }
1370
+ },
1371
+ createdAt: {
1372
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
1373
+ },
1374
+ updatedAt: {
1375
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
1376
+ },
1377
+ systemData: {
1378
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
1379
+ }
1380
+ }
1381
+ };
1382
+ }
1383
+ });
1384
+
1385
+ // src/schemas/payment.json
1386
+ var require_payment = __commonJS({
1387
+ "src/schemas/payment.json"(exports2, module2) {
1388
+ module2.exports = {
1389
+ $schema: "http://json-schema.org/draft-07/schema",
1390
+ $id: "https://api.kohost.app/schemas/v3/payment.json",
1391
+ title: "Payment",
1392
+ type: "object",
1393
+ required: ["type", "maskedNumber", "expires"],
1394
+ properties: {
1395
+ id: {
1396
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
1397
+ },
1398
+ type: {
1399
+ type: "string",
1400
+ enum: [
1401
+ "amex",
1402
+ "visa",
1403
+ "masterCard",
1404
+ "maestro",
1405
+ "discover",
1406
+ "diners",
1407
+ "jcb",
1408
+ "applePay",
1409
+ "alipay",
1410
+ "chinaUnionPay",
1411
+ "vpay"
1412
+ ]
1413
+ },
1414
+ maskedNumber: {
1415
+ string: "string"
1416
+ },
1417
+ issued: {
1418
+ type: ["string", "null"]
1419
+ },
1420
+ expires: {
1421
+ string: "string"
1422
+ },
1423
+ systemData: {
1424
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
1425
+ }
1426
+ }
1427
+ };
1428
+ }
1429
+ });
1430
+
1431
+ // src/Models/user.js
1432
+ var require_user2 = __commonJS({
1433
+ "src/Models/user.js"(exports2, module2) {
1434
+ var schemas = require_schema();
1435
+ var schema = require_user();
1436
+ var paymentSchema = require_payment();
1437
+ var Kohost = require_kohost();
1438
+ var { nanoid } = require("nanoid/async");
1439
+ schemas.add(paymentSchema);
1440
+ schemas.add(schema);
1441
+ var validator = schemas.compile(schema);
1442
+ var User2 = class extends Kohost {
1443
+ constructor(data) {
1444
+ super(data);
1445
+ }
1446
+ static validatePhone(phoneNumber) {
1447
+ const regex = /^\+?[1-9]\d{1,14}$/;
1448
+ return regex.test(phoneNumber);
1449
+ }
1450
+ static validateEmail(email) {
1451
+ const regex = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
1452
+ return regex.test(email);
1453
+ }
1454
+ static async generatePassword(len = 16) {
1455
+ return await nanoid(len);
1456
+ }
1457
+ };
1458
+ Object.defineProperty(User2.prototype, "schema", {
1459
+ value: schema
1460
+ });
1461
+ Object.defineProperty(User2.prototype, "validator", {
1462
+ get: function() {
1463
+ return validator;
1464
+ }
1465
+ });
1466
+ Object.defineProperty(User2, "validProperties", {
1467
+ value: Object.keys(schema.properties)
1468
+ });
1469
+ Object.defineProperty(User2.prototype, "fullName", {
1470
+ get: function() {
1471
+ return `${this.firstName} ${this.lastName}`;
1472
+ }
1473
+ });
1474
+ module2.exports = User2;
1475
+ }
1476
+ });
1477
+
1478
+ // src/schemas/courtesy.json
1479
+ var require_courtesy = __commonJS({
1480
+ "src/schemas/courtesy.json"(exports2, module2) {
1481
+ module2.exports = {
1482
+ $schema: "http://json-schema.org/draft-07/schema",
1483
+ $id: "https://api.kohost.app/schemas/v3/courtesy.json",
1484
+ title: "Courtesy",
1485
+ description: "Any smart courtesy system",
1486
+ type: "object",
1487
+ properties: {
1488
+ id: {
1489
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1490
+ },
1491
+ type: {
1492
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1493
+ },
1494
+ supportedNotifications: {
1495
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1496
+ },
1497
+ notification: {
1498
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
1499
+ },
1500
+ supportedStates: {
1501
+ type: "array",
1502
+ uniqueItems: true,
1503
+ items: {
1504
+ enum: ["privacy", "service", "none"]
1505
+ }
1506
+ },
1507
+ state: {
1508
+ type: "string",
1509
+ $ref: "#/properties/supportedStates/items"
1510
+ },
1511
+ systemData: {
1512
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
1513
+ }
1514
+ },
1515
+ additionalProperties: false,
1516
+ required: ["supportedStates", "state"]
1517
+ };
1518
+ }
1519
+ });
1520
+
1521
+ // src/Models/courtesy.js
1522
+ var require_courtesy2 = __commonJS({
1523
+ "src/Models/courtesy.js"(exports2, module2) {
1524
+ var schemas = require_schema();
1525
+ var schema = require_courtesy();
1526
+ var Kohost = require_kohost();
1527
+ schemas.add(schema);
1528
+ var validator = schemas.compile(schema);
1529
+ var Courtesy2 = class extends Kohost {
1530
+ constructor(data) {
1531
+ super(data);
1532
+ }
1533
+ };
1534
+ Object.defineProperty(Courtesy2.prototype, "schema", {
1535
+ value: schema
1536
+ });
1537
+ Object.defineProperty(Courtesy2.prototype, "validator", {
1538
+ get: function() {
1539
+ return validator;
1540
+ }
1541
+ });
1542
+ Object.defineProperty(Courtesy2, "validProperties", {
1543
+ value: Object.keys(schema.properties)
1544
+ });
1545
+ Object.defineProperty(Courtesy2, "actionProperties", {
1546
+ value: ["state"]
1547
+ });
1548
+ module2.exports = Courtesy2;
1549
+ }
1550
+ });
1551
+
1552
+ // src/schemas/camera.json
1553
+ var require_camera = __commonJS({
1554
+ "src/schemas/camera.json"(exports2, module2) {
1555
+ module2.exports = {
1556
+ $schema: "http://json-schema.org/draft-07/schema",
1557
+ $id: "https://api.kohost.app/schemas/v3/camera.json",
1558
+ title: "Camera",
1559
+ description: "Any smart camera",
1560
+ type: "object",
1561
+ properties: {
1562
+ id: {
1563
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1564
+ },
1565
+ type: {
1566
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1567
+ },
1568
+ supportedNotifications: {
1569
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1570
+ },
1571
+ notification: {
1572
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
1573
+ },
1574
+ streams: {
1575
+ type: "object",
1576
+ additionalProperties: false,
1577
+ properties: {
1578
+ origin: {
1579
+ type: ["string", "null"]
1580
+ },
1581
+ local: {
1582
+ type: ["string", "null"]
1583
+ },
1584
+ remote: {
1585
+ type: ["string", "null"]
1586
+ }
1587
+ }
1588
+ },
1589
+ systemData: {
1590
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
1591
+ }
1592
+ },
1593
+ additionalProperties: false,
1594
+ required: ["id", "type", "systemData", "streams"]
1595
+ };
1596
+ }
1597
+ });
1598
+
1599
+ // src/Models/camera.js
1600
+ var require_camera2 = __commonJS({
1601
+ "src/Models/camera.js"(exports2, module2) {
1602
+ var schemas = require_schema();
1603
+ var schema = require_camera();
1604
+ var Kohost = require_kohost();
1605
+ schemas.add(schema);
1606
+ var validator = schemas.compile(schema);
1607
+ var Camera2 = class extends Kohost {
1608
+ constructor(data) {
1609
+ super(data);
1610
+ }
1611
+ };
1612
+ Object.defineProperty(Camera2.prototype, "schema", {
1613
+ value: schema
1614
+ });
1615
+ Object.defineProperty(Camera2.prototype, "validator", {
1616
+ get: function() {
1617
+ return validator;
1618
+ }
1619
+ });
1620
+ Object.defineProperty(Camera2, "validProperties", {
1621
+ value: Object.keys(schema.properties)
1622
+ });
1623
+ module2.exports = Camera2;
1624
+ }
1625
+ });
1626
+
1627
+ // src/schemas/motionSensor.json
1628
+ var require_motionSensor = __commonJS({
1629
+ "src/schemas/motionSensor.json"(exports2, module2) {
1630
+ module2.exports = {
1631
+ $schema: "http://json-schema.org/draft-07/schema",
1632
+ $id: "https://api.kohost.app/schemas/v3/motionSensor.json",
1633
+ title: "Motion Sensor",
1634
+ description: "Any smart motion sensor",
1635
+ type: "object",
1636
+ properties: {
1637
+ id: {
1638
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1639
+ },
1640
+ type: {
1641
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1642
+ },
1643
+ systemData: {
1644
+ supportedNotifications: {
1645
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1646
+ },
1647
+ notification: {
1648
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
1649
+ },
1650
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
1651
+ }
1652
+ },
1653
+ additionalProperties: false,
1654
+ required: ["id", "type", "systemData"]
1655
+ };
1656
+ }
1657
+ });
1658
+
1659
+ // src/Models/motionSensor.js
1660
+ var require_motionSensor2 = __commonJS({
1661
+ "src/Models/motionSensor.js"(exports2, module2) {
1662
+ var schemas = require_schema();
1663
+ var schema = require_motionSensor();
1664
+ var Kohost = require_kohost();
1665
+ schemas.add(schema);
1666
+ var validator = schemas.compile(schema);
1667
+ var MotionSensor2 = class extends Kohost {
1668
+ constructor(data) {
1669
+ super(data);
1670
+ }
1671
+ };
1672
+ Object.defineProperty(MotionSensor2.prototype, "schema", {
1673
+ value: schema
1674
+ });
1675
+ Object.defineProperty(MotionSensor2.prototype, "validator", {
1676
+ get: function() {
1677
+ return validator;
1678
+ }
1679
+ });
1680
+ Object.defineProperty(MotionSensor2, "validProperties", {
1681
+ value: Object.keys(schema.properties)
1682
+ });
1683
+ module2.exports = MotionSensor2;
1684
+ }
1685
+ });
1686
+
1687
+ // src/schemas/mediaSource.json
1688
+ var require_mediaSource = __commonJS({
1689
+ "src/schemas/mediaSource.json"(exports2, module2) {
1690
+ module2.exports = {
1691
+ $schema: "http://json-schema.org/draft-07/schema",
1692
+ $id: "https://api.kohost.app/schemas/v3/mediaSource.json",
1693
+ title: "Media Source",
1694
+ description: "Any media source",
1695
+ type: "object",
1696
+ properties: {
1697
+ id: {
1698
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
1699
+ },
1700
+ type: {
1701
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
1702
+ },
1703
+ subType: {
1704
+ type: "string",
1705
+ enum: [
1706
+ "tv",
1707
+ "dvr",
1708
+ "appleTv",
1709
+ "discPlayer",
1710
+ "mediaPlayer",
1711
+ "uncontrolledDevice"
1712
+ ]
1713
+ },
1714
+ audio: {
1715
+ type: "boolean"
1716
+ },
1717
+ video: {
1718
+ type: "boolean"
1719
+ },
1720
+ powerFeedback: {
1721
+ type: "boolean"
1722
+ },
1723
+ volumeFeedback: {
1724
+ type: "boolean"
1725
+ },
1726
+ command: {
1727
+ type: ["string", "null"],
1728
+ enum: [
1729
+ "mute",
1730
+ "volumeUp",
1731
+ "volumeDown",
1732
+ "channelUp",
1733
+ "channelDown",
1734
+ "number0",
1735
+ "number1",
1736
+ "number2",
1737
+ "number3",
1738
+ "number4",
1739
+ "number5",
1740
+ "number6",
1741
+ "number7",
1742
+ "number8",
1743
+ "number9",
1744
+ "lastChannel",
1745
+ "display",
1746
+ "favoriteChannel",
1747
+ "play",
1748
+ "stop",
1749
+ "pause",
1750
+ "fastForward",
1751
+ "rewind",
1752
+ "instantReplay",
1753
+ "record",
1754
+ "ac3",
1755
+ "pvrMenu",
1756
+ "guide",
1757
+ "menu",
1758
+ "menuUp",
1759
+ "menuDown",
1760
+ "menuLeft",
1761
+ "menuRight",
1762
+ "pageUp",
1763
+ "pageDown",
1764
+ "select",
1765
+ "exit",
1766
+ "input",
1767
+ "power",
1768
+ "enterChannel",
1769
+ "number10",
1770
+ "number11",
1771
+ "number12",
1772
+ "number13",
1773
+ "number14",
1774
+ "number15",
1775
+ "number16",
1776
+ "number10Plus",
1777
+ "number20Plus",
1778
+ "number100",
1779
+ "dash",
1780
+ "threeChan",
1781
+ "threeD",
1782
+ "sixChan",
1783
+ "a",
1784
+ "add",
1785
+ "alarm",
1786
+ "am",
1787
+ "analog",
1788
+ "angle",
1789
+ "antenna",
1790
+ "antennaEast",
1791
+ "antennaWest",
1792
+ "aspect",
1793
+ "audio1",
1794
+ "audio2",
1795
+ "audio3",
1796
+ "audioDumming",
1797
+ "audioLevelDown",
1798
+ "audioLevelUp",
1799
+ "b",
1800
+ "back",
1801
+ "c",
1802
+ "component1",
1803
+ "component2",
1804
+ "component3",
1805
+ "d",
1806
+ "home",
1807
+ "list",
1808
+ "liveTv",
1809
+ "discreteInputCable",
1810
+ "powerOff",
1811
+ "powerOn",
1812
+ "setupMenu",
1813
+ "skipForward",
1814
+ "skipReverse",
1815
+ "video1",
1816
+ "video2",
1817
+ "video3",
1818
+ "video4",
1819
+ "video5",
1820
+ "details",
1821
+ "hdmi1",
1822
+ "hdmi2",
1823
+ "hdmi3",
1824
+ "cecDeviceList",
1825
+ "mtsSap"
1826
+ ]
1827
+ },
1828
+ supportedNotifications: {
1829
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
1830
+ },
1831
+ notification: {
1832
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
1833
+ },
1834
+ systemData: {
1835
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
1836
+ }
1837
+ },
1838
+ additionalProperties: false,
1839
+ required: ["id", "type", "systemData", "audio", "video"]
1840
+ };
1841
+ }
1842
+ });
1843
+
1844
+ // src/Models/mediaSource.js
1845
+ var require_mediaSource2 = __commonJS({
1846
+ "src/Models/mediaSource.js"(exports2, module2) {
1847
+ var schemas = require_schema();
1848
+ var schema = require_mediaSource();
1849
+ var Kohost = require_kohost();
1850
+ schemas.add(schema);
1851
+ var validator = schemas.compile(schema);
1852
+ var MediaSource2 = class extends Kohost {
1853
+ constructor(data) {
1854
+ super(data);
1855
+ }
1856
+ };
1857
+ Object.defineProperty(MediaSource2.prototype, "schema", {
1858
+ value: schema
1859
+ });
1860
+ Object.defineProperty(MediaSource2.prototype, "validator", {
1861
+ get: function() {
1862
+ return validator;
1863
+ }
1864
+ });
1865
+ Object.defineProperty(MediaSource2, "validProperties", {
1866
+ value: Object.keys(schema.properties)
1867
+ });
1868
+ module2.exports = MediaSource2;
1869
+ }
1870
+ });
1871
+
1872
+ // src/schemas/room.json
1873
+ var require_room = __commonJS({
1874
+ "src/schemas/room.json"(exports2, module2) {
1875
+ module2.exports = {
1876
+ $schema: "http://json-schema.org/draft-07/schema",
1877
+ $id: "https://api.kohost.app/schemas/v3/room.json",
1878
+ title: "Room",
1879
+ description: "A room represents a physical space of controllable IoT devices",
1880
+ type: "object",
1881
+ properties: {
1882
+ id: {
1883
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
1884
+ },
1885
+ name: {
1886
+ type: "string"
1887
+ },
1888
+ floor: {
1889
+ type: "string"
1890
+ },
1891
+ dimmers: {
1892
+ type: "array",
1893
+ default: [],
1894
+ items: {
1895
+ $ref: "https://api.kohost.app/schemas/v3/dimmer.json"
1896
+ }
1897
+ },
1898
+ switches: {
1899
+ type: "array",
1900
+ default: [],
1901
+ items: {
1902
+ $ref: "https://api.kohost.app/schemas/v3/switch.json"
1903
+ }
1904
+ },
1905
+ thermostats: {
1906
+ type: "array",
1907
+ default: [],
1908
+ items: {
1909
+ $ref: "https://api.kohost.app/schemas/v3/thermostat.json"
1910
+ }
1911
+ },
1912
+ locks: {
1913
+ type: "array",
1914
+ default: [],
1915
+ items: {
1916
+ $ref: "https://api.kohost.app/schemas/v3/lock.json"
1917
+ }
1918
+ },
1919
+ windowCoverings: {
1920
+ type: "array",
1921
+ default: [],
1922
+ items: {
1923
+ $ref: "https://api.kohost.app/schemas/v3/windowCovering.json"
1924
+ }
1925
+ },
1926
+ courtesy: {
1927
+ type: "array",
1928
+ default: [],
1929
+ items: {
1930
+ $ref: "https://api.kohost.app/schemas/v3/courtesy.json"
1931
+ }
1932
+ },
1933
+ cameras: {
1934
+ type: "array",
1935
+ default: [],
1936
+ items: {
1937
+ $ref: "https://api.kohost.app/schemas/v3/camera.json"
1938
+ }
1939
+ },
1940
+ sources: {
1941
+ type: "array",
1942
+ default: [],
1943
+ items: {
1944
+ $ref: "https://api.kohost.app/schemas/v3/mediaSource.json"
1945
+ }
1946
+ },
1947
+ motionSensors: {
1948
+ type: "array",
1949
+ default: [],
1950
+ items: {
1951
+ $ref: "https://api.kohost.app/schemas/v3/motionSensor.json"
1952
+ }
1953
+ },
1954
+ alarms: {
1955
+ type: "array",
1956
+ default: [],
1957
+ items: {
1958
+ $ref: "https://api.kohost.app/schemas/v3/alarm.json"
1959
+ }
1960
+ },
1961
+ media: {
1962
+ type: "object",
1963
+ additionalProperties: false,
1964
+ default: {
1965
+ volume: 0,
1966
+ currentSource: null
1967
+ },
1968
+ properties: {
1969
+ volume: {
1970
+ type: "number",
1971
+ minimum: 0,
1972
+ maximum: 100
1973
+ },
1974
+ currentSource: {
1975
+ type: ["string", "null"]
1976
+ }
1977
+ }
1978
+ },
1979
+ scenes: {
1980
+ type: "array",
1981
+ default: [],
1982
+ items: {
1983
+ description: "A list of scene IDs for later population, or entire scene objects",
1984
+ oneOf: [
1985
+ {
1986
+ $ref: "https://api.kohost.app/schemas/v3/scene.json"
1987
+ },
1988
+ {
1989
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
1990
+ }
1991
+ ]
1992
+ }
1993
+ },
1994
+ occupiedAt: {
1995
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
1996
+ },
1997
+ createdAt: {
1998
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
1999
+ },
2000
+ updatedAt: {
2001
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
2002
+ }
2003
+ },
2004
+ additionalProperties: false
2005
+ };
2006
+ }
2007
+ });
2008
+
2009
+ // src/schemas/scene.json
2010
+ var require_scene = __commonJS({
2011
+ "src/schemas/scene.json"(exports2, module2) {
2012
+ module2.exports = {
2013
+ $schema: "http://json-schema.org/draft-07/schema",
2014
+ $id: "https://api.kohost.app/schemas/v3/scene.json",
2015
+ title: "Scene",
2016
+ description: "A room represents a physical space of controllable IoT devices",
2017
+ type: "object",
2018
+ properties: {
2019
+ id: {
2020
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2021
+ },
2022
+ name: {
2023
+ type: "string"
2024
+ },
2025
+ devices: {
2026
+ type: "object",
2027
+ properties: {
2028
+ switches: {
2029
+ type: "array",
2030
+ items: {
2031
+ type: "object",
2032
+ properties: {
2033
+ id: {
2034
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2035
+ },
2036
+ state: {
2037
+ $ref: "https://api.kohost.app/schemas/v3/switch.json#/properties/state"
2038
+ }
2039
+ },
2040
+ default: []
2041
+ }
2042
+ },
2043
+ dimmers: {
2044
+ type: "array",
2045
+ items: {
2046
+ type: "object",
2047
+ properties: {
2048
+ id: {
2049
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2050
+ },
2051
+ level: {
2052
+ $ref: "https://api.kohost.app/schemas/v3/dimmer.json#/properties/level"
2053
+ }
2054
+ }
2055
+ },
2056
+ default: []
2057
+ },
2058
+ windowCoverings: {
2059
+ type: "array",
2060
+ items: {
2061
+ type: "object",
2062
+ properties: {
2063
+ id: {
2064
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2065
+ },
2066
+ position: {
2067
+ $ref: "https://api.kohost.app/schemas/v3/windowCovering.json#/properties/position"
2068
+ }
2069
+ }
2070
+ },
2071
+ default: []
2072
+ },
2073
+ thermostats: {
2074
+ type: "array",
2075
+ items: {
2076
+ type: "object",
2077
+ properties: {
2078
+ id: {
2079
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2080
+ },
2081
+ hvacMode: {
2082
+ $ref: "https://api.kohost.app/schemas/v3/thermostat.json#/properties/hvacMode"
2083
+ },
2084
+ setpoints: {
2085
+ $ref: "https://api.kohost.app/schemas/v3/thermostat.json#/properties/setpoints"
2086
+ },
2087
+ fanMode: {
2088
+ $ref: "https://api.kohost.app/schemas/v3/thermostat.json#/properties/fanMode"
2089
+ }
2090
+ }
2091
+ },
2092
+ default: []
2093
+ },
2094
+ media: {
2095
+ type: "array",
2096
+ items: {
2097
+ type: "object",
2098
+ properties: {
2099
+ id: {
2100
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2101
+ },
2102
+ volume: {
2103
+ type: "number",
2104
+ minimum: 0,
2105
+ maximum: 100
2106
+ },
2107
+ commands: {
2108
+ type: "array",
2109
+ items: {
2110
+ type: "string"
2111
+ }
2112
+ }
2113
+ }
2114
+ }
2115
+ }
2116
+ },
2117
+ additionalProperties: false
2118
+ },
2119
+ isDefault: {
2120
+ type: "boolean",
2121
+ default: false
2122
+ },
2123
+ showOnUi: {
2124
+ type: "boolean",
2125
+ default: true
2126
+ }
2127
+ },
2128
+ additionalProperties: false
2129
+ };
2130
+ }
2131
+ });
2132
+
2133
+ // src/Models/scene.js
2134
+ var require_scene2 = __commonJS({
2135
+ "src/Models/scene.js"(exports2, module2) {
2136
+ var schemas = require_schema();
2137
+ var schema = require_scene();
2138
+ var Kohost = require_kohost();
2139
+ schemas.add(schema);
2140
+ var validator = schemas.compile(schema);
2141
+ var Scene2 = class extends Kohost {
2142
+ constructor(data) {
2143
+ super(data);
2144
+ }
2145
+ };
2146
+ Object.defineProperty(Scene2.prototype, "schema", {
2147
+ value: schema
2148
+ });
2149
+ Object.defineProperty(Scene2.prototype, "validator", {
2150
+ get: function() {
2151
+ return validator;
2152
+ }
2153
+ });
2154
+ Object.defineProperty(Scene2, "validProperties", {
2155
+ value: Object.keys(schema.properties)
2156
+ });
2157
+ module2.exports = Scene2;
2158
+ }
2159
+ });
2160
+
2161
+ // src/Models/room.js
2162
+ var require_room2 = __commonJS({
2163
+ "src/Models/room.js"(exports2, module2) {
2164
+ var schemas = require_schema();
2165
+ var schema = require_room();
2166
+ var Kohost = require_kohost();
2167
+ var cloneDeep = require("lodash.clonedeep");
2168
+ var Switch2 = require_switch2();
2169
+ var Dimmer2 = require_dimmer2();
2170
+ var Thermostat2 = require_thermostat2();
2171
+ var Lock2 = require_lock2();
2172
+ var WindowCovering2 = require_windowCovering2();
2173
+ var Courtesy2 = require_courtesy2();
2174
+ var Camera2 = require_camera2();
2175
+ var Alarm2 = require_alarm2();
2176
+ var Source = require_mediaSource2();
2177
+ var MotionSensor2 = require_motionSensor2();
2178
+ var Scene2 = require_scene2();
2179
+ schemas.add(schema);
2180
+ var validator = schemas.compile(schema);
2181
+ var Room2 = class extends Kohost {
2182
+ constructor(data) {
2183
+ const roomData = mapRoomData(data);
2184
+ super(roomData);
2185
+ }
2186
+ static getDevicePath(type) {
2187
+ const validTypes = [
2188
+ "dimmer",
2189
+ "switch",
2190
+ "thermostat",
2191
+ "lock",
2192
+ "windowCovering",
2193
+ "courtesy",
2194
+ "camera",
2195
+ "source",
2196
+ "motionSensor",
2197
+ "alarm"
2198
+ ];
2199
+ if (!validTypes.includes(type))
2200
+ throw new Error("Invalid device type:" + type);
2201
+ switch (type) {
2202
+ case "courtesy":
2203
+ return type;
2204
+ case "switch":
2205
+ return "switches";
2206
+ default:
2207
+ return `${type}s`;
2208
+ }
2209
+ }
2210
+ get hasDimmer() {
2211
+ var _a;
2212
+ return ((_a = this.dimmers) == null ? void 0 : _a.length) > 0;
2213
+ }
2214
+ get hasSwitch() {
2215
+ var _a;
2216
+ return ((_a = this.switches) == null ? void 0 : _a.length) > 0;
2217
+ }
2218
+ get hasWindowCovering() {
2219
+ var _a;
2220
+ return ((_a = this.windowCoverings) == null ? void 0 : _a.length) > 0;
2221
+ }
2222
+ get hasThermostat() {
2223
+ var _a;
2224
+ return ((_a = this.thermostats) == null ? void 0 : _a.length) > 0;
2225
+ }
2226
+ get hasLock() {
2227
+ var _a;
2228
+ return ((_a = this.locks) == null ? void 0 : _a.length) > 0;
2229
+ }
2230
+ get hasCourtesy() {
2231
+ var _a;
2232
+ return ((_a = this.courtesy) == null ? void 0 : _a.length) > 0;
2233
+ }
2234
+ get hasCamera() {
2235
+ var _a;
2236
+ return ((_a = this.cameras) == null ? void 0 : _a.length) > 0;
2237
+ }
2238
+ get hasAlarm() {
2239
+ var _a;
2240
+ return ((_a = this.alarms) == null ? void 0 : _a.length) > 0;
2241
+ }
2242
+ get hasMedia() {
2243
+ var _a;
2244
+ return ((_a = this.sources) == null ? void 0 : _a.length) > 0;
2245
+ }
2246
+ get occupied() {
2247
+ const now = new Date();
2248
+ const lastOccupied = new Date(this.occupiedAt);
2249
+ const diff = now - lastOccupied;
2250
+ return diff < 60 * 60 * 1e3;
2251
+ }
2252
+ };
2253
+ Object.defineProperty(Room2.prototype, "schema", {
2254
+ value: schema
2255
+ });
2256
+ Object.defineProperty(Room2.prototype, "validator", {
2257
+ get: function() {
2258
+ return validator;
2259
+ }
2260
+ });
2261
+ Object.defineProperty(Room2, "validProperties", {
2262
+ value: Object.keys(schema.properties)
2263
+ });
2264
+ function mapRoomData(data) {
2265
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k;
2266
+ const roomData = cloneDeep(data);
2267
+ (_a = roomData.dimmers) == null ? void 0 : _a.map((dimmer) => {
2268
+ if (dimmer instanceof Dimmer2)
2269
+ return dimmer;
2270
+ else
2271
+ return new Dimmer2(dimmer);
2272
+ });
2273
+ (_b = roomData.switches) == null ? void 0 : _b.map((switch_) => {
2274
+ if (switch_ instanceof Switch2)
2275
+ return switch_;
2276
+ else
2277
+ return new Switch2(switch_);
2278
+ });
2279
+ (_c = roomData.windowCoverings) == null ? void 0 : _c.map((windowCovering) => {
2280
+ if (windowCovering instanceof WindowCovering2)
2281
+ return windowCovering;
2282
+ else
2283
+ return new WindowCovering2(windowCovering);
2284
+ });
2285
+ (_d = roomData.thermostats) == null ? void 0 : _d.map((thermostat) => {
2286
+ if (thermostat instanceof Thermostat2)
2287
+ return thermostat;
2288
+ else
2289
+ return new Thermostat2(thermostat);
2290
+ });
2291
+ (_e = roomData.locks) == null ? void 0 : _e.map((lock) => {
2292
+ if (lock instanceof Lock2)
2293
+ return lock;
2294
+ else
2295
+ return new Lock2(lock);
2296
+ });
2297
+ (_f = roomData.courtesy) == null ? void 0 : _f.map((courtesy) => {
2298
+ if (courtesy instanceof Courtesy2)
2299
+ return courtesy;
2300
+ else
2301
+ return new Courtesy2(courtesy);
2302
+ });
2303
+ (_g = roomData.sources) == null ? void 0 : _g.map((source) => {
2304
+ if (source instanceof Source)
2305
+ return source;
2306
+ else
2307
+ return new Source(source);
2308
+ });
2309
+ (_h = roomData.cameras) == null ? void 0 : _h.map((camera) => {
2310
+ if (camera instanceof Camera2)
2311
+ return camera;
2312
+ else
2313
+ return new Camera2(camera);
2314
+ });
2315
+ (_i = roomData.alarms) == null ? void 0 : _i.map((alarm) => {
2316
+ if (alarm instanceof Alarm2)
2317
+ return alarm;
2318
+ else
2319
+ return new Alarm2(alarm);
2320
+ });
2321
+ (_j = roomData.motionSensors) == null ? void 0 : _j.map((motionSensor) => {
2322
+ if (motionSensor instanceof MotionSensor2)
2323
+ return motionSensor;
2324
+ else
2325
+ return new MotionSensor2(motionSensor);
2326
+ });
2327
+ (_k = roomData.scenes) == null ? void 0 : _k.map((scene) => {
2328
+ if (scene instanceof Scene2)
2329
+ return scene;
2330
+ else
2331
+ return new Scene2(scene);
2332
+ });
2333
+ return roomData;
2334
+ }
2335
+ module2.exports = Room2;
2336
+ }
2337
+ });
2338
+
2339
+ // src/schemas/reservation.json
2340
+ var require_reservation = __commonJS({
2341
+ "src/schemas/reservation.json"(exports2, module2) {
2342
+ module2.exports = {
2343
+ $schema: "http://json-schema.org/draft-07/schema",
2344
+ $id: "https://api.kohost.app/schemas/v3/reservation.json",
2345
+ title: "Reservation",
2346
+ type: "object",
2347
+ required: ["type", "status", "checkInDateTime", "checkOutDateTime"],
2348
+ properties: {
2349
+ id: {
2350
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2351
+ },
2352
+ primaryGuest: {
2353
+ type: "string"
2354
+ },
2355
+ type: {
2356
+ type: "string"
2357
+ },
2358
+ sharedGuests: {
2359
+ type: "array",
2360
+ items: {
2361
+ type: "string"
2362
+ }
2363
+ },
2364
+ space: {
2365
+ type: "string"
2366
+ },
2367
+ status: {
2368
+ type: "string",
2369
+ enum: ["reserved", "checkedIn", "checkedOut", "cancelled", "noShow", "enquired", "requested", "optional"],
2370
+ description: " reserved - confirmed by both parties, before check-in\n checkedIn - checked in\n checkedOut - checked out\n cancelled - Cancelled\n noShow - No show\n enquired - Confirmed neither by the customer nor enterprise\n requested - Confirmed by the customer but not the enterprise (waitlist)\n optional - Confirmed by the enterprise but not the customer (holding)"
2371
+ },
2372
+ confirmationNumber: {
2373
+ type: "string"
2374
+ },
2375
+ checkInDateTime: {
2376
+ type: ["string", "object"],
2377
+ format: "date-time"
2378
+ },
2379
+ checkOutDateTime: {
2380
+ type: ["string", "object"],
2381
+ format: "date-time"
2382
+ },
2383
+ adultCount: {
2384
+ type: "number",
2385
+ default: 1,
2386
+ minimum: 1
2387
+ },
2388
+ childCount: {
2389
+ type: "number",
2390
+ default: 0
2391
+ },
2392
+ rateSuppressed: {
2393
+ type: "boolean"
2394
+ },
2395
+ payment: {
2396
+ type: "string"
2397
+ },
2398
+ company: {
2399
+ type: "string"
2400
+ },
2401
+ travelAgent: {
2402
+ type: "string"
2403
+ },
2404
+ systemData: {
2405
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
2406
+ },
2407
+ metadata: {
2408
+ ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/metadata"
2409
+ }
2410
+ }
2411
+ };
2412
+ }
2413
+ });
2414
+
2415
+ // src/Models/reservation.js
2416
+ var require_reservation2 = __commonJS({
2417
+ "src/Models/reservation.js"(exports2, module2) {
2418
+ var schemas = require_schema();
2419
+ var schema = require_reservation();
2420
+ var Kohost = require_kohost();
2421
+ schemas.add(schema);
2422
+ var validator = schemas.compile(schema);
2423
+ var Reservation2 = class extends Kohost {
2424
+ constructor(data) {
2425
+ super(data);
2426
+ }
2427
+ get peopleCount() {
2428
+ return this.adultCount + this.childCount;
2429
+ }
2430
+ get hasPayment() {
2431
+ var _a;
2432
+ return ((_a = this.paymentId) == null ? void 0 : _a.length) > 0;
2433
+ }
2434
+ range(tz) {
2435
+ const start = new Date(this.checkInDateTime);
2436
+ const end = new Date(this.checkOutDateTime);
2437
+ if (start.getMonth() === end.getMonth() && start.getFullYear() === end.getFullYear()) {
2438
+ return `${start.toLocaleString("default", {
2439
+ month: "short",
2440
+ timeZone: tz
2441
+ })} ${start.toLocaleString("default", {
2442
+ timeZone: tz,
2443
+ day: "numeric"
2444
+ })}-${end.toLocaleString("default", {
2445
+ timeZone: tz,
2446
+ day: "numeric"
2447
+ })}`;
2448
+ }
2449
+ return `${start.toLocaleString("default", {
2450
+ month: "short",
2451
+ timeZone: tz
2452
+ })} ${start.getDate()} - ${end.toLocaleString("default", {
2453
+ month: "short",
2454
+ timeZone: tz
2455
+ })} ${end.getDate()}`;
2456
+ }
2457
+ checkInTime(tz) {
2458
+ return new Date(this.checkInDateTime).toLocaleString("default", {
2459
+ hour: "numeric",
2460
+ minute: "numeric",
2461
+ timeZone: tz
2462
+ });
2463
+ }
2464
+ checkOutTime(tz) {
2465
+ return new Date(this.checkOutDateTime).toLocaleString("default", {
2466
+ hour: "numeric",
2467
+ minute: "numeric",
2468
+ timeZone: tz
2469
+ });
2470
+ }
2471
+ };
2472
+ Object.defineProperty(Reservation2.prototype, "schema", {
2473
+ value: schema
2474
+ });
2475
+ Object.defineProperty(Reservation2.prototype, "validator", {
2476
+ get: function() {
2477
+ return validator;
2478
+ }
2479
+ });
2480
+ Object.defineProperty(Reservation2, "validProperties", {
2481
+ value: Object.keys(schema.properties)
2482
+ });
2483
+ module2.exports = Reservation2;
2484
+ }
2485
+ });
2486
+
2487
+ // src/schemas/application.json
2488
+ var require_application = __commonJS({
2489
+ "src/schemas/application.json"(exports2, module2) {
2490
+ module2.exports = {
2491
+ $schema: "http://json-schema.org/draft-07/schema",
2492
+ $id: "https://api.kohost.app/schemas/v3/application.json",
2493
+ title: "Application",
2494
+ type: "object",
2495
+ required: ["id", "active", "name", "publicKey", "hashedPrivateKey"],
2496
+ properties: {
2497
+ id: {
2498
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2499
+ },
2500
+ active: {
2501
+ type: "boolean"
2502
+ },
2503
+ name: {
2504
+ type: "string"
2505
+ },
2506
+ publicKey: {
2507
+ type: "string"
2508
+ },
2509
+ hashedPrivateKey: {
2510
+ type: "string"
2511
+ }
2512
+ }
2513
+ };
2514
+ }
2515
+ });
2516
+
2517
+ // src/Models/application.js
2518
+ var require_application2 = __commonJS({
2519
+ "src/Models/application.js"(exports2, module2) {
2520
+ var schemas = require_schema();
2521
+ var schema = require_application();
2522
+ var Kohost = require_kohost();
2523
+ schemas.add(schema);
2524
+ var validator = schemas.compile(schema);
2525
+ var Application2 = class extends Kohost {
2526
+ constructor(data) {
2527
+ super(data);
2528
+ }
2529
+ };
2530
+ Object.defineProperty(Application2.prototype, "schema", {
2531
+ value: schema
2532
+ });
2533
+ Object.defineProperty(Application2.prototype, "validator", {
2534
+ get: function() {
2535
+ return validator;
2536
+ }
2537
+ });
2538
+ Object.defineProperty(Application2, "validProperties", {
2539
+ value: Object.keys(schema.properties)
2540
+ });
2541
+ module2.exports = Application2;
2542
+ }
2543
+ });
2544
+
2545
+ // src/schemas/space.json
2546
+ var require_space = __commonJS({
2547
+ "src/schemas/space.json"(exports2, module2) {
2548
+ module2.exports = {
2549
+ $schema: "http://json-schema.org/draft-07/schema",
2550
+ $id: "https://api.kohost.app/schemas/v3/space.json",
2551
+ title: "Space",
2552
+ type: "object",
2553
+ properties: {
2554
+ id: {
2555
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2556
+ },
2557
+ name: {
2558
+ type: "string",
2559
+ minLength: 1
2560
+ },
2561
+ type: {
2562
+ type: ["string"],
2563
+ enum: [
2564
+ "classRoom",
2565
+ "hotelRoom",
2566
+ "office",
2567
+ "building",
2568
+ "commonArea",
2569
+ "other"
2570
+ ]
2571
+ },
2572
+ rooms: {
2573
+ type: "array",
2574
+ items: {
2575
+ type: "string"
2576
+ }
2577
+ },
2578
+ subGroups: {
2579
+ type: "array",
2580
+ items: {
2581
+ type: "string"
2582
+ }
2583
+ },
2584
+ eco: {
2585
+ type: "object",
2586
+ additionalProperties: false,
2587
+ default: {
2588
+ active: false,
2589
+ allowed: false
2590
+ },
2591
+ properties: {
2592
+ active: {
2593
+ type: "boolean",
2594
+ default: false
2595
+ },
2596
+ activatedAt: {
2597
+ type: "string",
2598
+ format: "date-time"
2599
+ },
2600
+ allowed: {
2601
+ type: "boolean",
2602
+ default: false
2603
+ }
2604
+ }
2605
+ },
2606
+ features: {
2607
+ type: "array",
2608
+ items: {
2609
+ type: "string"
2610
+ }
2611
+ },
2612
+ maximumOccupancy: {
2613
+ type: "number",
2614
+ minimum: 1
2615
+ },
2616
+ housekeepingStatus: {
2617
+ type: "string",
2618
+ enum: ["clean", "dirty", "inspected", "pickup"]
2619
+ },
2620
+ serviceStatus: {
2621
+ type: "string",
2622
+ enum: ["inService", "outOfOrder", "outOfService"]
2623
+ },
2624
+ systemData: {
2625
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
2626
+ }
2627
+ },
2628
+ if: {
2629
+ properties: { type: { const: "hotelRoom" } }
2630
+ },
2631
+ then: {
2632
+ required: [
2633
+ "name",
2634
+ "type",
2635
+ "features",
2636
+ "maximumOccupancy",
2637
+ "housekeepingStatus",
2638
+ "serviceStatus"
2639
+ ],
2640
+ properties: {
2641
+ features: {
2642
+ default: []
2643
+ },
2644
+ maximumOccupancy: {
2645
+ default: 2
2646
+ },
2647
+ housekeepingStatus: {
2648
+ default: "dirty"
2649
+ },
2650
+ serviceStatus: {
2651
+ default: "inService"
2652
+ }
2653
+ }
2654
+ },
2655
+ else: {
2656
+ required: ["name", "type"]
2657
+ }
2658
+ };
2659
+ }
2660
+ });
2661
+
2662
+ // src/Models/space.js
2663
+ var require_space2 = __commonJS({
2664
+ "src/Models/space.js"(exports2, module2) {
2665
+ var schemas = require_schema();
2666
+ var schema = require_space();
2667
+ var Kohost = require_kohost();
2668
+ var cloneDeep = require("lodash.clonedeep");
2669
+ var Room2 = require_room2();
2670
+ schemas.add(schema);
2671
+ var validator = schemas.compile(schema);
2672
+ var Space2 = class extends Kohost {
2673
+ constructor(data) {
2674
+ const spaceData = mapSpaceData(data);
2675
+ super(spaceData);
2676
+ }
2677
+ get floor() {
2678
+ const floors = /* @__PURE__ */ new Set();
2679
+ this.room.forEach((room) => {
2680
+ if (room.floor)
2681
+ floors.add(room.floor);
2682
+ });
2683
+ return floors.size == 1 ? [...floors][0] : void 0;
2684
+ }
2685
+ get hasDimmer() {
2686
+ return this.rooms.some((room) => room.hasDimmer);
2687
+ }
2688
+ get hasSwitch() {
2689
+ return this.rooms.some((room) => room.hasSwitch);
2690
+ }
2691
+ get hasWindowCovering() {
2692
+ return this.rooms.some((room) => room.hasWindowCovering);
2693
+ }
2694
+ get hasThermostat() {
2695
+ return this.rooms.some((room) => room.hasThermostat);
2696
+ }
2697
+ get hasLock() {
2698
+ return this.rooms.some((room) => room.hasLock);
2699
+ }
2700
+ get hasCourtesy() {
2701
+ return this.rooms.some((room) => room.hasCourtesy);
2702
+ }
2703
+ get hasSceneController() {
2704
+ return this.rooms.some((room) => room.hasSceneController);
2705
+ }
2706
+ get hasCamera() {
2707
+ return this.rooms.some((room) => room.hasCamera);
2708
+ }
2709
+ get hasAlarm() {
2710
+ return this.rooms.some((room) => room.hasAlarm);
2711
+ }
2712
+ get hasMedia() {
2713
+ return this.rooms.some((room) => room.hasMedia);
2714
+ }
2715
+ get occupied() {
2716
+ return this.rooms.some((room) => room.occupied);
2717
+ }
2718
+ };
2719
+ Object.defineProperty(Space2.prototype, "schema", {
2720
+ value: schema
2721
+ });
2722
+ Object.defineProperty(Space2.prototype, "validator", {
2723
+ get: function() {
2724
+ return validator;
2725
+ }
2726
+ });
2727
+ Object.defineProperty(Space2, "validProperties", {
2728
+ value: Object.keys(schema.properties)
2729
+ });
2730
+ function mapSpaceData(data) {
2731
+ var _a;
2732
+ const spaceData = cloneDeep(data);
2733
+ if ((_a = spaceData.rooms) == null ? void 0 : _a.length) {
2734
+ spaceData.rooms.map((room) => {
2735
+ if (typeof room === "string")
2736
+ return room;
2737
+ if (room instanceof Room2)
2738
+ return room;
2739
+ return new Room2(room);
2740
+ });
2741
+ }
2742
+ return spaceData;
2743
+ }
2744
+ module2.exports = Space2;
2745
+ }
2746
+ });
2747
+
2748
+ // src/schemas/ticket.json
2749
+ var require_ticket = __commonJS({
2750
+ "src/schemas/ticket.json"(exports2, module2) {
2751
+ module2.exports = {
2752
+ $schema: "http://json-schema.org/draft-07/schema",
2753
+ $id: "https://api.kohost.app/schemas/v3/ticket.json",
2754
+ title: "Ticket",
2755
+ description: "A ticket is a request for help from a user.",
2756
+ type: "object",
2757
+ properties: {
2758
+ id: {
2759
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2760
+ },
2761
+ conversation: {
2762
+ type: "array",
2763
+ default: [],
2764
+ items: {
2765
+ type: "object",
2766
+ additionalProperties: false,
2767
+ properties: {
2768
+ id: {
2769
+ type: "string"
2770
+ },
2771
+ user: {
2772
+ type: "string"
2773
+ },
2774
+ timestamp: {
2775
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
2776
+ },
2777
+ body: {
2778
+ type: "string"
2779
+ },
2780
+ readBy: {
2781
+ type: "array",
2782
+ default: [],
2783
+ items: {
2784
+ type: "string"
2785
+ }
2786
+ }
2787
+ },
2788
+ required: ["user", "id", "timestamp", "body"]
2789
+ }
2790
+ },
2791
+ requester: {
2792
+ type: "string"
2793
+ },
2794
+ assignedTo: {
2795
+ type: ["string", "null"]
2796
+ },
2797
+ status: {
2798
+ type: "string",
2799
+ enum: ["open", "pending", "solved", "closed"],
2800
+ default: "open"
2801
+ },
2802
+ tags: {
2803
+ type: "array",
2804
+ default: [],
2805
+ items: {
2806
+ type: "string"
2807
+ }
2808
+ },
2809
+ createdAt: {
2810
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
2811
+ },
2812
+ updatedAt: {
2813
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
2814
+ },
2815
+ solvedAt: {
2816
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
2817
+ },
2818
+ closedAt: {
2819
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
2820
+ }
2821
+ },
2822
+ required: [
2823
+ "id",
2824
+ "conversation",
2825
+ "requester",
2826
+ "status",
2827
+ "tags",
2828
+ "createdAt",
2829
+ "updatedAt"
2830
+ ],
2831
+ additionalProperties: false
2832
+ };
2833
+ }
2834
+ });
2835
+
2836
+ // src/Models/ticket.js
2837
+ var require_ticket2 = __commonJS({
2838
+ "src/Models/ticket.js"(exports2, module2) {
2839
+ var schemas = require_schema();
2840
+ var schema = require_ticket();
2841
+ var Kohost = require_kohost();
2842
+ var sortBy = require("lodash.sortby");
2843
+ var findLast = require("lodash.findlast");
2844
+ var { nanoid } = require("nanoid");
2845
+ schemas.add(schema);
2846
+ var validator = schemas.compile(schema);
2847
+ var Ticket2 = class extends Kohost {
2848
+ constructor(data) {
2849
+ super(data);
2850
+ }
2851
+ static generateMessageId(len = 16) {
2852
+ return nanoid(len);
2853
+ }
2854
+ };
2855
+ Object.defineProperty(Ticket2.prototype, "schema", {
2856
+ value: schema
2857
+ });
2858
+ Object.defineProperty(Ticket2.prototype, "validator", {
2859
+ get: function() {
2860
+ return validator;
2861
+ }
2862
+ });
2863
+ Object.defineProperty(Ticket2, "validProperties", {
2864
+ value: Object.keys(schema.properties)
2865
+ });
2866
+ Object.defineProperty(Ticket2.prototype, "responseTime", {
2867
+ get: function() {
2868
+ const conversation = this.conversation;
2869
+ const requester = this.requester;
2870
+ if (conversation.length === 0)
2871
+ return 0;
2872
+ const mapped = conversation.map((msg) => {
2873
+ if (typeof msg.timestamp === "string")
2874
+ msg.timestamp = new Date(msg.timestamp);
2875
+ return msg;
2876
+ });
2877
+ const sorted = sortBy(mapped, ["timestamp"]);
2878
+ const firstMsg = sorted.find((entry) => entry.user === requester);
2879
+ const firstResponse = sorted.find((entry) => entry.user !== requester);
2880
+ if (firstMsg && firstResponse) {
2881
+ const firstMsgTime = firstMsg.timestamp.getTime() / 1e3;
2882
+ const firstResponseTime = firstResponse.timestamp.getTime() / 1e3;
2883
+ return firstResponseTime - firstMsgTime;
2884
+ }
2885
+ return 0;
2886
+ }
2887
+ });
2888
+ Object.defineProperty(Ticket2.prototype, "resolutionTime", {
2889
+ get: function() {
2890
+ if (this.status !== "closed")
2891
+ return 0;
2892
+ const createdAt = this.createdAt.getTime() / 1e3;
2893
+ const solvedAt = this.solvedAt ? this.solvedAt.getTime() / 1e3 : this.updatedAt.getTime() / 1e3;
2894
+ return Math.abs(solvedAt - createdAt);
2895
+ }
2896
+ });
2897
+ Object.defineProperty(Ticket2.prototype, "lastResponder", {
2898
+ get: function() {
2899
+ const conversation = this.conversation;
2900
+ const requester = this.requester;
2901
+ const sorted = sortBy(conversation, ["timestamp"]);
2902
+ const lastFromNonRequester = findLast(sorted, function(c) {
2903
+ return c.user !== requester;
2904
+ });
2905
+ if (!lastFromNonRequester)
2906
+ return null;
2907
+ else
2908
+ return lastFromNonRequester.user;
2909
+ }
2910
+ });
2911
+ module2.exports = Ticket2;
2912
+ }
2913
+ });
2914
+
2915
+ // src/schemas/gateway.json
2916
+ var require_gateway = __commonJS({
2917
+ "src/schemas/gateway.json"(exports2, module2) {
2918
+ module2.exports = {
2919
+ $schema: "http://json-schema.org/draft-07/schema",
2920
+ $id: "https://api.kohost.app/schemas/v3/iotGateway.json",
2921
+ title: "IoT Gateway",
2922
+ description: "Any smart gateway that is an entrypoint for controlling devices",
2923
+ type: "object",
2924
+ properties: {
2925
+ id: {
2926
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/id"
2927
+ },
2928
+ type: {
2929
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/type"
2930
+ },
2931
+ supportedNotifications: {
2932
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/supportedNotifications"
2933
+ },
2934
+ notification: {
2935
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/notification"
2936
+ },
2937
+ status: {
2938
+ type: "string"
2939
+ },
2940
+ systemData: {
2941
+ $ref: "https://api.kohost.app/schemas/v3/definitions/device.json#/definitions/systemData"
2942
+ }
2943
+ },
2944
+ additionalProperties: false,
2945
+ required: ["id", "type", "systemData", "status"]
2946
+ };
2947
+ }
2948
+ });
2949
+
2950
+ // src/Models/gateway.js
2951
+ var require_gateway2 = __commonJS({
2952
+ "src/Models/gateway.js"(exports2, module2) {
2953
+ var schemas = require_schema();
2954
+ var schema = require_gateway();
2955
+ var Kohost = require_kohost();
2956
+ schemas.add(schema);
2957
+ var validator = schemas.compile(schema);
2958
+ var Gateway2 = class extends Kohost {
2959
+ constructor(data) {
2960
+ super(data);
2961
+ }
2962
+ };
2963
+ Object.defineProperty(Gateway2.prototype, "schema", {
2964
+ value: schema
2965
+ });
2966
+ Object.defineProperty(Gateway2.prototype, "validator", {
2967
+ get: function() {
2968
+ return validator;
2969
+ }
2970
+ });
2971
+ Object.defineProperty(Gateway2, "validProperties", {
2972
+ value: Object.keys(schema.properties)
2973
+ });
2974
+ module2.exports = Gateway2;
2975
+ }
2976
+ });
2977
+
2978
+ // src/schemas/product.json
2979
+ var require_product = __commonJS({
2980
+ "src/schemas/product.json"(exports2, module2) {
2981
+ module2.exports = {
2982
+ $schema: "http://json-schema.org/draft-07/schema",
2983
+ $id: "https://api.kohost.app/schemas/v3/product.json",
2984
+ title: "Product",
2985
+ type: "object",
2986
+ required: ["name", "description", "price", "currency"],
2987
+ properties: {
2988
+ id: {
2989
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
2990
+ },
2991
+ type: {
2992
+ type: "string"
2993
+ },
2994
+ name: {
2995
+ type: "string"
2996
+ },
2997
+ description: {
2998
+ string: "string"
2999
+ },
3000
+ price: {
3001
+ type: "number"
3002
+ },
3003
+ currency: {
3004
+ type: "string",
3005
+ description: "ISO 4217 format",
3006
+ minLength: 3,
3007
+ maxLength: 3
3008
+ },
3009
+ image: {
3010
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/file"
3011
+ },
3012
+ systemData: {
3013
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
3014
+ }
3015
+ }
3016
+ };
3017
+ }
3018
+ });
3019
+
3020
+ // src/Models/product.js
3021
+ var require_product2 = __commonJS({
3022
+ "src/Models/product.js"(exports2, module2) {
3023
+ var schemas = require_schema();
3024
+ var schema = require_product();
3025
+ var Kohost = require_kohost();
3026
+ schemas.add(schema);
3027
+ var validator = schemas.compile(schema);
3028
+ var Product2 = class extends Kohost {
3029
+ constructor(data) {
3030
+ super(data);
3031
+ }
3032
+ };
3033
+ Object.defineProperty(Product2.prototype, "schema", {
3034
+ value: schema
3035
+ });
3036
+ Object.defineProperty(Product2.prototype, "validator", {
3037
+ get: function() {
3038
+ return validator;
3039
+ }
3040
+ });
3041
+ Object.defineProperty(Product2, "validProperties", {
3042
+ value: Object.keys(schema.properties)
3043
+ });
3044
+ module2.exports = Product2;
3045
+ }
3046
+ });
3047
+
3048
+ // src/schemas/discoveredDevice.json
3049
+ var require_discoveredDevice = __commonJS({
3050
+ "src/schemas/discoveredDevice.json"(exports2, module2) {
3051
+ module2.exports = {
3052
+ $schema: "http://json-schema.org/draft-07/schema",
3053
+ $id: "https://api.kohost.app/schemas/v3/discoveredDevice.json",
3054
+ title: "Discovered Device",
3055
+ description: "A device that has been discovered by Kohost, but not yet added to the Kohost system.",
3056
+ type: "object",
3057
+ required: ["name", "deviceId", "driver", "deviceData"],
3058
+ properties: {
3059
+ id: {
3060
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
3061
+ },
3062
+ name: {
3063
+ type: "string"
3064
+ },
3065
+ deviceId: {
3066
+ type: "string"
3067
+ },
3068
+ type: {
3069
+ type: "string",
3070
+ enum: [
3071
+ "dimmer",
3072
+ "switch",
3073
+ "motionSensor",
3074
+ "thermostat",
3075
+ "lock",
3076
+ "camera",
3077
+ "courtesy",
3078
+ "source",
3079
+ "alarm",
3080
+ "windowCovering"
3081
+ ]
3082
+ },
3083
+ driver: {
3084
+ type: "string"
3085
+ },
3086
+ integrationId: {
3087
+ type: "string"
3088
+ },
3089
+ deviceData: {
3090
+ type: "object"
3091
+ }
3092
+ }
3093
+ };
3094
+ }
3095
+ });
3096
+
3097
+ // src/Models/discoveredDevice.js
3098
+ var require_discoveredDevice2 = __commonJS({
3099
+ "src/Models/discoveredDevice.js"(exports2, module2) {
3100
+ var schemas = require_schema();
3101
+ var schema = require_discoveredDevice();
3102
+ var Kohost = require_kohost();
3103
+ schemas.add(schema);
3104
+ var validator = schemas.compile(schema);
3105
+ var DiscoveredDevice2 = class extends Kohost {
3106
+ constructor(data) {
3107
+ super(data);
3108
+ }
3109
+ };
3110
+ Object.defineProperty(DiscoveredDevice2.prototype, "schema", {
3111
+ value: schema
3112
+ });
3113
+ Object.defineProperty(DiscoveredDevice2.prototype, "validator", {
3114
+ get: function() {
3115
+ return validator;
3116
+ }
3117
+ });
3118
+ Object.defineProperty(DiscoveredDevice2, "validProperties", {
3119
+ value: Object.keys(schema.properties)
3120
+ });
3121
+ module2.exports = DiscoveredDevice2;
3122
+ }
3123
+ });
3124
+
3125
+ // src/schemas/credential.json
3126
+ var require_credential = __commonJS({
3127
+ "src/schemas/credential.json"(exports2, module2) {
3128
+ module2.exports = {
3129
+ $schema: "http://json-schema.org/draft-07/schema",
3130
+ $id: "https://api.kohost.app/schemas/v3/credential.json",
3131
+ title: "Credential",
3132
+ type: "object",
3133
+ required: ["type", "credential", "expires"],
3134
+ properties: {
3135
+ id: {
3136
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
3137
+ },
3138
+ type: {
3139
+ type: "string",
3140
+ enum: ["verificationCode", "token"]
3141
+ },
3142
+ credential: {
3143
+ type: "string"
3144
+ },
3145
+ user: {
3146
+ type: "string"
3147
+ },
3148
+ userAgent: {
3149
+ type: "string"
3150
+ },
3151
+ expires: {
3152
+ string: "string"
3153
+ }
3154
+ }
3155
+ };
3156
+ }
3157
+ });
3158
+
3159
+ // src/Models/credential.js
3160
+ var require_credential2 = __commonJS({
3161
+ "src/Models/credential.js"(exports2, module2) {
3162
+ var schemas = require_schema();
3163
+ var schema = require_credential();
3164
+ var Kohost = require_kohost();
3165
+ schemas.add(schema);
3166
+ var validator = schemas.compile(schema);
3167
+ var Credential2 = class extends Kohost {
3168
+ constructor(data) {
3169
+ super(data);
3170
+ }
3171
+ };
3172
+ Object.defineProperty(Credential2.prototype, "schema", {
3173
+ value: schema
3174
+ });
3175
+ Object.defineProperty(Credential2.prototype, "validator", {
3176
+ get: function() {
3177
+ return validator;
3178
+ }
3179
+ });
3180
+ Object.defineProperty(Credential2, "validProperties", {
3181
+ value: Object.keys(schema.properties)
3182
+ });
3183
+ module2.exports = Credential2;
3184
+ }
3185
+ });
3186
+
3187
+ // src/schemas/shortLink.json
3188
+ var require_shortLink = __commonJS({
3189
+ "src/schemas/shortLink.json"(exports2, module2) {
3190
+ module2.exports = {
3191
+ $schema: "http://json-schema.org/draft-07/schema",
3192
+ $id: "https://api.kohost.app/schemas/v3/shortLink.json",
3193
+ title: "Short Link",
3194
+ type: "object",
3195
+ required: ["destination", "url"],
3196
+ properties: {
3197
+ id: {
3198
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
3199
+ },
3200
+ type: {
3201
+ type: "string",
3202
+ default: "shortLink"
3203
+ },
3204
+ title: {
3205
+ type: "string"
3206
+ },
3207
+ destination: {
3208
+ string: "string",
3209
+ format: "uri"
3210
+ },
3211
+ url: {
3212
+ string: "string",
3213
+ format: "uri"
3214
+ },
3215
+ systemData: {
3216
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/systemData"
3217
+ }
3218
+ }
3219
+ };
3220
+ }
3221
+ });
3222
+
3223
+ // src/Models/shortLink.js
3224
+ var require_shortLink2 = __commonJS({
3225
+ "src/Models/shortLink.js"(exports2, module2) {
3226
+ var schemas = require_schema();
3227
+ var schema = require_shortLink();
3228
+ var Kohost = require_kohost();
3229
+ schemas.add(schema);
3230
+ var validator = schemas.compile(schema);
3231
+ var ShortLink2 = class extends Kohost {
3232
+ constructor(data) {
3233
+ super(data);
3234
+ }
3235
+ };
3236
+ Object.defineProperty(ShortLink2.prototype, "schema", {
3237
+ value: schema
3238
+ });
3239
+ Object.defineProperty(ShortLink2.prototype, "validator", {
3240
+ get: function() {
3241
+ return validator;
3242
+ }
3243
+ });
3244
+ Object.defineProperty(ShortLink2, "validProperties", {
3245
+ value: Object.keys(schema.properties)
3246
+ });
3247
+ module2.exports = ShortLink2;
3248
+ }
3249
+ });
3250
+
3251
+ // src/schemas/admin/customer.json
3252
+ var require_customer = __commonJS({
3253
+ "src/schemas/admin/customer.json"(exports2, module2) {
3254
+ module2.exports = {
3255
+ $schema: "http://json-schema.org/draft-07/schema",
3256
+ $id: "https://api.kohost.app/schemas/v3/admin/customer.json",
3257
+ title: "Customer",
3258
+ type: "object",
3259
+ description: "A Kohost customer",
3260
+ required: ["accountNumber", "name"],
3261
+ properties: {
3262
+ id: {
3263
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
3264
+ },
3265
+ accountNumber: {
3266
+ type: "number",
3267
+ minimum: 1e4
3268
+ },
3269
+ name: {
3270
+ type: "string"
3271
+ },
3272
+ properties: {
3273
+ type: "array",
3274
+ items: {
3275
+ type: "string"
3276
+ }
3277
+ },
3278
+ createdAt: {
3279
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/createdAt"
3280
+ },
3281
+ updatedAt: {
3282
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/updatedAt"
3283
+ }
3284
+ }
3285
+ };
3286
+ }
3287
+ });
3288
+
3289
+ // src/Models/admin/customer.js
3290
+ var require_customer2 = __commonJS({
3291
+ "src/Models/admin/customer.js"(exports2, module2) {
3292
+ var schemas = require_schema();
3293
+ var schema = require_customer();
3294
+ var Kohost = require_kohost();
3295
+ schemas.add(schema);
3296
+ var validator = schemas.compile(schema);
3297
+ var Customer = class extends Kohost {
3298
+ constructor(data) {
3299
+ super(data);
3300
+ }
3301
+ };
3302
+ Object.defineProperty(Customer.prototype, "schema", {
3303
+ value: schema
3304
+ });
3305
+ Object.defineProperty(Customer.prototype, "validator", {
3306
+ get: function() {
3307
+ return validator;
3308
+ }
3309
+ });
3310
+ Object.defineProperty(Customer, "validProperties", {
3311
+ value: Object.keys(schema.properties)
3312
+ });
3313
+ module2.exports = Customer;
3314
+ }
3315
+ });
3316
+
3317
+ // src/schemas/admin/property.json
3318
+ var require_property = __commonJS({
3319
+ "src/schemas/admin/property.json"(exports2, module2) {
3320
+ module2.exports = {
3321
+ $schema: "http://json-schema.org/draft-07/schema",
3322
+ $id: "https://api.kohost.app/schemas/v3/admin/property.json",
3323
+ title: "Property",
3324
+ type: "object",
3325
+ description: "A property is a physical asset or building",
3326
+ required: ["id", "name", "type", "hostname"],
3327
+ properties: {
3328
+ id: {
3329
+ $ref: "https://api.kohost.app/schemas/v3/definitions/common.json#/definitions/id"
3330
+ },
3331
+ name: {
3332
+ type: "string"
3333
+ },
3334
+ type: {
3335
+ type: "string",
3336
+ enum: ["hospitality", "education", "commercial"]
3337
+ },
3338
+ timezone: {
3339
+ type: "string"
3340
+ },
3341
+ smsNumber: {
3342
+ type: "string"
3343
+ },
3344
+ hostname: {
3345
+ type: "string"
3346
+ },
3347
+ address: {
3348
+ type: "object",
3349
+ properties: {
3350
+ street: {
3351
+ type: "string"
3352
+ },
3353
+ city: {
3354
+ type: "string"
3355
+ },
3356
+ state: {
3357
+ type: "string"
3358
+ },
3359
+ zip: {
3360
+ type: "string"
3361
+ },
3362
+ country: {
3363
+ type: "string"
3364
+ }
3365
+ }
3366
+ },
3367
+ latitude: {
3368
+ type: "number"
3369
+ },
3370
+ longitude: {
3371
+ type: "number"
3372
+ },
3373
+ appManifest: {
3374
+ type: "object",
3375
+ properties: {
3376
+ name: {
3377
+ type: "string"
3378
+ },
3379
+ short_name: {
3380
+ type: "string"
3381
+ },
3382
+ scope: {
3383
+ type: "string"
3384
+ },
3385
+ start_url: {
3386
+ type: "string"
3387
+ },
3388
+ themeColor: {
3389
+ type: "string"
3390
+ },
3391
+ backgroundColor: {
3392
+ type: "string"
3393
+ },
3394
+ display: {
3395
+ type: "string",
3396
+ enum: ["fullscreen", "standalone", "minimal-ui", "browser"],
3397
+ default: "fullscreen"
3398
+ },
3399
+ orientation: {
3400
+ type: "string",
3401
+ enum: ["portrait", "landscape"],
3402
+ default: "portrait"
3403
+ },
3404
+ splash: {
3405
+ type: "object",
3406
+ properties: {
3407
+ src: {
3408
+ type: "string"
3409
+ },
3410
+ type: {
3411
+ type: "string"
3412
+ },
3413
+ sizes: {
3414
+ type: "string"
3415
+ }
3416
+ }
3417
+ },
3418
+ icons: {
3419
+ type: "array",
3420
+ items: {
3421
+ type: "object",
3422
+ properties: {
3423
+ src: {
3424
+ type: "string"
3425
+ },
3426
+ sizes: {
3427
+ type: "string"
3428
+ },
3429
+ type: {
3430
+ type: "string"
3431
+ }
3432
+ }
3433
+ }
3434
+ },
3435
+ logo: {
3436
+ type: "object",
3437
+ properties: {
3438
+ src: {
3439
+ type: "string"
3440
+ },
3441
+ type: {
3442
+ type: "string"
3443
+ },
3444
+ sizes: {
3445
+ type: "string"
3446
+ }
3447
+ }
3448
+ }
3449
+ },
3450
+ default: {
3451
+ name: "Kohost",
3452
+ short_name: "Kohost",
3453
+ start_url: "/",
3454
+ scope: "/",
3455
+ display: "fullscreen",
3456
+ orientation: "portrait",
3457
+ theme_color: "#1d1f22",
3458
+ background_color: "#1d1f22",
3459
+ icons: [
3460
+ {
3461
+ src: "https://cdn.kohost.app/defaultIcon.png",
3462
+ sizes: "512x512",
3463
+ type: "image/png"
3464
+ }
3465
+ ],
3466
+ splash: {
3467
+ src: "https://cdn.kohost.app/defaultSplash.jpg",
3468
+ sizes: "1500x800",
3469
+ type: "image/jpg"
3470
+ },
3471
+ logo: {
3472
+ src: "https://cdn.kohost.app/defaultLogo.png",
3473
+ sizes: "300x75",
3474
+ type: "image/png"
3475
+ }
3476
+ }
3477
+ },
3478
+ appFeatures: {
3479
+ type: "object",
3480
+ properties: {
3481
+ RoomControl: {},
3482
+ CheckIn: {},
3483
+ CheckOut: {},
3484
+ Concierge: {},
3485
+ Elevator: {}
3486
+ },
3487
+ additionalProperties: false,
3488
+ default: {
3489
+ RoomControl: {}
3490
+ }
3491
+ },
3492
+ credentials: {
3493
+ type: "object",
3494
+ additionalProperties: true
3495
+ },
3496
+ additionalProperties: false
3497
+ }
3498
+ };
3499
+ }
3500
+ });
3501
+
3502
+ // src/Models/admin/property.js
3503
+ var require_property2 = __commonJS({
3504
+ "src/Models/admin/property.js"(exports2, module2) {
3505
+ var schemas = require_schema();
3506
+ var schema = require_property();
3507
+ var Kohost = require_kohost();
3508
+ schemas.add(schema);
3509
+ var validator = schemas.compile(schema);
3510
+ var Property = class extends Kohost {
3511
+ constructor(data) {
3512
+ super(data);
3513
+ }
3514
+ };
3515
+ Object.defineProperty(Property.prototype, "schema", {
3516
+ value: schema
3517
+ });
3518
+ Object.defineProperty(Property.prototype, "validator", {
3519
+ get: function() {
3520
+ return validator;
3521
+ }
3522
+ });
3523
+ Object.defineProperty(Property, "validProperties", {
3524
+ value: Object.keys(schema.properties)
3525
+ });
3526
+ module2.exports = Property;
3527
+ }
3528
+ });
3529
+
3530
+ // src/Models/index.js
3531
+ var Switch = require_switch2();
3532
+ var Alarm = require_alarm2();
3533
+ var Dimmer = require_dimmer2();
3534
+ var Lock = require_lock2();
3535
+ var Thermostat = require_thermostat2();
3536
+ var WindowCovering = require_windowCovering2();
3537
+ var Identification = require_identification2();
3538
+ var User = require_user2();
3539
+ var Courtesy = require_courtesy2();
3540
+ var Camera = require_camera2();
3541
+ var MotionSensor = require_motionSensor2();
3542
+ var MediaSource = require_mediaSource2();
3543
+ var Room = require_room2();
3544
+ var Reservation = require_reservation2();
3545
+ var Application = require_application2();
3546
+ var Space = require_space2();
3547
+ var Ticket = require_ticket2();
3548
+ var Scene = require_scene2();
3549
+ var Gateway = require_gateway2();
3550
+ var Product = require_product2();
3551
+ var DiscoveredDevice = require_discoveredDevice2();
3552
+ var Credential = require_credential2();
3553
+ var ShortLink = require_shortLink2();
3554
+ var AdminCustomer = require_customer2();
3555
+ var AdminProperty = require_property2();
3556
+ module.exports = {
3557
+ Admin: {
3558
+ Customer: AdminCustomer,
3559
+ Property: AdminProperty
3560
+ },
3561
+ Gateway,
3562
+ Switch,
3563
+ Alarm,
3564
+ Dimmer,
3565
+ Lock,
3566
+ Courtesy,
3567
+ Camera,
3568
+ MotionSensor,
3569
+ Thermostat,
3570
+ WindowCovering,
3571
+ MediaSource,
3572
+ Identification,
3573
+ Product,
3574
+ User,
3575
+ Room,
3576
+ Application,
3577
+ Space,
3578
+ Ticket,
3579
+ Scene,
3580
+ DiscoveredDevice,
3581
+ Reservation,
3582
+ Credential,
3583
+ ShortLink
3584
+ };